//Api for mears site
//Global
var isCSS, isW3C, isIE4, isNN4, isIE6CSS;
var currNav;

function initAPI(){
	if(document.images){
		isCSS = (document.body && document.body.style) ? true : false;
		isW3C = (isCSS && document.getElementById) ? true : false;
		isIE4 = (isCSS && document.all) ? true : false;
		isNN4 = (document.layers) ? true : false
		isIE6CSS = (document.compatMode && document.compatMode.indexOf("CSS1") >= 0) ? true : false;
	}
}
//set event handler
window.onload = init;

function init(){
	initAPI();
	CheckNav();
}

function seekLayer(doc,name){
	var theObj;
	for (var i =0; i< doc.layers.length; i++){
	if(doc.layers[i].name == name){
	theObj = doc.layers[i];
	break;
	}
//Dive into nested layers if necessary
if (doc.layers[i].document.layers.length > 0){
		theObj =  seekLayer(document.layers[i].document, name);
		}
	}
	return theObj;
}
	
// Convert object name string or object reference
// into a valid element object reference

function getRawObject(obj){
	var theObj;
	if(typeof obj == "string") {
		if(isW3C){
				theObj = document.getElementById(obj);
			} else if (isIE4) {
				theObj = document.all(obj);
			} else if (isNN4) {
				theObj = seekLayer(document, obj);
			}
		} else {
			//pass through object reference
			theObj = obj;
		}
			return theObj;
	}
	
//Convert object name string or object reference
//into a valid style (orNN4 layer) reference
function getObject(obj){
	var theObj = getRawObject(obj);
	if(theObj && isCSS) {
	theObj = theObj.style;
	}
	return theObj;
}
	
//Set the visibily to visible
function SwapLayers(obj){
	var theObj = getObject(obj);
	if(theObj) {
		if(theObj.display == "none")
			theObj.display = "";
		else
			theObj.display = "none";
	}
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function navOn(obj){
	var theObj = document.getElementById(obj);
	if(theObj) {
			theObj.className = "selected";
	}
}

function setMsg(msg){
	window.status = msg;
	return true;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  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 CheckNav(){
PageTitle= self.document.title.substring(8,80)
PageURL  = self.document.location.href			

	if (PageTitle == "Homepage"){
		currNav = 'home';
		navOn('navHome');
	}
	if (PageTitle == "Total Support"){
		currNav = 'support';
		navOn('navSupport');
	}
	if (PageTitle == "Driving Force"){
		currNav = 'driving';
		navOn('navDriving');
	}
	if (PageTitle == "Exceptional Service"){
		currNav = 'servive';
		navOn('navService');
	}
	if (PageTitle == "Nationwide Coverage"){
		currNav = 'coverage';
		navOn('navCoverage');
	}
	if (PageTitle == "Vehicle Storage"){
		currNav = 'storage';
		navOn('navStorage');
	}
	if (PageTitle == "Forms/ Downloads"){
		currNav = 'downloads';
		navOn('navDownloads');
	}
	if (PageTitle == "Contact Us"){
		currNav = 'contact';
		navOn('navContact');
	}
	if (PageTitle == "Quick Quote"){
		currNav = 'quote';
		navOn('navQuote');
	}
	if (PageTitle == "Login"){
		currNav = 'logins';
		navOn('navLogin');
	}
	if (PageTitle == "Job Opportunities"){
		currNav = 'jobs';
		navOn('navJobs');
	}
}