var isResponse = "true";	
/****************Ajax Xml Http Request Start***************/
function xmlhttpPost(strMethod, strURL, myFun, dataToSend) {
	//alert(strURL);	
	var xmlHttpReq = false;
    // Mozilla/Safari Http Request
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
    }
    // IE Http Request
    else if (window.ActiveXObject) {
        xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
    }
        
    xmlHttpReq.open(strMethod, strURL, true);
    xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    if(strMethod=="POST")
    {	
    	xmlHttpReq.send(dataToSend); 
    }
    else
    {
    	xmlHttpReq.send('null');
    }
    xmlHttpReq.onreadystatechange = function() {
        if(xmlHttpReq.readyState == 4) 
        {
           responseAjaxData = xmlHttpReq.responseText;  
           if(myFun!="noFun"){
				eval(myFun)(responseAjaxData);
           }	
        }
     }
}
/****************Ajax Xml Http Request End***************/

function selectedtopmenu(pname)
{
if(pname<7){
for(i=1; i<7; i++)
	{
	document.getElementById('page'+i).className = '';
	}
	document.getElementById('page'+pname).className = 'selected';
}
}

function callp(pname)
{
	selectedtopmenu(pname)
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	var t = new Date();
	switch (pname)
	{
		case 1:
			xmlhttpPost("GET", "home.php?t="+t.getTime(), "fillpage","");
			break;
		
		case 2:
			xmlhttpPost("GET", "about.php?t="+t.getTime(), "fillpage","");
			break;
		
		case 3:
			xmlhttpPost("GET", "services.php?t="+t.getTime(), "fillpage","");
			break;
		
		case 4:
			xmlhttpPost("GET", "contact.php?t="+t.getTime(), "fillpage","");
			break;
		
		case 5:
			xmlhttpPost("GET", "broker_info.php?t="+t.getTime(), "fillpage","");
			break;
		
		case 6:
			xmlhttpPost("GET", "advertise.php?t="+t.getTime(), "fillpage","");
			break;

		case 7:
			xmlhttpPost("GET", "jplogin.php?t="+t.getTime(), "fillpage","");
			break;
			
			
	}
	
}

function callbp(pname)
{
	window.location=pname+".php";
	
}

function callhomep(pname,nm,valu)
{
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	var t = new Date();
	
	xmlhttpPost("GET", pname+".php?"+nm+"="+valu+"&t="+t.getTime(), "fillpage","");
	
}

function calldetail(pname,nm,valu)
{
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	var t = new Date();
	
	xmlhttpPost("GET", pname+".php?"+nm+"="+valu+"&t="+t.getTime(), "fillpage","");
	
}

function fillpage(responseAjaxData)
{	
document.getElementById('rightcell').innerHTML = responseAjaxData;	

//ondetaiload();
}

function setlang(that)
{
	var t = new Date();
	var lang=that.options[that.selectedIndex].value;	
	window.location="setlang.php?l="+lang;
	//xmlhttpPost("GET", "setlang.php?l="+lang+"&t="+t.getTime(), "fillpage","");
}

function setweergave(that)
{
	var t = new Date();
	var weergave=that.options[that.selectedIndex].value;	
	//alert(weergave);
	//window.location="setlang.php?w="+weergave;
	xmlhttpPost("GET", "setlang.php?w="+weergave+"&t="+t.getTime(), "nothing","");
}

function nothing(responseAjaxData)
{
//
}

function doChallengeResponse() {
var that=document.getElementById('login_form') ;
  	//alert(that.username.value);
    str = that.username.value.toLowerCase() + ":" +sha256_digest(that.userpass.value) + ":" +that.challenge.value;
    that.userpass.value = "";
    that.challenge.value = "";
    that.response.value = sha256_digest(str);
   //alert(str)
   return true;
   
 /*  var t = new Date();
	
	var strData="";
				
		strData = 'username='+escape(that.username.value);
		strData += '&userpass='+escape(that.userpass.value);
		strData += '&challenge='+escape(that.challenge.value);
		strData += '&response='+escape(that.response.value);
		strData += '&mode='+escape(that.mode.value);
		
	that.submit();*/	
	//document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	//xmlhttpPost("POST", "login.php?t="+t.getTime(), "fillpage", strData);
	
	//return false;
  }
  
