// 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{
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				}
				catch(e1){
					submit();
					xmlhttp=false;
				}
			}
		}
		 	
		return xmlhttp;
	}
	
	
	
	function getRegion(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('divRegion').innerHTML=req.responseText;			
						var country1=document.getElementById('country');
						var region1=document.getElementById('region');
						
						
						
						getTown('findcity.php?country='+ country1.options[country1.selectedIndex].value + '&region='+region1.options[region1.selectedIndex].value );
						
						
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	function getTown(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('divTown').innerHTML=req.responseText;						
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}	
			var country1=document.getElementById('country');
			strURL=strURL + '&country='+ country1.options[country1.selectedIndex].value;
			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	function verifyEmail(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('divEmailVerify').innerHTML=req.responseText;						
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}
				
	}
	
	
	function similarProperty(pid,page_id,ptoid,url)
	{//used in prodetail1. 
	//to update the similar property for the analysis
		//alert(ptoid);
		var req = getXMLHTTP();
		
		//var strURL='http://www.propertyturkeyforsale.com/analysis_similar.php?pid='+pid + '&page_id='+page_id + '&ptoid='+ptoid;
		var strURL='analysis_similar.php?pid='+pid + '&page_id='+page_id + '&ptoid='+ptoid;
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
				//	alert(req.responseText);
					
					//	document.getElementById('divtemp').innerHTML=req.responseText;	
						window.location=url;
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}	
			//alert(strURL);
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
	
	function similarProperty1(pid,page_id,ptoid)
	{//used in prodetail1. 
	//to update the similar property for the analysis
		//alert(ptoid);
		var req = getXMLHTTP();
		
		//var strURL='http://www.propertyturkeyforsale.com/analysis_similar.php?pid='+pid + '&page_id='+page_id + '&ptoid='+ptoid;
		var strURL='analysis_similar.php?pid='+pid + '&page_id='+page_id + '&ptoid='+ptoid;
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
				//	alert(req.responseText);
					
						document.getElementById('divtemp').innerHTML=req.responseText;	
					
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}	
			//alert(strURL);
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	
	function searchProperty(spid,search_id)
	{//used in property_listing.php
	//to update the search analysis,when user clicked on the search result.
	

		var req = getXMLHTTP();
		
		//var strURL='http://www.propertyturkeyforsale.com/analysis_similar.php?spid='+spid + '&search_id='+search_id;
		var strURL='analysis_similar.php?spid='+spid + '&search_id='+search_id;
		
		if (req) {
			
			req.onreadystatechange = function() {
				if (req.readyState == 4) {
					// only if "OK"
					if (req.status == 200) {						
					//alert(req.responseText);
					
						document.getElementById('divtemp').innerHTML=req.responseText;						
					} else {
						//alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}	
			//alert(strURL);
			req.open("GET", strURL, true);
			req.send(null);
		}
	}
	



	