var popupWinoldonloadHndlr=window.onload, popupWinpopupHgt, popupWinactualHgt, popupWintmrId=-1, popupWinresetTimer;
var popupWintitHgt, popupWincntDelta, popupWintmrHide=-1, popupWinhideAfter=-1, popupWinhideAlpha, popupWinhasFilters=true;
var popupWinnWin, popupWinshowBy = null, popupWindxTimer = -1, popupWinpopupBottom;

var popupWinnText, popupWinnMsg, popupWinnTitle, popupWinbChangeTexts = false;

if(typeof(popupDecay) != "undefined")
	popupWinhideAfter = popupDecay;
else
	popupWinhideAfter = 10000;

if(typeof(popupDelay) != "undefined")
	popupWinstartAfter = popupDelay;
else
	popupWinstartAfter = 0;
	

//setTimeout("popupWinespopup_winLoad()", popupWinstartAfter);
//window.onload=popupWinespopup_winLoad;

function popupWinespopup_ShowPopup(show) {
	if (popupWindxTimer != -1) { el.filters.blendTrans.stop(); }
	if ((popupWintmrHide != -1) && ((show != null) && (show == popupWinshowBy))) {
		clearInterval(popupWintmrHide);
		popupWintmrHide = setInterval(popupWinespopup_tmrHideTimer, popupWinhideAfter);
		return;
	}
	if (popupWintmrId != -1)
		return;
	popupWinshowBy = show;

	elCnt=document.getElementById('popupWin_content')
	elTit=document.getElementById('popupWin_header');
	el=document.getElementById('popupWin');
	el.style.left = '';
	el.style.top = '';
	el.style.filter = '';

	if (popupWintmrHide!=-1) 
		clearInterval(popupWintmrHide);
	popupWintmrHide = -1;

	document.getElementById('popupWin_header').style.display = 'none';
	document.getElementById('popupWin_content').style.display = 'none';

	if (navigator.userAgent.indexOf('Opera') != -1)
		el.style.bottom = (document.body.scrollHeight * 1 - document.body.scrollTop * 1
					- document.body.offsetHeight * 1 + 1 * popupWinpopupBottom) + 'px';
	
	if (popupWinbChangeTexts) {
		popupWinbChangeTexts = false;
		document.getElementById('popupWinaCnt').innerHTML = popupWinnMsg;
		document.getElementById('popupWintitleEl').innerHTML = popupWinnTitle;
	}

	popupWinactualHgt=0; 
	el.style.height = popupWinactualHgt + 'px';
	el.style.visibility = '';
	if (!popupWinresetTimer) 
		el.style.display = '';
	popupWintmrId = setInterval(popupWinespopup_tmrTimer, (popupWinresetTimer?1000:20));
}

function popupWinespopup_winLoad() {
	if (popupWinoldonloadHndlr!=null) 
		popupWinoldonloadHndlr();
	elCnt=document.getElementById('popupWin_content')
	elTit=document.getElementById('popupWin_header');
	el=document.getElementById('popupWin');
	popupWinpopupBottom=el.style.bottom.substr(0,el.style.bottom.length-2);
	popupWintitHgt=elTit.style.height.substr(0,elTit.style.height.length-2);
	popupWinpopupHgt=el.style.height;
	popupWinpopupHgt=popupWinpopupHgt.substr(0,popupWinpopupHgt.length-2); popupWinactualHgt=0;
	popupWincntDelta=popupWinpopupHgt-(elCnt.style.height.substr(0,elCnt.style.height.length-2));
	if (true) {
		popupWinresetTimer=true;
		popupWinespopup_ShowPopup(null);
	}
}


function popupWinespopup_tmrTimer() {
  el=document.getElementById('popupWin');
  if (popupWinresetTimer)
  {
    el.style.display='';
    clearInterval(popupWintmrId); popupWinresetTimer=false;
    popupWintmrId=setInterval(popupWinespopup_tmrTimer,30);
  }
  popupWinactualHgt+=5;
  if (popupWinactualHgt>=popupWinpopupHgt)
  {
    popupWinactualHgt=popupWinpopupHgt; clearInterval(popupWintmrId); popupWintmrId=-1;
    document.getElementById('popupWin_content').style.display='';
    if (popupWinhideAfter!=-1) popupWintmrHide=setInterval(popupWinespopup_tmrHideTimer,popupWinhideAfter);
  }
  if (popupWintitHgt<popupWinactualHgt-6)
    document.getElementById('popupWin_header').style.display='';
  if ((popupWinactualHgt-popupWincntDelta)>0) {
    elCnt=document.getElementById('popupWin_content')
    elCnt.style.display='';
    elCnt.style.height=(popupWinactualHgt-popupWincntDelta)+'px';
  }
  el.style.height=popupWinactualHgt+'px';
}

