// JavaScript Document
var timerBasket = null;
var timerGlobal = null;
var prevIdCarac = null;

	function is_numeric(num){
		var exp = new RegExp("^[0-9-.]*$","g");
		return exp.test(num);
	}

function uniqid (prefix, more_entropy) {

    if (typeof prefix == 'undefined') {
        prefix = "";
    }
 
   var retId;
    var formatSeed = function (seed, reqWidth) {
        seed = parseInt(seed,10).toString(16); // to hex str
        if (reqWidth < seed.length) { // so long we split
            return seed.slice(seed.length - reqWidth);
        }
        if (reqWidth > seed.length) { // so short we pad
            return Array(1 + (reqWidth - seed.length)).join('0')+seed;
        }
        return seed;
    };
 
    // BEGIN REDUNDANT
    if (!this.php_js) {
        this.php_js = {};
    }
    // END REDUNDANT
    if (!this.php_js.uniqidSeed) { // init seed with big random int
        this.php_js.uniqidSeed = Math.floor(Math.random() * 0x75bcd15);
    }
    this.php_js.uniqidSeed++;
 
    retId  = prefix; // start with prefix, add current milliseconds hex string
    retId += formatSeed(parseInt(new Date().getTime()/1000,10),8);
    retId += formatSeed(this.php_js.uniqidSeed,5); // add seed hex string
 
    if (more_entropy) {
        // for more entropy we add a float lower to 10
        retId += (Math.random()*10).toFixed(8).toString();
   }

    return retId;
}

function strlen (string) {
 
    var str = string+'';
    var i = 0, chr = '', lgth = 0;
 
    var getWholeChar = function (str, i) {
        var code = str.charCodeAt(i);
        var next = '', prev = '';
        if (0xD800 <= code && code <= 0xDBFF) { 
            if (str.length <= (i+1))  {
                throw 'High surrogate without following low surrogate';
            }
            next = str.charCodeAt(i+1);
            if (0xDC00 > next || next > 0xDFFF) {
                throw 'High surrogate without following low surrogate';
            }
            return str.charAt(i)+str.charAt(i+1);
        } else if (0xDC00 <= code && code <= 0xDFFF) {
            if (i === 0) {
                throw 'Low surrogate without preceding high surrogate';
            }
            prev = str.charCodeAt(i-1);
            if (0xD800 > prev || prev > 0xDBFF) { 
                throw 'Low surrogate without preceding high surrogate';
            }
            return false; 
        }
        return str.charAt(i);
    };
 
    for (i=0, lgth=0; i < str.length; i++) {
        if ((chr = getWholeChar(str, i)) === false) {
            continue;
        } 
        lgth++;
    }
    return lgth;
}	

function trim (myString){
	return myString.replace(/^\s+/g,'').replace(/\s+$/g,'');
}






