var paginationdata='';
var paginationfile='';
var mylocationlati=[];
var mapload=0;
var mapflag=0;
var map = null;
var geocoder = null;
var mydomain=window.location.href.match(/:\/\/(.[^/]+)/)[1];
//alert(mydomain);
//alert(document.domain);
function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
/* Display City Start*/
function citydisplay(node, id ,filename , paginationfile)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
	var url=filename+"?property_type_id=" + id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=function(){city(node, paginationfile)}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}

function maindisplay(id ,filename, script, property_type,city,premoter,property)
{
	//var url=filename+"?propertytype_name="+property_type +"&location="+city+"&promotername="+premoter+"&propertyname="+property;
	if(getCookie('Script'))
	{
	deleteCookie('Script') ; 
	}
	setCookie('Script',script);
	var url=property_type+"_properties_"+city+"-"+premoter+"-"+property;
	url=url.toLowerCase();
	url=url.replace(/^\s*|\s*$/gi,'');
	url=url.replace(/\s/gi,"-");
	url=url+".html";
	window.location.href=url;
}


function developermain(id ,filename,developername)
{
	//var url=filename+"?propertytype_name="+property_type +"&location="+city+"&promotername="+premoter+"&propertyname="+property;
	var url=developername;
	//setCookie('promoter',id);
	url=url.toLowerCase();
	url=url.replace(/^\s*|\s*$/gi,'');
	url=url.replace(/\s/gi,"-");
	url=url+".html";
	window.location.href=url;
}
function propertiesforsale(PROJECT_CATEGORY_NAME,id ,filename)
{
	//var url=filename+"?propertytype_name="+property_type +"&location="+city+"&promotername="+premoter+"&propertyname="+property;
	var url='properties_for_sale'+"_"+PROJECT_CATEGORY_NAME+'-'+id;
	//setCookie('PROJECT_CATEGORY_ID',id);
	url=url.toLowerCase();
	url=url.replace(/^\s*|\s*$/gi,'');
	url=url.replace(/\s/gi,"-");
	url=url.split("/").join("&");
	url=url+".html";
	window.location.href=url;
}
function propertiesforsalemain(PROJECT_NAME,PROJECT_LOCATION,id)
{
	//var url=filename+"?propertytype_name="+property_type +"&location="+city+"&promotername="+premoter+"&propertyname="+property;
	var url='properties_for_salesite_at'+"_"+PROJECT_LOCATION+'-'+PROJECT_NAME+'-'+id;
	//setCookie('PROJECT_ID',id);
	url=url.toLowerCase();
	url=url.replace(/^\s*|\s*$/gi,'');
	url=url.replace(/\s/gi,"-");
	url=url.replace(/,/gi,"");
	url=url.split("/").join("&");
	url=url+".html";
	window.location.href=url;
}



function searchdisplay(node, id ,filename , paginationfile)
{
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null)
	{
	alert ("Your browser does not support AJAX!");
	return;
	}
	var url=filename+id;
	url=url+"&sid="+Math.random();
	xmlhttp.onreadystatechange=function(){city(node, paginationfile)}
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
}
	
function mainrec(innerid)
{
	if (xmlhttp.readyState==4)
	{
	var itemresult=xmlhttp.responseText;
	document.getElementById(innerid).innerHTML=itemresult;
	}
	else{
	try{
	document.getElementById(innerid).innerHTML='<img src="loading.gif" style="border:none;"/>';
	} catch(err){}
	}
}
	
