function rollover(pict_id) {
		new_source = "/images/" + pict_id + "1.gif";
		document.getElementById(pict_id).src = new_source;
}

function rollout(pict_id) {
		new_source = "/images/" + pict_id + "0.gif";
		document.getElementById(pict_id).src = new_source;
}



function cash(amount, commas){ // used for rounding too (in the hardware page)
		var i = parseFloat(amount);
        if(isNaN(i)) { i = 0.00; }
        var minus = '';
        if(i < 0) { minus = '-'; }
        i = Math.abs(i);
        i = parseInt((i + .005) * 100);
        i = i / 100;
        s = new String(i);
        if(s.indexOf('.') < 0) { s += '.00'; }
        if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
        s = minus + s;
        if(commas != false) s = CommaFormatted(s);
        return s;
}

function CommaFormatted(amount) // goes with "cash" above
{
        var delimiter = ","; // replace comma if desired
        var a = amount.split('.',2)
        var d = a[1];
        var i = parseInt(a[0]);
        if(isNaN(i)) { return ''; }
        var minus = '';
        if(i < 0) { minus = '-'; }
        if (amount == 0) {
        	n = "0";
        } else if (amount < 0) {
			n = new String(Math.abs(i));
		} else { // i is positive
			n = new String(Math.abs(i*-1));// have to put that in there to somehow fix abs(0) which is -0 for some reason
		}
//        window.alert("n is " + n + " and i is " + i);
        var a = [];
        while(n.length > 3)
        {
                var nn = n.substr(n.length-3);
                a.unshift(nn);
                n = n.substr(0,n.length-3);
        }
        if(n.length > 0) { a.unshift(n); }
        n = a.join(delimiter);
        if(d.length < 1) { amount = n; }
        else { amount = n + '.' + d; }
        amount = minus + amount;
        return amount;
}


