

function getcookie (name) {
var dcookie = document.cookie; 
var cname = name + "=";
var clen = dcookie.length;
var cbegin = 0;
        while (cbegin < clen) {
        var vbegin = cbegin + cname.length;
                if (dcookie.substring(cbegin, vbegin) == cname) { 
                var vend = dcookie.indexOf (";", vbegin);
                        if (vend == -1) vend = clen;
                return unescape(dcookie.substring(vbegin, vend));
                }
        cbegin = dcookie.indexOf(" ", cbegin) + 1;
                if (cbegin == 0) break;
        }
return null;
}

function WindowStatus() {
var text= getcookie("buyers")
var text2= getcookie("renters")
var text3= getcookie("sellers")
var text4= getcookie("exchangers")
window.status="Buyers  " + text + "  Renters " + text2 + "  Sellers " + text3 + "  Exchangers  " + text4;
}

function windowstatus() {
var text= getcookie("buyers")
var text2= getcookie("renters")
var text3= getcookie("sellers")
var text4= getcookie("exchangers")
window.status="Buyers  " + text + "  Renters " + text2 + "  Sellers " + text3 + "  Exchangers  " + text4;
}


 function changeCountry(fm)
  {
  	if(fm.Country.value != 'USA')
	{
		if(fm.City.value == "")
		{
			window.alert('Please enter the city where you live!')
			fm.City.focus();
		}
		
		fm.CountryCode.disabled = false;
		
		document.getElementById('divState').style.display = '';
		fm.State.value = 'Other';
	}
	else
	{
		fm.CountryCode.disabled = true;
		fm.State.value = '';
		document.getElementById('divState').style.display = 'none';
	}
  }
  
  



function opener(width,height,url){
     var ytop = screen.height/2 - (height/2);
window.open(url, "mywindow", 'height='+height+',width='+width+',scrollbars=yes,resizable=1');
}




function opener2(width,height,page){
     var ytop = screen.height/2 - (height/2);
window.open(page, "mywindow", 'height='+height+',width='+width+',scrollbars=no');
}


function isPhoneNumber(s) 
{

 // Check for correct phone number
 rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);
 //rePhoneNumber = new RegExp(/^\[1-9]\d{2}\\s?\d{3}\-\d{4}$/)
 
 if (!rePhoneNumber.test(s)) 
 {
  	//alert("Phone Number Must Be Entered As: (555) 555-1234");
    return false;
 }
	return true;
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
  
function CareTieCheck(fm)
{
var phone = "(" + fm.AreaCode.value + ")" + fm.PhoneNumber.value

if(fm.Email.value == "")
  {
    alert("please enter your email address")
    fm.Email.focus()
    return false
  }
  if(!fm.Email.value=="" && fm.Email.value.indexOf("@")==-1)
      {alert("Please enter a valid email address.")
       fm.Email.focus()
       return false
      }
  if(!fm.Email.value=="" && fm.Email.value.indexOf(".")==-1)
      {alert("Please enter a valid email address.")
       fm.Email.focus()
       return false
      }
  if(fm.FirstName.value == "")
  {
    alert("Please enter your first name")
    fm.FirstName.focus()
    return false
  }
  if(fm.LastName.value == "")
  {
	alert("Please enter your last name")
	fm.LastName.focus()
	return false
  } 
  if(fm.Address.value == "")
  {
	alert("Please enter your address")
	fm.Address.focus()
	return false
  }
  if(fm.Country.value != 'USA' && fm.City.value == "")
   {
     alert('Please enter your city where you live!')
     fm.City.focus()
	 return false
   }
  if(fm.Zip.value == "")
  {
    alert("Please enter your zip code")
    fm.Zip.focus()
    return false
  } 
  if(!validateZip(fm.Zip.value, fm.Country.value))
  {
  	alert("Please enter a numeric zip code")
    fm.Zip.focus()
    return false
  }
  
  if(fm.AreaCode.value =="")
  {
    alert("Please enter the area code of your phone number")
	fm.AreaCode.focus()
    return false
  }
   if(fm.PhoneNumber.value =="")
  {
    alert("Please enter your phone number")
	fm.PhoneNumber.focus()
    return false
  }
  if(!isPhoneNumber(phone))
  {
  	 alert("Phone Number Must Be Entered As: (555) 555-1234");
	 fm.AreaCode.focus();
	 return false;
  }
  
  if(fm.Comments.value.length  > 150)
     {alert("You have entered too much information in the comments box. Please limit your comment to under 150 characters.")
      fm.Comments.focus()
      return false
     }
  else
  {
    fm.action = "/register.asp?SendMail=Yes"
    return true
  }
}
  

