// prepare top navigation
window.onload = function()
{
	var lis = document.getElementById('cssnav').getElementsByTagName('li');
	for(i = 0; i < lis.length; i++)
	{
		var li = lis[i];
		if (li.className == 'cssheader')
		{
			li.onmouseover = function() { this.getElementsByTagName('ul').item(0).style.display = 'block'; }
			li.onmouseout = function() { this.getElementsByTagName('ul').item(0).style.display = 'none'; }
		}
	}
}


// change color of internal side naviation and text on right side
function switchtips(whichtip)
{

// set all green bg buttons to red
mya = document.getElementById(whichtip);
myaClassName = mya.className;

for (var i = 0; i < document.getElementsByTagName("a").length; i++) 
  {
  if (document.getElementsByTagName("a").item(i).className == 'tips_on')
    {
    document.getElementsByTagName("a").item(i).className = 'tips';
    }
  }

if (myaClassName=="tips_on")
  {
  mya.className = 'tips';
  document.getElementById("news_right").style.marginTop="";
  document.getElementById("news_right").innerHTML = document.getElementById("d_main").innerHTML;
  }
  else if (myaClassName=="tips")
  {
  mya.className = 'tips_on';

  // hack to allow content that begins with a paragraph tag to avoid jumping down
  if (document.getElementById("d_"+whichtip).innerHTML.indexOf("<P>")==0 && document.getElementById("news_right").style.marginTop=="")
    {
    document.getElementById("news_right").style.marginTop="-5px";
    }
    else if (document.getElementById("d_"+whichtip).innerHTML.indexOf("<P>")!=0 && document.getElementById("news_right").style.marginTop=="-5px")
    {
    document.getElementById("news_right").style.marginTop="";
    }

  // set the right side to the tip
  document.getElementById("news_right").innerHTML = document.getElementById("d_"+whichtip).innerHTML;
  }
}

// copies the content in the main section into a hidden div so that it can be replaced later
function copyMain()
{
document.getElementById("d_main").innerHTML = document.getElementById("news_right").innerHTML;
}



// check all checkboxes in the broker/realtor signup form
function checkall()
{
count = document.Broker_Signup.elements.length;
    for (i=0; i < count; i++) 
	{
    if(document.Broker_Signup.All_Communities.checked == 1)
    	{document.Broker_Signup.elements[i].checked = 1; }
    else {document.Broker_Signup.elements[i].checked = 0;}
	}
}

// check all checkboxes in the consumer signup form
function checkthem()
{
count = document.Interest_Signup.elements.length-12;
    for (i=0; i < count; i++) 
	{
    if(document.Interest_Signup.All_Communities.checked == 1)
    	{document.Interest_Signup.elements[i].checked = 1; }
    else {document.Interest_Signup.elements[i].checked = 0;}
	}
}

