function trimString(sInString) {  sInString = sInString.replace( /^\s+/g, "" );// strip leading  return sInString.replace( /\s+$/g, "" );// strip trailing}function isEmpty(inputStr){   if (inputStr == null || trimString(inputStr) == ""){      return true;   }   return false;}function isNumeric(inputVal){   oneDecimal = false;   inputStr = inputVal.toString();   for (var i = 0; i < inputStr.length; i ++){      var oneChar = inputStr.charAt(i);      if (i == 0 && oneChar == "-"){         continue;      }      if (oneChar == "."){         if (oneDecimal){            return false;         } else {            oneDecimal = true;         }         continue;      }      if (oneChar < "0" || oneChar > "9"){         return false;      }   }   return true;}function validateZip(form) {	if (form.zip.value =='Your ZIP')            form.zip.value='';	if (isEmpty(form.zip.value)) {		alert("Please input a 5-digit zip code for tax and shipping cost");		form.zip.focus();		return false;	}	if (!isEmpty(form.zip.value) && !isNumeric(trimString(form.zip.value))) {	                alert("Please input a 5-digit zip code for tax and shipping cost");		form.zip.focus();		return false;	}        	form.zip.value=trimString(form.zip.value);        form.submit();  }function validatePrices(form) {		if (isEmpty(form.query.value)) {		alert("Please input a keyword for product search");		form.query.focus();		return false;	}	if (!isEmpty(form.lowestprice.value) && !isNumeric(trimString(form.lowestprice.value))) {			alert("Please input a numeric value for lowest price");		form.lowestprice.focus();		return false;	}	if (!isEmpty(form.highestprice.value) && !isNumeric(trimString(form.highestprice.value))) {			alert("Please input a numeric value for highest price");		form.highestprice.focus();		return false;	}		form.lowestprice.value=trimString(form.lowestprice.value);	form.highestprice.value=trimString(form.highestprice.value);	form.query.value=trimString(form.query.value);    form.submit();  }function validateMinMaxPrices(form) {		if (isEmpty(form.minPrice.value) || (!isEmpty(form.minPrice.value) && !isNumeric(trimString(form.minPrice.value)))) {			alert("Please input a numeric value for minimal price");		form.minPrice.focus();		return false;	}	if (isEmpty(form.maxPrice.value) || (!isEmpty(form.maxPrice.value) && !isNumeric(trimString(form.maxPrice.value)))) {			alert("Please input a numeric value for max price");		form.maxPrice.focus();		return false;	}		form.minPrice.value=trimString(form.minPrice.value);	form.maxPrice.value=trimString(form.maxPrice.value);    form.submit();  }function validate(obj) {    if(obj.value=="") {        return false;    }    return true;}function validateNewsKey(form) {		if (isEmpty(form.query.value)) {		alert("Please input a keyword for news search");		form.query.focus();		return false;	}	form.query.value=trimString(form.query.value);        form.submit();  }function checkEnter(e, form){ 	var characterCode  	if(e && e.which){ 		e = e		characterCode = e.which 	}	else{		e = event		characterCode = e.keyCode 	}	if(characterCode == 13){ 	    validatePrices(form);		//document.forms[0].submit() 		return false	}	else{		return true	}}function Checkcount( which ) {  var i=0;  var count=0;  for(i=0; i<document.compare.elements.length; i++)  {    if (document.compare.elements[i].checked == true){count++;}    if (count > 8) {       alert('A maximum of 8 products can be compared at one time');       document.compare[which].checked = false;       break;    }  }  if (which == 'Form') {     if (count <= 1) {         alert('Choose at least two products to compare with');         return false;     } else {         return true;     }  }}function Toggle(menu) {menu.parentNode.className=(menu.parentNode.className == 'closed')?'open':'closed';}function ExpandAll() { var i=0; if (document.getElementById("ExpLabel").innerHTML == 'Expand all') {    while(document.getElementById("Node" + i)){    document.getElementById("Node" + i).className='open';    i = i + 1;     }    document.getElementById("ExpLabel").innerHTML='Collapse all';    }    else    {    while(document.getElementById("Node" + i)){    document.getElementById("Node" + i).className='closed';    i = i + 1;     }    document.getElementById("ExpLabel").innerHTML='Expand all'; }}function go(obj) {        if(isEmpty(obj.value)) {                alert('Please input keyword(s) to search. ---');                obj.focus();                return false;        }       // alert ('this form action =' + obj.form.action);		//alert ('button clicked =' + obj.form.news.value);      return true;}function changeText() { var myDiv1 = document.getElementById('myDiv1'); var myDiv2 = document.getElementById('myDiv2'); var myDiv3 = document.getElementById('myDiv3'); var myDiv4 = document.getElementById('myDiv4'); if (myDiv1 != null)   myDiv1.innerHTML = ''; if (myDiv2 != null) myDiv2.innerHTML = ''; if (myDiv3 != null) myDiv3.innerHTML = ''; if (myDiv4 != null) myDiv4.innerHTML = '';}//changeText();