(function($) {  
$.fn.carousel = function (options){ // réglages par défaut
	options = jQuery.extend({
		first : 0, // première image
		slideTime:400, // vitesse d'animation du défilement
		bgColor : '#000', // couleur de fond derrière les images (utile si l'opacité est présente);
		opacity : 0.6, // opacité des images non-survolées
		ease : '', // accélération
		affichage : 5, // accélération
		palierOpa : 20, // différence d'opacité à chaque palier
		baseOpa : 95, // opacité de base
		pageDest : 'fiche-produit.php',
		vertical : 0, // slide en hauteur activé / désactivé
		openShoe : 0
},options);	
	
maxWi=1;



this.each(function(){

var self = $(this);
var setTitle = true;
var old_title = null;
var currentMargin=0;		
var timerBtn = null;	
var timerHover = null;	

var selectorLi = self.find('li');

var nudeLiWi = parseInt(selectorLi.css('width'));

var liWi =  nudeLiWi + parseInt(selectorLi.css('marginRight')) + parseInt(selectorLi.css('marginLeft')) + parseInt(selectorLi.css('borderRightWidth')) + parseInt(selectorLi.css('borderLeftWidth'));

var totalLi = self.find('li').size();


var bgUlImg = self.find('ul').css('backgroundImage');


var marginLi = parseInt(selectorLi.css('marginLeft')) * 2;

var contenerPadding = Math.floor(liWi/2);
var totalWi = (totalLi*liWi) + (contenerPadding*2);

var contenerWi = (options.affichage-1) * liWi;
var contenerHei = parseInt(selectorLi.css('height')) + parseInt(selectorLi.css('borderTopWidth')) + parseInt(selectorLi.css('borderBottomWidth'));
self.css({width:(contenerWi + 2)+'px'});
//alert(contenerWi);
var pageContentHei = contenerHei+2;

var thumbWidth  = (contenerWi - parseInt(selectorLi.css('marginRight'))*totalLi - parseInt(selectorLi.css('marginLeft'))*totalLi - parseInt(selectorLi.css('borderRightWidth'))*totalLi - parseInt(selectorLi.css('borderLeftWidth'))*totalLi )/(totalLi);



self.find('ul').wrap('<div style="width:'+contenerWi+'px; overflow:hidden;" class="content"></div><a href="javascript:;" class="btPrev"><span>Précédent</span></a><a href="javascript:;" class="btNext"><span>Suivant</span></a>');
self.find('ul').before('<div class="secureCache"></div><div class="divLoader" style="background:'+options.bgColor+'; position:absolute; z-index:10; width:'+contenerWi+'px; height:'+pageContentHei+'px; display:none"></div><div class="loaderPage" style="display:none"></div><div class="pageContent" style="display:none"></div><div style="clear:both"></div>');


self.find('ul').css({width:totalWi+'px',padding:'0px '+contenerPadding+'px',height:contenerHei+'px'});

self.find('.pageContent').css({height:pageContentHei+'px',width:contenerWi+'px'});
self.find('.secureCache').css({height:pageContentHei+'px',width:contenerWi+'px',zIndex:'1',position:'absolute'});

self.find('.block').css({height:contenerHei+'px'});


var marginBtNext = '-'+parseInt((contenerHei*0.84) - parseInt($(this).find('.btNext').css('height')) / 2)+'px 0 0 '+parseInt(contenerWi -(parseInt($(this).find('.btNext').css('width'))+10))+'px';
self.find('.btNext').css({margin:marginBtNext})

var marginBtPrev = '-'+parseInt((contenerHei*0.84) - parseInt($(this).find('.btNext').css('height')) / 2)+'px 0 0 10px';
self.find('.btPrev').css({margin:marginBtPrev})

//alert(marginBtNext);
var selectorUl = $(this).find('ul');
selectorLi = $(this).find('li');
var maxDecal=(totalWi-contenerWi)*-1;

var checkPos=1;
$(this).find('li').each(function(){
	$(this).attr('value',checkPos);
	//$(this).html('pos : '+$(this).attr('value'));
	checkPos++;
});


var initLoadSize = parseInt(self.find('.loaderPage').css('width'));
var initLoadMargin = parseInt((contenerHei/2) - parseInt(self.find('.loaderPage').css('height'))/2)+'px 0 0 '+parseInt((contenerWi/2) - parseInt(self.find('.loaderPage').css('width'))/2)+'px';
self.find('.loaderPage').css({margin:initLoadMargin});
var initLoadMarginLeft =parseInt((contenerWi/2) - parseInt(self.find('.loaderPage').css('width'))/2)+'px';
var initLoadMarginTop = parseInt((contenerHei/2) - parseInt(self.find('.loaderPage').css('height'))/2)+'px';
self.find('.loaderPage').css({margin:initLoadMargin});



var nextMargin=0;

if(options.first<1){
	var defineFirst = Math.ceil(totalLi/2);
	options.first=defineFirst;
}	

nextMargin = ((options.first-Math.floor(options.affichage/2)) * liWi)*-1;
if(nextMargin>=0){nextMargin=0;}
if(nextMargin<=maxDecal){nextMargin=maxDecal;}
currentMargin = nextMargin;
selectorUl.css({marginLeft:nextMargin});


		
selectorUl.find('.loader').load(function(){								 
	$(this).prev('.block').show();
	$(this).parent('li').css({backgroundImage:'none'});
	$(this).parent('li').css({backgroundColor:options.bgColor});
});




$(this).find('.btNext').bind('click',function(){			
selectorUl.stop();
nextMargin = currentMargin - liWi;
if(nextMargin<maxDecal){nextMargin=maxDecal;}
currentMargin = nextMargin;
checkFocus();
selectorUl.animate({marginLeft:nextMargin+'px'},options.slideTime,options.ease);	
});

selectorUl.find('li').bind('mouseenter',function(){
	leaveOpa = $(this).find('.block').css('opacity');
	$(this).find('.block').stop();
	$(this).find('.block').animate({opacity:1},400);
});

selectorUl.find('li').bind('mouseleave',function(){
	$(this).find('.block').stop();
	$(this).find('.block').animate({opacity:leaveOpa},100);
	
	if(leaveOpa<0.1){checkFocus();}
	
});






// Chargement PRODUITS

selectorUl.find('.block').bind('click',function(){

	var currentId = $(this).attr('id');
	
	
	openPage(currentId);
	

	
	
	
});


if(options.openShoe>0){
	openPage(options.openShoe);
}



function openPage(id){

if(setTitle==true){
setTitle=false;
old_title = document.title;
}

$('.deplie').css({visibility:'hidden'});
$('.replie').css({visibility:'hidden'});

	//self.find('.pageContent').attr('id','pageContent-'+id);
	//self.find('.divLoader').attr('id','divLoader-'+id);
	//self.find('.loaderPage').attr('id','loaderPage-'+id);
	document.title = 'CARVIL - Chargement...';
	self.find('.divLoader').css({opacity:0.7});
	self.find('.divLoader').fadeIn(80);
	self.find('.loaderPage').fadeIn(80,function(){
	self.find('.pageContent').load(options.pageDest+'?id='+id,function(){	
	$('.controleMatiere').unbind();
	$('.liste-pointures').unbind();
	$('.addBasket').unbind();
	$('a.inactif').bind('click',function(){ noAddBasket();});	
	
	timerGlobal = null;
	prevIdCarac = null;
	
	self.find('.loaderPage').animate({marginLeft:0+'px',width:contenerWi+'px',marginTop:0+'px',height:pageContentHei+'px'},600,options.ease,function(){
	self.find('.pageContent').show();	
	self.find('.loaderPage').fadeOut(200,function(){controleDesc();});
	
	

self.find('.viewVarianteProd').bind('click',function(){
document.title = 'CARVIL - Chargement...';
nextId = parseInt($(this).find('img').attr('alt'));
self.find('.loaderPage').show();
		self.find('.pageContent').fadeOut(100,function(){
		self.find('.loaderPage').animate({width:initLoadSize+'px',height:initLoadSize+'px',marginLeft:initLoadMarginLeft,marginTop:initLoadMarginTop},400,options.ease,function(){
		openPage(nextId);
		
});

});
});

	
	
	
	
		self.find('.btInterne').bind('click',function(){
		nextId = $(this).find('span').html();
		
		document.title = 'CARVIL - Chargement...';
	
		self.find('.loaderPage').show();
		self.find('.pageContent').fadeOut(100,function(){
		self.find('.loaderPage').animate({width:initLoadSize+'px',height:initLoadSize+'px',marginLeft:initLoadMarginLeft,marginTop:initLoadMarginTop},400,options.ease,function(){
		openPage(nextId);
		
		});
		});
		
		
		
		
	});
	
	
	

self.find('.viewVariante').bind('click',function(){
	$('#bgEquiv').css({opacity:0.7});	
	$('#bgEquiv').fadeIn(200);	
	$('#thumbEquiv').fadeIn(300);
	});

self.find('.closeVariante').bind('click',function(){
		
	$('#bgEquiv').hide();	
	$('#thumbEquiv').hide();	
	});


	
	
	
	
	self.find('.closeProd').bind('click',function(){
		$('.deplie').css({visibility:''});
		$('.replie').css({visibility:''});										  
		$('.open').removeClass('open');
		document.title = old_title;
		self.find('.loaderPage').show();
		self.find('.pageContent').fadeOut(100,function(){
		self.find('.loaderPage').animate({width:initLoadSize+'px',height:initLoadSize+'px',marginLeft:initLoadMarginLeft,marginTop:initLoadMarginTop},400,options.ease,function(){
		self.find('.divLoader').fadeOut(100);	
		self.find('.loaderPage').fadeOut(100);	
		});
		});
		
		
		
		
		
	});
	
	
	});
	});
		

		

	});

}






$(this).find('.btPrev').bind('click',function(){			
selectorUl.stop();
nextMargin = currentMargin + liWi;
if(nextMargin>0){nextMargin=0;}
currentMargin = nextMargin;
checkFocus();
selectorUl.animate({marginLeft:nextMargin+'px'},options.slideTime,options.ease);							 							 
});


function extendGalerie(){
		selectorUl.stop();
		selectorUl.find('li').stop();
		self.find('ul').css({backgroundImage:'none'});
		selectorUl.find('.block').stop();
		self.find('.btPrev').hide(); self.find('.btNext').hide(); self.find('.deplie').hide(); self.find('.replie').show();
		selectorUl.css({padding:'0 0'});	
		selectorUl.animate({marginLeft:0+'px'},500,options.ease);															  
		selectorUl.find('li').animate({width:thumbWidth+'px',marginBottom:'0'},500,options.ease);
		selectorUl.find('.block').animate({opacity:((100-(options.palierOpa*2))/100)},200);
		selectorUl.find('.block').addClass('compress');
		//selectorUl.find('.block h1').fadeOut(100);
		//selectorUl.find('.block h2').fadeOut(100);



		selectorUl.find('.compress').bind('mouseenter',function(){
		clearTimeout(timerHover);																
		leaveOpa = ((100-(options.palierOpa*2))/100);
		
		adjustWi = Math.round((liWi-thumbWidth)/totalLi);

		selectorUl.find('.compress').parent('li').stop();
		
		
		 $(this).parent('li').stop();	
	     
		

		
		selectorUl.find('.compress').parent('li').each(function(){
																		
		$(this).css({width:thumbWidth-adjustWi+'px'});

																		  
																							  
		});
		
		$(this).parent('li').css({width:Math.round(liWi)+'px'});
		 //$(this).find('h1').show(); $(this).find('h2').show();
		 

		});
		
		selectorUl.find('.compress').bind('mouseleave',function(){
			
		$(this).parent('li').stop();
		
		timerHover = setTimeout(function(){
	    
		selectorUl.find('.compress').parent('li').stop();
		selectorUl.find('.compress').parent('li').animate({width:thumbWidth+'px'},600,options.ease);
		//selectorUl.find('.compress h1').stop();
		//selectorUl.find('.compress h2').stop();
		//selectorUl.find('.compress h1').hide();
		//selectorUl.find('.compress h2').hide();
		clearTimeout(timerHover);	
		},300);
		
		});
		
		
}

function compressGalerie(){
		self.find('ul').css({backgroundImage:bgUlImg});
		selectorUl.find('.compress').unbind('mouseenter');
		selectorUl.find('.compress').unbind('mouseleave');
		selectorUl.stop();
		selectorUl.find('li').stop();
		self.find('.btPrev').show(); self.find('.btNext').show(); self.find('.deplie').show(); self.find('.replie').hide();
		selectorUl.animate({marginLeft:currentMargin+'px'},300,options.ease);
		selectorUl.css({padding:'0 '+contenerPadding+'px'});	
		selectorUl.find('li').animate({width:nudeLiWi+'px'},300,options.ease);
		selectorUl.find('li').removeClass('compress');
		selectorUl.find('.block h1').show();
		selectorUl.find('.block h2').show();
}


self.find('.deplie').bind('click',function(){extendGalerie();});
self.find('.replie').bind('click',function(){compressGalerie();checkFocus();});




function checkFocus(){
thisFocus = Math.floor(nextMargin/liWi)*-1+(Math.floor(options.affichage/2));	


if(nextMargin>=(0-liWi)){self.find('ul').css({backgroundPosition:'left'});} else {self.find('ul').css({backgroundPosition:(totalWi-Math.round(liWi))+'px'});}

selectorUl.find('li').each(function(){
		//alert(parseInt($(this).attr('value')));	
		self.find('.secureCache').show();
	 var diffPos = 	parseInt($(this).attr('value')) - thisFocus;
	
	if(diffPos <0){diffPos=diffPos*-1;}
	
	 var thisOpa = Math.round((options.baseOpa - diffPos * options.palierOpa))/100;
	
	//$(this).css({opacity:thisOpa});
	$(this).find('.block').stop();
	if(diffPos < Math.ceil(options.affichage/2)){
		clearTimeout(timerBtn);
	$(this).find('.block').animate({opacity:thisOpa},Math.round(options.slideTime/2),function(){
	timerBtn = setTimeout(function(){self.find('.secureCache').hide();},100);
	});
	}
	
});

clearTimeout(timerBtn);

if(nextMargin>=0){timerBtn = setTimeout(function(){self.find('.btPrev').hide();},options.slideTime);} else {self.find('.btPrev').show();}
if(nextMargin<=maxDecal){timerBtn = setTimeout(function(){self.find('.btNext').hide();},options.slideTime);} else {self.find('.btNext').show();}


}

checkFocus();		



});
}})(jQuery);


