
var lastMouseX;
var lastMouseY;
var curPopupWindow = 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);
}

// -- CUSTOM FUNCTIONS ---------------------------------------------------------------------------</>-

// Div pop up Funtion

function showlink(layername) {

	if (!document.getElementById)
return
	if (layername.style.visibility=="hidden")
		layername.style.visibility="visible"
	else
		layername.style.visibility="visible"
} 

// Absolute Div Close Funtion

function hidelink(layername) {

	if (!document.getElementById)
return
	if (layername.style.visibility=="visible")
		layername.style.visibility="hidden"
	else
		layername.style.visibility="hidden"
}

//home page div ad image rotator
var currIndexAd = 0;
var imagesAd = new Array();

//edit links for each image here

imagesAd[imagesAd.length] = { src: "images/ad_rotator_hyundai.jpg", url: "inventorydisplay.aspx?brw=certifiedhyundai&s=certified" };
imagesAd[imagesAd.length] = { src: "images/ad_rotator_gm.jpg", url: "inventorydisplay.aspx?brw=certifiedgm&s=certified" };
imagesAd[imagesAd.length] = { src: "images/ad_rotator_trucks.jpg", url: "inventorydisplay.aspx?brw=usedtrucks&s=used" };

//use this setImages function for random display
function setAdImages() {
    var currIndexAd = Math.floor(Math.random() * (imagesAd.length));
    document.getElementById("ImageSwitchAd").src = imagesAd[currIndexAd].src;
    //comment the next line out if you don't use links
    document.getElementById("LinkupAd").href = imagesAd[currIndexAd].url;
}

/*use this setImages function for ordered display
function setAdImages() {
if (currIndex == imagesAd.length - 1) 
currIndex = 0;
else
currIndex += 1;
document.getElementById("ImageSwitchAd").src = imagesAd[currIndex].src;
		
comment the next line out if you don't use links
document.getElementById("LinkupAd").href = imagesAd[currIndex].url;
}*/

//set the delay here in milliseconds, 3000 = 3 seconds
function startIntervalAd() {
    setAdImages();
    //uncomment the line below to enable rotator
    //var interval = window.setInterval("setImages()", 3000);
}
//end home page div ad image rotator



//home page image rotator
var currIndex = 0;
var images = new Array();
images[images.length] = { src: "images/c_lacrosse.jpg", url: "inventorydisplay.aspx?brw=new-buick-lacrosse&s=port-angeles-buick-lacrosse" }; 
//images[images.length] = { src: "images/c_dodges.jpg", url: "inventorydisplay.aspx?brw=used&s=used#s=fp&eln=Make&elv=Dodge&sb=&rs=0&pc=10&pcurr=1&ps=10&els=VehicleType%3A~Price%3A~Make%3A~Model%3A" };
//images[images.length] = { src: "images/c_fords.jpg", url: "inventorydisplay.aspx?brw=used&s=used#s=fp&eln=Make&elv=Ford&sb=&rs=0&pc=2&pcurr=1&ps=10&els=VehicleType%3A~Price%3A~Make%3ADodge~Model%3A" };
images[images.length] = { src: "images/c_hyundais.jpg", url: "inventorydisplay.aspx?brw=certified&s=certified" };

//images[images.length] = { src: "images/c_camaro.jpg", url: "forms.aspx?frm=contact&s=contact" };
//images[images.length] = { src: "images/c_cashforclunkers.jpg", url: "forms.aspx?frm=cashforclunkers&makes=Cadillac,Buick,Pontiac,GMC,Hyundai&s=cashforclunkers" };
images[images.length] = { src: "images/c_newgm.jpg", url: "default.aspx?html=new.html&s=new" };
//images[images.length] = { src: "images/c_gaslock.jpg", url: "default.aspx?html=new-hyundai-port-angeles.html&s=new-port-angeles-hyundai" };
//images[images.length] = { src: "images/c_2010srx.jpg", url: "default.aspx?app=googlemaps&s=contact" };
//images[images.length] = { src: "images/c_2010lacrosse.jpg", url: "default.aspx?app=googlemaps&s=contact" };
//images[images.length] = { src: "images/c_2010wagon.jpg", url: "default.aspx?app=googlemaps&s=contact" };
//images[images.length] = { src: "images/c_2010terrain.jpg", url: "default.aspx?app=googlemaps&s=contact" };


//use this setImages function for ordered display
function setImages() {
    if (currIndex == images.length - 1)
        currIndex = 0;
    else
        currIndex += 1;
    document.getElementById("Image").src = images[currIndex].src;
    //comment the next line out if you don't use links
    document.getElementById("Linkup").href = images[currIndex].url;
}
//set the delay here in milliseconds, 3000 = 6 seconds
function startInterval() {
    var interval = window.setInterval("setImages()", 4000);
    //start the div ad image rotator
   //startIntervalAd();

}
//end home page image rotator