// function below is called by a submitted form to check. So, just return error - identical to below (non required date)
function isDateorNull(theElement, theElementName) {
		var CorrectDate;
		var SplitDate = new Array('','','');
		var thisDay;
		var thisMonth;
		var thisYear;
		var inpDate        = theElement.value;
		var DayArray       = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		var Errored         = 0;
		var messagetoreturn = "";
		today = new Date();
		// kill if nothing there
		if (inpDate.length == 0 ) {
			messagetoreturn = (theElementName + ' is required.\n');
			return messagetoreturn;
		} else if (/^[0-9]{6}$/.test(inpDate)==true) { // 6 digit year mmddyy
			thisMonth = inpDate.substr(0,2);
			thisDay   = inpDate.substr(2,2);
			thisYear  = inpDate.substr(4,2);
		} else if (/^[0-9]{8}$/.test(inpDate)==true) { // 8 digit date mmddyyyy
			thisMonth = inpDate.substr(0,2);
			thisDay   = inpDate.substr(2,2);
			thisYear  = inpDate.substr(4,4);
		} else { //  pick up every conceivable special character or kick out with error
			if      (/-/.test(inpDate))     {SplitDate = inpDate.split('-');}
			else if (/\//.test(inpDate))    {SplitDate = inpDate.split('/');}
			else if (/\./.test(inpDate))    {SplitDate = inpDate.split('.');}
			else if (/,/.test(inpDate))     {SplitDate = inpDate.split(',');}
			else if (/\;/.test(inpDate))     {SplitDate = inpDate.split(';');}
			else if (/\:/.test(inpDate))     {SplitDate = inpDate.split(':');}
			else if (/\*/.test(inpDate))     {SplitDate = inpDate.split('*');}
			else if (/_/.test(inpDate))     {SplitDate = inpDate.split('_');}
			else if (/%/.test(inpDate))     {SplitDate = inpDate.split('%');}
			else if (/ /.test(inpDate))     {SplitDate = inpDate.split(' ');}
			else if (/^[0-9]{6}$/.test(inpDate)) {
				SplitDate[0] = inpDate.substr(0,2);
				SplitDate[1] = inpDate.substr(2,2);
				SplitDate[2] = inpDate.substr(4,2);
			}
			else     {Errored = 1;}
			thisMonth = SplitDate[0];      
			thisDay   = SplitDate[1];   
			thisYear  = SplitDate[2]; 
		}
		// request reinput data if nonexistent
		if (!thisYear)	{thisYear = String(today.getYear());}
		if (!thisMonth) {Errored = 1;}
		if (!thisDay)	{Errored = 1;}
		// kick out any errors before we do any formatting etc
		if (Errored == 1) {
			messagetoreturn = (theElementName + '  must be a valid date.\n');
//			theElement.focus(); 
//			return false;
		}
		//     change from alpha  to numeric
		if (/^[a-zA-Z]{1}$/.test(thisMonth.substr(0,1))) {
			thisMonth = thisMonth.toLowerCase();
			thisMonth = thisMonth.substr(0,3);
			switch (thisMonth) {
				case 'jan' : 			thisMonth = '01'; break;
				case 'feb' : 			thisMonth = '02'; break;
				case 'mar' : 			thisMonth = '03'; break;
				case 'apr' : 			thisMonth = '04'; break;
				case 'may' : 			thisMonth = '05'; break;
				case 'jun' : 			thisMonth = '06'; break;
				case 'jul' : 		 	thisMonth = '07'; break;
				case 'aug' : 		 	thisMonth = '08'; break;
				case 'sep' : 			thisMonth = '09'; break;
				case 'oct' : 		    thisMonth = '10'; break;
				case 'nov' : 		    thisMonth = '11'; break;
				case 'dec' : 		    thisMonth = '12'; break;
				default : 
					messagetoreturn = (theElementName + ' must be a valid date. Month input is invalid.\n'); 
//					theElement.focus(); 
//					return false;
			}
		}
		// sort variable lengths out and build date
		if (thisDay.length  == 1) {thisDay = '0' + thisDay;}
		if (thisYear.length == 1) {thisYear = '200' + thisYear;}
		if (/[^0-9]+/.test(thisYear)) {
			messagetoreturn = (theElementName + '  must be a valid date.\n');
//			theElement.focus(); 
//			return false;
		}
		if ((thisYear.length != 2) && (thisYear.length != 4)) {
			messagetoreturn = (theElementName + ' must be a valid date. Year input is invalid.\n');
//			theElement.focus(); 
//			return false;
		}
		if (thisYear.length == 2) {thisYear = '20' + thisYear;}
		
		// check that it can't be in the past!
		good_date = new Date(thisYear, thisMonth, thisDay);
		last_year = new Date();
		last_year.setFullYear(last_year.getFullYear() - 1);
		twenty_years_from_now = new Date();
		twenty_years_from_now.setFullYear(twenty_years_from_now.getFullYear() + 20);
		if (good_date < last_year) {
			messagetoreturn = (theElementName + ' is too far in the past.\n');
//			theElement.focus(); 
//			return false;
		}
		// check that it can't be more than 20 years into the future
		if (good_date > twenty_years_from_now) {
			messagetoreturn = (theElementName + ' is too far in the future.\n');
		}
		
		// Check For Leap Year 
		N=thisYear;
		if ( ( N%4==0 && N%100 !=0 ) || ( N%400==0 ) ) {
			DayArray[2]=29;    
		} 
		
		// check for correct days in month
		var month_indexable = thisMonth;
		if(thisMonth.substr(0,1) == '0') month_indexable = thisMonth.substr(1,1); // this removes the "0" from months like 05 so that the indexing works
		if (thisDay<= DayArray[month_indexable] && thisDay>0 ) {
			Errored = 0;
		} else {
			messagetoreturn = (theElementName + ' must be a valid date. The day input for the month chosen is invalid.\n'); 
		}
	if (messagetoreturn == "") {
		if (thisMonth.length  == 1) {thisMonth = '0' + thisMonth;}
		CorrectDate = thisMonth + '/' + thisDay + '/' + thisYear;
		theElement.value = CorrectDate;
		return "";
	} else {
		return messagetoreturn;
	}
}




// identical to function above but removed the lines that check for null... if null, just pass no error - not required date
function isDateValid(theElement, theElementName) {
		var CorrectDate;
		var SplitDate = new Array('','','');
		var thisDay;
		var thisMonth;
		var thisYear;
		var inpDate        = theElement.value;
		var DayArray       = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		var Errored         = 0;
		var messagetoreturn = "";
		today = new Date();
		// kill if nothing there
		if (inpDate.length == 0 ) {
			return "";
		} else if (/^[0-9]{6}$/.test(inpDate)==true) { // 6 digit year mmddyy
			thisMonth = inpDate.substr(0,2);
			thisDay   = inpDate.substr(2,2);
			thisYear  = inpDate.substr(4,2);
		} else if (/^[0-9]{8}$/.test(inpDate)==true) { // 8 digit date mmddyyyy
			thisMonth = inpDate.substr(0,2);
			thisDay   = inpDate.substr(2,2);
			thisYear  = inpDate.substr(4,4);
		} else { //  pick up every conceivable special character or kick out with error
			if      (/-/.test(inpDate))     {SplitDate = inpDate.split('-');}
			else if (/\//.test(inpDate))    {SplitDate = inpDate.split('/');}
			else if (/\./.test(inpDate))    {SplitDate = inpDate.split('.');}
			else if (/,/.test(inpDate))     {SplitDate = inpDate.split(',');}
			else if (/\;/.test(inpDate))     {SplitDate = inpDate.split(';');}
			else if (/\:/.test(inpDate))     {SplitDate = inpDate.split(':');}
			else if (/\*/.test(inpDate))     {SplitDate = inpDate.split('*');}
			else if (/_/.test(inpDate))     {SplitDate = inpDate.split('_');}
			else if (/%/.test(inpDate))     {SplitDate = inpDate.split('%');}
			else if (/ /.test(inpDate))     {SplitDate = inpDate.split(' ');}
			else if (/^[0-9]{6}$/.test(inpDate)) {
				SplitDate[0] = inpDate.substr(0,2);
				SplitDate[1] = inpDate.substr(2,2);
				SplitDate[2] = inpDate.substr(4,2);
			}
			else     {Errored = 1;}
			thisMonth = SplitDate[0];      
			thisDay   = SplitDate[1];   
			thisYear  = SplitDate[2]; 
		}
		// request reinput data if nonexistent
		if (!thisYear)	{thisYear = String(today.getYear());}
		if (!thisMonth) {Errored = 1;}
		if (!thisDay)	{Errored = 1;}
		// kick out any errors before we do any formatting etc
		if (Errored == 1) {
			messagetoreturn = (theElementName + '  must be a valid date.\n');
//			theElement.focus(); 
//			return false;
		}
		//     change from alpha  to numeric
		if (/^[a-zA-Z]{1}$/.test(thisMonth.substr(0,1))) {
			thisMonth = thisMonth.toLowerCase();
			thisMonth = thisMonth.substr(0,3);
			switch (thisMonth) {
				case 'jan' : 			thisMonth = '01'; break;
				case 'feb' : 			thisMonth = '02'; break;
				case 'mar' : 			thisMonth = '03'; break;
				case 'apr' : 			thisMonth = '04'; break;
				case 'may' : 			thisMonth = '05'; break;
				case 'jun' : 			thisMonth = '06'; break;
				case 'jul' : 		 	thisMonth = '07'; break;
				case 'aug' : 		 	thisMonth = '08'; break;
				case 'sep' : 			thisMonth = '09'; break;
				case 'oct' : 		    thisMonth = '10'; break;
				case 'nov' : 		    thisMonth = '11'; break;
				case 'dec' : 		    thisMonth = '12'; break;
				default : 
					messagetoreturn = (theElementName + ' must be a valid date. Month input is invalid.\n'); 
//					theElement.focus(); 
//					return false;
			}
		}
		// sort variable lengths out and build date
		if (thisDay.length  == 1) {thisDay = '0' + thisDay;}
		if (thisYear.length == 1) {thisYear = '200' + thisYear;}
		if (/[^0-9]+/.test(thisYear)) {
			messagetoreturn = (theElementName + '  must be a valid date.\n');
//			theElement.focus(); 
//			return false;
		}
		if ((thisYear.length != 2) && (thisYear.length != 4)) {
			messagetoreturn = (theElementName + ' must be a valid date. Year input is invalid.\n');
//			theElement.focus(); 
//			return false;
		}
		if (thisYear.length == 2) {thisYear = '20' + thisYear;}
		
		// check that it can't be in the past!
		good_date = new Date(thisYear, thisMonth, thisDay);
		last_year = new Date();
		last_year.setFullYear(last_year.getFullYear() - 1);
		twenty_years_from_now = new Date();
		twenty_years_from_now.setFullYear(twenty_years_from_now.getFullYear() + 20);
		if (good_date < last_year) {
			messagetoreturn = (theElementName + ' is too far in the past.\n');
//			theElement.focus(); 
//			return false;
		}
		// check that it can't be more than 10 years into the future
		if (good_date > twenty_years_from_now) {
			messagetoreturn = (theElementName + ' is too far in the future.\n');
		}
		
		// Check For Leap Year 
		N=thisYear;
		if ( ( N%4==0 && N%100 !=0 ) || ( N%400==0 ) ) {
			DayArray[2]=29;    
		} 
		
		// check for correct days in month
		var month_indexable = thisMonth;
		if(thisMonth.substr(0,1) == '0') month_indexable = thisMonth.substr(1,1); // this removes the "0" from months like 05 so that the indexing works
		if (thisDay<= DayArray[month_indexable] && thisDay>0 ) {
			Errored = 0;
		} else {
			messagetoreturn = (theElementName + ' must be a valid date. The day input for the month chosen is invalid.\n'); 
		}
	if (messagetoreturn == "") {
		if (thisMonth.length  == 1) {thisMonth = '0' + thisMonth;}
		CorrectDate = thisMonth + '/' + thisDay + '/' + thisYear;
		theElement.value = CorrectDate;
		return "";
	} else {
		return messagetoreturn;
	}
}



// function below is called by a submitted form after date has been checked. So, just fix the dates
function fixDate(theElement) {
		var CorrectDate;
		var SplitDate = new Array('','','');
		var thisDay;
		var thisMonth;
		var thisYear;
		var inpDate        = theElement.value;
		var DayArray       = new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
		today = new Date();
		//  pick up every conceivable special character or kick out with error
			if      (/-/.test(inpDate))     {SplitDate = inpDate.split('-');}
			else if (/\//.test(inpDate))    {SplitDate = inpDate.split('/');}
			else if (/\./.test(inpDate))    {SplitDate = inpDate.split('.');}
			else if (/,/.test(inpDate))     {SplitDate = inpDate.split(',');}
			else if (/\;/.test(inpDate))     {SplitDate = inpDate.split(';');}
			else if (/\:/.test(inpDate))     {SplitDate = inpDate.split(':');}
			else if (/\*/.test(inpDate))     {SplitDate = inpDate.split('*');}
			else if (/_/.test(inpDate))     {SplitDate = inpDate.split('_');}
			else if (/%/.test(inpDate))     {SplitDate = inpDate.split('%');}
			else if (/ /.test(inpDate))     {SplitDate = inpDate.split(' ');}
			thisMonth = SplitDate[0];      
			thisDay   = SplitDate[1].toUpperCase();   
			thisYear  = SplitDate[2]; 
		// request reinput data if nonexistent
		if (!thisYear)	{thisYear = String(today.getYear());}
		//     change from alpha  to numeric
		if (/^[a-zA-Z]{1}$/.test(thisMonth.substr(0,1))) {
			thisMonth = thisMonth.toLowerCase();
			thisMonth = thisMonth.substr(0,3);
			switch (thisMonth) {
				case 'jan' : 			thisMonth = '01'; break;
				case 'feb' : 			thisMonth = '02'; break;
				case 'mar' : 			thisMonth = '03'; break;
				case 'apr' : 			thisMonth = '04'; break;
				case 'may' : 			thisMonth = '05'; break;
				case 'jun' : 			thisMonth = '06'; break;
				case 'jul' : 		 	thisMonth = '07'; break;
				case 'aug' : 		 	thisMonth = '08'; break;
				case 'sep' : 			thisMonth = '09'; break;
				case 'oct' : 		    thisMonth = '10'; break;
				case 'nov' : 		    thisMonth = '11'; break;
				case 'dec' : 		    thisMonth = '12'; break;
				default : 
					messagetoreturn = (theElementName + ' month is incorrect.\n'); 
//					theElement.focus(); 
//					return false;
			}
		}
		// sort variable lengths out and build date
		if (thisDay.length  == 1) {thisDay = '0' + thisDay;}
		if (thisYear.length == 1) {thisYear = '200' + thisYear;}
		if (thisYear.length == 2) {thisYear = '20' + thisYear;}
		if (thisMonth.length  == 1) {thisMonth = '0' + thisMonth;}
		CorrectDate = thisYear + '-' + thisMonth + '-' + thisDay;
		theElement.value = CorrectDate;
}



function openPopWin(winURL, winWidth, winHeight, winFeatures, winLeft, winTop) {
	var popWin = null;    // use this when referring to pop-up window
	var winCount = 0;
	var winName = "popWinx";
	var d_winLeft = 0;  // default, pixels from screen left to window left
	var d_winTop = 0;   // default, pixels from screen top to window top
	winName = "popWinx";// + winCount++ // unique name for each pop-up window
	// close any previously opened pop-up window
	if (navigator.appName != "Microsoft Internet Explorer" || parseInt(navigator.appVersion) >=4) { //do not close if early IE
		if(popWin != null) if(!popWin.closed) popWin.close();
	}
	if (openPopWin.arguments.length >= 4) { // any additional features? 
		winFeatures = "," + winFeatures
	} else {
		winFeatures = "";
	}
	if (openPopWin.arguments.length == 6) { // location specified
		winFeatures += getLocation(winWidth, winHeight, winLeft, winTop);
	} else {
		winFeatures += getLocation(winWidth, winHeight, d_winLeft, d_winTop);
	}
	popWin = window.open(winURL, winName, "width=" + winWidth  + ",height=" + winHeight + winFeatures);
	popWin.focus();
}





function getLocation(winWidth, winHeight, winLeft, winTop){ // part of popwin above
		var winLocation = ""
		if (winLeft < 0)
			winLeft = screen.width - winWidth + winLeft
		if (winTop < 0)
			winTop = screen.height - winHeight + winTop
		if (winTop == "cen")
			winTop = (screen.height - winHeight)/2 - 20
		if (winLeft == "cen")
			winLeft = (screen.width - winWidth)/2
		if (winLeft>0 & winTop>0)
			winLocation =  ",screenX=" + winLeft + ",left=" + winLeft     
					+ ",screenY=" + winTop + ",top=" + winTop
		else
			winLocation = ""
		return winLocation
	} 





function unique_array(values) {
	values.sort();
	var loop = values.length; 
	for(j = 1; j <= loop; j++) { 
		first_val = values[j-1]; 
		second_val = values[j];
		if (first_val==second_val && first_val!="" && first_val!="if applicable" && first_val!="if applicableif applicable") {
			return false;
		} 
	} 
	return true;
}








function trim(inputString) {
		// Removes leading and trailing spaces from the passed string. Also removes
		// consecutive spaces and replaces it with one space. If something besides
		// a string is passed in (null, custom object, etc.) then return the input.
		if (typeof inputString != 'string') { return inputString; }
			var retValue = inputString;
			var ch = retValue.substring(0, 1);
			while (ch == ' ') { // Check for spaces at the beginning of the string
			retValue = retValue.substring(1, retValue.length);
			ch = retValue.substring(0, 1);
		}
		ch = retValue.substring(retValue.length-1, retValue.length);
		while (ch == ' ') { // Check for spaces at the end of the string
			retValue = retValue.substring(0, retValue.length-1);
			ch = retValue.substring(retValue.length-1, retValue.length);
		}
		while (retValue.indexOf('  ') != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
			retValue = retValue.substring(0, retValue.indexOf('  ')) + retValue.substring(retValue.indexOf('  ')+1, retValue.length); // Again, there are two spaces in each of the strings
		}
		return retValue; // Return the trimmed string back to the user
	} 








