
// shows the drop down menu 

function showDDNav(){
	args = showDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = showDDNav.arguments;
		theObj = eval(args[1]);
  		if (theObj) if(theObj.visibility=='hide'){theObj.visibility = 'show';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if (theObj) if(theObj.style.visibility=='hidden'){hideElement('SELECT');theObj.style.visibility = 'visible'}
		}
	else{return}
}


// hides the drop down menu 

function hideDDNav(){
	args = hideDDNav.arguments;
        if(br=="N"){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = eval(args[1]);
                if (theObj) if(theObj.visibility=='show'){theObj.visibility = 'hide';}
	}
	else if(br=="IE"){
		theObj=eval(args[0]);
                //alert(theObj.id);
		if (theObj) if(theObj.style.visibility=='visible'){showElement('SELECT');theObj.style.visibility = 'hidden';}
		}
	else{return}
}


// hides drop down menu when menu is active

function hideDiv(me,event){
	//args = hideDiv.arguments;
        args = hideDiv.arguments;
	if(br=="N"){}
	else if(br=="IE"){
        
		theObj=eval(args[0]);
		// calculate active size of menu
		leftDiv=theObj.offsetLeft +2
		rightDiv=theObj.offsetLeft + theObj.clientWidth -2
		topDiv=theObj.offsetTop +2
		bottomDiv=theObj.offsetTop + theObj.clientHeight -2
//                alert(leftDiv);
//                alert(rightDiv);
//                alert(topDiv);
//                alert(bottomDiv);
//		if(window.event.clientY > bottomDiv || 
//			window.event.clientY < topDiv || 
//			window.event.clientX < leftDiv || 
//			window.event.clientX > rightDiv)
//			{theObj.style.visibility = 'hidden';showElement('SELECT');}				
//		}
                //alert(event.clientY+" "+bottomDiv  );
                if(event.clientY > bottomDiv || 
			event.clientY < topDiv || 
			event.clientX < leftDiv || 
			event.clientX > rightDiv)
			{theObj.style.visibility = 'hidden';showElement('SELECT');}
		}
	else{return}
}


// highlight menuitem

function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=eval(args[0]);
		if(theObj.style.backgroundColor="#144c1f"){
			theObj.style.backgroundColor="#144c1f";
		}
	}
	else{return}
}

// highlight off menuitem

function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
	theObj=eval(args[0]);
		if(theObj.style.backgroundColor="#144c1f"){
			theObj.style.backgroundColor="#376f3e";
		}
	}
	else{return}
}


// highlight on menuitem in netscape

function menuOver(){

	var args, theMenu;
	args = menuOver.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor="#144c1f" 
}


// highlight off menuitem in netscape

function menuOut(){
	var args, theMenu;
        args = menuOut.arguments;
	theMenu = eval(args[0]);
	theMenu.bgColor="#376f3e" 
}

// goes to specified url

function gotoUrl(){
	args = gotoUrl.arguments;
	popupOff();
        location.href=args[0]
        
}


// hides specified tag

function hideElement(HTMLtag)
{
	for ( i = 20; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "hidden";
                
	}
        
}


// shows specified tag

function showElement(HTMLtag)
{
	for ( i = 1; i < document.all.tags(HTMLtag).length; i++)
	{
		obj = document.all.tags(HTMLtag)[i];
		obj.style.visibility = "visible";
	}
}


// build the divs for IE

var tdID = 0
function doDiv(){
	args = doDiv.arguments;
	var divID = args[0];
	var x = args[1];
	var divLeft = args[2];
	var arrowPos = args[3];
	var divTop = args[4];
	
	objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; left:"+ divLeft +"px; top:"+ divTop +"px; width:170px; z-index:300; background-color:#376f3e; visibility:hidden; padding-left:2;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv('document.all[\\'" + divID + "\\']',event)\">"
        //objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; left:"+ divLeft +"px; top:"+ divTop +"px; width:170px; z-index:300; background-color:#999999; visibility:hidden; padding-left:2;\" onMouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv(event)\">"
	objDiv += "<div id=\"arrow\" style=\"position:relative; background-color:#376f3e; width:170px;\"><img src=../commercials_files/commercials_files/images/navspace.gif width=1 height=1 align="+ arrowPos +"></div>"
	//alert(divID);
	for (y = 0; y < 14; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"x" + tdID + "\" style=\"position:relative; background-color:#376f3e; width:170px;\" onMouseover=\"divOver('document.all[\\'x" + tdID + "\\']')\" onMouseout=\"divOut('document.all[\\'x" + tdID + "\\']')\"><span class=\"nav\" onClick=\"gotoUrl('"+menuData[x][y][1]+"')\">"+menuData[x][y][0]+"</span></div>"
		tdID = tdID +1
		}
	}
	
	objDiv +="<div id=\"line\" style=\"position:relative; background-color:#376f3e; width:170px; height:5px;\"><img src=../commercials_files/commercials_files/images/navbar2.gif width=\"172\" height=\"2\"></div></div>"
	//alert(objDiv);
	document.write(objDiv);
	
}


// build the layers for netscape

