function verifMail(a){
testm = false ;
 for (var j=1 ; j<(a.length) ; j++) {
  if (a.charAt(j)=='@') {
   if (j<(a.length-4)){
    for (var k=j ; k<(a.length-2) ; k++) {
     if (a.charAt(k)=='.') testm = true;
    }
   }
  }
 }
return testm ;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function applyClass(oElement,sCSSClass)

{
     oElement.className = sCSSClass;
}


function ImageMax(chemin)
   {
   i1 = new Image;
   i1.src = chemin;
   html = '<html><head><title><?= $siteName; ?></title></head><body scroll="no" leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" onBlur="top.close()"><a href="javascript:close()"><img src="'+chemin+'" border=0 name=ImageMax onLoad="window.resizeTo(document.ImageMax.width+10,document.ImageMax.height+60)"></a></body></html>';
   popupImage = window.open('','_blank','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=0,resizable=1,left=200,top=200');
   popupImage.document.open();
   popupImage.document.write(html);
   popupImage.document.close()
   };

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function setPointer(theRow, thePointerColor)
{
    if (typeof(theRow.style) == 'undefined' || typeof(theRow.cells) == 'undefined') {
        return false;
    }
 
    var row_cells_cnt = theRow.cells.length;
    
    for (var c = 0; c < row_cells_cnt; c++) {
        theRow.cells[c].bgColor = thePointerColor;        
    }
 
    return true;
}

function valid_search(form) {
  if (form.recherche.value == ""){
    alert("Veuillez saisir une recherche.")
	form.recherche.focus();
	return false }
	return true
}
function valid_mail(form) {
  if (form.email.value == ""){
    alert("Veuillez saisir une adresse mail.")
	form.email.focus();
	return false }
  if (verifMail(form.email.value)==false){
    alert("Le format de l'adresse mail n'est pas correct...")
	form.email.focus();
	return false }
	return true
}


//Gestion de Fondus	////////////////////////////////////////////////////////////////////////
function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
//	setTimeout("document.getElementById("+id+").style.display=\"none\";","3000");
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
	
} 
//Fin Gestion de Fondus	////////////////////////////////////////////////////////////////////////

function affiche_img(source, nom, lien){
	document.getElementById(nom).src = 'upload/produit/a-'+source;
	document.getElementById(lien).href = 'upload/produit/z-'+source;
	
}



function info_retour(txt,id,temps) { 

	document.getElementById(id).innerHTML ="<div id=\"retour_action\"><img src=\"../img/picto_valider_ajout.png\" align=\"absmiddle\" />&nbsp;"+txt+"</div>";
	timer=setTimeout("opacity('retour_action', 100, 0, 800)", temps);	
	setTimeout("document.getElementById('retour_action').style.display=\"none\";",2500);

}
	
function maj_quantite(pro_id, color, size){
	var qte = document.getElementById('qte_'+pro_id).value;
	window.location.href= 'panier_process.php?pro_id='+pro_id+'&maj=1&qte='+qte+'&color='+color+'&size='+size;	
}
function affiche_menu(id, value){
	document.getElementById(id).style.display=value;
	
	//setTimeout("document.getElementById("+id+").style.display=\"block\";",1500);
	
}
