//*****************************************************************
// Fonctions pour popup J'aime Facebook sur la page d'accueil
// Créé le 26/05/2011 par GRDevelopment
//*****************************************************************
function fctGetCookie(strName)
{  
	var i, strNom, strVal;
	var aryCookies=document.cookie.split(";");
	
	for (i=0;i<aryCookies.length;i++)
	{
		strNom = aryCookies[i].substr(0,aryCookies[i].indexOf("="));
		strVal = aryCookies[i].substr(aryCookies[i].indexOf("=")+1);
		strNom = strNom.replace(/^\s+|\s+$/g,"");
		if (strNom == strName)
		{
   		return unescape(strVal);
   	}
	}
}

function fctSetCookie(strName,strVal,exdays)
{
	var exdate = new Date();
	exdate.setDate(exdate.getDate() + exdays);
	var strVal = escape(strVal) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
	document.cookie = strName + "=" + strVal;
}


// Fonction qui ouvre le popup Facebook sur la page d'accueil du site
var objPopup = new fctOpenPopupDiv();   //obligatoire pour créer objet popup DIV

function fctLoadPopupFacebook()
{  
	var strHTML = fctFillPopup();//"<b>Ceci est mon popup</b><br><br><a href='javascript:objPopup.ClosePopup();'>FERMER</a>";
	objPopup.OpenPopup(strHTML, 245, 500);
}

function fctOpenPopupDiv() 
{  
	this.square = null; 
   this.overdiv = null; 
   
   this.OpenPopup = function(msgtxt, iHeight, iWidth)
	{             
		var aryPageSizes = fctReturnPageSizes();
		
		window.scrollTo(1,1);
		 
      this.overdiv = document.createElement("div"); 
      this.overdiv.className = "overdiv";
		this.overdiv.style.width = aryPageSizes[0] + "px";
		this.overdiv.style.height = aryPageSizes[1] + "px";
 
      this.square = document.createElement("div"); 
      this.square.className = "square";
      this.square.style.width = iWidth + "px";
      this.square.style.height = iHeight + "px";
      
		var haut=(aryPageSizes[3]-iHeight)/2;
		var gauche=(aryPageSizes[2]-iWidth)/2;
		this.square.style.position = "absolute";
		this.square.style.top = haut + "px";
		this.square.style.left = gauche + "px";
		this.square.Code = this; 
      
		var msg = document.createElement("div"); 
      msg.innerHTML = msgtxt; 
      this.square.appendChild(msg);
      document.body.appendChild(this.overdiv);
		document.body.appendChild(this.square); 
   } 
   
   this.ClosePopup = function() 
	{ 
   	if (this.square != null) 
		{ 
         document.body.removeChild(this.square); 
         this.square = null; 
      } 
      if (this.overdiv != null) 
		{ 
      	document.body.removeChild(this.overdiv); 
      	this.overdiv = null; 
      } 
   } 
} 

function fctReturnPageSizes()
{	                        
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	                                            
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari         
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function fctFillPopup()
{
	var strHTML = "";
	
	strHTML += "<table width='595' height='290' border='0' cellpadding='0' cellspacing='0' style='table-layout:fixed;background-color:#FFFFFF;'>";
	strHTML += "<tr>";
	strHTML += "<td valign='top'>";
	strHTML += "<map id='mapClose' name='mapClose'>";
	strHTML += "<area shape='rect' coords='535,5,590,27' href='javascript:objPopup.ClosePopup();' alt='Fermer' />";
	strHTML += "</map>";
	strHTML += "<img src='img/popupJaime.jpg' border='0' width='595' height='255' usemap='#mapClose'>";
	strHTML += "<div id='divJaime' name='divJaime' style='position:absolute;top:218px;left:143px;'>";
	//strHTML += "<iframe src='http://www.facebook.com/plugins/like.php?app_id=213261952040658&amp;href=http%3A%2F%2Fwww.facebook.com%2F%23%21%2FBelleIleLiege&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=66' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:450px; height:66px; background:transparent;'></iframe>";
	strHTML += "<iframe src='http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2F%23%21%2FBelleIleLiege&amp;send=false&amp;layout=standard&amp;width=450&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font=arial&amp;height=66' scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:450px; height:66px; background:transparent;'></iframe>";
	strHTML += "</div>";
	strHTML += "</td>";
	strHTML += "</tr>";
	strHTML += "</table>";
	
	return strHTML;
}