function valForm(formName)
{


switch(formName)
{

case "Broker_Signup":
k=0;
mycount = document.Broker_Signup.elements.length;
for (j=0; j < mycount; j++) 
{
if(document.Broker_Signup.elements[j].checked == 1)
{
k++;
}
}

if (document.Broker_Signup.realtor_first_name.value.length < 2) { alert('Please enter a first name '); document.Broker_Signup.realtor_first_name.select(); return false; }
else if (document.Broker_Signup.realtor_last_name.value.length < 2) { alert('Please enter a last name '); document.Broker_Signup.realtor_last_name.select(); return false; }
else if (document.Broker_Signup.realtor_email_address.value.length < 5 || document.Broker_Signup.realtor_email_address.value.indexOf("@") == -1) { alert('Please enter your email address '); document.Broker_Signup.realtor_email_address.select(); return false; }
else if (document.Broker_Signup.realtor_password.value.length < 2) { alert('Please enter a password '); document.Broker_Signup.realtor_password.select(); return false; }
else if (document.Broker_Signup.realtor_office_name.value.length < 2) { alert('Please enter the name of your office/business '); document.Broker_Signup.realtor_office_name.select(); return false; }
else if (document.Broker_Signup.realtor_broker_name.value.length < 2) { alert('Please enter the name of your broker '); document.Broker_Signup.realtor_broker_name.select(); return false; }
else if (document.Broker_Signup.realtor_address.value.length < 2) { alert('Please enter your street address '); document.Broker_Signup.realtor_address.select(); return false; }
else if (document.Broker_Signup.realtor_city.value.length < 2) { alert('Please enter your city '); document.Broker_Signup.realtor_city.select(); return false; }
else if (document.Broker_Signup.realtor_zip.value.length < 5) { alert('Please enter your ZIP Code '); document.Broker_Signup.realtor_zip.select(); return false; }
else if (document.Broker_Signup.realtor_daytime_phone.value.length < 2) { alert('Please enter a daytime phone number where you can be reached '); document.Broker_Signup.realtor_daytime_phone.select(); return false; }
else if (k==0) { alert('Please select at least one community '); return false; }
else if (document.Broker_Signup.realtor_hear.options[document.Broker_Signup.realtor_hear.selectedIndex].value=="") { alert('Please tell us how you heard about us '); document.Broker_Signup.realtor_hear.focus(); return false; }
else if (document.Broker_Signup.captcha_code.value.length < 5) { alert('Please identify the letters in the\nimage at the bottom of the\npage and type them into the field\nbelow the image.\n\nIf you have trouble reading\nthem you can click on the speaker\nicon to hear them.\n\nThis is the standard method of\navoiding spam, sometimes called\na CAPTCHA.'); document.Broker_Signup.captcha_code.select(); return false; }
else { document.Broker_Signup.submit(); }
break;

case "Interest_Signup":
l=0;
mycount = document.Interest_Signup.elements.length;
for (j=0; j < mycount; j++) 
{
if(document.Interest_Signup.elements[j].checked == 1)
{
l++;
}
}

if (document.Interest_Signup.consumer_first_name.value.length < 2) { alert('Please enter a first name '); document.Interest_Signup.consumer_first_name.select(); return false; }
else if (document.Interest_Signup.consumer_last_name.value.length < 2) { alert('Please enter a last name '); document.Interest_Signup.consumer_last_name.select(); return false; }
else if (document.Interest_Signup.consumer_email_address.value.length < 5 || document.Interest_Signup.consumer_email_address.value.indexOf("@") == -1) { alert('Please enter your email address '); document.Interest_Signup.consumer_email_address.select(); return false; }
else if (document.Interest_Signup.consumer_address.value.length < 2) { alert('Please enter your street address '); document.Interest_Signup.consumer_address.select(); return false; }
else if (document.Interest_Signup.consumer_city.value.length < 2) { alert('Please enter your city '); document.Interest_Signup.consumer_city.select(); return false; }
else if (document.Interest_Signup.consumer_zip.value.length < 5) { alert('Please enter your ZIP Code '); document.Interest_Signup.consumer_zip.select(); return false; }
else if (document.Interest_Signup.consumer_daytime_phone.value.length < 2) { alert('Please enter a daytime phone number where you can be reached '); document.Interest_Signup.consumer_daytime_phone.select(); return false; }
else if (l==0) { alert('Please select at least one community '); return false; }
else if (document.Interest_Signup.consumer_hear.options[document.Interest_Signup.consumer_hear.selectedIndex].value=="") { alert('Please tell us how you heard about us '); document.Interest_Signup.consumer_hear.focus(); return false; }
else if (document.Interest_Signup.captcha_code.value.length < 5) { alert('Please identify the letters in the\nimage at the bottom of the\npage and type them into the field\nbelow the image.\n\nIf you have trouble reading\nthem you can click on the speaker\nicon to hear them.\n\nThis is the standard method of\navoiding spam, sometimes called\na CAPTCHA.'); document.Interest_Signup.captcha_code.select(); return false; }
else { document.Interest_Signup.submit(); }
break;

case "Cust_Service":
if (document.Cust_Service.first_name.value.length < 2) { alert('Please enter a first name '); document.Cust_Service.first_name.select(); return false; }
else if (document.Cust_Service.last_name.value.length < 2) { alert('Please enter a last name '); document.Cust_Service.last_name.select(); return false; }
else if (document.Cust_Service.email_address.value.length < 5 || document.Cust_Service.email_address.value.indexOf("@") == -1) { alert('Please enter your email address '); document.Cust_Service.email_address.select(); return false; }
else if (document.Cust_Service.address.value.length < 2) { alert('Please enter your street address '); document.Cust_Service.address.select(); return false; }
else if (document.Cust_Service.city.value.length < 2) { alert('Please enter your city '); document.Cust_Service.city.select(); return false; }
else if (document.Cust_Service.state.value.length != 2) { alert('Please enter your state '); document.Cust_Service.state.select(); return false; }
else if (document.Cust_Service.home_phone.value.length < 2) { alert('Please enter your home phone number '); document.Cust_Service.home_phone.select(); return false; }
else if (document.Cust_Service.service_item.value.length < 10) { alert('Please describe what you would like customer service with '); document.Cust_Service.service_item.select(); return false; }
else if (document.Cust_Service.captcha_code.value.length < 5) { alert('Please identify the letters in the\nimage at the bottom of the\npage and type them into the field\nbelow the image.\n\nIf you have trouble reading\nthem you can click on the speaker\nicon to hear them.\n\nThis is the standard method of\navoiding spam, sometimes called\na CAPTCHA.'); document.Cust_Service.captcha_code.select(); return false; }
else { document.Cust_Service.submit(); }
break;
}

}

function sendpassword()
{
document.brokerloginform.Side_Form.value = "sendemail";
document.brokerloginform.submit();
}

function switchme()
{
signaturelogo.src="images/signature.png";
}