// XML REQUEST
var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) {	xmlhttp=false; } };
if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest();	} catch (e) { xmlhttp=false; } };
// MS 
function openWindow(file,div,divhandle,dragme) { // abre um ficheiro, div é opcional
	getWindowContent("GET",file,'',div,false,false,divhandle,false,dragme);
}
function openWindowPOSTNO(file,vars) { // abre um ficheiro e envia variaveis por POST e não tem feedback
	getWindowContent("POST",file,vars,false,false,false,false,false,false,true,false);
}
function openWindowGETNO(file,vars) { // abre um ficheiro e envia variaveis por GET e não tem feedback
	getWindowContent("GET",file,vars,false,false,false,false,false,false,true,false);
}
function openWindowPOST(file,vars,div,divhandle,dragme,f) { // abre um ficheiro e envia variaveis por POST, div é opcional
	getWindowContent("POST",file,vars,div,false,false,divhandle,false,dragme,false,f);
}
function openWindowGET(file,vars,div,divhandle,dragme,f) { // abre um ficheiro e envia variaveis por GET, div é opcional
	getWindowContent("GET",file,vars,div,false,false,divhandle,false,dragme,false,f);
}
function getWindowContent(method, url, vars, div, docObj, obj, divhandle, objhandle, dragme,nofb,f) { // faz o que for preciso, não está preparada para o metodo HEADER, porque não estou a ver utilidade para já
	if ((vars == "") || (vars == "undefined")) vars = null;
	if (xmlhttp != null && xmlhttp.readyState != 0 && xmlhttp.readyState !=4)
		xmlhttp.abort(); /* IE fix */
	if (!div) div = "xml_popup_window";
	if (!divhandle) divhandle = "xml_box_top";
	var x = document.getElementById(div); // div que vai conter a informação
	if ((!method) || (!url) || ( (!x) && (!docObj) && (!nofb) ) ) return false;
	document.body.style.cursor = "wait";
	try { xmlhttp.open(method, url, true); }
	catch (e) { url = url.replace(/www./i,""); xmlhttp.open(method, url, true); }
	if (method == "POST") {
		xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xmlhttp.setRequestHeader("Connection", "close");
	}
	xmlhttp.onreadystatechange=function() {
		if (!nofb) {
			if (xmlhttp.readyState==4) {
				xmlhttp.onreadystatechange=function() { };
				if (!docObj) {
					x.innerHTML = xmlhttp.responseText;
					showPopWindow(div,false,true);
					if (dragme)	Drag.init(document.getElementById(divhandle),document.getElementById(div));
				} else if (obj) {
					obj = eval(obj);
					obj.innerHTML = xmlhttp.responseText;
					objhandle = eval(objhandle);
					obj.style.display = "block";
					if (dragme) Drag.init(objhandle,obj);
				}
				document.body.style.cursor = "";
			}
		} else {
			document.body.style.cursor = "";
		}
		if ((f) && (xmlhttp.readyState==4)) { xmlhttp.onreadystatechange=function() { }; eval(f); }
	}
	xmlhttp.send(vars); /* IE Fix: readystate depois de open e antes de send */
}
function showPopWindow(div,e,update,obj,px,py) {
	if (!div) div = "xml_popup_window";
	var x = (obj)?obj:document.getElementById(div);
	if (!e)	x.style.display = "block";
	else hidePopWindow(div);
	if (e) {
		pos_y = (e||event).clientY?((e||event).clientY):(e||event).pageY-x.clientHeight;
		pos_x = (e||event).clientX?((e||event).clientX):(e||event).pageX-x.clientWidth;
	} else if (!update) { // else if (e === false)
		pos_x = (!isNaN(window.innerWidth / 2))?(window.innerWidth / 2):(window.document.documentElement.clientWidth / 2);
 		pos_y = (!isNaN(window.innerHeight / 2))?(window.innerHeight / 2):(window.document.documentElement.clientHeight / 2);
	}
	if (!update) {
		x.style.top = ((py)?py:pos_y)+"px";
		x.style.left = ((px)?px:pos_x)+"px";
	}
//	x.style.border = "2px solid black";
}
function hidePopWindow(div) {
	if (!div) div = "xml_popup_window";
	x = document.getElementById(div);
	x.style.display = "none";
}
//-----