var sendUrl='';

// Functionality for search property according to property id

function searchResultForId(){

xmlhttpPostId();
	return true;
}

function xmlhttpPostId(){
    var proid=document.getElementById('proid').value;
    var hidRes_com = document.getElementById('hidRes_com').value;  
    document.getElementById("searchmain").innerHTML = "<FONT SIZE='2' COLOR='red'>Sending Request...<img src='manage/images/ajax-loader.gif' border='0'></font>";
    var url ="searchforid.php";
    var posData = "?propertyid="+proid+"&type="+hidRes_com;;
   
   if (window.XMLHttpRequest) 
    { 
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
        {
            http_request.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
	sendUrl=url + posData
    http_request.onreadystatechange = function() { getsearch(http_request); };
    http_request.open('GET', url + posData, true);
    http_request.send(null);

	
}

//********************************************************************************

function searchResult(val1,val2,val3,val4,val5)
{ 
	xmlhttpPost(val1,val2,val3,val4,val5);
	return true;
}
function xmlhttpPost(val1,val2,val3,val4,val5) 
{    
	var checked = new Array('1', '2', '3', '4');
	var selection = document.frmsearch.listing;
	for (i=0; i<selection.length; i++)
 	{
  		if (selection[i].checked == true)
      	{
  			listing=selection[i].value;
  		}
  		else
  		if ((typeof listing =='undefined')||(typeof listing =='object') )
  		{
      		listing="";
  		}
  		else
  		{

  		}
  }
    

if ((typeof val1 !='undefined') || (typeof val2 !='undefined') || (typeof val3 !='undefined'))
{
	var page_pri=val1;
	var pg=val2;
	var order=val3;  
}
else
{    
	var page_pri="";
	var pg="";
	var order="";
}
    var cat=document.getElementById('cat').value;
	if(val4=='footer')
	cat=val5;
	//alert(cat);
    var city1=document.getElementById('city');
	var ll=city1.length;
	
	var city='';
	for(var i=0;i<ll;i++)
	{	if(city1.options[i].selected==true)
		city=city+','+city1.options[i].value;
		}
    var price=document.getElementById('price').value;       
    var price2=document.getElementById('price2').value;  
    if (typeof cat =='undefined')
    {
    	cat="";
    }
    if (typeof city =='undefined')
    {
    	city="";
    }
    if (typeof price =='undefined')
    {
    	price="";
    }
    if (typeof price2 =='undefined')
    {
    	price2="";
    }
	var hidRes_com = document.getElementById('hidRes_com').value;
    var state=document.getElementById('state').value;       
    document.getElementById("searchmain").innerHTML = "<FONT SIZE='2' COLOR='red'>Sending Request...<img src='manage/images/ajax-loader.gif' border='0'></font>";
	//document.getElementById("searchLoader").innerHTML = "<FONT SIZE='2' COLOR='red'>Sending Request...<img src='manage/images/ajax-loader.gif' border='0'></font>";
    var url ="search.php";
    var posData = "?cat=" + cat + "&state=" + state + "&price=" + price  + "&price2=" + price2 +  "&page_pri=" + page_pri +   "&pg=" + pg + "&listing=" + listing + "&city=" + city + "&order=" + order+"&ptype="+ hidRes_com+"&nochace="+Math.random();
   //alert(posData);
   if (window.XMLHttpRequest) 
    { 
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
        {
            http_request.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
	sendUrl=url + posData
    http_request.onreadystatechange = function() { getsearch(http_request); };
    http_request.open('GET', url + posData, true);
    http_request.send(null);
}
function searchResultFooter(val1,val2)
{ //alert(val1);
	xmlhttpPostFooter(val1,val2);
	return true;
}
function xmlhttpPostFooter(val1,val2) 
{    

    
   


      listing="";
  
    


	var page_pri="";
	var pg="";
	var order="";
	if(val1=='footer')
	cat=val2;
	//alert(cat);
    
    if (typeof cat =='undefined')
    {
    	cat="";
    }
    if (typeof city =='undefined')
    {
    	city="";
    }
    if (typeof price =='undefined')
    {
    	price="";
    }
    if (typeof price2 =='undefined')
    {
    	price2="";
    }

    var state='';       
    document.getElementById("searchmain").innerHTML = "<FONT SIZE='2' COLOR='red'>Sending Request...<img src='manage/images/ajax-loader.gif' border='0'></font>";
    var url ="search.php";
    var posData = "?cat=" + cat + "&state=" + state + "&price=" + price  + "&price2=" + price2 +  "&page_pri=" + page_pri +   "&pg=" + pg + "&listing=" + listing + "&city=" + city + "&order=" + order+"&nochace="+Math.random();
   
   if (window.XMLHttpRequest) 
    { 
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) 
        {
            http_request.overrideMimeType('text/xml');
        }
    } 
    else if (window.ActiveXObject) 
    { // IE
        try 
        {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
	sendUrl=url + posData
    http_request.onreadystatechange = function() { getsearch(http_request); };
    http_request.open('GET', url + posData, true);
    http_request.send(null);
}
function getsearch(http_request){
   if (http_request.readyState == 4) {
        if (http_request.status == 200)
        {
            resText = http_request.responseText;
            //alert(resText);
            //document.getElementById("searchmain").innerHTML =  sendUrl+"<br>"+resText;
			document.getElementById("searchmain").innerHTML =  resText;
          //  alert("Hello");
             document.getElementById("searchmain2").innerHTML =  "";
			  document.getElementById("searchmain3").innerHTML =  "";
        } else {
            document.getElementById("searchmain").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
            document.getElementById("searchmain").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
        }
    }
        }

function sendRequestPrice(val) {
	// Open PHP script for requests
	//alert ("Helllllooooooooo");

	var url ="price.php";
	var posData = "?type=" + val+"&nochace="+Math.random();
	//alert (posData);
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	//alert(url + posData);
	http_request.onreadystatechange = function() { sendrequestres(http_request); };
	http_request.open('GET', url + posData, true);
	http_request.send(null);
}



function sendrequestres(http_request){

	if (http_request.readyState == 4) {
		if (http_request.status == 200)
		{
			resText = http_request.responseText;
			//alert(resText);

			document.getElementById("Price").innerHTML = resText;
			//var resText1="name="price""+"id="price"";
			var resText1=resText;
			resText1=resText1.replace("name=\"price\"","name=\"price2\"");
			resText1=resText1.replace("id=\"price\"","id=\"price2\"");
			//alert(resText1);
			document.getElementById("Price2").innerHTML = resText1;
		} else {
			document.getElementById("Price").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
			document.getElementById("Price2").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}
}


// Set path to PHP script
var phpscript = 'city.php';

function createRequestObject() {
	var req;
	if(window.XMLHttpRequest){
		// Firefox, Safari, Opera...
		req = new XMLHttpRequest();
	} else if(window.ActiveXObject) {
		// Internet Explorer 5+
		req = new ActiveXObject("Microsoft.XMLHTTP");
	} else {
		// There is an error creating the object,
		// just as an old browser is being used.
		alert('There was a problem creating the XMLHttpRequest object');
	}
	return req;
}

// Make the XMLHttpRequest object
var http = createRequestObject();

function sendRequestGet(act) {
	// Open PHP script for requests
	http.open('get', phpscript+'?act='+act);
	http.onreadystatechange = handleResponseGet;
	http.send(null);
}

function sendRequestPost(state) {
	// Open PHP script for requests
	//alert("state);
	
	var url ="city.php";
	var posData = "?state=" + state+"&nochace="+Math.random();
	//alert (posData);
	if (window.XMLHttpRequest)
	{
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType)
		{
			http_request.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	http_request.onreadystatechange = function() { sendrequest(http_request); };
	http_request.open('GET', url + posData, true);
	http_request.send(null);
}



function sendrequest(http_request){

	if (http_request.readyState == 4) {
		if (http_request.status == 200)
		{
			resText = http_request.responseText;
			//alert(resText);
			document.getElementById("ajaxTest2").innerHTML = resText;
		} else {
			document.getElementById("ajaxtest2").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}
}

function handleResponseGet() {
	if(http.readyState == 4 && http.status == 200){
		// Text returned from PHP script
		var response = http.responseText;
		if(response) {
			// Update ajaxTest content
			document.getElementById("ajaxTest").innerHTML = response;
		}
	}
}
function handleResponsePost() {
	if(http.readyState == 4 && http.status == 200){
		// Text returned from PHP script
		var response = http.responseText;
		if(response) {
			// Update ajaxTest2 content
			document.getElementById("ajaxTest2").innerHTML = response;
		}

	}
}
function loadCategory(val) 
{
	var url2 ="category.php";
	var posData2 = "?type=" + val+"&nochace="+Math.random();
	//alert (posData2);
	if (window.XMLHttpRequest)
	{
		http_request2 = new XMLHttpRequest();
		if (http_request2.overrideMimeType)
		{
			http_request2.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ 
		try
		{
			http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	//alert(url + posData);
	http_request2.onreadystatechange = function() { sendrequestresult(http_request2); };
	http_request2.open('GET', url2 + posData2, true);
	http_request2.send(null);
}
function sendrequestresult(http_request2)
{
	if (http_request2.readyState == 4) {
		if (http_request2.status == 200)
		{
			resText2 = http_request2.responseText;
			//alert(resText);

			document.getElementById("category").innerHTML = resText2;
			//var resText1="name="price""+"id="price"";
//var resText1=resText;
			//resText1=resText1.replace("price","price2");
			//document.getElementById("Price2").innerHTML = resText;
		} else {
			document.getElementById("category").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
			//document.getElementById("Price2").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}

	}

function loadSubCategory(val) {
	var url2 ="subcategory.php";
	var posData2 = "?type=" + val+"&nochace="+Math.random();
	//alert (posData2);
	if (window.XMLHttpRequest)
	{
		http_request2 = new XMLHttpRequest();
		if (http_request2.overrideMimeType)
		{
			http_request2.overrideMimeType('text/xml');
		}
	}
	else if (window.ActiveXObject)
	{ // IE
		try
		{
			http_request2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			try
			{
				http_request2 = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	http_request2.onreadystatechange = function() { sendrequestresult(http_request2); };
	http_request2.open('GET', url2 + posData2, true);
	http_request2.send(null);
	}
	function sendrequestresult(http_request2){

	if (http_request2.readyState == 4) {
		if (http_request2.status == 200)
		{
			resText2 = http_request2.responseText;
			document.getElementById("category").innerHTML = resText2;
		} else {
			document.getElementById("category").innerHTML = "<FONT SIZE='4' COLOR='red'>Query not submitted!</FONT>";
		}
	}

	}

 function textCounter(field,counter,maxlimit,linecounter) {
 	// text width//
 	var fieldWidth =  parseInt(field.offsetWidth);
 	var charcnt = field.value.length;

 	// trim the extra text
 	if (charcnt > maxlimit)
 	{
 		field.value = field.value.substring(0, maxlimit);
 	}

 	else {
 		// progress bar percentage
 		var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
 		document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
 		document.getElementById(counter).innerHTML="&nbsp;&nbsp;"+percentage+"%"
 		// color correction on style from CCFFF -> CC0000
 		setcolor(document.getElementById(counter),percentage,"background-color");
 	}
 }

 function setcolor(obj,percentage,prop){
 	obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
 }

 function check()
 {
 	if(document.form2.property_size.value=='')
 	{
 		alert('select the property available for value');
 		return false;
 	}
 }

var panes = new Array();

function setupPanes(containerId, defaultTabId) {
    // go through the DOM, find each tab-container
    // set up the panes array with named panes
    // find the max height, set tab-panes to that height
    panes[containerId] = new Array();
    var maxHeight = 0; var maxWidth = 0;
    var container = document.getElementById(containerId);
    var paneContainer = container.getElementsByTagName("div")[0];
    var paneList = paneContainer.childNodes;
    for (var i=0; i < paneList.length; i++ ) {
        var pane = paneList[i];
        if (pane.nodeType != 1) continue;
        if (pane.offsetHeight > maxHeight) maxHeight = pane.offsetHeight;
        if (pane.offsetWidth  > maxWidth ) maxWidth  = pane.offsetWidth;
        panes[containerId][pane.id] = pane;
        pane.style.display = "none";
    }
    paneContainer.style.height = maxHeight + "px";
    paneContainer.style.width  = maxWidth + "px";
    document.getElementById(defaultTabId).onclick();
}

function showPane(paneId, activeTab) {
    // make tab active class
    // hide other panes (siblings)
    // make pane visible
    //alert("hello");
    // work out which container this tab is part of. could also bounce on parent node
    for (var con in panes) {
        activeTab.blur();
        activeTab.className = "tab-active";
        if (panes[con][paneId] != null) { // tab and pane are members of this container
            var pane = document.getElementById(paneId);
            pane.style.display = "block";
            var container = document.getElementById(con);
            var tabs = container.getElementsByTagName("ul")[0];
            var tabList = tabs.getElementsByTagName("a")
            for (var i=0; i<tabList.length; i++ ) {
                var tab = tabList[i];
                if (tab != activeTab) tab.className = "tab-disabled";
            }
            for (var i in panes[con]) {
                var pane = panes[con][i];
                if (pane == undefined) continue;
                if (pane.id == paneId) continue;
                pane.style.display = "none"
            }
        }
    }
    return false;    
}
function change_background_res()
{
	document.getElementById('residential').bgColor="#D8D8D8";
	document.getElementById('commercial').bgColor="";
}
function change_background_com()
{
	document.getElementById('residential').bgColor="";
	document.getElementById('commercial').bgColor="#D8D8D8";
}
	
	function toggleDivNCR(action,divid)
	{ if(action=='show')
		{
		document.getElementById('propdesc'+divid).style.display='none';
		document.getElementById('propdescfull'+divid).style.display='block';
		}else{
				document.getElementById('propdesc'+divid).style.display='block';
				document.getElementById('propdescfull'+divid).style.display='none';

			}
	}


