function writetag(tag, content) {
     document.getElementById(tag).innerHTML = content;
}

function createXMLHttpRequest(){
 var xmlhttp;

 if (window.XMLHttpRequest) {
   xmlhttp = new XMLHttpRequest();
   // evite un Bug du navigateur Safari :
   if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType("text/xml");
 }
 else if (window.ActiveXObject){
   try {
   	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  	 } 
  catch (e){   
     try {
       xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
     } catch (e){return false;}
   }
 }
 return xmlhttp; 
}



var xmlhttp_navigation_categorie;
var xmlhttp_mes_articles;
var xmlhttp_titre;
var xmlhttp_localisation;

function navigation_categorie() {
if (xmlhttp_navigation_categorie.readyState==4) {
	  // if "OK"
	  if (xmlhttp_navigation_categorie.status==200) {
		writetag('SousCategorie0', xmlhttp_navigation_categorie.responseText);
	  } else {
		/*alert("Problem retrieving XML data on navigation_categorie(),statut : "+xmlhttp_navigation_categorie.status);*/
	  }
	}
}

function mes_articles() {
if (xmlhttp_mes_articles.readyState==4) {
	  // if "OK"
	  if (xmlhttp_mes_articles.status==200) {
		writetag('MesArticles', xmlhttp_mes_articles.responseText);
	  } else {
		/*alert("Problem retrieving XML data on mes_articles(), statut: "+xmlhttp_mes_articles.status);*/
	  }
	}
}

function verifProd(dispatchUrl) {
	if(dispatchUrl== ""){
		exit();
	}
	else{
		 xmlhttp_mes_articles = createXMLHttpRequest();
		if (xmlhttp_mes_articles!=null) {
		  xmlhttp_mes_articles.onreadystatechange=mes_articles;
		   xmlhttp_mes_articles.open("GET",''+dispatchUrl,true);
		  xmlhttp_mes_articles.send(null);
		}
	}
}

function verifCategorie(idCat) {
if(idCat== 0){
	exit();
}
else{
	    xmlhttp_navigation_categorie = createXMLHttpRequest();
		if (xmlhttp_navigation_categorie!=null) {
		  xmlhttp_navigation_categorie.onreadystatechange=navigation_categorie;
		   xmlhttp_navigation_categorie.open("GET",'?p=2&sp=1&n='+escape(idCat),true);
		  xmlhttp_navigation_categorie.send(null);
		}
	}
}


// RAZ de la zone article - reprendre pr&eacute;cisement le code de la div 'MesArticles'
function InitResult() {
	document.getElementById('MesArticles').innerHTML = '<img src="images/en/un_selectionner-type-produit.gif" alt="Choose a product type" class="finger" title="Choose a product type" />';
}
var activeCat;
var activeSousCat;

function CheckAction(idObject, nbObject, typeColoneCA, classColoneCA) {
document.getElementById('MesArticles').className='coloneArticle';
	if(typeColoneCA=="Categorie") {
		activeCat = typeColoneCA+''+idObject;
	} else {
		activeSousCat = typeColoneCA+idObject;
	}
	var i;
	for(i=0;i<nbObject;i++) {
		if (typeColoneCA+i==activeCat) {
			eval("RollOver("+i+",'"+typeColoneCA+"','"+classColoneCA+"','in')");
			if (i!=idObject) {
				eval("ShowOneHideOther('Liseret',"+i+","+nbObject+",'tiret show')"); // show
			}
		}
		 else {
			eval("RollOver("+i+",'"+typeColoneCA+"','"+classColoneCA+"','out')");
		}
	}
}

function RollOver(idObjectRO, typeColone, classColone, typeAction) {
	if(typeAction=='in') {
	eval("document.getElementById('"+typeColone+""+idObjectRO+"').className='"+classColone+" over'");
	} else {
		if((activeCat==typeColone+idObjectRO) || (activeSousCat==typeColone+idObjectRO)) {
			if(typeAction=='in') {
			eval("document.getElementById('"+typeColone+""+idObjectRO+"').className='"+classColone+" over'");
			}
		} else {
			eval("document.getElementById('"+typeColone+""+idObjectRO+"').className='"+classColone+"'");
		}
	}
}

function Chekonload(index_click,catId,total) {
	CheckAction(index_click,total,'Categorie','categorie');
	document.getElementById('MesArticles').className='coloneArticleH';
	InitResult(); 
	verifCategorie(catId);
}

function Chekonload2(index_click,catId,total,index_click_parent) {
	CheckAction(index_click,total,'SousCategorieLevel','souscategorie');
	RollOver(index_click,'SousCategorieLevel','souscategorie','in')
	RollOver(index_click_parent,'Categorie','categorie','in')
}

function macaronFlash(){
	document.write('<object type="application/x-shockwave-flash" data="images/en/macaron_verspop.swf" width="176" height="177">	<param name="movie" wmode="transparent" value="images/en/macaron_verspop.swf" /><param name="wmode" value="transparent" /><p>En savoir plus</p></object>');
}

function macaronFlashAcc(){
	document.write('<object type="application/x-shockwave-flash" data="images/en/macaron_home.swf"  width="176" height="177">	<param name="movie" value="images/en/macaron_home.swf" /><param name="wmode" value="opaque"><embed src="images/en/macaron_home.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="430" height="330" wmode="opaque"></embed></object>');
}