function city(innerid, paginationfile)
{
	if(xmlhttp.readyState==4)
	{
		var itemresult=xmlhttp.responseText;
		itemresultarray=itemresult.split("|~");
		nodeid=innerid.split(",");
		if((nodeid.length==1 && itemresultarray.length ==2) && (paginationfile!='searchresult.php' && paginationfile!='prosearchresult.php'))
		{
			document.getElementById(nodeid[0]).innerHTML=itemresultarray[0];
			paginationdata=itemresultarray[1];
			try{
			document.getElementById('paginate-top').innerHTML="";
			document.getElementById('paginate-bottom').innerHTML="";
		} catch(err){}
			pagination( paginationdata ,paginationfile ); 
		}
		else if(nodeid.length==2 && itemresultarray.length >2)
			{
			//document.getElementById(nodeid[0]).innerHTML=itemresultarray[0];
			document.getElementById(nodeid[1]).innerHTML=itemresultarray[1];
			paginationdata=itemresultarray[2];
			pagination1( paginationdata ,paginationfile );
			}
		else if(itemresultarray.length >2  && nodeid.length!=2)
		{
			document.getElementById(innerid).innerHTML=itemresultarray[0];
			try{
			document.getElementById('PROPERT_DISPLAY').innerHTML=itemresultarray[1];
			}catch(err){
				document.getElementById('PROPERT').innerHTML=itemresultarray[1];
			}
			try{
			document.getElementById('paginate-top').innerHTML="";
			document.getElementById('paginate-bottom').innerHTML="";
		} catch(err){}
			paginationdata=itemresultarray[2];
			pagination( paginationdata ,paginationfile );
									
		}
		else if(nodeid.length==2 && itemresultarray.length==2)
		{
			document.getElementById(nodeid[0]).innerHTML=itemresultarray[0];
			document.getElementById(nodeid[1]).innerHTML=itemresultarray[1];
			try{
			document.getElementById('paginate-top').innerHTML="";
			document.getElementById('paginate-bottom').innerHTML="";
		} catch(err){}
		}
		else 
		{
			if(paginationfile=='searchresult.php' || paginationfile=='prosearchresult.php')
			{
			document.getElementById(innerid).innerHTML=itemresultarray[0];		
			paginationdata=itemresultarray[1];
			pagination1( paginationdata ,paginationfile );
			}
			else{
			document.getElementById(innerid).innerHTML=itemresultarray[0];
			pagination( paginationdata ,paginationfile );
			}
		}
		}
		else{
		try{
		//document.getElementById(innerid).innerHTML='<img src="loading.gif" style="border:none;"/>';
		document.getElementById('PROPERT_DISPLAY').innerHTML="";
		document.getElementById('PROPERT').innerHTML="";
		document.getElementById('PROPERT').innerHTML='<img src="loading.gif" style="border:none;"/>';
		document.getElementById('PROPERT_DISPLAY').innerHTML='<img src="loading.gif" style="border:none;"/>';
		} catch(err){}
	}
} 
/*Display City End*/
function pagination( paginationdata, paginationfile )
{
	var bookcombo={
	pages: [],
	selectedpage: 0 //set page shown by default (0=1st page)
	}
	var array=paginationdata.split(",");
	array=array.clean("");
	var l=array.length-1
	var arg1=array.slice(0,l).join(',');
	var totalrec=array[l];
	var recperpage=6;
	var numpage=0;
	if((totalrec % recperpage)>0)
	{
	numpage=parseInt(totalrec/recperpage)+1; 
	}
	else {
	numpage=(totalrec/recperpage);
	}
	for(var j=1;j<=numpage;j++)
	{
	arg=arg1+','+j+','+recperpage;
	bookcombo.pages.push(paginationfile+"?property_type_id="+arg);
	}
	var mybookinstance=new ajaxpageclass.createBook(bookcombo, "PROPERT", ["paginate-top", "paginate-bottom"])	
}

function pagination1( paginationdata, paginationfile )
{
	var bookcombo={
	pages: [],
	selectedpage: 0 //set page shown by default (0=1st page)
		}
	var array=paginationdata.split(",");
	var totalrec=array[1];
	var recperpage=6;
	var numpage=0;
	try{
	document.getElementById('result-found').innerHTML=totalrec;
	  } catch(err) {}
	if(totalrec%recperpage > 0)
	  {
		numpage=parseInt(totalrec/recperpage)+1 ;
	   }
	 else {
			numpage=(totalrec/recperpage);
		}
	
	for(var j=1;j<=numpage;j++)
	{
	var arg=array[0]+','+j+','+recperpage;
	bookcombo.pages.push(paginationfile+"?property_type_id="+arg);
	}
	var mybookinstance=new ajaxpageclass.createBook(bookcombo, "PROPERT", ["paginate-top", "paginate-bottom"])	
}

