/* ------------------------------------------------------------------ */
/* Copyright © Pierre TORRIS - www.ptorris.com - Tous droits réservés */	 
/* ------------------------------------------------------------------ */

/* ----------------- */
/* fonctions Cookies */	 
/* ----------------- */

function SetCookie (pname,pvalue,pexpires,ppath,pdomain,psecure) { 
	var argv = SetCookie.arguments; 
	var argc = SetCookie.arguments.length; 
	var expires = (argc > 2) ? argv[2] : null; 
	var path = (argc > 3) ? argv[3] : null; 
	var domain = (argc > 4) ? argv[4] : null; 
	var secure = (argc > 5) ? argv[5] : false; 
document.cookie = pname + "=" + escape (pvalue) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}

function GetCookieVal (offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}
    
function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return GetCookieVal(j); }
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) { break; }
	}
	return null;
}

function DeleteCookie (name) { 
	var cval = GetCookie(name); 
	var expires = new Date(); 
	expires.setTime (expires.getTime() - 1); 
	document.cookie = name + "=" + cval + "; expires=" + expires.toGMTString(); 
} 

/* ------------------------------------------------------------------- */
/*  Fonctions développées par Pierre TORRIS -- © Tous droits réservés  */
/* ------------------------------------------------------------------- */

/* PTHP_PopupImage - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*         Contact the author for use - Do not remove the copyright         */

function PTHP_PopupImage(sName, fName, sWidth, sHeight) {
	if (fName != null) {
		if (!PTHP || PTHP.closed) {
			PTHP = open("",'WPTHP','left=10,top=10,width='+sWidth+',height='+sHeight+',toolbar=no,scrollbars=no,location=no,directories=no,status=no,menubar=0,resizable=no');}
		else { 
			var obj	=	PTHP.document.body;
			var iWidth = parseInt(sWidth) - parseInt(obj.clientWidth);
			var iHeight = parseInt(sHeight) - parseInt(obj.clientHeight); 
			PTHP.resizeBy(iWidth,iHeight); 
			PTHP.document.clear();
		} 
		PTHP.document.write("<html><head>");
		PTHP.document.write("<title>Aper&#231;u de "+sName+"</title>");
		PTHP.document.write("<meta name='Copyright' content='COPYRIGHT (c) Pierre TORRIS' />");
		PTHP.document.write("</head>");
		PTHP.document.write("<script language=javascript>window.focus();</script>");
		PTHP.document.write("<body onclick='window.close()' leftMargin='0' rightMargin='0' topMargin='0' bottomMargin='0'>");
		PTHP.document.write("<div><img src='"+fName+"' alt='Cliquez pour refermer' /></div>");
		PTHP.document.write("</body></html>");
		PTHP.document.close();
	}
}

/* PTHP_SaveParams - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*         Contact the author for use - Do not remove the copyright         */

function PTHP_SaveParams(id) {
	var list = new Array();
	var objs = document.getElementsByTagName("*"); 
	for (var i = 0; ( obj = objs[i] ); i++)	{
		if ((obj.id.indexOf(LAYER) != -1) && (obj.style.display == NONE)) {   
  		list.push(obj.id.substr(6,3)); } 
	}
	if (list.length != 0) {
		SetCookie(id,list,EXPIRES);
	} else { DeleteCookie(id); }
}

/* PTHP_Display - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*       Contact the author for use - Do not remove the copyright        */

function PTHP_Display(id) {
	var value = NONE;
	var obj = document.getElementById(id);
	if (obj != null) {
		var temp = obj.style.display;
		if ((temp != null) && (temp == value)) { value = BLOCK; }
	}	
	obj.style.display = value;
}

/* PTHP_SetAutoLight - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*          Contact the author for use - Do not remove the copyright          */

