// Browser safe opacity handling function
var iMyWidth;
var iMyHeight;

function setOpacity( value ) {
 document.getElementById("pop").style.opacity = value / 10;
 document.getElementById("pop").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("pop").style.display = "none";
}

$(document).ready(
	function() {
		iMyWidth = $(document).width()/2 - 325 ;
		iMyHeight = $(document).height()/2 - 225 ;
		$(window).resize(
			function() {
				iMyWidth = $(document).width()/2 - 325 ;
				iMyHeight = $(document).height()/2 - 225 ;
				 $('#pop').css('left', iMyWidth).css('top', iMyHeight);
			}
		);
	}
);

function fireMyPopup() {
 setOpacity( 0 );
 document.getElementById("pop").style.display = "block";
 $('#pop').css('left', iMyWidth).css('top', iMyHeight);
 fadeInMyPopup();
}