function doforget() {
var that=document.getElementById('forget_form') ;

if ( (that.username.value == "")){
	alert ("Please Enter username");
	that.username.focus();
	return (false);
}

else if  ( (that.email.value == "")){
	alert ("Please Enter Email");
	that.email.focus();
	return (false);
}

else if ( (that.email.value.indexOf("@") == -1) ||(that.email.value.indexOf(" ") >= 0) || (that.email.value.indexOf(".") == -1) ) {
	alert("Please Fill A Valid Email"); 
	that.email.value="";
	that.email.focus();
	return (false);
}
else{
	return (true);
    /*var t = new Date();
	
	var strData="";
				
		strData = 'username='+escape(that.username.value);
		strData += '&email='+escape(that.email.value);	
		strData += '&mode='+escape(that.mode.value);	
		
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	xmlhttpPost("POST", "forgotp.php?t="+t.getTime(), "fillpage", strData);
	
	return false;*/
  }
}

function donewuser() {
var that=document.getElementById('register_form') ;

if ( (that.username.value == "")){
	alert ("Please Enter username");
	that.username.focus();
	return (false);
}


else if  ( (that.userpass.value == "")){
	alert ("Please Enter Password");
	that.userpass.focus();
	return (false);
}

else if  ( (that.name.value == "")){
	alert ("Please Enter name");
	that.name.focus();
	return (false);
}

else if  ( (that.email.value == "")){
	alert ("Please Enter Email");
	that.email.focus();
	return (false);
}

else if ( (that.email.value.indexOf("@") == -1) ||(that.email.value.indexOf(" ") >= 0) || (that.email.value.indexOf(".") == -1) ) {
	alert("Please Fill A Valid Email"); 
	that.email.value="";
	that.email.focus();
	return (false);
}
else{
	return true;
   /* var t = new Date();
	
	var strData="";
				
		strData = 'username='+escape(that.username.value);
		strData += '&userpass='+escape(that.userpass.value);
		strData += '&name='+escape(that.name.value);
		strData += '&addr='+escape(that.addr.value);
		strData += '&city='+escape(that.city.value);
		strData += '&coutry='+escape(that.coutry.value);
		strData += '&tel='+escape(that.tel.value);
		strData += '&fax='+escape(that.fax.value);
		strData += '&email='+escape(that.email.value);	
		strData += '&mode='+escape(that.mode.value);	
		strData += '&zip='+escape(that.zip.value);
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	xmlhttpPost("POST", "register.php?t="+t.getTime(), "fillpage", strData);
	
	return false;*/
  }
}

