//<?

function hytFakePopup () {
	var bgcolor = "#FFFFFF";
	
	this.open = function($nWidth, $nHeight, $sURL, $sContent) {
		var $sWidth		= ($nWidth) ? $nWidth+"px" : "auto";
		var $sHeight	= ($nHeight) ? $nHeight+"px" : "auto";
		var $sURL		= $sURL || false;
		var $sContent	= $sContent || false;

		var $nWinWidth = Math["max"] (
				Math["max"](document.body["scrollWidth"], document.documentElement["scrollWidth"]),
				Math["max"](document.body["offsetWidth"], document.documentElement["offsetWidth"]),
				Math["max"](document.body["clientWidth"], document.documentElement["clientWidth"])
		);

		var $nWinHeight = Math["max"] (
				Math["max"](document.body["scrollHeight"], document.documentElement["scrollHeight"]),
				Math["max"](document.body["offsetHeight"], document.documentElement["offsetHeight"]),
				Math["max"](document.body["clientHeight"], document.documentElement["clientHeight"])
		);

		if($sHeight!="auto") {
			var $nTop = ($nWinHeight<$nHeight) ? ($nWinHeight-$nHeight)/2 : 10;
		} else {
			var $nTop = 10;
		}

		var $eDivPopup = document.createElement("DIV");
		$eDivPopup.id 						= "divPopup";
		$eDivPopup.style.position 			= "absolute";
		$eDivPopup.style.top 				= $nTop+"px";
		$eDivPopup.style.left 				= ($nWinWidth-$nWidth)/2+"px";
		$eDivPopup.style.padding 			= "0px";
		$eDivPopup.style.margin 			= "0px";
		$eDivPopup.style.textAlign 			= "center";
		$eDivPopup.style.width 				= $sWidth;
		$eDivPopup.style.height 			= $sHeight;
		$eDivPopup.style.backgroundColor 	= this.bgcolor;
		$eDivPopup.style.color 				= "#000000";
		
		window.scrollTo(0,0);
		this.Overlay();	
		document.body.appendChild($eDivPopup);
		
		if($sURL) { this.LoadContent($sURL, $eDivPopup); }
		if($sContent) { $eDivPopup.innerHTML = $sContent; }
		
	}

	this.close = function() {
		var $eOverlay = document.getElementById("overlayMask");
		var $eDivPopup = document.getElementById("divPopup");
		
		$eOverlay.parentNode.removeChild($eOverlay);
		$eDivPopup.parentNode.removeChild($eDivPopup);
	}

	this.Overlay = function() {
		var $nHeight = Math["max"] (
				Math["max"](document.body["scrollHeight"], document.documentElement["scrollHeight"]),
				Math["max"](document.body["offsetHeight"], document.documentElement["offsetHeight"]),
				Math["max"](document.body["clientHeight"], document.documentElement["clientHeight"])
		);

		var $eOverlay = document.createElement("DIV");
		$eOverlay.id = "overlayMask";
		$eOverlay.style.position = "absolute";
		$eOverlay.style.top = "0px";
		$eOverlay.style.left = "0px";
		$eOverlay.style.padding = "0px";
		$eOverlay.style.margin = "0px";
		$eOverlay.style.textAlign = "center";
		$eOverlay.style.width = "100%";
		$eOverlay.style.height = $nHeight+"px";
		$eOverlay.style.backgroundColor = "#000000";
		
		if(navigator.appName=="Netscape") {
			$eOverlay.style["opacity"] = 0.75;
		} else if(navigator.appName=="Microsoft Internet Explorer") {
			$eOverlay.style["filter"] = "alpha(opacity:75)";
		} else {
			$eOverlay.style["KHTMLOpacity"] = 0.75;
		}
		
		document.body.appendChild($eOverlay);
	}

	this.LoadContent = function($sURL, $eTarget) {
		$eAjax = this.AjaxHandler(); 
		$eAjax.open("GET", $sURL, true); 
		
		$eAjax.onreadystatechange = function() {
			if($eAjax.readyState==1) {
				//Sucede cuando se esta cargando la pagina
				$eTarget.innerHTML = "cargando...";
			} else if($eAjax.readyState==4) {
				//Sucede cuando la pagina se cargó
				if($eAjax.status==200){
					//Todo OK
					$eTarget.innerHTML = $eAjax.responseText;
				} else if($eAjax.status==404) {
					//La pagina no existe
					$eTarget.innerHTML = "La pagina no existe";
				} else {
					//Mostramos el posible error
					$eTarget.innerHTML = "Error:".$eAjax.status; 
				}
			}
		}

		$eAjax.send(null);
	}

	this.AjaxHandler = function() {
		var xmlhttp = false;
		try {
			$eHTTP = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				$eHTTP = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(E) {
				$eHTTP = false;
			}
		}

		if(!$eHTTP && typeof XMLHttpRequest!="undefined") {
			$eHTTP = new XMLHttpRequest();
		}

		return $eHTTP;
	}
}
