/*
* Showroom
*/
function Showroom(model, style, application){
		this.vsModel = model;
		this.style = style;
		this.application = application;
		this.table = createTable;
		this.writeShopModel = writeShopModel;
		this.writeShopStyle = writeShopStyle;
		this.writeShopApplication = writeShopApplication;
		this.selectByModel = selectByModel;
		this.selectByBody = selectByBody;
		this.selectByVehicle = selectByVehicle;
		this.selected = "vsModel";
		if ((window.location.href.indexOf("Door") > -1) || (window.location.href.indexOf("Vans") > -1)
			|| (window.location.href.indexOf("Trucks") > -1) || (window.location.href.indexOf("Utility") > -1)
			|| (window.location.href.indexOf("Convertibles") > -1) || (window.location.href.indexOf("Crossovers") > -1)
			|| (window.location.href.indexOf("Medium_Duty") > -1))
			this.selected = "style";
			
			
			
		if ((window.location.href.indexOf("Catering") > -1) || (window.location.href.indexOf("Ambulance") > -1) || 
			(window.location.href.indexOf("Dump_Body") > -1) || (window.location.href.indexOf("Platform") > -1) ||
			(window.location.href.indexOf("Plow") > -1) || (window.location.href.indexOf("Shuttle") > -1) ||
			(window.location.href.indexOf("/Utility") > -1) || (window.location.href.indexOf("Van_Body") > -1) ||
			(window.location.href.indexOf("Wrecker") > -1) || (window.location.href.indexOf("products/police.jsp") > -1))
			this.selected = "app";
}

function ShopByModel(name,href, vehicle, imageUrl){
	this.name = name;
	if (typeof(href) != "undefined")
		this.href =href;
	this.vehicle= "imageHref";
	if (typeof(imageUrl) != "undefined")
		this.imageUrl= imageUrl;
		
}

function ShopByStyle(name,href, vehicle, imageUrl){
	this.name = name;
	if (typeof(href) != "undefined")
		this.href =href;
	this.vehicle= "imageHref";
	if (typeof(imageUrl) != "undefined")
		this.imageUrl= imageUrl;
}

function ShopByApplication(name,href, vehicle, imageUrl){
	this.name = name;
	if (typeof(href) != "undefined")
		this.href =href;
	this.vehicle= "imageHref";
	if (typeof(imageUrl) != "undefined")
		this.imageUrl= imageUrl;
}

function writeShopApplication(){
	//var table = "<table  cellspacing='0' cellpadding='0'>" 
	var table=""
	this.selectByVehicle();
	for (var i=0; i< this.application.length; i = i + 2){
		  if (typeof(this.application[i+1]) != "undefined")
			   table += " <tr><td class='imageTd'> <a class='" + this.application[i].vehicle + "' href='" + this.application[i].href + "'> <img src='" + this.application[i].imageUrl + 
			   "' /></a></td><td class='imageTd'> <a class='" + this.application[i+1].vehicle + "' href='" + this.application[i+1].href + "'> <img src='" + this.application[i+1].imageUrl +  
			   "' /></a></td></tr>";
			else   
			   table += " <tr><td class='imageTd'> <a class='" + this.application[i].vehicle + "' href='" + this.application[i].href + "'> <img src='" + this.application[i].imageUrl + 
			   "' /></a></td><td class='imageTd'> &nbsp;</td></tr>";
		   
	}
	//table += "</table>"
	return table;	
}

function writeShopModel(){
//	var table = "<table   cellspacing='0' cellpadding='0'>" 
	var table=""
	this.selectByModel();	
	for (var i=0; i< this.vsModel.length; i = i + 2){
		  if (typeof(this.vsModel[i+1]) != "undefined"){		   	   
					   table += " <tr><td class='imageTd'> <a class='" + this.vsModel[i].vehicle +  "' href='" + this.vsModel[i].href + "'> <img src='" + this.vsModel[i].imageUrl + 
					   "' /></a></td><td class='imageTd'> <a class=' " + this.vsModel[i+1].vehicle +  "' href='" + this.vsModel[i+1].href + "'> <img src='" + this.vsModel[i+1].imageUrl +  
					   "' /></a></td></tr>";
		  }else   
			   table += " <tr><td class='linkTd'> <a class='simpleLink' href='" + this.vsModel[i].href + "'>" + this.vsModel[i].name+"</a></td></tr>";
}
 // table += "</table>"
	return table;	
}

