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) {

	var arr = new Array();
	var ident = target_id+new Date();
	arr[ident] = GetXmlHttpObject();
	if (arr[ident]==null) {
		alert ("Your browser does not support AJAX!");
		return;
	}
	arr[ident].onreadystatechange = function() {
		if (arr[ident].readyState==4 || arr[ident].readyState=="complete")
		{
			document.getElementById(target_id).innerHTML = arr[ident].responseText;
			//alert(xmlhttp.responseText);
			if (command == 'advanced_search_get_structure_type_category')
			{
				var str_type_id_ = document.getElementById('str_type_id').value;
				var str_type_id__ = new String(str_type_id_);
				get_ajax('get_structure_type_search',str_type_id__,'div_caracteristici__',url,lang,selected);
			}
			
			//get_caracteristics_('get_caracteristics_');
		}
	}
	arr[ident].open('POST', url+'/ajax.php', true);
	arr[ident].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	arr[ident].send('command='+command+'&value='+value+'&lang='+lang+'&selected='+selected);
}

function get_ajax_sheet(command,value,target_id,url,lang) {
	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);
		}
	}
	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) {

	var file_ = new String();
	file_ = file.replace(' ','');

	var newwindow = window.open('../../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;
}