/******************************************************************************/
/*   					 			 					 	Javascript By Cco      	  	 				    	    */
/******************************************************************************/

if (window.attachEvent){window.attachEvent("onload", appelFonctions);}
if (window.addEventListener){window.addEventListener("load", appelFonctions, false);}
 
function appelFonctions(){
}


/*----------------------------------------------------------------------------*/
/*                  		 		 	FONCTION WRITESESSION			                      */
/*----------------------------------------------------------------------------*/

function writeSession(Nom, Valeur){
	var argc = writeSession.arguments.length;
	var argv = writeSession.arguments;

	var Expire			= (argc > 2) ? argv[2] : null;
	var Repertoire	= (argc > 3) ? argv[3] : null;
	var Domaine			= (argc > 4) ? argv[4] : null;
	var Securise		= (argc > 5) ? argv[5] : false;

	document.cookie = Nom+"="+escape(Valeur)+
	((Expire==null) ? "" : ("; expires="+Expire.toGMTString()))+
	((Repertoire==null) ? "" : ("; path="+Repertoire))+
	((Domaine==null) ? "" : ("; domain="+Domaine))+
	((Securise==true) ? "; secure" : "");
}

/*----------------------------------------------------------------------------*/
/*                  		 				FONCTION READSESSION			                    */
/*----------------------------------------------------------------------------*/

function readSession(Nom){
	var Argument	= Nom+"=";
	var ArgLen		= Argument.length;
	var CookLen		= document.cookie.length;
	var Counter		= 0;

	while (Counter<CookLen){
		var Offset = Counter + ArgLen;
		if(document.cookie.substring(Counter, Offset)==Argument){
			return getSessionVal(Offset);
		}
		Counter = document.cookie.indexOf(" ",Counter) + 1;
		if(Counter==0) break;
	}
	return null;
}

/*----------------------------------------------------------------------------*/
/*                  		 			FONCTION GETSESSIONVAL			                    */
/*----------------------------------------------------------------------------*/

function getSessionVal(Offset){
	var EndStr = document.cookie.indexOf (";", Offset);
	if(EndStr == -1){
		EndStr = document.cookie.length;
	}
	return unescape(document.cookie.substring(Offset, EndStr));
}

/*----------------------------------------------------------------------------*/
/*                  		 			FONCTION GETEXPIRESESSION                       */
/*----------------------------------------------------------------------------*/

function getExpireSession(butWhen){
	var LaDate = new Date();
	var heureEnCours = LaDate.getHours();
	
	if(butWhen == 'Tomorrow'){
		LaDate.setSeconds(0);
		LaDate.setMinutes(0);
		LaDate.setHours(heureEnCours + (24 - heureEnCours) + 2);
		//alert(LaDate);
	}
	
	return(LaDate);
}

/*----------------------------------------------------------------------------*/
/*                               Info Bulle                                   */
/*----------------------------------------------------------------------------*/

jQuery.noConflict();
jQuery(document).ready(function(){
	if (jQuery('#einfobulle').length > 0)
	{
	
		dExpire = getExpireSession('Tomorrow');
			
		if(readSession('einfobulle') != 'ok'){
			writeSession('einfobulle','ok',dExpire);
			show_transp();
		

			jQuery('.einfobulle_fermer a').live('click',function(){
				hide_transp();
				return(false);
			})
		

			
		}else{
			jQuery('#einfobulle').css('display','none');
		}
	}
	
});


jQuery(window).resize(function(){
	adjust_transp();						   
});


function show_transp(){
	var width = jQuery('body').width();
	var height = jQuery('body').height();

	jQuery("<div>").attr({'id':'transparant_bg','style':'position:absolute; top:0; left: 0;width:'+width+'px;height:'+height+'px;','class':'transparant'}).appendTo("#global"); //.tx-ebulleinfo-pi1
	
	
	var oBulle = jQuery('#einfobulle');
	var oBulleW = oBulle.width();
	var oBulleH = oBulle.height();
	
	var nW = (width/2)-(oBulleW/2);
	//var nH = (height/4)-(oBulleH/2);
	
	
	var nH = 100;
	
	if (jQuery('#einfobulle').length > 0){
		jQuery('#einfobulle').css('position','absolute'); //fixed
		jQuery('#einfobulle').css('left',nW+'px');
		jQuery('#einfobulle').css('top',nH+'px');
	}
}

function hide_transp(){
	jQuery('#transparant_bg').remove();
	jQuery('#einfobulle2').remove();
}

function adjust_transp()
{
	//var width = eval (jQuery(window).width());
	//var height = eval (jQuery(window).height()+500);
	var width = jQuery('body').width();
	var height = jQuery('body').height();
	jQuery('#transparant_bg').css({'width':width+'px','height':+height+'px'});
}

