
	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_validateForm() { //v4.0
		var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
		
		for (i=0; i<(args.length-2); i+=3) {
		
				test=args[i+2];
				
				val=MM_findObj(args[i]);
				

				
				if (val!=null && val.name!='btn_search') {

						nm=val.name;
		
						if ((val=val.value)!="") {
		
								if (test.indexOf('isEmail')!=-1) {
		
										p=val.indexOf('@');
		
										if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
		
								} else if (test!='R') {
				
										if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
		
										if (test.indexOf('inRange') != -1) {
		
											p=test.indexOf(':');
		
											min=test.substring(8,p); max=test.substring(p+1);
		
											if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
		
										}
		
								}
		
						}else if (test.charAt(0) == 'R'){
		
								errors += '- '+nm+' is required.\n'; 
		
						}
		
				}
		
		}
		
		if (errors) alert('The following error(s) occurred:\n'+errors);
		
		document.MM_returnValue = (errors == '');
	
	}

	function doesItJump(caller, jumpto){

		if(caller.value.length >= 4){
			document.getElementById(jumpto).focus();
			return true;
		}else{
			return false;
		}
	
	}



LaPostaleSlideshow = function(slideshow) {
slideshow = $(slideshow);		
var run = function () {
	var findToShow = function() {
		var childElements = slideshow.immediateDescendants();
		for (var i=0;i<childElements.length;i++) {
			if (childElements[i]  && childElements[i].style.display == 'none') {
				return childElements[i];
			}
		}
		for (var i=0;i<childElements.length-1;i++) {
			childElements[i].style.display = 'none';
		}
		var first = slideshow.down();
		if (first.style.display != 'none') first.style.display = 'none';

		new Effect.Fade(childElements[childElements.length-1]);
		return first;
	}
	var toShow = findToShow();
	if (toShow) new Effect.Appear(toShow);
}

new PeriodicalExecuter(run, 5);

}






function ins_verif() {
	if(document.ecrire.com_nom_client.value == "") {
		alert('Veuillez saisir votre nom !');
		document.ecrire.com_nom_client.focus();
	} else {
		if(document.ecrire.com_mail.value == "") {
			alert('Veuillez saisir votre mail !');
			document.ecrire.com_mail.focus();
		} else {
			 var reponse = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			if(!reponse.test(document.ecrire.com_mail.value)) {
				 alert("Vous n'avez pas saisie une adresse email valable !");
				 document.ecrire.com_mail.focus();
			} else {
				if(document.ecrire.com_texte.value == "") {
					alert('Veuillez indiquer votre commentaire !');
					document.ecrire.com_texte.focus();
				} else {
					document.ecrire.url.value = "good";
					document.ecrire.submit();
				}
			}
		}
	}
}

function toggleShoppingCart(){
	
	if($('new_shopping_cart').style.display=='none'){
		$('plus').src='images/minus.gif';
		$('new_shopping_cart').show();
	}else{
		$('plus').src='images/plus.gif';
		$('new_shopping_cart').hide();
	}

	return false;
}


function testCBinJs(){
		var cli_cbexpa = $('cli_cbexpa');
		var cli_cbexpm = $('cli_cbexpm');
		var curM = new Date().getMonth() + 1;
		var curY = new Date().getFullYear();
		var curDate = curY.toString() + curM.toString();
		var dateTest = cli_cbexpa.value.toString() + cli_cbexpm.value.toString();
		var ecart = curDate - dateTest;
		if(ecart>0){
			alert('Carte Bancaire Expirée');
			return false;
		}else{
			var next = true;
			if($('cb_num1').value=='') next = false;
			if($('cb_num2').value=='') next = false;
			if($('cb_num3').value=='') next = false;
			if($('cb_num4').value=='') next = false;
			if($('cli_cbverso').value=='') next = false;
			if(next == false)	{
				alert('Informations Bancaires Incomplètes');
			}
			return next;
		}
		//
}





function showMe(id){
	if($(id)){
		$(id).show();
	}
}

function hideMe(id){
	if($(id)){
		$(id).hide();
	}
}

