﻿


function gotoKaba() {
    kabaWin = window.open("http://www.kaba.com/index-e.html","");
}



/////////////////////////////////////
//  Function name: QuickLink()
//  Parameter(s): select object
//  Purpose: Sends user to the URL value of selected option
/////////////////////////////////////
function QuickLink(selobj) {
   var selval = selobj.options[selobj.selectedIndex].value;
   if (selval==0 || selval==-1) {
      return;
   } else {
       document.location=selval;
   }
}



//reloads the window if Nav4 resized
function MM_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function showMsg(msg,fld) {
    alert(msg);fld.focus();fld.select();return;
}

function validQty(fld,max) {
    if (fld.value=="") { fld.value=0 }
    fval=fld.value;
    if (fval<0 || isNaN(fval) || fval % 1 != 0 || fval>max) {
         return false;
    }
    else {
         return true;
    }
}

function validQty2(fld) {
    fval=fld.value;
    if (fval=="" || fval<0 || isNaN(fval) || fval % 1 != 0) {
         return false;
    }
    else {
         return true;
    }
}

function readRadios(grp) {
	var found = -1 ;
	for(i=0;i<grp.length;i++) {
		if(grp[i].checked==true) { found=i; }
	}
	return found;
}

function validateLitRequest(fm) {
  found=false;
  for(i=1;i<=14;i++) {
      qfld=document.getElementById("qty_"+i);
      if(!validQty(qfld,10)) { showMsg("Invalid quantity. Must be 10 or less.",qfld);return false; }
      if(qfld.value>0) { found=true; }
  }
  for(i=15;i<=15;i++) {
      qfld=document.getElementById("qty_"+i);
      if(!validQty(qfld,3)) { showMsg("Invalid quantity. Must be 3 or less.",qfld);return false; }
      if(qfld.value>0) { found=true; }
  }
 if(!found) { alert("You did not order any literature. Please enter your desired quantities.");return false; }
  if (fm.company.value=="") { showMsg("Please enter your company name.",fm.company);return false; }
  if (fm.full_name.value=="") { showMsg("Please enter your name.",fm.full_name);return false; }
  if (fm.address1.value=="") { showMsg("Please enter your address.",fm.address1);return false; }
  if (fm.city.value=="") { showMsg("Please enter your city.",fm.city);return false; }
  if (fm.state.selectedIndex==0) { alert("Please select your state.");fm.state.focus();return false; }
  z=fm.zip.value;
  if (z=="" || z<0 || isNaN(z) || z % 1 != 0 || z.length<5) { showMsg("Please enter your 5-digit zip code.",fm.zip);return false }
  if (fm.customer_type.selectedIndex==0) { alert("Please select your customer type.");fm.customer_type.focus();return false; }
  if (fm.phone.value.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) == -1) {
	showMsg("Please enter phone number as xxx-xxx-xxxx.",fm.phone); return false;
  }
  if(fm.user_email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
	showMsg("Please enter a valid email address.",fm.user_email);return false;
  }
  //everything okay, so...
return true;
}

function validateLagardLitReq(fm) {
  found=false;
  for(i=1;i<=6;i++) {
      qfld=document.getElementById("qty_"+i);
      if(!validQty(qfld,10)) { showMsg("Invalid quantity. Must be 10 or less.",qfld);return false; }
      if(qfld.value>0) { found=true; }
  }
  for(i=7;i<=7;i++) {
      qfld=document.getElementById("qty_"+i);
      if(!validQty(qfld,3)) { showMsg("Invalid quantity. Must be 3 or less.",qfld);return false; }
      if(qfld.value>0) { found=true; }
  }
 if(!found) { alert("You did not order any literature. Please enter your desired quantities.");return false; }
  if (fm.company.value=="") { showMsg("Please enter your company name.",fm.company);return false; }
  if (fm.full_name.value=="") { showMsg("Please enter your name.",fm.full_name);return false; }
  if (fm.address1.value=="") { showMsg("Please enter your address.",fm.address1);return false; }
  if (fm.city.value=="") { showMsg("Please enter your city.",fm.city);return false; }
  if (fm.state.selectedIndex==0) { alert("Please select your state.");fm.state.focus();return false; }
  z=fm.zip.value;
  if (z=="" || z<0 || isNaN(z) || z % 1 != 0 || z.length<5) { showMsg("Please enter your 5-digit zip code.",fm.zip);return false }
  if (fm.customer_type.selectedIndex==0) { alert("Please select your customer type.");fm.customer_type.focus();return false; }
  if (fm.phone.value.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) == -1) {
	showMsg("Please enter phone number as xxx-xxx-xxxx.",fm.phone); return false;
  }
  if(fm.user_email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
	showMsg("Please enter a valid email address.",fm.user_email);return false;
  }
  //everything okay, so...
