// Declare our request variable.
var request = false;

// Define a function that will make our request for us:
function retrieveLoc(judet_name,localitate_name, subdomeniu) {
    // Clear the curent request
    request = false;
	var judet_name = judet_name;
	var clasa = clasa;
	var localitate_name = localitate_name;
	if (subdomeniu == '')
		var subdomeniu = 'www';
	//alert(judet_name);
	//alert(clasa);
	//alert(localitate_name);
	//var checkbox_fields = document.news_categ.stiri_categ;
	//alert(categ_id);
	//alert(getSelectedCheckbox(checkbox_fields));
    //alert(getSelectedCheckboxValue(checkbox_fields));
	
	// Generate the request object and handle different browsers:
    if (window.XMLHttpRequest) { // Mozilla & other compliant browsers
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        request = new ActiveXObject("Microsoft.XMLHTTP");
    }

    // If we don't have a request object, then error out.
    if (!request) {
        alert('Browser does not support AJAX!');
        return false;
    }

    // Ok, now we are ready.  Make the request, and tell it to run the
    // function 'updateDate' when it gets data back.
    request.onreadystatechange = updateLoc;
	//alert('fdsgdsg');
    // Open the connection, sending the current value of the form element:
	show_debug('http://'+ subdomeniu +'.immo-land.ro/ajax-loc.php?judet_name=' + judet_name + '&localitate=' + localitate_name + '&clasa=' + clasa+'&subdomeniu='+subdomeniu);
	//alert('http://'+ subdomeniu +'.immo-land.ro/ajax-loc.php?judet_name=' + judet_name + '&localitate=' + localitate_name + '&clasa=' + clasa+'&subdomeniu='+subdomeniu);
    request.open('GET',
        'http://'+ subdomeniu +'.immo-land.ro/ajax-loc.php?judet_name=' + judet_name + '&localitate=' + localitate_name + '&clasa=' + clasa+'&subdomeniu='+subdomeniu)
    request.send(null);
}

function retrieveLocAdmin(judet_name,localitate_name, subdomeniu) {
    // Clear the curent request
    request = false;
	var judet_name = judet_name;
	var subdomeniu = subdomeniu;
	var localitate_name = localitate_name;
	if (subdomeniu == '')
		subdomeniu = 'www';
	//var checkbox_fields = document.news_categ.stiri_categ;
	//alert(categ_id);
	//alert(getSelectedCheckbox(checkbox_fields));
    //alert(getSelectedCheckboxValue(checkbox_fields));
	
	// Generate the request object and handle different browsers:
    if (window.XMLHttpRequest) { // Mozilla & other compliant browsers
        request = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        request = new ActiveXObject("Microsoft.XMLHTTP");
    }

    // If we don't have a request object, then error out.
    if (!request) {
        alert('Browser does not support AJAX!');
        return false;
    }

    // Ok, now we are ready.  Make the request, and tell it to run the
    // function 'updateDate' when it gets data back.
    request.onreadystatechange = updateLoc;
	//alert('fdsgdsg');
    // Open the connection, sending the current value of the form element:
	//alert('http://www.immo-land.ro/ajax-loc-admin.php?judet_name=' + judet_name + '&localitate=' + localitate_name);
    request.open('GET',
        'http://'+ subdomeniu +'.immo-land.ro/ajax-loc-admin.php?judet_name=' + judet_name + '&localitate=' + localitate_name)
    request.send(null);
}

// The function that will accept the data, and update the page:
function updateLoc() {
	//alert('asdsa');
    // Make sure that the state is '4', which means finished:
    if (request.readyState == 4) {
	//alert('1111');
        // Make sure that the status is 200, or 'ok'
        if (request.status == 200) {
		//alert('222');
            // And now, update the text on the page:
			//alert(request.responseText);
            var text = document.getElementById('select_localitati');
            //text.innerHTML = result.firstChild.data;
			//alert(request.responseText);
			text.innerHTML = request.responseText;
        } else {
            alert('Error performing request!' + request.status);
        }
    }
	else
	{
		//alert('333');
	}
}

// Declare our request variable.
var request2 = false;

