// JScript File

function swapImage(img_name, img_src) 
{
    document.images[img_name].src = img_src;
}

function writeHeaderText(headerText) 
{
	
	var so = new SWFObject("/dealer/en/objects/swf/smartHeadline1line18px.swf", "header2", "380", "30", "8", "#FFFFFF"); 
	so.addParam("wmode","transparent"); 
	so.addVariable("titleText", headerText); 
	so.write("header2");

	
}

function writeHeaderTextorg(headerTextorg) 
{
	var so = new SWFObject("/dealer/en/objects/swf/smartHeadline1line18pxorg.swf", "header3", "340", "30", "6", "#FFFFFF"); 
	so.addParam("wmode","transparent"); 
	so.addVariable("titleText", headerTextorg); 
	so.write("header3");

	
}

function writeSubHeaderText(id, subheaderText) 
{
	
	var so = new SWFObject("/dealer/en/objects/swf/smartHeadline1line18px.swf", id, "282", "24", "8", "#FFFFFF"); 
	so.addParam("wmode","transparent"); 
	so.addVariable("titleText", subheaderText); 
	so.write(id);

	
}

function FindBottom() {
	vLeftColBtm = (document.getElementById('LftColBtm').offsetTop);
	vRightColBtm = (document.getElementById('RgtColBtm').offsetTop);
	vMiddleColBtm = (document.getElementById('MidColBtm').offsetTop);

	vContentWellHeight = Number(vLeftColBtm);

	if (Number(vRightColBtm) > Number(vContentWellHeight)) {
		vContentWellHeight = vRightColBtm;
		}

	if (Number(vMiddleColBtm) > Number(vContentWellHeight)) {
		vContentWellHeight = vMiddleColBtm;
		}
	document.getElementById('MiddleCol').style.height = vContentWellHeight-50+'px';
}

function PlayVideo(file,title,type) 
{
    window.open('videoplayer-wm.htm','title','width=450,height=400');
}

function getURLVar(urlVarName) 
{
    var urlHalves = String(document.location).split('?');
	var urlVarValue = '';
	if(urlHalves[1])
	{
	    var urlVars = urlHalves[1].split('&');
		for(i=0; i<=(urlVars.length); i++)
		{
		    if(urlVars[i])
		    {
			    var urlVarPair = urlVars[i].split('=');
				if (urlVarPair[0] && urlVarPair[0] == urlVarName) 
				{
				    urlVarValue = urlVarPair[1];
				}
			}
		}
	}
	return urlVarValue;
}
function js_waterMark_Focus(objname, waterMarkText)
  {
      obj = document.getElementById(objname);
      if(obj.value == waterMarkText)
      {
          obj.value="";
      }
  }
  function js_waterMark_Blur(objname, waterMarkText)
  {
      obj = document.getElementById(objname);
      if(obj.value == "")
      {
  	    obj.value=waterMarkText;
      }
  }
  
  function PodPopUp(popurl, wth, hgt) 
  {
    var windowopenstring="window.open('" + popurl + "', 'podpopwin', 'height=" + hgt + ",width=" + wth +"')";
    newWindow=eval(windowopenstring);    
 
    return;
   }

function popWin2(control, allowresize) 
  {
    var index=control.selectedIndex;
    var valu = control.options[index].value;
    if (valu=="") return;
    var base = "/dealer/en/contact.aspx"
    var popurl = base+"?id="+valu;
    var popname = "contactpopwin";
    var wth = 250;
    var hgt = 150;
    var resize = allowresize;
    var scroll = allowresize;
    var windowopenstring="window.open('" + popurl + "', '" + popname + "', 'height=" + hgt + ",width=" + wth
    if(resize) windowopenstring+=",resizable"
    if(scroll) windowopenstring+=",scrollbars"
    windowopenstring  += "')"
   
    newWindow=eval(windowopenstring);    
 
    return;
   }

function popWinPDF(popurl)
  {
    //var base = "/dealer/en/contact.aspx"
    //var popurl = base+"?id="+contentID;
    var popname = "contactpopwinPDF";
    var wth = 500;
    var hgt = 500;
    var resize = true;
    var scroll = true;
    var windowopenstring="window.open('" + popurl + "', '" + popname + "', 'height=" + hgt + ",width=" + wth
    if(resize) windowopenstring+=",resizable"
    if(scroll) windowopenstring+=",scrollbars"
    windowopenstring  += "')"
   
    newWindow=eval(windowopenstring);    
 
    return;
   }
   
