
    
function menuRollover(imgName,srcName) {

  if (document.images) {
		document[imgName].src = eval(srcName + ".src");
  }
}
  function trim(trimee){

    	trimee = trimee.replace(/^\s+/,"");
    	trimee = trimee.replace(/\s+$/,"");

    	return trimee;
  }
  
  function stripSpaces(trimee){

    	trimee = trimee.replace(/^\s+/,"");
    	trimee = trimee.replace(/\s+$/,"");
    	trimee = trimee.replace(/\s/g,"");

    	return trimee;
  }

  function patternChecks(nameVal,thisPattern,thisLength) {

		if(nameVal == null || nameVal == "") { return false; }

		if(nameVal.length < 0 || nameVal.length > thisLength) { return false; }

		var matchA = nameVal.match(thisPattern);

		if(matchA == null){ return false; }

        return true;
  }
  
  function checkLength(nameVal,thisLength) {
  
  	
     if(nameVal == null || nameVal == "" || nameVal.length > thisLength || nameVal.length < 0) { return false; }
     else { return true; }
     
  }

function toCurrency(myPrice){

    if((myPrice != null) && (myPrice != "") ) {

		var dotPos =	myPrice.indexOf(".");
		var myLength = myPrice.length;
		var dotOffset = (myLength - 1) - dotPos;

		if(dotPos == -1){

			myPrice = myPrice + ".00";
		}
		else {

			if(dotOffset == 0){

				myPrice = myPrice + "00";
			}
			else if(dotOffset == 1){

				myPrice = myPrice + "0";
			}
			else if(dotOffset > 2){

				var endCh = myPrice.charAt(dotPos + 3);
				var endInt = eval(endCh);

				if(endInt >= 5){

					var begStr = myPrice.substring(0,dotPos);
					var midStr = myPrice.substring(dotPos + 1, dotPos + 3);

					var tempPrice = begStr + midStr + "." + endCh

					var newPrice = Math.round(tempPrice);
					var newPriceStr = newPrice + "";

					var thisLength = newPriceStr.length;

					begStr = newPriceStr.substring(0,thisLength - 2);
					tempPrice = begStr + "." + newPriceStr.substring(thisLength - 2);

					myPrice = tempPrice;

				}
				else{

					myPrice = myPrice.substring(0,dotPos + 2);
				}

			}
	   }
   }

   return myPrice;

}

function isANumber(myStr) {

    var str = myStr;
    var re = /^[-]?\d*\.?\d*$/;
    str = str.toString(  );
    if (!str.match(re)) {
    
        return false;
    }
    return true;
}
var findIdrcNumberPat  = /^[0-9]+$/;

function findIdrc(){

	var alertStr = "Error in input fields: \n"
	var badInput = 0;

	if(!patternChecks(trim(document.zipForm.enteredZip.value),findIdrcNumberPat,5)){

		alertStr += "Zipcode\n"; badInput++;
	}
	else if(document.zipForm.enteredZip.value.length != 5){

		alertStr += "Zipcode\n"; badInput++;
	}

	if(badInput > 0){

		alert(alertStr);
		return false;
	}
	else{

		//document.zipForm.submit();
	}

	return true;
}

function clearZipInput(valueName){

	document.zipForm[valueName].value = "";
}

function goToPricingWDoor(){

	if(currSelected != null && currSelected != "" && doorOb[currSelected].subCollection != "specialty"){
	
		window.location = "pricing.php?selectedDoor=" + currSelected;
	}
	else{
	
		window.location = "pricing.php";
	}
}