function popupWinespopup_tmrHideTimer() {
  clearInterval(popupWintmrHide); popupWintmrHide=-1;
  el=document.getElementById('popupWin');
/*  if (popupWinhasFilters)
  {
    backCnt=document.getElementById('popupWin_content').innerHTML;
    backTit=document.getElementById('popupWin_header').innerHTML;
    document.getElementById('popupWin_content').innerHTML='';
    document.getElementById('popupWin_header').innerHTML='';
    el.style.filter='blendTrans(duration=1)';
    el.filters.blendTrans.apply();
    el.style.visibility='hidden';
    el.filters.blendTrans.play();
    document.getElementById('popupWin_content').innerHTML=backCnt;
    document.getElementById('popupWin_header').innerHTML=backTit;

    popupWindxTimer=setInterval(popupWinespopup_dxTimer,1000);
  }
  else */
  el.style.left='0';
  el.style.top='0';
  el.style.visibility='hidden';
}

function popupWinespopup_dxTimer() {
	clearInterval(popupWindxTimer); 
	popupWindxTimer=-1;
}

function popupWinespopup_Close() {
	if (popupWintmrId==-1) {
		el=document.getElementById('popupWin');
		el.style.filter='';
		el.style.display='none';
		if (popupWintmrHide!=-1) 
			clearInterval(popupWintmrHide); 
		popupWintmrHide=-1;
	}
}



var popupWinmousemoveBack,popupWinmouseupBack;
var popupWinofsX,popupWinofsY;
function popupWinespopup_DragDrop(e) {
	popupWinmousemoveBack=document.body.onmousemove;
	popupWinmouseupBack=document.body.onmouseup;
	ox=(e.offsetX==null)?e.layerX:e.offsetX;
	oy=(e.offsetY==null)?e.layerY:e.offsetY;
	popupWinofsX=ox;
	popupWinofsY=oy;
	document.body.onmousemove=popupWinespopup_DragDropMove;
	document.body.onmouseup=popupWinespopup_DragDropStop;
	if (popupWintmrHide!=-1) clearInterval(popupWintmrHide);
}

function popupWinespopup_DragDropMove(e) {
  el=document.getElementById('popupWin');
  if (e==null&&event!=null) {
    el.style.left=(event.clientX*1+document.body.scrollLeft-popupWinofsX)+'px';
    el.style.top=(event.clientY*1+document.body.scrollTop-popupWinofsY)+'px';
    event.cancelBubble=true;
  }
  else {
    el.style.left=(e.pageX*1-popupWinofsX)+'px';
    el.style.top=(e.pageY*1-popupWinofsY)+'px';
    e.cancelBubble=true;
  }
  if ((event.button&1)==0) popupWinespopup_DragDropStop();
}

function popupWinespopup_DragDropStop() {
	document.body.onmousemove=popupWinmousemoveBack;
	document.body.onmouseup=popupWinmouseupBack;
}











/**
  *
  *
  */

function cls_xml(){ return new InetXML(); }