function getheight()
{
	var getheight = document.getElementById('leftnav').offsetHeight;
	var getmidsecheight = document.getElementById('divheight').offsetHeight;

	//alert (getheight+ ' leftnav ' + getmidsecheight + ' middle section');
	
	if (getmidsecheight < getheight) {
		var changeheight = document.getElementById('divheight').style.height = (getheight-40) +'px' ;
		//alert(changeheight)
	}

	/*var is_ie6 = ('ActiveXObject' in window && !('XMLHttpRequest' in window));
	if (is_ie6){
	var linklocation = window.location.href;
	var dent = linklocation.indexOf("dent_");
	var fi_faq = linklocation.indexOf("fi_faq_");
	var gap = linklocation.indexOf("gap_");
	var scontracts = linklocation.indexOf("servicecontracts_");
	var askforit = linklocation.indexOf("askforit");

		if (dent != -1 || fi_faq != -1 || gap != -1 || scontracts != -1 || askforit != -1 || linklocation.indexOf("main.aspx") != -1)
		{
			document.getElementById('rightColumn').style.marginLeft ="0";
	
		} 
		else
		{
			document.getElementById('rightColumn').style.marginLeft ="-1";
		}	
	}*/
}



function openFullscreen(page) {
	var yes = 1;
	var no = 0;

	var menubar = yes;      // The File, Edit, View Menus
	var scrollbars = yes;   // Horizontal and vertical scrollbars
	var locationbar = yes;  // The location box with the site URL
	var directories = yes;  // the "What's New", "What Cool" links
	var resizable = yes;    // Can the window be resized?
	var statusbar = yes;    // Status bar (with "Document: Done")
	var toolbar = yes;      // Back, Forward, Home, Stop toolbar

//	windowprops = "width=" + (screen.width-10) + ",height=" + (screen.height-50) + ",top=0,left=0";
	windowprops = "width=800,height=800,top=0,left=0";

	windowprops += (menubar ? ",menubars" : "") +
	(scrollbars ? ",scrollbars" : "") +
	(locationbar ? ",location" : "") +
	(directories ? ",directories" : "") +
	(resizable ? ",resizable" : "") +
	(statusbar ? ",status" : "") +
	(toolbar ? ",toolbar" : "");

	window.open(page, null, windowprops);
}


function go1() {
  if (document.aspnetForm.land.options[document.aspnetForm.land.selectedIndex].value != "") {
    this.location.href = document.aspnetForm.land.options[document.aspnetForm.land.selectedIndex].value;
  }
}

function getMovie(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
    	return document[movieName];
    } else {
    	return document[movieName];
    }
} 
  
function changeVideo(flvPath, flvTitle, flvDesc, flvduration) {
	getMovie("videoplayer").changeVideo(flvPath, flvTitle, flvDesc, flvduration);
	} 

function TestimonialBodyLoad() {
    getheight(); 
    changeVideo("/dealer/en/objects/swf/video-BD-MacHaik.flv","Partner for good times and bad","Mac Haik Auto Group","36");
}
function BodyLoad() {
    getheight();
}

this.imagelink = function(){
	
	var arr = [			   			  				
				["image1", "", "imageOver"],
				["image2", "imageOut2", "imageOver2"],
				["image3", "", "imageOver3"],
				["image4", "", "imageOver4"],
				["image5", "", "imageOver5"]
			  ];
			
	// END CONFIG
	
	for (var x=0;x<arr.length;x++){
		
		var a = document.getElementsByTagName("a");
		for (var i=0;i<a.length;i++){
			var img = a[i].getElementsByTagName("img");		
			for (var j=0;j<img.length;j++){			
				if(img[j].className == arr[x][0] || arr[x][0] == ""){
					a[i].style.position = "static";						 
					if(a[i].getElementsByTagName("span").length > 0) a[i].removeChild(a[i].getElementsByTagName("span")[0]);
					var span = document.createElement("span");	
					var image = img[j];
					span.style.position = "absolute";
					span.style.top = 0; 
					//document.getElementById('vidhighlight').offsetTop + "px";
					//alert('span.style.top' + span.style.top)
					span.style.left = document.getElementById('vidhighlight').offsetLeft + "px";
					span.style.width = document.getElementById('vidhighlight').offsetWidth + "px";
					span.style.height = document.getElementById('vidhighlight').offsetHeight + "px";
					span.style.cursor = "pointer";
					span.out = span.className = arr[x][1];
					span.over = arr[x][2];
					span.a = img[j].a = a[i];	
					span.j = img[j].j = j;					
					a[i]["span" + j] = span;					
					span.onmouseover = img[j].onmouseover = function(){ 
						this.a["span" + this.j].className = this.a["span" + this.j].over;
					};
					span.onmouseout = img[j].onmouseout = function(){
						this.a["span" + this.j].className = this.a["span" + this.j].out;
					};
					a[i].appendChild(span);							
				};		
			};	
		};
		
	};
};



// script initiates on page load. 

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",imagelink);
addEvent(window,"resize",imagelink);