var timerError=null;

function noAddBasket(){
	clearTimeout(timerError);
	$('#errorBasket').slideDown(150,function(){												   
	timerError = setTimeout(function(){$('#errorBasket').fadeOut(200); clearTimeout(timerError);},600);	
	});
}

function addBasket(id){

var submitIdCarac = parseInt($('#id_carac').val());
var submitIdProduit = parseInt($('.addBasket').attr('value'));
var submitPointure = parseFloat($('.liste-pointures').find('span').html());

if(submitIdCarac>0 && submitIdProduit>0 && submitPointure>0){
	
clearTimeout(timerBasket);
$('#load-basket').show();
$('#okBasket').hide();
clearTimeout(timerError);
timerBasket = setTimeout(function(){

$('#actions').load('add-basket.php?id_produit='+encodeURIComponent(submitIdProduit)+'&id_carac='+encodeURIComponent(submitIdCarac)+'&pointure='+encodeURIComponent(submitPointure),function(){
$('#load-basket').hide();
$('#okBasket').slideDown(150,function(){												   
	timerError = setTimeout(function(){$('#okBasket').fadeOut(200); clearTimeout(timerError);},800);	
});
clearTimeout(timerBasket);
});
 },200);

}

}




function showMatieres(){
	$('.liste-matieres-result').slideToggle(200,function(){
	
	$('.controleMatiere').bind('mouseleave',function(){	timerGlobal = setTimeout(function(){$('.liste-matieres-result').slideUp(100); $('.controleMatiere').unbind();  clearTimeout(timerGlobal);},500);});
	$('.controleMatiere').bind('mouseenter',function(){ clearTimeout(timerGlobal);});
	
	$('.liste-matieres-result').find('a').each(function(){
		$(this).bind('click',function(){
		
		var idCarac = $(this).attr('value');
		
		$('#id_carac').val(idCarac);
		
		$('#errorBasket').css({marginTop:'-108px'});
		$('#errorBasket').find('div').html('Vous devez choisir une pointure');
		
		
		$('.liste-matieres').find('span').removeClass('inactif');
		$('.liste-matieres').find('span').html($(this).html());
		$('.liste-pointures').css({opacity:1});
		$('.liste-pointures-result').html($('#pointures-'+idCarac).html());
		$('.controleMatiere').unbind();  $('.liste-matieres-result').hide(); clearTimeout(timerGlobal);
		
		
		if( prevIdCarac != idCarac){
		prevIdCarac = idCarac;
		
		
		$('.liste-pointures').unbind();
		$('.liste-pointures').find('span').addClass('inactif');
		$('.liste-pointures').find('span').html('Choisissez');
		$('.addBasket').addClass('inactif');
		$('.addBasket').unbind();
		$('.addBasket').bind('click',function(){
		noAddBasket();
		});
		
		$('.liste-pointures').bind('click',function(){
		$('.liste-pointures-result').slideToggle(200,function(){
		$('.controlePointures').bind('mouseleave',function(){	timerGlobal = setTimeout(function(){$('.liste-pointures-result').slideUp(100); $('.controlePointures').unbind();  clearTimeout(timerGlobal);},500);});
		$('.controlePointures').bind('mouseenter',function(){ clearTimeout(timerGlobal);});
		$('.liste-pointures-result').find('a').each(function(){
		$(this).bind('click',function(){
		$('.liste-pointures').find('span').removeClass('inactif');
		$('.liste-pointures').find('span').html($(this).html());
		$('.controlePointures').unbind();  $('.liste-pointures-result').hide(); clearTimeout(timerGlobal);
		
		$('.addBasket').removeClass('inactif');
		$('.addBasket').unbind();
		$('.addBasket').bind('click',function(){
		addBasket();
		});
		
		
		
		});
		});
		});	
		});	
		
		
		
		
		}
		
			
		});
	});

});	
}


