/* check for IE6 and tell user to upgrade! */
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";
}
$.safeDocumentReady.add(function() {
	
	//if(navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0")<=-1)
	//if(navigator.appName!="Microsoft Internet Explorer")
	//"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; GTB6.3; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729)"
	//if(navigator.appName=="Microsoft Internet Explorer" && navigator.appVersion.indexOf("MSIE 6.0")>-1 && navigator.appVersion.indexOf("MSIE 8.0")==-1 && navigator.appVersion.indexOf("MSIE 7.0")==-1)
	
	var ie6popupShown = $.cookie("PCPie6popup");
	
	if( (navigator.appName=="Microsoft Internet Explorer") && (navigator.appVersion.indexOf("MSIE 6.0")>-1) && (navigator.appVersion.indexOf("MSIE 8.0")==-1) && (navigator.appVersion.indexOf("MSIE 7.0")==-1) && (ie6popupShown!="shown") )
	{
		// set a cookie so the user view only be bugged once a day
		createCookieWithoutDomain("PCPie6popup","shown","1");
		
		$("#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);
		//var popUpTop = (viewportHeight/2)-(popUpHeight/2);
		var popUpTop = 50;
		
		//document.write('<p>Your viewport width is '+viewortWidth+'x'+viewportHeight+'</p>');	

		//$("#warn-ie6-housing").css('display','none');
		$("#warn-ie6-housing").css('top',popUpTop+'px');
		$("#warn-ie6-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="ie6-popup" style="border-collapse: collapse;"><tr>';
		popUp = popUp + '<td class="nw"><img src="http://www.parentsconnect.com/assets/balloons/avatar-actions-balloon_nw.gif"></td>';
		popUp = popUp + '<td class="n"></td>';
		popUp = popUp + '<td class="ne"><img src="http://www.parentsconnect.com/assets/balloons/avatar-actions-balloon_ne.gif"></td>';
		popUp = popUp + '</tr><tr>';
		popUp = popUp + '<td class="w1"></td>';
		popUp = popUp + '<td class="closelink clearfix">';
		popUp = popUp + '<a href="#!" class="close">close [x]</a>';
		popUp = popUp + '</td>';
		popUp = popUp + '<td class="e"></td>';
		popUp = popUp + '</tr><tr>';
		popUp = popUp + '<td class="w2"></td>';
		popUp = popUp + '<td class="content clearfix">';
		
		popUp = popUp + '<div class="hi">hi!</div>';
		popUp = popUp + '<div class="explanation">We think you\'re awesome... and we also think that<br> your browser is outta date! <span class="upgrade">Upgrade</span> your browser<br> now - it\'s free and easy! And you\'ll see the world<br> (well at least the web) in a whole new light!</div>';
		
		popUp = popUp + '<br>';
		popUp = popUp + '<a target="_blank" href="http://www.microsoft.com/windows/Internet-explorer/default.aspx"><img class="upgradeimage" src="http://www.parentsconnect.com/assets/balloons/btn-update-now.gif"></a>';
		
		popUp = popUp + '</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-ie6-housing").css('opacity','1.0');
		
		$('#warn-ie6-housing').html(popUp);
		$("#warn-ie6-housing").toggle();
		
		
		
		$("#warn-ie6-housing .close").click(function() {
			$("#warn-ie6-housing").toggle();
			$("#aOverlay").css('opacity','0.0');
			$("#aOverlay").css('width','0px');
			$("#aOverlay").css('height','0px');
		});
	}
});



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=/;"; 

}


