//By: Chris Campbell
//Created: May 20, 2005
//Last Modified: June 27th, 2005
//www.particletree.com



// path = /production/office/cybarco/www
path = location.pathname;
if (location.pathname.lastIndexOf("manager") != -1) {
	var path = location.pathname.substr(0,(location.pathname.lastIndexOf("manager"))); 
}
else if ( location.pathname.lastIndexOf("/") != -1) {
	var path = 	location.pathname.substr(0,(location.pathname.lastIndexOf("/")));
}
if (path.charAt(path.length - 1) != '/') {
	path = path + '/';	
}

/* for the ajaxy stuff */
var isBusy = false;
var xmlHttp = getHTTPObject();

function getHTTPObject() {
	var xmlHttp = false;
	
	try {
		// Opera 8.0+, Firefox, Safari
		xmlHttp = new XMLHttpRequest();
		
	} catch (e){
		// Internet Explorer Browsers
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				// Something went wrong
				alert("Your browser broke!");
				xmlHttp = false;
				//return false;
			}
		}
	}
	return xmlHttp;
} // end function getHTTPObject()


function getAreas(selected) {
	var url = 'http://www.easyproperty.com.cy/templates/irealty/ajax_functions.php?mode=gAreas&district=';
	var sId = selected.options[selected.selectedIndex].value;
	
	if (isBusy) {
		xmlHttp.onreadystatechange = function () {}
		xmlHttp.abort();
	}

    xmlHttp.open("GET", url + escape(sId), true); 
    isBusy = true;
    xmlHttp.onreadystatechange = handleHttpResponseGetAreas;
    xmlHttp.send('');		
}

function handleHttpResponseGetAreas() {   
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			var obj = document.getElementById('Area');
			// note in search field type, had to add the id attribute
			obj.options.length = 0;
			obj.options[obj.options.length] = new Option('Any Area','');
			eval(xmlHttp.responseText);	
      	}
    }
} // end function handleHttpResponseGetAreas()

