function Inint_AJAX() {
   
   try { return new ActiveXObject("Msxml2.XMLHTTP");  } catch(e) {}
   try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
   try { return new XMLHttpRequest(); } catch(e) {}
   alert("XMLHttpRequest not supported");
   return null;
};

function windmal_loadingwindow(display){
	if(display==1){
		var x=158;
		var y=34;	 
		var nloa = document.createElement('div');
		nloa.setAttribute('id', 'windmal_loading'); 
		document.body.appendChild(nloa);
		nloa.style.width = x+"px";
		nloa.style.height = y+"px";
		nloa.innerHTML="<div class=\"windmal_loading_image\"><img src=\"plug_modules/mod/windmal/images/an008.gif\" border=\"0\" width=\"24\" height=\"24\" /></div>";
		nloa.style.display = "block";
		staticbar('windmal_loading', x, y);		
	} else {
		document.body.removeChild(document.getElementById('windmal_loading'));
	}
}

function windmal(x, y, title, openfunction){
	windmalopenground(1);
	windmal_loadingwindow(1);
	y=y+24;

	var objname="windmalbox";
	var contentobj="windmal_contentbox";
	
	var windmal_onobj=document.getElementById(objname);
	windmal_onobj.style.width=x;
	windmal_onobj.style.height=y;	
 
 	var xmlhttp=Inint_AJAX();
    xmlhttp.onreadystatechange = function () { 
          if (xmlhttp.readyState==4) {
               if (xmlhttp.status==200) {
                    windmal_onobj.innerHTML=xmlhttp.responseText;
					document.getElementById(contentobj).style.height=y-25;               
					windmal_loadingwindow(0);
	                staticbar(objname, x, y);
					windmalopenwindow(objname);
					eval(openfunction); 
					//setTimeout("aop()",1000);
               } 
          }
     };
     xmlhttp.open("GET", "plug_modules/mod/windmal/onserver/windmal.php?title="+title);
     xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=iso-8859-1");
     xmlhttp.send(null);
}

function windmalopenwindow(obj) {
	var sDiv = document.getElementById(obj);
	if( sDiv.style.display == "block" ) {
		sDiv.style.display = "none";
		windmalopenground(0);		
		obj.innerHTML = "";
	} else {
		sDiv.style.display = "block";		 
	}
}

function windmalopenground(display) {
 
 	if(display==1){
		var ndiv = document.createElement('div');
		ndiv.setAttribute('id', 'ground'); 
		document.body.appendChild(ndiv);
		var ua = navigator.userAgent.toLowerCase();  
		if ( ua.indexOf( "msie" ) != -1 ) {
			ndiv.style.height=document.body.scrollHeight > document.body.offsetHeight ? document.body.scrollHeight : document.body.offsetHeight + 'px';
		}		
		ndiv.style.display = "block";
	} else {
		document.body.removeChild(document.getElementById('ground'));		
	}
 
}

function iecompattest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function staticbar(obj, x, y){
	
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;
	var d = document;
	
	var unlef = ns ? innerWidth : iecompattest().clientWidth;
	var untop = ns ? innerHeight : iecompattest().clientHeight;
	
	var startX = (unlef/2)-(x/2);
	var startY = (untop/2)-(y/2);
	
	function ml(id){
		var el=d.getElementById(id);
		if(d.layers)
			el.style=el;
		el.sP=function(x,y){
			this.style.left=x+"px";
			this.style.top=y+"px";
		};
		
		el.x = startX;
		el.y = startY;
			
		return el;
	}
	
	window.stayTopLeft=function(){
		var pY = ns ? pageYOffset : iecompattest().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		ftlObj.sP(ftlObj.x, ftlObj.y);
		setTimeout("stayTopLeft()", 10);
	}
	
	ftlObj = ml(obj);
	stayTopLeft();
	
}
