	new_img = document.createElement('img');
	new_img.src = 'images/ajax-loader.gif';

function formSubmit()
{
document.form1.submit();
}


function isEmptyValidation(id)
{

  var val = document.getElementById(id).value;
  if (val == '') {
     alert('This field is required !!!');
	 return false;
  }
  
}




function loadXMLDocCity(){

	xmlhttp= (window.XMLHttpRequest ? new XMLHttpRequest(): ((window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : null) );
	xmlhttp.onreadystatechange = state_change
	xmlhttp.open("POST",'getCityState.php',true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send('state='+document.form1.state.value);
}


function emailCheck(id) {
  var emailStr = document.getElementById(id).value;
  var checkTLD=1;
  var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
  var emailPat=/^(.+)@(.+)$/;
  var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
  var validChars="\[^\\s" + specialChars + "\]";
  var quotedUser="(\"[^\"]*\")";
  var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
  var atom=validChars + '+';
  var word="(" + atom + "|" + quotedUser + ")";
  var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
  var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
  var matchArray=emailStr.match(emailPat);

  if (matchArray==null) {
    //alert("Email address seems incorrect (check @ and .'s)");
    return false;
  }
  var user=matchArray[1];
  var domain=matchArray[2];

  for (i=0; i<user.length; i++) {
    if (user.charCodeAt(i)>127) {
     //alert("Ths username contains invalid characters.");
     return false;
    }
  }

  for (i=0; i<domain.length; i++) { 
   if (domain.charCodeAt(i)>127) {
    //alert("Ths domain name contains invalid characters.");
     return false;
   }
  }


  if (user.match(userPat)==null) {
    //alert("The username doesn't seem to be valid.");
    return false;
  }

  var IPArray=domain.match(ipDomainPat);
  if (IPArray!=null) {
   for (var i=1;i<=4;i++) {
      if (IPArray[i]>255) {
         //alert("Destination IP address is invalid!");
         return false;
      }
   }
  return true;
  }

 
  var atomPat=new RegExp("^" + atom + "$");
  var domArr=domain.split(".");
  var len=domArr.length;
  for (i=0;i<len;i++) {
   if (domArr[i].search(atomPat)==-1) {
      //alert("The domain name does not seem to be valid.");
      return false;
   }
  }

  if (checkTLD && domArr[domArr.length-1].length!=2 && 
   domArr[domArr.length-1].search(knownDomsPat)==-1) {
   //alert("The address must end in a well-known domain or two letter " + "country.");
   return false;
  }

  if (len<2) {
   //alert("This address is missing a hostname!");
   return false;
  }

 return true;
}


function check_date(fld) {
	
  
    var mo, day, yr;
    var entry = fld.value;
    var reLong = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{4}\b/;
    var reShort = /\b\d{1,2}[\/-]\d{1,2}[\/-]\d{2}\b/;
    var valid = (reLong.test(entry)) || (reShort.test(entry));
    if (valid) {
        var delimChar = (entry.indexOf("/") != -1) ? "/" : "-";
        var delim1 = entry.indexOf(delimChar);
        var delim2 = entry.lastIndexOf(delimChar);
        mo = parseInt(entry.substring(0, delim1), 10);
        day = parseInt(entry.substring(delim1+1, delim2), 10);
        yr = parseInt(entry.substring(delim2+1), 10);
        // handle two-digit year
        if (yr < 100) {
            var today = new Date( );
			// get current century floor (e.g., 2000)
            var currCent = parseInt(today.getFullYear( ) / 100) * 100;
			// two digits up to this year + 15 expands to current century
            var threshold = (today.getFullYear( ) + 15) - currCent;
            if (yr > threshold) {
                yr += currCent - 100;
            } else {
                yr += currCent;
            }
        }
        var testDate = new Date(yr, mo-1, day); //alert();
        if (testDate.getDate( ) == day) { 
            if (testDate.getMonth( ) + 1 == mo) {
				var curDate;
                curDate = new Date();
				curDate.setDate(curDate.getDate( ) - 1);
				
				if (testDate.getFullYear( ) == yr) {
                    // fill field with database-friendly format
                    fld.value = mo + "/" + day + "/" + yr;
                    return true;
                } else {
                    alert("Invalid year entry.");
                }
            } else {
                alert("Invalid month entry.");
            }
        } else {
            alert("Invalid date entry.");
        }
    } else {
        alert("Incorrect date format. Enter as mm/dd/yyyy.");
    }
    return false;
}


function chcek_float(e)
{
		
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 46 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 46 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}


function chcek_numeric(e)
{
	
	var isIE = (window.event) ? 1 : 0;
	if (isIE)
	{
		if (e.keyCode < 47 || e.keyCode >57 ) 
		{ 
			e.returnValue = false;
		}
	}
	else
	{

		if ( e.which < 47 || e.which >57 ) 
		{
			if ( e.which != 8 ) e.preventDefault();
		}
	}

}


function show_popup(str)
{
  var arg = 'resizable=yes, toolbar=no,location=no,directories=no,addressbar=no,scrollbars=yes,status=no,menubar=no,width=620,height=620,top=20,left=250';
  window.open(str, "_blank", arg);
}
function closeWin(){
	window.close('large_img.html');
	
}

function saveProperty(id){
   //p=confirm('Do you really want to save this property?');
   
  Dialog.confirm("Do you really want to save this property?", 
                   {top: 150, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", onOk:function(win){
						var parms = 'p_id='+id; 
     					new Ajax.Request('save-property.php', {method: 'post', parameters: parms});
						Windows.focusedWindow.close();
				   }
				   });

   /*if(p){
      var parms = 'p_id='+id; 
      new Ajax.Request('save-property.php', {method: 'post', parameters: parms});
   }*/
}

function savePropertyOver(id){
   //p=confirm('Do you really want to save this property?');
   Dialog.confirm("Do you really want to save this property?", 
                   {top: 150, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", onOk:function(win){
						var parms = 'p_id='+id+'&flag=1'; 
      					new Ajax.Request('save-property.php', {method: 'post', parameters: parms});  
						Windows.focusedWindow.close();
				   }
				   });
}