function writeShopStyle(){
	//var table = "<table cellspacing='0' cellpadding='0'>" 
	var table=""
	this.selectByBody();
	for (var i=0; i< this.style.length; i = i + 2){
		  if (typeof(this.style[i+1]) != "undefined")
			   table += " <tr><td class='imageTd'> <a class='" + this.style[i].vehicle + "' href='" + this.style[i].href + "'> <img src='" + this.style[i].imageUrl + 
			   "' /></a></td><td class='imageTd'> <a class='" + this.style[i+1].vehicle + "' href='" + this.style[i+1].href + "'> <img src='" + this.style[i+1].imageUrl +  
			   "' /></a></td></tr>";
			else   
			   table += " <tr><td class='imageTd'> <a class='" + this.style[i].vehicle + "' href='" + this.style[i].href + "'> <img src='" + this.style[i].imageUrl + 
			   "' /></a></td><td class='imageTd'> &nbsp;</td></tr>";
	}
 // table += "</table>"
	return table;	
}

function selectByModel(){
	if (window.location.href.indexOf("Buick") > -1){
		shopModel[0].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Cadillac") > -1){
		shopModel[1].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Chevrolet") > -1){
		shopModel[2].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("GMC") > -1){
		shopModel[3].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Pontiac") > -1){
		shopModel[4].vehicle = "selectedItem";
	}
}

function selectByBody(){
	if (window.location.href.indexOf("Coupes") > -1){
		shopStyle[0].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Sedan") > -1){
		shopStyle[1].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Convertible") > -1){
		shopStyle[2].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Utility") > -1){
		shopStyle[3].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Trucks") > -1){
		shopStyle[4].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Vans") > -1){
		shopStyle[5].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Crossover") > -1){
		shopStyle[6].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Medium_Duty") > -1){
		shopStyle[7].vehicle = "selectedItem";
	}
}

