
var lastMouseX;
var lastMouseY;
var curPopupWindow = null;
	
function manualSubmit(action) {
	var f = document.forms[0];
	f.action = action
	f.submit();
}

// 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 mouseCursor(cursor) {
  var el = event.srcElement;
	switch (cursor) {
		case "hand":
			el.style.cursor = "hand";
			break
		default:
			el.style.cursor = "default";
	}
}

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 ----------------------------------------------------------------------------

//these are for expedia maps link
	function getdirections() {
		document.forms[0].submit();
	}
		
	function OpenWindow(url){
		window.open('' + url + '', 'ex', 'width=800, height=550, toolbar=1, scrollbars=yes, resizable=yes, top=0, left=0');
	}
	function newWindowForm()
	{
		var popUp = window.open
		('','popUp','scrollbars=yes,toolbar=yes, resizable=yes,height=600,width=675');
		document.DirectionsForm.target = 'popUp';
	}
//end expedia maps functions

// 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 image rotator
	var currIndex = 0;
	var images = new Array();
	images[images.length] = { src: "images/home_yearend.jpg", url: "inventorydisplay.aspx?brw=allnew&s=new" };
	images[images.length] = { src: "images/home_changes.jpg", url: "forms.aspx?frm=contact" };
	images[images.length] = { src: "images/home_stop.jpg", url: "inventorydisplay.aspx?brw=used&s=used" };
	images[images.length] = {src:"images/home_motortrend.jpg", url:"default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford"};
	
	//images[images.length] = {src:"images/home_apr.jpg", url:"http://www.theriversideford.com/inventorydisplay.aspx?brw=used&s=used"};

	images[images.length] = { src: "images/home_hybrid.jpg", url: "default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford" };

	images[images.length] = { src: "images/home_2010taurus.jpg", url: "inventorydisplay.aspx?brw=allnew&s=new" };

//images[images.length] = {src:"images/home_zero01.jpg", url:"default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford"};

	
//images[images.length] = {src:"images/home_zero02.jpg", url:"default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford"};
	
	images[images.length] = {src:"images/home_why.jpg", url:"default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford"};
	//images[images.length] = {src:"images/home_apr.jpg", url:"http://www.theriversideford.com/inventorydisplay.aspx?brw=used&s=used"};
	
		images[images.length] = {src:"images/home_riverside.jpg", url:"default.aspx?app=newcars&xslt=new-ford.xslt&s=new-ford"};
		
		//images[images.length] = {src:"images/home_apr.jpg", url:"http://www.theriversideford.com/inventorydisplay.aspx?brw=used&s=used"};
		
   
	//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 = 3 seconds
	function startInterval(){
		var interval = window.setInterval("setImages()", 5000);
	}
	//end home page image rotator