function confirm_delete()
{
	var val;
	val = confirm("Do you want to delete?");
	return val;
	
	/*Dialog.confirm("Do you want to delete?", 
                   {top: 150, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", onOk:function(win){
						return true;
						Windows.focusedWindow.close();
				   }
				   });*/
}

function confirm_del()
{

	
	Dialog.confirm("Do you want to delete?", 
                   {top: 150, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", onOk:function(win){
						document.form2.submit();
						Windows.focusedWindow.close();
				   }
				   });
}



function checkTerms(str){
	if(!document.getElementById('agree_terms').checked){
		//alert("You have to agree to the Terms and Conditions for get an account.");
	    Dialog.alert("You have to agree to the Terms and Conditions for get an account.", {top: 150, width:250, className: "alphacube"})
		return false;
	}
	
	if(!checkRequired(str))
		return false;
	
	return true;
}

function checkUserSignUp(){
	if(!checkTerms())
		return false;
		
		
	
}

function goDel(id){
 // p=confirm("Do you really want to remove this property from your shortlist?");
  Dialog.confirm("Do you really want to remove this property from your shortlist?", 
                   {top: 150, width:250, className: "alphacube", okLabel: "Yes", cancelLabel:"No", onOk:function(win){
						window.location= 'saved-property.php?del='+id;  
				   }
				   });

  
  }
  
  
 function goSignIn(){
	window.location="user-signin.php";
}

function swapDisplay(id){
	if($(id).style.display=='none')
		$(id).style.display='block';
	else
		$(id).style.display='none';
}


function swapContact(id){
	if($(id).style.display=='none'){
		$(id).style.display='block';
		$('contact-button').className='contact-agent-show';
		
	}
	else{
		$(id).style.display='none';
		$('contact-button').className='contact-agent-hide';
	}
}

