// New JS function included for Cookie Management
function getDomainForCookie(){
    var currentHost = window.location.host;
    var domainForCookie = null;
    if(currentHost.indexOf("localhost")!=-1)
        domainForCookie = currentHost.substring(0,currentHost.indexOf(":"));
    else
        domainForCookie = currentHost.substring(currentHost.indexOf("."),currentHost.length); 

    return domainForCookie;
}

function writeCookie(name, value, nbDays, domain) {  
    	var cookieString = name + "=" + escape(value); 
   		var domainString = ""; 
   			 if (nbDays) { 
       		 var date = new Date(); 
       		 date.setTime(date.getTime()+(nbDays*24*60*60*1000)); 
       		 cookieString += "; expires="+date.toGMTString(); 
  			  } 
   			 if (domain){ 
       		 domainString = "; domain=" + escape(domain); 
   			 } 
  		document.cookie = cookieString + "; path=/" + domainString; 
}
	
function DeleteCookie(name) { 
    writeCookie(name,"",-1,getDomainForCookie());
    
}
 
function AddToFavorites(){
	if (navigator.appName != 'Microsoft Internet Explorer'){
		window.sidebar.addPanel(document.title,document.location.href,"");
	}else{
		window.external.AddFavorite(document.location.href,document.title);
	}
}

function openThePopup(page,larg,haut,scroll){
	var posXpop = (screen.width-larg)/2;
	var posYpop = 0;	
	if(larg==0) {
		posXpop =0;
		larg=screen.width;
	}	
	if(haut==0)	{
		haut=screen.height;
	}	
	param = "width="+larg+",height="+haut+",left="+posXpop+",top="+posYpop+",scrollbars="+scroll+",resizable=yes";
	popup = window.open(page,"pop",param);
}

// click_out() sera associee a tous les liens sortants
// du site
function click_out(xt_n2,url) {
	xt_med('C',xt_n2,url,'S');
}

// on parcoure tous les liens <a href> contenus dans
// la page si ces liens pointent vers un autre site
// (sortent du site) on associe a l'event "onclick"
// la fonction click_out()
function generateXitiExitLinkTag(xt_n2) {
	var siteHostName = window.location.hostname;
    for (i = 0; i < document.links.length; i++) {
        var hostname = document.links[i].hostname;
        if (hostname != '' && hostname != siteHostName) {
	        document.links[i].oldClick = (document.links[i].onclick) ? document.links[i].onclick : function() {};
            document.links[i].onclick = function() {
	        	click_out(xt_n2,this.href);
	        	return(this.oldClick());
        	};
        }
    }
}
//-->
