	
		
		
	var RequetePort = function (pays, total) {
    		var req = new Request({
  			url: 'http://www.disquesdreyfus.com/shop/assets/snippets/dreyfus/gestionPort.php',
			method:'get',
			data:{	pays:pays,
					total:$('soustotal').get('html')
 			},
  			onSuccess: function(retourAjax) { 				   
				var retour = retourAjax.split('-');
				var frais = retour[0];    
				var totalOK = retour[1];  
				var tvaTotal = retour[2];  
				var fraisOffert = retour[3];  
				$('valeur_frais').set('html', frais + " €");        
				$('valeur_totalTTC').set('html',totalOK + " €"); 
				$('tvaOK').set('html',tvaTotal + " €");      
 				if (fraisOffert.length>2) {                          
					$('benefice').setStyle('display', 'block');
					$('fraisOffert').set('html',fraisOffert + " €");      
				} else {
					$('benefice').setStyle('display', 'none');
				};     
				                                        
 			},
  			onFailure: function(retourAjax){
				alert(retourAjax);
			}		
 		});
		req.send();
 	};
			
			   	
		
		
	var RequetePortEtCommande = function (pays, total) {
    		var req = new Request({
  			url: 'http://www.disquesdreyfus.com/shop/assets/snippets/dreyfus/gestionPort.php',
			method:'get',
			data:{	pays:pays,
					total:$('soustotal').get('html')
 			},
  			onSuccess: function(retourAjax) { 				   
				var retour = retourAjax.split('-');
				var frais = retour[0];    
				var totalOK = retour[1];  
				var tvaTotal = retour[2];  
				var fraisOffert = retour[3];  
				$('valeur_frais').set('html', frais + " €");        
				$('valeur_totalTTC').set('html',totalOK + " €"); 
				$('tvaOK').set('html',tvaTotal + " €");      
 				if (fraisOffert.length>2) {                          
					$('benefice').setStyle('display', 'block');
					$('fraisOffert').set('html',fraisOffert + " €");      
				} else {
					$('benefice').setStyle('display', 'none');
				};     
				window.location = "http://www.disquesdreyfus.com/shop/index.php?id=16&action=commander";
 			},
  			onFailure: function(retourAjax){
				alert(retourAjax);
			}		
 		});
		req.send();
 	};
			
			   
			
			
	var requeteSupprime = function (idProd) {
    		var req = new Request({
  			url: 'http://www.disquesdreyfus.com/shop/assets/snippets/dreyfus/gestionPort.php',
			method:'get',
			data:{	
				action:'supprimeProduit',
				idProd:idProd
 			},
  			onSuccess: function(retourAjax) { 				
				alert(retourAjax);
 			},
  			onFailure: function(retourAjax){
				alert(retourAjax);
			}		
 		});
		req.send();
 	};
		
		
		
		
		
		
	var commander = function(e) {
		window.location = "http://www.disquesdreyfus.com/shop/index.php?id=16&action=commander";
	};
	
	var SelectionPort = function(e) {
 		RequetePort($('pays').value);
	};
		
	var SelectionPortEtCommande = function(e) {
 		RequetePortEtCommande($('pays').value);
	};
		
	    
		
		

	function desactiveEnter(){      
		if (event.keyCode == 13) { 
			event.keyCode = 0; 
			window.event.returnValue = SelectionPort();;  
		} 
	}          		
		
		
		
		
		
		
		
		
		
		
		
window.addEvent('domready',function(){
	
	$$('td.td_supprimer').each(function(e) {
		e.addEvent('click', function(f) {
			var url = window.location;
			window.location = url + "&action=supprimeProduit&idProd="+e.id.substring(9);
		});
	});     	
	                       
	
	
	$$('td.td_quantite input').each(function(e) {
		e.addEvent('change', function(f) {
			var url = window.location;      
			var idProd = e.id.substring(12);
			var qte = e.value;
		    window.location = "http://www.disquesdreyfus.com/shop/index.php?id=14&action=quantiteProduit&idProd=" + idProd + "&qte= "+qte;
		});
	});     
                        


  	
	$$('td.td_quantite span.qte_moins').each(function(e) {
		e.addEvent('click', function(f) {  
			var parent = e.getParent().getElement('input');
			var url = window.location;      
			var idProd = parent.id.substring(12);
			var qte = parent.value;  
			if (qte==1) {                
 				window.location = url + "&action=supprimeProduit&idProd="+parent.id.substring(12);     			
			} else {                                                                
				parent.set('value',qte--); 
				window.location = "http://www.disquesdreyfus.com/shop/index.php?id=14&action=quantiteProduit&idProd=" + idProd + "&qte= "+qte;   
			}                                                                                                                              
		});
	});     

  	
	$$('td.td_quantite span.qte_plus').each(function(e) {
		e.addEvent('click', function(f) {  
			var parent = e.getParent().getElement('input');
			var url = window.location;      
			var idProd = parent.id.substring(12);
			var qte = parent.value; 			                                                
			parent.set('value',qte++); 
			window.location = "http://www.disquesdreyfus.com/shop/index.php?id=14&action=quantiteProduit&idProd=" + idProd + "&qte= "+qte;                                                                                                                                 
		});
	});     
             
  

     
	$('commander').addEvent('click', function(e) {    
		e.stop();
		SelectionPortEtCommande();
	});

	$('pays').addEvent('change', function(e) {
		SelectionPort();
	});
		
 	RequetePort($('pays').value);     

           
		
});
        
             
