/* show popup */
var browserName=navigator.appName;
var OSName="Unknown OS";
var _pcServer = "";
if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
var browserVersion=parseInt(navigator.appVersion); 
var appName = navigator.appCodeName;
if(navigator.userAgent.indexOf("Firefox")!=-1){
var versionindex=navigator.userAgent.indexOf("Firefox")+8
if (parseInt(navigator.userAgent.charAt(versionindex))>=1)
browserName = "Firefox";
}
if(navigator.userAgent.indexOf("Safari")!=-1){
browserName = "Safari";
}
$(document).ready(function() {
	
	var fipopupShown=readCookie("PCSBSpopup");
	if(fipopupShown!="shown" || window.location.pathname=="/connect/boards/bootcamp/baby_shower/chat_it_up.jhtml")
	{
		drawPopup();
	} 
});



function createCookieWithoutDomain(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	//document.cookie = name+"="+value+expires+"; path=/";
	document.cookie = name+"="+value+expires+"; path=/;"; 

}

function drawPopup() {
	// set a cookie so the user view only be bugged once a week
		createCookieWithoutDomain("PCSBSpopup","shown","365");
		
		$("#aOverlay").css('opacity','0.5');
		
		//alert("Greetings"); 
		var popUpWidth = 500;
		var popUpHeight = 300;			
		var viewortWidth;
		var viewportHeight;
		
		var docHeight;
		if (typeof document.height != 'undefined') {
			docHeight = document.height; 
		}
		else if (document.body && typeof document.body.scrollHeight != 'undefined') {
			docHeight = document.body.scrollHeight;
		}
		
		//offset... not sure why, but off by 26px;
		docHeight = docHeight + 26;
		 
		// the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight			 
		if (typeof window.innerWidth != 'undefined')
		{
			viewortWidth = window.innerWidth,
			viewportHeight = window.innerHeight
		}			 
		// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)
		else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0)
		{
			viewortWidth = document.documentElement.clientWidth,
			viewportHeight = document.documentElement.clientHeight
		}			 
		// older versions of IE
		else
		{
			viewortWidth = document.getElementsByTagName('body')[0].clientWidth,
			viewportHeight = document.getElementsByTagName('body')[0].clientHeight
		}
		
		//var popUpLeft = (viewortWidth/2)-(popUpWidth/2)-250;
		var popUpLeft = (viewortWidth/2)-(popUpWidth/2);
		var popUpTop = 254;
		
		//document.write('<p>Your viewport width is '+viewortWidth+'x'+viewportHeight+'</p>');	

		//$("#warn-fi-housing").css('display','none');
		$("#warn-fi-housing").css('top',popUpTop+'px');
		$("#warn-fi-housing").css('left',popUpLeft+'px');
		
		$("#aOverlay").css('width',viewortWidth+'px');
		$("#aOverlay").css('height',docHeight+'px');


		var popUp = '';
		//popUp = popUp + '<div id="aOverlay" title="Click to Close" style="opacity: 0.85; display: block; height: 1702px;"/>';
		popUp = popUp + '<table id="fi-popup" style="border-collapse: collapse;"><tr>';
		popUp = popUp + '<td class="nw"><img src="/assets/balloons/blue-nw.png"></td>';
		popUp = popUp + '<td class="n" width="448"></td>';
		popUp = popUp + '<td class="ne"><img src="/assets/balloons/blue-ne.png"></td>';
		popUp = popUp + '</tr><tr>';
		popUp = popUp + '<td class="w"></td>';
		popUp = popUp + '<td class="content">';
		popUp = popUp + '<div class="innercontent" style="height: 257px;">';
		popUp = popUp + '<div class="logo"><img src="/assets/balloons/spring-baby-shower.png"></div>';
		if(window.location.pathname!="/connect/boards/bootcamp/baby_shower/chat_it_up.jhtml")
		{
			popUp = popUp + '<div class="closelink"><a href="#!" class="close"><img src="/assets/balloons/close-btn.png"></a></div>';		
		}

		popUp = popUp + '<div class="mainlink"><a href="http://www.parentsconnect.com/connect/boards/hot_topics/online_baby_shower/chat_it_up.jhtml"><img class="goimage" src="/assets/balloons/join-party-now-btn.png"></a></div>';
		popUp = popUp + '<div id="umbrella"><img src="/assets/balloons/chick-umbrella.png"/></div>';

		popUp = popUp + '</div></td>';
		popUp = popUp + '<td class="e"></td>';
		popUp = popUp + '</tr><tr>';
		popUp = popUp + '<td class="sw"></td>';
		popUp = popUp + '<td class="s"></td>';
		popUp = popUp + '<td class="se"></td>';
		popUp = popUp + '</tr></table>';
		//popUp = popUp + '</div>';
		
		//$("#warn-fi-housing").css('opacity','1.0');
		
		$('#warn-fi-housing').html(popUp);
		$("#warn-fi-housing").toggle();
		
		
		
		$("#warn-fi-housing .close").click(function() {
			$("#warn-fi-housing").toggle();
			$("#aOverlay").css('opacity','0.0');
			$("#aOverlay").css('width','0px');
			$("#aOverlay").css('height','0px');
		});
}