return true;
}


function validateEmployment(fm) {
	if (fm.JOB_NUMBER.value=="") { showMsg("Please enter job number.",fm.JOB_NUMBER);return false; }
	if (fm.FULL_NAME.value=="") { showMsg("Please enter your name.",fm.FULL_NAME);return false; }
	if (fm.ADDRESS.value=="") { showMsg("Please enter your address.",fm.ADDRESS);return false; }
	if (fm.CITY.value=="") { showMsg("Please enter your city.",fm.CITY);return false; }
	if (fm.STATE.selectedIndex == 0)  { alert("Please select your state."); fm.STATE.focus(); return false; }
	if (fm.ZIP_CODE.value.search(/^[0-9][0-9][0-9][0-9][0-9]$/) == -1) {
		showMsg("Please enter your zip code.",fm.ZIP_CODE); return false;
	}
	if (fm.PHONE.value.search(/^[0-9][0-9][0-9]\-[0-9][0-9][0-9]\-[0-9][0-9][0-9][0-9]$/) == -1) {
		showMsg("Please enter phone number as xxx-xxx-xxxx.",fm.PHONE); return false;
	}
	if (fm.EMAIL.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMsg("This does not appear to be a valid email address. Please try again.",fm.EMAIL);return false;
	}
	if (readRadios(fm.EMPLOYMENT_DESIRED) == -1) { showMsg("Please select type of employment desired.",fm.EMPLOYMENT_DESIRED[0]);return false; }
	if (fm.DATE_AVAILABLE.value.search(/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/) == -1) {
		showMsg("Please enter date available as mm/dd/yy.",fm.DATE_AVAILABLE); return false;
	}
	if (readRadios(fm.OVERTIME_OK) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.OVERTIME_OK[0]);return false; }
	if (readRadios(fm.TRAVEL_OK) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.TRAVEL_OK[0]);return false; }
	if (readRadios(fm.PREVIOUS_EMPLOYEE) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.PREVIOUS_EMPLOYEE[0]);return false; }
	if (readRadios(fm.HAS_PAPERS) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.HAS_PAPERS[0]);return false; }
	if (readRadios(fm.UNDER_18_PERMIT) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.UNDER_18_PERMIT[0]);return false; }
	if (readRadios(fm.CONVICTED) == -1) { showMsg("Please answer all of the Yes/No questions.",fm.CONVICTED[0]);return false; }
	if (fm.CONVICTED[0].checked==true && fm.CONVICTION_EXPLANATION.value=="") {
		showMsg("Please explain your conviction or guilty plea.",fm.CONVICTION_EXPLANATION);return false;
	}
	if (fm.DRIVERS_LICENSE.value=="") { showMsg("Please enter drivers license number or click \"don't drive.\"",fm.DRIVERS_LICENSE);return false; }
	if (fm.CONDITIONS_ACCEPTED.checked==false) { alert("You must read and agree to our Terms & Conditions before we will accept your online application."); return false; }
	document.getElementById('submitButton').value = "Submitting... One moment please.";
	document.getElementById('submitButton').disabled = true;
	// everything ok, so...
	return true;
}


