function popUp(page,width,height,title) {
	winprops = "toolbar=0,status=0,scrollbars=1,resizable=1,width=" + width + ", height=" + height;
	new_win = window.open(page, title, winprops);
	new_win.focus();
}

function showAd(tabshow, tabhide) {		
	swapAdHeaderCopy(tabshow);
	$(".adinfo-" + tabshow).css("display", "block");
	$(".adinfo-" + tabhide).css("display", "none");
	$("#tabshow").removeClass().addClass("active");
	$("#tabhide").removeClass();
}

function swapAdHeaderCopy(tabshow){
	var copy;
	if(tabshow == "ads"){
		copy = "IMPORTANT NOTE:  ALL THESE ADS CAN BE CUSTOMIZED FOR YOUR SPECIFIC NEEDS.";
	}else{ 
		copy = "IMPORTANT NOTE:  ALL THESE PACKAGES CAN BE CUSTOMIZED FOR YOUR SPECIFIC NEEDS.";
	}
	$('.adnote').text(copy);
}

//Validate data and Build Error Message
function validateData() {
	var errorMsg = "";
		if (!document.dealertown_contact.realname.value) { errorMsg += "Please enter your name.\n"; }
		if (!document.dealertown_contact.email.value.match(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/)) { errorMsg += "Please enter a valid e-mail address.\n"; }
    	if ((!document.dealertown_contact.dayphone.value) && (!document.dealertown_contact.nightphone.value))  { errorMsg += "Please enter your day or night phone number with area code.\n"; }
    	if ( (document.dealertown_contact.dayphone.value) && (!document.dealertown_contact.dayphone.value.match(/^(1|\+|\-| )+\d{3}[\- ]\d{3}[\- ]\d{4}$/) && !document.dealertown_contact.dayphone.value.match(/^\d{3}[\- ]\d{3}[\- ]\d{4}$/))) { errorMsg += "Please re-enter your day phone number with area code.\n"; }
    	if ( (document.dealertown_contact.nightphone.value) && (!document.dealertown_contact.nightphone.value.match(/^(1|\+|\-| )+\d{3}[\- ]\d{3}[\- ]\d{4}$/) && !document.dealertown_contact.nightphone.value.match(/^\d{3}[\- ]\d{3}[\- ]\d{4}$/))) { errorMsg += "Please re-enter your night phone number with area code.\n"; }
  	 	if ((!document.dealertown_contact.zip.value) || (!document.dealertown_contact.zip.value.match(/^\d\d\d\d\d$/))) { errorMsg += "Please enter your 5-digit U.S. zip code.\n"; }
		if (errorMsg) { dispErrorMsg("We're sorry.  We could not send your data as it was submitted.\n", errorMsg); }
		else {  return true; }
	}

//Alert of invalid data
function dispErrorMsg(head, errorMsg) {
	var line = "________________________________________________________\n\n";
	alert(line + head + line + errorMsg);
	return false;
}

function choose_section(section_name) {
	document.cookie="section="+section_name+"; path=/";
}

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);

