function doLayer(){
	args = doLayer.arguments;
	var nestLayerID=0
	var layerID = args[0];
	var x = args[1];
	var layerLeft = args[2];
	var layerTop = args[4];

	if(navigator.platform.indexOf("Win") < 0){layerInc=15;layerStyle="navMenu";}
	else{layerInc=22;layerStyle="navMenu";}	
		
	objDiv = "<layer id=\""+ layerID +"\" Z-INDEX=100 BGCOLOR=\"#666666\" width=170 LEFT="+ layerLeft +" TOP="+ layerTop +" VISIBILITY=HIDE onmouseover=\"showDDNav('','document.layers[\\'"+ layerID +"\\']')\" onmouseout=\"hideDDNav('','document.layers[\\'"+ layerID +"\\']')\">"
	objDiv +="<layer id=\"line\" BGCOLOR=\"#666666\" width=170 HEIGHT=4 Z-INDEX=700><center><img src=../commercials_files/commercials_files/images/navbar.gif width=172 height=2></center></layer>"
	
	var nestTop=3
		for (y = 0; y < 14; y++){
		    if(menuData[x][y][0]!=null){
			
	objDiv += "<layer id=\"x"+nestLayerID+"\" CLIP=\"2,0,147,22\" class=\""+ layerStyle +"\" Z-INDEX=700 BGCOLOR=\"#999999\" HEIGHT=21 width=170 TOP="+ nestTop +" onmouseover=\"menuOver('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\" onmouseout=\"menuOut('document.layers[\\'"+ layerID +"\\'].document.layers[\\'x"+nestLayerID+"\\']')\"><a id=navstyle href=javascript:gotoUrl('"+menuData[x][y][1]+"')><font color=#FFFFFF>"+ menuData[x][y][0]
	objDiv +="</font></a></layer>"		

	nestLayerID=nestLayerID+1
	nestTop=nestTop+layerInc
	objDiv +="<layer id=\"line2\" BGCOLOR=\"#666666\" width=170 HEIGHT=5 Z-INDEX=700 TOP="+ nestTop +"><center><img src=../commercials_files/commercials_files/images/navbar.gif width=172 height=2></center></layer>"
	nestTop=nestTop+2
			}
		}
	objDiv +="<layer id=\"lineEnd\" BGCOLOR=\"#666666\" width=170 HEIGHT=4 Z-INDEX=700 TOP="+ nestTop +"></layer></layer>"

	document.write(objDiv)
}


// SET BROWSERS
var br
if(navigator.appName == 'Netscape' && document.layers != null){br="N";}
else if(navigator.appName == 'Microsoft Internet Explorer' && document.all != null){br="IE";}
else{br=null}
br="IE";

// DECLARE ARRAYS
menuData = new Array()
for (i=0; i < 8; i++) {
	menuData[i] = new Array(40)
	for (j=0; j < 14; j++) {
		menuData[i][j] = new Array(2)
	}
}

// SECTION01 - HOME
menuData[0][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Home Page";
menuData[0][0][1]="homeAction.do";
menuData[0][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Contact Us";
menuData[0][1][1]="contactUsB4Action.do";


// SECTION02 - INVENTORY
menuData[1][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Inventory";
menuData[1][0][1]="preownedListAllAction.do";
menuData[1][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Cash Specials";
menuData[1][1][1]="preownedListAllAction.do?inventoryType=cash";

// SECTION05 - TradeIn
menuData[3][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Get a Quick Quote";
menuData[3][0][1]="buying_quote.jsp";
menuData[3][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Trade-In Appraisal";
menuData[3][1][1]="buying_tradein.jsp";
menuData[3][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Payment Calculator";
menuData[3][2][1]="buying_calc.jsp";

// SECTION06 - ABOUT US
menuData[5][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Our Company";
menuData[5][0][1]="about.jsp";
menuData[5][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Contact Us";
menuData[5][1][1]="contactUsB4Action.do";
menuData[5][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Locate Us";
menuData[5][2][1]="locate_home.jsp";


// SET DROPDOWN POSITION FOR BROWSERS
if(br=="N"){
	doLayer('section01',0,200,'left',86)
	doLayer('section02',1,200,'left',114)
	doLayer('section03',2,200,'left',140)
	doLayer('section04',3,200,'left',166)
	doLayer('section05',4,200,'left',192)
	doLayer('section06',5,200,'left',218)
	doLayer('section07',6,200,'left',218)
}else if(br=="IE"){
	doDiv('section01',0,200,'left',88)
	doDiv('section02',1,200,'left',114)
	doDiv('section03',2,200,'left',140)
	doDiv('section04',3,200,'left',166)
	doDiv('section05',4,200,'left',192)
	doDiv('section06',5,200,'left',218)
	doDiv('section07',6,200,'left',218)
}else{}


//NISSANUSA
function nissanusa(url){
nissWnd = window.open(url,'trcNissanUsa','WIDTH=760,height=440,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=1,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=1,status=1,titlebar=0,toolbar=1,z-lock=0,screenX=0,screeny=0,left=0,top=0');
nissWnd.focus();
}

//function openWindow(url,name,height,width,top,left,alignCenter,otherfeatures)
//{
//	if (alignCenter){
//				top=(window.screen.availHeight/2)-(height/2);
//				left=(window.screen.availWidth/2)-(width/2);
//	 }  
//    var features="width=" + width + "px,height=" + height +"px,";
//		features=features + "left=" + left + "px," + "top=" + top + "px,";    
//		features=features+otherfeatures;
//    var obj_window=window.open (url,name,features);
//    obj_window.focus();
//    return window.open (url,name,features);
//
// }

  

var popUp = false;

function doOnLoad(){
  for(var i = 0; i < document.links.length; i++){
    document.links[i].onclick = popupOff;
  }
  popUp = true;
}

function popupOff(){
  popUp = false;
}
function doOnUnLoad(){
  //alert(popUp);
  //if(popUp)window.open('couponDisplayAction.do','Coupon', 'WIDTH=600,height=530,alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,z-lock=0,screenX=40,screeny=40,left=20,top=20');
}
window.onload=function(){
  //alert(popUp);
  doOnLoad();
}
window.onbeforeunload=function(){
  doOnUnLoad();
}

