/* UTILISATION DE LA FONTION StartTag
 * Déclarer un tableau de coordonnées (x,y,L,H) : x=coordonnées x, y=coordonnées y, L=largeur, H=hauteur
 * ex: var layer_coords=new Array(34,108,34,137);
 * Si besoin, déclarer un tableau de clipping de la rÃ©gion (a,b,c,d) : a=point zéro de la zone, b=largeur de la zone, c=hauteur de la zone, et d=retour au point zéro
 * ex: var layer_clip=new Array(0,120,350,0);
 *
 * Les arguments à passer à la fonction sont, dans l'ordre:
 * 		1- Le nom du layer
 * 		2- le tableau de coordonnées
 * 		3- la "visibility" [optionnel: 'visible' ou 'hidden']
 * 		4- le clipping [optionnel]
 * 		5- l'overflow du clipping (IE) [optionnel: 'visible' ou 'hidden']
 *
 * Le résultat sort une <DIV> pour IE ou NS6 et un <LAYER> pour NS4 avec les attributs optimisés pour chaque navigateur. Le z-indexing est incrémenté automatiquement à chaque appel de la fonction.
*/

var z_indexing=0;

function checkBrowser(){
this.ver=navigator.appVersion;
this.dom=document.getElementById?1:0;
this.mac=(this.ver.indexOf("Mac")>-1 && this.dom)?1:0;
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5);
return this;
}



function StartTag(nom,coords,visibility,clip,overflow) {
	var tabcoord= new Array("left","top","width","height");
	var tag="";
	bw=new checkBrowser();
	if(document.layers) {
		tag += "<layer name=\""+nom+"\" ";
		if(coords) {
			if(bw.ns4) {coords[0]-=1;}
			for(var i=0; i<coords.length; i++) {
				if(coords[i] != null && coords[i] != "")tag += tabcoord[i]+"=\""+coords[i]+"\" ";
				}
			}
		if(clip) {
			tag += "clip=\"" + clip[1]+ "," +clip[2] + "\"";
		}
		if(visibility) {
			if(visibility=="visible")tag += " visibility=\"show\"";
			else tag += " visibility=\"hide\"";
			}
		tag += " z-index="+ ++z_indexing+">";
	} else {
		tag += "<div id=\""+nom+"\" ";
		tag +="style=\"position:absolute; "
		if(coords) {
			if(bw.mac && bw.ie5) {coords[0]-=1;coords[3]-=20;}
			if(bw.mac && bw.ns5) {coords[3]-=25;}
			if(bw.ns5) {coords[3]-=2;}
			for(var i=0; i<coords.length; i++) {
				if(coords[i] != null && coords[i] != "")tag += tabcoord[i]+":"+coords[i]+"; ";
				}
			}
		if(clip) {
			tag += "clip:rect(";
			for (var i=0; i< clip.length; i++) {
				tag += clip[i];
				if(i < clip.length-1) tag +=",";
				}
			tag += ");";
			}
		if(visibility) tag += " visibility:"+visibility+";";
		if(overflow) tag += " overflow:"+overflow+";"
		tag += "; z-index:"+ ++z_indexing;
		tag += "\">";
	}
	document.write(tag);
}



/* 12/11/02 FF
> Fonction qui génère un bouton avec libellé et rollover :
 strNom 		: nom du libellé
 intTaille		: taille du bouton en pixel
 Boosens		: sens d'orientation du bouton ( 1 : fleche à droite, 0 : fleche à gauche )
 codeM			: code marchÃ© ( optionel )
 codeL			: code langue ( optionel )
 flagTest 		: l'initaliser à  false pour n'utiliser que le codeMArche dans la declaration du bouton
*/
function bouton( strNom, intTaille, Boosens, codeM, codeL )
{
	cu_Mar = cu_Marche!=null?cu_Marche:'FR';
	var coef1 = 6.2; var coef2 = 2.5; var coef3 = 10.7; var coef4 = 3.5;
	var nbblanc = 0; var liSize = 0; var autreSize = 0; var Sesp = 13;
	var mSize = 0; var espSize = 0;
	var deb = strNom.indexOf( '>' );
	var fin = strNom.indexOf( '</' );
	var TrueName = (deb!=-1)?strNom.substring( deb+1, fin ):strNom;
	var mac=(navigator.userAgent.indexOf('Mac')!=-1)?true:false;
	var ns=(document.layers)?true:false;
	if(ns) {coef1 = 5.1; coef3 = 8.6; coef2 = 2.6; coef4 = 4; Sesp = 14; };
	if(mac && ns) {coef1 = 6.3; coef2 = 2.6; coef3 = 9; coef4 = 4; Sesp = 14; };
	var stesp = TrueName.match( eval( '/ /g' ) );
	var stli = TrueName.match( eval( '/[i,l]/g' ) );
	var stm = TrueName.match( eval( '/m/g' ) );
	var stautre = TrueName.match( eval( '/[^i,l,m, ]/g' ) );
	if( stautre!=null ) autreSize = stautre.length*coef1;
	if( stli!=null ) liSize = stli.length*coef2;
	if( stm!=null ) mSize = stm.length*coef3;
	if( stesp!=null ) espSize = stesp.length*coef4;
	var blocNV = 10+liSize+autreSize+mSize+espSize;
	Ecart = Math.ceil( intTaille - blocNV - Sesp );
	if( intTaille < 100 ) Ecart += 5;
	//strCode=( bouton.arguments.length>3 )?( bouton.arguments.length>4 )?"/"+codeM+"/"+codeL:"/"+codeM:"../../../..";
	if( flagTest ) {
		strCode = '../../..';
	} else {
		if (codeM != null) strCode = '/'+codeM;
		else strCode = '/'+cu_Mar;
	}
	strPixTrans = '<img src="'+strCode+'/common/common/img/pixel/pixtrans.gif" width="'+Ecart+'" height="10" border="0" />';
	var strtot = ( Boosens )?'&nbsp;'+TrueName+'&nbsp;'+strPixTrans:strPixTrans+'&nbsp;'+TrueName+'&nbsp;';
	document.write( strtot );
}