function validateOptional(fm) {
	if (fm.JOB_NUMBER.value=="") { showMsg("Please enter job number.",fm.JOB_NUMBER);return false; }
	if (fm.FULL_NAME.value=="") { showMsg("Please enter your name.",fm.FULL_NAME);return false; }
	if (readRadios(fm.GENDER) == -1) { showMsg("Please select your gender.",fm.GENDER[0]);return false; }
	if (fm.DATE_OF_BIRTH.value.search(/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9]$/) == -1) {
		showMsg("Please enter your date of birth as mm/dd/yy.",fm.DATE_OF_BIRTH); return false;
	}
	if (fm.ZIP_CODE.value.search(/^[0-9][0-9][0-9][0-9][0-9]$/) == -1) {
		showMsg("Please enter your zip code.",fm.ZIP_CODE); return false;
	}
	if (readRadios(fm.ETHNIC_GROUP) == -1) { showMsg("Please select your ethnic group.",fm.ETHNIC_GROUP[0]);return false; }
	document.getElementById('submitButton').value = "Submitting... One moment please.";
	document.getElementById('submitButton').disabled = true;
	// everything ok, so...
	return true;
}



function validateCenconInput(fm) {
	//return true;
	if (fm.Company.value=="") { showMsg("Please enter company name.",fm.Company);return false; }
	if (fm.Address_1.value=="") { showMsg("Please enter address.",fm.Address_1);return false; }
	if (fm.City.value=="") { showMsg("Please enter city.",fm.City);return false; }
	if (fm.State.value=="") { showMsg("Please enter state or province.",fm.State);return false; }
	if (fm.Country.value=="") { showMsg("Please enter country.",fm.Country);return false; }
	if (fm.Zip.value=="") { showMsg("Please enter zip or postal code.",fm.Zip);return false; }
	
	if (fm.Main_Contact_Name.value=="") { showMsg("Please enter the main contact person's name.",fm.Main_Contact_Name);return false; }
	if (fm.Main_Contact_Title.value=="") { showMsg("Please enter the main contact person's title.",fm.Main_Contact_Title);return false; }
	if (fm.Main_Contact_Phone.value=="") { showMsg("Please enter the main contact person's phone.",fm.Main_Contact_Phone);return false; }
	if (fm.Main_Contact_Email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMsg("This does not appear to be a valid email address. Please try again.",fm.Main_Contact_Email);return false;
	}
	if (fm.IT_Contact_Name.value=="") { showMsg("Please enter the IT contact person's name.",fm.IT_Contact_Name);return false; }
	if (fm.IT_Contact_Title.value=="") { showMsg("Please enter the IT contact person's title.",fm.IT_Contact_Title);return false; }
	if (fm.IT_Contact_Phone.value=="") { showMsg("Please enter the IT contact person's phone.",fm.IT_Contact_Phone);return false; }
	if (fm.IT_Contact_Email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMsg("This does not appear to be a valid email address. Please try again.",fm.IT_Contact_Email);return false;
	}
	if (fm.Other_Contact_Name.value=="") { showMsg("Please enter the back-up contact person's name.",fm.Other_Contact_Name);return false; }
	if (fm.Other_Contact_Title.value=="") { showMsg("Please enter the back-up contact person's title.",fm.Other_Contact_Title);return false; }
	if (fm.Other_Contact_Phone.value=="") { showMsg("Please enter the back-up contact person's phone.",fm.Other_Contact_Phone);return false; }
	if (fm.Other_Contact_Email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMsg("This does not appear to be a valid email address. Please try again.",fm.Other_Contact_Email);return false;
	}

	if(fm.Cencon_Version.selectedIndex==0) { alert("Please select Cencon version or \"None\"."); fm.Cencon_Version.focus(); return false; }
	if(fm.CenTran_Version.selectedIndex==0) { alert("Please select CenTran version or \"None\"."); fm.CenTran_Version.focus(); return false; }
	if(fm.CenBank_Version.selectedIndex==0) { alert("Please select CenBank version or \"None\"."); fm.CenBank_Version.focus(); return false; }
	if(fm.SQL_Version.selectedIndex==0) { alert("Please select SQL server version."); fm.SQL_Version.focus(); return false; }
	
	if (fm.Requirements_Accepted.checked==false) { alert("Minimum Requirements must be agreed to before form can be submitted."); return false; }
	if (fm.Agreement_Name.value=="") { showMsg("Please enter your name.",fm.Agreement_Name);return false; }
	
	if(!validQty(fm.Number_of_Cencon_Locks) || fm.Number_of_Cencon_Locks.value==0 ) { 
		showMsg("Invalid quantity. Please enter the number of Cencon locks.",fm.Number_of_Cencon_Locks);return false; 
	}
	if (fm.Version_3_Start_Date.value.search(/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]$/) == -1) {
		showMsg("Please enter date as mm/dd/yyyy.",fm.Version_3_Start_Date); return false;
	}
	if(!validQty2(fm.Locks_in_FLM)) { showMsg("Invalid quantity. Please enter number or zero.",fm.Locks_in_FLM);return false; }
	if(!validQty2(fm.Keys_in_FLM)) { showMsg("Invalid quantity. Please enter number or zero.",fm.Keys_in_FLM);return false; }
	if(!validQty2(fm.Locks_in_Route)) { showMsg("Invalid quantity. Please enter number or zero.",fm.Locks_in_Route);return false; }
	if(!validQty2(fm.Keys_in_Route)) { showMsg("Invalid quantity. Please enter number or zero.",fm.Keys_in_Route);return false; }
	if(!validQty2(fm.Locks_in_Bank)) { showMsg("Invalid quantity. Please enter number or zero.",fm.Locks_in_Bank);return false; }
	if(!validQty2(fm.Keys_in_Bank)) { showMsg("Invalid quantity. Please enter number, zero, or leave blank.",fm.Keys_in_Bank);return false; }
	if(!validQty2(fm.Branches_in_Country) || fm.Branches_in_Country.value < 1) {
		showMsg("Invalid quantity. Must be 1 or more.",fm.Branches_in_Country);return false;
	}
	if(!validQty2(fm.Cencon_PC_Clients) || fm.Cencon_PC_Clients.value < 1) {
		showMsg("Invalid quantity. Must be 1 or more.",fm.Cencon_PC_Clients);return false;
	}
	if (fm.Software_Company.value=="") { showMsg("Please enter the company name with whom your software order was submitted.",fm.Software_Company);return false; }
	if (fm.Salesperson.value=="") { showMsg("Please enter the sales person you've spoken with.",fm.Salesperson);return false; }
	if (fm.Training_Date.value.search(/^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]$/) == -1) {
		showMsg("Please enter date as mm/dd/yyyy.",fm.Training_Date); return false;
	}
	if (fm.Instructor_Name.value=="") { showMsg("Please enter Kaba instructor's name or n/a.",fm.Instructor_Name);return false; }
	if (fm.Training_Location.value=="") { showMsg("Please enter training location or n/a.",fm.Training_Location);return false; }
 //everything's ok so...
 return true;
}