function setActive( catid ) 
{
	aObj = document.getElementById(catid);
	if(aObj!=null){
	addClass(aObj,"hot-pro-txtsmlw" );
	}
}


function setproperty( node, str, tab , filename, paginationfile, ptype ) 
{
	try{
	document.getElementById('PROPERT_DISPLAY').style.display='block'
	document.getElementById('PROPERT').style.display='none'
	}catch(err){}
	aObj = document.getElementById(str).getElementsByTagName('a'); 
	aObj1 = document.getElementById(str).getElementsByTagName('li');
	for(i=0;i<aObj.length;i++) 
	{
		if(aObj[i].innerHTML==tab.innerHTML)
		{
			if(node=='PROPERT_DISPLAY' || ptype){
					var j=aObj[i].innerHTML+','+ptype;
					try{
						if(tab.rel)	{
							j = j + ',' + tab.rel;
						}
						}catch(err){}
				}
			else {
				var j=i+1;
				try{
						if(tab.rel)	{
							j = j+','+tab.rel;
						}
					}catch(err){}
				}
			addClass(aObj1[i], "TAB");
		}
		else
		{
			removeClass(aObj1[i],"TAB");
		}
	}
	citydisplay(node,j,filename, paginationfile);
}

function viewmorehotproperty( node, str, filename, arg, paginationfile ) 
{
	aObj = document.getElementById(str).getElementsByTagName('a'); 
	aObj1 = document.getElementById(str).getElementsByTagName('li');
	for(i=0;i<aObj.length;i++) 
	{
		if(aObj[i].innerHTML=='Residential')
		{
		addClass(aObj1[i], "TAB");
		}
		else
		{
		removeClass(aObj1[i],"TAB");
		}
	}
	citydisplay(node,arg,filename ,paginationfile);
}
//////// setproperty1('CITY_TAB','PROPERTY_TAB','citydisplay.php','projectdisplay.php')
function setproperty1( node, str, filename, paginationfile ) 
{
	aObj = document.getElementById(str).getElementsByTagName('a'); 
	aObj1 = document.getElementById(str).getElementsByTagName('li');
	for(i=0;i<aObj.length;i++) 
	{
		if(aObj[i].innerHTML=='Residential')
		{
			var j=i+1;
			addClass(aObj1[i], "TAB");
		}
		else
		{
			removeClass(aObj1[i],"TAB");
		}
	}
	citydisplay(node,j,filename, paginationfile);
}

function setActive1( str, tab ) 
{
aObj = document.getElementById(str).getElementsByTagName('a'); 
aObj1 = document.getElementById(str).getElementsByTagName('li');
if(tab)
	{
		var newStr =tab;
	}
else
	{	
		var newStr =window.location.href; 
	}
if(newStr.charAt(newStr.length-1)=="#")
	{
		newStr = newStr.substring(0, newStr.length-1);
	}
if(newStr.charAt(newStr.length-1)=="/")
	{
		newStr=newStr + "index.php";
	}
	var url=newStr.split('?');
	for(i=0;i<aObj.length;i++) 
	{
		if(aObj[i].href==url[0])
		{
			
			aObj1[i].className='current';
		}
		else
		{
			removeClass(aObj1[i],"current");
		}
	}
}