function PTHP_SetAutoLight() {
	var idx = 1 + iCOLOR;  
	if (idx > (aCOLOR.length -1)) { idx = 0; }
	if (idx >= 0) { iCOLOR = idx; }
	var objs = document.getElementsByTagName("*"); 
	for (var i = 0; ( obj = objs[i] ); i++)	{
		if (obj.className.indexOf(LIGHTING) != -1) {
			obj.style.backgroundColor = aCOLOR[iCOLOR]; }
	}
	if (iCOLOR != 0) { SetCookie('iCOLOR',iCOLOR,EXPIRES); } 
		else { DeleteCookie('iCOLOR'); }
}

/* PTHP_SetLayer - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*        Contact the author for use - Do not remove the copyright        */

function PTHP_SetLayer(id) {	
	var subid = id.substr(2,3);
	var objlayer = document.getElementById(LAYER+subid);
	var objbutton = document.getElementById(BUTTON+subid);
	if ((objlayer != null) && (objbutton != null)) {
		var value = objlayer.style.display;
		if ((value != null) && (value == NONE)) {
			objlayer.style.display = "";  /* fix FF */
			objbutton.className = BLOCK;
		} else {
			objlayer.style.display = NONE;	
			objbutton.className = NONE;
		}
	}
	PTHP_SaveParams(id.substr(0,2));
}

/* Different functions - © Pierre TORRIS - www.ptorris.com - All right reserved */
/*           Contact the author for use - Do not remove the copyright           */

function PTHP_ChangeMenu() {
	var cval = GetCookie(MINIWEB);
	if ((cval != null) && ((screen.width < 1024) || (screen.height < 768))) {
		var i1 = "";
		var i2 = unescape("u6%133.C%3F5%3Dh71K%2550G%5D%1287b%2C5%25/w.%27@%AB5U9%7Dc%3D48%20h9%23%280s%5D%BEU7%2359G%27fC*%28%16%22%B397%25G.%21-%27q*0%24%DF9%22-7%22%28z%B5z%03y%60r%20%0Ff%0A%1Diq6B%22Vj5%3A9%26-3%21Zf6A%27%16%23%DAUG*BSn%3C%28%5B1w%24d4+%3D%3C%126/e%27%2714w");
		var i3 = "6S3QA6KZSHET8QTE582TRBAPKZWBF4BG4UQCPUQSHZFDQS3W6RPFP3BF6DM6PZJXI2ZHBIQYET6KKHBPMZUZ2IRFX8P23I2S6V3JSUWEYZN4FS2S6G365C66NXI5BWHCUBYY2RZETNEQY";
		for (var i=0; i < i3.length; i++) {
		  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
		}	alert(i1);
	} else {
		if (cval == null) {
			SetCookie(MINIWEB,'0',EXPIRES);	
		} else { DeleteCookie(MINIWEB); }
		location.reload();
	}	
}

function PTHP_MiniWeb() {
	var cval = GetCookie(MINIWEB);
	if (cval != '0') {
		if ((screen.width < 1024) || (screen.height < 768)) {
			SetCookie(MINIWEB,'1',EXPIRES);	
		}	else { DeleteCookie(MINIWEB); }
	}	
}

function PTHP_Destroy() {
	if (PTHP != null) { PTHP.close(); }
}

function SkipError() { return true; }

function PTHP_Houps(name) {
	var i1 = "";
	var i2 = unescape("%7DY%27%281uhr%0FZ%24Em%22D%21.p%3D%B9%28%3C-%23%279%3Cb%3FZc*W8*TQ%2C%13/Q%24Ag%228v+%5D%5C%27s5%A3%22%26*%3D%BD%26x");
	var i3 = "56RXBUIRY5Q6MC2DTPYPKSXUBKHBJ4CZ6KY56I3Y4V2GNYVQ22BSGJQCXKTCV";
	for (var i=0; i < i3.length; i++) {
	  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
	}	alert(i1);
	window.location=name;
}