function validateACCInputForm(fm) {
	//return true;
	if (fm.customer_ID.value=="") { showMsg("Please enter your Customer ID.",fm.customer_ID);return false; }
	if (fm.Main_Contact_Name.value=="") { showMsg("Please enter your full name.",fm.Main_Contact_Name);return false; }
	if (fm.Main_Contact_Title.value=="") { showMsg("Please enter your title.",fm.Main_Contact_Title);return false; }
	if (fm.Fax_or_Email.value=="") { showMsg("Please enter either a fax number or email address.",fm.Fax_or_Email);return false; }

 //everything's ok so...
 return true;
}


function validateALOAForm(fm) {
	//return true;
	if (fm.Name.value=="") { showMsg("Please enter your full name.",fm.Name);return false; }
	if (fm.Company.value=="") { showMsg("Please enter a company name or type N/A.",fm.Company);return false; }
	if (fm.Address_1.value=="") { showMsg("Please enter your street address.",fm.Address_1);return false; }
	if (fm.City.value=="") { showMsg("Please enter your city name.",fm.City);return false; }
	if (fm.State.value=="") { showMsg("Please enter your state of residence.",fm.State);return false; }
	if (fm.Zip.value=="") { showMsg("Please enter a valid zip code.",fm.Zip);return false; }
	if (fm.Main_Contact_Email.value.search(/^\w+((-\w+)|(\.\w+)|(\+\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9][A-Za-z0-9]+$/) == -1) {
		showMsg("Please enter a valid email address.",fm.Main_Contact_Email);return false;
	}
	
	if(fm.First_CGP_choice.selectedIndex==0) { alert("Please select your first ComboGard Pro class preference or \"None\"."); fm.First_CGP_choice.focus(); return false; }
	if(fm.Second_CGP_choice.selectedIndex==0) { alert("Please select your second ComboGard Pro class preference or \"None\"."); fm.Second_CGP_choice.focus(); return false; }
	if(fm.First_AG_choice.selectedIndex==0) { alert("Please select your first AuditGard class preference or \"None\"."); fm.First_AG_choice.focus(); return false; }
	if(fm.Second_AG_choice.selectedIndex==0) { alert("Please select your second AuditGard class preference or \"None\"."); fm.Second_AG_choice.focus(); return false; }
	
//everything's ok so...
 return true;
}




/* Hot, random banner on home page.
Place each banner into the array using the following format:
var bannerArray[INCREMENTAL_NUMBER] = "IMAGE_PATH_AND_FILE_NAME|IMAGE_ALT_TEXT|HREF";
Note each of the 3 values are separated by a pipe | and the whole thing is wrapped in double-quotes.
If the image need not be hot, set HREF to none.
See examples below.
*/
var bannerArray = new Array();
bannerArray[0] = "imgs/home_0.jpg|Kaba Mas Product Configurator|a.php?page=configurator";
bannerArray[1] = "imgs/home_5.jpg|Kaba Mas: Gitcon Series|a.php?page=gitcon_main";
bannerArray[2] = "imgs/home_2.jpg|Kaba Mas: Unicon Series|a.php?page=unicon_series";
bannerArray[3] = "imgs/home_3.jpg|Kaba Mas: Auditcon 2 Series|a.php?page=auditcon_main";
bannerArray[4] = "imgs/home_4.jpg|Kaba Mas: Careers|a.php?page=careers";
bannerArray[5] = "imgs/home_5.jpg|Kaba Mas: Gitcon Series|a.php?page=gitcon_main";
bannerArray[5] = "imgs/home_6.jpg|Kaba Mas: Cencon System 2000|a.php?page=cencon_main";

// Do not edit below this line
var rndm = Math.round(Math.random() * (bannerArray.length-1));
var temparray = bannerArray[rndm].split("|");
var homeimage = new Image(); homeimage.src=temparray[0];
var imgstr = "<img id=\"mainimage\" src=\"" + temparray[0] + "\" width=\"553\" height=\"175\" border=\"0\" alt=\"" + temparray[1] + "\">";
if (temparray[2]!= "none") {
	imgstr = "<a href=\"" + temparray[2] + "\">" + imgstr + "</a>";
}


// For the special Kaba Americas rollover swap
var amerimage=new Image(); amerimage.src="imgs/home_amer.jpg";
function amerOn() {
   if(document.getElementById) { document.getElementById("mainimage").src = amerimage.src; }
} 
function amerOff() {
   if(document.getElementById) { document.getElementById("mainimage").src = homeimage.src; }
}


// "only 1 open at a time" popup function //
var popupWin;
function openPop(url,width,height,addloptions){
	var xspot=Math.round((screen.width/2)-(width/2));
	var yspot=Math.round((screen.height/2)-(height/2)-30);
	features = "height="+height+",width="+width+",top="+yspot+",screenY="+yspot+",left="+xspot+",screenX="+xspot;
	if (addloptions && addloptions!="") { features += ","+addloptions; }
	if (!popupWin || popupWin.closed){
		popupWin = window.open(url, '', features);
	}
	else {
		window.popupWin.close();
		popupWin = window.open(url, '', features);
	}
}


 