function checkState(fm)
  {
  	if(fm.State.value == "Other")
	{
		document.getElementById('divState').style.display = '';
		fm.StateOther.focus();
	}
	else
	{
		document.getElementById('divState').style.display = 'none';
	}
  }
  
  function checkProspectState(fm)
  {
  	if(fm.ProspectState.value == "Other")
	{
		document.getElementById('divProspectState').style.display = '';
		fm.ProspectStateOther.focus();
	}
	else
	{
		document.getElementById('divProspectState').style.display = 'none';
	}
  }
  
  function validateZip(zip, country)
  {
  //If country isn't canada and zip isn't a number
  	if(isNaN(zip) == true && country != "CAN")
	{
	 	return false;
	}
	else
	{
		return true;
	}
  }
  
  
  function cancelClick(fm)
  {
	window.location = "http://www.timeshare-information-exchange.com"
  
  }
  
  
  function checkReferralForm(fm)
{
	var phone = "(" + fm.AreaCode.value + ")" + fm.PhoneNumber.value

      if(fm.ProspectFirstName.value=="")
      {alert("Please enter the Prospect's first name.")
       fm.ProspectFirstName.focus()
       return false
      }
	  else if(fm.ProspectLastName.value=="")
      {alert("Please enter the Prospect's last name.")
       fm.ProspectLastName.focus()
       return false
      }
	  else if(!fm.ProspectEmail.value=="" && fm.ProspectEmail.value.indexOf("@")==-1)
      {alert("The Prospect's email address is not valid.")
       fm.ProspectEmail.focus()
       return false
      }
    else if(!fm.ProspectEmail.value=="" && fm.ProspectEmail.value.indexOf(".")==-1)
      {alert("The Prospect's email address is not valid.")
       fm.ProspectEmail.focus()
       return false
      }
	  else if(fm.ProspectDayPhone.value=="")
      {alert("Please enter the Prospect's phone number.")
       fm.ProspectDayPhone.focus()
       return false
      }
	  else if(fm.RealEstateOffice.value=="")
      {alert("Please enter the name of your Real Estate office.")
       fm.RealEstateOffice.focus()
       return false
      }
	  else if(fm.FirstName.value=="")
      {alert("Please enter your first name.")
       fm.FirstName.focus()
       return false
      }
	  else if(fm.LastName.value=="")
      {alert("Please enter your last name.")
       fm.LastName.focus()
       return false
      }
	 else if(fm.Country.value != 'USA' && fm.City.value == "")
	   {
		 alert('Please enter your city where you live!')
		 fm.City.focus()
		 return false
	   }
	 else if(!validateZip(fm.Zip.value, fm.Country.value))
	  {
		alert("Please enter a numeric zip code")
		fm.Zip.focus()
		return false
	  }
	if(fm.Email.value == "")
      {
        alert("Please enter your email address.")
        fm.Email.focus()
        return false
      }
	else if(!fm.Email.value=="" && fm.Email.value.indexOf("@")==-1)
      {alert("Your email address is not valid.")
       fm.Email.focus()
       return false
      }
    else if(!fm.Email.value=="" && fm.Email.value.indexOf(".")==-1)
      {alert("Your email address is not valid.")
       fm.Email.focus()
       return false
      }
	 else if(fm.AreaCode.value =="")
  {
    alert("Please enter the area code of your phone number")
	fm.AreaCode.focus()
    return false
  }
  else if(fm.PhoneNumber.value =="")
  {
    alert("Please enter your phone number")
	fm.PhoneNumber.focus()
    return false
  }
  else if(!isPhoneNumber(phone))
  {
  	 alert("Phone Number Must Be Entered As: (555) 555-1234");
	 fm.AreaCode.focus();
	 return false;
  }
   else if(fm.Comments.value.length  > 150)
     {alert("You have entered too much information in the comments box. Please limit your comment to under 150 characters.")
      fm.Comments.focus()
      return false
     }
    else
      {fm.action="referral.asp?SendMail=Yes&type=realtor#sucess"
       return true
      }
  }
  
  
   /*Check Password */
  var commonPasswords = new Array('password', 'pass', '1234', '1246'); 
 
