	var BUTTON_CLASS_OVER = "buttn-over";
	var BUTTON_CLASS_OUT = "buttn-out";
				
	var winSpawn = null;
	var reDash = /-/g;
	var reInteger = /^\d+$/;
	var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/;
	var reEmail =  /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*\.(\w{2}|(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|jobs|travel|mobi))$/;
	var DaysInMonth = [0,31,29,31,30,31,30,31,31,30,31,30,31];
	

	
	
	function isFloat(sFloat,bolNullOK){
		if(isEmpty(sFloat)) return !bolNullOK;
		if(!reFloat.test(sFloat)) return false;
		return true;
	}
		
	function isInteger(sInt,bolNullOK){
		if(isEmpty(sInt)) return !bolNullOK;
		if(!reInteger.test(sInt)) return false;
		return true;
	}	
	
	function isEmail(sEmail,bolNullOK){
		if(isEmpty(sEmail)) return !bolNullOK;
		if(!reEmail.test(sEmail)) return false;
		return true;
	}	
	
	function isZipShort(sZip,bolNullOK){
		if(isEmpty(sZip)){
			if(bolNullOK)
				return false;
			else
				return true;
		}
		if(!(sZip.length == 5)) return false;
		if(!reInteger.test(sZip)) return false;
		return true;
	}
	
	
					
	function isTime(sTime,bolNullOK){
	// Time Format hh:mm AM/PM
		if(isEmpty(sTime)) return !bolNullOK;
		if (sTime.length < 8) return false;
		
		var sHour 			= sTime.slice(0,2);	// 'hh
		var cTimeSeparator 	= sTime.slice(2,3);	// ':'
		var sMin 			= sTime.slice(3,5);	// 'mm'
		var cSpace 			= sTime.slice(5,6);	// ' '
		var sClockCycle		= sTime.slice(6,8);	// 'AM/PM'
		
		if (!(reInteger.test(sHour)  && cTimeSeparator == ":" && reInteger.test(sMin) && cSpace == " " && (sClockCycle == "PM" || sClockCycle == "AM"))) return false;
		
		var intHour = ((sHour.slice(0,1) == 0) ? parseInt(sHour.slice(1,2)): parseInt(sHour));
		var intMin = ((sMin.slice(0,1) == 0) ? parseInt(sMin.slice(1,2)): parseInt(sMin));
		
		if(intHour < 1 || intHour > 12)	return false;
		if(intMin > 59)	return false;
	
		return true;
	}	
	
	function getTime12(){
		var myDate = new Date();
		var tHours = myDate.getHours();
		var tMinutes = myDate.getMinutes();
		var tAMPM = "AM";
		if(tHours >= 12){	
			tHours = tHours - 12;
			if(tHours == 0) tHours = 12;
			tAMPM = "PM";
		}
		if(tHours == 0){ 
			tHours = 12;
			tAMPM = "AM";
		}	
		if(tHours < 10) tHours = "0" + tHours;
		if(tMinutes < 10) tMinutes = "0" + tMinutes;		
		return(tHours + ":" + tMinutes + " " + tAMPM);
	}	
	
	function isDate(sDate,bolNullOK){ //DATE FORMAT mm/dd/yy
		//Check for NUll or string not long enough for a date format of mm/dd/yy
		if (isEmpty(sDate)) return !bolNullOK;
		if (sDate.length < 8) return false;
		//Make sure the Date sybmols are in the correct place
		if ((sDate.slice(2,3) != "/") && (sDate.slice(5,6) != "/")) return false;
		//Seperate date components.  See if they are all integer
		var mm = sDate.slice(0,2);
		var dd = sDate.slice(3,5);
		var yy = sDate.slice(6,8);
		if (!(reInteger.test(mm)  && reInteger.test(dd) && reInteger.test(yy))) return false;
		//Parse to integer.  Parse 2nd char if its a 0.  ParseInt doesn't like leading 0's
		var intMonth = ((mm.slice(0,1) == 0) ? parseInt(mm.slice(1,2)): parseInt(mm));
		var intDay = ((dd.slice(0,1) == 0) ? parseInt(dd.slice(1,2)): parseInt(dd));
		var intYear = ((yy.slice(0,1) == 0) ? parseInt(yy.slice(1,2)): parseInt(yy)); 
		
		//Month range 1-12
		if ((intMonth < 1) ||(intMonth > 12)) return false; 
		//Days no more than usual days in month
		
		if ((intDay < 1) || (intDay > DaysInMonth[intMonth])) return false; 
		//February is special case
		var intDaysInFeb = (((intYear % 4 == 0) && ((!(intYear % 100 == 0)) || (intYear % 400 == 0)) ) ? 29 : 28);
		if ((intMonth == 2) && (intDay > intDaysInFeb)) return false;
		
		return true;
	}		
	
	function isDateLong(sDate,bolNullOK){ //DATE FORMAT mm/dd/yyyy
		//Check for NUll or string not long enough for a date format of mm/dd/yyyy
		if (isEmpty(sDate)) return !bolNullOK;
		
		if (sDate.length < 10) return false;
		
		//Make sure the Date sybmols are in the correct place
		if ((sDate.slice(2,3) != "/") && (sDate.slice(5,6) != "/")) return false;
		
		//Seperate date components.  See if they are all integer
		var mm = sDate.slice(0,2);
		var dd = sDate.slice(3,5);
		var yyyy = sDate.slice(6,10);
		
		//Leading Zero in Year is not allowed.  
		if(yyyy.slice(0,1) == 0) return false;
		
		//Test using regular expression each component is integer
		if (!(reInteger.test(mm)  && reInteger.test(dd) && reInteger.test(yyyy))) return false;
	
		//Parse to integer.  Parse 2nd char if its a 0.  ParseInt doesn't like leading 0's
		var intMonth = ((mm.slice(0,1) == 0) ? parseInt(mm.slice(1,2)): parseInt(mm));
		var intDay = ((dd.slice(0,1) == 0) ? parseInt(dd.slice(1,2)): parseInt(dd));
		var intYear = parseInt(yyyy); 
		
		//Month range 1-12
		if ((intMonth < 1) ||(intMonth > 12)) return false; 
		
		//Days no more than usual days in month
		if ((intDay < 1) || (intDay > DaysInMonth[intMonth])) return false; 
		
		//February is special case
		var intDaysInFeb = (((intYear % 4 == 0) && ((!(intYear % 100 == 0)) || (intYear % 400 == 0)) ) ? 29 : 28);
		
		if ((intMonth == 2) && (intDay > intDaysInFeb)) return false;
		
		return true;
	}	
	
	function isEmpty(strEvaluate){   
		return ((strEvaluate == null) || (strEvaluate.length == 0))
	}
	
	function isEmptyReturn(strEvaluate, strReturn){
		if(isEmpty(strEvaluate))
			return strReturn
		else
			return strEvaluate
	}
	
	function isSSN(sInt, bolNullOK){   
		if(isEmpty(sInt)) return !bolNullOK;
		sInt = sInt.replace(reDash,"");
		if(sInt.length == 9 &&  reInteger.test(sInt)) 
			return true;
		else
			return false;
	}

	function isPhone(sInt, bolNullOK){   
		if(isEmpty(sInt)) return !bolNullOK;
		sInt = sInt.replace(reDash,"");
		if(sInt.length == 10 &&  reInteger.test(sInt)) 
			return true;
		else
			return false;
	}	
		
	// rounds number to X decimal places, defaults to 2			
	function roundByPlace(number,X) {
		X = (!X ? 2 : X);
		return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
	}			
	
	function selectOption(ctrlOption, strValue){
		if(strValue == "")
			ctrlOption.options[0].selected = true;
		else
			for (var i = 0; i < ctrlOption.length; i++)
				if (ctrlOption.options[i].value == strValue){
					ctrlOption.options[i].selected = true;
					break;
				}
	 }

	function selectRadio(ctrlRadio, strValue){
		if(strValue == "")
			ctrlRadio[0].checked = true;
		else
			for (var i = 0; i < ctrlRadio.length; i++)
				if (ctrlRadio[i].value == strValue)
					ctrlRadio[i].checked = true;
	 }
	 
	function setMsg(msg) {
		window.status = msg;
		return true;
	}	 
	
	function openWindow(strURL, strTitle, nWidth, nHeight) {
		var strProperties = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes, copyhistory=no,width=" + nWidth + ",height=" + nHeight + ",left=" + ((screen.availWidth - nWidth - 10) * .5) + ",top=" + ((screen.availHeight - nHeight - 30) * .5);
		winSpawn = window.open(strURL,strTitle,strProperties); 
		winSpawn.focus();
	}	
	
	function disableControls(f){
		for(var i=0;i < f.elements.length;i++){ 
			var element = f.elements[i]; 
			element.disabled="disabled";
			//if((element.type == "text") || (element.type == "textarea")  || (element.type == "select-one") || (checkbox)){ 
				//element.disabled="disabled";
			//} 
		} 
	}
	
	function expand(ID, bolExpand){
		if(bolExpand){
			document.getElementById(ID).ClassName = "expanded";
		}
		else{
			document.getElementById(ID).ClassName = "unexpanded";
		}
	}	
	
	function preparePrint(bolPre){
		var nodeList = document.getElementsByTagName("div");
		for (var i = 0; i < nodeList.length; i++){
		  	if(!isEmpty(nodeList[i].id) && (nodeList[i].ClassName == 'expanded' || nodeList[i].ClassName == 'unexpanded')){	
				expand(nodeList[i].id,!bolPre);
			}
		}
	} 
	
	 function handleTextAreaLimit(ctrlTextArea, intLimit, errMessage){
		if(ctrlTextArea.value.length > intLimit){
			alert(errMessage);
			ctrlTextArea.value = ctrlTextArea.value.slice(0,intLimit);
		}
	 } 	 	
