var allChecked=false;

function addImage(fileUrl) {
	findObj('previewImage').src = fileUrl;
	findObj('imageName').value = fileUrl;
}

function addRows(parent, quantity) {
	var qty			= document.getElementById(quantity).value;
	var rowCount	= document.getElementById('rowCount').value;
	var parentNode	= document.getElementById(parent);

	qty = (qty >= 1)  ? qty: 1;
	qty = (qty <= 20) ? qty: 20;

	for (i=0; i<qty; i++) {
		var newRow		= document.createElement('tr');
		newRow.setAttribute('id', 'orderRow_'+rowCount);
		parentNode.appendChild(newRow);
		newRow.innerHTML = '<td valign="top"><a href="" onclick="return delRow(\'orderRow_'+rowCount+'\')"><img src="admin/images/del.gif" alt="" /></a></td><td valign="top"><input type="hidden" name="id['+rowCount+']" value="" /><input type="text" name="prodName['+rowCount+']" class="textbox" value="" /></td><td valign="top"><input name="productCode['+rowCount+']" type="text" class="textbox" value="" size="15" /></td><td valign="top"><textarea name="product_options['+rowCount+']" cols="30" rows="1" class="textbox"></textarea></td><td align="center" valign="top"><input name="quantity['+rowCount+']" type="text" class="textbox" style="text-align:center;" value="" size="3" /></td><td align="center" valign="top"><input name="price['+rowCount+']" type="text" class="textbox" style="text-align:right;" value="" size="7" /></td>';
		rowCount++;
	}
	document.getElementById('rowCount').value = rowCount;
	return false;
}

function checkAll(fieldName,val) {
	var checks = findObj(fieldName)
	for (i=0; i<checks.length; i++) {
		if(val == 'true') {
			checks[i].checked = true;
		} else {
			checks[i].checked = false;
		}
	}
}

function checkUncheck(parent, className) {
	var elements = $(parent).getElementsByClassName(className);
	for (i=0;i<elements.length;i++) {
		var ele = elements[i];
		(allChecked==false) ? ele.checked='checked' : ele.checked='';
	}
	(allChecked!=true) ? allChecked=true : allChecked=false;
	return false;
}

function compareInputbox(idNo) {
	if (findObj('custom_'+idNo) != findObj('default_'+idNo)) {
		// show revert buttons
		findObj('revertLink_'+idNo).style.display = '';
		findObj('revAllLink').style.display='';
		var tds = findObj('tr_'+idNo).getElementsByTagName('td');
		for (var i = 0; i <= 2; i++) {
			tds[i].className = 'tdModified';
		}
	}
}

function decision(message, url) {
	if (confirm(message)) {
		location.href = url;
	} else {
		return false;
	}
}

function delRow(element) {
	var node	= document.getElementById(element);
	var parent	= node.parentNode;
	parent.removeChild(node);
	return false;
}

function disableSubmit(obj,msg) {
	obj.value=msg;
	obj.disabled=true;
	obj.disabled=true;
	obj.className='submitDisabled';
}

function displayStatusMsg(msgStr) { //v1.0
	status=msgStr;
	document.returnValue = true;
}

function editVal(id,val) {
	findObj(id).value = val;
}

