//--------------------------------Display the Panel of Extra Classified Field---------------------------------------------//

function select_panel(property_id,property_name)
{
	//alert("inside panel");
		var status_id=document.getElementById("status").value;
		//alert("inside panel:1:"+status_id);

		var property_id=document.getElementById("class_type").value;
		//alert("inside panel:2:"+property_id);

		var Estate_ID=new Array("buy_sell_house","buy_sell_studio_commercial","buy_sell_farm_agri_land","rent_house","rent_accom_commercial","lease_house","lease_studio_commercial","lease_agri_farm_land","rent_room");
		var x=0;
		
		
			//alert("inside panel:3");

//----------------------------------BUY and SELL Panel of Terraced,Detached,Accomadation and Flate--------------------------//		
			if((status_id==2 || status_id==3) && (property_id==1 || property_id==2 || property_id==3 || property_id==4 || property_id==5))
			{
			
			
			
				for(x=0;x<9;x++){
				if(x==0){
						document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
						document.getElementById(Estate_ID[x]).style.display='none';
					}
				}
			
			}
//----------------------------------Renting the Panel of Terraced,Detached,Accomadation and Flate---------------------------//			
			else if((status_id==4) && (property_id==1 || property_id==2 || property_id==3 || property_id==4 || property_id==5))
			{
		
				for(x=0;x<9;x++){
				if(x==3){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
			}
//-----------------------------LEASE the Panle of Terraced,Detached ,Semi Detached ,Accomadation and Flate---------------//			
			else if((status_id==5) && (property_id==1 || property_id==2 || property_id==3 || property_id==4 || property_id==5))
			{
		
		
		for(x=0;x<9;x++){
				if(x==5){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
		
			}
//-----------------------------BUY and SELL Panel of Farm, Agricultural, Plots & Lands--------------------------------//			
			else if((status_id==2 || status_id==3) && (property_id==9 || property_id==11 || property_id==12))
			{
		
				for(x=0;x<9;x++){
				if(x==2){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
			}
//------------------------------BUY and SELL Panel of Commercial Building------------------------------------------------//			
			else if((status_id==2 || status_id==3) && (property_id==10 || property_id==8 || property_id==13|| property_id==14|| property_id==15|| property_id==16|| property_id==17|| property_id==18|| property_id==19|| property_id==20 || property_id==21 || property_id==22 || property_id==23))
			{
				for(x=0;x<9;x++){
				if(x==1){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
			}
//--------------------------------Renting Panel of  the Commercial Building----------------------------------------------------//
			else if((status_id==4) && (property_id==10 || property_id==6 || property_id==8 || property_id==13|| property_id==14|| property_id==15|| property_id==16|| property_id==17|| property_id==18|| property_id==19|| property_id==20 || property_id==21 || property_id==22 || property_id==23))
			{
				for(x=0;x<9;x++){
				if(x==4){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
			}
//--------------------------------Renting Panel of  the Room----------------------------------------------------//
			else if((status_id==4) && (property_id==7))
			{
				for(x=0;x<9;x++){
				if(x==8){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
				
			}			
//-------------------------------lease Panel of the Commercial Building--------------------------------------------------------//
			else if((status_id==5) && (property_id==10 || property_id==8 || property_id==13|| property_id==14|| property_id==15|| property_id==16|| property_id==17|| property_id==18|| property_id==19|| property_id==20 || property_id==21 || property_id==22 || property_id==23))
			{
				for(x=0;x<9;x++){
				if(x==6){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
		
				
			}



//---------------------------------------Lease Panel of Agricultural, Farm and Lands----------------------------------------//	
	else if((status_id==5) && (property_id==9 || property_id==11 || property_id==12))
	{
		
		
		for(x=0;x<9;x++){
				if(x==7){
							document.getElementById(Estate_ID[x]).style.display='block';
						}
				else{
							document.getElementById(Estate_ID[x]).style.display='none';
					}
			}
	
	}

	else
	{
		
		var x=0;
		for(x=0;x<9;x++)
		{
			
			document.getElementById(Estate_ID[x]).style.display='none';
		}
		
}
	
}
//-------------------------------------Non Appear of Panel of Property---------------------------------------------------//
function None_Edit()
{
	
		document.getElementById("buy_sell_house").style.display='none';
		document.getElementById("buy_sell_studio_commercial").style.display='none';
		document.getElementById("buy_sell_farm_agri_land").style.display='none';
		document.getElementById("rent_house").style.display='none';
		document.getElementById("rent_accom_commercial").style.display='none';
		document.getElementById("lease_house").style.display='none';
		document.getElementById("lease_studio_commercial").style.display='none';
		document.getElementById("lease_agri_farm_land").style.display='none';
		document.getElementById("rent_room").style.display='none';
		
		
}
//------------------------------------Null Field List in Town List Box---------------------------------------------------//
function dell_all(data1,data2)
{
	
	for(i=data1-1;i>0;i--)
	{
	data2.remove(i);
	}
}
//-----------------------------------Initializing the Color And submit Button Activation---------------------------------//
function initiate()
{
	document.getElementById("searchinput").disabled = true;
	document.getElementById("searchinput").style.background = "#CCC";
}
//-----------------------------------Filling the County List in County List Box-----------------------------------------//
function fill_county(str,st2,placeid)
{	
	
	var len=document.getElementById("town").length;
	List_level=document.first.town;
	dell_all(len,List_level);
	var alpha="a";
	common(str,st2,alpha);
	document.getElementById(placeid).value=str;   
	
}
//----------------------------------Filling the Town List in Town List Box---------------------------------------------//
function fill_town(str,st2,placeid)
{	
	var alpha="b";
	common(str,st2,alpha);
	document.getElementById(placeid).value=str;  
}
//----------------------------------Place id in Hidden Field----------------------------------------------------------//
function setPlaceId(value,placeid)
{
	
	document.getElementById(placeid).value=value;       
}
function sel_status(str,st2,dirid)
{
	
	
	var alpha="c";
	common(str,st2,alpha);
	document.getElementById(dirid).value=str;
	None_Edit();

}
//-----------------------------------Ajax Calling for fill the County and Town---------------------------------------//
function common(str,st2,alpha)
{
	
	xmlHttp=GetXmlHttpObject()
	if(xmlHttp==null)
    {
     	alert ("Browser does not support HTTP Request")
     	return;
	}
	
	var url="ajax_php_trans.php";
	url=url+"?"+alpha+"="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);	
	var mycombo = document.getElementById(st2);
	mycombo.options.length = 0;
	function stateChanged() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 			{ 
				var myString=xmlHttp.responseText.replace(/^\s*|\s*$/g,"");
				
				var mySplitResult = myString.split(";");
				if(alpha=="a" || alpha=="b" || alpha=="c")
					{
						if(myString == "No Directory Available" )
							{
								
							}
						else
							{
							for(i = 0; i < mySplitResult.length-1; i++)
							{
    							var opt = document.createElement("option");
    							document.getElementById(st2).options.add(opt);       
    							var idval=mySplitResult[i].split(":");
    							opt.text = idval[1];
    							opt.value = idval[0];
							}
							}
					}
					
				
			}
		}
}
//-------------------------------------------Calling the Object Function---------------------------------------------//
var xmlHttp;
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
xmlHttp=new XMLHttpRequest();
}
catch(e)
{
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
 //---------------------------------Dynamically Fill the Max Amount with Min Amount Click----------------------------//
 function fill_Max_Amount(str1,str2)
{
	
	
	xmlHttp=GetXmlHttpObject()
	if(xmlHttp==null)
    {
     	alert ("Browser does not support HTTP Request")
     	return;
	}
	
	var url="ajax_php_trans.php";
	url=url+"?min="+str1;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("POST",url,true);
	xmlHttp.send(null);	
	var mycombo = document.getElementById(str2);
	mycombo.options.length = 0;
			function stateChanged() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 			{ 
				var myString=xmlHttp.responseText.replace(/^\s*|\s*$/g,"");
				//alert(myString);
				var mySplitResult = myString.split(";");
				for(i = 0; i < mySplitResult.length-1;i++)
							{
    							var opt = document.createElement("option");
    							document.getElementById(str2).options.add(opt);       
    							var idval=mySplitResult[i].split(":");
    							opt.text = idval[1];
    							opt.value = idval[0];
							}
			}
		}
}

  


function showSendButton(id){
		
	
 	if(isEmail(document.getElementById("email"+id).value) & document.getElementById("email"+id).value !="" &document.getElementById("message"+id).value !="" & document.getElementById("subject"+id).value !="")
        {document.getElementById("send"+id).disabled = false;}else{document.getElementById("send"+id).disabled = true;}

}
