function openFloorPlan(url) {
	var params = "toolbars=no,scrollbars=no,resizable,width=675,height=500";
	var w = window.open(url, "floorPlans", params);
	return;
}

function openContent(url, width, height) {
	var w = window.open(url, 'email',"toolbars=no,scrollbars=no,resizable,width=" + width + ",height=" + height);
	w.focus();
}


/** launches the email-a-friend popup **/
function emailFriend() {
	var url = "/index.php/intl/public/rv/email";
	var w = window.open(url, 'email','toolbars=no,scrollbars=no,resizable,width=560,height=450');
	w.focus();
}

/** launches the Canadian Regulations popup **/
function caRegulations() {
	var url = "/ca-regulations.html";
	var w = window.open(url, 'email','toolbars=no,scrollbars=no,resizable,width=560,height=550');
	w.focus();
}

/* email validator */
function validEmail(str) {
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})$/;
	return (filter.test(str));  //returns true if valid, false if not
}


/** validates the contactUs form for submission **/
function checkForm(form) {
	if (form.name.value == "" || form.email.value == "" || form.address.value == "" ||
		form.city.value == "" || form.state.value == "" || form.zip.value == "" ||
		form.phone.value == "") {
		alert("Please complete all required fields");
		return false;	
	}
	return true;
}

/** validates the dealer login form for submission **/
function checkLoginForm(form) {
	if (form.userName.value == "" || form.dealerName.value == "" || form.login.value == "" ||
		form.password.value == "") {
		alert("All fields are required.");
		return false;	
	}
	return true;
}

/** validates email-a-friend form **/
function checkEmailForm(form) {
	if (form.fromNm.value == "" || form.fromEmail.value == "" || form.toNm.value == "" ||
		form.toEmail.value == "") {
		alert("Please complete all required fields");
		return false;	
	} else if (!validEmail(form.fromEmail.value) || !validEmail(form.toEmail.value)) {
		alert("One or more email addresses appear to be invalid.  This message cannot be delivered without valid addresses.");
		return false;
	}
	
	if (form.url.value == "") form.url.value = window.opener.location;
	return true;
}

/**
 * styelsheet switcher, for print-friendly layouts
 **/
var newCss = "print-";
function printLayout() {
	var vLoop, vLink;
	for(vLoop=0; vLink = document.getElementsByTagName("link")[vLoop]; vLoop++) {
		if (vLink.getAttribute("rel").indexOf("stylesheet")!= -1 && vLink.getAttribute("href")) {
			var v = vLink.getAttribute("href");
			if (v.indexOf("layout") != -1) {
				vLink.disabled = true;
				vLink.setAttribute("href", "/bin/style/" + newCss + "layout.css");
				vLink.disabled = false;
			}
		}
	}
	newCss = (newCss == "print-") ? "" : "print-" ;
	scrollTo(0,0);
	return;
}


/** for homepage PNG flyouts **/
function showHomeImage(imgSrc) {
	var tmpImg = document.getElementById("homeRolloverImage");
	tmpImg.src = "/bin/images/prod_lines/thumb/" + imgSrc;
	document.getElementById("homeRollover").style.display = "block";
}
function hideHomeImage() {
	document.getElementById("homeRollover").style.display = "none";
}


/** dropdown menus **/
var currAlias = null;
var parObj = null;
var chiObj = null;
var menuVisible = false;

//fix for menu positioning relative to the rendering
var xOffset = (navigator.appVersion.indexOf("MSIE 7.") > 0) ? -616 : -60;
var yOffset = 18; // + ((navigator.appVersion.indexOf("MSIE ") > 0) ? 0 : 0);
if (navigator.appVersion.indexOf("MSIE 6.") > 0) xOffset=0;

function showMenu(d) {
	if (chiObj != null) hideMenu();
	
	currAlias = d;
	parObj = document.getElementById(d + "Menu");
	chiObj = document.getElementById(d + "SubMenu");

	chiObj.className = "menuLevel2Show";
	chiObj.style.left = (parObj.offsetLeft-xOffset) + "px";
	chiObj.style.top = (parObj.offsetTop+yOffset) + "px";
	
	//add event listeners and monitor cursor movement
	menuVisible = true;
	parObj.onmouseover = setFocus; 
	parObj.onmouseout = setBlur;
	chiObj.onmouseover = setFocus; 
	chiObj.onmouseout = setBlur;
	monitorFocus();
}
function hideMenu() {
	if (parObj != null) parObj.onmouseover = new Function("showMenu('" + currAlias + "')");
	if (chiObj != null) chiObj.className = "menuLevel2";
}
function setFocus() {
	menuVisible = true;
}
function setBlur() {
	menuVisible = false;
}
function monitorFocus() {
	if (!menuVisible) hideMenu();
	else setTimeout("monitorFocus()", 500);
}

