
var lastMouseX;
var lastMouseY;
var curPopupWindow = null;
var curPopunderWindow = null;

function manualSubmit(action) {
    var f = document.forms[0];
    f.action = action
    f.submit();
}

function mouseCursor(cursor) {
    var el = event.srcElement;
    switch (cursor) {
        case "hand":
            el.style.cursor = "hand";
            break
        default:
            el.style.cursor = "default";
    }
}

// cross browser compatible
function changeCursor(cursor, evt) {
    evt = (evt) ? evt : event;
    var el = (evt.target) ? evt.target : event.srcElement;

    switch (cursor) {
        case "hand":
            el.style.cursor = "pointer"; // for modzilla, don't change order
            el.style.cursor = "hand"; // for ie
            break
        default:
            el.style.cursor = "";
    }
}

function openPopup(url, name, width, height, features, snapToLastMousePosition) {
    closePopup();
    if (snapToLastMousePosition) {
        if (lastMouseX - width < 0) lastMouseX = width;
        if (lastMouseY + height > screen.height) lastMouseY -= (lastMouseY + height + 50) - screen.height;
        lastMouseX -= width;
        lastMouseY += 10;
        features += "screenX=" + lastMouseX + ",left=" + lastMouseX + "screenY=" + lastMouseY + ",top=" + lastMouseY;
    }
    curPopupWindow = window.open(url, name, features, false);
}

function setLastMousePosition(evt) {
    evt = (evt) ? evt : event;
    lastMouseX = evt.screenX;
    lastMouseY = evt.screenY;
}

function closePopup() {
    if (curPopupWindow != null) {
        if (!curPopupWindow.closed) curPopupWindow.close();
        curPopupWindow = null;
    }
}

function popUp_Scroll(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=yes,directories=no,menubar=no,scrollbars=1", false);
}

function popUp(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0", false);
}

