// JavaScript Document
// JavaScript Document

//previous signup page
/*function signup() //create a sign up window for new user .
	{
	win = new Window('dialog1', {className: "alphacube",  width:300, height:350, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win.getContent().innerHTML= "<div style='padding:10px; background-color:#CCCCCC; height:285px;'><div style='width: 260px;'><div style='float:right; margin-right:1em;'><a style='display: inline;' href='javascript:close_signup();'><img src='images/delete.png' border='none' /></a></div><p><strong><big><span >SIGN UP</span></big></strong><br><span >Already have an account?</span>&nbsp;<a style='display: inline;'  href='javascript:go_login();'>Log in</a></p><p><form ><span style='width: 70px; float: left;'><strong>Email:</strong></span><span style='float: left; width: 170px;'><input size='25'   style='width: 150px;' id='email' onKeyPress='checkEnter1(event)' type='text'></span><div style='float: left; clear: both; width: 250px;'>&nbsp;</div><span style='width: 70px;float: left;'><strong>Password:</strong></span><span style='float: left; width: 170px;'><input  size='15'  style='width: 150px;' id ='pass' onKeyPress='checkEnter1(event)' type='password'><br><span>5-15 characters</span></span><span style='width: 70px; float: left;'><strong>Re-type<br>password:</strong></span><span style='float: left; width: 170px;'><br/><input  size='15' style='width: 150px;' id ='repass' onKeyPress='checkEnter1(event)' type='password'></span><div style='clear: both; float: left; width: 250px;'>&nbsp;</div><span style='width: 70px; float: left;'>Name<br><span >(optional)</span>:</span><span style='width: 170px; float: left;'><input  size='25' id ='nam' style='width: 150px;' name='name' type='text' onKeyPress='checkEnter1(event)'></span><div style='clear: both; float: left;'>&nbsp;</div><div style='clear: both; float: left; width: 250px;'><div style='clear: both; float: left;'><span style='width: 70px; float: left;'>Location<br><span>(optional)</span>:</span><span style='width: 170px; float: left;'><input  size='25' style='width: 150px;' id ='loc' onKeyPress='checkEnter1(event)' type='text'><br><span>City &amp; State, or ZIP</span></span></div><div style='clear: both; float: left;'>&nbsp;</div><br/><br/><div style='clear: both; float: left;'>&nbsp;</div><div align='center'><br/><input type='button' value='Signup' onclick='validate_register();'/></div></form></div></div>";
	win.showCenter();
	win.setLocation(30, 690) // here location set 
	win.show();
	win.setDestroyOnClose();
	}*/

