function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function verif(email) { // vérif validité email par REGEXP
   var reg = /^[a-z0-9._-]+@[a-z0-9.-]{2,}[.][a-z]{2,3}$/
   return (reg.exec(email)!=null)
}


function ValiderMail(formulaire) {
	if (!verif(formulaire.visitormail.value)) {
			alert("Merci de saisir une adresse e-mail valide.");		 
	}else{
		 formulaire.submit();
	}
}

function ValiderMail2(formulaire) {
	if (!verif(formulaire.email_address.value)) {
			alert("Merci de saisir une adresse e-mail valide.");		 
	}else{
		 formulaire.submit();
	}
}

function favoris() {
      if ( navigator.appName != 'Microsoft Internet Explorer' ){
          window.sidebar.addPanel("ChezElise, Boutique de Cadeaux personnalisés","http://www.ChezElise.com","");
      }
      else {
          window.external.AddFavorite("http://www.ChezElise.com","ChezElise : Cadeaux personnalisés !");
      }
}

  function toggleDiv_old(divid){
	
    if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
	  document.getElementById(divid).style.visibility = 'visible';
	  // 84 est la valeur de Oui pour l'option de personnalisation
	  //document.getElementById('optn2').value = '84';	  
	  document.getElementById('verrouperso').value = "1";
		}else{
      document.getElementById(divid).style.display = 'none';
	  document.getElementById(divid).style.visibility = 'hidden';
	  // 83 est la valeur de Non pour l'option de personnalisation
	  //document.getElementById('optn2').value = '84';
	  document.getElementById('verrouperso').value = "";
	}
  
  }


  function toggleDiv(divid, radiovalue){
	
	myOption = -1;
	for (i=radiovalue.optn0.length-1; i > -1; i--) {
		if (radiovalue.optn0[i].checked) {
			myOption = i; i = -1;
			/*alert("radiobuttonchecked=" + myOption );*/
			n=navigator;
			nua=n.userAgent;
			saf=(nua.indexOf('Safari')!=-1);
			if (saf)
			{
				/*alert("safari détecté");
				alert("radiobuttonchecked=" + myOption );*/
				myOption = myOption + 1 ;
			}
		}
	}
	/*alert("You selected button number " + myOption
		+ " which has a value of "
		+ radiovalue.optn0[myOption].value);
	alert("verrouperso2=" + document.getElementById('verrouperso2').value );*/
	var obj1 = document.getElementById(divid);
    if(myOption == "2"){
	 obj1.style.display = "block";
      //document.getElementById(divid).style.display = 'block';
	  // 84 est la valeur de Oui pour l'option de personnalisation
	  //document.getElementById('optn2').value = '84';	  
	  document.getElementById('verrouperso').value = "1";
	}else if(myOption == "1"){
	  obj1.style.display = "none";
      //document.getElementById(divid).style.display = 'none';
	  //document.getElementById(divid).style.visibility = 'hidden';
	  // 83 est la valeur de Non pour l'option de personnalisation
	  //document.getElementById('optn2').value = '84';
	  document.getElementById('verrouperso').value = "";
	}
	  
  }  
  
function toggle(id){
    ul = "ul_" + id;
    img = "img_" + id;
    ulElement = document.getElementById(ul);
    imgElement = document.getElementById(img);
    if (ulElement){
            if (ulElement.className == 'closed'){
                    ulElement.className = "open";
                    imgElement.src = "opened.gif";
                    }else{
                    ulElement.className = "closed";
                    imgElement.src = "closed.gif";
                    }
            }
    }


//** Form field Limiter v2.0- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
//** Feb 25th, 09'- Script creation date
//** This notice must stay intact for legal use

var fieldlimiter={

defaultoutput: "<b>[int]</b> caractère(s) restant(s)", //default message that gets output to statusid element

uncheckedkeycodes: /(8)|(13)|(16)|(17)|(18)/, //keycodes that are not checked, even when limit has been reached. See http://www.javascriptkit.com/jsref/eventkeyboardmouse.shtml for avail keycodes

limitinput:function(e, config){
	var e=window.event || e
	var thefield=config.thefield
	var keyunicode=e.charCode || e.keyCode
	if (!this.uncheckedkeycodes.test(keyunicode)){
		if (thefield.value.length>=config.maxlength){
			if (e.preventDefault)
				e.preventDefault()
			return false
		}
	}
},

showlimit:function(config){
	var thefield=config.thefield
	var statusids=config.statusids
	var charsleft=config.maxlength-thefield.value.length
	if (charsleft<0) //if user has exceeded input limit (possible if cut and paste text into field)
		thefield.value=thefield.value.substring(0, config.maxlength) //trim input
	for (var i=0; i<statusids.length; i++){
		var statusdiv=document.getElementById(statusids[i])
		if (statusdiv) //if status DIV defined
			statusdiv.innerHTML=this.defaultoutput.replace("[int]", Math.max(0, charsleft))
	}
	config.onkeypress.call(thefield, config.maxlength, thefield.value.length)
},

cleanup:function(config){
	for (var prop in config){
		config[prop]=null
	}
},


addEvent:function(targetarr, functionref, tasktype){
	if (targetarr.length>0){
		var target=targetarr.shift()
		if (target.addEventListener)
			target.addEventListener(tasktype, functionref, false)
		else if (target.attachEvent)
			target.attachEvent('on'+tasktype, function(){return functionref.call(target, window.event)})
		this.addEvent(targetarr, functionref, tasktype)
	}
},

setup:function(config){
	if (config.thefield){ //if form field exists
		config.onkeypress=config.onkeypress || function(){}
		config.thefield.value=config.thefield.value
		this.showlimit(config)
		this.addEvent([window], function(e){fieldlimiter.showlimit(config)}, "load")
		this.addEvent([window], function(e){fieldlimiter.cleanup(config)}, "unload")		
		this.addEvent([config.thefield], function(e){return fieldlimiter.limitinput(e, config)}, "keypress")
		this.addEvent([config.thefield], function(){fieldlimiter.showlimit(config)}, "keyup")
	}
}

}

