// for the main menu
function hover(obj){
  if(document.all){
    UL = obj.getElementsByTagName('ul');
    if(UL.length > 0){
      sousMenu = UL[0].style;
      if(sousMenu.display == 'none' || sousMenu.display == ''){
        sousMenu.display = 'block';
      }else{
        sousMenu.display = 'none';
      }
    }
  }
}

function setHover(){
  LI = document.getElementById('menu').getElementsByTagName('li');
  nLI = LI.length;
  for(i=0; i < nLI; i++){
    LI[i].onmouseover = function(){
      hover(this);
    }
    LI[i].onmouseout = function(){
      hover(this);
    }
  }
}

// Validate the search
function validateIt() {
LaChaine = document.trouv1Field.trouv1.value;
Partie1 = "";
Partie2 = "";
if (LaChaine == " Keyword / Item No") {
	alert("Please input a Keyword or an Item no.");
	return false;
	}
if (LaChaine == " Mot-clé \/ article") {
	alert("Veuillez inscrire un mot clef ou un numéro d'item");
	return false;
	}
if (isNaN (LaChaine)) {
	return;
	}
if (LaChaine.length == 6) {
	Partie1 = LaChaine.substring(0,3);
	Partie2 = LaChaine.substring(3,6);
	document.trouv1Field.trouv1.value = Partie1 + '-' + Partie2;
	return;
	}
}

// Empty the search
function emptySearch() {
	if (document.trouv1Field.trouv1.value == " Keyword / Item No") {
	document.trouv1Field.trouv1.value = "";
	}
	if (document.trouv1Field.trouv1.value == " Mot-clé \/ article") {
	document.trouv1Field.trouv1.value = "";
	}
}

// Open-close div with ID
function openClose(theID) {
      if (document.getElementById(theID).style.display == "block") { document.getElementById(theID).style.display = "none" }
      else {document.getElementById(theID).style.display = "block"}
  }
  
// Control cookies
 function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function faitCookies(LanguePays) {
createCookie('LaLangueLePays',LanguePays,365);
}
