
/* OPEN/HIDE THE SUPPORT PORTION OF CONTACT FORM */
function contactType(){
	var el = document.getElementById('cSupport');

	if(document.frmContact.selType.options[document.frmContact.selType.selectedIndex].value=="1"){
		el.style.display = "block";
	}else{
		el.style.display = "none";
	}
}

/* SHOW/HIDE ANY ELEMENT */
function displayElement(element){
	if (document.getElementById)
	{
	// this is the way the standards work
	   if(document.getElementById(element).style.display == 'none'){
		document.getElementById(element).style.display = 'block';
	   }else{
		document.getElementById(element).style.display = 'none';
	   }
	}
	else if (document.all)
	{
	// this is the way old msie versions work
	   if(document.all[element].style.display=='none'){
		document.all[element].style.display='block';
	   }else{
		document.all[element].style.display='none';
	   }
	}
	else if (document.layers)
	{
	// this is the way nn4 works
	   if(document.all[element].style.display=='none'){
		document.all[element].style.display='block';
	   } else {
		document.all[element].style.display='none';
	   }
	}
}

/* RESELLER LIST PAGE, COLOURING FOR ACTIVE ROWS */
function highlightRow(element){
	if (document.getElementById)
	{
	// this is the way the standards work
	   if(document.getElementById(element+'info').style.display == 'none'){
		document.getElementById(element).style.background = '#ffffff';
	   }else{
		document.getElementById(element).style.background = '#ffffcc';
	   }
	}
	else if (document.all)
	{
	// this is the way old msie versions work
	   if(document.all[element+'info'].style.display == 'none'){
		document.all[element].style.background='#ffffff';
	   }else{
		document.all[element].style.background='#ffffcc';
	   }
	}
	else if (document.layers)
	{
	// this is the way nn4 works
	   if(document.all[element+'info'].style.display == 'none'){
		document.all[element].style.background='#ffffff';
	   } else {
		document.all[element].style.background='#ffffcc';
	   }
	}

}

/* USED TO LINK TO THE RESELLER LIST PAGE, LOADING THE SELECTED COUNTRY */
function showResellers(){
	if(document.toResellers.country.options[document.toResellers.country.selectedIndex].value!=''){
		window.location='resellerlisting.php?country='+document.toResellers.country.options[document.toResellers.country.selectedIndex].value;
	}else{
		window.location='resellerlisting.php';
	}
}

/* SET THE RESELLER LIST COUNTRY DROP DOWN TO THE CORRECT COUNTRY, IF SUPPLIED */
function scSetCountry(matchvalue){
	for (var i=0; i < document.toResellers.country.length;i++){
		 if(document.toResellers.country.options[i].value==matchvalue){
			 eval(document.toResellers.country.selectedIndex = i);
		 }
	}
}

/*NEW*/
/* USED TO LINK TO THE RESELLER LIST PAGE, LOADING THE SELECTED COUNTRY */
function rsrCountryOnChange(){
	if(document.toResellers.country.options[document.toResellers.country.selectedIndex].value!=''){
		window.location='resellerlisting2.php?country='+document.toResellers.country.options[document.toResellers.country.selectedIndex].value;
	}else{
		window.location='resellerlisting2.php';
	}
}

/*NEW*/
/* USED TO LINK TO THE RESELLER LIST PAGE, LOADING THE SELECTED COUNTRY */
function rsrProvinceOnChange(){
	if(document.toResellers.country.options[document.toResellers.country.selectedIndex].value!=''
				&& document.provinceForm.ddProvinceFilter.options[document.provinceForm.ddProvinceFilter.selectedIndex].value!='') {

		window.location='resellerlisting2.php?country='+document.toResellers.country.options[document.toResellers.country.selectedIndex].value+'&province='+document.provinceForm.ddProvinceFilter.options[document.provinceForm.ddProvinceFilter.selectedIndex].value;
	}else{
		window.location='resellerlisting2.php';
	}
}

/*NEW*/
/* SET THE RESELLER LIST COUNTRY DROP DOWN TO THE CORRECT COUNTRY, IF SUPPLIED */
function scSetFilters(matchvalue1,matchvalue2){
	for (var i=0; i < document.toResellers.country.length;i++){
		 if(document.toResellers.country.options[i].value==matchvalue1){
			 eval(document.toResellers.country.selectedIndex = i);
		 }
	}
	for (var i=0; i < document.provinceForm.ddProvinceFilter.length;i++){
		 if(document.provinceForm.ddProvinceFilter.options[i].value==matchvalue2){
			 eval(document.provinceForm.ddProvinceFilter.selectedIndex = i);
		 }
	}
}


/* purchase - select edition / make plural */
function updateUserText ( element, value){
	if( value==1 ){

		if (document.getElementById)
		{
			document.getElementById(element).style.visibility = 'hidden';
		}
		else if (document.all)
		{
			document.all[element].style.visibility=='hidden';
		}
		else if (document.layers)
		{
			document.all[element].style.visibility=='hidden';
		}


	}
	else
	{

		if (document.getElementById)
		{
			document.getElementById(element).style.visibility = 'visible';
		}
		else if (document.all)
		{
			document.all[element].style.visibility=='visible';
		}
		else if (document.layers)
		{
			document.all[element].style.visibility=='visible';
		}
	}
}


/* only allow numerical input in field */
  function isNumberKey(evt)
  {
	 var charCode = (evt.which) ? evt.which : event.keyCode
	 if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	 return true;
  }


//format for currency
function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function set_element_value(element, value){

	if (document.getElementById)
	{
		// this is the way the standards work
		document.getElementById(element).value=value;

	}
	else if (document.all)
	{
		// this is the way old msie versions work
		document.all[element].value=value;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		document.all[element].value=value;
	}
}

function return_element_value(element){

	if (document.getElementById)
	{
		// this is the way the standards work
		return document.getElementById(element).value;

	}
	else if (document.all)
	{
		// this is the way old msie versions work
		return document.all[element].value;
	}
	else if (document.layers)
	{
		// this is the way nn4 works
		return document.all[element].value;
	}
}