function showSignUp(){
	$('signin-form').style.display='none';
	$('signup-form').style.display='block';
	$('forget-form').style.display='none';
	
}

function showForgetPass(){
	$('signin-form').style.display='none';
	$('signup-form').style.display='none';
	$('forget-form').style.display='block';
	
}

function showSignIn(id){
	if($(id).style.display=='none')
		$(id).style.display='block';
	else
		$(id).style.display='none';
	
	$('signup-form').style.display='none';
	$('forget-form').style.display='none';
	
}


function checkRequired(str){
	fields=str.split(',');
	err=0;
	

	for(i=0;i<fields.length;i++){
		if($(fields[i]).value=='Email Address:')
			$(fields[i]).value='';
		
		if(fields[i]=='pwd'){
			$('password').value=$(fields[i]).value;	
		}
		
		if($(fields[i]).value==''){
			err=1;
			break;
		}
		
		if(fields[i]=='email'){
			if(!emailCheck('email'))
				err=2;
		}
		
		if(fields[i]=='email2'){
			if(!emailCheck('email2'))
				err=2;
		}
		
		if(fields[i]=='email3'){
			if(!emailCheck('email3'))
				err=2;
		}
		
		if(fields[i]=='conf_password'){
			if($('password').value!=$('conf_password').value)
				err=3;
		}
	}
	

	if(err==1){
		 
		 Dialog.alert("Please complete required fields. Required fields are marked with an asterisk(*)", {top: 150, width:250, className: "alphacube"})		
		 return false;
	}
	
	if(err==2){
		 
		 Dialog.alert("Invalid Email Address", {top: 150, width:250, className: "alphacube"})		
		 return false;
	}
	
	if(err==3){
		 Dialog.alert("Please Retype Same Password.", {top: 150, width:250, className: "alphacube"})		
		 return false;
	}
	
	
	
	return true;
	
}


function showBuildAd(id) {

	
	$('right_bdy').innerHTML = '<div style="width:100%; color:red; text-align:center; padding:100px 0 20px 0;"><img src="images/ajax-loader.gif" /><br><br><strong>Loading...</strong></div>';
    var parms = 'cat_id='+id; 
	new Ajax.Request('findads.php', {method: 'post', parameters: parms,onComplete: ad_proper});
}

function ad_proper(re1_id){
	if(re1_id.responseText) {
	//alert(re1_id.responseText);
	   $('right_bdy').innerHTML = re1_id.responseText;
	}
}


var curBanner=1;
var curLeftBanner=1;

function runBanner(){
	curBanner=1;
	curLeftBanner=1;
	
	setInterval('rotateBanner()', 3000);
	if($('left_bnr_count'))
		setInterval('rotateLeftBanner()', 3000);
}


function rotateBanner(){
				
				
				//Effect.Fade('img_'+curImg, { duration: 1.0, afterFinishInternal:function(effect){
					bnrCount=$('bnr_count').value;
					new Effect.Fade('bnr_img_'+curBanner,{ duration: 0.6 });
					//$('bnr_img_'+curBanner).style.display='none';
					curBanner=curBanner+1;
					if(curBanner > bnrCount)
						curBanner=1;
					Effect.Appear('bnr_img_'+curBanner, { duration: 0.6 });

				//}
				//});
				

}

function rotateLeftBanner(){
				
				//alert(1);
				//Effect.Fade('img_'+curImg, { duration: 1.0, afterFinishInternal:function(effect){
					bnrCount=$('left_bnr_count').value;
					new Effect.Fade('left_bnr_img_'+curLeftBanner,{ duration: 0.6 })
					//$('left_bnr_img_'+curBanner).style.display='none';
					curLeftBanner=curLeftBanner+1;
					if(curLeftBanner > bnrCount)
						curLeftBanner=1;
					Effect.Appear('left_bnr_img_'+curLeftBanner, { duration: 0.6 });

				//}
				//});
				

		}
		
		
		