function fastsearchresult(str, file)
{
	alert(str+'//'+file)
	if(str.form.searchvalue.value!='')
	{
		arg=str.form.searchvalue.value;
		citydisplay('searchcontainer', arg , file , 'searchresult.php');			
	}
}
function initialize() 
{
	if(GBrowserIsCompatible()) 
	{
		var map = new GMap2(document.getElementById("map_canvas"));
		//map.setCenter(new GLatLng(37.4419, -122.1419), 13);
		//map.setUIToDefault();

		GEvent.addListener(map,"click", function(overlay,latlng) {     
		if (latlng) {   
		var myHtml = "The GLatLng value is: " + map.fromLatLngToDivPixel(latlng) + " at zoom level " + map.getZoom();
		map.openInfoWindow(latlng, myHtml);
		}
		});
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.addControl(new GScaleControl());
		map.addControl(new GOverviewMapControl());
		for(var i=0;i<mylocationlati.length-1;i++)
		{
		showAddress(mylocationlati[i][0],mylocationlati[i][1],i);
		}
	}
	else
	{
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }

}

		
function showAddress(lat,address,j)
{
	j+=1;
	map = new GMap2(document.getElementById("map_canvas"));
	geocoder = new GClientGeocoder();
	if (geocoder) {
	geocoder.getLatLng(lat, function(point){
		t=lat.split(",");
		var la =  t[0] ;
		var lo =  t[1] ;
		/*la = la.toFixed(7);
		lo = lo.toFixed(7);*/
		var point1 = new GLatLng(la , lo);
		map.setCenter(point1 , 15);
		var blueIcon = new GIcon(G_DEFAULT_ICON);
		blueIcon.iconSize=new GSize(16,16);
		blueIcon.image = "http://www.domaintesting.com.php5-6.dfw1-1.websitetestlink.com/ssassociates/tab/"+j+".jpg";
		blueIcon.shadow=null;
		blueIcon.iconAnchor= new GPoint(8,8);
		markerOptions = { icon:blueIcon };
		var marker = new GMarker(point1, markerOptions);
		map.addOverlay(marker);
		GEvent.addListener(marker, "mouseover", function() {
		marker.openInfoWindowHtml('<div style="width:250px;" class="search-result-thumbtxt" >'+address+'</div>');
	});
	}
	);
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GScaleControl());
	map.addControl(new GOverviewMapControl());
	}
	if(j==mylocationlati.length-2)
	{
	jsWaitForDelay(1000);
	}
} 
	
function movecenter(lat, html)
{
	t = lat.split(",");
	var lat = parseFloat(t[0]);
	var long = parseFloat(t[1]);
	//var point = new GLatLng(la , lo);
	document.getElementById('map_canvas').scrollIntoView(); 
	//map.panTo(point);	
	map.setCenter(new GLatLng(lat,long));
	var point = new GLatLng(lat,long);
	var marker1 = new GMarker(point);
	map.addOverlay(marker1);
	marker1.openInfoWindowHtml(html);
	map.setCenter(new GLatLng(lat,long))
	
	var blueIcon = new GIcon(G_DEFAULT_ICON);
	blueIcon.iconSize=new GSize(16,16);
	blueIcon.image = "tab/"+j+".jpg";
	blueIcon.shadow=null;
	blueIcon.iconAnchor= new GPoint(8,8);
}
	
function jsWaitForDelay(delay) 
{    
	var startTime = new Date();    
	var endTime = null;    
	do {        
	endTime = new Date();    
	} while ((endTime - startTime) < delay);
}

	
	
function loadScript() 
{
	var headid= document.getElementsByTagName("head")[0];
	if(mapflag==0)
	{
	var script = document.createElement("script");
	script.type = "text/javascript";
	script.src = "http://maps.google.com/maps?file=api&v=2&key=ABQIAAAA7YwrqDxfwCT5uYmjXB76BxSJcg9DAQLKz0x_C0tfzgfxWATPxxTQ2An0RbzicCTyHkObJ-yNFMgqkw&async=2&callback=initialize";
	headid.appendChild(script);
	mapflag=1;
	}
}


/* This is tested my Own function . I will Use it when ever i want. You are requested not to delete these function*/
function get(obj1, searchtype)
{
	obj=obj1.form;
	var URL;
	var getstr = "?";
	for (i=0; i<obj.elements.length; i++)
	{
		if (obj.elements[i].tagName == "INPUT")
		{
			if (obj.elements[i].type == "text")
			{
				getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
			}
			if (obj.elements[i].type == "checkbox")
			{
				if(obj.elements[i].checked)
				{
					getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
				}
				else
				{
					getstr += obj.elements[i].name + "=&";
				}
			}
			if (obj.elements[i].type == "radio")
			{
				if (obj.elements[i].checked)
				{
					getstr += obj.elements[i].name + "=" + obj.elements[i].value + "&";
				}
			}
		}   
		if (obj.elements[i].tagName == "SELECT")
		{
			var sel = obj.elements[i];
			getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
		}
	}
	getstr+="SEARCH_TYPE="+searchtype;
	if(mapload==0)
	{
		searchdisplay('searchcontainer', getstr , 'prosearch.php' , 'prosearchresult.php');
	}
	else
	{
		searchdisplay('PROPERT', getstr , 'prosearchresult.php' , 'prosearchresult.php');
	}
	//alert(getstr); return false;
	/*
	if(searchtype=='searchbylist')
	{
		URL ='listsearchresults.php'+getstr;// , 'prosearch.php' , 'prosearchresult.php');
	}
	if(searchtype=='searchbymap')
	{
		//URL = 'mapsearchresults.php'+getstr;
		searchdisplay('PROPERT', getstr , 'prosearchresult.php' , 'prosearchresult.php');
	}
	//alert(URL);
	*/
}




