// set default pop-up window dimensions. 
var popupWidth = 500; 
var popupHeight = 400; 
// 
//	showSection - Advanced search zone locations 
// 
function setCheckedItems(bChecked) { 
var query = window.location.search.substring(1);
var pairs = query.split("&");
for (var i=0;i= 0;) { 
var argname = pairs[i].substring(0,pos);
var value = pairs[i].substring(pos+1);
if(argname.substring(0, 1) == "L" && argname != "living") { 

var elem = document.getElementById(String(argname));
if(elem != null) { 
if(elem.tagName == "INPUT" && elem.type == "checkbox") { 
if(bChecked) { 
//alert("Checking items");
elem.checked = true;

} else { 
//alert("Unchecking items");
//elem.checked = false;

var elems = document.frmSearch.elements;
for(var j = 0;j < elems.length;j++) { 
var elemName = elems[j].name;
if(elemName.substring(0, 1) == "L" && elemName != "living") { if(elems[j].tagName == "INPUT" && elems[j].type == "checkbox") { elems[j].checked = false;

}
}
}
}
}
}	
}
}
}
function displaySection(aValue, bDoCheck) { 
var zone1, zone2;
zone1 = document.getElementById('zone1');
zone2 = document.getElementById('zone2');
if(bDoCheck) { setCheckedItems(true);

}
else { setCheckedItems(false);

}
if (aValue == 'zone1') { zone2.style.display = "none";
if (zone1.style.display != "block") { zone1.style.display = "block";

}
else { zone1.style.display = "none";

}

}
else if (aValue == 'zone2') { zone1.style.display = "none";
if (zone2.style.display != "block") { zone2.style.display = "block";

}
else { zone2.style.display = "none";

}

}

}

// 
// gotoURL - allows a URL to be coded into an HTML block 
// append vid to the URL. 
// 
function gotoURL(theURL, newWindow) { 
var newURL = theURL;
var blnVID = false;// 
// make sure local variable vid is available 
// 
if (typeof(vid) == 'string') { blnVID = true;}
if (theURL.match(/[?]/)) { 
// 
// there are already query string variables 
// append vid 
// 
if (blnVID) newURL = newURL + "&vid=" + vid;

}else { 
// 
// there are no query string variables. assume this 
// is a link to external site. 
// 
//
if (blnVID) newURL = newURL + "?vid=" + vid;

}
if (typeof(newWindow) != 'undefined') { if (newWindow == 'new') { window.open(newURL);

}else { window.location.href = newURL;}

}else { window.location.href = newURL;}
return;

}

// BEGIN PRIMARY NAV ROLLOVER ========================== 
// wrapper functions to swap both "background-color style" on cell and image 
function PNavOver(imgID,newImageSRC,navID,cellID){ 
if ( newImageSRC.length != 0 ) over(imgID,newImageSRC);
setHighlightOn(navID,cellID);

}
function PSubNavOver(navID,cellID){ 
setHighlightOn(navID,cellID);

}
function PSubNavOut(navID,cellID)
{ 
setHighlightOff(navID,cellID);

}


function PNavOut(imgID,newImageSRC,navID,cellID){ if ( newImageSRC.length != 0 ) out(imgID,newImageSRC);
setHighlightOff(navID,cellID);

}

// END PRIMARY NAV ROLLOVER ========================== 
// BEGIN IMAGE ROLLOVER CODE ====================== 
// swaps image source file onmouseover, onmouseout 
function over(imgID,newImageSRC){ document.images["pnav_" + imgID].src = newImageSRC;

}
function out(imgID,newImageSRC){ document.images["pnav_" + imgID].src = newImageSRC;

}
function SwapImage(imgID,newImageSRC){ document.getElementById(imgID).src = newImageSRC;

}

// END IMAGE ROLLOVER CODE ======================= 

// BEGIN ROLLOVER CLASSNAME SWAP CODE USED BY NAV ================= 

// creates dom object from table cell to be altered. 
function setObjectForBrowser(cellID){ if(document.all && ! (document.getElementById)){ objElement = document.all[cellID];

}
else if (document.getElementById){ objElement = document.getElementById(cellID);

}
return objElement;

}

// changes css classname on specified cell 
function setHighlightOn(navid, cellID){ if(!document.layers){ 
var elementToChange = setObjectForBrowser(cellID);
elementToChange.className = navid + "_on";

}

}

// changes css classname on specified cell 
function setHighlightOff(navid, cellID){ if(!document.layers){ 
var elementToChange = setObjectForBrowser(cellID);
elementToChange.className = navid + "_off";

}

}

// BEGIN POP UP A NEW WINDOW ================================================ 
function doPopWin(strLocation,strWindowName,strParameters){ window.open(strLocation,strWindowName,strParameters);

}

