initZip = true;
initAreaCode = true;
initState = true;

diag = new Image; diag.src = "images/nav/diagonal.gif";
diago = new Image; diago.src = "images/nav/diagonalo.gif";

ns = (document.layers)? true:false
ie = (document.all)? true:false
ns6 = (navigator.appName == "Netscape" && document.getElementById)? true:false
winIE5 = false;
var browserString = navigator.appVersion;
if (navigator.userAgent.indexOf("Win") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	if (parseInt(browserString.charAt(22)) < 6){
		winIE5 = true;
	}
}
macIE = false;
macNS = false;
var browserString = navigator.appVersion;
if (navigator.userAgent.indexOf("Mac") > -1 && navigator.appName == "Microsoft Internet Explorer"){
	macIE = true;
}else if(navigator.userAgent.indexOf("Mac") > -1 && navigator.appName != "Microsoft Internet Explorer"){
	macNS = true;
}
function hide(id){
	if (ns) document.layers[id].visibility = "hide"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "hidden"
	}
	else if (ie) document.all[id].style.visibility = "hidden"
}
function show(id){
	if (ns) document.layers[id].visibility = "show"
	if (ns6){
		var obj = eval("document.getElementById('" + id + "')")
		obj.style.visibility = "visible"
	}
	else if (ie) document.all[id].style.visibility = "visible"
}
function findPosX(obj){
	var curleft = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
		//alert(curleft);
		return curleft;
	}
}
function findPosY(obj){
	var curtop = 0;
	if (document.getElementById || document.all){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
		return curtop;
	}else{
		curtop += obj.y;
		return curtop;
	}
}

function swap(theName,theImg){
	eval("document." + theName + ".src=" + theImg + ".src");
}

loaded = false;
loaded_pagenav = false;
totalSubs = 6;
masterTop = 81;

function doNav(ele, state){
	if(state > 0){
		ele.style.color = '98C0FD';
		if(!macIE){
			ele.style.backgroundImage = "url('images/nav/bgwide.gif')";
		}
	}else{
		ele.style.color = 'ffffff';
		if(!macIE){
			ele.style.backgroundImage = "url('images/nav/bg.gif')";
		}
	}
}
function doSubNav(ele, state){
	if(state > 0){
		ele.style.backgroundColor = '98C0FD';
		ele.style.color = '000000';
	}else{
		ele.style.backgroundColor = 'D82000';
		ele.style.color = 'ffffff';
	}
}
function doPageNav(ele, state){
	if(loaded_pagenav){
		if(state > 0){
			ele.style.backgroundColor = 'd3d3d3';
			ele.style.color = '000000';
		}else{
			ele.style.backgroundColor = 'ffffff';
			ele.style.color = '003685';
		}
	}
}
function doNavReset(n){
	if(loaded){
		for(i = 0; i < totalSubs; i ++){
			if(i == n){
				if(ns6){
					var obj = eval("document.getElementById('theBase" + i + "')")
					obj.style.backgroundImage = "url('images/nav/bgwide.gif')";
					obj.style.color = '98C0FD';
				}else if(ie){
					if(!macIE){
						document.all["theBase" + i].style.backgroundImage = "url('images/nav/bgwide.gif')";
					}
					document.all["theBase" + i].style.color = '98C0FD';
				}
				show("menu" + (i + 1));
				show("bigHide");
				if(i == 5 && !ns && !macIE){
					swap("theDiag","diago");
					//document.theDiag.src=diago.src;
				}
			}else{
				if(ns6){
					var obj = eval("document.getElementById('theBase" + i + "')")
					obj.style.backgroundImage = "url('images/nav/bg.gif')";
					obj.style.color = 'ffffff';
				}else if(ie){
					if(!macIE){
						document.all["theBase" + i].style.backgroundImage = "url('images/nav/bg.gif')";
					}
					document.all["theBase" + i].style.color = 'ffffff';
				}
				hide("menu" + (i + 1));
				if(!ns && !macIE){
					swap("theDiag","diag");
				}
			}
		}
		if(n == -1){
			hide("bigHide");
		}
	}
}

function menuItem(displayText,goLink,theWidth){
	this.displayText = displayText;
	this.goLink = goLink;
	this.theWidth = theWidth;
}
mainNav = new Array();
	mainNav[0] = new menuItem("The Safety Experts","autoglass_safety.asp",114);
	mainNav[1] = new menuItem("Find a Location","storeLocator.asp",113);
	mainNav[2] = new menuItem("Schedule and Track Appointments","jnpapptlaunch.asp",200);
	mainNav[3] = new menuItem("Our Services","services.asp",101);
	mainNav[4] = new menuItem("Our Partners","agencyPartners.asp",129);
	mainNav[5] = new menuItem("About Us","corpprfile.asp",79);