function hasClass(ele,cls) 
{
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) 
{
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) 
{
	if (hasClass(ele,cls)) 
	{
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}
  
     /* call the functions
      addClass(document.getElementById("test"), "test");
      removeClass(document.getElementById("test"), "test")
      if(hasClass(document.getElementById("test"), "test")){//do something};*/
	  
	  
/*----------------------------------Property Search----------------------------------*/
function propertytab(str, tab, classtag) 
 {
    aObj = document.getElementById(str).getElementsByTagName('a'); 
  	for(i=0;i<aObj.length;i++) 
  		{
			if(aObj[i].rel==tab.rel)
    			{
					aObj[i].className=classtag;
					document.getElementById(tab.rel).style.display='BLOCK';
    			}
			else
				{
					removeClass(aObj[i],classtag);
					document.getElementById(aObj[i].rel).style.display='NONE';
				}
     	}
}
/****************************************** cookie********************************************/
function getExpDate(days, hours, minutes) {
    var expDate = new Date();
    if (typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
        expDate.setDate(expDate.getDate() + parseInt(days));
        expDate.setHours(expDate.getHours() + parseInt(hours));
        expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
        return expDate.toGMTString();
    }
}

// utility function called by getCookie()
function getCookieVal(offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) {
        endstr = document.cookie.length;
    }
    return unescape(document.cookie.substring(offset, endstr));
}

// primary function to retrieve cookie by name
function getCookie(name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) {
            return getCookieVal(j);
        }
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break; 
    }
    return null;
}

