// 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 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'>Select</option></select>";
	var trans="<select name='find_transaction'><option value='' selected='selected'>Select</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_owner.php?owner="+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'>Select</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_transaction.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);
		}
				
	}		
	
	
// serach

function find_search(flat_type) {
//alert(flat_type);
		var strURL="dropdownfile/find_bed_size.php?flat_type="+flat_type;
		//alert(strURL);
		var req = getXMLHTTP();
		
	var own="Bedroom :-";
	//var trans="<select name='find_transaction'><option value='' selected='selected'>Select</option></select>";
				
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('findsearch').innerHTML=req.responseText;
						document.getElementById('size').innerHTML=own;
						
						
					//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 Wish(Wish) {
//alert(Wish);
		var strURL="dropdownfile/ad_search.php?Wish="+Wish;
		//alert(strURL);
		var req = getXMLHTTP();
	
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('Wish').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);
		}
				
	}	
	
	function find_bedroom(find_bedroom) {
//alert(find_bedroom);
		var strURL="dropdownfile/ad_search.php?find_bedroom="+find_bedroom;
		//alert(strURL);
		var req = getXMLHTTP();
	
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						document.getElementById('find_bedroom').innerHTML=req.responseText;
					
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}	
	
	function book_mark(id) {
			var strURL="dropdownfile/book_mark.php?book_mark="+id;
		//alert(strURL);
		var req = getXMLHTTP();
	
		if (req) {
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {
						//alert(req.responseText);
						document.getElementById('star'+id).src=req.responseText;
						
						if(req.responseText=="images/star1.png")
						document.getElementById('star'+id).title="Remove Bookmark";
						else
						document.getElementById('star'+id).title="Bookmark";
											
					} else {
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}	
