// JavaScript Document

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function ExplorerFix() {
	for (linkindex in document.links) document.links[linkindex].onfocus = document.links[linkindex].blur;
	return true
}

if(document.all) document.onmousedown = ExplorerFix;
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function formsubmit(){
document.form.send.value = "yes";
document.form.submit();
}

function formerase(){
document.form.send.value = "no";
document.form.submit();
}

// ================================================================
// IMM091804: Javascript to handle installation estimate calculator
// ----------------------------------------------------------------
function checkNumeric()
{
	// Restrict Countertop area sq. ft. to numbers only
	sKC = new String(event.keyCode);
	sVK = new String("8,9,18,35,36,37,39,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105");
	event.returnValue = (sVK.indexOf(sKC) > -1 ? true : false);
}

function recalcEstimate()
{
	oFrm = document.forms[1];
	dEst = Number(oFrm.area.value) * 66.0;
	dEst += (oFrm.cutoutsink.checked == true ? 275.0 : 0.0);
	dEst += (oFrm.cooktop.checked == true ? 150.0 : 0.0);
	dEst += (oFrm.holes.checked == true ? 50.0 : 0.0);
	oFrm.total.value = String(dEst);
}

function consume()
{
	// Restrict final total field to tabbing only
	sKC = new String(event.keyCode);
	event.returnValue = (sKC == "9" ? true : false);
}
// ================================================================

// ================================================================
// IMM091804: Javscript for Contact Us form validation
// ----------------------------------------------------------------
function checkContact()
{
	oFrm = document.forms["ContactForm"];
	if (oFrm.refer.selectedIndex == 0)
	{
		alert("Please specify how you heard about us.");
		oFrm.refer.focus();
		return false;
	}

	sNme = new String(oFrm.name.value);
	if (sNme.length == 0)
	{
		alert("Please provide your full name before submitting the form.");
		oFrm.name.select();
		return false;
	}

	sPhn = new String(oFrm.phone.value);
	sTel = new String("");
	for (idx = 0; idx < sPhn.length; idx++ )
		if ("0123456789".indexOf(sPhn.substr(idx,1)) > -1)
			sTel += sPhn.substr(idx,1);

	if (sTel.length < 10)
	{
		alert("Please provide a valid telephone number, including area code.");
		oFrm.phone.select();
		return false;
	}

	sCmt = new String(oFrm.comments.value);
	if (sCmt.length == 0)
	{
		alert("Please describe your question or comment before submitting the form.");
		oFrm.comments.select();
		return false;
	}

	return true;
}
// ================================================================


