﻿/* AjaxPage */
var bustcachevar=1,loadedobjects="",rootdomain="http://"+window.location.hostname,bustcacheparameter="",tab3_DealerName='';
function ajaxpage(url,containerid,googleid){var myNewString=url;while(myNewString.indexOf('_')>0)
{myNewString=myNewString.replace('_','&');}
url=myNewString;var tab=url.substring(0,url.indexOf('.'));var page_request=false;
if(window.XMLHttpRequest){page_request=new XMLHttpRequest();}
else if(window.ActiveXObject)
{try
{page_request=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{try
{page_request=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e)
{}}}
else {return false}
page_request.onreadystatechange=function(){loadpage(page_request,containerid,tab);}
if(bustcachevar){
bustcacheparameter=(url.indexOf("?")!=-1)?"&"+new Date().getTime():"?"+new Date().getTime();}
page_request.open('GET',url+bustcacheparameter,true);
page_request.send(null);
if(tab=='Tab1')
{val='';tab4_latitude='';}
if(tab=='Tab2')
{val='';ShowGoogleMap();tab4_latitude='';}
if(tab=='Tab3')
{val='';tab4_latitude='';showScrollInTab3();}
if(tab=='Tab4')
{tab4_latitude='';ShowGoogleMap2();}}
function loadpage(page_request,containerid,googleid){if(page_request.readyState==4&&(page_request.status==200||window.location.href.indexOf("http")==-1))
{var outputHtml = page_request.responseText;
switch(googleid){case 'Tab1':case 'Tab2':case 'Tab3':case 'Tab4': case 'DLAllDealers': case 'DLRouteDescription': outputHtml = replaceAll(outputHtml,"<form","<div");outputHtml = replaceAll(outputHtml,"</form>","</div>"); outputHtml = replaceAll(outputHtml,"form1","DealerLocatorDiv1"); outputHtml = replaceAll(outputHtml,"__doPostBack","DealerLocatorDivdoPostBack"); outputHtml = replaceAll(outputHtml,"action","DealerLocatorAction"); outputHtml = replaceAll(outputHtml,"method","DealerLocatorMethod"); break;}
try{document.getElementById(containerid).innerHTML=outputHtml;
try{var divPlayer1=document.getElementById('divPlayer1');if(divPlayer1!=null)
{var imageName1=document.getElementById('imageName1');if(imageName1!=null)
{var strImageName1=imageName1.innerHTML;__EmbedSwf("swf/imgLoader.swf","divPlayer1","192","127",{filePath:strImageName1},"divPlayer1");}}
var divPlayer2=document.getElementById('divPlayer2');if(divPlayer2!=null)
{var imageName2=document.getElementById('imageName2');if(imageName2!=null)
{var strImageName2=imageName2.innerHTML;__EmbedSwf("swf/imgLoader.swf","divPlayer2","192","127",{filePath:strImageName2},"divPlayer2");}}}
catch(e1)
{}}
catch(e){document.getElementById(containerid).innerHTML="<!--"+page_request.responseText;}}}

function DLRedirectPage(url,currentPage){switch(currentPage){
case "AllDealers":GetHiddenField('preloaderAllDealers','div').style.display = '';ajaxpage(url,'main');break;
case "DealerDetails":GetHiddenField('preloaderTab3','div').style.display = '';ajaxpage(url,'main');break;
case "RoureDescription":GetHiddenField('preloaderRouteDescription','div').style.display = '';ajaxpage(url,'main');break;}
if(url.indexOf('DLRouteDescription')> -1 ){showScrollInDLRouteDescription();}UnTip();}

function showGeneralMap(){GetHiddenField('divDetailedMap','div').style.display = 'none';GetHiddenField('divGeneralMap','div').style.display = '';GetHiddenField('imgDetailedLink','img').style.display = '';GetHiddenField('imgGeneralLink','img').style.display = 'none';GetHiddenField('txtGeneral','span').style.display = 'none';GetHiddenField('txtDetailed','span').style.display = '';}
function showDetailedMap(){GetHiddenField('divDetailedMap','div').style.display = '';GetHiddenField('divGeneralMap','div').style.display = 'none';GetHiddenField('imgGeneralLink','img').style.display = '';GetHiddenField('imgDetailedLink','img').style.display = 'none';GetHiddenField('txtDetailed','span').style.display = 'none';GetHiddenField('txtGeneral','span').style.display = '';}
function showScrollInTab3(){var flag=0;if(GetHiddenField('hdnTab3','input')!=null){tab3_DealerName=GetHiddenField('hdnTab3','input').value;}if(tab3_DealerName==''||tab3_DealerName.length<=0){flag=1;}if(flag==1){window.setTimeout("showScrollInTab3()",1000);return;}CSBfleXcroll(GetHiddenField('mycustomscroll1','div'));tab3_DealerName='';}
function showScrollInDLRouteDescription(){var flag=0;if(GetHiddenField('hdnDLRouteDescription','input')!=null){tab3_DealerName=GetHiddenField('hdnDLRouteDescription','input').value;}if(tab3_DealerName==''||tab3_DealerName.length<=0){flag=1;}if(flag==1){window.setTimeout("showScrollInDLRouteDescription()",1000);return;}CSBfleXcroll(GetHiddenField('mycustomscroll1','div'));tab3_DealerName='';}
function replaceAll(text,strA,strB){while(text.indexOf(strA)!=-1){text=text.replace(strA,strB);}return text;}
function GetHiddenField(fieldName,fieldtype){var arr=document.getElementsByTagName(fieldtype);var hidden=null;for(i=0;i<arr.length;i++){if(arr[i].id.indexOf(fieldName)>-1){hidden=arr[i];break;}}return hidden;}



/* FewDealerLocatorPrint */

function hideDetailedMapPrint(){document.getElementById('chkDetailedMap1').style.display='none';document.getElementById('chkDetailedMap2').style.display='none';document.getElementById('chkDetailedMap3').style.display='inline';document.getElementById('chkDetailedMap4').style.display='inline';document.getElementById('divDetailedMap').style.display='none';}
function showDetailedMapPrint(){document.getElementById('chkDetailedMap4').style.display='none';document.getElementById('chkDetailedMap3').style.display='none';document.getElementById('chkDetailedMap2').style.display='inline';document.getElementById('chkDetailedMap1').style.display='inline';document.getElementById('divDetailedMap').style.display='';}
function hideGeneralMapPrint(){document.getElementById('chkGeneralMap1').style.display='none';document.getElementById('chkGeneralMap2').style.display='none';document.getElementById('chkGeneralMap3').style.display='inline';document.getElementById('chkGeneralMap4').style.display='inline';document.getElementById('divGeneralMap').style.display='none';}
function showGeneralMapPrint(){document.getElementById('chkGeneralMap4').style.display='none';document.getElementById('chkGeneralMap3').style.display='none';document.getElementById('chkGeneralMap2').style.display='inline';document.getElementById('chkGeneralMap1').style.display='inline';document.getElementById('divGeneralMap').style.display='';}

function printPage2(){
var height = document.getElementById('DealerDetails').clientHeight;
var top = false, bottom = false;
var pageHeight=850;
var rem,content=90+26+68+height+19;
var top = 516 + 6;
var bottom = 516 + 6;
if(document.getElementById('divGeneralMap')!=null && document.getElementById('divGeneralMap').style.display=='')
{content = content + top; top = true;}
if(document.getElementById('divGeneralMap')!=null && document.getElementById('divDetailedMap').style.display=='')
{content = content + bottom; bottom = true;}
rem = content%pageHeight;    
if((top == true || bottom == true) && rem < 522)
{document.getElementById('tdFooter2').style.pageBreakAfter='always';}
window.print();}

/* function set the bg color of the icons in Bottom section */

function setBackground(obj)
{   
    obj.className="hovclr";
}
function resetBackground(obj)
{
    obj.className="";
}