var pics = new Array();
var imgCount = 0;
var checkform = true;

function validate( formName, formVal)
{
	if(formName == "name")
	{
		if (formVal == null || formVal == "")
		{
			alert("You need to fill out your name.");
			checkform = false;
		}
	}
	else if (formName == "email")
	{
		if (formVal == null || formVal == "" || formVal == 0)
		{
			alert("You need to fill out your email address.");
			checkform = false;
		}
	}
	else if (formName == "contact")
	{
		if (formVal == null || formVal == "" || formVal == "0")
		{
			alert("You need to choose a means of contact.");
			checkform = false;
		}
	}

}

function checkVal()
{
	checkform = true;
	
	for (i = 0; i < document.forms[0].elements.length; i++)
	{
		if (document.forms[0].elements[i].name == "contact")
			validate(document.forms[0].elements[i].name, document.forms[0].elements[i].options[document.forms[0].elements[i].selectedIndex].value);
		else
			validate(document.forms[0].elements[i].name, document.forms[0].elements[i].value);
	}
}

function gotoCommunity(){
	var c = document.ffind.findit[document.ffind.findit.selectedIndex].value;
	if (c == 9 || c == 47 || c == 48 || c == 49 || c == 50)
		window.open("http://www.liveatragleranch.com", "", "toolbar=yes,scrollbars=yes,resizable=yes");
	else
		document.location.href="overview.asp?cid=" + c;
}

function showPage(p){
	document.f1.currentPage.value = p;
	document.f1.submit();
}

function preloadImages()
{
	loadImage("nav_whatsnew");
	loadImage("nav_calendar");
	loadImage("nav_newhomes");
	loadImage("nav_realty");
	loadImage("nav_mortgage");
	loadImage("nav_designstudio");
	loadImage("nav_aboutus");
	loadImage("nav_customerservice");
	loadImage("nav_joinourteam");
	loadImage("nav_contactus");
	loadImage("nav_brokers");
	loadImage("nav_trades");
	loadImage("arrows_whatsnew");
	loadImage("arrows_newhomes");
	loadImage("arrows_aboutus");
}

function loadImage(name)
{
	pics[imgCount] = new Array(3);
	pics[imgCount][0] = new Image;
	pics[imgCount][0].src = "images/" + name + ".gif";
	pics[imgCount][1] = new Image;
	pics[imgCount][1].src = "images/" + name + "_roll.gif";
	pics[imgCount][2] = name;
	imgCount++;
}

function off(imgName){
	if (document.images) {
 		for (var i=0;i<imgCount;i++){
			if (pics[i][2] == imgName)
				document.images[imgName].src = pics[i][0].src; 
     		}
	}
}

function on(imgName){
	if (document.images) {
		for (var i=0;i<imgCount;i++){
			if (pics[i][2] == imgName)
				document.images[imgName].src = pics[i][1].src; 
		}
	}
}

function showDisclaimer(){
	window.open("disclaimer.html","","toolbar=no,scrollbars=no,width=400,height=250,resizable=no");
}

function showTerms(){
	window.open("termsofuse.html","","toolbar=no,scrollbars=yes,width=600,height=400,resizable=yes");
}

function showPrivacy(){
	window.open("privacypolicy.html","","toolbar=no,scrollbars=yes,width=600,height=400,resizable=yes");
}
function showBrokers(){
	
}

function nancyBrooks(){
	window.open("nancybrooks.asp","","toolbar=no,scrollbars=no,width=400,height=300,resizable=no");
}

function halSackett(){
	window.open("halsackett.asp","","toolbar=no,scrollbars=yes,width=400,height=300,resizable=no");
}

function jillKingwell(){
	window.open("jillkingwell.asp","","toolbar=no,scrollbars=yes,width=400,height=300,resizable=no");
}

function rainaDuran(){
	window.open("rainaduran.asp","","toolbar=no,scrollbars=yes,width=400,height=300,resizable=no");
}

function showJob(i){
	window.open("joblist.asp?id=" + i,"","toolbar=no,scrollbars=yes,width=400,height=400,resizable=yes");
}

function showMap(m){
	if (m=='wisteria_communitymap_popup.html')
		window.open(m, "", "toolbar=no,scrollbars=yes,width=1025,height=670,resizable=yes");
	else	
		window.open(m, "", "toolbar=no,scrollbars=yes,width=600,height=500,resizable=yes");
}

