﻿// JScript File
var Result;
var Timeout=0;

function ResizeBanner(h) {
    ((document.getElementById) ? document.getElementById("FlashBanner") : eval("document.all['FlashBanner']")).style.height=h + "px";
}
 function ResizeMoviex(h) {
 alert('resising to: ' + h);
	((document.getElementById) ? document.getElementById("FlashContainer") : eval("document.all['FlashContainer']")).style.height=h + "px";
}
function InsertPanel(MapOrContact, WhichVeh) {
    ((document.getElementById) ? document.getElementById("ContactInfo1") : eval("document.all['" + ContactInfo2 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("ContactPanel") : eval("document.all['" + ContactPanel + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("ContactInfo2") : eval("document.all['" + ContactInfo2 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("ContactInfo3") : eval("document.all['" + ContactInfo3 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("DealerContact1") : eval("document.all['" + DealerContact1 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("DealerContact2") : eval("document.all['" + DealerContact2 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("DealerContact3") : eval("document.all['" + DealerContact3 + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("AppID") : eval("document.all['" + AppID + "']")).value = WhichVeh
    HideMapPanel();
    
    if (MapOrContact == 1) {
        if (WhichVeh > 0) {
			((document.getElementById) ? document.getElementById("ContactInfo" + WhichVeh) : eval("document.all['" + ContactInfo + WhichVeh +  "']")).style.display = 'block';
			((document.getElementById) ? document.getElementById("DealerContact" + WhichVeh) : eval("document.all['" + DealerContact + WhichVeh + "']")).style.display = 'block';
			((document.getElementById) ? document.getElementById("ContactPanel") : eval("document.all['" + ContactPanel + "']")).style.display = 'block';
            var hgt;
			if (navigator.appName=="Microsoft Internet Explorer") {
			    hgt=328;
		    } else {
		        hgt=329;
		    }
		    
		    Enlarge('ContactPanel', '0',hgt,'20',MapOrContact);            
        } else {
			((document.getElementById) ? document.getElementById("ContactInfo1") : eval("document.all['" + ContactInfo1 + "']")).style.display = 'block';
            ((document.getElementById) ? document.getElementById("ContactPanel") : eval("document.all['" + ContactPanel + "']")).style.display = 'none';
        }
    } 
    if (MapOrContact == 2) {
        InsertMapPanel();
    }
}
function HideMapPanel() {
    //((document.getElementById) ? document.getElementById("map") : eval("document.all['" + map + "']")).style.display = 'none';
    //((document.getElementById) ? document.getElementById("MapBottom") : eval("document.all['" + MapBottom + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("MapPanel") : eval("document.all['" + MapPanel + "']")).style.display = 'none';
    ((document.getElementById) ? document.getElementById("MapPanel") : eval("document.all['" + MapPanel + "']")).style.height = '0px';
    
    //((document.getElementById) ? document.getElementById("Panel2") : eval("document.all['" + Panel2 + "']")).style.height = '0px';
    
}
function SetMap(Lat, Lng, DlrName, Addr1, City, State, Zip, Cid, CURL, CLot, MapZoom, MapView)  {
    ((document.getElementById) ? document.getElementById("URL1") : eval("document.all['URL1']")).value = "Lat1=" + Lat + "&Long1=" + Lng + "&ClientID1=" + Cid + "&ClientName1=" + DlrName + "&ClientAddress1=" + Addr1 + "&ClientCity1=" + City + ', ' + State + ' ' + Zip + "&ClientURL1=" + CURL + "&ClientLot1=" + CLot + "&MapZoom=" + MapZoom + "&MapView=" + MapView

    /*((document.getElementById) ? document.getElementById("Lat1") : eval("document.all['Lat1']")).value = Lat;
    ((document.getElementById) ? document.getElementById("Long1") : eval("document.all['Long1']")).value = Lng;
    ((document.getElementById) ? document.getElementById("ClientName1") : eval("document.all['ClientName1']")).value = DlrName;
    ((document.getElementById) ? document.getElementById("ClientAddress1") : eval("document.all['ClientAddress1']")).value = Addr1;
    ((document.getElementById) ? document.getElementById("ClientCity1") : eval("document.all['ClientCity1']")).value = City + ', ' + State + ' ' + Zip;
    ((document.getElementById) ? document.getElementById("ClientID1") : eval("document.all['ClientID1']")).value = Cid;
    ((document.getElementById) ? document.getElementById("ClientURL1") : eval("document.all['ClientURL1']")).value = CURL;
    ((document.getElementById) ? document.getElementById("ClientLot1") : eval("document.all['ClientLot1']")).value = CLot;
    ((document.getElementById) ? document.getElementById("MapZoom") : eval("document.all['MapZoom']")).value = MZoom;
    ((document.getElementById) ? document.getElementById("MapView") : eval("document.all['MapView']")).value = MView;
    */
}

function InsertMapPanel() {
    ((document.getElementById) ? document.getElementById("Mapness") : eval("document.all['" + Mapness + "']")).src = ((document.getElementById) ? document.getElementById("URL2") : eval("document.all['" + URL2 + "']")).value + ((document.getElementById) ? document.getElementById("URL1") : eval("document.all['" + URL1 + "']")).value
    //alert(((document.getElementById) ? document.getElementById("Mapness") : eval("document.all['" + Mapness + "']")).src);
    var H;
    
    HideMapPanel();
    
    
    ((document.getElementById) ? document.getElementById("MapPanel") : eval("document.all['" + MapPanel + "']")).style.display = 'block';
    
    //((document.getElementById) ? document.getElementById("map") : eval("document.all['" + map + "']")).style.display = 'block';
    H = ((document.getElementById) ? document.getElementById("MapHeight") : eval("document.all['" + MapHeight + "']")).value;

    
    Enlarge('MapPanel', '0',H,'20','2');    
    
    //}
}
function Enlarge(ElementID, CurrentHeight, MaxHeight, Step, wh) {
    y = MaxHeight - CurrentHeight;
    if (y > Step) {
        H = CurrentHeight + Step;
        ((document.getElementById) ? document.getElementById(ElementID) : eval("document.all['" + ElementID + "']")).style.height = H + "px";
        //alert(((document.getElementById) ? document.getElementById(ElementID) : eval("document.all['" + ElementID + "']")).style.height);
        if (Result) window.clearTimeout(Result);
        Result = window.setTimeout( "Enlarge('" + ElementID + "'," + H + "," + MaxHeight + "," + Step + ", '" + wh + "')", 20 );
    } else {
        ((document.getElementById) ? document.getElementById(ElementID) : eval("document.all['" + ElementID + "']")).style.height = MaxHeight + "px";
        if (wh == '1') {
            ((document.getElementById) ? document.getElementById("ContactPanel") : eval("document.all['" + ContactPanel + "']")).style.display = 'block';
        }
        if (wh == '2') {
            //((document.getElementById) ? document.getElementById("map") : eval("document.all['" + map + "']")).style.display = 'block';
            ((document.getElementById) ? document.getElementById("MapPanel") : eval("document.all['" + MapPanel + "']")).style.display = 'block';
            ((document.getElementById) ? document.getElementById("MapBottom") : eval("document.all['" + MapBottom + "']")).style.display = 'block';

    
            //ShowMap()
        }
    }
}
function SetMap_OLD(Lat, Lng, DlrName, Addr1, City, State, Zip, Cid, CURL, CLot, MZoom, MView)  {
    ((document.getElementById) ? document.getElementById("Lat1") : eval("document.all['Lat1']")).value = Lat;
    ((document.getElementById) ? document.getElementById("Long1") : eval("document.all['Long1']")).value = Lng;
    ((document.getElementById) ? document.getElementById("ClientName1") : eval("document.all['ClientName1']")).value = DlrName;
    ((document.getElementById) ? document.getElementById("ClientAddress1") : eval("document.all['ClientAddress1']")).value = Addr1;
    ((document.getElementById) ? document.getElementById("ClientCity1") : eval("document.all['ClientCity1']")).value = City + ', ' + State + ' ' + Zip;
    ((document.getElementById) ? document.getElementById("ClientID1") : eval("document.all['ClientID1']")).value = Cid;
    ((document.getElementById) ? document.getElementById("ClientURL1") : eval("document.all['ClientURL1']")).value = CURL;
    ((document.getElementById) ? document.getElementById("ClientLot1") : eval("document.all['ClientLot1']")).value = CLot;
    ((document.getElementById) ? document.getElementById("MapZoom") : eval("document.all['MapZoom']")).value = MZoom;
    ((document.getElementById) ? document.getElementById("MapView") : eval("document.all['MapView']")).value = MView;
}



function ShowPage(URL, Caption, ScrollBars, ToolBars, Width, Height) 
    {
        MyWindow = null;
	    X=(screen.width)?(screen.width-Width)/3:100;    
	    Y=(screen.height)?(screen.height-Height)/3:100;
	    	   
	    MyWindow=window.open(URL,Caption,"width=" + Width + ",height=" + Height + ",top=" + Y + ",left=" + X + ",toolbar=" + ToolBars + ",scrollbars=" + ScrollBars + ",location=no,status=no,directories=no,menubar=no,resizable=yes");
	    MyWindow.focus();	
	   
    }
    
    
topDone = 0;
bottomDone = 0;
function SetDone(x) 
{
    
	if (x == 1) {topDone = 1}
	if (x == 2) {bottomDone = 1}
	if ((topDone == 1) && (bottomDone == 1)) { 
	    //alert('done');
	    //document.getElementById("Preloader").style.display="none"; 
	}
}
function ResizeIFrame()
{
    //alert("ResizeIFrame");
    var height=(document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);			
	if (height == undefined)
	{
	    height=window.innerHeight;//Firefox
	}

	var IFrame = document.getElementById("Preloader")
	height = parseInt(height-IFrame.offsetTop-8);
	IFrame.style.height=height+"px";
	//IFrame.style.display="block"
	IFrame = window.frames[0]
	//alert(height);
	if (IFrame) {
        if (typeof(IFrame["SetMovie"]) != 'undefined') {                    
            IFrame["SetMovie"](height);
            return false;
	    }
	}
}

function setQuery(x) {
	var myDiv1 = document.getElementById("printingdiv");
	myDiv1.innerText=x;
}
function getQuery() {
	var theQuery = document.getElementById('printingdiv').innerText;
	NewWindow=window.open('ASAPrint.aspx?' + theQuery, 'newWin', 'width=625, height=600, left=25, top=25, toolbar=No, location=No, scrollbars=Yes, status=No, resizable=Yes, fullscreen=No' );   NewWindow.focus();  void(0);
}

/**
 * Copyright (C) 2002-2003, CodeHouse.com. All rights reserved.
 * CodeHouse(TM) is a registered trademark.
 *
 * THIS SOURCE CODE MAY BE USED FREELY PROVIDED THAT
 * IT IS NOT MODIFIED OR DISTRIBUTED, AND IT IS USED
 * ON A PUBLICLY ACCESSIBLE INTERNET WEB SITE.
 *
 * Script Name: Cool Redirect
 *
 * You can obtain this script at http://www.codehouse.com
 */

function coolRedirect(url, msg)
{
   var TARG_ID = "COOL_REDIRECT";
   var DEF_MSG = "Redirecting...";

   if( ! msg )
   {
      msg = DEF_MSG;
   }

   if( ! url )
   {
      throw new Error('You didn\'t include the "url" parameter');
   }


   var e = document.getElementById(TARG_ID);

   if( ! e )
   {
      throw new Error('"COOL_REDIRECT" element id not found');
   }

   var cTicks = parseInt(e.innerHTML);

   var timer = setInterval(function()
   {
      if( cTicks )
      {
         e.innerHTML = --cTicks;
      }
      else
      {
         clearInterval(timer);
         document.body.innerHTML = msg;
         location = url;	  
      }

   }, 1000);
}
function ChangeButton(btn, inval) {
    var btnid; //_ctl0_maincontent_{btnid}  _ctl0_ContentPlaceHolder1
    /*
    if (btn.id.substring(0,6) == "_ctl0_") {
        btnid  = btn.id.substring(6);
        if (btn.id.substring(0,26) == "_ctl0_ContentPlaceHolder1_") {
            btnid = btn.id.substring(26);
        } 
        if (btn.id.substring(0,27) == "_ctl00_ContentPlaceHolder1_") {
            btnid = btn.id.substring(26);
        } 
    } else {         
        btnid = btn.id;   
    }
 */
    if (inval == 0) {
        btn.src = btn.src.replace('_N.','_O.');
        //btn.src = "/img/" + btnid + "_O.png"; 
	} else {
	 	//if (inval==1)  btn.src = "/img/" + btnid + "_N.png"; else btn.src = "/img/" + btnid + "_D.png";
	 	if (inval==1) {
	 	    btn.src = btn.src.replace('_O.','_N.');    
	 	} else {
	 	    if (btn.id.substring(0,6) == "_ctl0_") {
                btnid  = btn.id.substring(6);
                if (btn.id.substring(0,26) == "_ctl0_ContentPlaceHolder1_") {
                    btnid = btn.id.substring(26);
                } 
                if (btn.id.substring(0,27) == "_ctl00_ContentPlaceHolder1_") {
                    btnid = btn.id.substring(26);
                } 
            } else {         
                btnid = btn.id;   
            }
            btn.src = "/img/" + btnid + "_D.png";
	 	}
	}	
}
function formatCommas(strValue) {
    //strValue = strValue.toString().replace(/\$|\,/g,'');
    dblValue = parseFloat(strValue);

    blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
    dblValue = Math.floor(dblValue*100+0.50000000001);
     
    dblValue = Math.floor(dblValue/100).toString();
     
    for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
        dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
        dblValue.substring(dblValue.length-(4*i+3));
    return (((blnSign)?'':'-') + dblValue); //+ '.' + strCents);
}
function formatCurrency(strValue) {
    strValue = strValue.toString().replace(/\$|\,/g,'');
    dblValue = parseFloat(strValue);

    blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
    dblValue = Math.floor(dblValue*100+0.50000000001);

    dblValue = Math.floor(dblValue/100).toString();

    for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
        dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
        dblValue.substring(dblValue.length-(4*i+3));
    return (((blnSign)?'':'-') + '$' + dblValue); //+ '.' + strCents);
}