// Define a function that will make our request for us:
function retrieveZone(loc_name, judet_name,zona, subdomeniu) {
    // Clear the curent request
	//alert('fsgsdfgdfg');
    request2 = false;
	var loc_name = loc_name;
	var judet_name = judet_name;
	var zona = zona;
	var subdomeniu = subdomeniu;
	if (subdomeniu == '')
		subdomeniu = 'www';
	/*alert(loc_name);
	alert(judet_name);
	alert(zona);
	alert(subdomeniu);*/
		
	//var checkbox_fields = document.news_categ.stiri_categ;
	//alert(categ_id);
	//alert(getSelectedCheckbox(checkbox_fields));
    //alert(getSelectedCheckboxValue(checkbox_fields));
	
	// Generate the request object and handle different browsers:

    if (window.XMLHttpRequest) { // Mozilla & other compliant browsers
        request2 = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        request2 = new ActiveXObject("Microsoft.XMLHTTP");
    }

    // If we don't have a request object, then error out.
    if (!request2) {
        alert('Browser does not support AJAX!');
        return false;
    }

    // Ok, now we are ready.  Make the request, and tell it to run the
    // function 'updateDate' when it gets data back.
    request2.onreadystatechange = updateZone;
	//alert('http://'+ subdomeniu +'.immo-land.ro/ajax-zone.php?localitate=' + loc_name + '&judet=' + judet_name + '&zona=' + zona);
    // Open the connection, sending the current value of the form element:
	//alert('http://www.immo-land.ro/ajax-zone.php?localitate=' + loc_name + '&judet=' + judet_name);
    request2.open('GET',
        'http://'+ subdomeniu +'.immo-land.ro/ajax-zone.php?localitate=' + loc_name + '&judet=' + judet_name + '&zona=' + zona);
    request2.send(null);
}

function retrieveZoneAdmin(loc_name, judet_name, zona, subdomeniu) {
    // Clear the curent request
    request2 = false;
	//alert(loc_name);
	//alert(judet_name);
	//alert(zona);
	var loc_name = loc_name;
	var judet_name = judet_name;
	var zona = zona;
	var subdomeniu = subdomeniu;
	if (subdomeniu == '')
		subdomeniu = 'www';
/*	alert(loc_name);
	alert(judet_name);
	alert(zona);
	alert(subdomeniu);*/
	//var checkbox_fields = document.news_categ.stiri_categ;
	//alert(categ_id);
	//alert(getSelectedCheckbox(checkbox_fields));
    //alert(getSelectedCheckboxValue(checkbox_fields));
	
	// Generate the request object and handle different browsers:
    if (window.XMLHttpRequest) { // Mozilla & other compliant browsers
        request2 = new XMLHttpRequest();
    } else if (window.ActiveXObject) { // Internet Explorer
        request2 = new ActiveXObject("Microsoft.XMLHTTP");
    }

    // If we don't have a request object, then error out.
    if (!request2) {
        alert('Browser does not support AJAX!');
        return false;
    }

    // Ok, now we are ready.  Make the request, and tell it to run the
    // function 'updateDate' when it gets data back.
    request2.onreadystatechange = updateZone;
//alert('http://'+ subdomeniu +'.immo-land.ro/ajax-zone-admin.php?localitate=' + loc_name + '&judet=' + judet_name + '&zona=' + zona);
    // Open the connection, sending the current value of the form element:
	//alert('http://www.immo-land.ro/ajax-zone.php?localitate=' + loc_name + '&judet=' + judet_name);
    request2.open('GET',
        'http://'+ subdomeniu +'.immo-land.ro/ajax-zone-admin.php?localitate=' + loc_name + '&judet=' + judet_name + '&zona=' + zona);
    request2.send(null);
}


// The function that will accept the data, and update the page:
function updateZone() {
    // Make sure that the state is '4', which means finished:
	//alert('111');
	//alert(request2.readyState);
    if (request2.readyState == 4) {
		//alert('4444');
        // Make sure that the status is 200, or 'ok'
        if (request2.status == 200) {
			//alert('200');
            // And now, update the text on the page:
            var text = document.getElementById('select_zone');
            //text.innerHTML = result.firstChild.data;
			//alert(responseText);
			text.innerHTML = request2.responseText;
			//alert(request2.responseText + "hhhhh");
        } else {
            //alert('Error performing request!' + request2.status);
        }
    }
	else
	{
		//alert('xxxxx');
	}
}



/*-----------------------------------------------------------+
 | addLoadEvent: Add event handler to body when window loads |
 +-----------------------------------------------------------*/
/*function addLoadEvent(func) {
	var oldonload = window.onload;
	
	if (typeof window.onload != "function") {
		window.onload = func;
	} else {
		window.onload = function () {
			oldonload();
			func();
		}
	}
}*/

/*------------------------------------+
 | Functions to run when window loads |
 +------------------------------------*/
/*addLoadEvent(function () {
	initChecklist();
});*/

/*----------------------------------------------------------+
 | initChecklist: Add :hover functionality on labels for IE |
 +----------------------------------------------------------*//*
function initChecklist() {
	if (document.all && document.getElementById) {
		// Get all unordered lists
		var lists = document.getElementsByTagName("ul");
		
		for (i = 0; i < lists.length; i++) {
			var theList = lists[i];
			
			// Only work with those having the class "checklist"
			if (theList.className.indexOf("checklist") > -1) {
				var labels = theList.getElementsByTagName("label");
				
				// Assign event handlers to labels within
				for (var j = 0; j < labels.length; j++) {
					var theLabel = labels[j];
					theLabel.onmouseover = function() { this.className += " hover"; };
					theLabel.onmouseout = function() { this.className = this.className.replace(" hover", ""); };
				}
			}
		}
	}
}

*/
/**/