// ************************
// DEFINITION DES VARIABLES
// ************************

TAB_pics = new Array();

var GEN_reppic = "";
var GEN_repasp = "";
var GEN_repcss = "";
var GEN_seslan = "";
var GEN_seseta = "";

// ********************
// DETECTION NAVIGATEUR
// ********************

var GEN_navnam = "";
var GEN_navver = "";

var nv_detect = navigator.userAgent.toLowerCase();

var nav_opera = (nv_detect.indexOf("opera") != -1);
var nav_ie = (!nav_opera && nv_detect.indexOf("msie") !=-1);
var nav_webtv = (nv_detect.indexOf("webtv") !=-1);
var nav_icab = (nv_detect.indexOf("icab") != -1);
var nav_netscape = (!nav_opera && nv_detect.indexOf("compatible") ==-1);

GEN_navver = navigator.appVersion.charAt(0);
if (nav_opera) { GEN_navver = nv_detect.charAt(nv_detect.indexOf('opera ') + 6) };
if (nav_ie && (nv_detect.indexOf("5.") != -1)){ GEN_navver = 5; }
if (nav_ie && GEN_navver < 3){ GEN_navver = 3; }

if (nav_opera) { GEN_navnam = "opera" };
if (nav_icab) { GEN_navnam = "icab" };
if (nav_ie) { GEN_navnam = "explorer" };
if (nav_webtv) { GEN_navnam = "webtv" };
if (nav_netscape) { GEN_navnam = "netscape" };


// *************************
// INITIALISATION JAVASCRIPT
// *************************

function JSC_initjavascript(reppic,repasp,repcss,seslan){
	GEN_reppic = reppic;
	GEN_repasp = repasp;
	GEN_repcss = repcss;
	GEN_seslan = seslan;
}

// ****************
// FONCTION PRELOAD
// ****************

function JSC_preload(name, first, second) {
	TAB_pics[name] = new Array();
	TAB_pics[name][0] = new Image();
	TAB_pics[name][0].src = first;
	TAB_pics[name][1] = new Image();
	TAB_pics[name][1].src = second;
}

// ****************
// FONCTION PRELOAD
// ****************

function JSC_initpics(name, first, second) {
	TAB_pics[name] = new Array();
	TAB_pics[name][0] = first;
	TAB_pics[name][1] = second;
}

// ********************
// FONCTION ROLLOVER ON
// ********************

function JSC_picon(name,layerName){

	if(GEN_navnam == "netscape" && GEN_navver < 5 && layerName != null && layerName != ""){

		document.layers[layerName].document.images[name].src = TAB_pics[name][1].src;

	}
	else{

		JSC_getObjectName(name).src = TAB_pics[name][1].src;

	}

}

// **********************
// FONCTION ROLLOVER OFF
// **********************

function JSC_picoff(name,layerName){

	if(GEN_navnam == "netscape" && GEN_navver < 5 && layerName != null && layerName != ""){

		document.layers[layerName].document.images[name].src = TAB_pics[name][0].src;

	}
	else{

		JSC_getObjectName(name).src = TAB_pics[name][0].src;

	}

}

// *************************
// FONCTION INSERTION PICKER
// *************************

var GEN_nombrepickers = 0;
var GEN_pickercaller = "";
var GEN_pickertarget = "";
var GEN_pickeraction = "";

function JSC_insertcolorpicker(targetinput,action){

	if(GEN_nombrepickers==0){JSC_makecolorpickerdiv()}; 

	++GEN_nombrepickers;

	if(targetinput==null || targetinput==""){alert("Le 'Color Picker " + GEN_nombrepickers + "' ne marchera pas, pas de TARGET spécifié !")}; 

	JSC_preload("picker" + GEN_nombrepickers, "/common/images/picker_off.gif", "/common/images/picker_on.gif");

	document.write('<A HREF="javascript:JSC_opencolorpickerdiv(\'picker' + GEN_nombrepickers + '\',\'' + targetinput + '\',' + action + ')" OnMouseOver="JSC_picon(\'' + 'picker' + GEN_nombrepickers + '\',\'\')" OnMouseOut="JSC_picoff(\'' + 'picker' + GEN_nombrepickers + '\',\'\')">');
	document.write('<IMG SRC="/common/images/picker_off.gif" BORDER="0" WIDTH="23" HEIGHT="22" ALIGN="Bottom" NAME="picker' + GEN_nombrepickers + '" ALT="Cliquez pour choisir une couleur">');
	document.write('</A>');

}