sub1 = new Array();
	//sub1[0] = new menuItem("No Compromises Autoglass Replacement","no_compromises.asp");
	sub1[0] = new menuItem("Safety and Convenience","safety_convenience.asp");
	sub1[1] = new menuItem("Our 180° Difference","180_difference.asp");
	sub1[2] = new menuItem("Red Tag Guarantee","redtag.asp");
	sub1[3] = new menuItem("Auto Glass University","autoglass_university.asp");
	sub1[4] = new menuItem("Glass Facts","glass_fact1.asp");
	sub1[5] = new menuItem("Glass-Max Protection","learn_more.asp");
	sub1[6] = new menuItem("Windshield Safety","windshield_safety.asp");
	sub1[7] = new menuItem("Auto Glass Terms","auto-glass-terms.asp");
sub2 = new Array();
sub3 = new Array();
	sub3[0] = new menuItem("Make An Appointment","jnpapptlaunch.asp");
	sub3[1] = new menuItem("Check Appointment Status","AppointmentStatus.aspx");
	sub3[2] = new menuItem("Customer Feedback","CustomerSatisfaction_invoice.aspx");
sub4 = new Array();
	sub4[0] = new menuItem("Auto Glass Replacement","autoglass_replacement.asp");
	sub4[1] = new menuItem("Windshield Repair","windshield_repair.asp");
	sub4[2] = new menuItem("Insurance Claims","claims.asp");
	sub4[3] = new menuItem("National Service","national_service.asp");
	sub4[4] = new menuItem("Mobile Service","mobile_service.asp");
	sub4[5] = new menuItem("In-Shop Service","inshop_service.asp");
sub5 = new Array();
	sub5[0] = new menuItem("Make an Appointment","JNPApptLaunch.asp");
	sub5[1] = new menuItem("Insurance FAQs","insfaqs.asp");
sub6 = new Array();
	sub6[0] = new menuItem("Our History","history.asp");
	sub6[1] = new menuItem("Join The Team","emplopps.asp");
	sub6[2] = new menuItem("Contact Us","contactus.asp?t=CF");
	sub6[3] = new menuItem("Site Map","sitemap.asp");
