
// shows the drop down menu 

function showDDNav(){
	args = showDDNav.arguments;
	if(br=="N"){
		var args, theObj;
		args = showDDNav.arguments;
		theObj = document.getElementById(args[1]);
  		if (theObj) if(theObj.display=='none'){theObj.display = 'block';}
	}
	else if(br=="IE"){
		theObj=document.getElementById(args[0]);
				if (theObj) if(theObj.style.display=='none'){theObj.style.display = '';}
		}
	else{return}
}


// hides the drop down menu 

function hideDDNav(){
	args = hideDDNav.arguments;
        if(br=="N"){
		var args, theObj;
		args = hideDDNav.arguments;
		theObj = document.getElementById(args[1]);
                if (theObj) if(theObj.display=='block'){theObj.display = 'none';}
	}
	else if(br=="IE"){
		theObj=document.getElementById(args[0]);
                //alert(theObj.id);
		if (theObj) if(theObj.style.display==''){theObj.style.display = 'none';}
		}
	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=document.getElementById(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.display = 'none';showElement('SELECT');}				
//		}
                //alert(event.clientY+" "+bottomDiv  );
                if(event.clientY > bottomDiv || 
			event.clientY < topDiv || 
			event.clientX < leftDiv || 
			event.clientX > rightDiv)
			{theObj.style.display = 'none';}
		}
	else{return}
}


// highlight menuitem

function divOver(){
	args = divOver.arguments;
	if(br=="N"){}
	else if(br=="IE"){
		theObj=document.getElementById(args[0]);
		if(theObj.style.backgroundColor="#C71444"){
			theObj.style.backgroundColor="#999999";
		}
	}
	else{return}
}

// highlight off menuitem

function divOut(){
	args = divOut.arguments;
	if(br=="N"){}
	else if(br=="IE"){
	theObj=document.getElementById(args[0]);
		if(theObj.style.backgroundColor="#004474"){
			theObj.style.backgroundColor="#666666";
		}
	}
	else{return}
}


// highlight on menuitem in netscape

function menuOver(){

	var args, theMenu;
	args = menuOver.arguments;
	theMenu = document.getElementById(args[0]);
	theMenu.bgColor="#004474" 
}


// highlight off menuitem in netscape

function menuOut(){
	var args, theMenu;
        args = menuOut.arguments;
	theMenu = document.getElementById(args[0]);
	theMenu.bgColor="#666666" 
}

// 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.display = "none";
                
	}
        
}


// shows specified tag

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


// 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; margin-left:"+ divLeft +"px; top:"+ divTop +"px; width:170px; z-index:300; background-color:#999999; display:none; padding-left:2;\" onmouseover=\"showDDNav('"+ divID +"\')\"  onMouseout=\"hideDiv('" + divID + "',event)\">"
        //objDiv = "<div id=\"" + divID + "\" style=\"position:absolute; left:"+ divLeft +"px; top:"+ divTop +"px; width:170px; z-index:300; background-color:#999999; display:none; padding-left:2;\" onmouseover=\"showDDNav('document.all[\\'"+ divID +"\\']')\"  onMouseout=\"hideDiv(event)\">"
	objDiv += "<div id=\"arrow\" style=\"position:relative; background-color:#999999; width:170px;\"><img src=../commercials_files/commercials_files/images/navspace.gif width=1 height=1 align="+ arrowPos +"></div>"
	//alert(divID);
	for (y = 0; y < 19; y++){
	    if(menuData[x][y][0]!=null){
		objDiv += "<div id=\"x" + tdID + "\" style=\"text-align:left; position:relative; background-color:#666666; width:170px;\" onmouseover=\"divOver('x" + tdID + "')\" onMouseout=\"divOut('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:#666666; 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 +" display=none 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 < 19; 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)
}


//=====================================================
// THIS BELOW IS THE SECTION THAT SHOWS UP AS DROWDOWN
// THIS SECTION COULD BE COPIED DIRECTLY INTO THE PAGE
// BY ROGEE ROGERS - May 18, 2003
//=====================================================