function dolsiting() {
	
var that=document.getElementById('newlisting') ;

//alert(that.dicount[1].checked);

if ( (that.address.value == "")){
alert ("Please Enter address");
that.address.focus();
return (false);
}

else if  ( (that.zipcode.value == "")){
alert ("Please Enter zipcode");
that.zipcode.focus();
return (false);
}
else if  ( (that.city.value == "")){
alert ("Please Enter city");
that.city.focus();
return (false);
}
else if  ( (that.mainbuilding_rooms.value == "")){
alert ("Please Enter mainbuilding_rooms");
that.mainbuilding_rooms.focus();
return (false);
}
else if  ( (that.mainbuilding_outbuildings_amount.value == "")){
alert ("Please Enter How Many outbuildings");
that.mainbuilding_outbuildings_amount.focus();
return (false);
}
else if  ( (that.mainbuilding_total_sqaure_floor.value == "")){
alert ("Please Enter Mainbuilding total sqaure floor");
that.mainbuilding_total_sqaure_floor.focus();
return (false);
}
else if  ( (that.object_area_m2.value == "")){
alert ("Please Enter object_area_m2");
that.object_area_m2.focus();
return (false);
}
else if  ( (that.object_distance_to_village.value == "")){
alert ("Please Enter object_distance_to_village");
that.object_distance_to_village.focus();
return (false);
}
else if  ( (that.object_distance_to_small_city.value == "")){
alert ("Please Enter object_distance_to_small_city");
that.object_distance_to_small_city.focus();
return (false);
}
else if  ( (that.object_distance_to_city.value == "")){
alert ("Please Enter object_distance_to_city");
that.object_distance_to_city.focus();
return (false);
}

else if  (that.dicount[1].checked){

	if ( (that.address1.value == "")){
		alert ("Please Enter address");
		that.address1.focus();
		return (false);
	}

	else if  ( (that.zipcode1.value == "")){
		alert ("Please Enter zipcode");
		that.zipcode1.focus();
		return (false);
	}
	else if  ( (that.city1.value == "")){
		alert ("Please Enter city");
		that.city1.focus();
		return (false);
	}
	else if  ( (that.mainbuilding_rooms1.value == "")){
		alert ("Please Enter mainbuildingrooms");
		that.mainbuilding_rooms1.focus();
		return (false);
	}
	else if  ( (that.mainbuilding_outbuildings_amount1.value == "")){
		alert ("Please Enter How Many outbuildings");
		that.mainbuilding_outbuildings_amount1.focus();
		return (false);
	}
	else if  ( (that.mainbuilding_total_sqaure_floor1.value == "")){
		alert ("Please Enter Mainbuilding total sqaure floor");
		that.mainbuilding_total_sqaure_floor1.focus();
		return (false);
	}
	else if  ( (that.object_area_m21.value == "")){
		alert ("Please Enter object_area_m2");
		that.object_area_m21.focus();
		return (false);
	}
	else if  ( (that.object_distance_to_village1.value == "")){
		alert ("Please Enter object_distance_to_village");
		that.object_distance_to_village1.focus();
		return (false);
	}
	else if  ( (that.object_distance_to_small_city1.value == "")){
		alert ("Please Enter object_distance_to_small_city");
		that.object_distance_to_small_city1.focus();
		return (false);
	}
	else if  ( (that.object_distance_to_city1.value == "")){
		alert ("Please Enter object_distance_to_city");
		that.object_distance_to_city1.focus();
		return (false);
	}
}


else{
	return true;
  }
}

function calllp(id, mode)
{
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	var t = new Date();
	switch (mode)
	{
		case 1:
			window.location="home.php?t="+t.getTime();
			break;
		
		case 2:
			window.location="listingprocess.php?t="+t.getTime()+"&mode=edit&id="+id;
			break;
		
		case 3:
			window.location="listingprocess.php?t="+t.getTime()+"&mode=del&id="+id;
			break;
	}
	
}


function searchsubmit(pagn) {
var that=document.getElementById('search') ;
that.pageno.value=pagn;
that.submit();
	
    /*var t = new Date();
	
	var strData="";
				
		strData += '&listing_type='+escape(that.listing_type.value);
		strData += '&listing_price='+escape(that.listing_price.value);
		strData += '&listing_land='+escape(that.listing_land.value);
		strData += '&pageno='+escape(pagn);
		
		
		strData += '&mode='+escape(that.mode.value);
	//alert(strData);	
	document.getElementById('rightcell').innerHTML = "<div class='loading'><img src='./images/loading.gif'></div>";
	
	//alert(strData);
	xmlhttpPost("POST", "kopen.php?t="+t.getTime(), "fillpage", strData);
	
	xmlhttpPost("POST", "kkopen.php?t="+t.getTime(), "fillpagee", strData);*/
	
}

function fillpagee(responseAjaxData)
{	
document.getElementById('noofresult').innerHTML = responseAjaxData;	

//ondetaiload();
}

function gotopaypal(fid)
{
var formname="paypal_"+fid;
document.getElementById(formname).submit();
}


function alphanumeric(alphane)
{
	var numaric = alphane.value;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			
			alert("Only alfanumeric allowed here");
			alphane.value=""
			 return false;
		  }
		}
 return true;
}


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_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_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_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];}



}