function hl(n){
	var ro, x, y;
	switch(n){
		
		case 8:{x = 245;y = 360;ro = "WEST HAVEN";} break;
		case 9:{x = 251;y = 334;ro = "GRASSLANDS AT RAGLE RANCH";} break;
		case 47:{x = 251;y = 334;ro = "GRASSLANDS TOWNHOMES<br>AT RAGLE RANCH";} break;
		case 48:{x = 251;y = 334;ro = "SAGEWOOD AT RAGLE RANCH";} break;
		case 49:{x = 251;y = 334;ro = "LINWOOD AT RAGLE RANCH";} break;
		case 50:{x = 251;y = 334;ro = "CHAPARRAL AT RAGLE RANCH";} break;
		case 46:{x = 252;y = 407;ro = "OLIVE RIDGE";} break;
		
		
		case 10:{x = 375;y = 321;ro = "MONTECITO";} break;
		case 11:{x = 309;y = 307;ro = "LEGACY LANE";} break;
		case 12:{x = 287;y = 415;ro = "INNOVATIONS";} break;
		case 42:{x = 181;y = 267;ro = "HEARTLAND";} break;
		case 43:{x = 327;y = 287;ro = "ARBORS";} break;
		case 44:{x = 341;y = 273;ro = "WISTERIA";} break;
		case 45:{x = 218;y = 300;ro = "OAK HOLLOW";} break;
		case 51:{x = 231;y = 325;ro = "PALM SQUARE";} break;
		case 52:{x = 190;y = 246;ro = "LAVENDER LANE";}break;
		
	}
			
	eval("document.b" + n + ".src='images/yellowarrow.gif'");
	
	if(document.getElementById){
		document.getElementById("rotext").innerHTML = ro;
		document.getElementById("whitedot").style.visibility = 'visible';
		document.getElementById("whitedot").style.left = x;
		document.getElementById("whitedot").style.top = y;
		eval("document.getElementById('c" + n + "').style.color='#FFFFFF'");
	}
	else if (document.layers){
		document.whitedot.visibility = 'visible';
		document.whitedot.left = x;
		document.whitedot.top = y;
		document.layer['rotext'].innerHTML = ro;
	}
}

function uhl(n){
	eval("document.b" + n + ".src='images/spacer.gif'");
	
	if(document.getElementById){
		document.getElementById("whitedot").style.visibility = 'hidden';
		eval("document.getElementById('c" + n + "').style.color='#C8AA48'");
		document.getElementById("rotext").innerHTML = "";
	}
	else if (document.layers)
		document.whitedot.visibility = 'hidden';
}

function floor(number)
{
  return Math.floor(number*Math.pow(10,2))/Math.pow(10,2);
}

function dosum()
{
  var mi = document.f1.IR.value / 1200;
  var base = 1;
  var mbase = 1 + mi;
  for (i=0; i<document.f1.YR.value * 12; i++)
  {
    base = base * mbase
  }
  document.f1.PI.value = floor(document.f1.LA.value * mi / ( 1 - (1/base)))
  document.f1.MT.value = floor(document.f1.AT.value / 12)
  document.f1.MI.value = floor(document.f1.AI.value / 12)
  var dasum = document.f1.LA.value * mi / ( 1 - (1/base)) +
	document.f1.AT.value / 12 + 
	document.f1.AI.value / 12;
  document.f1.MP.value = floor(dasum);
}

function selNorth(){
	document.f1.currentPage.value = "1";
	document.f1.action = "quickmoveinnb.asp";
	document.f1.submit();
}

function selSac(){
	document.f1.currentPage.value="1";
	document.f1.action = "quickmoveinsac.asp";
	document.f1.submit();
}


function commVT(communityid){
	window.open("virtualtours.asp?commid="+communityid,"", "toolbar=no,scrollbars=no,width=600,height=600,resizable=no");
}






// instead of document.createElement
function dce(obj) {
    return document.createElement(obj);
}

// instead of setAttribute
function sa(obj,attr,val) {
    obj.setAttribute(attr,val);
}

// so long as obj has children, remove them
function clearInnerHTML(obj) {
    while(obj.firstChild) obj.removeChild(obj.firstChild);
}