function findObj(n, d) {
	var p,i,x;
	if (!d) d=document;
	if ((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if (!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for (i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
	if (!x && d.getElementById) x=d.getElementById(n);
	return x;
}

function flashBasket(flashes) {
	setTimeout("flash("+flashes+")", 500);
}

function flash(flashes) {
	var targetBtn = findObj('flashBasket');
	if (flashes<=0) return;
	if ((flashes%2) == 0) {
		targetBtn.className="flashBasket";
	} else {
 		targetBtn.className="txtviewCart";
	}
	setTimeout("flash("+(flashes-1)+")", 300);
	return;
}

function getImage(imageName) {
	var img	= findObj('img');
	img.src	= img.src.replace(/language\/[a-z\-_]{2,5}\/flag.gif/gi, imageName);
}

function setMainImage(imageName) {
	findObj('img').src = imageName;
}

function goToURL() { //v3.0
  var i, args=goToURL.arguments; document.returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function jumpMenu(target, object, restore) {
	eval(target+".location='"+object.options[object.selectedIndex].value+"'");
	if (restore) object.selectedIndex=0;
}

function menuBlinds() {

}

function openPopUp(url, windowName, w, h, scrollbar) {
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scrollbar+',resizable=1';
	win = window.open(url, windowName, winprops);
	if (parseInt(navigator.appVersion) >= 4) {
		win.window.focus();
	}
}

function resizeOuterTo(w,h) {
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			top.outerWidth=w;
			top.outerHeight=h;
		} else {
			top.resizeTo(w,h);
		}
	}
}

function revert(idNo,className) {
	var tds = findObj('tr_'+idNo).getElementsByTagName('td');
	for (var i = 0; i <= 2; i++) {
		tds[i].className = className;
	}
	findObj('custom_'+idNo).value = findObj('default_'+idNo).value;
	findObj('revertLink_'+idNo).style.display = 'none';
}

function revertAll(maxId) {
	for (var idNo = 1; idNo < maxId; idNo++) {
		// find array of TD's
		var tds = findObj('tr_'+idNo).getElementsByTagName('td');
		var binary = idNo.toString(2);
		for (var j = 0; j <= 2; j++) {
			// restore class
			if (binary.charAt(binary.length - 1) == "1") {
				tds[j].className = 'tdOdd';
			} else {
				tds[j].className = 'tdEven';
			}
		}
		// set default value back
		findObj('custom_'+idNo).value = findObj('default_'+idNo).value;
		// hide revert button
		findObj('revertLink_'+idNo).style.display = 'none';
	}
	// hide revert all button
	findObj('revAllLink').style.display='none';
}

function setTextOfLayer(objName,x,newText) {
	if ((obj=findObj(objName))!=null) with (obj)
		if (document.layers) {document.write(unescape(newText)); document.close();}
		else innerHTML = unescape(newText);
}

function submitDoc(formName) {
	var obj=findObj(formName);
	if (obj!=null) {
		obj.submit();
	} else {
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}
}

function reloadPage(init) {  //reloads the window if Nav4 resized
	if (init==true) with (navigator) {
		if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    		document.pgW=innerWidth; document.pgH=innerHeight;
			onresize=reloadPage;
		}
	} else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);

function showHideLayers() { //v6.0
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function stars(rating, pathImg) {
	/* Positive Stars */
	for (var i = 0; i <= rating; i++) {
		if (i>0) findObj("star"+i).src = pathImg+'1.gif';
	}
	/* Negative Stars */
	for (var i = rating+1; i <= 5; i++) {
		findObj("star"+i).src = pathImg+'0.gif';
	}
	findObj('rating_val').value=rating;
}

function toggleReg() {
	var password = findObj('password');
	var passwordConf = findObj('passwordConf');
	if (password.disabled == false && passwordConf.disabled==false) {
		password.disabled=true;
		passwordConf.disabled=true;
		password.className="textboxDisabled";
		passwordConf.className="textboxDisabled";
	} else {
		password.disabled=false;
		passwordConf.disabled=false;
		password.className="textbox";
		passwordConf.className="textbox";
	}
	password.value="";
	passwordConf.value="";
}

function toggleProdStatus(i,messageRemove, messageNotRemoved,removeImgSrc,noRemoveImgSrc){
	if(findObj('delId['+i+']').value==1) {
		var result = false;
		var className = 'textbox';
		findObj('del['+i+']').src = removeImgSrc;
		findObj('delId['+i+']').value = 0;
		// change class
		findObj('prodName['+i+']').className = "textbox";
		findObj('productCode['+i+']').className = "textbox";
		findObj('product_options['+i+']').className = "textbox";
		findObj('quantity['+i+']').className = "textbox";
		findObj('price['+i+']').className = "textbox";
		alert(messageNotRemoved);
	} else {
		var result = true;
		var className = 'textboxDisabled';
		findObj('del['+i+']').src = noRemoveImgSrc;
		findObj('delId['+i+']').value = 1;
		// change class
		findObj('prodName['+i+']').className = "textboxDisabled";
		findObj('productCode['+i+']').className = "textboxDisabled";
		findObj('product_options['+i+']').className = "textboxDisabled";
		findObj('quantity['+i+']').className = "textboxDisabled";
		findObj('price['+i+']').className = "textboxDisabled";
		alert(messageRemove);
	}

	findObj('prodName['+i+']').disabled = result;
    findObj('prodName['+i+']').className = className;

	findObj('productCode['+i+']').disabled = result;
	findObj('productCode['+i+']').className = className;

	findObj('product_options['+i+']').disabled = result;
	findObj('product_options['+i+']').className = className;

	findObj('quantity['+i+']').disabled = result;
	findObj('quantity['+i+']').className = className;

	findObj('price['+i+']').disabled = result;
	findObj('price['+i+']').className = className;
}


function toggleProductStatus() {
	return false;
}

function goUrl(element) {
	var url = document.getElementById(element).options[document.getElementById(element).selectedIndex].value;
	window.location = url;
}



/* Start Cross-Browser DHTML Menu */
function showSubMenu() {
	var objThis = this;
	for (var i = 0; i  < objThis.childNodes.length; i++) {
		if (objThis.childNodes.item(i).nodeName == "UL")	{
			objThis.childNodes.item(i).style.display = "block";
		}
	}
}

function hideSubMenu() {
	var objThis = this;
	for (var i = 0; i  < objThis.childNodes.length; i++) {
		if (objThis.childNodes.item(i).nodeName == "UL") {
			objThis.childNodes.item(i).style.display = "none";
			return;
		}
	}
}

/* this is the cause of the highly annoying flashing submenu problem
function initialiseMenu() {
	var objLICollection = document.body.getElementsByTagName("LI");
	for (var i = 0; i < objLICollection.length; i++) {
		var objLI = objLICollection[i];
		for (var j = 0; j  < objLI.childNodes.length; j++) {
			if(objLI.childNodes.item(j).nodeName == "UL") {
				objLI.onClick=function({toggle(this)});
				objLI.onmouseout=hideSubMenu;
				for (var j = 0; j  < objLI.childNodes.length; j++) {
					if(objLI.childNodes.item(j).nodeName == "A") {
						objLI.childNodes.item(j).className = "hassubmenu";
					}
				}
			}
		}
	}
}
*/
/* End Cross-Browser DHTML Menu */

/* New Options code */
function optionEdit(assign_id, optionData) {
	var data		= optionData.split('|');
	var elements	= $('opt_mid').getElementsByTagName('option');
	for (i=0; i<elements.length; i++) {
		elements[i].removeAttribute('selected');

		if (data[1] == '0') {
			if (elements[i].value == data[0] && elements[i].getAttribute('class') == 'top') {
				elements[i].setAttribute('selected', 'selected');
				elements[i].selected = true;
			}
		} else {
			if (elements[i].value == data[1] && elements[i].getAttribute('class') == 'sub') {
				elements[i].setAttribute('selected', 'selected');
				elements[i].selected = true;
			}
		}
	}
	$('opt_price').value = data[2];
	$('opt_assign_id').value = assign_id;

	optionRemove(assign_id, true);
}

function optionRemoveTemp(element) {
	var object = $(element).parentNode
	$('options_added').removeChild(object);
}

function optionRemove(id, preserve) {
	$('option_'+id).remove();
	if (!preserve) {
		new Insertion.Bottom($('options_added'), '<input type="hidden" name="option_remove[]" value="'+id+'"/>');
	}
}

function optionAdd() {

	var assign_id = $('opt_assign_id').value;

	var opt_top_title = $('opt_mid').options[$('opt_mid').selectedIndex].parentNode.getAttribute('label');
	var opt_mid_title = $('opt_mid').options[$('opt_mid').selectedIndex].innerHTML;

	var opt_mid_value	= $('opt_mid').options[$('opt_mid').selectedIndex].value;
	var opt_top_value	= $('opt_mid').options[$('opt_mid').selectedIndex].parentNode.id;

	var opt_price	= $('opt_price').value;
	opt_price		= (!opt_price) ? 0.00 :  opt_price;

	if (opt_top_value != '' && opt_mid_value != '') {
		if (assign_id != '0') {
			var method	= 'option_edit['+assign_id+']';
			$('opt_assign_id').value = '0';
		} else {
			var method	= 'option_add[]';
		}
		if (opt_top_title == null) opt_top_title = 'Custom';
		var hidden = '<input type="hidden" name="'+method+'" value="'+opt_top_value+'|'+opt_mid_value+'|'+opt_price+'"/>';
		new Insertion.Bottom('options_added', '<div style="clear: right;">'+hidden+'<span style="float: right;"><a href="#" onclick="optionRemoveTemp(this.parentNode); return false;"><img src="images/icons/delete.png" alt="delete" /></a></span><strong>'+opt_top_title+'</strong>: '+opt_mid_title+' ('+opt_price+')</div>');
		$('opt_price').value = '0.00';
	}
}

function bookmarksite(title,url){
    if (window.sidebar) // firefox
        window.sidebar.addPanel(title, url, "");
    else if(window.opera && window.print){ // opera
        var elem = document.createElement('a');
        elem.setAttribute('href',url);
        elem.setAttribute('title',title);
        elem.setAttribute('rel','sidebar');
        elem.click();
    }
    else if(document.all)// ie
        window.external.AddFavorite(url, title);
}

function updateCounty(theForm) {
		var NumState = theForm.county_sel.options.length;
		var CurrentCountry = '';
		while(NumState > 0) {
		NumState--;
		theForm.county_sel.options[NumState] = null;
	}
	CurrentCountry = theForm.country.options[theForm.country.selectedIndex].value;
  if (CurrentCountry == "1") {

    theForm.county_sel.options[0] = new Option("", "");

  } else if (CurrentCountry == "13") {

    theForm.county_sel.options[0] = new Option("Australian Capital T..", "Australian Capital T..");
    theForm.county_sel.options[1] = new Option("New South Wales", "New South Wales");
    theForm.county_sel.options[2] = new Option("Northern Territory", "Northern Territory");
    theForm.county_sel.options[3] = new Option("Queensland", "Queensland");
    theForm.county_sel.options[4] = new Option("South Australia", "South Australia");
    theForm.county_sel.options[5] = new Option("Tasmania", "Tasmania");
    theForm.county_sel.options[6] = new Option("Victoria", "Victoria");
    theForm.county_sel.options[7] = new Option("Western Australia", "Western Australia");

  } else if (CurrentCountry == "14") {

    theForm.county_sel.options[0] = new Option("Burgenland", "Burgenland");
    theForm.county_sel.options[1] = new Option("Kärnten", "Kärnten");
    theForm.county_sel.options[2] = new Option("NiederÖsterreich", "NiederÖsterreich");
    theForm.county_sel.options[3] = new Option("OberÖsterreich", "OberÖsterreich");
    theForm.county_sel.options[4] = new Option("Salzburg", "Salzburg");
    theForm.county_sel.options[5] = new Option("Steiermark", "Steiermark");
    theForm.county_sel.options[6] = new Option("Tirol", "Tirol");
    theForm.county_sel.options[7] = new Option("Voralberg", "Voralberg");
    theForm.county_sel.options[8] = new Option("Wien", "Wien");

  } else if (CurrentCountry == "38") {

    theForm.county_sel.options[0] = new Option("Alberta", "Alberta");
    theForm.county_sel.options[1] = new Option("British Columbia", "British Columbia");
    theForm.county_sel.options[2] = new Option("Manitoba", "Manitoba");
    theForm.county_sel.options[3] = new Option("New Brunswick", "New Brunswick");
    theForm.county_sel.options[4] = new Option("Newfoundland", "Newfoundland");
    theForm.county_sel.options[5] = new Option("Northwest Territorie..", "Northwest Territorie..");
    theForm.county_sel.options[6] = new Option("Nova Scotia", "Nova Scotia");
    theForm.county_sel.options[7] = new Option("Nunavut", "Nunavut");
    theForm.county_sel.options[8] = new Option("Ontario", "Ontario");
    theForm.county_sel.options[9] = new Option("Prince Edward Island", "Prince Edward Island");
    theForm.county_sel.options[10] = new Option("Quebec", "Quebec");
    theForm.county_sel.options[11] = new Option("Saskatchewan", "Saskatchewan");
    theForm.county_sel.options[12] = new Option("Yukon Territory", "Yukon Territory");

  } else if (CurrentCountry == "80") {

    theForm.county_sel.options[0] = new Option("Baden-Württemberg", "Baden-Württemberg");
    theForm.county_sel.options[1] = new Option("Bayern", "Bayern");
    theForm.county_sel.options[2] = new Option("Berlin", "Berlin");
    theForm.county_sel.options[3] = new Option("Brandenburg", "Brandenburg");
    theForm.county_sel.options[4] = new Option("Bremen", "Bremen");
    theForm.county_sel.options[5] = new Option("Hamburg", "Hamburg");
    theForm.county_sel.options[6] = new Option("Hessen", "Hessen");
    theForm.county_sel.options[7] = new Option("Mecklenburg-Vorpomme..", "Mecklenburg-Vorpomme..");
    theForm.county_sel.options[8] = new Option("Niedersachsen", "Niedersachsen");
    theForm.county_sel.options[9] = new Option("Nordrhein-Westfalen", "Nordrhein-Westfalen");
    theForm.county_sel.options[10] = new Option("Rheinland-Pfalz", "Rheinland-Pfalz");
    theForm.county_sel.options[11] = new Option("Saarland", "Saarland");
    theForm.county_sel.options[12] = new Option("Sachsen", "Sachsen");
    theForm.county_sel.options[13] = new Option("Sachsen-Anhalt", "Sachsen-Anhalt");
    theForm.county_sel.options[14] = new Option("Schleswig-Holstein", "Schleswig-Holstein");
    theForm.county_sel.options[15] = new Option("Thüringen", "Thüringen");

  } else if (CurrentCountry == "103") {

    theForm.county_sel.options[0] = new Option("Carlow", "Carlow");
    theForm.county_sel.options[1] = new Option("Cavan", "Cavan");
    theForm.county_sel.options[2] = new Option("Clare", "Clare");
    theForm.county_sel.options[3] = new Option("Cork", "Cork");
    theForm.county_sel.options[4] = new Option("Donegal", "Donegal");
    theForm.county_sel.options[5] = new Option("Dublin", "Dublin");
    theForm.county_sel.options[6] = new Option("Galway", "Galway");
    theForm.county_sel.options[7] = new Option("Kerry", "Kerry");
    theForm.county_sel.options[8] = new Option("Kildare", "Kildare");
    theForm.county_sel.options[9] = new Option("Kilkenny", "Kilkenny");
    theForm.county_sel.options[10] = new Option("Laoighis", "Laoighis");
    theForm.county_sel.options[11] = new Option("Leitrim", "Leitrim");
    theForm.county_sel.options[12] = new Option("Limerick", "Limerick");
    theForm.county_sel.options[13] = new Option("Longford", "Longford");
    theForm.county_sel.options[14] = new Option("Louth", "Louth");
    theForm.county_sel.options[15] = new Option("Mayo", "Mayo");
    theForm.county_sel.options[16] = new Option("Meath", "Meath");
    theForm.county_sel.options[17] = new Option("Monaghan", "Monaghan");
    theForm.county_sel.options[18] = new Option("Offaly", "Offaly");
    theForm.county_sel.options[19] = new Option("Roscommon", "Roscommon");
    theForm.county_sel.options[20] = new Option("Sligo", "Sligo");
    theForm.county_sel.options[21] = new Option("Tipperary", "Tipperary");
    theForm.county_sel.options[22] = new Option("Waterford", "Waterford");
    theForm.county_sel.options[23] = new Option("Westmeath", "Westmeath");
    theForm.county_sel.options[24] = new Option("Wexford", "Wexford");
    theForm.county_sel.options[25] = new Option("Wicklow", "Wicklow");

  } else if (CurrentCountry == "150") {

    theForm.county_sel.options[0] = new Option("Drenthe", "Drenthe");
    theForm.county_sel.options[1] = new Option("Flevoland", "Flevoland");
    theForm.county_sel.options[2] = new Option("Friesland", "Friesland");
    theForm.county_sel.options[3] = new Option("Gelderland", "Gelderland");
    theForm.county_sel.options[4] = new Option("Groningen", "Groningen");
    theForm.county_sel.options[5] = new Option("Limburg", "Limburg");
    theForm.county_sel.options[6] = new Option("Noord-Brabant", "Noord-Brabant");
    theForm.county_sel.options[7] = new Option("Noord-Holland", "Noord-Holland");
    theForm.county_sel.options[8] = new Option("Overijssel", "Overijssel");
    theForm.county_sel.options[9] = new Option("Utrecht", "Utrecht");
    theForm.county_sel.options[10] = new Option("Zeeland", "Zeeland");
    theForm.county_sel.options[11] = new Option("Zuid-Holland", "Zuid-Holland");

  } else if (CurrentCountry == "199") {

    theForm.county_sel.options[0] = new Option("A Coruña", "A Coruña");
    theForm.county_sel.options[1] = new Option("Alava", "Alava");
    theForm.county_sel.options[2] = new Option("Albacete", "Albacete");
    theForm.county_sel.options[3] = new Option("Alicante", "Alicante");
    theForm.county_sel.options[4] = new Option("Almeria", "Almeria");
    theForm.county_sel.options[5] = new Option("Asturias", "Asturias");
    theForm.county_sel.options[6] = new Option("Avila", "Avila");
    theForm.county_sel.options[7] = new Option("Badajoz", "Badajoz");
    theForm.county_sel.options[8] = new Option("Baleares", "Baleares");
    theForm.county_sel.options[9] = new Option("Barcelona", "Barcelona");
    theForm.county_sel.options[10] = new Option("Burgos", "Burgos");
    theForm.county_sel.options[11] = new Option("Caceres", "Caceres");
    theForm.county_sel.options[12] = new Option("Cadiz", "Cadiz");
    theForm.county_sel.options[13] = new Option("Cantabria", "Cantabria");
    theForm.county_sel.options[14] = new Option("Castellon", "Castellon");
    theForm.county_sel.options[15] = new Option("Ceuta", "Ceuta");
    theForm.county_sel.options[16] = new Option("Ciudad Real", "Ciudad Real");
    theForm.county_sel.options[17] = new Option("Cordoba", "Cordoba");
    theForm.county_sel.options[18] = new Option("Cuenca", "Cuenca");
    theForm.county_sel.options[19] = new Option("Girona", "Girona");
    theForm.county_sel.options[20] = new Option("Granada", "Granada");
    theForm.county_sel.options[21] = new Option("Guadalajara", "Guadalajara");
    theForm.county_sel.options[22] = new Option("Guipuzcoa", "Guipuzcoa");
    theForm.county_sel.options[23] = new Option("Huelva", "Huelva");
    theForm.county_sel.options[24] = new Option("Huesca", "Huesca");
    theForm.county_sel.options[25] = new Option("Jaen", "Jaen");
    theForm.county_sel.options[26] = new Option("La Rioja", "La Rioja");
    theForm.county_sel.options[27] = new Option("Las Palmas", "Las Palmas");
    theForm.county_sel.options[28] = new Option("Leon", "Leon");
    theForm.county_sel.options[29] = new Option("Lleida", "Lleida");
    theForm.county_sel.options[30] = new Option("Lugo", "Lugo");
    theForm.county_sel.options[31] = new Option("Madrid", "Madrid");
    theForm.county_sel.options[32] = new Option("Malaga", "Malaga");
    theForm.county_sel.options[33] = new Option("Melilla", "Melilla");
    theForm.county_sel.options[34] = new Option("Murcia", "Murcia");
    theForm.county_sel.options[35] = new Option("Navarra", "Navarra");
    theForm.county_sel.options[36] = new Option("Ourense", "Ourense");
    theForm.county_sel.options[37] = new Option("Palencia", "Palencia");
    theForm.county_sel.options[38] = new Option("Pontevedra", "Pontevedra");
    theForm.county_sel.options[39] = new Option("Salamanca", "Salamanca");
    theForm.county_sel.options[40] = new Option("Santa Cruz de Teneri..", "Santa Cruz de Teneri..");
    theForm.county_sel.options[41] = new Option("Segovia", "Segovia");
    theForm.county_sel.options[42] = new Option("Sevilla", "Sevilla");
    theForm.county_sel.options[43] = new Option("Soria", "Soria");
    theForm.county_sel.options[44] = new Option("Tarragona", "Tarragona");
    theForm.county_sel.options[45] = new Option("Teruel", "Teruel");
    theForm.county_sel.options[46] = new Option("Toledo", "Toledo");
    theForm.county_sel.options[47] = new Option("Valencia", "Valencia");
    theForm.county_sel.options[48] = new Option("Valladolid", "Valladolid");
    theForm.county_sel.options[49] = new Option("Vizcaya", "Vizcaya");
    theForm.county_sel.options[50] = new Option("Zamora", "Zamora");
    theForm.county_sel.options[51] = new Option("Zaragoza", "Zaragoza");

  } else if (CurrentCountry == "206") {

    theForm.county_sel.options[0] = new Option("Aargau", "Aargau");
    theForm.county_sel.options[1] = new Option("Appenzell Ausserrhod..", "Appenzell Ausserrhod..");
    theForm.county_sel.options[2] = new Option("Appenzell Innerrhode..", "Appenzell Innerrhode..");
    theForm.county_sel.options[3] = new Option("Basel-Landschaft", "Basel-Landschaft");
    theForm.county_sel.options[4] = new Option("Basel-Stadt", "Basel-Stadt");
    theForm.county_sel.options[5] = new Option("Bern", "Bern");
    theForm.county_sel.options[6] = new Option("Freiburg", "Freiburg");
    theForm.county_sel.options[7] = new Option("Genf", "Genf");
    theForm.county_sel.options[8] = new Option("Glarus", "Glarus");
    theForm.county_sel.options[9] = new Option("Graubünden", "Graubünden");
    theForm.county_sel.options[10] = new Option("Jura", "Jura");
    theForm.county_sel.options[11] = new Option("Luzern", "Luzern");
    theForm.county_sel.options[12] = new Option("Neuenburg", "Neuenburg");
    theForm.county_sel.options[13] = new Option("Nidwalden", "Nidwalden");
    theForm.county_sel.options[14] = new Option("Obwalden", "Obwalden");
    theForm.county_sel.options[15] = new Option("Schaffhausen", "Schaffhausen");
    theForm.county_sel.options[16] = new Option("Schwyz", "Schwyz");
    theForm.county_sel.options[17] = new Option("Solothurn", "Solothurn");
    theForm.county_sel.options[18] = new Option("St. Gallen", "St. Gallen");
    theForm.county_sel.options[19] = new Option("Tessin", "Tessin");
    theForm.county_sel.options[20] = new Option("Thurgau", "Thurgau");
    theForm.county_sel.options[21] = new Option("Uri", "Uri");
    theForm.county_sel.options[22] = new Option("Waadt", "Waadt");
    theForm.county_sel.options[23] = new Option("Wallis", "Wallis");
    theForm.county_sel.options[24] = new Option("Zürich", "Zürich");
    theForm.county_sel.options[25] = new Option("Zug", "Zug");

  } else if (CurrentCountry == "225") {

    theForm.county_sel.options[0] = new Option("Aberdeenshire", "Aberdeenshire");
    theForm.county_sel.options[1] = new Option("Anglesey", "Anglesey");
    theForm.county_sel.options[2] = new Option("Angus", "Angus");
    theForm.county_sel.options[3] = new Option("Antrim", "Antrim");
    theForm.county_sel.options[4] = new Option("Argyll", "Argyll");
    theForm.county_sel.options[5] = new Option("Armagh", "Armagh");
    theForm.county_sel.options[6] = new Option("Avon", "Avon");
    theForm.county_sel.options[7] = new Option("Ayrshire", "Ayrshire");
    theForm.county_sel.options[8] = new Option("Banffshire", "Banffshire");
    theForm.county_sel.options[9] = new Option("Bedfordshire", "Bedfordshire");
    theForm.county_sel.options[10] = new Option("Berkshire", "Berkshire");
    theForm.county_sel.options[11] = new Option("Berwickshire", "Berwickshire");
    theForm.county_sel.options[12] = new Option("Brecknockshire", "Brecknockshire");
    theForm.county_sel.options[13] = new Option("Buckinghamshire", "Buckinghamshire");
    theForm.county_sel.options[14] = new Option("Bute", "Bute");
    theForm.county_sel.options[15] = new Option("Caernarfonshire", "Caernarfonshire");
    theForm.county_sel.options[16] = new Option("Caithness", "Caithness");
    theForm.county_sel.options[17] = new Option("Cambridgeshire", "Cambridgeshire");
    theForm.county_sel.options[18] = new Option("Cardiganshire", "Cardiganshire");
    theForm.county_sel.options[19] = new Option("Carmarthenshire", "Carmarthenshire");
    theForm.county_sel.options[20] = new Option("Cheshire", "Cheshire");
    theForm.county_sel.options[21] = new Option("Clackmannanshire", "Clackmannanshire");
    theForm.county_sel.options[22] = new Option("Cleveland", "Cleveland");
    theForm.county_sel.options[23] = new Option("Clwyd", "Clwyd");
    theForm.county_sel.options[24] = new Option("Cornwall", "Cornwall");
    theForm.county_sel.options[25] = new Option("County Durham", "County Durham");
    theForm.county_sel.options[26] = new Option("Cromartyshire", "Cromartyshire");
    theForm.county_sel.options[27] = new Option("Cumberland", "Cumberland");
    theForm.county_sel.options[28] = new Option("Cumbria", "Cumbria");
    theForm.county_sel.options[29] = new Option("Denbighshire", "Denbighshire");
    theForm.county_sel.options[30] = new Option("Derbyshire", "Derbyshire");
    theForm.county_sel.options[31] = new Option("Devon", "Devon");
    theForm.county_sel.options[32] = new Option("Dorset", "Dorset");
    theForm.county_sel.options[33] = new Option("Down", "Down");
    theForm.county_sel.options[34] = new Option("Dumfriesshire", "Dumfriesshire");
    theForm.county_sel.options[35] = new Option("Dunbartonshire", "Dunbartonshire");
    theForm.county_sel.options[36] = new Option("Dyfed", "Dyfed");
    theForm.county_sel.options[37] = new Option("East Lothian", "East Lothian");
    theForm.county_sel.options[38] = new Option("Essex", "Essex");
    theForm.county_sel.options[39] = new Option("Fermanagh", "Fermanagh");
    theForm.county_sel.options[40] = new Option("Fife", "Fife");
    theForm.county_sel.options[41] = new Option("Flintshire", "Flintshire");
    theForm.county_sel.options[42] = new Option("Glamorgan", "Glamorgan");
    theForm.county_sel.options[43] = new Option("Gloucestershire", "Gloucestershire");
    theForm.county_sel.options[44] = new Option("Greater London", "Greater London");
    theForm.county_sel.options[45] = new Option("Greater London", "Greater London");
    theForm.county_sel.options[46] = new Option("Greater Manchester", "Greater Manchester");
    theForm.county_sel.options[47] = new Option("Gwent", "Gwent");
    theForm.county_sel.options[48] = new Option("Gwynedd", "Gwynedd");
    theForm.county_sel.options[49] = new Option("Hampshire", "Hampshire");
    theForm.county_sel.options[50] = new Option("Hereford and Worcest..", "Hereford and Worcest..");
    theForm.county_sel.options[51] = new Option("Herefordshire", "Herefordshire");
    theForm.county_sel.options[52] = new Option("Hertfordshire", "Hertfordshire");
    theForm.county_sel.options[53] = new Option("Humberside", "Humberside");
    theForm.county_sel.options[54] = new Option("Huntingdonshire", "Huntingdonshire");
    theForm.county_sel.options[55] = new Option("Inverness-shire", "Inverness-shire");
    theForm.county_sel.options[56] = new Option("Isle of Wight", "Isle of Wight");
    theForm.county_sel.options[57] = new Option("Kent", "Kent");
    theForm.county_sel.options[58] = new Option("Kinross-shire", "Kinross-shire");
    theForm.county_sel.options[59] = new Option("Kirkcudbrightshire", "Kirkcudbrightshire");
    theForm.county_sel.options[60] = new Option("Lanarkshire", "Lanarkshire");
    theForm.county_sel.options[61] = new Option("Lancashire", "Lancashire");
    theForm.county_sel.options[62] = new Option("Leicestershire", "Leicestershire");
    theForm.county_sel.options[63] = new Option("Lincolnshire", "Lincolnshire");
    theForm.county_sel.options[64] = new Option("Londonderry", "Londonderry");
    theForm.county_sel.options[65] = new Option("Merionethshire", "Merionethshire");
    theForm.county_sel.options[66] = new Option("Merseyside", "Merseyside");
    theForm.county_sel.options[67] = new Option("Middlesex", "Middlesex");
    theForm.county_sel.options[68] = new Option("Midlothian", "Midlothian");
    theForm.county_sel.options[69] = new Option("Monmouthshire", "Monmouthshire");
    theForm.county_sel.options[70] = new Option("Montgomeryshire", "Montgomeryshire");
    theForm.county_sel.options[71] = new Option("Moray", "Moray");
    theForm.county_sel.options[72] = new Option("Nairnshire", "Nairnshire");
    theForm.county_sel.options[73] = new Option("Norfolk", "Norfolk");
    theForm.county_sel.options[74] = new Option("Northamptonshire", "Northamptonshire");
    theForm.county_sel.options[75] = new Option("Northumberland", "Northumberland");
    theForm.county_sel.options[76] = new Option("Nottinghamshire", "Nottinghamshire");
    theForm.county_sel.options[77] = new Option("Orkney", "Orkney");
    theForm.county_sel.options[78] = new Option("Oxfordshire", "Oxfordshire");
    theForm.county_sel.options[79] = new Option("Peeblesshire", "Peeblesshire");
    theForm.county_sel.options[80] = new Option("Pembrokeshire", "Pembrokeshire");
    theForm.county_sel.options[81] = new Option("Perthshire", "Perthshire");
    theForm.county_sel.options[82] = new Option("Powys", "Powys");
    theForm.county_sel.options[83] = new Option("Radnorshire", "Radnorshire");
    theForm.county_sel.options[84] = new Option("Renfrewshire", "Renfrewshire");
    theForm.county_sel.options[85] = new Option("Ross", "Ross");
    theForm.county_sel.options[86] = new Option("Roxburghshire", "Roxburghshire");
    theForm.county_sel.options[87] = new Option("Rutland", "Rutland");
    theForm.county_sel.options[88] = new Option("Selkirkshire", "Selkirkshire");
    theForm.county_sel.options[89] = new Option("Shetland", "Shetland");
    theForm.county_sel.options[90] = new Option("Shropshire", "Shropshire");
    theForm.county_sel.options[91] = new Option("Somerset", "Somerset");
    theForm.county_sel.options[92] = new Option("Staffordshire", "Staffordshire");
    theForm.county_sel.options[93] = new Option("Stirlingshire", "Stirlingshire");
    theForm.county_sel.options[94] = new Option("Suffolk", "Suffolk");
    theForm.county_sel.options[95] = new Option("Surrey", "Surrey");
    theForm.county_sel.options[96] = new Option("Sussex", "Sussex");
    theForm.county_sel.options[97] = new Option("Sutherland", "Sutherland");
    theForm.county_sel.options[98] = new Option("Tyne and Wear", "Tyne and Wear");
    theForm.county_sel.options[99] = new Option("Tyrone", "Tyrone");
    theForm.county_sel.options[100] = new Option("Warwickshire", "Warwickshire");
    theForm.county_sel.options[101] = new Option("West Lothian", "West Lothian");
    theForm.county_sel.options[102] = new Option("West Midlands", "West Midlands");
    theForm.county_sel.options[103] = new Option("Westmorland", "Westmorland");
    theForm.county_sel.options[104] = new Option("Wigtownshire", "Wigtownshire");
    theForm.county_sel.options[105] = new Option("Wiltshire", "Wiltshire");
    theForm.county_sel.options[106] = new Option("Worcestershire", "Worcestershire");
    theForm.county_sel.options[107] = new Option("Yorkshire", "Yorkshire");

  } else if (CurrentCountry == "226") {

    theForm.county_sel.options[0] = new Option("Alabama", "Alabama");
    theForm.county_sel.options[1] = new Option("Alaska", "Alaska");
    theForm.county_sel.options[2] = new Option("American Samoa", "American Samoa");
    theForm.county_sel.options[3] = new Option("Arizona", "Arizona");
    theForm.county_sel.options[4] = new Option("Arkansas", "Arkansas");
    theForm.county_sel.options[5] = new Option("Armed Forces Africa", "Armed Forces Africa");
    theForm.county_sel.options[6] = new Option("Armed Forces America..", "Armed Forces America..");
    theForm.county_sel.options[7] = new Option("Armed Forces Canada", "Armed Forces Canada");
    theForm.county_sel.options[8] = new Option("Armed Forces Europe", "Armed Forces Europe");
    theForm.county_sel.options[9] = new Option("Armed Forces Middle ..", "Armed Forces Middle ..");
    theForm.county_sel.options[10] = new Option("Armed Forces Pacific", "Armed Forces Pacific");
    theForm.county_sel.options[11] = new Option("California", "California");
    theForm.county_sel.options[12] = new Option("Colorado", "Colorado");
    theForm.county_sel.options[13] = new Option("Connecticut", "Connecticut");
    theForm.county_sel.options[14] = new Option("Delaware", "Delaware");
    theForm.county_sel.options[15] = new Option("District of Columbia", "District of Columbia");
    theForm.county_sel.options[16] = new Option("Federated States Of ..", "Federated States Of ..");
    theForm.county_sel.options[17] = new Option("Florida", "Florida");
    theForm.county_sel.options[18] = new Option("Georgia", "Georgia");
    theForm.county_sel.options[19] = new Option("Guam", "Guam");
    theForm.county_sel.options[20] = new Option("Hawaii", "Hawaii");
    theForm.county_sel.options[21] = new Option("Idaho", "Idaho");
    theForm.county_sel.options[22] = new Option("Illinois", "Illinois");
    theForm.county_sel.options[23] = new Option("Indiana", "Indiana");
    theForm.county_sel.options[24] = new Option("Iowa", "Iowa");
    theForm.county_sel.options[25] = new Option("Kansas", "Kansas");
    theForm.county_sel.options[26] = new Option("Kentucky", "Kentucky");
    theForm.county_sel.options[27] = new Option("Louisiana", "Louisiana");
    theForm.county_sel.options[28] = new Option("Maine", "Maine");
    theForm.county_sel.options[29] = new Option("Marshall Islands", "Marshall Islands");
    theForm.county_sel.options[30] = new Option("Maryland", "Maryland");
    theForm.county_sel.options[31] = new Option("Massachusetts", "Massachusetts");
    theForm.county_sel.options[32] = new Option("Michigan", "Michigan");
    theForm.county_sel.options[33] = new Option("Minnesota", "Minnesota");
    theForm.county_sel.options[34] = new Option("Mississippi", "Mississippi");
    theForm.county_sel.options[35] = new Option("Missouri", "Missouri");
    theForm.county_sel.options[36] = new Option("Montana", "Montana");
    theForm.county_sel.options[37] = new Option("Nebraska", "Nebraska");
    theForm.county_sel.options[38] = new Option("Nevada", "Nevada");
    theForm.county_sel.options[39] = new Option("New Hampshire", "New Hampshire");
    theForm.county_sel.options[40] = new Option("New Jersey", "New Jersey");
    theForm.county_sel.options[41] = new Option("New Mexico", "New Mexico");
    theForm.county_sel.options[42] = new Option("New York", "New York");
    theForm.county_sel.options[43] = new Option("North Carolina", "North Carolina");
    theForm.county_sel.options[44] = new Option("North Dakota", "North Dakota");
    theForm.county_sel.options[45] = new Option("Northern Mariana Isl..", "Northern Mariana Isl..");
    theForm.county_sel.options[46] = new Option("Ohio", "Ohio");
    theForm.county_sel.options[47] = new Option("Oklahoma", "Oklahoma");
    theForm.county_sel.options[48] = new Option("Oregon", "Oregon");
    theForm.county_sel.options[49] = new Option("Palau", "Palau");
    theForm.county_sel.options[50] = new Option("Pennsylvania", "Pennsylvania");
    theForm.county_sel.options[51] = new Option("Puerto Rico", "Puerto Rico");
    theForm.county_sel.options[52] = new Option("Rhode Island", "Rhode Island");
    theForm.county_sel.options[53] = new Option("South Carolina", "South Carolina");
    theForm.county_sel.options[54] = new Option("South Dakota", "South Dakota");
    theForm.county_sel.options[55] = new Option("Tennessee", "Tennessee");
    theForm.county_sel.options[56] = new Option("Texas", "Texas");
    theForm.county_sel.options[57] = new Option("Utah", "Utah");
    theForm.county_sel.options[58] = new Option("Vermont", "Vermont");
    theForm.county_sel.options[59] = new Option("Virgin Islands", "Virgin Islands");
    theForm.county_sel.options[60] = new Option("Virginia", "Virginia");
    theForm.county_sel.options[61] = new Option("Washington", "Washington");
    theForm.county_sel.options[62] = new Option("West Virginia", "West Virginia");
    theForm.county_sel.options[63] = new Option("Wisconsin", "Wisconsin");
    theForm.county_sel.options[64] = new Option("Wyoming", "Wyoming");

  } else {
    theForm.county_sel.options[0] = new Option("", "");
  }

  if (theForm.county_sel.options.length <= 1) {
    findObj('divCountyText').style.display='block';
    findObj('divCountySelect').style.display='none';
    findObj('which_field').value='T';
  } else {
    findObj('divCountyText').style.display='none';
    findObj('divCountySelect').style.display='block';
    findObj('which_field').value='S';
  }

}