// ================================================================
// IMM091804: Javascript for Application form validation
// ----------------------------------------------------------------
function checkApplication()
{
	oFrm = document.forms["ContactForm"];
	sNme = new String(oFrm.Applicant_Name.value);
	if (sNme.length == 0)
	{
		alert("Please provide your full name.");
		oFrm.Applicant_Name.select();
		return false;
	}

	sAdr = new String(oFrm.Applicant_Address.value);
	if (sAdr.length == 0)
	{
		alert("Please provide your street address.");
		oFrm.Applicant_Address.select();
		return false;
	}

	sCSZ = new String(oFrm.Applicant_City.value);
	if (sCSZ.length == 0)
	{
		alert("Please enter your City, State and ZipCode.");
		oFrm.Applicant_City.select();
		return false;
	}

	sPhn = new String(oFrm.Applicant_Phone.value);
	sTel = new String("");
	for (idx = 0; idx < sPhn.length; idx++ )
		if ("0123456789".indexOf(sPhn.substr(idx,1)) > -1)
			sTel += sPhn.substr(idx,1);

	if (sTel.length < 10)
	{
		alert("Please provide a valid telephone number, including area code.");
		oFrm.Applicant_Phone.select();
		return false;
	}

	sPos = new String(oFrm.Employment_Desired_Position.value);
	if (sPos.length == 0)
	{
		alert("Please specify the desired position you are applying for.");
		oFrm.Employment_Desired_Position.select();
		return false;
	}

	sDSD = new String(oFrm.Employment_Desired_StartDate.value);
	if (sDSD.length == 0)
	{
		alert("Please specify your desired start date.");
		oFrm.Employment_Desired_StartDate.select();
		return false;
	}

	sDSL = new String(oFrm.Employment_SalaryDesired.value);
	if (sDSL.length > 0)
	{
		sSal = new String("");
		for (idx = 0; idx < sDSL.length; idx++ )
			if ("0123456789".indexOf(sDSL.substr(idx,1)) > -1)
				sSal += sDSL.substr(idx,1);

		if (sSal.length == 0)
		{
			alert("Please specify a valid, numeric starting salary.");
			oFrm.Employment_SalaryDesired.select();
			return false;
		}
	}

	if (oFrm.CurrentlyEmployed[0].checked == false && oFrm.CurrentlyEmployed[1].checked == false)
	{
		alert("Please check whether you are currently employed.");
		return false;
	}

	if (oFrm.CurrentlyEmployed[0].checked == true)
	{
		if (oFrm.Can_Contact_Employer[0].checked == false && oFrm.Can_Contact_Employer[1].checked == false)
		{
			alert("Please specify whether we may contact your current employer.");
			return false;
		}
	}

	if (oFrm.Ever_Applied_Before[0].checked == false && oFrm.Ever_Applied_Before[1].checked == false)
	{
		alert("Please specify if you have ever applied to our company before.");
		return false;
	}

	/* IMM103004: Requested that education and prior employment history
	              information be NOT made mandatory...
	sHSL = new String(oFrm.HighSchoolLocation.value);
	if (sHSL.length == 0)
	{	
		alert("Please specify the name and location of the High School you went to.");
		oFrm.HighSchoolLocation.select();
		return false;
	}

	sHSY = new String(oFrm.HighSchoolYrsAttend.value);
	if (sHSY.length == 0)
	{
		alert("Please specify the number of years you attended your high school.");
		oFrm.HighSchoolYrsAttend.select();
		return false;
	}

	if (oFrm.HighSchoolGraduated[0].checked == false && oFrm.HighSchoolGraduated[1].checked == false)
	{
		alert("Please specify if you graduated from your high school.");
		return false;
	}

	sE1NA = new String(oFrm.Employer1_NameAddress.value);
	if (sE1NA.length == 0)
	{
		alert("Please specify the name and address of employer #1.");
		oFrm.Employer1_NameAddress.select();
		return false;
	}

	sE1DE = new String(oFrm.Employer1_Dates.value);
	if (sE1DE.length == 0)
	{
		alert("Please specify the dates you were employed for employer #1.");
		oFrm.Employer1_Dates.select();
		return false;
	}

	sE1SL = new String(oFrm.Employer1_Salary.value);
	if (sE1SL.length == 0)
	{
		alert("Please specify the salary you held at employer #1.");
		oFrm.Employer1_Salary.select();
		return false;
	}

	sE1PH = new String(oFrm.Employer1_Position.value);
	if (sE1PH.length == 0)
	{
		alert("Please specify the position you held at employer #1.");
		oFrm.Employer1_Position.select();
		return false;
	}

	sE2NA = new String(oFrm.Employer2_NameAddress.value);
	if (sE2NA.length == 0)
	{
		alert("Please specify the name and address of employer #2.");
		oFrm.Employer2_NameAddress.select();
		return false;
	}

	sE2DE = new String(oFrm.Employer2_Dates.value);
	if (sE2DE.length == 0)
	{
		alert("Please specify the dates you were employed for employer #2.");
		oFrm.Employer2_Dates.select();
		return false;
	}

	sE2SL = new String(oFrm.Employer2_Salary.value);
	if (sE2SL.length == 0)
	{
		alert("Please specify the salary you held at employer #2.");
		oFrm.Employer2_Salary.select();
		return false;
	}

	sE2PH = new String(oFrm.Employer2_Position.value);
	if (sE2PH.length == 0)
	{
		alert("Please specify the position you held at employer #2.");
		oFrm.Employer2_Position.select();
		return false;
	}

	sE3NA = new String(oFrm.Employer3_NameAddress.value);
	if (sE3NA.length == 0)
	{
		alert("Please specify the name and address of employer #3.");
		oFrm.Employer3_NameAddress.select();
		return false;
	}

	sE3DE = new String(oFrm.Employer3_Dates.value);
	if (sE3DE.length == 0)
	{
		alert("Please specify the dates you were employed for employer #3.");
		oFrm.Employer3_Dates.select();
		return false;
	}

	sE3SL = new String(oFrm.Employer3_Salary.value);
	if (sE3SL.length == 0)
	{
		alert("Please specify the salary you held at employer #3.");
		oFrm.Employer3_Salary.select();
		return false;
	}

	sE3PH = new String(oFrm.Employer3_Position.value);
	if (sE3PH.length == 0)
	{
		alert("Please specify the position you held at employer #3.");
		oFrm.Employer3_Position.select();
		return false;
	}
	*/

	sR1NA = new String(oFrm.Reference1_NameAddress.value);
	if (sR1NA.length == 0)
	{
		alert("Please specify the name and address for reference #1.");
		oFrm.Reference1_NameAddress.select();
		return false;
	}

	sR1BN = new String(oFrm.Reference1_Business.value);
	if (sR1BN.length == 0)
	{
		alert("Please specify the name of the company that reference #1 is employed by.");
		oFrm.Reference1_Business.select();
		return false;
	}

	sR1YN = new String(oFrm.Reference1_YearsKnown.value);
	if (sR1YN.length == 0)
	{
		alert("Please specify the number of years you have known reference #1.");
		oFrm.Reference1_YearsKnown.select();
		return false;
	}

	sR2NA = new String(oFrm.Reference2_NameAddress.value);
	if (sR2NA.length == 0)
	{
		alert("Please specify the name and address for reference #2.");
		oFrm.Reference2_NameAddress.select();
		return false;
	}

	sR2BN = new String(oFrm.Reference2_Business.value);
	if (sR2BN.length == 0)
	{
		alert("Please specify the name of the company that reference #2 is employed by.");
		oFrm.Reference2_Business.select();
		return false;
	}

	sR2YN = new String(oFrm.Reference2_YearsKnown.value);
	if (sR2YN.length == 0)
	{
		alert("Please specify the number of years you have known reference #2.");
		oFrm.Reference2_YearsKnown.select();
		return false;
	}
	
	return true;
}
// ================================================================