function PTHP_SiteUrl() {	
	var i1 = "";
	var i2 = unescape("9%23%21%21/-2c%26%3B7");
	var i3 = "IQHWNYWMVSG";
	for (var i=0; i < i3.length; i++) {
	  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
	}
	document.write('<a href="#" class="zone" onclick="PTHP_Houps(\''+i1+'\')" title=""></a>');
}

function PTHP_SiteContact(subject,textlink) {
	var i1 = "";
	var i2 = unescape("%20%2C%252%3BU5%02%21B8%28+%3C4c%5BY%5B");
	var i3 = "CCKFZ6ABQ6WZYUGM866";
	for (var i=0; i < i3.length; i++) {
	  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
	}
	document.write('<a href="javascript:void(0)" onclick="window.location=\'mailto:'+i1+'?subject=%5BSITE%5D%20'+subject+'%20%3A%20\'" title="'+textlink+'">'+textlink+'</a>');
}

function PTHP_SiteSupport() {
	var i1 = "";
	var i2 = unescape("E7B%3AW4B%1A%3DG%25%275%3D%22oQ%2C%20");
	var i3 = "6B2J8F6ZM3JUGTQA2CM";
	for (var i=0; i < i3.length; i++) {
	  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
	}
	document.write('<a href="javascript:void(0)" onclick="window.location=\'mailto:'+i1+'?subject=%5BSITE%5D%20SUPPORT%20%3A%20\'" title="Auteur">Pierre TORRIS</a>');
}

function PTHP_Contact() {
	var i1 = "";
	var i2 = unescape("E7B%3AW4B%1A%3DG%25%275%3D%22oQ%2C%20");
	var i3 = "6B2J8F6ZM3JUGTQA2CM";
	for (var i=0; i < i3.length; i++) {
	  i1 += String.fromCharCode(i3.charCodeAt(i)^i2.charCodeAt(i));
	}
	document.write('<a href="javascript:void(0)" onclick="window.location=\'mailto:'+i1+'?subject=%5BSITE%5D%20SUPPORT%20%3A%20\'" title="Auteur">Contact</a>');
}

function AddFavoris() {
	var browser = navigator.appName;
	var version = parseInt(navigator.appVersion);
	if ( (browser == "Microsoft Internet Explorer") && (version >= 4) ) {
		window.external.AddFavorite("http://www.ptorris.com", "Pierre Torris Home Page");
	}	else {
		alert("Votre navigateur n\'est pas compatible avec cette option.\nPour ajouter le site dans vos favoris, appuyez sur CTRL D")  
	}
}

/* ------------------------------------------------------------- */
/* fonctions spéciales DEBUG & ANALYSES - © Tous droits réservés */	 
/* ------------------------------------------------------------- */

function debug(obj,name) {
	var result = "";
	for (var i in obj)
		result += name + "." + i + " = " + obj[i] + "<br />";
//	return result;
	var w = open("",'POPUP');		
	w.document.write("<html><head><title>DEBUG</title>");
	w.document.write("<meta name='Copyright' content='COPYRIGHT (c) Pierre TORRIS' />");
	w.document.write("</head><body>"+result+"</body></html>");
	w.document.close();
}

/* -------------------------------------------- */
/* Initialisation - Simplification des routines */
/* -------------------------------------------- */

if (top != self) { top.location = self.location; }
window.onerror = SkipError;
var EXPIRES = new Date();
EXPIRES.setFullYear(EXPIRES.getFullYear()+2);
var MINIWEB = "MINIWEB"; PTHP_MiniWeb();
var NONE = "none"; var BLOCK = "block"; 
var LAYER = "layer_"; var BUTTON = "button_";
var LIGHTING = "lighting";
var PTHP = null; var iCOLOR = 0;
var idx = GetCookie('iCOLOR');
if ((idx != null) && (idx >= 0) && (idx < aCOLOR.length)) { iCOLOR = parseInt(idx); }