// JavaScript Document
function getXMLHTTP() { //fuction to return the xml http object
		var xmlhttp=false;	
		try{
			xmlhttp=new XMLHttpRequest();
		}
		catch(e)	{		
			try{			
				xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e){
				try{
				req = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
    }
	
	
function del_record(id,tblname,uniq_id) {		
		//alert(tblname);
		if(confirm('Are you really delete?'))
		{
				var strURL="../dropdownfile/find_delete_manage_level.php?id="+id+"&tb_name_1="+tblname+"&un_id="+uniq_id;
				
				//alert(strURL);
	
				var req = getXMLHTTP();
				
				
				
				
				
				if (req) {
					
					req.onreadystatechange = function() {
						if (req.readyState == 4) {
							// only if "OK"
							if (req.status == 200) {						
								document.getElementById("delrecord_"+id).innerHTML=req.responseText;	
													
							} else {
								alert("There was a problem while using XMLHTTP:\n" + req.statusText);
							}
						}				
					}			
					req.open("GET", strURL, true);
					req.send(null);
				}	
				
			}		
	}
	
	// change status 
function change_status(id,sta,tblname,auto_id) {		
		
		var strURL="../dropdownfile/change_status.php?id="+id+"&sta="+sta+"&tb_name="+tblname+"&auto_1="+auto_id;
	
		// alert(strURL);
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById("changestatus_"+id).innerHTML=req.responseText;	
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}
	
// change status with mail
function change_status_member(id,sta,tblname,auto_id) {		
		
		var strURL="../dropdownfile/change_status_member.php?id="+id+"&sta="+sta+"&tb_name="+tblname+"&auto_1="+auto_id;
	
		// alert(strURL);
		var req = getXMLHTTP();
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						document.getElementById("changestatus_"+id).innerHTML=req.responseText;	
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}	
	
// get state
function getState(countryId) 
	{		
		var strURL="../dropdownfile/findState.php?country="+countryId;
		//alert(strURL);
		var req = getXMLHTTP();
		//
		var dis="<select name='city_auto_id'><option value='' selected='selected'>--- Select City ---</option></select>";
	
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
						var t=document.getElementById('statediv').innerHTML=req.responseText;
						document.getElementById('citydiv').innerHTML=dis;
					
							
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
	}

	function getCity(countryId,stateId) {
		var strURL="../dropdownfile/findCity.php?country="+countryId+"&state="+stateId;
		var req = getXMLHTTP();
		//alert(strURL);
		
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						var t=document.getElementById('citydiv').innerHTML=req.responseText;	
						//alert(t);
						
												
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
function change()
 {
	 
		  document.getElementById('ch').innerHTML;
		  document.getElementById('ch').style.display='';
	 
 }
 
 function cd()
 {
	
	  document.getElementById('ch').innerHTML;
	  document.getElementById('ch').style.display='none';
	
 }
 
 function find_flat(flat_type) {
//alert(flat_type);
		var strURL="../dropdownfile/find_flat.php?flat_type="+flat_type;
		//alert(strURL);
		var req = getXMLHTTP();
	var own="<select name='property_ownership'><option value='' selected='selected'>--- Ownership ---</option></select>";
	var trans="<select name='find_transaction'><option value='' selected='selected'>--- Transaction ---</option></select>";
				
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('find_flat').innerHTML=req.responseText;
						document.getElementById('find_ownership').innerHTML=own;
						document.getElementById('find_transaction').innerHTML=trans;
						
						
					//document.getElementById('find_ownership').innerHTML=req.responseText;
						//document.getElementById('find_transaction').innerHTML=req.responseText;		
						
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}	
function find_owner(owner) {
//alert(owner);

		var strURL="../dropdownfile/find_ownership.php?owner="+owner;
		//var strURL="../dropdownfile/find_ownership.php?flat_type="+flat_type+"&ow="+ow;
		//alert(strURL);
		var req = getXMLHTTP();
		var trans="<select name='property_ownership'><option value='' selected='selected'>--- Transaction ---</option></select>";
	
				
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('find_ownership').innerHTML=req.responseText;
						document.getElementById('find_transaction').innerHTML=trans;
						
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}		
	
function find_trans(trans) {
//alert(trans);

		var strURL="../dropdownfile/find_trans.php?trans="+trans;
		//var strURL="../dropdownfile/find_ownership.php?flat_type="+flat_type+"&ow="+ow;
		//alert(strURL);
		var req = getXMLHTTP();
		
				
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('find_transaction').innerHTML=req.responseText;
						//document.getElementById('find_ownership').innerHTML=req.responseText;
						//document.getElementById('find_transaction').innerHTML=req.responseText;		
						
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}	
	
	
