var siteID = 'chpshl_';
var seasonsgreetingspopupShownCount = 0;
var seasonsgreetingspopupShowTimes = 3;

var popupImageUrl = 'gui/seasonsgreeting2011.jpg';
var popupImageWidth = 840;
var popupImageHeight = 340;

function showGreetPopup() {

   var offsetTop = -(popupImageHeight/2);
   var offsetLeft = -(popupImageWidth/2);
   
   var html =  '<div id="seasonsgreetingspopup" style="visibility:hidden;position:absolute;z-index:9;top:50%;left:50%;margin-left:'+offsetLeft+'px;margin-top:'+offsetTop+'px">';
   html+=      '<a href="javascript:closeGreetPopup();"><img src="'+popupImageUrl+'" alt="Best Wishes" border="0" usemap="#seasonsgreetingspopupMap" /></a>';
   //html+=      '<map name="seasonsgreetingspopupMap" id="seasonsgreetingspopupMap"><area shape="circle" coords="633,52,22" href="javascript:closeGreetPopup();" alt="Sluiten" /></map>';
   html+= '</div>';

   if (typeof jQuery != 'undefined') {  
	  $(document).ready(function() {
		 $("body").append(html);
		 $("#seasonsgreetingspopup").css('visibility','visible').hide().fadeIn(800);
	  });
   } else {
	  document.write(html);
	  document.getElementById("seasonsgreetingspopup").style.visibility = "visible";
   }
   
   seasonsgreetingspopupShownCount = parseInt(seasonsgreetingspopupShownCount) +1;
}

function closeGreetPopup() {
   if (typeof jQuery != 'undefined') {  
	  $(document).ready(function() {
		 $("#seasonsgreetingspopup").fadeOut(300);
	  });
   } else {
	  document.getElementById("seasonsgreetingspopup").style.visibility = "hidden";
   }
}

function setSeasonsCookie(c_name,value,exdays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie=c_name + "=" + c_value;
}

function getSeasonsCookie(c_name)
{
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
		x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
		y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
		x=x.replace(/^\s+|\s+$/g,"");
		if (x==c_name)
		{
			return unescape(y);
		}
	}
}

var popupshown=getSeasonsCookie(siteID+"seasonsgreetingspopupShown");
if (popupshown != null && popupshown != "")
{
	seasonsgreetingspopupShownCount = parseInt(popupshown);
}
// show popup if not already shown n times (cookie set)
if (seasonsgreetingspopupShownCount < seasonsgreetingspopupShowTimes)
{
	// show popup
	showGreetPopup();
	// set cookie
	setSeasonsCookie(siteID+"seasonsgreetingspopupShown",seasonsgreetingspopupShownCount,365);
}



