function recherche(path) {
	if (document.form_recherche.recherche.value!="" && document.form_recherche.recherche.value!=" ") {
		tempo = document.form_recherche.recherche.value;
		location.href=path + "recherche/search.asp?keywords="+tempo+"&qu="+tempo+"*&ct=nouv_calor_catalog";
	}else{
		alert("Vous devez saisir au moins un mot pour lancer une recherche.");
	}
}

function openRecall(x) {
	if (x==1) {
		window.open("recall.html","Calorpopup","toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=558,height=360");
	}else{
		window.open("../recall.html","Calorpopup","toolbar=no,directories=no,menubar=no,scrollbars=no,resizable=no,width=558,height=360");
	}
}

function OpenPopup(strPageURL, i_width, i_height, str_name) {
	window.open(strPageURL,str_name,'width='+i_width+',height='+i_height+',resizable=yes,scrollbars=no,status=no,toolbar=no,directories=no,menubar=no');
}

function printPage()
{
	if (window.print)
	{
		window.print() ;
	} else
	{
		var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
		document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
		WebBrowser1.ExecWB(6, 2);
		WebBrowser1.outerHTML = "";
	}
}

function SubmitFamille(obj)	{		
		obj.submit();
}
function SubmitUnivers(obj)	{		
		if(obj.famille){
			obj.famille.selectedIndex=0;
		}	
		obj.submit();
}		

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function GetCookie(name) {
 var result = null;
 var myCookie = " " + document.cookie + ";";
 var searchName = " " + name + "=";
 var startOfCookie = myCookie.indexOf(searchName);
 var endOfCookie;
 if (startOfCookie != -1) {
  startOfCookie += searchName.length;
  endOfCookie = myCookie.indexOf(";", startOfCookie);
  result = unescape(myCookie.substring(startOfCookie, endOfCookie));
 }
 return result;
}

function SetCookie(name, value) {
 var never = new Date()
 never.setTime(never.getTime() + 24*60*60*1000);
 
 var expString = "; expires=" + never.toGMTString();
 document.cookie = name + "=" + escape(value) + expString;
}


function test_cookie()
{
	temp_val = GetCookie("cook_popup");
	
	if (!temp_val)
	{ SetCookie("cook_popup",1);
	  return true; }
	
	if (temp_val==1)
	{ SetCookie("cook_popup",2);
	  return true; }
	  
	return false; 
}

