function ChangeImage(ImgNM,ImgSrc) {
	document[ImgNM].src=ImgSrc;
}
function populateDays(e) {

	
	// Populate the Days select element with the proper days for the selected month
	f = e.form;
	
	// Determine whether the user selected a month
	if (f.formmonth.selectedIndex > 0) {
		// The user selected a month
	    // Determine which month the user selected
	    selectedMonth = f.formmonth[f.formmonth.selectedIndex].value
	
		// Clear any previous Days
	    f.formday.options.length = 0;
	 	
		// Enter an option of no day in the date
		new Option(0);
		
	    // Loop over the all of the Days, building the correct list of days for the month selected
	    for (iRow=0; iRow<31; iRow++) {
	 
	    	// Add this Day to the Day select element
	 
	 		if (iRow < 28) {
	        	f.formday[iRow + 1] = new Option(iRow+1);
	 	
	 		} else {
	 			if (iRow == 28) {
					
					if ((f.formmonth[f.formmonth.selectedIndex].text != "2") || ((f.formmonth[f.formmonth.selectedIndex].text == "2") && (f.formyear.value % 4 == 0))) 				
						f.formday[iRow + 1] = new Option(iRow+1);
				}
				if (iRow == 29) {
					if (f.formmonth[f.formmonth.selectedIndex].text != "2")
						f.formday[iRow + 1] = new Option(iRow+1);
				}
				if (iRow == 30) {
					if ((f.formmonth[f.formmonth.selectedIndex].text != "2") && ((f.formmonth[f.formmonth.selectedIndex].text == "1") || (f.formmonth[f.formmonth.selectedIndex].text == "3") || (f.formmonth[f.formmonth.selectedIndex].text == "5") || (f.formmonth[f.formmonth.selectedIndex].text == "7") || (f.formmonth[f.formmonth.selectedIndex].text == "8") || (f.formmonth[f.formmonth.selectedIndex].text == "10") || (f.formmonth[f.formmonth.selectedIndex].text == "12")))  {                                                                                                                                    				
				    f.formday[iRow + 1] = new Option(iRow+1);
				}	
		    }			
		 }
	          }
	}
      
  }
  

function toDouble(num)
{
   // roll the number up or down to 2 decimal places
      num = Math.round(num * 100);	
      num = parseFloat(num / 100);

   // if the number is an integer add the zero cents and return
      if( num == parseInt(num) )
	        return(num + ".00");

   // see if the number is missing one trailing zero
      if((num * 10) == parseInt(num * 10))
         return(num + "0");

   // if the number got this far, it has two decimal places, 
   // so just return it
      return(num);

   } //  close the toDouble function

function check_decimals(mynum) {
	//Check to make sure decimals are to the 100ths place
	
	var n = mynum.value;
	var newnum;
			
	newnum =  parseFloat(n);

	if (isNaN(newnum)) {
		
		alert("Please check your number values. They must not contain dollar signs or commas. Only 0-9 and decimal point.")
		return;
	}
	
	//Return the correct values
	mynum.value =  toDouble(newnum);

}

function CheckTextBox(cntlname) {
	//Trim spaces in from and back of string as well as trim carriage control and tabs.
    var inString = cntlname.value;
    var outString;
    var frontIndex = 0
    var backIndex = inString.length - 1;        

    while (inString.charAt( frontIndex ) == " " || inString.charAt( frontIndex ) == "\t" || inString.charAt( frontIndex ) == "\n" || inString.charAt( frontIndex ) == "\r")  
    {
	frontIndex++;
    }

    while (inString.charAt( backIndex ) == " " || inString.charAt( backIndex ) == "\t" || inString.charAt( backIndex ) == "\n" || inString.charAt( backIndex ) == "\r" )  
    {
	backIndex--;
    }

    outString = inString.substring( frontIndex, (backIndex + 1) );
	cntlname.value = outString;
		
}
	
	
/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(datename,dtStr){
	if (dtStr == '') return true;
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		
		alert(datename + " format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert(datename + " Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert(datename + " Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert(datename + " Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert(datename + " Please enter a valid date")
		return false
	}
return true

}
function getQueryStrings() {
    var argList = new Object();
	
	if(window.location != null && window.location.search.length > 1) {
        var urlParms = window.location.search.substring(1);
        var argPairs = urlParms.split('&');

        for(var i = 0; i < argPairs.length; i++) {
            var pos = argPairs[i].indexOf('=')

            if(pos == -1)
                continue;
            else {
                var argName = argPairs[i].substring(0, pos);
                var argVal = argPairs[i].substring(pos + 1);

                if(argVal.indexOf('+') != -1)
                    argVal = argVal.replace(/\+/g, ' ');

                argList[argName] = unescape(argVal);
            }
        }
    }
	
    return argList;
   


 }