// JavaScript Document
// Browser safe opacity handling function
function setOpacity( value ) {
	document.getElementById("styled_popup").style.opacity = value / 10;
	document.getElementById("styled_popup").style.filter = 'alpha(opacity=' +  value * 10 + ')';
	document.getElementById("styled_popup_shadow").style.opacity = ( value / 10 ) - 0.4;
	document.getElementById("styled_popup_shadow").style.filter = 'alpha(opacity=' + ( value * 10 ) - 40 + ')';	
}

function fadeInMyPopup(id) {
	for( var i = 0 ; i <= 100 ; i++ )
	  setTimeout( 'setOpacity(' + (i / 10) + ')' , 4 * i );
}

function fadeOutMyPopup() {
	 for( var i = 0 ; i <= 100 ; i++ ) {
	   setTimeout( 'setOpacity(' + (10 - i / 10) + ')' , 4 * i );
	 }
	
	 setTimeout('closeMyPopup()', 800 );
}

function closeMyPopup() {
 	document.getElementById("popup").style.display = "none"
}

function fireMyPopup() {
	
	setOpacity( 0);	
	var oMsgPanel = document.getElementById("popup");
	
	// w is a width of the newsletter panel
	w = 350;
	// h is a height of the newsletter panel
	h = 380;
	// get the x and y coordinates to center the newsletter panel
	xc = Math.round((document.body.clientWidth/2)-(w/2))
	yc = Math.round((document.body.clientHeight/2)-(h/2))
	// show the newsletter panel
	oMsgPanel.style.left = xc + "px";
	oMsgPanel.style.top = yc + "px";
	oMsgPanel.style.display = "block";
	
	fadeInMyPopup(document.getElementById("popup").id);

}



