function GetXmlHttpObject(){
	var xmlhttp=null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlhttp=new XMLHttpRequest();
	} catch (e)  {
		// Internet Explorer
		try {
		xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlhttp;
}

function get_ajax(command,value,target_id,url,lang,selected) {

	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {

			document.getElementById(target_id).innerHTML = xmlhttp.responseText;

		}
	}
	xmlhttp.open('POST', url+'/ajax.php', true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send('command='+command+'&value='+value+'&lang='+lang+'&selected='+selected);
}

function get_ajax_sheet(command,value,target_id,url,lang,url_) {
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState==4 || xmlhttp.readyState=="complete") {
			open_window(xmlhttp.responseText,url_);
		}
	}
	xmlhttp.open('POST', url+'ajax_sheet.php', true);
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlhttp.send('command='+command+'&value='+value+'&lang='+lang);
}

function open_window(file,url) {

	var file_ = new String();
	file_ = file.replace(' ','');
	var newwindow = window.open(url+'featured_sheets/'+file_,'PreviewRaportStructuriVandute','height=1024,width=1024,menubar=1,resizable=1,scrollbars=1,status=1,toolbar=1,location=1');
	if (window.focus) {newwindow.focus()}
	existsPopup = true;
	return false;
}