// END POP UP A NEW WINDOW ================================================== 
// BEGIN FORM FIELD VALIDATION ================================================ 
function chkForm() { 
	var email = document.frmEmail.email;
	if ((email.value==null) || (email.value=="")) { 
		alert("E-mail Address is a required field.");
		email.focus();
		return false;
	}
	if (validEmail(email.value)==false) { 
		email.focus();
		return false;
	}

	var firstname = document.frmEmail.firstname;
	if (firstname != null) { 
		if ((firstname.value==null) || (firstname.value=="")) { 
			alert("First Name is a required field.");
			firstname.focus();
			return false;
		}
	}

	var lastname = document.frmEmail.lastname;
	if (lastname != null) { 
		if ((lastname.value==null) || (lastname.value=="")) { 
			alert("Last Name is a required field.");
			lastname.focus();
			return false;
		}
	}

	var subject = document.frmEmail.subject;
	if ((subject != null) && (subject.value != null) && (subject.value.length != null) && (subject.value.length > 100)) { 		
		alert("Subject is 100 characters maximum.");
		subject.focus();
		return false;
	}
	return true;

}

function validEmail(email) { 
	invalidChars = " /:,;" 
	for (i=0;i -1;) { 
		alert("Please enter a valid e-mail address."); 
		return false 
	}


	atPos = email.indexOf("@",1) 
	// there must be one "@" symbol 
	if (atPos == -1) { 
		alert("Please enter a valid e-mail address."); 
		return false 
	}
	if (email.indexOf("@",atPos+1) != -1) { 
		// and only one "@" symbol 
		alert("Please enter a valid e-mail address.");	return false 
	}
	periodPos = email.indexOf(".",atPos) 
	if (periodPos == -1) { 
		// and at least one "." after the "@" 
		alert("Please enter a valid e-mail address.") 
		return false 
	}
	if (periodPos+3 > email.length) { 
		// must be at least 2 characters after the "." 
		alert("Please enter a valid e-mail address.") 
		return false 
	}
	return true 
}

function chkAdvancedSearch() { 
var theForm = document.frmSearch;

var newURL = 'default.asp?pageID=list_view_search&siteID=' + siteID + '&vid=' + vid + '&type=1';

// 
// Test min and max values 
// 
var minValue = theForm.min.options[theForm.min.selectedIndex].value;

var maxValue = theForm.max.options[theForm.max.selectedIndex].value;
if ((Math.floor(minValue) > Math.floor(maxValue)) && (Math.floor(maxValue) > 0)) { alert("Minimum price can not be greater than maximum price.");
return false;

}
newURL += '&rg=' + theForm.rg.options[theForm.rg.selectedIndex].value + '&min=' + minValue + '&max=' + maxValue;
for (var i = 0;i < theForm.length;i++) { 
var el = theForm.elements[i];
if (el.type == 'checkbox') { if (el.checked) { newURL += '&' + el.name + '=1';

}
else { newURL += '&' + el.name + '=0';

}

}

}
window.location.href = newURL;

// 
// always return false otherwise form submit will override window.location.href 
// return false;

}
function jsFavoritesLogin() { if (document.frmFavorites.email.value.length == 0) { alert("Please enter an email address.");
document.frmFavorites.email.focus();
return;

}
document.frmFavorites.hidType.value = 'login';
document.frmFavorites.submit();

}
function jsSubmitFavorites() { if (document.frmFavorites.email.value.length == 0) { alert("Please enter an email address.");
document.frmFavorites.email.focus();
return;

}
if (validEmail(document.frmFavorites.email.value)==false) { document.frmFavorites.email.focus();
return;

}
document.frmFavorites.hidType.value = 'submit';
document.frmFavorites.submit();

}
function jsFavoritesPopup() { alert("If you would like more information on this property please proceed to Request Information or call us at 1-800-WCI-2290.");

}
function jsSubmitModelForm() { if (document.frmModel.email.value.length == 0) { alert("Email is a required field.");
document.frmModel.email.focus();
return;

}
if (validEmail(document.frmModel.email.value)==false) { document.frmModel.email.focus();
return;

}
if (document.frmModel.fname.value.length == 0) { alert("First name is a required field.");
document.frmModel.fname.focus();
return;

}
if (document.frmModel.lname.value.length == 0) { alert("Last name is a required field.");
document.frmModel.lname.focus();
return;

}
document.frmModel.submit();

}

// END FORM FIELD VALIDATION ================================================ 
function jsModelAvailability() {

// 
// modelID and vid were in query string and were assigned to local page variables 
// 
window.open('ModelAvailability.asp?modelID=' + modelID + '&vid=' + vid, '_blank', 'resizeable=no,scrollbars=no,toolbar=no,width=476,height=670');

}
