// JavaScript Document
var IS_IE = (document.all) ? true : false;
var CLASS_NAME = (IS_IE) ? "className" : "class";
var DEST ='DEC';
// --------------------------------------------------------------------------------------
function PopupImage(img) { 
titre="Agrandissement cadeau"; 
w=open("",'image','width=620,height=620,toolbar=no,scrollbars=no,resizable=yes'); 
w.document.write("<HTML><HEAD><TITLE>"+titre+"</TITLE></HEAD>"); 
w.document.write("<SCRIPT language=javascript>function checksize() { if (document.images[0].complete) { window.resizeTo(document.images[0].width+10,document.images[0].height+30); window.focus();} else { setTimeout('checksize()',620) } }</"+"SCRIPT>"); 
w.document.write("<BODY onblur='window.close()' onclick='window.close()' leftMargin=0 topMargin=0 marginwidth=0 marginheight=0>");
w.document.write("<TABLE width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'><TR>");
w.document.write("<TD valign='middle' align='center'><IMG src='"+img+"' border=0 alt='Cliquer pour fermer'></TD></TR>");
w.document.write("<TR><TD valign='middle' align='center'>Cliquer pour fermer la fenêtre"); 
w.document.write("</TD></TR></TABLE>");
w.document.write("</BODY></HTML>"); 
w.document.close();
} 
// --------------------------------------------------------------------------------------
function GoPage(){
	if(ie) window.location.href="abovision2.php?P1=PRL&P2=OBS_" + DEST + "&PG=OFF_LST&CLI_CPAYS=000&CLI_PAYS=FRANCE" ;
	else window.location.href="../abovision2.php?P1=PRL&P2=OBS_" + DEST + "&PG=OFF_LST&CLI_CPAYS=000&CLI_PAYS=FRANCE" ;
}
// --------------------------------------------------------------------------------------
function afficherPop(type,lien){
	var onglet = lien.parentNode.parentNode.parentNode;
	var calques = onglet.getElementsByTagName("div");
	for(var i=0;i<calques.length ;i++){
		if(calques[i].getAttribute(CLASS_NAME)==type){
			var sous_calques = calques[i].getElementsByTagName("div");
			for(var j=0;j<sous_calques.length ;j++){
				if(sous_calques[j].getAttribute(CLASS_NAME)=="cache"){
					sous_calques[j].setAttribute(CLASS_NAME, "conteneur");
				}
			}
		}
	}
}
// --------------------------------------------------------------------------------------
function masquerPop(lien){
	var div_a_cacher = lien.parentNode.parentNode.parentNode;
	div_a_cacher.setAttribute(CLASS_NAME, "cache");
}
// --------------------------------------------------------------------------------------
function switchOnglet(element){
	
	divonglet = $("rotative-c").childNodes[1];
	onglets = divonglet.getElementsByTagName("li");
	for(var i=0;i<onglets.length ;i++){
		curClass =onglets[i].getAttribute(CLASS_NAME)
		if(curClass=='actif')
		{
			idactif = i
			if(i==onglets.length-1){
				rang = 0
		
			} 
			else
			{
				rang = i+1
			}		
		}
	}
	onglets[rang].setAttribute(CLASS_NAME,'actif');
	onglets[idactif].removeAttribute(CLASS_NAME);	
	var calques = $("rotative-c").getElementsByTagName('ul');
	for(var i=0;i<calques.length ;i++){
		if(calques[i].getAttribute(CLASS_NAME)=="contenus"){
			var contenus = calques[i];
		}
	}
	var listecalquescontenus = new Array();
	var calquescontenus = contenus.getElementsByTagName("li");
	for(var i=0;i<calquescontenus.length ;i++){
		if((calquescontenus[i].getAttribute(CLASS_NAME) == 'contenu' ||	calquescontenus[i].getAttribute(CLASS_NAME) == 'cache')){
			//alert(typeof(calquescontenus));
			listecalquescontenus.push( calquescontenus[i]);
			
		}
	}
	for(var i=0;i<listecalquescontenus.length ;i++){
		if(i==rang){
			listecalquescontenus[i].setAttribute(CLASS_NAME,'contenu');
		}else{
			listecalquescontenus[i].setAttribute(CLASS_NAME,'cache');
		}
	}
}
// --------------------------------------------------------------------------------------
function afficherProduit(element,sens){
	var contenus = element.parentNode.parentNode;
	var listecalquescontenus = new Array();
	var calquescontenus = contenus.getElementsByTagName("div");
	for(var i=0;i<calquescontenus.length ;i++){
		if((calquescontenus[i].getAttribute(CLASS_NAME) == 'produit' ||	calquescontenus[i].getAttribute(CLASS_NAME) == 'cache-produit')){
			//alert(typeof(calquescontenus));
			listecalquescontenus.push( calquescontenus[i]);
		}
	}
	var numero;
	if(sens==true){
		for(var i=0;i<listecalquescontenus.length ;i++){
			if(listecalquescontenus[i].getAttribute(CLASS_NAME) == 'produit'){
				listecalquescontenus[i].setAttribute(CLASS_NAME,'cache-produit');
				if(i<listecalquescontenus.length-1){
					listecalquescontenus[i+1].setAttribute(CLASS_NAME,'produit');
					numero = i+2;
				}else{
					listecalquescontenus[0].setAttribute(CLASS_NAME,'produit');
					numero =1;
				}
				break;
			}
		}
	}else{
		for(var i=listecalquescontenus.length-1 ;i>=0;i--){
			if(listecalquescontenus[i].getAttribute(CLASS_NAME) === 'produit'){
				listecalquescontenus[i].setAttribute(CLASS_NAME,'cache-produit');
				if(i>0){
					listecalquescontenus[i-1].setAttribute(CLASS_NAME,'produit');
					numero = i;
				}else{
					listecalquescontenus[listecalquescontenus.length-1].setAttribute(CLASS_NAME,'produit');
					numero = listecalquescontenus.length;
				}
				break;
			}
		}
	}
	var span_numeros = contenus.getElementsByTagName("span");
	for(var i=0;i<span_numeros.length ;i++){
		if(span_numeros[i].getAttribute(CLASS_NAME) == 'numero'){
			span_numeros[i].innerHTML = numero;
		}
	}
}
// --------------------------------------------------------------------------------------
function afficherPlus(element){
	var div_parent = element.parentNode.parentNode;
	var div_enfant = element.firstChild;
	calques = div_parent.getElementsByTagName("div");
	for(var i=0;i<calques.length ;i++){
		if(calques[i].getAttribute(CLASS_NAME)=="content"){
			calques[i].setAttribute(CLASS_NAME,'cache');
			div_enfant.setAttribute('src','/redimgs/picto-plus.gif');
		}else if(calques[i].getAttribute(CLASS_NAME)=="cache"){
			calques[i].setAttribute(CLASS_NAME,'content');
			div_enfant.setAttribute('src','/redimgs/picto-moins.gif');
		}
	}
	
}
// --------------------------------------------------------------------------------------
function afficherIndiscrets(on){
	var indiscretsoff = document.getElementById('indiscrets-off');
	var indiscretson = document.getElementById('indiscrets-on');
	if(on){
		indiscretsoff.setAttribute(CLASS_NAME,'cache');
		indiscretson.setAttribute(CLASS_NAME,'visible');
	}else{
		indiscretson.setAttribute(CLASS_NAME,'cache');
		indiscretsoff.setAttribute(CLASS_NAME,'visible');
	}
}
// --------------------------------------------------------------------------------------
// vide les input text onfocus
function viderChamp(quelchamp){
	if(!quelchamp.drapeau){
		quelchamp.value = "";
		quelchamp.drapeau = true;
	}
}
// --------------------------------------------------------------------------------------
//Article : grossir texte
function grossirTexteArticle(incr){
	var texte = document.getElementById('corps-article');
	if(!texte){
		texte = document.getElementById('corps-article-tableau');
	}
	var chapeau = document.getElementById('chapeau');
	if(!chapeau){
		chapeau = document.getElementById('chapeau-horizontal');
	}
	var style_courant = texte.getAttribute(CLASS_NAME);
	var no_style_courant = Number(style_courant.charAt(5));
	var no_nouveau_style = no_style_courant + incr;
	if( (no_nouveau_style <=6)&&(no_nouveau_style >=1)){
		texte.setAttribute(CLASS_NAME,'texte'+no_nouveau_style);
		chapeau.setAttribute(CLASS_NAME,'texte'+no_nouveau_style);
	}
}
// --------------------------------------------------------------------------------------
function afficherOnglet(element,rang){

	var div_onglets = element.parentNode.parentNode.parentNode;

	onglets = div_onglets.getElementsByTagName("li");

	for(var i=0;i<onglets.length ;i++){
		if(i==rang){
			onglets[i].setAttribute(CLASS_NAME,'actif');
			if (i == 0) DEST = 'DEC';
			if (i == 1) DEST = 'LIB';
			if (i == 2) DEST = 'ALA';
			if (i == 3) DEST = 'NUM';
			if (i == 4) DEST = 'ETR';			
		}
		else
		{
			onglets[i].removeAttribute(CLASS_NAME);
		}
	}
	var calqueparent =  div_onglets.parentNode.parentNode;
	var calques = calqueparent.getElementsByTagName('ul');
	for(var i=0;i<calques.length ;i++){
		if(calques[i].getAttribute(CLASS_NAME)=="contenus"){
			var contenus = calques[i];
		}
	}
	var listecalquescontenus = new Array();
	var calquescontenus = contenus.getElementsByTagName("li");
	for(var i=0;i<calquescontenus.length ;i++){
		if((calquescontenus[i].getAttribute(CLASS_NAME) == 'contenu' ||	calquescontenus[i].getAttribute(CLASS_NAME) == 'cache')){
			//alert(typeof(calquescontenus));
			listecalquescontenus.push( calquescontenus[i]);			
		}
	}
	for(var i=0;i<listecalquescontenus.length ;i++){
		if(i==rang){
			listecalquescontenus[i].setAttribute(CLASS_NAME,'contenu');
		}else{
			listecalquescontenus[i].setAttribute(CLASS_NAME,'cache');
		}
	}
}
// --------------------------------------------------------------------------------------
function afficherInit(rang){
	
	var div_onglets = document.getElementById('ong1');
	
	onglets = div_onglets.getElementsByTagName("li");
	for(var i=0;i<onglets.length ;i++){
		if(i==rang){
			onglets[i].setAttribute(CLASS_NAME,'actif');
		}else{
			onglets[i].removeAttribute(CLASS_NAME);
		}
	}
	
	var calqueparent =  div_onglets.parentNode.parentNode;
	var calques = calqueparent.getElementsByTagName('ul');
	for(var i=0;i<calques.length ;i++){
		if(calques[i].getAttribute(CLASS_NAME)=="contenus"){
			var contenus = calques[i];
		}
	}
	var listecalquescontenus = new Array();
	var calquescontenus = contenus.getElementsByTagName("li");
	for(var i=0;i<calquescontenus.length ;i++){
		if((calquescontenus[i].getAttribute(CLASS_NAME) == 'contenu' ||	calquescontenus[i].getAttribute(CLASS_NAME) == 'cache')){
			listecalquescontenus.push( calquescontenus[i]);			
		}
	}
	for(var i=0;i<listecalquescontenus.length ;i++){
		if(i==rang){
			listecalquescontenus[i].setAttribute(CLASS_NAME,'contenu');
		}else{
			listecalquescontenus[i].setAttribute(CLASS_NAME,'cache');
		}
	}

}
// --------------------------------------------------------------------------------------
window.onload = function() {

	afficherInit(0);
}