function checkCBNumbers(){
	var ok = true;
	var numEntier = "";
	for(i=1;i<=4;i++){
		var id = "cb_num" + i;
		if(isNaN($(id).value)){
			ok = false;
			$(id).style.backgroundColor = '#ffaaaa';
		}
		numEntier = numEntier + $(id).value;
	}

	if(isNaN($('cli_cbverso').value)){
		ok = false;
		alert("Attention, votre numéro de validation ne doit contenir que des caractères numériques!");
		return ok;
	}

	if(numEntier==""){
		ok = false;
		alert("Attention, vous n'avez pas saisie votre numéro de CB!");
		return ok;
	}

	if(!ok){
		alert("Attention, votre numéro de CB ne doit contenir que des caractères numériques!");
		return ok;
	}

	return ok;
}


function toggleCheckboxes(element, classe){
	var checkboxes = $$('.' + classe);
	for(i=0;i<checkboxes.length;i++){
		if(element.checked){
			checkboxes[i].checked = 'checked';
		}else{
			checkboxes[i].checked = '';
		}
	}
}


/*
function alertCB (month, year) {

	var mydate	= new Date();
	var myday	=	mydate.getDate();
	var mymonth	=	mydate.getMonth() + 1;
	var myyear	=	mydate.getYear() + 1900;
	
	if (mymonth < 10) { mymonth = "0" + mymonth; }

	if ( (month != '') && (year != '') ) {
		if ( (month - mymonth) < 4 ) {
			alert('Attention, votre carte bancaire expirera dans ' + (month - mymonth) 
			+ ' mois, merci de mettre à jour vos informations bancaires dès que possible');
			return false;
		} 
	}

	return true;

}
*/


function alertCB(mois, annee, type, cbtype){

	var now = new Date();
	var now_year = now.getFullYear();
	var now_month = now.getMonth() + 1;
	var bool = true;

	var cb_date = (annee*12) + mois;

	now = (now_year*12) + now_month;

		if(cbtype==''){
			alert('Merci de renseigner vos nouvelles coordonnées bancaires.');
			bool = false;
			return false;
		}

//	if(type=='single'){
		if(now > cb_date){
			alert('Il semblerait que votre carte bleue ai expirée,' + "\n" + 'merci de renseigner vos nouvelles coordonnées bancaires.');
			bool = false;
		}
//	}

	if(type=='four'){
		if(cb_date - now <= 4){
			alert('Afin de pouvoir payer en 4 fois sans frais, vous devez posséder une carte valide pour les 4 prochains mois minimum...');
			bool = false;
		}
	}


	return bool;
}




function showDynMenu(id){
//	$('sub_img1').src="images/menu2_1_ro.gif";
	$('groupement_categories').show();
	if($(id))	$(id).show();
}

function hideDynMenu(id){
	if($(id))	$(id).hide();
}
/*
function loadAllPics(){

		var imgs = $$('img');
		var totalComplete = true;
		for(i=0;i<imgs.length;i++){
			var img = imgs[i];

			var pos = img.src.indexOf('fili-photos/minis');
			var pos2 = img.src.indexOf('fili-photos/grandes');

			if(pos!=-1 || (pos==-1 && pos2==-1)){
				var src = img.src;
				var bool = false;
//				do{
					bool = loadImg(src);
//				}while(bool!=true);

			}
		}
}
*/
/*
function loadImg(src){
	var temp = Image();
	temp.src=src;
	return temp.complete;
}
*/


document.observe("dom:loaded", function() {

		function tempTest(){

			if($('ajax-loader')){
				$('ajax-loader').hide();
			}
			if($('hidden_content'))	{
				$('hidden_content').show();
			}

			if($('slideshow1'))	 new LaPostaleSlideshow('slideshow1');
		}

			//loadAllPics();

		tempTest.delay(15);

		if($('texte_deroulant_obj1')){
			var loop = function() {
					var marginActuel = parseInt(this.style.marginLeft);
					var nouveauMargin = (marginActuel <= -500) ? 600 : (marginActuel - 2);
					this.style.marginLeft = nouveauMargin + 'px';
			}.bind($('texte_deroulant_obj1')); // elm => this
			window.setInterval(loop, 66); // 1000/15 => 15 i/s
		}

});
