function openMortgageCalculator() {
	window.open('MortgageCalculator.htm','','width=320,height=403');
}
function openMetricConverter() {
	window.open('MetricConv.htm','','width=295,height=290');
}
function openCurrencyConverter() {
	window.open('XE.htm','','width=600,height=150');
}
function searchForPlots() {
	document.forms[0].Type.value = 'Plot';
	document.forms[0].action = 'Search.php';
	document.forms[0].submit();
}

function searchForShops() {
	document.forms[0].Type.value = 'Shop';
	document.forms[0].action = 'Search.php';
	document.forms[0].submit();
}

function searchAreaPrice() {
	document.forms[0].action = 'SearchResults.php';
	document.forms[0].submit();	
}

function searchCode() {
	document.forms[0].action = 'SearchResults.php';
	document.forms[0].submit();
}

function login() {
	document.forms[0].action = 'MembersSection.php';
	document.forms[0].submit();
}

function insert_member() {
	document.forms[0].action = 'MemberInsert.php';
	if (validateMemberInsert()!='false') {
		document.forms[0].submit();
	}
}

function edit_member() {
	document.forms[0].action = '';
	if (validateMemberEdit()!='false') {
		document.forms[0].submit();
	}
}

function goToHotPropertyMore(x) {
	document.forms[0].action = 'SearchResultDetails.php';
	document.forms[0].where.value = " AND DevMlsID=0 AND Price>=171000 AND (Status='For Sale' OR Status=null)";
	document.forms[0].orderBy.value = ' ORDER BY Price ASC';
	document.forms[0].recNum.value = x;
	document.forms[0].submit();
}

function goToHotPropertyLess(x) {
	document.forms[0].action = 'SearchResultDetails.php';
	document.forms[0].where.value = " AND DevMlsID=0 AND Price<171000 AND (Status='For Sale' OR Status=null)";
	document.forms[0].orderBy.value = ' ORDER BY Price ASC';
	document.forms[0].recNum.value = x;
	document.forms[0].submit();
}

function validateMemberEdit() {

	x=document.forms[0];
	at=x.Email.value.indexOf("@");
	msg="";
	
	document.getElementById('OldPassword1').style.display='none';
	document.getElementById('NewPassword1').style.display='none';
	document.getElementById('ConfirmNewPassword1').style.display='none';
	document.getElementById('Email1').style.display='none';
	document.getElementById('Firstname1').style.display='none';
	document.getElementById('Lastname1').style.display='none';
		
	if (x.NewPassword.value.length>0) {
		if (x.OldPassword.value.length<1) {
			document.getElementById('OldPassword1').style.display='inline';
			msg+="Please supply Old Password!\n";
		}
		else {			
			if (x.ConfirmNewPassword.value!=x.NewPassword.value) {			
				document.getElementById('NewPassword1').style.display='inline';
				document.getElementById('ConfirmNewPassword1').style.display='inline';
				msg+="New Password & Confirm New Password do not match!\n";
			}
		}
	}
	
	if (at==-1) {
		document.getElementById('Email1').style.display='inline';
		msg+="Not a valid e-mail!\n";
	}
	 
	if (x.Firstname.value.length<1) {
		document.getElementById('Firstname1').style.display='inline';
		msg+="First name must be submitted!\n";
	}
	
	if (x.Lastname.value.length<1) {
		document.getElementById('Lastname1').style.display='inline';
		msg+="Last name must be submitted!\n";
	}
	
	if (msg!="") {
		alert(msg);
		return false; 
	}
}

function validateMemberInsert() {
	
	x=document.forms[0];
	at=x.Email.value.indexOf("@");
	msg="";
	
	document.getElementById('Username1').style.display='none';
	document.getElementById('Password1').style.display='none';
	document.getElementById('ConfirmPassword1').style.display='none';
	document.getElementById('Email1').style.display='none';
	document.getElementById('ConfirmEmail1').style.display='none';
	document.getElementById('Firstname1').style.display='none';
	document.getElementById('Lastname1').style.display='none';	
	
	if (x.Username.value.length<3) {
		document.getElementById('Username1').style.display='inline';
		msg+="Username must be at least 3 characters long!\n";
	}
	
	if (x.Password.value.length<6) {
		document.getElementById('Password1').style.display='inline';
		msg+="Password must be a least 6 characters long!\n";
	}
	else {
		if (x.Password.value!=x.ConfirmPassword.value) {
			document.getElementById('Password1').style.display='inline';
			document.getElementById('ConfirmPassword1').style.display='inline';			
			msg+="Password and Confirm Password do not match!\n";
		}
	}
	
	if (at==-1) {
		document.getElementById('Email1').style.display='inline';
		msg+="Not a valid e-mail!\n";
	}
	else {
		if (x.Email.value!=x.ConfirmEmail.value) {
			document.getElementById('Email1').style.display='inline';
			document.getElementById('ConfirmEmail1').style.display='inline';
			msg+="Email and Confirm Email do not match!\n";
		}
	}
	 
	if (x.Firstname.value.length<1) {
		document.getElementById('Firstname1').style.display='inline';
		msg+="First name must be submitted!\n";
	}
	
	if (x.Lastname.value.length<1) {
		document.getElementById('Lastname1').style.display='inline';
		msg+="Last name must be submitted!\n";
	}
	
	if (msg!="") {
		alert(msg);
		return false; 
	}
}

function popup_contact(devmlsid,code) { 
  win_photo=open("ShowContact.php?DevMlsID="+devmlsid+"&Code="+code,"photo","resizable=yes,width=250,height=230");
  win_photo.focus();
}

function popup_usernotes(notes) { 
  win_photo2=open("UserNotes.php?UserID="+notes,"usernotes","resizable=yes,width=450,height=230");
  win_photo2.focus();
}





//v1.0
//Copyright 2006 Adobe Systems, Inc. All rights reserved.
function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '<object ';
  for (var i in objAttrs)
    str += i + '="' + objAttrs[i] + '" ';
  str += '>';
  for (var i in params)
    str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  str += '<embed ';
  for (var i in embedAttrs)
    str += i + '="' + embedAttrs[i] + '" ';
  str += ' ></embed></object>';

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "id":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}