//modified by hitesh
function signup() //create a sign up window for new user .
	{
	win = new Window('dialog1', {className: "alphacube",  width:300, height:350, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win.getContent().innerHTML= "<div style='width: 120px; padding:5px; background-color:#CCCCCC; height:55px;'><div style='float:right; margin-right:.2em;'><a style='display: inline;' href='javascript:close_signup();'><img src='images/delete.png' border='none' /></a></div><p><strong><big><span >SIGN UP</span></big></strong><br><span >by Invitation only!</p></div>";
	//win.showCenter();
	win.setLocation(30, 690) // here location set 
	win.show();
	win.setDestroyOnClose();
	}
	
function login() //create a login window for existing user .
	{
	win1 = new Window('dialog2', {className: "alphacube",  width:275, height:200, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win1.getContent().innerHTML="<div style='padding-left:1em; padding-top:.5em; padding-right:1em; padding-bottom:.5em;background-color:#CCCCCC; height: 170px;'><div style='width: 260px;'><div style='float:right; margin-right:1em;'><a style='display: inline;' href='javascript:close_login();'><img src='images/delete.png' border='none' /></a></div><strong><big><span>LOG IN</span></big></strong><br><span>Don't have an account?</span>&nbsp;<a style='display: inline;' href='javascript:go_signup();'>Sign up</a></p><p>&nbsp;</p><div style='display: inline;'><div style='clear:both; float: left; width: 250px;'><div style='clear:both; float: left;'><span style='width: 70px; float: left;'><strong>Email:</strong></span><span style='width: 170px; float: left;'><input size='25' name='email'id='login_email_field' onKeyPress='checkEnter(event)' style='width:150px;' type='text'></span></div><div style='clear:both; float: left; width: 250px;'>&nbsp;</div></div><div style='clear:both; float: left;'><span style='width: 70px; float: left;'><strong>Password:</strong></span><span style='width: 170px; float: left;'><input  size='15' style='width: 150px;'  type='password' id='login_password_field' onKeyPress='checkEnter(event)'></span></div><div style='clear:both; float: left; width: 250px; height: 25px;'><span style='float: left; width: 100px;'></span><span style='clear:both; float: left; width: 42px;'>&nbsp;</span><span style='float: right; width: 95px; height: 25px;'><br/><input type='button'  value='Login' onclick='validate_login();'></span></div></div></div><div style='clear:both;'></div></div>";

	win1.setLocation(30, 700) // here location set 
	win1.show();
	win1.setDestroyOnClose();
	}
	
// when user directly clik to login without sign and clik signup from login window then go_signup//////////	
function go_signup()
{
	win1.destroy('dialog2');
	signup();
}
// end go_signup()  function///////////////////////

//close login window
function close_login()
{
	win1.destroy('dialog2');
}

//close signup window
function close_signup()
{
	win.destroy('dialog1');
}
// when user directly clik to signup but he is already registerd then clik log in  from signup window then go_login///
function go_login()
{
	win.destroy('dialog1');
	login();
}
// end go_login()  function///////////////////////

///////////////////////////////////////////start sign up ajax request//////////////////////////////////////////////
function sign()           // function use for show exist task after the document refresh.
	{
		var ef = xb_get_element('email').value;
		//var a = document.getElementById('email').value;
		var ff = xb_get_element('pass').value;
		//var b = document.getElementById('pass').value;
		var gf = xb_get_element('repass').value;
		//var c = document.getElementById('repass').value;
		var hf = xb_get_element('nam').value;
		//var d = document.getElementById('nam').value;
		var ifs = xb_get_element('loc').value;
		//var e = document.getElementById('loc').value;
		
		var url="check.php";
		url=url+"?rq="+11;
		url=url+"&em="+ef;
		url=url+"&pas="+ff;
		url=url+"&repas="+gf;
		url=url+"&name="+hf;
		url=url+"&location="+ifs;
		url=url+"&c="+Math.random();
		
		//alert("manish sign");
		stchange1(url); 
	}
	
	var xmlHttp;

function stchange1(url)
	{
	
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
			{
				alert ("Browser does not support HTTP Request")
				return
			} 
		xmlHttp.onreadystatechange=stateChanged ;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);

 
	}
	
function stateChanged() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ //alert("");
				var datanode = xmlHttp.responseText;  
				//xb_get_element('main_display').innerHTML=datanode;
				//window.location.reload(false);
				openInfoDialog();
				//alert("you are successfully Log in !");
				
				xb_get_element('signup').style.display="none";
				xb_get_element('logout').style.display="block";
	
				win.destroy('dialog1');
				
					
					
	
 			} 
	} 



function GetXmlHttpObject()
	{ 
		var objXMLHttp=null;
		if (window.XMLHttpRequest)
			{
			objXMLHttp=new XMLHttpRequest()
			}
		else if (window.ActiveXObject)
				{
					objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
				}
		return objXMLHttp;
	} 

/////////////////////////////////////////////////end sign up ajax request///////////////////////////////////


// below three variable r using to define  the email validation states.
var EMAIL_OK = 0;
var EMAIL_BLANK = 1;
var EMAIL_BAD_SYNTAX = 2;

// function for all browser to get element by Id
function xb_get_element(id)
{
  var el = document.all ? document.all[id] : document.getElementById(id);
  if (el)
    return el;
  else
    return null;
}

// this function check the space through the regular expression if yes then replace and return.
function trim(s)
{
  if (!s)
    return '';
  return s.replace(/^\s*|\s*$/g,"");
}

// this function check the email validation.
function is_valid_email(e)
{
  e = trim(e).toLowerCase();
  if (e == '')
    return EMAIL_BLANK;
  regex = /^\s*[a-z0-9-+\_\.]+@[a-z0-9-_\.]+\.[a-z]{2,4}\s*$/;
  if(!regex.test(e))
    return EMAIL_BAD_SYNTAX;
  return EMAIL_OK;
}


// start signup validation////////////////////////////////////////////////////////////////
function validate_register()
{ 

  var reg_email = trim(xb_get_element('email').value).toLowerCase();
  var reg_password = xb_get_element('pass').value;
  var reg_password_verify = xb_get_element('repass').value;
  var reg_name = trim(xb_get_element('nam').value);
  var reg_location = trim(xb_get_element('loc').value);
  var validate_error_message = '';
  var reg_errors = new Array();
  var field_to_focus = '';
  
  if (is_valid_email(reg_email) == EMAIL_BAD_SYNTAX)
  {
    reg_errors.push('Please enter a valid email address, such as name@domain.com.');
    field_to_focus = 'email';
  }
  else
  {
    if (reg_email == '')
    {
      reg_errors.push('Please enter an email address.');
      field_to_focus = 'email';
    }
  }
  if (reg_password == '')
  {
    reg_errors.push('Please enter a password.');
    if (field_to_focus == '')
      field_to_focus = 'pass';
  }
  if (reg_password_verify == '')
  {
    reg_errors.push('Please enter your password again for verification.');
    if (field_to_focus == '')
      field_to_focus = 'repass';
  }
  rgl = reg_password.length;
  rglv = reg_password_verify.length;
  if (reg_password != '' && reg_password_verify != '' && reg_password != reg_password_verify)
  {
    reg_errors.push('The passwords you entered do not match.');
    if (field_to_focus == '')
      field_to_focus = 'pass';
  }
  else
  {
    if (rgl > 0 && (rgl < 5 || rgl > 15) || (rglv > 0 && (rglv < 5 || rglv > 15)))
    { 
      reg_errors.push('Your password should be between 5 and 15 characters.');
      if (field_to_focus == '')
        field_to_focus = 'pass';
    }
  }
  if (  reg_password != '' && reg_password_verify != '' &&
        (reg_password.toLowerCase() == reg_email.toLowerCase() ||
        reg_password.toLowerCase() == reg_email.toLowerCase().substring(0, reg_email.indexOf('@'))) )
  {
    reg_errors.push('Your password is too easy to guess. Please try a different one.');
    if (field_to_focus == '')
      field_to_focus = 'pass';
  }
  if (reg_errors.length > 0)
  {
    for (i = 0; i < reg_errors.length; ++i)
      validate_error_message += reg_errors[i] + '\n';
    alert(validate_error_message);
    if (field_to_focus != '' && (ff = document.getElementById(field_to_focus)))
      ff.focus();
    return false;
  }
  else
    sign();
}

////////////////////////////////////////////end signup validation////////////////////////////////////////

///////////// validates login form/////////////////////////////////////////////////////////////////////////////////////
function validate_login()
{
  
  var email = trim(xb_get_element('login_email_field').value).toLowerCase();
  var password = xb_get_element('login_password_field').value;
  var validate_error_message = '';
  var errors = new Array();
  var field_to_focus = '';
  
  // blank or malformed fields
  if (is_valid_email(email) == EMAIL_BAD_SYNTAX)
  {
    errors.push('Please enter a valid email address, such as name@domain.com.');
    field_to_focus = 'login_email_field';
  }
  else
  {
    if (email == '')
    {
      errors.push('Please enter an email address.');
      field_to_focus = 'login_email_field';
    }
  }
  if (password == '')
  {
    errors.push('Please enter a password.');
    if (field_to_focus == '')
      field_to_focus = 'login_password_field';
  }
  if (errors.length > 0)
  {
    for (i = 0; i < errors.length; ++i)
      validate_error_message += errors[i] + '\n';
    alert(validate_error_message);
    if (field_to_focus != '' && (ff = document.getElementById(field_to_focus)))
      ff.focus();
    return false;
  }
  else
    login_dt();  
}

///////////////////////////////////////end validation login form//////////////////////////////////////

// ajax request 2 for logout ./////////////////////////////////////////////////////////////

function logout()           // function use for show exist task after the document refresh.
{
	//alert("now logout request and session destroy");
	var url="check.php";
	url=url+"?rq="+2;
	url=url+"&c="+Math.random();
	logsou(url); 
}

var xmlHttp1;

function logsou(url)
{
	
	xmlHttp1=GetXmlHttpObject();
	if (xmlHttp1==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp1.onreadystatechange=stateChanged1 ;
	xmlHttp1.open("GET",url,true);
	xmlHttp1.send(null);

 
}
	function stateChanged1() 
		{ 
			if (xmlHttp1.readyState==4 || xmlHttp1.readyState=="complete")
				{ //alert("");
					var datanode = xmlHttp1.responseText;  
					xb_get_element('signup').innerHTML=datanode;
					//window.location.reload(false);
					
					xb_get_element('signup').style.display="block";
					xb_get_element('logout').style.display="none";
					xb_get_element('myfevdata').style.display="none";
							openInfoDialog();
						win.destroy('dialog1');
				} 
		} 

/////////////////////////end logout form//////////////////////////////////
/////////////////////////start login form//////////////////////////////////

function login_dt()
{
	
 var p_email = trim(xb_get_element('login_email_field').value).toLowerCase();
  var p_password = xb_get_element('login_password_field').value;
var url="check.php";
	url=url+"?rq="+3;
	url=url+"&emil="+encodeURIComponent(p_email);
	url=url+"&pass="+p_password;
	url=url+"&c="+Math.random();
	login_dt_ajax(url);

}
var xmlHttp2;

function login_dt_ajax(url)
{
	//alert(url);
	xmlHttp2=GetXmlHttpObject();
	if (xmlHttp2==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp2.onreadystatechange=stateChanged2 ;
	xmlHttp2.open("GET",url,true);
	xmlHttp2.send(null);

 
}

function stateChanged2() 
		{ 
			if (xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
				{ //alert("");
					var datanode = xmlHttp2.responseText;  
					//alert(datanode);
					
					if(datanode==0)
					{
					xb_get_element('signup').style.display="block";
					xb_get_element('logout').style.display="none";
					alert("email and password are not match please try again! ");
					}
					else
					{
					
					
					xb_get_element('signup').style.display="none";
					xb_get_element('logout').style.display="block";
					alert("iam login after");
					//xb_get_element('main_display').style.display="block";
					//xb_get_element('main_display').innerHTML=datanode;
					openInfoDialog();
					win1.destroy('dialog2');
					
					//mylikedata();
					
					//alert("you are successfully Log in !");
					}

						//win1.destroy('dialog2');
						//myfavorite(datanode);
						
				} 
		} 

///////////////////////////////////////////////////////end login form///////////////////////

///////////////////////////////////start to check the user is exist or not//////////////////////////////////////

function chek()
{
	
	var url="check.php";
	url=url+"?rq="+14;
	url=url+"&c="+Math.random();
	chek_ajax(url);
}
	
var xmlHttp3;

function chek_ajax(url)
{
	
	xmlHttp3=GetXmlHttpObject();
	if (xmlHttp3==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp3.onreadystatechange=stateChanged3 ;
	xmlHttp3.open("GET",url,true);
	xmlHttp3.send(null);

 
}

function stateChanged3() 
		{ 
			if (xmlHttp3.readyState==4 || xmlHttp3.readyState=="complete")
				{ 
					var datanode = xmlHttp3.responseText;  
					
					if(datanode==0)
					{
						xb_get_element('signup').style.display="block";
						xb_get_element('logout').style.display="none";
						
						login();
					}
					else
					{
						//alert(datanode);
						myfav_fetch(datanode);
					}
					
					
					
				} 
		} 
// end the  check the user existant/////////////////////////////////////////////////////
////check the session the exist or not////////////////////////////////////////////////

function check_session()
{
	//alert("mmmlkj");
	var url="check.php";
	url=url+"?rq="+5;
	url=url+"&c="+Math.random();
	chek_sess(url);
}
	
var xmlHttp4;

function chek_sess(url)
{
	//alert(url);
	xmlHttp4=GetXmlHttpObject();
	if (xmlHttp4==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp4.onreadystatechange=stateChanged4 ;
	xmlHttp4.open("GET",url,true);
	xmlHttp4.send(null);

 
}

function stateChanged4() 
		{ 
			if (xmlHttp4.readyState==4 || xmlHttp4.readyState=="complete")
				{ //alert("");
					var datanode = xmlHttp4.responseText;  
					//alert(datanode);
					
					if(datanode==0)
					{
						xb_get_element('signup').style.display="block";
						xb_get_element('logout').style.display="none"
						
					}
					else
					{
						xb_get_element('signup').style.display="none";
						xb_get_element('logout').style.display="block"
						//mylikedata();
					
					}
					
					
						
				} 
		} 


////// end of the check seesion function here///////////////////////
///// save data according to user login  ////////////////////////////////////////


function save_data(markerid)
{
	
	
	//alert(markerid);
	var url="check.php";
	url=url+"?rq="+6;
	url=url+"&markid="+markerid;
	url=url+"&c="+Math.random();
	save_data_ajax(url);
}
var xmlHttp5;

function save_data_ajax(url)
{
	//alert(url);
	xmlHttp5=GetXmlHttpObject();
	if (xmlHttp5==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp5.onreadystatechange=stateChanged5 ;
	xmlHttp5.open("GET",url,true);
	xmlHttp5.send(null);

 
}

function stateChanged5() 

		{
			
			if (xmlHttp5.readyState==4 || xmlHttp5.readyState=="complete")
				{ 
					var datanode = xmlHttp5.responseText;  
					//alert(datanode);
					
					if(datanode==0)
					{
						//alert("Please Log in then save"); 
						login();
						
					}
					else
					{
						openInfoDialog();
						//alert("save Property");
					//mylikedata();
						
						
					
					}
					
					
						
				} 
		} 

////////////////////////////////save function end here//////////////////////////////////
//////////////////////////////////myfav window is calling/////////////////////////////

/*function myfav(datanode)
{
	
	
	win2 = new Window('dialog3', {className: "alphacube",  width:175, height:100, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win2.getContent().innerHTML="<div style='padding:10px;'></div>";

		win2.setLocation(30, 700) // here location set 
	win2.show();
	win2.setDestroyOnClose();
	}*/


///////////////////////////////////end the myfav window is calling end here//////////////////////////////////////        	

//////////////////////////////////start to fetch data for my favriot//////////////////////////////

function myfav_fetch(datanode)
{
	//alert(datanode);
	var url="check.php";
	url=url+"?rq="+7;
	url=url+"&markid="+datanode;
	url=url+"&c="+Math.random();
	myfav_fetch_ajax(url);
	
}
var xmlHttp6;

function myfav_fetch_ajax(url)
{
	//alert(url);
	xmlHttp6=GetXmlHttpObject();
	if (xmlHttp6==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp6.onreadystatechange=stateChanged6 ;
	xmlHttp6.open("GET",url,true);
	xmlHttp6.send(null);

 
}

function stateChanged6() 

		{
			
			if (xmlHttp6.readyState==4 || xmlHttp6.readyState=="complete")
				{ 
					var xmlDoc1 = xmlHttp6.responseXML;  
					//alert(xmlDoc);
					openInfoDialog1();
					
					
					
					var data1 = xmlDoc1.getElementsByTagName("data");
								
							//	alert(data1.length+"  default");
								
								
								var mid = xmlDoc1.getElementsByTagName("mid");
	    	    				var comp = xmlDoc1.getElementsByTagName("comp");
								var title = xmlDoc1.getElementsByTagName("title");
		   						var desc = xmlDoc1.getElementsByTagName("desc");
							
								var price = xmlDoc1.getElementsByTagName("price");
								var bed = xmlDoc1.getElementsByTagName("bed");
		   						var bath = xmlDoc1.getElementsByTagName("bath");
								var garj = xmlDoc1.getElementsByTagName("garj");
		   						var img = xmlDoc1.getElementsByTagName("img");
								//var types = xmlDoc1.getElementsByTagName("types");
		   					//	var imga = xmlDoc1.getElementsByTagName("img1");
		   					//	var imgb = xmlDoc1.getElementsByTagName("img2");
		   					
								var lat = xmlDoc1.getElementsByTagName("lat");
		   						var lng = xmlDoc1.getElementsByTagName("lng");
								
								var j=1;
								side_bar_html ="";
								side_bar_html += "<table id='tab' width='100%'><tr><td>";
	  								for (var i = 0; i < data1.length; i++) 
									
										{
											mid1=String(mid[i].firstChild.nodeValue);
											comp1=parseInt(comp[i].firstChild.nodeValue);
											title1=String(title[i].firstChild.nodeValue);
											desc1= String(desc[i].firstChild.nodeValue); 
											desc1=desc1.substr(0,60);
											desc1=desc1+'...';
										
											price1= String(price[i].firstChild.nodeValue);
											//pricel= parseInt(price[i].firstChild.nodeValue); 
											bed1= parseInt(bed[i].firstChild.nodeValue); 
											bath1= parseInt(bath[i].firstChild.nodeValue); 
											garj1= parseInt(garj[i].firstChild.nodeValue);
											img1= String(img[i].firstChild.nodeValue); 
											//types1= String(types[i].firstChild.nodeValue);
											
										//	imgaa= String(imga[i].firstChild.nodeValue); 
											
										//	imgbb= String(imgb[i].firstChild.nodeValue); 
											
											lat1= String(lat[i].firstChild.nodeValue); 
											lng1= String(lng[i].firstChild.nodeValue); 
											
							
											var point = new GLatLng(lat1,lng1);
     										
											
												var info=fun(j,title1,desc1,types1,img1,price1,bed1,bath1,garj1,mid1,comp1);	  	
												
									side_bar_html +='<div id="container" onClick="javascript:myclick(' + (i+1) + '); zooms();" onMouseOver="style.backgroundColor=\'#D5F1FF\'; style.cursor=\'pointer\'; mymouseover('+(i+1)+')" onMouseOut="style.backgroundColor=\'#FFFFFF\'; mymouseout('+(i+1)+')"><b class="top"><b class="b1"></b><b class="b2"></b><b class="b3"></b><b class="b4"></b></b><dl id="gallery"><div><table  width="100%" border="0" cellspacing="0" cellpadding="3"><tr>   <td width="50" rowspan="2" valign="top"><img src="'+img1+'" alt="click the image" width="75" height="60" hspace="5" vspace="5" class="imgborder" /></td><td width="20" valign="top" class="dsc"><span class="no">'+ (i+1) +'.</span></td><td width="180" class="dsc">'+ title1 +  '<br /><span class="descs">'+desc1+'</span></td><td valign="bottom" colspan="3" class="dsc"><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td valign="top" class="Save"></td><td valign="top" class="Save"><div align="right"><a href="javascript:send_email(\''+mid1+'\')" >Send to Friends </a></div></td></tr>    <tr><td  class="dsc">$ '+ price1 +'</td></tr></table></td></tr><tr>   <td >&nbsp;</td><td >'+ bed1 +' beds, '+ bath1 +' baths,'+ garj1 +' Garage</td><td  class="unitApt">'+types1+'</td><td><div><img src="images/favorites.gif" width="18" height="18"></div></td><td class="remove"><a href="javascript:myfavorite_remv(\''+mid1+'\')" >Remove</a></td></tr></table></div></dl><b class="b4"></b><b class="b3"></b><b class="b2"></b><b class="b1"></b></div>';
											
											
											var icon1 = createIcon("icons/"+j+".gif");
										 v=createInfoMarker(point,info,j,icon1);
										
											map.addOverlay(v);
											 
        								j++;
										} 
						
									side_bar_html += '</td></tr></table>'; 
									map.setCenter(new GLatLng(-26.396175, 135.1419), 4);
										document.getElementById("tab").style.display ='block'; 
									document.getElementById("tabs").style.display ='none'; 
								
									document.getElementById("tab").innerHTML = side_bar_html; 	
								
				 }
					
					
	
 			} 
								
								
								
								
								
								
								
								
								
								/*var data1 = xmlDoc.getElementsByTagName("data");
								var mid = xmlDoc.getElementsByTagName("mid");
	    	    				var title = xmlDoc.getElementsByTagName("title");
		   						//var desc = xmlDoc.getElementsByTagName("description");
								var price = xmlDoc.getElementsByTagName("price");
								var bed = xmlDoc.getElementsByTagName("bed");
		   						var bath = xmlDoc.getElementsByTagName("bath");
		   						var img = xmlDoc.getElementsByTagName("img");
		   						var imga = xmlDoc.getElementsByTagName("img1");
		   						var imgb = xmlDoc.getElementsByTagName("img2");
		   						var lat = xmlDoc.getElementsByTagName("lat");
		   						var lng = xmlDoc.getElementsByTagName("lng");
								//alert(data1.length);
								var icon1 = createIcon("images/red-house.png");
									var j=1;
								side_bar_html ="";
								side_bar_html += "<table id='tab' width='100%'><tr><td>";
								for (var i = 0; i < data1.length; i++) 
									
										{
											mid1=String(mid[i].firstChild.nodeValue);
											
											title1=String(title[i].firstChild.nodeValue);
											//desc1= String(desc[i].firstChild.nodeValue); 
											price1= parseInt(price[i].firstChild.nodeValue);
											//pricel= parseInt(price[i].firstChild.nodeValue); 
											bed1= parseInt(bed[i].firstChild.nodeValue); 
											bath1= parseInt(bath[i].firstChild.nodeValue); 
											img1= String(img[i].firstChild.nodeValue); 
											
											imgaa= String(imga[i].firstChild.nodeValue); 
											
											imgbb= String(imgb[i].firstChild.nodeValue); 
											
											lat1= String(lat[i].firstChild.nodeValue); 
											lng1= String(lng[i].firstChild.nodeValue); 
											
											var point = new GLatLng(lat1,lng1);
     										
											//bounds.extend(point);
											
											//map.setCenter(point,7);
										var info=fun(j,title1,img1,price1,bed1,bath1);	  	
												//var info1=fun1(img1);//posin//	
											
											side_bar_html +='<div ><table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="12" height="10"  align="right" valign="top"><img src="images/g_tl2.gif" alt="tl" width="12" height="11" /></td>    <td  class="topGrad"></td><td width="12" height="10" align="right"><img src="images/g_tr2.gif" alt="tr" width="12" height="11" /></td></tr><tr><td width="12" valign="middle" class="g_l"></td><td valign="middle"><div><table width="100%" border="0" cellspacing="0" cellpadding="3" ><tr><td width="3%" rowspan="2" class="dsc"><a href="javascript:myclick(' + (i+1) + ')" onMouseOver="mymouseover('+(i+1)+')" onMouseOut="mymouseout('+(i+1)+')">'+ (i+1) + '</a></td><td width="50" rowspan="2"><a href="javascript:myclick(' + (i+1) + ')"><img src='+ img1 +' width="75" height="60" hspace="5" vspace="5" class="imgborder" /></a></td><td  class="dsc" width="210"><a href="javascript:myclick(' + (i+1) + ')">'+ title1 + '</a></td><td valign="bottom"  class="dsc"><table width="100%" border="0" cellspacing="0" cellpadding="2"><tr><td valign="top" class="Save">&nbsp;</td><td align="right" valign="top" class="Save"><a href="javascript:send_email(\''+mid1+'\')" >Send to Friends </a></td></tr>  <tr><td colspan="2" class="dsc"><a href="javascript:myclick(' + (i+1) + ')">$'+ price1 +'</a></td></tr></table></td></tr><tr><td >'+ bed1 +' beds, '+ bath1 +' baths, Garage, pool etcHouse</td><td class="unitApt"><table width="100%" border="0" cellspacing="1" cellpadding="1"><tr><td class="unitApt" >Unit/Appt.</td><td><div><img src="images/favorites.gif" width="18" height="18"></div></td><td class="remove"><a href="javascript:myfavorite_remv(\''+mid1+'\')" >Remove</a></td><tr></table></td></tr></table></div></td><td width="12" valign="middle" class="g_r" ></td></tr><tr><td width="12" height="11" align="left"><img src="images/g_bl2.gif" alt="glb" width="12" height="11" /></td><td height="11" align="center" valign="bottom" class="g_b"></td><td width="12" height="11" align="right"><img src="images/g_br2.gif" alt="grb" width="12" height="11" /></td></tr></table></div>';
										
											
											 //v=createTabbedMarker(point,info,info1,"Details","Images",j,icon1);
											map.addOverlay(v);
											 //table += '<a href="javascript:myclick(' + i + ')">' + mark + '</a><br>';
        								j++;
										} 
						//document.getElementById("main").innerHTML = "";
									side_bar_html += '</td></tr></table>'; 
									map.setCenter(new GLatLng(-26.396175, 135.1419), 4);
										document.getElementById("tab").style.display ='block'; 
									document.getElementById("tabs").style.display ='none'; 
								
									document.getElementById("tab").innerHTML = side_bar_html; 	*/
								
				 
				//} 
							
					
			//}
								
								
///////////////////////////////////////my_fetch function end here////////////////////////////////////////////////								
////////////////////////////////////processing window here//////////////////////////////////////////////////////

var timeout;
	function openInfoDialog() {
		Dialog.info(" Searching Please wait .....",
				        {windowParameters: {className: "alert_lite",width:250, height:70}, showProgress: true});
		timeout=1;
		setTimeout("infoTimeout()", 1000)
	}
	
	function infoTimeout() {
	  timeout--;
	  if (timeout >0) {
	    Dialog.setInfoMessage(" Searching Please wait ...")
  		setTimeout("infoTimeout()", 1000)
    }
	  else
	    Dialog.closeInfo()
	}



///////////////////////////////////////processing window end here////////////////////////////////////////////
////////////////////////////////////////Send email to friend////////////////////////////////////////////////

function send_email(markid)  // from search.php div///
{
	//alert(markid);
	var url="check.php";
	url=url+"?rq="+9;
	url=url+"&makid="+markid;
	send_email_check(url);
}
var xmlHttp8;

function send_email_check(url)
{
	//alert(url);
	xmlHttp8=GetXmlHttpObject();
	if (xmlHttp8==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp8.onreadystatechange=stateChanged8 ;
	xmlHttp8.open("GET",url,true);
	xmlHttp8.send(null);

 
}

function stateChanged8() 

		{
			
			if (xmlHttp8.readyState==4 || xmlHttp8.readyState=="complete")
				{ 
					var datanode = xmlHttp8.responseText; 
					
					if(datanode==0)
					{
						//alert("Please Log in then mail"); 
						login();
						
					}
					else
					{
						var markid = datanode;
						
						//alert(markid);
	win3 = new Window('dialog4', {className: "alphacube",  width:290, height:240, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win3.getContent().innerHTML="<div style='padding:10px;'><div style='background-color:#FFFFFF;'><table width='280' border='0' align='center' cellpadding='8' cellspacing='0' bgcolor='#FFFFFF' ><tr><td class='heading'>Send this property to a friend!</td></tr><tr><td colspan='2'><table width='100%' border='0' cellspacing='1' cellpadding='2'><tr><td width='19%'>Friend's email:</td><td width='81%'><input name='textfield' id='fmail' type='text' class='text' ></td></tr><tr><td valign='top'>Message(optional):</td><td><textarea name='textarea' cols='15' id='msgtxt' class='textarea'></textarea></td></tr><br/><tr><td valign='top'>&nbsp;</td><td><input name='Submit' type='button' class='btn' onclick='send_destry();' value='CANCEL'> <input name='Submit2' type='button' onclick='validate_mail(\""+markid+"\");' class='btnsend' value='SEND'></td> </tr></table></td></tr> <tr> <td colspan='2'>&nbsp;</td></tr></table></div></div>";
win3.setLocation(200, 500) // here location set 
	win3.show();
	win3.setDestroyOnClose();
					}
	
			}
		}//send_email_ajax(\""+markid+"\")
////////////////////////////////////////////End send email to friend here//////////////////////////////////////////					
//// start email window cancel button function ////////////////////////////////////////////////////////////////////					
function send_destry()
{
	
	win3.destroy('dialog4');
	
}
//// end email window cancel button function//////////////////////////

///////////////////////////////////start send email to a freind on send button onclick event function///////////////////

function send_email_ajax(markids)
{
	//alert(markids);
	var fmails =xb_get_element('fmail').value;
	var msgtxts =xb_get_element('msgtxt').value;
	//alert(fmails);
	//alert(msgtxts);
	var url="check.php";
	url=url+"?rq="+8;
	url=url+"&mrid="+markids;
	url=url+"&femail="+fmails;
	url=url+"&addmsg="+msgtxts;
	url=url+"&c="+Math.random();
	send_email_ajax_requs(url);
}
var xmlHttp7;

function send_email_ajax_requs(url)
{
	//alert(url);
	xmlHttp7=GetXmlHttpObject();
	if (xmlHttp7==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp7.onreadystatechange=stateChanged7 ;
	xmlHttp7.open("GET",url,true);
	xmlHttp7.send(null);

 
}

function stateChanged7() 

		{
			
			if (xmlHttp7.readyState==4 || xmlHttp7.readyState=="complete")
				{ 
					var datanode = xmlHttp7.responseText; 
					
					
					//alert(datanode);
						openInfoDialog();
						//alert("save Property");
					win3.destroy('dialog4');
					
					
					
					
					

				}
		}
		
///////////////////////////////	End send email to a freind on send button onclick event function///////////////////////	
	////////////////////////// start my favriot loding images function ////////////////////////////////////
	
	var timeout1;
	function openInfoDialog1() {
		Dialog.info("Please wait Loding your Favorit.....",
				        {windowParameters: {className: "alert_lite",width:250, height:70}, showProgress: true});
		timeout1=2;
		setTimeout("infoTimeout1()", 1000)
	}
	
	function infoTimeout1() {
	  timeout1--;
	  if (timeout1 >0) {
	    Dialog.setInfoMessage("Please wait Loding your Favorit.....")
  		setTimeout("infoTimeout1()", 1000)
    }
	  else
	    Dialog.closeInfo()
	}
	/////////////////////////my favriot loding images  function end here///////////////////////////////////////////
	/////////////////////////////if enter key is press login window////////////////////////////////////////////////
	
	function checkEnter(e)    			//e is event object passed from function invocation
{ 
	var characterCode; 				//literal character code will be stored in this variable
	if(e && e.which)
	{ 								//if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which ;	//character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; 	//character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{ 								//if generated character code is equal to enter key then function call for add new div.
		 
		validate_login();
	}
	else
	{
		return true
	}

}

/////////////////////////////End login window( press enter key here)//////////////////////////

///////////////////////////////check enter event for signup window/////////////////////////////

function checkEnter1(e)    			//e is event object passed from function invocation
{ 
	var characterCode; 				//literal character code will be stored in this variable
	if(e && e.which)
	{ 								//if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which ;	//character code is contained in NN4's which property
	}
	else
	{
		e = event;
		characterCode = e.keyCode; 	//character code is contained in IE's keyCode property
	}

	if(characterCode == 13)
	{ 								//if generated character code is equal to enter key then function call for add new div.
		 
		validate_register();
	}
	else
	{
		return true
	}

}

/////////////////////////////////////////end function for signup window here(press enter)///////////////////////////////
///// remove from myfavorie function start here//////////////////////////////////
function myfavorite_remv(remvid)
{
	
var url="check.php";
	url=url+"?rq="+10;
	url=url+"&remid="+remvid;
	myfavorite_remv_ajax(url);
}
var xmlHttp9;

function myfavorite_remv_ajax(url)
{
	//alert(url);
	xmlHttp9=GetXmlHttpObject();
	if (xmlHttp9==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	xmlHttp9.onreadystatechange=stateChanged9 ;
	xmlHttp9.open("GET",url,true);
	xmlHttp9.send(null);

 
}

function stateChanged9() 

		{
			
			if (xmlHttp9.readyState==4 || xmlHttp9.readyState=="complete")
				{ 
					var datanode = xmlHttp9.responseText;
					//alert(datanode);
					//openInfoDialog();
					myfav_fetch();
				}
		}
					






//// end remove from myfavorite function here///////////////////////////////////



///  mail from index.php top link////////////////////////////////
function sendmail()
{
	//alert("");
var url="check.php";
	url=url+"?rq="+101;
	
	sendmail_ajax(url);
}
var sendmail_xmlHttp;

function sendmail_ajax(url)
{
	//alert(url);
	sendmail_xmlHttp=GetXmlHttpObject();
	if (sendmail_xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	sendmail_xmlHttp.onreadystatechange=sendmail_stateChanged ;
	sendmail_xmlHttp.open("GET",url,true);
	sendmail_xmlHttp.send(null);

 
}

function sendmail_stateChanged() 

		{
			
			if (sendmail_xmlHttp.readyState==4 || sendmail_xmlHttp.readyState=="complete")
				{ 
					var datanode = sendmail_xmlHttp.responseText;
					//alert(datanode);
					
					if(datanode==0)
					{
						//alert("Please Log in then mail"); 
						login();
						
					}
					else
					{
						
						
						var mail_id =1;
	win4 = new Window('dialog5', {className: "alphacube",  width:290, height:240, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win4.getContent().innerHTML="<div style='padding:10px;'><div style='background-color:#FFFFFF;'><table width='280' border='0' align='center' cellpadding='8' cellspacing='0' bgcolor='#FFFFFF' ><tr><td class='heading'>Send this property to a friend!</td></tr><tr><td colspan='2'><table width='100%' border='0' cellspacing='1' cellpadding='2'><tr><td width='19%'>Friend's email:</td><td width='81%'><input name='textfield' id='fmail' type='text' class='text' ></td></tr><tr><td valign='top'>Message(optional):</td><td><textarea name='textarea' cols='15' id='msgtxt' class='textarea'></textarea></td></tr><br/><tr><td valign='top'>&nbsp;</td><td><input name='Submit' type='button' class='btn' onclick='sendm_destry();' value='CANCEL'> <input name='Submit2' type='button' onclick='validate_mail("+mail_id+");' class='btnsend' value='SEND'></td> </tr></table></td></tr> <tr> <td colspan='2'>&nbsp;</td></tr></table></div></div>";
win4.setLocation(140, 670) // here location set 
	win4.show();
	win4.setDestroyOnClose();
					}
			}
		}
///////////////////////////end send mail function from index.php///////////////////////////////////////////

function sendmail_ajax_next()

{
var fmails =xb_get_element('fmail').value;
var msgtxts =xb_get_element('msgtxt').value;
var suburb =xb_get_element('country').value;

var minprice =xb_get_element('value_display_4').value;
var finalmin=(minprice*1000);
var maxprice =xb_get_element('value_display_1').value;
var finalmax=(maxprice*1000);
var beds =xb_get_element('value_display_2').value;
var baths =xb_get_element('value_display_3').value;
var garage =xb_get_element('value_display_5').value;

//alert(fmails);
//alert(msgtxts);
//alert(suburb);

//alert(finalmin);
//alert(finalmax);
//alert(beds);
//alert(baths);
//alert(garage);
var url="check.php";
	url=url+"?rq="+102;
	url=url+"&femail="+fmails;
	url=url+"&addmsg="+msgtxts;
	url=url+"&mipri="+finalmin;
	url=url+"&maxpri="+finalmax;
	url=url+"&fbeds="+beds;
	url=url+"&fbaths="+baths;
	url=url+"&fgarage="+garage;
	url=url+"&c="+Math.random();
sendmail_ajax_next_ajax(url);

}
var sendm_xmlhttp;
function sendmail_ajax_next_ajax(url)
{
	sendm_xmlhttp=GetXmlHttpObject();
	if (sendm_xmlhttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	sendm_xmlhttp.onreadystatechange=sendm_stateChanged ;
	sendm_xmlhttp.open("GET",url,true);
	sendm_xmlhttp.send(null);

 

}
function sendm_stateChanged()
{
if (sendm_xmlhttp.readyState==4 || sendm_xmlhttp.readyState=="complete")
				{ 
					var datanode = sendm_xmlhttp.responseText;
					//alert(datanode);
					openInfoDialog();
						//alert("save Property");
					win4.destroy('dialog5');
					
				}
	
}
///////////////////////////end send email fuction from index.php///////////////////////////////	
function sendm_destry()
{
	
	win4.destroy('dialog5');
	
}
///////////////////////////////////////////above function for destroy mail window from index.php////////////////////


/////////////////////////////////validate mail /////////////////////////////////////////

function validate_mail(mailid)
{
  var mails = mailid;
  var email = trim(xb_get_element('fmail').value).toLowerCase();
 
  var validate_error_message = '';
  var errors = new Array();
  var field_to_focus = '';
  
  // blank or malformed fields
  if (is_valid_email(email) == EMAIL_BAD_SYNTAX)
  {
    errors.push('Please enter a valid email address, such as name@domain.com.');
    field_to_focus = 'login_email_field';
  }
  else
  {
    if (email == '')
    {
      errors.push('Please enter an email address.');
      field_to_focus = 'login_email_field';
    }
  }
  
  if (errors.length > 0)
  {
    for (i = 0; i < errors.length; ++i)
      validate_error_message += errors[i] + '\n';
    alert(validate_error_message);
    if (field_to_focus != '' && (ff = document.getElementById(field_to_focus)))
      ff.focus();
    return false;
  }
  else
  if (mails==1)
  {
  	sendmail_ajax_next(); 
  }
  else
  {
	  //alert("div mail ");
	  send_email_ajax(mails);
  }
}
////////////////////////////////////////////validate mail here//////////////////////////////

// how to funcion here...onmouseup............./////////////////////////////

function howtoup()
{
//alert("onmouseup");

win11 = new Window('dialog11', {className: "alphacube",  width:300, height:180, zIndex: 100, resizable: false,minimizable: false,maximizable: false, title: "", draggable:false})
	win11.getContent().innerHTML= "<div style='padding:10px; background-color:#CCCCCC;'><table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\"><tr><td class=\"step\">Easy Steps </td></tr><tr><td class=\"point\">1. Type City or Postcode in to box </td></tr><tr><td class=\"point\">2. Use Filter to tick boxes or slider arrow to change the property type, value,bed &amp; baths </td></tr><tr><td class=\"point\">3. Number in the property list on left matches the location of property on map</td></tr><tr><td class=\"point\">4. Click property on left or pin on map and porperty info will appear </td></tr><tr><td class=\"point\"></td></tr></table></div>";
	win11.setLocation(30, 550) // here location set 
	win11.show();
	win11.setDestroyOnClose();
}

// howto function..............onmouseout/////////////////////

function howtoout()
{
//alert("ommousrout");

win11.destroy('dialog11');

}

// function for update save data to show on the left side div on indexpage myfevdata////////////////////////////////

/*function mylikedata()
{
var url="check.php";
	url=url+"?rq="+103;
	url=url+"&c="+Math.random();
mylikedata_ajax(url);
alert(url);
}

var mylikedata_xmlhttp;

function mylikedata_ajax(url)
{
	mylikedata_xmlhttp=GetXmlHttpObject();
	if (mylikedata_xmlhttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	mylikedata_xmlhttp.onreadystatechange=mylikedata_stateChanged ;
	mylikedata_xmlhttp.open("GET",url,true);
	mylikedata_xmlhttp.send(null);

}
function mylikedata_stateChanged()
{
if (mylikedata_xmlhttp.readyState==4 || mylikedata_xmlhttp.readyState=="complete")
				{ 
					var datanode = mylikedata_xmlhttp.responseText;
					alert(datanode);
					xb_get_element('myfevdata').style.display="block";
					xb_get_element('myfevdata').innerHTML = datanode;
					
					
				}
	
	
}*/