function popUp_Snap(url, name, width, height) {
    openPopup(url, name, width, height, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0", true);
}

function popUnder(url, name, width, height) {
    closePopunder();
    curPopunderWindow = window.open(url, name, "width=" + width + ",height=" + height + ",dependent=no,resizable=yes,toolbar=no,status=no,directories=no,menubar=no,scrollbars=0");
    curPopunderWindow.blur();
    window.focus();
}

function closePopunder() {
    if (curPopunderWindow != null) {
        if (!curPopunderWindow.closed) curPopunderWindow.close();
        curPopunderWindow = null;
    }
}

// -- CUSTOM FUNCTIONS ----------------------------------------------------------------------------



function manualSubmit(action) {
	var f = document.forms[0];
	f.action = action
	f.submit();
}
//function financeWindow(){
		//window.open('https://secureserver.motorwebs.com/default.aspx?frm=finance&webname=LarsonAutomotiveGroup_Net2', 'win', 'width=640,height=520,resizable=yes,toolbar=no,status=yes,directories=no,menubar=no,scrollbars=1');
//}
//function financeWindow(){
		//window.open('https://secureforms.motorwebs.com/finance_application_v1/default.aspx?dealerid=1108&id=22', 'win', 'width=640,height=520,resizable=yes,toolbar=no,status=yes,directories=no,menubar=no,scrollbars=1');
//}
//function financeWindow2(){
		//window.open('https://secureforms.motorwebs.com/finance_application_v1/default.aspx?dealerid=1108&id=22', 'win', 'width=640,height=520,resizable=yes,toolbar=no,status=yes,directories=no,menubar=no,scrollbars=1');
//}


function mouseCursor(sCursor) {
	var el = event.srcElement 
	switch (sCursor) {
		case "hand":
			el.style.cursor = "hand";
			break
		default:
			el.style.cursor = "default";
	}
}


function CreateFlashControl(divID, classID, name, flashUrl, bgcolor, width, height, isTransparent) {
  var d = document.getElementById(divID);
  
  if (isTransparent) {
		d.innerHTML = 
			'<object classid=' + classID + ' id=' + name + ' codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0  width=' + width + ' height=' + height + ' align=middle VIEWASTEXT>' +
			'<param name=allowScriptAccess value=sameDomain />' +
			'<param name=movie value=' + flashUrl + ' />' +
			'<param name=quality value="high" />' +
			'<param name=wmode VALUE=transparent /> ' +
			'<param name=bgcolor value=' + bgcolor + ' />' +
			'<embed src=' + flashUrl + ' name=' + name + ' bgcolor=' + bgcolor + ' width=' + width + ' height=' + height + ' align=middle wmode=transparent quality=high allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer />' + 
			'</object>';
	}
	else {
		d.innerHTML = 
			'<object classid=' + classID + ' id=' + name + ' codebase=http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0  width=' + width + ' height=' + height + ' align=middle VIEWASTEXT>' +
			'<param name=allowScriptAccess value=sameDomain />' +
			'<param name=movie value=' + flashUrl + ' />' +
			'<param name=quality value="high" />' +
			'<param name=bgcolor value=' + bgcolor + ' />' +
			'<embed src=' + flashUrl + ' name=' + name + ' bgcolor=' + bgcolor + ' width=' + width + ' height=' + height + ' align=middle  quality=high allowScriptAccess=sameDomain type=application/x-shockwave-flash pluginspage=http://www.macromedia.com/go/getflashplayer />' + 
			'</object>';
	}
}

// Div Overlay Close Funtion

function hidelink(layername) {

	if (!document.getElementById)
return
	if (layername.style.visibility=="visible")
		layername.style.visibility="hidden"
	else
		layername.style.visibility="hidden"
}
//start bodyshop referral functions
function bodyshopreferral() {

    if ((document.forms[0].Zip.value).length == 5) {
        switch (document.forms[0].Zip.value) {

            //bremerton
            case '98310':
            case '98311':
            case '98312': { window.location.href = "default.aspx?html=bodyshop-bremerton.html&s=bodyshop-referral"; break }

            //gig harbor
            case '98359':
            case '98329':
            case '98335':
            case '98332': { window.location.href = "default.aspx?html=bodyshop-gigharbor.html&s=bodyshop-referral"; break }

            //kent auburn
            case '98001':
            case '98002':
            case '98031':
            case '98092':
            case '98032': { window.location.href = "default.aspx?html=bodyshop-kent-auburn.html&s=bodyshop-referral"; break }

            //north puyallup
            case '98404':
            case '98354':
            case '98371':
            case '98372':
            case '98390':
            case '98443':
            case '98444':
            case '98445': { window.location.href = "default.aspx?html=bodyshop-north-puyallup.html&s=bodyshop-referral"; break }

            //olympia
            case '98501':
            case '98503':
            case '98506':
            case '98512':
            case '98513':
            case '98516': { window.location.href = "default.aspx?html=bodyshop-olympia.html&s=bodyshop-referral"; break }

            //tacoma north
            case '98403':
            case '98405':
            case '98406':
            case '98407':
            case '98408':
            case '98409':
            case '98418':
            case '98465':
            case '98466': { window.location.href = "default.aspx?html=bodyshop-tacoma-north.html&s=bodyshop-referral"; break }

            //tacoma south
            case '98467':
            case '98433':
            case '98438':
            case '98327':
            case '98498':
            case '98499': { window.location.href = "default.aspx?html=bodyshop-tacoma-south.html&s=bodyshop-referral"; break }

            //portorchard
            case '98367':
            case '98366': { window.location.href = "default.aspx?html=bodyshop-portorchard.html&s=bodyshop-referral"; break }

            //poulsbo
            case '98346':
            case '98342':
            case '98340':
            case '98339':
            case '98110':
            case '98325':
            case '98365':
            case '98392':
            case '98370': { window.location.href = "default.aspx?html=bodyshop-poulsbo.html&s=bodyshop-referral"; break }

            //sequim portangeles
            case '98362':
            case '98363':
            case '98368':
            case '98376':
            case '98382': { window.location.href = "default.aspx?html=bodyshop-sequim-portangeles.html&s=bodyshop-referral"; break }

           //silverdale
           case '98315':
           case '98383': { window.location.href = "default.aspx?html=bodyshop-silverdale.html&s=bodyshop-referral"; break }
           
           //south 512
           case '98338':
           case '98360':
           case '98328':
           case '98387':
           case '98373':
           case '98374':
           case '98375':
           case '98446': { window.location.href = "default.aspx?html=bodyshop-south-512.html&s=bodyshop-referral"; break }

           //yelm
           case '98558':
           case '98576':
           case '98580':
           case '98589':
           case '98597': { window.location.href = "default.aspx?html=bodyshop-yelm.html&s=bodyshop-referral"; break }

           //fife north same as tacoma north for now
           case '98421':
           case '98422':
           case '98424':
           case '98003':
           case '98023': { window.location.href = "default.aspx?html=bodyshop-tacoma-north.html&s=bodyshop-referral"; break }

           default: document.getElementById("msg").innerHTML = "<br /><b><font color='#999999'>Your zip code is not located near any of our recommended bodyshops.<br /> Please enter another 5 digit zip code below:</font></b><br>";
           
        }
    }


    else
        document.getElementById("msg").innerHTML = "<br /><b><font color='#999999'>You must enter a 5 digit zip code.<br />Please enter a 5 digit zip code below:</font></b><br>";
}

//checkenter function to enable enter key for bodyshop referral form
function checkEnter(e){ //e is event object passed from function invocation
var characterCode //literal character code will be stored in this variable

if(e && e.which){ //if which property of event object is supported (NN4)
e = e
characterCode = e.which //character code is contained in NN4's which property
}
else{
e = event
characterCode = e.keyCode //character code is contained in IE's keyCode property
}

if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
   // document.forms[0].submit() //submit the form

    bodyshopreferral();
return false 
}
else{
return true 
}

}
//end bodyshop referral 