function selectByVehicle(){
	if (window.location.href.indexOf("police") > -1){
		shopApplication[0].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Ambulance") > -1){
		shopApplication[1].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Catering") > -1){
		shopApplication[2].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Dump") > -1){
		shopApplication[3].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Platform") > -1){
		shopApplication[4].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Shuttle") > -1){
		shopApplication[5].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Plow") > -1){
		shopApplication[6].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Utility") > -1){
		shopApplication[7].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Van") > -1){
		shopApplication[8].vehicle = "selectedItem";
	}
	if (window.location.href.indexOf("Wrecker") > -1){
		shopApplication[9].vehicle = "selectedItem";
	}
}
/***/
var shopModel = new Array ();
shopModel[shopModel.length] = new ShopByModel("Buick", "/pages/shopBy/Buick_byBodyStyle.jsp", "", "/images/vehicleshowroom/thumb_buick.jpg");
shopModel[shopModel.length] = new ShopByModel("Cadillac", "/pages/shopBy/Cadillac_byBodyStyle.jsp", "", "/images/vehicleshowroom/thumb_cadillac.jpg");
shopModel[shopModel.length] = new ShopByModel("Chevrolet", "/pages/shopBy/Chevrolet_byBodyStyle.jsp", "", "/images/vehicleshowroom/thumb_chevy.jpg");
shopModel[shopModel.length] = new ShopByModel("GMC", "/pages/shopBy/GMC_byBodyStyle.jsp", "", "/images/vehicleshowroom/thumb_GMC.jpg");
shopModel[shopModel.length] = new ShopByModel("Pontiac", "/pages/shopBy/Pontiac_byBodyStyle.jsp", "", "");
/***/
var shopStyle = new Array ();
shopStyle[shopStyle.length] = new ShopByStyle("2-Door Coupe", "/pages/shopBy/2_Door_Coupes_byBrand.jsp", "", "/images/vehicleshowroom/thumb_coupe.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("4-Door Sedan", "/pages/shopBy/4_Door_Sedans_byBrand.jsp", "", "/images/vehicleshowroom/thumb_sedan.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Sport Convertible", "/pages/shopBy/Sport_Convertibles_byBrand.jsp", "", "/images/vehicleshowroom/thumb_convertible.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Sport Utility", "/pages/shopBy/Sport_Utility_Vehicles_byBrand.jsp", "", "/images/vehicleshowroom/thumb_utility.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Pick-up Truck", "/pages/shopBy/Pick_Up_Trucks_byBrand.jsp", "", "/images/vehicleshowroom/thumb_pick-up.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Sport/Cargo Van", "/pages/shopBy/Sport_Cargo_Vans_byBrand.jsp", "", "/images/vehicleshowroom/thumb_cargo.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Crossover", "/pages/shopBy/Crossovers_byBrand.jsp", "", "/images/vehicleshowroom/thumb_crossover.jpg");
shopStyle[shopStyle.length] = new ShopByStyle("Medium Duty", "/pages/shopBy/Medium_Dutys_byBrand.jsp", "", "/images/vehicleshowroom/thumb_medium.jpg");
/***/
var shopApplication = new Array ();
shopApplication[shopApplication.length] = new ShopByApplication("Police", "/government/products/police.jsp", "", "/images/vehicleshowroom/thumb_police.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Ambulance", "/pages/shopBy/Ambulance.jsp", "", "/images/vehicleshowroom/thumb_ambulance.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Cathering Body", "/pages/shopBy/Catering_Body.jsp", "", "/images/vehicleshowroom/thumb_catering.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Dump Body", "/pages/shopBy/Dump_Body.jsp", "", "/images/vehicleshowroom/thumb_dump.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Platform/Stake Body", "/pages/shopBy/Platform.jsp", "", "/images/vehicleshowroom/thumb_platform.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Shuttle", "/pages/shopBy/Shuttle.jsp", "", "/images/vehicleshowroom/thumb_shuttle.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Snow Plow/Spreader", "/pages/shopBy/Plow.jsp", "", "/images/vehicleshowroom/thumb_snow.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Utility/Service Body", "/pages/shopBy/Utility.jsp", "", "/images/vehicleshowroom/thumb_service.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Van Body", "/pages/shopBy/Van_Body.jsp", "", "/images/vehicleshowroom/thumb_van.jpg");
shopApplication[shopApplication.length] = new ShopByApplication("Wrecker", "/pages/shopBy/Wrecker.jsp", "", "/images/vehicleshowroom/thumb_wrecker.jpg");


function createTable()
{
	var table = "<div id='showroomContent'> <table  width='220' cellspacing='0' cellpadding='0' >" +
			 " <tr > " +
			 "   <td id='vehicleshowroom' colspan='2'></td> " +
			 " </tr> " +
			 " </table>" +
			 " <h3 id='vsModelTbl' class='titles vsModelTbl' onclick=\"changeDisplay(this) \"><span class=\"gHidden\">Shop by Model</span></h3>" +
			 " <div id='vsModelDiv' class='gVSNavContent'>" +			 
			 " <table id='vsModel'   cellspacing='0' cellpadding='0' >" +			 
					this.writeShopModel() +
			 " </table>	" + 
			 " </div>	" + 
			 " <h3 id='styleTbl' class='titles styleTbl' onclick=\"changeDisplay(this) \"><span class=\"gHidden\">Shop by Body Style</span></h3> " +			 
			 " <div id='styleDiv' class='gVSNavContent'>" +			 
			 " <table id='style'    cellspacing='0' cellpadding='0' >" +			 
					this.writeShopStyle() +
			 " </table>	" + 
			 " </div>	" + 
			 " <h3 id='appTbl' class='titles appTbl' onclick=\"changeDisplay(this) \"><span class=\"gHidden\">Shop by Application</span></h3>" +
			 " <div id='appDiv' class='gVSNavContent'>" +			 
			 " <table id='app'  cellspacing='0' cellpadding='0' >" +			 
					this.writeShopApplication() +
			 " </table>	" + 
			 " </div>	" + 
			 " </table>	</div>";
	///document.write(table);	
	
	return table;
}
/*
*
*/
var lastId = "modelTbl";
var lastContainer = "vsModel";

function showHideModel(opc){
	var modelObj, styleObj, appObj ;
	var modelClose, styleClose, appClose;
	modelObj  = document.getElementById("vsModel"); 
	styleObj  = document.getElementById("style"); 
	appObj  = document.getElementById("app"); 
	
	
	switch(opc){
			case 1: 
				modelObj.className = ((modelObj.className == "show")?"hide":"show");
				styleObj.className = "hide";
				appObj.className = "hide";
				break;
			case 2: 
				styleObj.className = ((styleObj.className == "show")?"hide":"show"); 
				modelObj.className = "hide";
				appObj.className = "hide";
				break;
			case 3: 
				appObj.className = ((appObj.className == "show")?"hide":"show");
				styleObj.className = "hide";
				modelObj.className = "hide";
				break;
	}
}

var sDefault = 0;
function setShowroomDefault(opt){
    if (opt != ""){
		document.getElementById(opt+"Tbl").className = "titles " + opt +"TblOn on"; 
		document.getElementById(opt).className="show";
		//if (sDefault == 1) scrollDiv(opt, "down"); else sDefault = 1;
		lastId = opt+"Tbl";
		lastContainer = opt;
	}
}


function over(id, vContainer){
	if(document.getElementById(vContainer).className!="show"){
		document.getElementById(id).className = "titles " + id +"Over"; 
	}
}

function out(id, vContainer){
	if(document.getElementById(vContainer).className!="show"){
		document.getElementById(id).className = "titles " + id;
	}
}

function on(id, vContainer){
	if (document.getElementById(vContainer)){
		if(document.getElementById(vContainer).className=="show"){
			out(lastId, lastContainer);
			if (document.getElementById(id))
				document.getElementById(id).className = "titles " + id +"On"; 
			//scrollDiv(vContainer, "down");
		} else {
			out(id, vContainer);
			//document.getElementById(vContainer +"Div").style.height = "0px";
		}
	}	
	lastId=id;
	lastContainer=vContainer;
	returnMaxHeight();
}

var  cont=0;

function scrollDiv(id, direction){
	var height=0;
	if(id == "vsModel") height=311;
	if(id == "style") height=311;
	if(id == "app") height=398;
	
	if (cont == 0)	document.getElementById(lastContainer +"Div").style.height = "0px";
	if (direction == "down"){
			if (cont <= (height - 10) ){
			   cont = cont + 10;
				document.getElementById(id+"Div").style.height = cont + "px";
				setTimeout("scrollDiv('"+id+"','down')",60);
			}else{
				cont=0;
			}
	}		
}



function loadWidget(swfFile){
	var section = "Nohome";
	var so = new SWFObject("/flash/showroomWidget/" + swfFile + ".swf", "showroomSwf", "220", "130", "8", "#FFFFFF");
	so.addParam("menu","false");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	
	so.addVariable("xml","/flash/showroomWidget/xml/vehicleShowroom.xml");
	so.addVariable("section",section);
	
	
	so.write("gShowroom");	
}

function loadFlashTracking(container){		
	
	var so = new SWFObject("/flash/TrackingManager.swf", "trackingSwf", "1", "1", "8", "#FFFFFF");

	so.addParam("menu","false");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addVariable("txt0","/xml/widgetTrackingConfig.xml");
		
	so.write(container);
}

function expandMenu(){
	if(document.body.className.indexOf("FireFox") || document.body.className.indexOf("Safari")){
		document.getElementById("showroomSwf").style.zIndex = "900";
		document.getElementById("gContent").style.zIndex = "0";
	}
}

function collapseMenu(){
	if(document.body.className.indexOf("FireFox") || document.body.className.indexOf("Safari")){
		document.getElementById("gContent").style.zIndex = "500";
		document.getElementById("showroomSwf").style.zIndex = "0";
	}
}