function writeFlash(id,name,bg,w,h,var_url)
{
	document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ');
	document.write('WIDTH="'+w+'" HEIGHT="'+h+'">');
	document.write('<PARAM NAME=id VALUE="'+id+'">');	
	document.write('<PARAM NAME=movie VALUE="'+name+'?url='+var_url+'">');
	document.write('<PARAM NAME=quality VALUE=high>');
	document.write('<PARAM NAME=scale VALUE=noborder>');
	document.write('<PARAM NAME=salign VALUE=LT>');
	document.write('<PARAM NAME=wmode VALUE='+bg+'>');
	document.write('<EMBED src='+name+'?url='+var_url+' quality=high scale=noborder salign=LT wmode='+bg+'  WIDTH='+w+' HEIGHT='+h+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>');
	document.write('</OBJECT>');
}

function getScriptFlash(id,name,bg,w,h,var_url)
{
	var script='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
	script+='  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
	script+=' WIDTH="'+w+'" HEIGHT="'+h+'">';
	script+='<PARAM NAME=id VALUE="'+id+'">';	
	script+='<PARAM NAME=movie VALUE="'+name+'?url='+var_url+'">';
	script+='<PARAM NAME=quality VALUE=high>';
	script+='<PARAM NAME=scale VALUE=noborder>';
	script+='<PARAM NAME=salign VALUE=LT>';
	script+='<PARAM NAME=wmode VALUE='+bg+'>';
	script+='<EMBED src='+name+'?url='+var_url+' quality=high scale=noborder salign=LT wmode='+bg+' WIDTH='+w+' HEIGHT='+h+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>';
	script+='</OBJECT>';
	
	return script;
}


function WriteGif (gifname,var_url) 
{
   var sg;
   sg = "<a href=\""+var_url+"\">";
   sg += '<IMG SRC="'+gifname+'"';
   sg += ' BORDER="0">';
   sg += '<\/a\>\n';
   document.write(sg);
}

function writeDiv (id,bg,w,h,top,left,rel,vis) {
var sd;
if(ie){
if (rel=="rel"){
sPos="position:relative;";
} else if (rel=="abs"){
sPos="position:absolute;";
} else {
sPos="";
}
var sVis = vis?"visible;":"hidden;";
sd = "<DIV ID='l_"+id+"' STYLE='"+sPos+"background:"+bg+";width:"+w+";height:"+h+";top:"+top+"px; left:"+left+"px;visibility:"+sVis+"'>";
document.write(sd);
}
}

// verifie la validite d'un email
function validemail(champ)
{
	
 test = document.formulaire.elements[""+champ+""].value;
 valeur = test.indexOf("@");
 valeur2 = test.lastIndexOf(".");
 valeur3 = valeur2 + 1;
 longueur = test.length;
 ext = test.substring(valeur3,longueur);
 ok=0;
 temp = ext.length;
 if ( temp==2 || temp==3 ) 
    { ok=1; }
 else
    { ok=0; }
 if ( valeur2 == (valeur + 1) )
     { ok=0; }
 if (valeur==0)
     { ok=0; }
 if (valeur==-1 || valeur2==-1 || ok==0)
    { alert("L'email que vous avez rentrée n'est pas valide.\nVeuillez la ressaisir s'il vous plaît.");
      return false; }
 else
    { return true; }   
    
}

// verifie les champs obligatoire d'un formulaire
valider_formulaire = function () {
	var tab = valider_formulaire.arguments;

	taille = tab.length;

	for (i=0;i<taille;i++) {
		if (tab[i]=="email") {
			if (!validemail(tab[i])) {
				return 0; 
			}
		}else{
			if ((document.formulaire.elements[tab[i]].value=="") || (document.formulaire.elements[tab[i]].value==" ")) {
				alert("Le champ "+tab[i]+" est obligatoire.\nVeuillez le ressaisir s'il vous plaît.");
				return 0; 
			}
		}
	}
	
	document.formulaire.submit();
}

function empechechar()
{
	if( event.keyCode < 48 || event.keyCode > 57 )
 	{ 
 		alert( "Ce champ doit être numérique, il ne peut contenir aucun autre type de caratères." );
   		event.returnValue = false;
   	}
}

// *** Fonctions pour le footer de la home

actu=0;
function showFooter(i) {
	actu = i;
	document.getElementById("footer_univers").style.display = "none";
	document.getElementById("famille_"+i).style.display = "block";
	document.getElementById("footer_fleche").style.visibility = "visible";
}
function offFooter() {
	document.getElementById("famille_"+actu).style.display = "none";
	document.getElementById("footer_univers").style.display = "block";
	document.getElementById("footer_fleche").style.visibility = "hidden";
}


// *** Fonctions spécifiques à la fiche produit
function MM_showHideLayers() {
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
function showAcheter() {
	chrone_attente=0;
	hideLayer();
	document.getElementById("ouacheter").style.visibility = "visible";
}
function hideAcheter() {
	chrone_attente=1;
	id_timout = setTimeout("chroneHide()",1000);
}
function chroneHide() {
	if (chrone_attente==1) {
		hideLayer();
	}
}
function stopChrone() {
	window.clearTimeout(id_timout);
	chrone_attente=0;
}
function hideLayer() {
	document.getElementById("ouacheter").style.visibility = "hidden";
}

// => Charge une demonstration produit
function loadDemo(id) {
	if ( id > 0 )
		window.open('../../demo_produit.asp?id_demo='+id,'Demonstration',"toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width=500,height=500");
}	
function imprimer(id) {
	MM_openBrWindow('../../produit_print.asp?id_produit='+id,'Imprimer','scrollbars=yes,width=730,height=500')
}

// => Affiche les textes référencement dans les prehome du catalogue
function showLayer(i) {
	document.getElementById("acc"+i).style.display = "block";
}
function hideLayer(i) {
	document.getElementById("acc"+i).style.display = "none";
}


//=> Page home Repassage : rollover sur le div entier

function rollover (param){
	document.getElementById ("contenu").className="over";
}

function rollout (param){
	document.getElementById ("contenu").className="";
}

function toggleAstuceSubmit ()
{
	var sel = document.getElementById( 'theme' );
	var val	= sel.options[ sel.selectedIndex ].value;
	var tar	= document.getElementById( 'btn_astuce_valider' );
	
	if ( val == -1 )
		tar.style.display = 'none';
	else
		tar.style.display = 'inline';
}

// Formatage des données pour XITI
function xtTraiter(nompage) {
   caractere1 = 'éêèëîïíàâáùüûçñôöó';
   caractere2 = 'eeeeiiiaaauuucnooo';
   alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789-_:~\\/';
   nompage = nompage.toLowerCase();
   for (i=0; i<nompage.length; i++) {
        pos = caractere1.indexOf(nompage.charAt(i));
        if (pos != -1) nompage = nompage.substring(0, i) + caractere2.charAt(pos) + nompage.substring(i+1, nompage.length);
        else {
             pos = alphabet.indexOf(nompage.charAt(i));
             if (pos == -1) nompage = nompage.substring(0, i) + '_' + nompage.substring(i+1, nompage.length);
        }
   }
    return (nompage);	
 }