// store cookie value with optional details as needed
function setCookie(name, value, expires, path, domain, secure) {
    document.cookie = name + "=" + escape (value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}
// remove the cookie by setting ancient expiration date
function deleteCookie(name,path,domain){
	if (getCookie(name)) {
	document.cookie = name + "=" +
	((path) ? "; path=" + path : "") +
	((domain) ? "; domain=" + domain : "") +
	"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
function encode64(input) {
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;
	do {
		chr1 = input.charCodeAt(i++);
		chr2 = input.charCodeAt(i++);
		chr3 = input.charCodeAt(i++);
		
		enc1 = chr1 >> 2;
		enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
		enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
		enc4 = chr3 & 63;
		if (isNaN(chr2))
		{
		enc3 = enc4 = 64;
		} else if (isNaN(chr3)) {
		enc4 = 64;
		}
		output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 
		keyStr.charAt(enc3) + keyStr.charAt(enc4);
	} while (i < input.length);
	return output;
}
 
function decode64(input)
{
	var output = "";
	var chr1, chr2, chr3;
	var enc1, enc2, enc3, enc4;
	var i = 0;
	// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
	input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
	do {
	enc1 = keyStr.indexOf(input.charAt(i++));
	enc2 = keyStr.indexOf(input.charAt(i++));
	enc3 = keyStr.indexOf(input.charAt(i++));
	enc4 = keyStr.indexOf(input.charAt(i++));
	chr1 = (enc1 << 2) | (enc2 >> 4);
	chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
	chr3 = ((enc3 & 3) << 6) | enc4;
	output = output + String.fromCharCode(chr1);
	if (enc3 != 64) {
	output = output + String.fromCharCode(chr2);
	}
	if (enc4 != 64) {
	output = output + String.fromCharCode(chr3);
	}
	} while (i < input.length);
	return output;
}
Array.prototype.clean = function(to_delete)
{
	var a;
	for (a = 0; a < this.length; a++)
	{
	if (this[a] == to_delete)
	{         
	this.splice(a, 1);
	a--;
	}
	}
	return this;
};

function submitenter(myfield,e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;
	if (keycode == 13) { fastsearchresult(myfield,'search.php');return false;}
	else return true;
}
function selectclass(tab_id)
{
	document.getElementById('residential_li').className="";
	document.getElementById('residential_tab_data').style.display="none";
	document.getElementById('commercial_li').className="";
	document.getElementById('commercial_tab_data').style.display="none";
	document.getElementById('industrial_li').className="";
	document.getElementById('industrial_tab_data').style.display="none";
	
	document.getElementById(tab_id+"_li").className="active";
	document.getElementById(tab_id+"_tab_data").style.display="block";
	$("input#projectType").val(tab_id);
	var projectType = $("input#projectType").val();
}

function setPropertyLocation(CityId)
{
	$("input#projectCity").val(CityId);
	var projectType = $("input#projectType").val();
	var promoter = $("input#promoter").val();
	var projectCity = $("input#projectCity").val();
	
	$("#residential_tab_data").html('');	
	$("#commercial_tab_data").html('');	
	$("#industrial_tab_data").html('');	
	$("#"+projectType+"_tab_data").html('<img src="http://localhost/ssassociates/images/loading.gif">');
	
	innertest = displayMsg('get-data-for-promoter.php?PRO_ID='+promoter+'&projectType='+projectType+'&projectCity='+projectCity);
	$("#"+projectType+"_tab_data").html(innertest);	
}
function setPropertyLocationProject(CityId)
{
	$("input#projectCity").val(CityId);
	var projectType = $("input#projectType").val();
	var promoter = $("input#promoter").val();
	var projectCity = $("input#projectCity").val();
	
	$("#residential_tab_data").html('');	
	$("#commercial_tab_data").html('');	
	$("#industrial_tab_data").html('');	
	$("#"+projectType+"_tab_data").html('<img src="images/loading.gif">');
	//alert(projectCity)
	//innertest = displayMsg('get-data-for-promoter.php?PRO_ID='+promoter+'&projectType='+projectType+'&projectCity='+projectCity);
	//innertest = displayMsg('get-data-for-project.php?PRO_ID='+promoter+'&projectType='+projectType+'&projectCity='+projectCity+'&page='+page);
	//$("#"+projectType+"_tab_data").html(innertest);	
}
function setPropertyType(tab_id)
{
	document.getElementById('residential_li').className="";
	document.getElementById('residential_tab_data').style.display="none";
	document.getElementById('commercial_li').className="";
	document.getElementById('commercial_tab_data').style.display="none";
	document.getElementById('industrial_li').className="";
	document.getElementById('industrial_tab_data').style.display="none";
	document.getElementById(tab_id+"_li").className="active";
	document.getElementById(tab_id+"_tab_data").style.display="block";
	$("#residential_tab_data").html('');	
	$("#commercial_tab_data").html('');	
	$("#industrial_tab_data").html('');	
	$("#"+tab_id+"_tab_data").html('<img src="http://localhost/ssassociates/images/loading.gif">');
	
	$("input#projectType").val(tab_id);
	var projectType = $("input#projectType").val();
	var promoter = $("input#promoter").val();
	var projectCity = $("input#projectCity").val();
	
	innertest = displayMsg('get-data-for-promoter.php?PRO_ID='+promoter+'&projectType='+projectType+'&projectCity='+projectCity);
	$("#"+tab_id+"_tab_data").html(innertest);	
	
	innertest2 = displayMsg('get-data-for-promoter-city.php?PRO_ID='+promoter+'&projectType='+projectType+'&projectCity='+projectCity);
	$("#CITY_TAB").html(innertest2);
	
	return false;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function displayMsg(url)
{
	var html = $.ajax({
		url: url,
		async: false
	}).responseText;
	return jQuery.trim(html);
}
function toRedirect(url)
{
	/*if(confirm('Do you really want to nevigate:\n'+url))
	{*/
		setTimeout(function(){
			$.unblockUI({
			onUnblock: function(){ window.location = url;}
			});
		},1000);
	/*}*/
}
function ChangeValue(obj)
{	
	var select = $('#maxprice');
	var options = select.attr('options');
	$('option', select).remove();
	var selectedOption = '50';
	if(obj==0){var newOptions = {'':'Max Price', '20':'20 Lacs', '30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==1){var newOptions = {'20':'20 Lacs', '30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==2){var newOptions = {'30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==3){var newOptions = {'40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==4){var newOptions = {'50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==5){var newOptions = {'60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==6){var newOptions = {'75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==7){var newOptions = {'100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==8){var newOptions = {'150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==9){var newOptions = {'200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==10){var newOptions = {'300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==11){var newOptions = {'500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==12){var newOptions = {'1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==13){var newOptions = {'':'Max Price'};}
	if(obj==14){var newOptions = {'':'Max Price'};}
	
	if((obj>=0) && (obj<15))
	{
		$("#maxprice").attr('disabled', '');
		if((obj==0) || (obj=='14.99')){$("#maxprice").attr('disabled', 'disabled');}
		$.each(newOptions, function(val, text){
		options[options.length] = new Option(text, val);
		});
	}
	else
	{
		$("#maxprice").attr('disabled', 'disabled');
	}
	select.val(selectedOption);
}
function emptyTxt(id)
{
    if(document.getElementById(id).value == "Keywords"){
        document.getElementById(id).value="";
    }
}
function fillTxt(id)
{
    if(document.getElementById(id).value == ""){
        document.getElementById(id).value = "Keywords";
    }
}

function emptyTxtEmail(id){if(document.getElementById(id).value == "Enter your Email address"){document.getElementById(id).value="";}}
function fillTxtEmail(id){if(document.getElementById(id).value == ""){document.getElementById(id).value = "Enter your Email address";}}

function emptyTxtCode(id){if(document.getElementById(id).value == "Security code"){document.getElementById(id).value="";}}
function fillTxtCode(id){if(document.getElementById(id).value == ""){document.getElementById(id).value = "Security code";}}

function selectPropertyDisplay(tab_id)
{
	document.getElementById('residential_li').className="";
	document.getElementById('residential_tab_data').style.display="none";
	document.getElementById('commercial_li').className="";
	document.getElementById('commercial_tab_data').style.display="none";
	document.getElementById('industrial_li').className="";
	document.getElementById('industrial_tab_data').style.display="none";
	
	
	document.getElementById(tab_id+"_li").className="active";
	document.getElementById(tab_id+"_tab_data").style.display="block";
	$("input#projectType").val(tab_id);
	var projectType = $("input#projectType").val();
}
function ChangeValue(obj)
{	
	var select = $('#maxprice');
	var options = select.attr('options');
	$('option', select).remove();
	var selectedOption = '50';
	if(obj==0){var newOptions = {'':'Max Price', '20':'20 Lacs', '30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==1){var newOptions = {'20':'20 Lacs', '30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==2){var newOptions = {'30':'30 Lacs', '40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==3){var newOptions = {'40':'40 Lacs', '50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==4){var newOptions = {'50':'50 Lacs', '60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==5){var newOptions = {'60':'60 Lacs', '75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==6){var newOptions = {'75':'75 Lacs', '100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==7){var newOptions = {'100':'1 Crore', '150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==8){var newOptions = {'150':'1.5 Crore', '200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==9){var newOptions = {'200':'2 Crore', '300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==10){var newOptions = {'300':'3 Crore', '500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==11){var newOptions = {'500':'5 Crore', '1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==12){var newOptions = {'1000':'10 Crore', '2000':'>20 Crore'};}
	if(obj==13){var newOptions = {'':'Max Price'};}
	if(obj==14){var newOptions = {'':'Max Price'};}
	if(obj==0)
	{
		$("#maxprice").attr('disabled', 'disabled');
	}
	if((obj>=0) && (obj<14))
	{
		$("#maxprice").attr('disabled', '');
		if((obj==0) || (obj==14)){$("#maxprice").attr('disabled', 'disabled');}
		$.each(newOptions, function(val, text){
		options[options.length] = new Option(text, val);
		});
	}
	else
	{
		$("#maxprice").attr('disabled', 'disabled');
	}
	select.val(selectedOption);
}
function CheckMinValue(obj)
{
	if(obj==2000)
	{
		$("#minprice").attr('disabled', 'disabled');
	}
	else
	{
		$("#minprice").attr('disabled', '');
	}
}
function  redirect_serach_index()
{
	var data1 = $("#prosearch").serialize();
	var projectType = $("select#projectTypeSearch").val();
	var projectCity = $("select#projectCitySearch").val();
	
	if(projectType==""){alert('Please Select Property Type.');$("select#projectTypeSearch").focus();return false; }
	if(projectCity==""){alert('Please Select Property City.');$("select#projectCitySearch").focus();return false; }
	
	document.prosearch.action='prosearch-intermediate.php'
	document.prosearch.method='get';
	document.prosearch.submit();
	
}
function redirect_serach()
{
	var data1 = $("#prosearch").serialize();
	var projectType = $("select#projectTypeSearch").val();
	var projectCity = $("select#projectCitySearch").val();
	if(projectType==""){alert('Please Select Property Type.');$("select#projectTypeSearch").focus();return false; }
	if(projectCity==""){alert('Please Select Property City.');$("select#projectCitySearch").focus();return false; }
	
	/*if(document.prosearch.view.value=='searchbylist'){alert('LIST')
	document.prosearch.action='searchresults.php'
	}
	else if(document.prosearch.view.value=='searchbymap'){alert('MAP')
	document.prosearch.action='search-by-map.php'
	}*/
	document.prosearch.method='get';
	document.prosearch.submit();
}
function submitenterForm()
{
	var data1 = $("#fastsearch").serialize();
	var searchvalue = $("input#searchvalue").val();
	if(searchvalue==""){alert('Please Enter Search Value.');$("input#searchvalue").focus();return false; }
	document.fastsearch.method='get';
	document.fastsearch.submit();
}
function keywords_serach()
{
	var data1 = $("#keySearch").serialize();
	var searchvalue = document.keySearch.idkeywords.value;
	if((searchvalue=='')||(searchvalue=='Search by Keywords') || ((searchvalue.length<3))){$("input#idkeywords").val(''); alert('Please Enter Search Value.');$("input#searchvalue").focus();return false; }
	document.fastsearch.method='get';
	document.fastsearch.submit();
}
function sleep(ms)
{
	var dt = new Date();
	dt.setTime(dt.getTime() + ms);
	while (new Date().getTime() < dt.getTime());
}
function display_newsletter()
{
	document.getElementById('newsletter_email').value='';
	document.getElementById('cMessage2').innerHTML='';
	if(document.getElementById('newsletter').style.display=='none')
	{
		document.getElementById('newsletter').style.display='block';
		document.getElementById('newsletter_email').focus();
		document.getElementById('newsletter_email').value='Enter your Email address';
		document.getElementById('vcodenews').value='Security code';
		return false;
	}
	else
	{
		document.getElementById('newsletter').style.display='none';
		return false;
	}
}
function SignupNewsLetter()
{
	var emailID = $('input#newsletter_email').val();
	var vcode = $('input#vcodenews').val();
	if((emailID=="")|| (emailID=="Enter your Email address")){alert('Please Enter Email.');$("input#newsletter_email").focus();return false; }
	if(vcode==""){alert('Please Enter security code.');$("input#vcodenews").focus();return false; }
	if(emailID!="")
	{
		if(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(emailID))
		{
		}
		else
		{
			alert('Invalid Email Id.');return false; 
		}
	}
	else
	{
		alert('Please Enter Email Id.');return false; 
	}
	//alert('subscribe_newsletter.php?emailID='+emailID); 
	$.ajax({
		type: "POST", 
		url: "subscribe_newsletter.php",
		data: "emailID="+emailID+"&vcode="+vcode, 
		success: function(msg){
			//alert(msg)
			var arr = msg.split("||");
			var refmsg = arr[0];
			var emsg   = arr[1];
			if(refmsg=='0')
			{
				$("#cMessage2").html(emsg);
			}
			if(refmsg=='1')
			{
				$("#cMessage2").html(emsg);
				sleep(1500);
				document.getElementById('newsletter_email').value='';
				setTimeout('document.getElementById(\'newsletter\').style.display=\'none\'',10000);
				document.getElementById('cMessage2').value='';
			}
		}
	});
}
