// JavaScript Document

function $id(id){
	return document.getElementById(id)
}
function showbox(str){
	$id(str).style.visibility='visible';	
}
function hidebox(str){
	$id(str).style.visibility='hidden';	
}
function sendcart(){
		sendReq("cart_total.php?qty="+$id('qty').value+"&addPro="+$id('produt_cart').value+"&attribute="+$id('attribute').value+"&price="+$id('price').value,"prixtotal","hidebox('cart')");
		sendReq("cart.php?qty="+$id('qty').value+"&addPro="+$id('produt_cart').value+"&attribute="+$id('attribute').value+"&price="+$id('price').value,"article","document.location.replace('Votre-panier-e_etape1.html')");
	}
function cartclose(){
		sendReq("cart_total.php?qty="+$id('qty').value+"&addPro="+$id('produt_cart').value+"&attribute="+$id('attribute').value+"&price="+$id('price').value,"prixtotal","hidebox('cart')");
		sendReq("cart.php?qty="+$id('qty').value+"&addPro="+$id('produt_cart').value+"&attribute="+$id('attribute').value+"&price="+$id('price').value,"article","hidebox('cart')");
		hidebox("cart");
}

function checkemail(){
							var str=$id('email').value;
							var pos_acrobat=str.indexOf("@");
							if ((str.lastIndexOf(".") > pos_acrobat+2) && ( pos_acrobat > 0) ){
   								$id('check_Email').innerHTML='<img src="images/check_v.gif" height="20"/>';
								return 1;
							}else $id('check_Email').innerHTML='<img src="images/check_f.gif" height="20"/>';
								return 0;
}

function checkemailnewlettre(id){
	
							var str=$id(id).value;
							var pos_acrobat=str.indexOf("@");
							if ((str.lastIndexOf(".") > pos_acrobat+2) && ( pos_acrobat > 0) ){
								return 1;
							}else 
								return 0;
}
function checkemailnewlettre2(id){
	
								if($id(id).value.match( /^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$/)){
								return 1;
							}else 
								return 0;
}


function sendReq(url,id,eval_str){
    if(document.getElementById){
		 var object=(window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
	}
	
	
    if(object){
		 object.onreadystatechange=function() {
        el=document.getElementById(id);
        el.innerHTML='attendez....';
        if(object.readyState==4&&object.status==200){
            el.innerHTML='';
            el=document.getElementById(id);
            el.innerHTML=object.responseText;
				if(eval_str!='')eval(eval_str);
        }
    	}
		
    object.open("GET",url,true);
	 object.send(null);
    }
}

function news_lettre(){
		 if(checkemailnewlettre('news')==1)
		 sendReq('newsletter.php?email='+$id('news').value,'inscrit') 
		 else alert('Votre email n\'est pas valide')
}
function news_lettre_popup(){
		 if(checkemailnewlettre2('news')==1)
		 sendReq('../newsletter.php?email='+$id('news').value,'inscrit') 
		 else alert('Votre email n\'est pas valide')
}

// Page registration.php
				function validation(){
								var check_id='';
								var check_id2='';
								
								if($id('postal_d').value=='') check_id='postal_d';
								if($id('Ville_d').value=='') check_id='Ville_d';
								if($id('adresse_d').value=='') check_id='adresse_d';
								if($id('prenom_d').value=='') check_id='prenom_d'; 
								if($id('nom_d').value=='') check_id='nom_d';
								if($id('postal').value=='') check_id='postal';				
								
								if($id('ville').value=='') check_id='ville'; 
								if($id('adresse').value=='') check_id='adresse';
                        		if($id('email').value=='') check_id='email';
								if(checkemail()==0)check_id='email';
								if($id('tel').value=='') check_id='tel'; 
								
								if($id('date').value=='') check_id='date'; 
								
								if($id('prenom').value=='') check_id='prenom';
								if($id('nom').value=='') check_id='nom'; 
								
								if($id('repassword').value!=$id('repassword').value) check_id='repassword';
								
								if($id('passwords').value=='') check_id='passwords'; 
								if($id('identifiant').value=='') check_id='identifiant';  
								
								if(isNaN($id('postal').value)) check_id2='postal';
								 
								if(isNaN($id('postal_d').value)) check_id2='postal_d';
								if(isNaN($id('tel').value)) check_id2='tel';
								if(isNaN($id('tel_d').value)) check_id2='tel_d';
								if(isNaN($id('portable').value)) check_id2='portable';
								if(isNaN($id('portable_d').value)) check_id2='portable_d';
								if(isNaN($id('fax').value)) check_id2='fax';
			
								
								if(check_id!=''){
									$id(check_id).style.background='url(images1/bginputRed.gif) right repeat-y';
									$id(check_id).style.border='dotted 1px #F00';
									alert('Veuillez remplir les champs obligatoires(*) : '+check_id);
									$id(check_id).focus();
								}
								else if(check_id2!=''){
									$id(check_id2).style.background='url(images1/bginputRed.gif) right repeat-y';
									$id(check_id2).style.border='dotted 1px #F00';
									alert('Veuillez saisir uniquement des chiffres dans ce champ: '+check_id2);
									$id(check_id).focus();
								}
								
								else $id('frm').submit(); 
							}

function checkRePw(){
								if($id('passwords').value==$id('repassword').value) 
									$id('checkpw').innerHTML='<img src="images/check_v.gif" height="20"/>';
									else{
										$id('checkpw').innerHTML='<img src="images/check_f.gif" height="20"/>';
										$id('repassword').focus();
										return false;
									}
							}

function checkPw(object){
						
								if(object.value.length<4){
									alert('Pour votre sécurité! Veuillez entrer avec au moins 4 caractères');
									object.focus(); 
									return false;
								}
						}