function controleDesc(){
	var divHei = $('#prodDesc').find('div').height();	
	if(divHei>42){
	$('#prodDesc').css({height:'38px'});	
	$('#prodDesc').find('div').css({width:'180px'});	
	divHei = $('#prodDesc').find('div').height();
	
	ratioSlide = (divHei-30)/100;

	$("#slider-vertical").slider({
			orientation: "vertical",
			range: "min",
			min: -100,
			max: 0,
			value: 0,
			animate:true,
			slide: function(event, ui) {
				
				newMarginDec = ui.value*ratioSlide;
				
			$('#prodDesc').find('div').css({marginTop:''+newMarginDec+'px'});
				
				
				$("#amount").val(ui.value);
			}
		});

	
	
	
	
	
	
	
	
	
	
	
	}

}



function majForm(){
	$('#load-my-infos').show();
	$('#my-infos').hide();
	$('#my-infos').submit();
}
	
	
function deleteProd(id){
	$('#load-basket').show();
	$('#basket').hide();
	$('#actions').load('delete-basket.php?id='+id,function(){
	$('#my-infos').submit();
	});
}


function validCommande(){
	
	var nom = trim($('#form-nom').val());
	var prenom = trim($('#form-prenom').val());
	var adresse_1 = trim($('#form-adresse_1').val());
	var adresse_2 = trim($('#form-adresse_2').val());
	var code_postal = trim($('#form-code_postal').val());
	var ville = trim($('#form-ville').val());
	var pays = parseInt($('#form-pays').val());
	if($('#my_abo').is(':checked')==false){
	var my_abo = 0;
	var mode = trim($('#form-mode').val());
	var presta = '';
	var num_abo = '';
	} else {
	var my_abo = 1;
	var mode = '';
	var presta = parseInt($('#form-presta').val());
	var num_abo = trim($('#form-num_abo').val());
	}
	var email = trim($('#form-email').val());
	var telephone = trim($('#form-telephone').val());
	var commentaire = trim($('#form-commentaire').val());




	
if(strlen(nom)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre nom</div>')	
}

else

if(strlen(prenom)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre prénom</div>')	
}

else

if(strlen(adresse_1)<5){
$('#erreur-commande').html('<div>Vous devez indiquer votre adresse</div>')	
}

else

if(strlen(code_postal)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre code postal</div>')	
}

else

if(strlen(ville)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre ville</div>')	
}

else

if(pays<1){
$('#erreur-commande').html('<div>Vous devez indiquer votre pays</div>')	
}

else

if(strlen(email)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre adresse e-mail</div>')	
}

else

if(strlen(telephone)<2){
$('#erreur-commande').html('<div>Vous devez indiquer votre numéro de téléphone</div>')	
}


else

if($('#my_abo').is(':checked')==true && presta<1){
$('#erreur-commande').html('<div>Vous devez indiquer un prestataire pour l\'envoi du colis</div>')
}

else

if($('#my_abo').is(':checked')==true && strlen(num_abo)<2){
$('#erreur-commande').html('<div>Vous devez indiquer un numéro d\'abonné</div>')
}


else

{
	$('#basket').hide();
	$('#load-commande').show();
	$('#actions-commande').html('');
	$('#actions-commande').load('create_commande.php?nom='+encodeURIComponent(nom)+'&prenom='+encodeURIComponent(prenom)+'&adresse_1='+encodeURIComponent(adresse_1)+'&adresse_2='+encodeURIComponent(adresse_2)+'&ville='+encodeURIComponent(ville)+'&code_postal='+encodeURIComponent(code_postal)+'&pays='+encodeURIComponent(pays)+'&mode='+encodeURIComponent(mode)+'&my_abo='+encodeURIComponent(my_abo)+'&presta='+encodeURIComponent(presta)+'&num_abo='+encodeURIComponent(num_abo)+'&email='+encodeURIComponent(email)+'&telephone='+encodeURIComponent(telephone)+'&commentaire='+encodeURIComponent(commentaire));
	
}

	
}