function writeMainNav(){
	theClass = "topNav";
	line = "<td width=1 bgcolor='EA8682'><img src=\"images/spacer.gif\" width=1 height=1></td>";
	outNav = "<table cellpadding=0 cellspacing=0 border=0 width=700><tr>";
	for(i = 0; i < totalSubs; i ++){
		if(ns){
			theLink = "<a href=\"" + mainNav[i].goLink + "\" onMouseOver=\"doNavReset(" + i + "); swap('theDiag','diago');\">" + mainNav[i].displayText + "</a>";
			theClass = "topNavNS";
		}else{
			theLink = mainNav[i].displayText;
		}
		theBase = " id=\"theBase" +	i + "\"><ilayer name=\"theBaseNS" + i + "\"><layer></layer></ilayer>";
		outNav += "<td width=\"" + mainNav[i].theWidth + "\" align=center class=\"" + theClass + "\" nowrap onClick=\"parent.location='" + mainNav[i].goLink + "';\" onMouseOver=\"doNavReset(" + i + ")\"" + theBase;
		outNav += theLink + "</td>";
		if(i != (mainNav.length - 1)){
			outNav += line;
		}
	}
	if(ns){
		diagImage = "o";
	}else{
		diagImage = "";
	}
	outNav += "<td width=16><img src=\"images/nav/diagonal" + diagImage + ".gif\" width=16 height=20 name=\"theDiag\"></td></tr></table>";
	document.write(outNav);
}
function writePageNav(pageArray, highlight, noGo, theTitle, theURL){
	pageArray = eval(pageArray);
	theLine = "<tr><td width=216 bgcolor='8F8F8F'><img src=\"images/spacer.gif\" width=1 height=1></td></tr>";
	pnavHTML = "<table cellpadding=0 cellspacing=0 border=0 width=216>";
	pnavHTML += "<tr><td width=216><a href=\"" + theURL + "\"><img src=\"images/page_nav/titles/" + theTitle + ".gif\" border=0 width=216 height=18></a></td></tr>"
	if(noGo > 0){
		for(p = 0; p < pageArray.length; p ++){
			if(highlight == p){
				img = "";
			}else{
				img = "blank";
			}
			theDisplayText = "<img src=\"images/page_nav/flag" + img + ".gif\" width=35 height=24 align=absmiddle>" + pageArray[p].displayText;
			if(pageArray[p].displayText == "No Compromises Autoglass Replacement"){
				theDisplayText = "<table cellpadding=0 cellspacing=0 border=0 width=216><tr><td width=35><img src=\"images/page_nav/flag" + img + ".gif\" width=35 height=24 align=absmiddle></td><td class=\"pageNav\" width=181>No Compromises Autoglass Replacement</td></tr></table>";
			}
			pnavHTML += "<tr><td width=216 class=\"pageNav\" onMouseOver=\"doPageNav(this,1);\" onMouseOut=\"doPageNav(this,0);\" onClick=\"parent.location='" + pageArray[p].goLink + "';\">" + theDisplayText + "</td></tr>";
			pnavHTML += theLine;
		}
	}
	pnavHTML += "</table>";
	document.write(pnavHTML);
	loaded_pagenav = true;
}
function writeLayers(){
	outHTML = "";
	menuWith = 150;//120;
	if(ns){
		outHTML += "<div id=\"mud\" style=\"position:absolute;left:0px;top:0px;visibility:hidden;z-index:0\"></div>"
	}
	for(j = 1; j <= mainNav.length; j ++){
		currentMenu = eval("sub" + j);
		theLength = currentMenu.length;
		n = (j - 1)
		if(ie){
			anchorX = findPosX(document.all("theBase" + n));
			//theClass = "navSub";
		}else if(ns6){
			anchorX = findPosX(document.getElementById("theBase" + n));
			//theClass = "navSub";
		}else if(ns){
			anchorX = document.layers["theBaseNS" + n].pageX;
			//theClass = "navSubNS4";
		}
		outHTML += "<div id=\"menu" + j + "\" style=\"position:absolute; top:" + masterTop + "px; left:" + anchorX + "px; visibility:hidden; z-index:100;\">";
		if(theLength > 0){
			outHTML += "<table cellpadding=0 cellspacing=0 border=0>"; // width=" + menuWith + "
			for(z = 0; z < theLength; z ++){
				if(ns){
					theLink = "<a href=\"" + currentMenu[z].goLink + "\">" + currentMenu[z].displayText + "</a>";
					theClass = "subNavNS";
				}else{
					theLink = currentMenu[z].displayText;
					theClass = "subNav";
				}
				outHTML += "<tr><td nowrap class=\"" + theClass + "\" onClick=\"parent.location='" + currentMenu[z].goLink + "';\" onMouseOver=\"doSubNav(this,1);\" onMouseOut=\"doSubNav(this,0);\">" + theLink + "<img src=\"images/spacer.gif\" width=12 height=20 align=absmiddle></td></tr>";
				outHTML += "<tr><td widdth=" + menuWith + " bgcolor=\"E25750\"><img src=\"images/spacer.gif\" width=1 height=1></td></tr>";
			}
			outHTML += "</table>";
		}
		outHTML += "</div>";
	}
	outHTML += "<div id=\"bigHide\" style=\"position:absolute;left:0px;top:" + masterTop + "px;visibility:hidden;z-index:1\"><a href=\"#\" onMouseOver=\"doNavReset(-1)\"><img src=\"images/spacer.gif\" width=766 height=300 border=0></a></div>";
	document.write(outHTML);
	loaded = true;
}
function check(f,field,fieldName,numberLength){
	field = eval("f." + field);
	if(fieldName == "Zip Code"){
		initZip = false;
		displayAlert = "Zip Code";
	}
	if(fieldName == "Area Code"){
		initAreaCode = false;
		displayAlert = "Phone Number (including Area Code, numbers only, no dashes)";
	}
	if(fieldName == "State"){
		initState = false;
		if(field.value == ""){
			alert("Please select your State");
			return false;
		}else{
		    return true;
		}    
	}else{
	    if(isStringWhitespace(field.value)){
		    alert("Please enter your " + displayAlert);
		    field.focus();
		    return false;
	    }else{
		    if(field.value.length != numberLength || isNaN(field.value)){
			    alert("Please enter your " + numberLength + " digit " + displayAlert);
			    field.select();
			    return false;
		    }else{
			    if(fieldName == "Area Code"){
				    NPA = field.value.substring(0,3);
				    NXX = field.value.substring(3,6);
				    EXTN = field.value.substring(6,10);
				    f.NPA.value = NPA;
				    f.NXX.value = NXX;
				    f.EXTN.value = EXTN;
			    }
			    return true;
		    }
	    }
    }
}
function doField(ele,whichField){
	if(whichField == "ZipCode" && initZip){
		ele.value = "";
	}else if(whichField == "NPA" && initAreaCode){
		ele.value = "";
	}
}