function JSC_makecolorpickerdiv() {

	var cols		= 18
	var cellwidth	= 14
	var cellheight	= 15
	var cellspacing	= 1

	var tablewidth	= cellspacing + cols * (cellwidth + cellspacing)
	var tableheight	= cellspacing + (216 / cols) * (cellheight + cellspacing)

	var cpaColorElts = new Array("00","33","66","99","CC","FF")
	var cpaColors    = new Array()

	var x = 0

	for (cpti = 0; cpti < 6; cpti++) {
		var c1 = cpaColorElts[cpti]
		for (cptj = 0; cptj < 6; cptj++) {
			var c2 = cpaColorElts[cptj]
			for (cptk = 0; cptk < 6; cptk++) {
				var c3 = cpaColorElts[cptk]
				cpaColors[x] = c1 + c2 + c3
				x++
			}
		}
	}

	document.write('<div id="colpicker" style="display:none;position:absolute">');
	document.write('<table border="0" cellspacing="0" cellpadding="1" bgcolor="#CCCCCC"><tr><td>');
	document.write('<table cellspacing="' + cellspacing + '" width="' + tablewidth + '" border="0" cellpadding="0" bgcolor="#FFFFFF">');
	document.write('<tr>');
	document.write('<td height="' + cellheight + '" align="left"><font face="verdana,arial" size="1" color="#000000"><b>CHOISISSEZ UNE COULEUR</B></font></td>');
	document.write('<td height="' + cellheight + '" align="right" bgcolor="#FFFFFF" style="cursor:hand"><A HREF="javascript:JSC_closecolorpickerdiv()" onMouseOver="window.status=\'fermer la fenêtre des couleurs\'" onMouseOut="window.status=\'\'"><IMG SRC="/common/images/picker_close.gif" HEIGHT="13" WIDTH="15" BORDER="0" ALT="fermer"></A></td>');
	document.write('</tr>');
	document.write('</table>');
	document.write('<table cellspacing="' + cellspacing + '" width="' + tablewidth + '" height="' + tableheight + '" border="0" cellpadding="0" bgcolor="#FFFFFF">');

 	for (cpti = 0; cpti < cpaColors.length; cpti++) {
		var mouseOverJS = ' onMouseOver="window.status=\'#' + cpaColors[cpti] + '\'" '
		var mouseOutJS  = ' onMouseOut="window.status=\'\'" '
		var clickJS		= ' onClick="JSC_colorpickerreturnvalue(\'' + cpaColors[cpti] + '\')" '
		
		if (cpti % cols == 0) {document.write("<tr>")}
		document.write('<td width="' + cellwidth + '" height="' + cellheight + '"' + mouseOverJS + mouseOutJS + clickJS + 'bgcolor="#' + cpaColors[cpti] + '" title="#' + cpaColors[cpti] + '" style="cursor: hand"></td>')
		if ((cpti + 1) % cols == 0) {document.write("</tr>")}

	}

	document.write('<tr>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#000000\'" onMouseOut="window.status=\'\'" bgcolor="#000000" onClick="JSC_colorpickerreturnvalue(\'000000\')"  title="#000000" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>NOIR</B></font></td>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#FFFFFF\'" onMouseOut="window.status=\'\'" bgcolor="#FFFFFF" onClick="JSC_colorpickerreturnvalue(\'FFFFFF\')"  title="#FFFFFF" style="cursor:hand"><font face="verdana,arial" size="1" color="#000000"><b>BLANC</B></font></td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#CC0000\'" onMouseOut="window.status=\'\'" bgcolor="#CC0000" onClick="JSC_colorpickerreturnvalue(\'CC0000\')"  title="#CC0000" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>ROUGE</B></font></td>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#990000\'" onMouseOut="window.status=\'\'" bgcolor="#990000" onClick="JSC_colorpickerreturnvalue(\'990000\')"  title="#990000" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>ROUGE FONCE</B></font></td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#00CC00\'" onMouseOut="window.status=\'\'" bgcolor="#00CC00" onClick="JSC_colorpickerreturnvalue(\'00CC00\')"  title="#00CC00" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>VERT</B></font></td>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#009900\'" onMouseOut="window.status=\'\'" bgcolor="#009900" onClick="JSC_colorpickerreturnvalue(\'009900\')"  title="#009900" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>VERT FONCE</B></font></td>');
	document.write('</tr>');
	document.write('<tr>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#0000CC\'" onMouseOut="window.status=\'\'" bgcolor="#0000CC" onClick="JSC_colorpickerreturnvalue(\'0000CC\')"  title="#0000CC" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>BLEU</B></font></td>');
	document.write('<td colspan="' + (cols/2) + '" height="' + cellheight + '" align="center" onMouseOver="window.status=\'#000099\'" onMouseOut="window.status=\'\'" bgcolor="#000099" onClick="JSC_colorpickerreturnvalue(\'000099\')"  title="#000099" style="cursor:hand"><font face="verdana,arial" size="1" color="#FFFFFF"><b>BLEU FONCE</B></font></td>');
	document.write('</tr>');
	document.write('</td></tr></table>');
	document.write('</td></tr></table>');
	document.write('</div>');

	
}

