<!--
	
	// Configuration
	
	var Checked = new Array();
	
	Checked["a"]    = true;        // [ Activer la reecriture des liens hypertexte          | href   | onclick  ]
	Checked["area"] = true;        // [ Activer la reecriture des zones d'images cliquables | href   | onclick  ]
	Checked["form"] = true;        // [ Activer la reecriture des formulaires               | action | onsubmit ]
	
	var CookInfos = new Array();
	
	CookInfos["name"] = "ptt_popunder";
	CookInfos["value"] = "yes";
	CookInfos["delay"] = 7;
	
	// Variables
	
	var MyLocation = self.location.toString().substr(self.location.toString().indexOf(":"),self.location.toString().indexOf("/",self.location.toString().indexOf(":")+3)-self.location.toString().indexOf(":")); /* var MyLocation = "://www.princessetamtam.com"; */
	
	var isMOZ = (navigator.appName.substring(0,3) == "Net") ? true : false ;
	var isIE  = (navigator.appName.substring(0,3) == "Net") ? false : true ;
	var isIE7 = (navigator.appVersion.indexOf("MSIE 7.0") != -1) ? true : false ;
	
	// Traitement lorsque le DOM est charge
	
	$(document).ready(function() {
	//window.addEvent("domready",function() {
		
		// [ Location ]
		
		var MyLocationHTTP  = "http" + MyLocation;
		var MyLocationHTTPS = "https" + MyLocation;
		
		// [ Traitement ]
		
		if (Checked["a"] || Checked["area"]) { // [ Meme traitement pour les liens et pour les zones cliquables ]
			
			// [ Recuperation des tags ]
			
			var Elems     = new Array();
			var ElemsA    = document.body.getElementsByTagName("a");
			var ElemsArea = document.body.getElementsByTagName("area");
			for ( var i = 0 ; i < ElemsA.length    ; i++ ) Elems.push(ElemsA[i]);
			for ( var i = 0 ; i < ElemsArea.length ; i++ ) Elems.push(ElemsArea[i]);
			
			// [ Lecture des tags ]
			
			for ( var i = 0 ; i < Elems.length ; i++ ) {
				
				var myHref    = Elems[i].href    != undefined ? Elems[i].href.toString()    : "" ;
				var myOnClick = Elems[i].onclick != undefined ? Elems[i].onclick.toString() : "" ;
				
				if (myHref.indexOf(MyLocationHTTP) == 0 || myHref.indexOf(MyLocationHTTPS) == 0 || ( myHref.indexOf("http:") == -1 && myHref.indexOf("https:") == -1 ) || myHref == "") {
					
					if (isMOZ) {
						/*Elems[i].addEvent("click",function() {
							DisablePopup();
							DisableKillSession();
						});*/
						$(Elems[i]).click(function() {
							DisablePopup();
							DisableKillSession();
						});
					} else {
						if (myOnClick == "") Elems[i].onclick = function() { DisablePopup(); DisableKillSession(); };
					}
					
				} else { /* Lien externe */ }
				
			}
			
		}
		
		if (Checked["form"]) {
			
			// [ Recuperation des tags ]
			
			var Elems     = new Array();
			var ElemsForm = document.body.getElementsByTagName("form");
			for ( var i = 0 ; i < ElemsForm.length ; i++ ) Elems.push(ElemsForm[i]);
			
			// [ Lecture des tags ]
			
			for ( var i = 0 ; i < Elems.length ; i++ ) {
				
				var myAction   = Elems[i].action   != undefined ? Elems[i].action.toString()   : "" ;
				var myOnSubmit = Elems[i].onsubmit != undefined ? Elems[i].onsubmit.toString() : "" ;
				
				if (myAction.indexOf(MyLocationHTTP) == 0 || myAction.indexOf(MyLocationHTTPS) == 0 || ( myAction.indexOf("http:") == -1 && myAction.indexOf("https:") == -1 ) || myAction == "") {
					
					if (isMOZ) {
						/*Elems[i].addEvent("onsubmit",function() {
							DisablePopup();
							DisableKillSession();
						});*/
						$(Elems[i]).submit(function() {
							DisablePopup();
							DisableKillSession();
						});
					} else {
						if (myOnClick == "") Elems[i].onsubmit = function() { DisablePopup(); DisableKillSession(); };
					}
					
				} else { /* Lien externe */ }
				
			}
			
		}
		
	});
	
	
	/* ***** ***** */
	
	
	Cook_Write = function(fName,fValue,fExpires,fPath,fDomain,fSecure) {
		
		var expires = "";
		if (fExpires != undefined && fExpires != "") {
			var myDate = new Date();
			myDate.setTime(myDate.getTime()+(fExpires*24*60*60*1000));
			expires = "; expires=" + myDate.toGMTString();
		}
		
		var CookieContent = fName + "=" + escape(fValue) + expires;
		
		if (fPath    != null) CookieContent += "; path=" + fPath;
		if (fDomain  != null) CookieContent += "; domain=" + fDomain;
		if (fSecure  == true) CookieContent += "; secure";
		
		document.cookie = CookieContent;
		
	};
	
	Cook_Read = function(fName) {
		
		var CookieName = fName + "=";
		var CookieNameLen = CookieName.length;
		
		for ( var i = 0 ; i < document.cookie.length ; i++ ) {
			
			if (document.cookie.substr(i,CookieNameLen) == CookieName) {
				var EndString = document.cookie.indexOf(";",i + CookieNameLen);
				if (EndString == -1) EndString = document.cookie.length;
				return unescape(document.cookie.substring(i + CookieNameLen,EndString));
			}
			
			i = document.cookie.indexOf(" ",i) + 1;
			if (i == 0 || i == -1) break;
			
		}
		
	};
	
	Cook_Defined = function(fName) {
		
		var CookieName = fName + "=";
		
		if (document.cookie.toString().indexOf(CookieName) !== -1) {
			return(true);
		} else {
			return(false);
		}
		
	};
	
	
	/* ***** ***** */
	
	
	
	// Variable d'activation du popup
	
	document.popupEnabled = ( Cook_Defined(CookInfos["name"]) ) ? false : true ;
	
	if (self.location != top.location) { document.popupEnabled = false; } // Si on est dans une frame
	
	// Fonction de desactivation du pop-under
	
	DisablePopup = function() {
		
		document.popupEnabled = false;
		
	};
	
	
	// Variable d'activation du la fermeture de session
	
	document.killSessionEnabled = true; // [ Activer la fermeture de session a la fermeture du navigateur ]
	
	if (self.location != top.location) { document.killSessionEnabled = false; } // Si on est dans une frame
	
	// Fonction de desactivation de la fermeture de session
	
	DisableKillSession = function() {
	
		document.killSessionEnabled = false;
		
	};
	
	// Sortie de page
	
	OpenPopunder = function() {
	    
		if (document.popupEnabled == true) {
			
			Cook_Write(CookInfos["name"],CookInfos["value"],CookInfos["delay"],"/");
			
			var myWidth = 896;
			var myHeight = 518;
			var myLeft = ( screen.width - myWidth ) / 2;
			var myTop = ( screen.height - myHeight ) / 2;
			
			var myPop = window.open(PopupUrl,"pttpop","width=" + myWidth + ",height=" + myHeight + ",left=" + myLeft + ",top=" + myTop + "");
			if (myPop) { 
			    myPop.blur();
			    window.focus();
			}
			
		}
		
		// KillSession
		if (document.killSessionEnabled == true) {
			
			var isIE  = /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent);
			if (!isIE) {
			    sendRequest(KillSessionUrl);
			}
			else 
			{
			    var myWidth = 896;
			    var myHeight = 518;
			    var myLeft = ( screen.width - myWidth ) / 2;
			    var myTop = ( screen.height - myHeight ) / 2;
    			
			    var myPop = window.open(KillSessionUrl,"pttpop","width=" + myWidth + ",height=" + myHeight + ",left=" + myLeft + ",top=" + myTop + "");
			    if (myPop) { 
			        myPop.blur();
			        window.focus();
			    }
			}

        }
	};
	
	
	//window.addEvent("beforeunload",function() {
	//$(window).unload(function() {
	//$(window).bind("beforeunload",function(){
	window.onunload = function() {
		
		OpenPopunder();
		
	};
	//});
	
	DisablePopup();
	DisableKillSession();
	
	
	function sendRequest(url,callback,postData) {
	    var req = createXMLHTTPObject();
	    if (!req) return;
	    var method = (postData) ? "POST" : "GET";
	    req.open(method,url,true);
	    req.setRequestHeader('User-Agent','XMLHTTP/1.0');
	    if (postData)
		    req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
	    req.onreadystatechange = function () {
		    if (req.readyState != 4) return;
		    if (req.status != 200 && req.status != 304) {
    //			alert('HTTP error ' + req.status);
			    return;
		    }
		    callback(req);
	    }
	    if (req.readyState == 4) return;
	    req.send(postData);
    }

    var XMLHttpFactories = [
	    function () {return new XMLHttpRequest()},
	    function () {return new ActiveXObject("Msxml2.XMLHTTP")},
	    function () {return new ActiveXObject("Msxml3.XMLHTTP")},
	    function () {return new ActiveXObject("Microsoft.XMLHTTP")}
    ];

    function createXMLHTTPObject() {
	    var xmlhttp = false;
	    for (var i=0;i<XMLHttpFactories.length;i++) {
		    try {
			    xmlhttp = XMLHttpFactories[i]();
		    }
		    catch (e) {
			    continue;
		    }
		    break;
	    }
	    return xmlhttp;
    }

	
-->
