
// to hide rent button
function showdiv(pass) {
var divs = document.getElementsByTagName('div');
for(i=0;i<divs.length;i++){
if(divs[i].id.match(pass)){//if they are 'see' divs
//if (document.getElementById) // DOM3 = IE5, NS6
//divs[i].style.visibility="visible";// show/hide
//else
//if (document.layers) // Netscape 4
//document.layers[divs[i]].display = 'visible';
//else // IE 4
//document.all.divs[i].visibility = 'visible';
//} else {

if (document.getElementById)
divs[i].style.display="none";
else
if (document.layers) // Netscape 4
document.divs[i].visibility = 'hidden';
else // IE 4
document.all.divs[i].visibility = 'hidden';
}
}
} 


// JavaScript Document
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




function showTypes(){
		document.form1.flag.value='';
		form1.submit();
}


function rentType(frm){
		if (document.frm.type.value == "Rent"){
			docuemnt.frm.renttype.style = true;
		}
}

function confirmDel(frm,msg){
	if(confirm(msg) == true){
		frm.submit();
	}
}


function signup()
{
var membership_choice = false;
	for (counter = 0;  counter < frmsignup1.membership.length; counter++)
	{
		if (frmsignup1.membership[counter].checked){
		membership_choice = true; 
		}
	}
		if (!membership_choice)
		{
		alert("Please select membership type.");
		return (false);
		}
return (true);
}

// windows new open
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos)
{
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);
}


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}



// mortgage calc

    function checkNumber(input, min, max, msg) {

        msg = msg + " field has invalid data: " + input.value;

        var str = input.value;
        for (var i = 0; i < str.length; i++) {
            var ch = str.substring(i, i + 1)
            if ((ch < "0" || "9" < ch) && ch != '.') {
                alert(msg);
                return false;
            }
        }
        var num = 0 + str
        if (num < min || max < num) {
            alert(msg + " not in range [" + min + ".." + max + "]");
            return false;
        }
        input.value = str;
        return true;
    }

    function computeField(input) {

        if (input.value != null && input.value.length != 0)
            input.value = "" + eval(input.value);
        computeForm(input.form);
    }

    function computeForm(form) {

        if ((form.payments.value == null || form.payments.value.length == 0) ||
            (form.interest.value == null || form.interest.value.length == 0) ||
            (form.principal.value == null || form.principal.value.length == 0)) {
            return;
        }

        if (!checkNumber(form.payments, 1, 480, "# of payments") ||
            !checkNumber(form.interest, .001, 99, "Interest") ||

            !checkNumber(form.principal, 100, 10000000, "Principal")) {
            form.payment.value = "Invalid";
            return;
        }

        var i = form.interest.value;
        
        if (i > 1.0) {
            i = i / 100.0;
           // form.interest.value = i;
        }
        i /= 12;

        var pow = 1;
        for (var j = 0; j < form.payments.value; j++)
            pow = pow * (1 + i);
        form.payment.value = (form.principal.value * pow * i) / (pow - 1)
    }

    function clearForm(form) {
        form.payments.value = "";
        form.interest.value = "";
        form.principal.value = "";
		form.payment.value="";
    }

// flash Load function

function FlashLoad(flVersion, flName, flColor, flWidth, flHeight) {
var flCodeBase;

if (flVersion == '6')
flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0";
else if (flVersion == '7')
flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
else
flCodeBase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0";

document.writeln('<OBJECT ');
document.writeln('classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
document.writeln(' codebase=" ' + flCodeBase);
document.writeln(' ID="flash"');
document.writeln(' WIDTH=' + flWidth);
document.writeln(' HEIGHT=' + flHeight + '>');
document.writeln('<PARAM NAME=movie VALUE="' + flName + '">');
document.writeln('<PARAM NAME=quality VALUE=high>');
document.writeln('<PARAM NAME=wmode VALUE=transparent>');
document.writeln('<PARAM NAME=bgcolor VALUE=' + flColor + '>');
document.writeln('<EMBED src="' + flName + '"');
document.writeln(' name="flash"');
document.writeln(' wmode="transparent"');
document.writeln(' quality=high bgcolor=' + flColor);
document.writeln(' WIDTH=' + flWidth);
document.writeln(' HEIGHT=' + flHeight);
document.writeln(' TYPE="application/x-shockwave-flash"');
document.writeln(' PLUGINSPAGE="http://www.macromedia.com/shockwave/');
document.writeln('download/index.cgi?P1_Prod_Version=ShockwaveFlash">');
document.writeln('</EMBED></OBJECT>');

}



// mortgage calc



/***********************************************
* Contractible Headers script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use. Last updated Mar 23rd, 2004.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var enablepersist="on" //Enable saving state of content structure using session cookies? (on/off)
var collapseprevious="no" //Collapse previously open content when opening present? (yes/no)

if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{display:none;}')
document.write('</style>')
}

function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}

function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}

function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}

function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}

function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}

document.cookie=window.location.pathname+"="+selectedItem
}

function do_onload(){
uniqueidn=window.location.pathname+"firsttimeload"
getElementbyClass("switchcontent")
if (enablepersist=="on" && typeof ccollect!="undefined"){
document.cookie=(get_cookie(uniqueidn)=="")? uniqueidn+"=1" : uniqueidn+"=0"
firsttimeload=(get_cookie(uniqueidn)==1)? 1 : 0 //check if this is 1st page load
if (!firsttimeload)
revivecontent()
}
}


if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload

if (enablepersist=="on" && document.getElementById)
window.onunload=saveswitchstate