function login(type){
	
	var log_email = trim($('#log-email').val());
	var log_passwd = trim($('#log-passwd').val());
	var acting = 'account';
	
	
	if(type==1){
		acting = 'basket';
	}
	
	$('#actions-login').html('<img src="./imgs/load-mini.gif" alt="Chargement"/>');
	$('#actions-login').load('ident.php?email='+encodeURIComponent(log_email)+'&passwd='+encodeURIComponent(log_passwd)+'&action='+acting);
	
	
}



function inscription(){


	
	var log_email = trim($('#inscri-email').val());
	var log_passwd = trim($('#inscri-passwd').val());


if(strlen(trim(log_email))>0 && strlen(trim(log_passwd))>0){

	$('#actions-inscri').html('<img src="./imgs/load-mini.gif" alt="Chargement"/>');
	$('#actions-inscri').load('inscription.php?email='+encodeURIComponent(log_email)+'&passwd='+encodeURIComponent(log_passwd));

}
	
}






function checkCode(){
	var myCode = trim($('#myCode').val());
	if(strlen(myCode)>0){
	$('#load-code').show();
	$('#checkCode').load('check-code.php?code='+encodeURIComponent(myCode),function(){
	$('#load-code').hide();
	});
	}
}



function addChequeBasket(id){
	$('.addBasket').css({opacity:0.2});
	
	$('#actions').load('add-cheque-basket.php?id_produit='+encodeURIComponent(id),function(){
		$('.addBasket').css({opacity:1});
		
		
		
	});
	
	
}




function checkMail(mail) {
if(mail!=""){
if ((mail.indexOf("@")>=0)&&(mail.lastIndexOf(".")>mail.indexOf("@"))) {
return true
} else {
return false
}
}else{
return true
}
}


function inscriptionNL(){
	var email = trim($('#emailNL').val());	
	
	if(checkMail(email)==false || strlen(email)<3){
		alert("Adresse e-mail non valide");
	}
	
	else
	
	{
		$('#actions').load('inscriptionNL.php?email='+encodeURIComponent(email));	
	}
	
	
}


