// JavaScript Document
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_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_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];}
}

// JavaScript Document
var dwNumberOfCollapsibleMenu = 4;

//close all expanded menu
function closeAll(){
	for (i=1; i<=dwNumberOfCollapsibleMenu; i++){
		var menuNow = 'menu' + i;
		var bigNow = 'big' + i;
		var ob = document.getElementById(menuNow).style;
		ob.display = 'none';
		var divBig = document.getElementById(bigNow);		
		divBig.style.backgroundImage = "url("+"/images/leftNavSmall.jpg"+")";
	}
}

//close all expanded menu
function closeAllMenu(objID){
	for (i=1; i<=dwNumberOfCollapsibleMenu; i++){
		var menuNow = 'menu' + i;
		var bigNow = 'big' + i;
		var ob = document.getElementById(menuNow).style;
		if (objID != menuNow)ob.display = 'none';
		
		var divBig = document.getElementById(bigNow);
		divBig.style.backgroundImage = "url("+"/images/leftNavSmall.jpg"+")";
	}
}


//close all expanded menu
function closeAllMenu2(objID){
	for (i=1; i<=dwNumberOfCollapsibleMenu; i++){
		var menuNow = 'menu' + i;
		var bigNow = 'big' + i;
		var ob = document.getElementById(menuNow).style;
		if (objID != menuNow)ob.display = 'none';
		
		var divBig = document.getElementById(bigNow);
		divBig.style.backgroundImage = "url("+"/images/leftNavSmall.jpg"+")";
	}
}

/*
ORiginal toggle for time parking

function toggleMenu(objID, element) {
	//if not found objid exit
	if (!document.getElementById) return;
	
	//close all expanded menu
	closeAllMenu(objID);
	
	//get the expanded/or not state of the objid and toggle it in the style
	var ob = document.getElementById(objID).style;
	ob.display = (ob.display == 'block')?'none': 'block';
	
	//get the expanded/or not state of the objid and change the image background
	if (ob.display == 'none'){
		dwClickedAgain(element);
	}else {
		dwClicked(element);
	}
	
	//
	window.location.hash='top';
}
*/


//expand/shrink menu if clicked
function toggleMenu(objID, element) {
	//toggleMenu('menu2', 'big2');
	//if not found objid exit
	if (!document.getElementById) return;
	
	//close all expanded menu
	closeAllMenu(objID);
	
	 
	//hack begins
	changeDiv('menu1', objID);
	changeDiv('big1', element);
	
	objID = 'menu1';
	element = 'big1';
	
	//hack ends;
	
	//get the expanded/or not state of the objid and toggle it in the style
	var ob = document.getElementById(objID).style;
	ob.display = (ob.display == 'block')?'none': 'block';
	
	//get the expanded/or not state of the objid and change the image background
	if (ob.display == 'none'){
		dwClickedAgain(element);
	}else {
		dwClicked(element);
	}
	
	//
	window.location.hash='top';
}

//expand/shrink menu if clicked
function toggleMenu2(objID, element) {
	//toggleMenu('menu2', 'big2');
	//if not found objid exit
	if (!document.getElementById) return;
	
	//close all expanded menu
	closeAllMenu2(objID);
	
	
	//hack begins
	changeDiv('menu1', objID);
	changeDiv('big1', element);
	
	objID = 'menu1';
	element = 'big1';
	
	//hack ends;
	
	//get the expanded/or not state of the objid and toggle it in the style
	var ob = document.getElementById(objID).style;
	ob.display = (ob.display == 'block')?'none': 'block';
	
	//get the expanded/or not state of the objid and change the image background
	if (ob.display == 'none'){
		dwClickedAgain2(element);
	}else {
		dwClicked2(element);
	}
	
	//
	window.location.hash='top';
}

//if clicked change bg to  big
function dwClicked(element)
{
	var divBig = document.getElementById(element);
	divBig.style.backgroundImage = "url("+"/images/leftNavBigHeader.jpg"+")";
}

//if clicked again change bg to small
function dwClickedAgain(element)
{
	var divBig = document.getElementById(element);
	divBig.style.backgroundImage = "url("+"/images/leftNavSmall.jpg"+")";
}

//if clicked change bg to  big
function dwClicked2(element)
{
	var divBig = document.getElementById(element);
	divBig.style.backgroundImage = "url("+"/images/leftNavBigHeader.jpg"+")";
}


//if clicked again change bg to small
function dwClickedAgain2(element)
{
	var divBig = document.getElementById(element);
	divBig.style.backgroundImage = "url("+"/images/leftNavSmall.jpg"+")";
}

//swap div content
function changeDiv(dwTo, dwFrom){
	dwTemp = document.getElementById(dwTo).innerHTML;
	document.getElementById(dwTo).innerHTML = document.getElementById(dwFrom).innerHTML;
	document.getElementById(dwFrom).innerHTML = dwTemp;
}


//get the file name out of URL
function showfile() {
	var pathname = location.pathname;
	var filename = pathname.split("/");
	//filename.length-x, x is the place where the file name is located from the end of the array
	return filename[filename.length-2];
}


//check pagename and open the menu that has that page under it.
function openSpecificPage(){
	var myFileName = showfile(); 
	switch (myFileName){
		
		case "licensed-software-attendance-enterprise":
			toggleMenu2('menu3', 'big3');
			break;
		case "web-hosted-software-attendance":
			toggleMenu2('menu3', 'big3');
			break;
		case "biometric-technologies":
			toggleMenu2('menu3', 'big3');
			break;
		case "card-reader-technologies":
			toggleMenu2('menu3', 'big3');
			break;
		case "browser-based-technologies":
			toggleMenu2('menu3', 'big3');
			break;
		case "interactive-voice-response-technologies":
			toggleMenu2('menu3', 'big3');
			break;
			
			
		case "access-control":
			toggleMenu2('menu2', 'big2');
			break;
		case "visitor-management":
			toggleMenu2('menu2', 'big2');
			break;
		case "turnstiles":
			toggleMenu2('menu2', 'big2');
			break;
		case "employee-photo-identification-systems":
			toggleMenu2('menu2', 'big2');
			break;
		case "emergency-mass-notification-systems":
			toggleMenu2('menu2', 'big2');
			break;
			
		case "parking-control":
			toggleMenu2('menu1', 'big1');
			break;	
		case "parking-access-revenue-control-systems":
			toggleMenu2('menu1', 'big1');
			break;	
		case "radio-frequency-identification-rfid":
			toggleMenu2('menu1', 'big1');
			break;	
		case "design-consulting-services":
			toggleMenu2('menu1', 'big1');
			break;	
			
		case "video-recording-systems":
			toggleMenu2('menu4', 'big4');
			break;	
		case "analog-and-internet-protocol-ip-video-cameras":
			toggleMenu2('menu4', 'big4');
			break;	
			
		default:
			closeAll();
			break;
			
	}
}

function chekAll(form){
	
}

function checkEmail(form){
	if ( (form.email.value !="" ) && (form.confirm_email.value !="" ) )
	{
		if (form.email.value != form.confirm_email.value){
			alert("email and confirm email does not match");
			form.email.focus();
			return false;
		}
	}
	return true;
}


function checkEmailSupport(form){
	if ( (form.contact_email.value !="" ) && (form.confirm_email.value !="" ) )
	{
		if (form.contact_email.value != form.confirm_email.value){
			alert("email and confirm email does not match");
			form.contact_email.focus();
			return false;
		}
	}
	return true;
}