function home_loadXMLDoc() {
	$('loc_area').innerHTML = '<div id="showblock" style="text-align:center;"><img src="images/loader-small.gif" alt="" /></div>';
	var parms = 'state_id='+document.form1.state_id.value;
	new Ajax.Request('getcity.php', {method: 'post', parameters: parms,onComplete: home_state_Change});	
}

function home_state_Change(re_id) {
    if(re_id.responseText)    
        $('loc_area').innerHTML = re_id.responseText;  
}

function loadXMLDoc1(obj) {
	$('showblock').innerHTML = '<div id="showblock" style="text-align:center;"><img src="images/loader-small.gif" alt="" /></div>';
	var parms = 'city_id='+obj.value;
	new Ajax.Request('getblock.php', {method: 'post', parameters: parms,onComplete: state_Change1});	
}

function state_Change1(re_id) {
    if(re_id.responseText)    
        $('showblock').innerHTML = re_id.responseText;  
}



//tracking property visit


function trackLog(pro_id,agent_id,ovsersea){
	var parms = 'hitlog=y&propertyId='+pro_id+'&agent_id='+agent_id+'&ovsersea='+ovsersea;
	new Ajax.Request('ajaxRequest.php', {method: 'post', parameters: parms});
	
}


//locationwise property search

function viewDiv(id,num){
	//return;
	var f=$$('.pg'+M);
	for(var i=0; i<f.length; i++){
		$(f[i]).removeClassName('selected');
	}
	
	if(id==1 && PG==1){
		//$$('.pgPrev').setStyle({visibility: 'hidden'});
		var f=$$('.pgPrev');
		for(var i=0; i<f.length; i++){
			$(f[i]).setStyle({visibility: 'hidden'});
		}
		
	}
		//$('pgPrev').style.visibility='hidden';
		
	if(id>1){
		//$$('.pgPrev').setStyle({visibility: 'visible'});
		var f=$$('.pgPrev');
		for(var i=0; i<f.length; i++){
			$(f[i]).setStyle({visibility: 'visible'});
		}
		//$('pgPrev').style.visibility='visible';
	}
	//alert($('last_pagi').value+'>>'+M);
	if($('last_pagi').value!=0 && $('last_pagi').value==(M+2)){
		//$$('.pgNext').setStyle({visibility: 'hidden'});
		var f=$$('.pgNext');
		for(var i=0; i<f.length; i++){
			$(f[i]).setStyle({visibility: 'hidden'});
		}
		//$('pgNext').style.visibility='hidden';
	}
	else{
		//$$('.pgNext').setStyle({visibility: 'visible'});
		var f=$$('.pgNext');
		for(var i=0; i<f.length; i++){
			$(f[i]).setStyle({visibility: 'visible'});
		}
		//$('pgNext').style.visibility='visible';
	}
		
	/*if(id<num)
		$('pgNext').style.display='block';*/
	
	M=id;
	//$('pg'+M).addClassName('selected');
	//$$('.pg'+M).addClassName('selected');
	var f=$$('.pg'+M);
		for(var i=0; i<f.length; i++){
			$(f[i]).addClassName('selected');
		}
	
	
	for(var i=1;i<=num;i++){
			$('blk_'+i).style.display='none';
	}
	
	$('blk_'+id).style.display='block';
}

function PrevNext(pn,num,pg){

     //alert(pn+'>>'+pg+'>>'+M);
	if(pn==0 && pg==0 && M==1)
		return;

	if((M%5 == 0 && pn==1) || (pn==0 && M==1)){
		
		if(STEP==1)
			accordion('',pg);
		else if(STEP==2)
			getBlockList('',pg);
		else if(STEP==3)
			getBlockPro('',pg);
	}
	else{		
			
		if(pn==0)
			id=M-1;
		if(pn==1)
			id=M+1;
		
		if(id!=0){
			viewDiv(id,num);
		}
		
	}
		
		
}




function proListInit(pg){
	if(PG > pg)
		M=5;
	else
		M=1;	
	
	if(pg)
		PG=pg;
	else
		PG=1;
}