var numbers = "0123456789"; 
var lowercase = "abcdefghijklmnopqrstuvwxyz"; 
var uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
var punctuation = "!.@$£#*()%~<>{}[]"; 
 
function checkPassword(password) { 
 
    var combinations = 0; 
 
    if (contains(password, numbers) > 0) { 
        combinations += 10; 
    } 
 
    if (contains(password, lowercase) > 0) { 
        combinations += 26; 
    } 
 
    if (contains(password, uppercase) > 0) { 
        combinations += 26; 
    } 
 
    if (contains(password, punctuation) > 0) { 
        combinations += punctuation.length; 
    } 
 
    // work out the total combinations 
    var totalCombinations = Math.pow(combinations, password.length); 
 
    // if the password is a common password, then everthing changes... 
    if (isCommonPassword(password)) { 
        totalCombinations = 75000 // about the size of the dictionary 
    } 
 
    // work out how long it would take to crack this (@ 200 attempts per second) 
    var timeInSeconds = (totalCombinations / 200) / 2; 
 
    // this is how many days? (there are 86,400 seconds in a day. 
    var timeInDays = timeInSeconds / 86400 
 
    // how long we want it to last 
    var lifetime = 365; 
 
    // how close is the time to the projected time? 
    var percentage = timeInDays / lifetime; 
 
    var friendlyPercentage = cap(Math.round(percentage * 100), 100); 
    if (totalCombinations != 75000 && friendlyPercentage < (password.length * 5)) { 
        friendlyPercentage += password.length * 5; 
    } 
 
    var progressBar = document.getElementById("progressBar"); 
    progressBar.style.width = friendlyPercentage + "%"; 
 
    if (percentage > 1) { 
        // strong password 
        progressBar.style.backgroundColor = "#3bce08"; 
        return; 
    } 
 
    if (percentage > 0.5) { 
        // reasonable password 
        progressBar.style.backgroundColor = "#ffd801"; 
        return; 
    } 
 
    if (percentage > 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "orange"; 
        return; 
    } 
 
    // useless password! 
    if (percentage <= 0.10) { 
        // weak password 
        progressBar.style.backgroundColor = "red"; 
        return; 
    } 
 
 
} 
 
function cap(number, max) { 
    if (number > max) { 
        return max; 
    } else { 
        return number; 
    } 
} 
 
function isCommonPassword(password) { 
 
    for (i = 0; i < commonPasswords.length; i++) { 
        var commonPassword = commonPasswords[i]; 
        if (password == commonPassword) { 
            return true; 
        } 
    } 
 
    return false; 
 
} 
 
function contains(password, validChars) { 
 
    count = 0; 
 
    for (i = 0; i < password.length; i++) { 
        var char = password.charAt(i); 
        if (validChars.indexOf(char) > -1) { 
            count++; 
        } 
    } 
 
    return count; 
} 
 
/*End Password Javascript */
  