function InetXML() {
	this.xmlSrc = arguments.length==1 ? arguments[0] : null;
	this.xslSrc = arguments.length==2 ? arguments[1] : null;
	this.xmlDom = null;
	this.xslDom = null;
	this.httpApplet = null;
	this.httpNative = null;
	this.httpParameters = "";
	this.httpMethod = "GET";
	this.IEprefixes = ["MSXML2","Microsoft","MSXML","MSXML3"];
	this.IEprefix = null;
	this.isIE = /MSIE/gim.test(navigator.userAgent);
	this.isNS = /Gecko|Netscape6/gim.test(navigator.userAgent);
	this.isOP = /Opera/gim.test(navigator.userAgent);
	this.responseBody = null;
	this.responseText = null;
	this.responseXML = null;
		
	// XML/XSL METHOD'S !!
	this.loadXML = function(url) {
		this.xmlSrc = url;
		if (this.httpApplet != null) {
			this.httpApplet.setUrl(url);
			this.str2dom(this.xmlDom, this.httpApplet.execute());
		}
		else
			try { this.xmlDom.load(url); }catch(ex){};
	}
	this.loadXSL = function(url) {
		this.xslSrc = url;
		if (this.httpApplet != null) {
			this.httpApplet.setUrl(url);
			this.str2dom(this.xslDom, this.httpApplet.execute());
		}
		else
			try { this.xslDom.load(url); }catch(ex){};
	}
	this.reloadXML = function(){ this.loadXML(this.xmlSrc); }
	this.reloadXSL = function(){ this.loadXSL(this.xslSrc); }
	this.str2dom = function(dom, xml) {
		if (window.ActiveXObject)
			dom.loadXML(xml);
		else if (document.implementation && document.implementation.createDocument) {
			var nsdom = (new DOMParser()).parseFromString(xml, "text/xml");
			while (dom.hasChildNodes())
				dom.removeChild(dom.lastChild);
			for (var i=0; i < nsdom.childNodes.length; i++)
				dom.appendChild(dom.importNode(nsdom.childNodes[i], true));
		}
	}
	this.getTransformed = function() {
		var html = null;
		if (window.ActiveXObject)
			html = this.xmlDom.transformNode(this.xslDom);
		else if (document.implementation && document.implementation.createDocument) {
			var xsltProcessor = new XSLTProcessor();
			xsltProcessor.importStylesheet(this.xslDom);
			var htmlDom = xsltProcessor.transformToFragment(this.xmlDom, document);
			html = (new XMLSerializer()).serializeToString(htmlDom);
		}
		return html;
	}
	
	// REQUEST METHOD'S !!
	this.setRequestMethod = function(name) {
		this.httpMethod = name.toUpperCase();
		if (this.httpApplet != null)
			this.httpApplet.setRequestMethod(this.httpMethod);
	}
	this.addRequestParameter = function(name, value) {
		this.httpParameters +=(this.httpParameters!=""?"&":"")+window.escape(name)+"="+window.escape(value);
		if (this.httpApplet != null)
			this.httpApplet.addRequestParameter(name, value);
	}
	this.sendRequest = function() {
		if (this.httpApplet != null)
			this.reloadXML();
		else {
			try {
			  var n = this.httpNative;
			  n.open("POST", this.xmlSrc, true);
				n.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				n.send(this.httpParameters);
				this.httpParameters = "";
				/*
				if (n.readyState == 4) {
				  this.responseText = n.responseText;
				  this.responseBody = n.responseBody;
				  this.responseXML = n.responseXML;
				}
				*/
				/*
				if (window.ActiveXObject)
					this.xmlDom.loadXML(this.responseText);
				else if (document.implementation && document.implementation.createDocument) {
					var nsdom = (new DOMParser()).parseFromString(str, "text/xml");
					while (this.xmlDom.hasChildNodes())
						this.xmlDom.removeChild(this.xmlDom.lastChild);
					for (var i=0; i < nsdom.childNodes.length; i++)
						this.xmlDom.appendChild(this.xmlDom.importNode(nsdom.childNodes[i], true));
				}
				*/
			}catch(e){}	
		}
		return true;
	}
	
	this.main = function() {
		// CREATE HTTPAPPLET-OBJECT !!
		if (!document.getElementById("httpApplet"))
			;//document.body.innerHTML += "<applet id=\"httpApplet\" code=\"xmlcomm.class\" width=\"0\" height=\"0\"></applet>\n";
		try { this.httpApplet = document.getElementById("httpApplet"); }
		catch (ex) { this.httpApplet = null; }
		// CREATE XML/XSL-OBJECT !!
		try {
			if (window.ActiveXObject) {
				if (window.ActiveXObject)
				for (var i=0; i<this.IEprefixes.length; i++)
					try {
						var o = new ActiveXObject(this.IEprefixes[i] + ".XMLDOM");
						this.IEprefix = this.IEprefixes[i];
					}catch (ex) {};
				this.xmlDom = new ActiveXObject(this.IEprefix + ".XMLDOM");
				this.xslDom = new ActiveXObject(this.IEprefix + ".XMLDOM");
				this.xmlDom.async = false;
				this.xslDom.async = false;
				this.httpNative = new ActiveXObject(this.IEprefix + ".XMLHTTP");
			}
			else if (document.implementation && document.implementation.createDocument) {
				this.xmlDom = document.implementation.createDocument("", "", null);
				this.xslDom = document.implementation.createDocument("http://www.w3.org/1999/XSL/Transform","stylesheet",null);
				if (this.xmlDom.readyState == null) {
					this.xmlDom.readyState = 1;
					this.xmlDom.addEventListener("load", function(){
						this.xmlDom.readyState = 4;
						if (typeof this.xmlDom.onreadystatechange == "function")
							this.xmlDom.onreadystatechange();
					}, false);
				}
				this.httpNative = new XMLHttpRequest();
			}
		}catch(ex){ throw new Error("Your browser does not support XML-objects"); }
	}
	this.main();
}



