function initHeaderAllCatalog(){
   if(!document.getElementById) return;
   if(document.getElementById("allCatalogSections") && document.getElementById("allCatalogSectionsLink")){
      var myDiv = document.getElementById("allCatalogSections");
      myDiv.style.display = "none";
      var link = document.getElementById("allCatalogSectionsLink");
      addEvent(link, 'click', displayCatalogSections, false);
   }
}
function displayCatalogSections(){
   var myDiv = document.getElementById("allCatalogSections");
   if(myDiv.style.display == "none") myDiv.style.display = "block";
   else if(myDiv.style.display == "block") myDiv.style.display = "none";
}

var INPUTSVALUE = new Array();
function initInput(){
   if(!document.getElementsByTagName) return;
   var inputs = getElementsByClass("defaultValue",null,"input");
   for(var i=0; i<inputs.length;i++){
		var myInput=inputs[i];
      INPUTSVALUE[i] = inputs[i].value;
      addEvent(myInput, 'focus', emptyInput, false);
   }
}

function emptyInput(e){
   var myInput;
	myInput = findTarget(e);
   if(myInput.nodeName.toLowerCase()=="input" && INPUTSVALUE.length){
      for(var i=0; i<INPUTSVALUE.length;i++){
         if(myInput.value == INPUTSVALUE[i]) myInput.value = "";
      }
   }
}
// Imported from displayLayer.js
$(document).ready(function (){
	if($(".layer").is("div")){$(".layer").hide();}
   $("#listOnglets li a").each(function(i){
      if(i==DISPLAYABLE_LAYER){
         if($(this).parents().is("li")){$(this).parents().addClass("active");}
         if($("#displayLayer"+i).is("div")){
            $("#displayLayer"+i).show();
            $("#displayLayer"+i).addClass("opened");
         }
      }
      $(this).click(function(){
         if($("#listOnglets .active").is("li")){$("#listOnglets .active").removeClass("active");}
         if($("#productsList .layer").is("div")){$("#productsList .layer").hide();}
         if($("#productsList .opened").is("div")){$("#productsList .opened").removeClass("opened");}
         if($(this).parents().is("li")){$(this).parents().addClass("active");}
         if($("#displayLayer"+i).is("div")){
            $("#displayLayer"+i).show();
            $("#displayLayer"+i).addClass("opened");
         }
      	return false;
      });
   });
   $(".selectionNav").click(function(){
   		return false;
   });
   
   // Imported from color.js
	$(".colors img").each(function(i){
      $(this).click(function(){
         if($(".colorActive").is("img")){$(".colorActive").removeClass("colorActive");}
         $(this).addClass("colorActive");
         $(this).parents("label").siblings("input").check();
      	return false;
      });
   });
   $(".colors input").each(function(i){
      $(this).click(function(){
         if($(".colorActive").is("img")){$(".colorActive").removeClass("colorActive");}
         $(this).siblings("label").children("img").addClass("colorActive");
         $(this).check();
      	return false;
      });
   });
});

// Imported from loadImageFlash.js
function loadImageInFlash(lowdef,highdef){
    thisMovie("magnifier").loadImage(lowdef,highdef);
}

function thisMovie(movieName){
    if (navigator.appName.indexOf("Microsoft") != -1) {
       return window[movieName];
    }
    else {
        return document[movieName];
    }
}

// Imported from scrips.js

var MIN_ELEMS = 1;
var MAX_ELEMS = 9;

function initInputValues () {
	var ALL_MINUSBTNS = getElementsByClass("qtyControlMinus",null,"a");
	var ALL_PLUSBTNS = getElementsByClass("qtyControlPlus",null,"a");
	i=0;
	while(i<ALL_MINUSBTNS.length) {
		ALL_MINUSBTNS[i].onclick = function() {
			var elem = this.parentNode.getElementsByTagName("input")[0];
			if (elem.value > MIN_ELEMS) elem.value = parseInt(elem.value)-1;
			return false;
		}
		i++;
	}
	ii=0;
	while(ii<ALL_PLUSBTNS.length) {
		ALL_PLUSBTNS[ii].onclick = function() {
			var elem = this.parentNode.getElementsByTagName("input")[0];
			if (elem.value < MAX_ELEMS) elem.value = parseInt(elem.value)+1;
			return false;
		};
		ii++;
	}
}

//initialisation au chargement de la page
addLoadListener(initHeaderAllCatalog);
addLoadListener(initInput);
addLoadListener(initInputValues);