function makeRequest(url, div, additional_action) {
	document.getElementById(div).innerHTML = '<img src="img/loading.gif" align="center" />';
//	alert (document.getElementById('right_menu').value);
	if (additional_action=="get_right_menu" && document.getElementById('right_menu').value!='1') document.getElementById('right').innerHTML = '<img src="img/loading.gif" align="center" />';
	var http_request = false;

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		http_request = new XMLHttpRequest();
		if (http_request.overrideMimeType) {
			http_request.overrideMimeType('text/xml');
			// See note below about this line
		}
	} else if (window.ActiveXObject) { // IE
		try {
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!http_request) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	http_request.onreadystatechange = function() { alertContents(http_request, div, additional_action); };
	http_request.open('GET', url, true);
	http_request.send(null);
}

function alertContents(http_request, div, additional_action) {
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
			document.getElementById(div).innerHTML=http_request.responseText;
			if (additional_action=="get_right_menu" && document.getElementById('right_menu').value!='1')
			{
				makeRequest('includes/inc/right.inc.php?id_cladire='+document.getElementById('id_cladire').value, 'right');
				//document.getElementById('right_menu').value='1';
			}
			
			if (document.getElementById('right_menu').value=='1')
			{
				//alert ('tst');
				//alert ('document.getElementById('right_menu').value');
				makeRequest('includes/inc/right_cladire.inc.php?id_cladire='+document.getElementById('id_cladire').value, 'right_cladire');
				document.getElementById('right_menu').value='0';
			}
			
		} else {
			alert('There was a problem with the request.');
		}
	}
}

function open_app(app_id){
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winW = document.body.offsetWidth;
			winH = document.body.offsetHeight;
		}
		if (navigator.appName=="Opera") {
			winW = window.innerWidth;
			winH = window.innerHeight;
		}
	}
	document.getElementById('overlayer').style.height = (winH+document.body.scrollTop)+"px";

	document.getElementById('big_plan').style.top = document.body.scrollTop+(winH/2-300);
	document.getElementById('big_plan').style.left = (winW/2-424);

	makeRequest('includes/inc/show_big.inc.php?id='+app_id, 'big_plan');

	document.getElementById('camere').className="hidden";
	document.getElementById('etaj').className="hidden";
	document.getElementById('buget').className="hidden";

	document.getElementById('big_plan').className = "shown";
	document.getElementById('overlayer').className = "shown";

}

function close_app(){
	document.getElementById('big_plan').className = "hidden";
	document.getElementById('overlayer').className = "hidden";

	document.getElementById('camere').className="shown";
	document.getElementById('etaj').className="shown";
	document.getElementById('buget').className="shown";
}


function send_friend(eap_id){
	makeRequest('includes/inc/send_friend.inc.php?id='+epp_id, 'big_plan');
}