// 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 < 19; 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]="contact.jsp";
menuData[0][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Copyright";
menuData[0][2][1]="copyright.jsp";
menuData[0][3][0]="&nbsp;&nbsp;&raquo;&nbsp;Privacy";
menuData[0][3][1]="privacy.jsp";
menuData[0][4][0]="&nbsp;";
menuData[0][4][1]="javascript:void();";
menuData[0][5][0]="&nbsp;&nbsp;&raquo;&nbsp;Coupon Center";
menuData[0][5][1]="getCouponDataB4Action.do";
menuData[0][6][0]="&nbsp;&nbsp;&raquo;&nbsp;Advertisements";
menuData[0][6][1]="ads.jsp";
menuData[0][7][0]="&nbsp;&nbsp;&raquo;&nbsp;TV Commercials";
menuData[0][7][1]="commercial_closedeal.jsp";

// SECTION02 - NEW VEHICLES
menuData[1][0][0]="&nbsp;&nbsp;&raquo;&nbsp;New Vehicle Line-up";
menuData[1][0][1]="newVehicleLineUpAction.do";
menuData[1][1][0]="&nbsp;<img src='images/navicon_sentra.jpg' height=20 width=42 border=0> Sentra";
menuData[1][1][1]="newVehicleAction.do?introOfModel=sentra";
menuData[1][2][0]="&nbsp;<img src='images/navicon_altima.jpg' height=20 width=42 border=0> Altima";
menuData[1][2][1]="newVehicleAction.do?introOfModel=altima";
menuData[1][3][0]="&nbsp;<img src='images/navicon_maxima.jpg' height=20 width=42 border=0> Maxima";
menuData[1][3][1]="newVehicleAction.do?introOfModel=maxima";
menuData[1][4][0]="&nbsp;<img src='images/navicon_370z.jpg' height=20 width=42 border=0> 370Z";
menuData[1][4][1]="newVehicleAction.do?introOfModel=370z";
menuData[1][5][0]="&nbsp;<img src='images/navicon_murano.jpg' height=20 width=42 border=0> Murano";
menuData[1][5][1]="newVehicleAction.do?introOfModel=murano";
menuData[1][6][0]="&nbsp;<img src='images/navicon_xterra.jpg' height=20 width=42 border=0> Xterra";
menuData[1][6][1]="newVehicleAction.do?introOfModel=xterra";
menuData[1][7][0]="&nbsp;<img src='images/navicon_pathfinder.jpg' height=20 width=42 border=0> Pathfinder";
menuData[1][7][1]="newVehicleAction.do?introOfModel=pathfinder";
menuData[1][8][0]="&nbsp;<img src='images/navicon_pathfinderarmada.jpg' height=20 width=42 border=0> Armada";
menuData[1][8][1]="newVehicleAction.do?introOfModel=armada";
menuData[1][9][0]="&nbsp;<img src='images/navicon_frontier.jpg' height=20 width=42 border=0> Frontier";
menuData[1][9][1]="newVehicleAction.do?introOfModel=frontier";
menuData[1][10][0]="&nbsp;<img src='images/navicon_titan.jpg' height=20 width=42 border=0> Titan";
menuData[1][10][1]="newVehicleAction.do?introOfModel=titan";
menuData[1][11][0]="&nbsp;<img src='images/navicon_cube.jpg' height=20 width=42 border=0> Cube";
menuData[1][11][1]="newVehicleAction.do?introOfModel=cube";
menuData[1][12][0]="&nbsp;<img src='images/navicon_rogue.jpg' height=20 width=42 border=0> Rogue";
menuData[1][12][1]="newVehicleAction.do?introOfModel=rogue";
menuData[1][13][0]="&nbsp;<img src='images/navicon_gt-r.jpg' height=20 width=42 border=0> GT-R";
menuData[1][13][1]="newVehicleAction.do?introOfModel=gt-r";
menuData[1][14][0]="&nbsp;<img src='images/navicon_leaf.jpg' height=20 width=42 border=0> Leaf";
menuData[1][14][1]="newVehicleAction.do?introOfModel=leaf";
menuData[1][15][0]="&nbsp;<img src='images/navicon_quest.jpg' height=20 width=42 border=0> Quest";
menuData[1][15][1]="newVehicleAction.do?introOfModel=quest";
menuData[1][16][0]="&nbsp;<img src='images/navicon_versa.jpg' height=20 width=42 border=0> Versa";
menuData[1][16][1]="newVehicleAction.do?introOfModel=versa";
menuData[1][17][0]="&nbsp;<img src='images/navicon_juke.jpg' height=20 width=42 border=0> Juke";
menuData[1][17][1]="newVehicleAction.do?introOfModel=juke";
menuData[1][18][0]="&nbsp;&nbsp;&raquo;&nbsp;<B>Inventory SEARCH</B>";
menuData[1][18][1]="newInvSearchListAction.do";


// SECTION03 - PRE-OWNED
menuData[2][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Certified Vehicles";
menuData[2][0][1]="preowned.jsp";
menuData[2][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Vehicle Coupons";
menuData[2][1][1]="getCouponDataAction.do?type=vehicles";
menuData[2][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Manager's Specials";
menuData[2][2][1]="managers_specials.jsp"
menuData[2][3][0]="&nbsp;&nbsp;&raquo;&nbsp;<B>Inventory SEARCH</B>";
menuData[2][3][1]="preownedListAllAction.do";

// SECTION04 - BUYING
menuData[3][0][0]="&nbsp;&nbsp;&raquo;&nbsp;The Experience";
menuData[3][0][1]="buying.jsp";
menuData[3][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Get a Quick Quote";
menuData[3][1][1]="buying_quote.jsp";
menuData[3][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Credit Application";
menuData[3][2][1]="buying_credit.jsp";
menuData[3][3][0]="&nbsp;&nbsp;&raquo;&nbsp;Trade-In Appraisal";
menuData[3][3][1]="buying_tradein.jsp";
menuData[3][4][0]="&nbsp;&nbsp;&raquo;&nbsp;Schedule Test Drive";
menuData[3][4][1]="buying_test.jsp";
menuData[3][5][0]="&nbsp;&nbsp;&raquo;&nbsp;Payment Calculator";
menuData[3][5][1]="buying_calc.jsp";
menuData[3][6][0]="&nbsp;&nbsp;&raquo;&nbsp;Rentals";
menuData[3][6][1]="buying_rentals.jsp";
menuData[3][7][0]="&nbsp;";
menuData[3][7][1]="javascript:void();";
menuData[3][8][0]="&nbsp;&nbsp;&raquo;&nbsp;Advertisements";
menuData[3][8][1]="ads.jsp";
menuData[3][9][0]="&nbsp;&nbsp;&raquo;&nbsp;TV Commercials";
menuData[3][9][1]="commercial_closedeal.jsp";

// SECTION05 - SERVICE
menuData[4][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Customer Care";
menuData[4][0][1]="service.jsp";
menuData[4][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Appointments";
menuData[4][1][1]="serviceappt.jsp";
menuData[4][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Service Coupons";
menuData[4][2][1]="getCouponDataAction.do?type=service";

// SECTION06 - PARTS
menuData[5][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Quality Parts";
menuData[5][0][1]="quality_parts.jsp";
menuData[5][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Parts Request";
menuData[5][1][1]="partsrequest.jsp";
menuData[5][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Parts Coupons";
menuData[5][2][1]="getCouponDataAction.do?type=parts";

// SECTION07 - ABOUT US
menuData[6][0][0]="&nbsp;&nbsp;&raquo;&nbsp;Our Company";
menuData[6][0][1]="about.jsp";
menuData[6][1][0]="&nbsp;&nbsp;&raquo;&nbsp;Our Team";
menuData[6][1][1]="about_staff.jsp";
menuData[6][2][0]="&nbsp;&nbsp;&raquo;&nbsp;Contact Us";
menuData[6][2][1]="contact.jsp";
menuData[6][3][0]="&nbsp;&nbsp;&raquo;&nbsp;Locate Us";
menuData[6][3][1]="locate_home.jsp";
menuData[6][4][0]="&nbsp;&nbsp;&raquo;&nbsp;Employment";
menuData[6][4][1]="employment.jsp";

// SET DROPDOWN POSITION FOR BROWSERS
if(br=="N"){
	doLayer('section01',0,0,'left',86)
	doLayer('section02',1,48,'left',86)
	doLayer('section03',2,168,'left',86)
	doLayer('section04',3,278,'left',86)
	doLayer('section05',4,388,'left',86)
	doLayer('section06',5,498,'left',86)
	doLayer('section07',6,545,'left',86)
}else if(br=="IE"){
	doDiv('section01',0,0,'left',88)
	doDiv('section02',1,50,'left',88)
	doDiv('section03',2,170,'left',88)
	doDiv('section04',3,280,'left',88)
	doDiv('section05',4,390,'left',88)
	doDiv('section06',5,500,'left',88)
	doDiv('section07',6,546,'left',88)
}else{doLayer('section01',0,0,'left',86)
	doLayer('section02',1,48,'left',86)
	doLayer('section03',2,168,'left',86)
	doLayer('section04',3,278,'left',86)
	doLayer('section05',4,388,'left',86)
	doLayer('section06',5,498,'left',86)
	doLayer('section07',6,545,'left',86)}


//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++){
    //alert(document.links[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();
}