function macaronFlash2(){
	document.write('<object type="application/x-shockwave-flash" data="images/expo/accueil_d.swf" width="430" height="330">	<param name="movie" value="images/expo/accueil_d.swf" /><param name="wmode" value="opaque"><embed src="images/expo/accueil_d.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="430" height="330" wmode="opaque"></embed></object>');
}

function macaronFlash3(){
	document.write("<script type=text/javascript");
	document.write("<!--");
	document.write("OAS_AD('Middle1');");
	document.write("//-->");
	document.write("</script>");
}
 function fermetureExpo(){
	 document.getElementById('boxBack').className='invisible'; 
	 document.getElementById('flashContainer').className='invisible';
 }
 
 function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6.
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (document.body.filters)) 
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
         {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText 
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }    
}
//window.attachEvent("onload", correctPNG);

var idOn = 0 ;
var ft = true;

function changeCouleurRecherche(recherche) {
	if (ft == true && recherche.value == 'Search here') {
		ft = false;
		recherche.value = '';
		recherche.className = 'focus';
	}
}

function resetClass(){
	for (i=1;i<=4;i++){
		if (i != idOn){
			document.getElementById('onglet'+i).className='onglet'+i;	
		}
	}
}

function setClassActif(id){
	for (i=1;i<=4;i++){
		document.getElementById(eval('\'onglet'+i+'\'')).className='onglet'+i;
	}
	if (idOn != 0){
		document.getElementById(eval('\'onglet'+idOn+'\'')).className='onglet'+idOn+'_actif';
	}
	document.getElementById(eval('\'onglet'+id+'\'')).className='onglet'+id+'_actif';
	return id;
}

function setSearch(){	
	switch (idOn){
		case '1' :
			 document.theForm.p.disabled = false;
			 document.theForm.p.value = "2";
			 document.theForm.CAT.disabled = true;
			 document.theForm.C.disabled = true;
			 document.theForm.X.disabled = true;
			 document.theForm.SORT_ORDER.disabled = true;
			 document.theForm.KEYWORDS.disabled = true;
			 document.theForm.action = "/index.php";
			 break;
		case '2' :
			 document.theForm.p.disabled = false;
			 document.theForm.p.value = "2";
			 document.theForm.CAT.disabled = true;
			 document.theForm.C.disabled = true;
			 document.theForm.X.disabled = true;
			 document.theForm.SORT_ORDER.disabled = true;
			 document.theForm.KEYWORDS.disabled = true;
			 document.theForm.action = "/web/index.php";
			 break;
		case '3' :
			 document.theForm.p.disabled = false;
			 document.theForm.p.value 	= "11";
			 document.theForm.CAT.disabled = true;
			 document.theForm.C.disabled = true;
			 document.theForm.X.disabled = true;
			 document.theForm.SORT_ORDER.disabled = true;
			 document.theForm.KEYWORDS.disabled = true;
			 document.theForm.action = "/expo/index.php";
			 break;			 
		case '4' :
			 document.theForm.p.disabled = true;
			 document.theForm.CAT.disabled = false;
			 document.theForm.CAT.value = "U";
			 document.theForm.C.disabled = false;
			 document.theForm.C.value = "139";
			 document.theForm.X.disabled = false;
			 document.theForm.X.value = "8";
			 document.theForm.SORT_ORDER.disabled = false;
			 document.theForm.SORT_ORDER.value = "PERTINENCE";
			 document.theForm.KEYWORDS.disabled = false; 
			 document.theForm.action = "http://www.usinenouvelle.com/archive/page_resultat_archive.cfm";			
			 break;
	}	
}

function getkeyword(){
	document.theForm.KEYWORDS.value = document.theForm.q.value;
}

var alpha = true;
function bravo(emailnewsletter) {
	if (alpha == true && emailnewsletter.value == 'yourname@company.com') {
		alpha = false;
		emailnewsletter.value = '';
		emailnewsletter.className = 'focusNewsLetter';
	}
}

function writeTagErrorCatcha(ret) {
	document.getElementById('error_captcha').style.display = 'inline';
	if (ret == '<p>0</p>') {
		writetag('error_captcha', 'Code invalid.');
	}
}

function reloadCaptcha(code){
	document.getElementById('captcha').src = "/expo/?p=90&sp=1&code="+code.value;
	return true;
}

var xmlhttp_check_captcha ;

function verifCaptcha(code) {
	if (code.value.length == 0) {
		writeTagErrorEmail(0)
		return false;
	}
	
	writetag('error_captcha', '');
	
	xmlhttp_check_captcha = createXMLHttpRequest();
	
	if (xmlhttp_check_captcha!=null) {
	
		xmlhttp_check_captcha.open("GET",'index.php?p=10&sp=28&code='+escape(code.value),false);
		xmlhttp_check_captcha.send(null);
		var ret = xmlhttp_check_captcha.responseText;
		if (ret == '<p>0</p>') {
			reloadCaptcha(code);
			writeTagErrorCatcha(ret);
			document.getElementById(code.id).value=''; 
			return false;
		}
		else return true;
	}
}