function JSC_opencolorpickerdiv(pickername_,pickertarget_,pickeraction_){

	GEN_pickercaller = pickername_;
	GEN_pickertarget = pickertarget_;
	GEN_pickeraction = pickeraction_;

	var eletop = 0;
	var eleleft = 0;
	var eleobj = document.all[pickername_];

	while(eleobj){
		eletop += eleobj.offsetTop;
		eleleft += eleobj.offsetLeft;
		eleobj = eleobj.offsetParent;
    } 

	document.all.colpicker.style.top = eletop;
	document.all.colpicker.style.left = eleleft + 25;
	document.all.colpicker.style.display = "";

}

function JSC_colorpickerreturnvalue(value) {
	document.all[GEN_pickertarget].value = value;
	JSC_closecolorpickerdiv();
	if(GEN_pickeraction==1){chkCfgColMen()};
	if(GEN_pickeraction==2){chkCfgColLig()};
	if(GEN_pickeraction==3){chkCfgColSuj()};
}

function JSC_closecolorpickerdiv() {
	document.all.colpicker.style.display = "none";
}


// ************
// CONFIRMATION
// ************

function JSC_confirm(confirm) {
	return(window.confirm(confirm));
}

// **********
// POPUP FULL
// **********

function JSC_popupFull(url){

	popup = window.open( url, 'JSCPopup', 'width=800,height=600,toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1');

}

// *********
// POPUP URL
// *********

function JSC_popupUrl(titre,url,largeur,hauteur,scroll){

	popup = window.open( '', titre, 'width=' + largeur + ',height=' + hauteur + ',scrollbars=' + scroll);
	popup.focus();
	popup.location = url;

}

// ******************
// POPUP URL NO FOCUS
// ******************

function JSC_popupUrlNoFocus(titre,url,largeur,hauteur,scroll){

	popup = window.open( url, titre, 'width=' + largeur + ',height=' + hauteur + ',scrollbars=' + scroll);

}

// **********
// POPUP FTP
// **********

function JSC_popupFtp(url){

	popup = window.open( url, 'FTPPopup', 'width=600,height=400,toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1');

}

// ***************
// REDIRECTION URL
// ***************

function JSC_redirectUrl(url,target){ 

	if(url=="" || url==null){
		url="#"
	}

	if(target.toLowerCase()=="_blank"){
	
		JSC_popupFull(url)
	
	}
	else{

		document.location.target = target;
		document.location = url;

	}

} 

// ********************
// RECUPERATION D'OBJET
// ********************

function JSC_getObjectId(objectID){

	if(GEN_navnam == "explorer"){return document.all[objectID]}
	else{return document.getElementById(objectID)}
}

function JSC_getObjectName(objectName){

	if(GEN_navnam == "explorer"){return document.all[objectName]}
	else{return document.getElementsByName(objectName)[0]}
}

function JSC_getTopObjectId(objectID){

	if(GEN_navnam == "explorer"){return parent.document.all[objectID]}
	else{return parent.document.getElementById(objectID)}
}

function JSC_getTopObjectName(objectName){

	if(GEN_navnam == "explorer"){return parent.document.all[objectName]}
	else{return parent.document.getElementsByName(objectName)[0]}

}

function JSC_getTargetObjectId(ftarget,objectID){

	if(GEN_navnam == "explorer"){return top.frames[ftarget].document.all[objectID]}
	else{return top.frames[ftarget].document.getElementById(objectID)}
}

function JSC_getTargetObjectName(ftarget,objectName){

	if(GEN_navnam == "explorer"){return top.frames[ftarget].document.all[objectName]}
	else{return top.frames[ftarget].document.getElementsByName(objectName)[0]}

}

// ***************
// DETECTION FLASH
// ***************

var MM_FlashSnifferURL = "/common/flash/detectFlash.swf";

var MM_FlashControlInstalled;	// is the Flash ActiveX control installed?
var MM_FlashControlVersion;	// ActiveX control version if installed

function JSC_getFlashStatus(){

    if (navigator.plugins && navigator.plugins.length > 0){

		this.implementation = "Plug-in";
		this.autoInstallable = 0;	// until Netscape SmartUpdate supported

		// Check whether the plug-in is installed:

		if (navigator.plugins["Shockwave Flash"]){

		    this.installed = 1;

		    // Get the plug-in version and revision:

		    var words =
			navigator.plugins["Shockwave Flash"].description.split(" ");

		    for (var i = 0; i < words.length; ++i){

				if (isNaN(parseInt(words[i])))
				continue;

				this.version = words[i];

			this.revision = parseInt(words[i + 1].substring(1));

		    }
		}

		else

		{

		    this.installed = 0;

		}

    }
    else if (MM_FlashControlInstalled != null)
    {
	this.implementation = "ActiveX control";
	this.installed = MM_FlashControlInstalled;
	this.version = MM_FlashControlVersion;
	this.autoInstallable = 1;
    }

}