<!-- 
//******************************************************
//
//Copyright (c) 2006, T2B&H
//
//Source: common_functions.js
//
//Revision: KERNEL 3.2
//
//Date: 2006/05/31
//
//Author: T2B&H
//
//Description: Fonctions Javascript partagées
//			  
//*******************************************************

//fonction de rollover toute version
function swap(name,adr,calque) {
	if (navigateur.ns4 && calque!=null) {
		//cheminiment calque pour ns
		scalque = ''
		if (calque.indexOf('§')!=-1) {
			calquepath = calque.split('§');
			calque = calquepath[calquepath.length-1]
			for (i=0;i<calquepath.length-1;i++) { 
				scalque += 'document.layers["'+calquepath[i]+'"].';}}
		if (eval(scalque+'document.layers["'+calque+'"].document.images["'+name+'"]')) { eval(scalque+'document.layers["'+calque+'"].document.images["'+name+'"].src="'+adr+'"');}}
	else {
		if (navigateur.ok) {
			if (document.images[name]) {document.images[name].src=adr;}}}
}

// detection du navigateur
function NObjNavigateur(){ //Browsercheck (needed)
	this.ver=navigator.appVersion;
	this.agent=navigator.userAgent;
	this.dom=document.getElementById?1:0;
	this.opera5=(this.agent.indexOf("Opera 5")>-1)?1:0;
	this.firefox=(this.agent.indexOf("Firefox")>-1)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=(this.ie4||this.ie5||this.ie6||this.ie7)?1:0;
	this.mac=(this.agent.indexOf("Mac")>-1)?1:0;
	this.ns6=(this.dom && parseInt(this.ver) >= 5 && !this.firefox) ?1:0;
	this.ns4=(document.layers && !this.dom && !this.firefox)?1:0;
	this.ok=(this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5||this.firefox)?1:0;
	return this
}
var navigateur=new NObjNavigateur();

// correction du manque d'état over pour les menu dynamique sous IE
function FindInChildNodeMenuDD(sNode,sTag,indis) {
	for (var i=0; i<sNode.childNodes.length; i++) {
		var node1=sNode.childNodes[i];
		if (node1.tagName==sTag) {
			node1.onmouseover=function() {
				this.className+=' over';}
			node1.onmouseout=function() {
				this.className=this.className.replace(' over', '');}}
		if (node1.hasChildNodes()) {
			FindInChildNodeMenuDD(node1,sTag,(indis+1));}}
}
// dummy pour le placement relatif des elements dhtml de la page
var oDummy=new Array();
window.onload=RelativeToAbsolute

function RelativeToAbsolute() {
	if (navigateur.ns6) {
		for (i=0;i<oDummy.length;i++) {
			var oDummyLayer=document.getElementById(oDummy[i][0])
			var oModulLayer=document.getElementById(oDummy[i][1])
			if (oDummyLayer&&oModulLayer) {
				var newX=CssToNum(oDummyLayer.offsetLeft)+CssToNum(oModulLayer.style.left);
				var newY=CssToNum(oDummyLayer.offsetTop)+CssToNum(oModulLayer.style.top);
				var newW=CssToNum(oModulLayer.offsetWidth)+CssToNum(oModulLayer.style.margin)+CssToNum(oModulLayer.style.marginLeft)+CssToNum(oModulLayer.style.marginRight);
				var newH=CssToNum(oModulLayer.offsetHeight)+CssToNum(oModulLayer.style.margin)+CssToNum(oModulLayer.style.marginTop)+CssToNum(oModulLayer.style.marginBottom);
				var newZ=CssToNum(oModulLayer.style.zIndex);
				//alert(oDummy[i][1]+' : '+newX+'-'+newY+'-'+newW+'-'+newH+'-'+newZ+'/\n');
				//oDummyLayer.style.backgroundColor='#FF0000';
				oModulLayer.style.left=newX;
				oModulLayer.style.top=newY;
				oModulLayer.style.visibility='visible';
				oDummyLayer.style.width=newW;
				oDummyLayer.style.height=newH;}}}
}
//retourne une valeur numerique des css
function CssToNum(CssObj) {
	if (isNaN(CssObj)) CssObj=Number(CssObj.replace(/px||pt||%/gi,''));
	if (isNaN(CssObj)) CssObj=0;
	return Number(CssObj);
}


//open window du site
function ouvrewin1(adr,nom,winWidth,winHeight) {
	window.open(adr,nom,"width="+winWidth+",height="+winHeight+",scrollbars=yes,")}
function ouvrewin3(adr,nom,winWidth,winHeight) {
	window.open(adr,nom,"width="+winWidth+",height="+winHeight+",resizable=yes,")
}
function ouvrewinadmin(adr,nom,winWidth,winHeight,isResizable) {
	window.open(adr,nom,"width="+winWidth+",height="+winHeight+",resizable="+isResizable+",scrollbars=yes")
}

function OpenPopWindow(sAdr,sName,iWinWidth,iWinHeight) {
//	window.open(sAdr,sName,"width="+iWinWidth+",height="+iWinHeight+",scrollbars=yes")
var sCmd
sCmd = sName + ' = window.open("'+ sAdr + '","' + sName + '","width=' + iWinWidth + ',height=' + iWinHeight + ',scrollbars=yes")';
	eval(sCmd);
	eval(sName + '.focus();');
}

// BEGIN VIS
function OpenVisWindow(sAdr,sName,iWinWidth,iWinHeight,sOption) {
	window.open(sAdr,sName,"width="+iWinWidth+",height="+iWinHeight+sOption)
}
// END VIS

// fonction donnant l'index correspondant à une valeur donnée dans un selecteur
function getIndex(oSelect, sValue) {
	var iIndex = -1;
	var i;
	for (i=0;i<oSelect.options.length;i++) {
		if (oSelect.options[i].value == sValue) iIndex = i;
	}
	return(iIndex);
}

function ImageMax(sUrl) {
   html = '<html> <head> <title>Image</title> </head> <body marginleft="0" marginheight="0" leftmargin="0" topmargin="0" bgcolor="#FFFFFF"><IMG src="'+sUrl+'" BORDER=0 NAME=ImageMax onLoad="window.resizeTo(document.ImageMax.width+13, document.ImageMax.height+55)"></body></html>';
   popupImage =    window.open('','zoomimg','toolbar=0, location=0, directories=0, menuBar=0, scrollbars=0, resizable=1');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close()
   popupImage.focus();
}

// fonction d'impression de documents
function SendToPrint(sHeaderContent, sBodyContent, sPopTarget)
	{
	//sBodyContent.replace(/%22/gi, '"');
	
	//var sBodyHeader = new String(sBodyContent);
	//sBodyHeader.replace(/%22/gi, '"');
	
	var pattern = /%22/gi;
	var sBodyHeader = sBodyContent.replace(pattern,'"');
				
	eval(sPopTarget + '.document.open();');
	eval(sPopTarget + '.document.write("<html><head><title>Webadmin - Impression</title>");');
	eval(sPopTarget + '.document.write(sHeaderContent);');
	eval(sPopTarget + '.document.write("</head><body>");');
	eval(sPopTarget + '.document.writeln(sBodyHeader);');
	eval(sPopTarget + '.document.write("</body></html>");');
	eval(sPopTarget + '.document.close();');
	eval(sPopTarget + '.print();');
	}

function asme(sEmail) {
	sEmail = ReturnDecodedEmail(sEmail);
	document.location.href='mailto:'+sEmail;
}

function ReturnDecodedEmail(sEmail) {
	sEmail = sEmail.replace('[a]','@').replace('[dot]','.');
	return sEmail;
}

// -->