function setOpacity( value ) {
 document.getElementById("styled_popup").style.opacity = value / 10;
 document.getElementById("styled_popup").style.filter = 'alpha(opacity=' + value * 10 + ')';
}

function fadeInMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ )
   setTimeout( 'setOpacity(' + (i / 10) + ')' , 8 * i );
}

function fadeOutMyPopup() {
 for( var i = 0 ; i <= 100 ; i++ ) {
   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 8 * i );
 }

 setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
 document.getElementById("styled_popup").style.display = "none";
 document.getElementById("shadow_popup").style.display = "none";
 try {
	 document.getElementById("windowShade2").style.display = "none";
 } catch (e) {
	 document.getElementById("windowShade").style.display = "none";
 }

}

var lastLocation;
function fireMyPopup(location,popupButtons,width,height) {
	if (width === 0 || width == "" || width == null) width = '530';
	if (height === 0 || height == "" || height == null) height = '400'
 lastLocation = location;
 var screenWidth, screenHeight;
// setOpacity( 0 );
 try {
 allowClose();
 } catch (e) {
 }
 document.getElementById("Popup").src = location;
 document.body.clientHeight

 if (navigator.appName == 'Netscape') {
	isNS = true;
 } else {
	isNS = false;
 }
	
 var yOffset;

 if (isNS) { 
 	yOffset = window.pageYOffset;
 } else {
 	yOffset = document.body.scrollTop;
 }

 xPos = (document.body.clientWidth/2) - ((width/2) + 10);
 yPos = (document.body.clientHeight/2) - ((height/2) + 10) + yOffset;
 
 document.getElementById("styled_popup").style.width = width + "px";
 document.getElementById("styled_popup").style.height = height + "px";
 document.getElementById("Popup").style.height = (parseInt(height)-parseInt(10)) + "px";
 document.getElementById("Popup").style.width = (parseInt(width)-parseInt(5)) + "px";
 //document.getElementById("shadow_popup").style.width = width + "px";
 //document.getElementById("shadow_popup").style.height = (parseInt(height)+parseInt(55)) + "px"; 
 document.getElementById("styled_popup").style.top = yPos;
 document.getElementById("styled_popup").style.left = xPos;
 //document.getElementById("shadow_popup").style.top = yPos;
 //document.getElementById("shadow_popup").style.left = xPos;
 if (popupButtons != "") {
	 document.getElementById("popup_buttons").innerHTML = popupButtons;
	 document.getElementById("popup_buttons").style.margin = "10px 0px 0px 0px";
	 document.getElementById("popup_buttons").style.width = width + "px";
	 //alert(parseInt(document.getElementById("popup_buttons").clientHeight));
	 
 }
 try {
	 document.getElementById("windowShade2").style.display = "block";
	 document.getElementById("windowShade2").style.height = document.body.clientHeight + yOffset;
} catch (e) {
	 document.getElementById("windowShade").style.display = "block";
	 document.getElementById("windowShade").style.height = document.body.clientHeight + yOffset;
}
 //document.getElementById("shadow_popup").style.display = "block";
 document.getElementById("styled_popup").style.display = "block";
 document.getElementById("Popup").focus();
 document.getElementById("styled_popup").style.height = (parseInt(height)+parseInt(document.getElementById("popup_buttons").clientHeight)) + "px";
// document.getElementById("windowShade").onclick = closeMyPopup;
// fadeInMyPopup();
}

/*var hash = location.hash;
setInterval(function()
{
	if (location.hash != "#Popup") {
	 closeMyPopup();
	} else {
		if (hash != location.hash) {
			fireMyPopup(lastLocation);
			hash = location.hash;
		}
	}
	hash = location.hash;
}, 100);
*/