<!--

/**
 *
 */
function restrictToNumbersOnly(){
	if (window.event.keyCode < 48 || window.event.keyCode > 57) {
		window.event.returnValue = false;
	}//end if
}//end restricToNumberOnly

/**
 *
 */
function restrictToLettersOnly(){
	if( (event.keyCode != 32) && (event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)  || (event.keyCode > 122)){
		event.returnValue = false;
	}//end if
}//end restrictToLettersOnly

/**
 *
 */
function restrictToEmailOnly(){	
	if( event.keyCode < 46 || event.keyCode == 47 || (event.keyCode > 57 && event.keyCode < 64) || (event.keyCode > 90 && event.keyCode < 97) || event.keyCode > 122 ){
		event.returnValue = false;
	}//end if	
}//end restrictToEmailOnly

/*
 *
 */
function restrictToLettersAndNumbers(){
	if( (event.keyCode < 32) || (event.keyCode > 32 && event.keyCode < 48) || (event.keyCode > 57 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97) || (event.keyCode > 122) ){
		event.returnValue = false;
	}//end if
}//end restrictToLettersAndNumbers

/**
 * Changes the value of the field to uppercase.
 */
function fieldToUpperCase(field){
	field.value = field.value.toUpperCase();
}//end toUpperCase

/*
 *
 */
function isValidEmailAddress(email) {
	var emailReg  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return emailReg.test(email);
}//end isValidEmailAddress

/**
 * Changes the color of the item passed as parameter
 * to the specified color.
 */
function changeColor(itm, color){
	itm.style.backgroundColor = color;
}//end colorChange

/*
 *
 */
function toggleSame(status){
	
	var color = "FFFFFF";
	
	if(status == 'Y'){
		color = "D4D0C8";
		document.forms[0].propAddress.value = "";
		document.forms[0].propCity.value = "";
		document.forms[0].propState.value = "";
		document.forms[0].propZip.value = "";
		
		document.forms[0].propAddress.disabled = true;
		document.forms[0].propCity.disabled = true;
		document.forms[0].propState.disabled = true;
		document.forms[0].propZip.disabled = true;
	}//end if
	else{
		document.forms[0].propState.value = "NY";
		document.forms[0].propAddress.disabled = false;
		document.forms[0].propCity.disabled = false;
		document.forms[0].propState.disabled = false;
		document.forms[0].propZip.disabled = false;
	}//end else
	
	changeColor(document.forms[0].propAddress, color);
	changeColor(document.forms[0].propCity, color);
	changeColor(document.forms[0].propState, color);
	changeColor(document.forms[0].propZip, color);

}//end toggleSame

/*
 *
 */
function openStatusWindow(){
	
	var winWidth = 320, winHeight= 150;
	var xPos = (window.screen.width - winWidth) / 2;
	var yPos = (window.screen.height - winHeight) / 2;
	var winName = 'Status';
	var winAttributes = 'directories=0, status=0, menbar=0, toolbar=0, resizable=0, scrollbars=0, location=0, ' + 
					'width=' + winWidth + ', height=' + winHeight + ', left=' + xPos + ', top=' + yPos;

	window.open('showStatus.jsp?statusMsg=' + document.statusForm.statusMsg.value, winName, winAttributes);
}//end openStatusWindow

/*
 * Generates valid dates based on the year and month passed in
 * and populates the daysField with this valid dates.
 */
function generateValidDates(year, month, daysField){
	
	//Calculate the number of days.
	var numDays = (32 - new Date(year, month, 32).getDate());
	
	//Clear the list
	daysField.options.length = 0;

	for(i = 0; i < numDays; i ++){
		daysField.options[i] = new Option(i + 1);
	}//end for
	
}//end generateValidDates

/**
 *
 */
function autoTab(original,destination){

	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength")){
		destination.focus()
	}//end if
}//end autoTab

function showFAQ(){
	
	var winWidth = 640, winHeight= 475;
	var xPos = (window.screen.width - winWidth) / 2;
	var yPos = (window.screen.height - winHeight) / 2;
	var winName = 'Status';
	var winAttributes = 'directories=0, status=0, menbar=0, toolbar=0, resizable=0, scrollbars=1, location=0, ' + 
					'width=' + winWidth + ', height=' + winHeight + ', left=' + xPos + ', top=' + yPos;

	window.open('faq.jsp', winName, winAttributes);	
	
}//end showTermsOfSale

/*** LOAD AND FORM SUBMIT FUNCTIONS ***/

function loadSalesSchedule(){

	var now = new Date();
	var month = now.getMonth();
	var date = now.getDate();
	var year = now.getYear();
	var form = document.forms[0];
	
	generateValidDates(year, month, form.startDate);
	generateValidDates(year, month, form.endDate);

	form.startMonth.value = month;
	form.startDate.selectedIndex = (date - 1);
	form.startYear.value = year;
	
	form.endMonth.value = month;
	form.endDate.selectedIndex = (date - 1);
	form.endYear.value = year;
	
}//end loadSalesSchedule

function submitSalesSchedule(){
	if(validateSalesSchedule(document.forms[0])){
		document.scheduleForm.Submit.disabled = true;
		document.scheduleForm.submit();
	}//end if
}//end submitSalesSchedule

function viewSalesSchedulePDF(){	
	window.open("viewSalesSchedule.do?type=pdf", "SalesSchedule","alwaysRaised=1, status=1, resizable=1, width="+(screen.width-11)+", height="+(screen.height-79)+", left=0, top=0");
}//end submitSalesSchedulePDF()

function loadRPSRequest(){
	document.forms[0].firstName.focus();
	toggleSame('Y');
}//end loadRPSRequest

function submitRPSRequest(){
	
	if(validateRequestForm(document.forms[0])){
		document.forms[0].Submit.disabled = true;
		document.forms[0].submit();
	}//end if
	
}//end submitRPSRequest

function resetRPSRequest(){
	toggleSame('Y');
}//end resetForm

function loadRPSStatus(){
	
}//end loadRPSStatus

function submitRPSStatus(){
	if(validateStatusForm(document.forms[0])){
		document.forms[0].Submit.disabled = true;
		document.forms[0].submit();
	}//end if
}//end submitRPSStatus

//-->