function initInput(size) {
	var ie4=false;
	var bigSize = size>10 ? true : false;
	if( navigator.userAgent.indexOf('Win')==-1 ) mac=true; else mac=false;
	if (document.layers) ns=true; else ns=false;
	if (document.all) { ie=true; if( navigator.appVersion.indexOf( "MSIE 4" ) !=-1 || navigator.appVersion.indexOf( "MSIE 5" ) != -1 )ie4=true;}
	else { ie=false; }
	if(!ie&&document.getElementById){ns=false;n6=true;}
	if(!mac && ns) { var taille = bigSize?Math.abs(size*0.60):Math.abs(size*0.70); }
	else if(!mac && ie) { if( ie4 ) { var taille = size; }
						else { var taille = bigSize?size:Math.abs(size*0.70); } }
	else if(mac) { var taille = bigSize?Math.abs(size*0.90):size; }
	else if(mac && ie) { var taille = bigSize?Math.abs(size*1.10):Math.abs(size*1.50); }
	else {taille = size;}
	return taille;
}



function WriteInputRet( nom, size, maxlength, value, typeCSS, BooPassOk, disable, tip ) {
var strHTML
if( isNaN( maxlength*1 ) ) { BooPassOk=value; typeCSS=maxlength; maxlength=35; value='' };
ttaille = Math.round(initInput(size));
var Ty = ((BooPassOk==1) || (BooPassOk=="1"))?'password':'text';
strHTML = '<INPUT TYPE=\"'+Ty+'\" SIZE=\"'+ttaille+'\" MAXLENGTH=\"'+maxlength+'\" NAME=\"'+nom+'\" class=\"'+typeCSS+'\" VALUE=\"'+value+'\"';
strHTML += (disable==1)?' disabled':'';
strHTML += (tip!=null && tip.length>0)? ' title=\"' + tip + '\"' : '';
//if( WriteInputRet.arguments.length>6 ) strHTML += ' />';
return strHTML;
}

function WriteInput( nom, size, maxlength, value, typeCSS, BooPassOk, disable ) {
document.write( WriteInputRet( nom, size, maxlength, value, typeCSS, BooPassOk, disable, '' ) + ' />' );
}

function WriteInputWithTip( nom, size, maxlength, value, typeCSS, BooPassOk, disable, tip ) {
document.write( WriteInputRet( nom, size, maxlength, value, typeCSS, BooPassOk, disable, tip ) + ' />' );
}

function initArea(size) {
	var ie4=false;
	var bigSize = size>30 ? true : false;
	if( navigator.userAgent.indexOf('Win')==-1 ) mac=true; else mac=false;
	if (document.layers) ns=true; else ns=false;
	if (document.all) { ie=true; if( navigator.appVersion.indexOf( "MSIE 4" ) !=-1 )ie4=true;}
	else { ie=false; }
	if(!ie&&document.getElementById){ns=false;n6=true;}
	if(!mac && ns) { var taille = bigSize?Math.abs(size*0.60):Math.abs(size*0.80); }
	else if(!mac && ie) { var taille = Math.abs(size*1); }
	else if(mac && ns) { var taille = bigSize?Math.abs(size*0.70):Math.abs(size*1); }
	else if(mac && ie) { var taille = bigSize?Math.abs(size*1):Math.abs(size*0.9); }
	else {taille = size;}
	return taille;
}

function WriteAreaRet( nom, size, typeCSS, ligne, valeur ) {
var strHTML
if( !isNaN( nom*1 ) ) { ligne=typeCSS; typeCSS=size; size=nom }
ttaille = Math.round(initArea(size));
if( ligne == "" ) var ligne="10";
strHTML = '<textarea name=\"'+nom+'\" class=\"'+typeCSS+'\" cols=\"'+ttaille+'\" rows=\"'+ligne+'\">';
if (valeur != null) { strHTML +=valeur; }
strHTML += '</textarea>';
return strHTML;
}



function WriteArea( nom, size, typeCSS, ligne, valeur ) {
document.write( WriteAreaRet( nom, size, typeCSS, ligne, valeur ) );
}



