// JavaScript Document
// calculate price based on quantity
function changeQty(change){
    var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    switch (change) {
        case 'add':
            currentQty += 1
            $('quant').value = currentQty
            calculate()
            break
        case 'subtract':
            if (currentQty > 1) { // only subtract if qty is greater than zero
                currentQty -= 1
                $('quant').value = currentQty
                calculate()
            }
            break
        case 'field':
            if (currentQty >= 0) {
                window.setTimeout('calculate()', 500)
            }
            break
    }
}
function calculate(){
    var startPrice = $F('base_price') // Where base_price is the id of your hidden base price field. Gets value of base_price field
    var currentQty = parseInt($F('quant')) // Where quant is the id of your quantity input field. Gets value of currentQty field
    
    if (currentQty > 0) { // Don't want price to display if zero if customer zeros out quantity
        var qtyPrice = startPrice * currentQty // Calculate the price.
        var qtyPrice = qtyPrice.toFixed(2) // Only allow 2 decimals. I'll let you add rounding features up or down.
    } else { // set price back to original price
        qtyPrice = startPrice
    }
    var qtyPrice = qtyPrice + '€' // Add a dollar sign
    $('priceHeading2').update(qtyPrice) // Where priceHeading2 is the id of your span for the echoed product price
    new Effect.Highlight($('priceHeading2'))
}

 function OpenLayer(id){
   if(document.getElementById(id).style.display == "block") {
    document.getElementById(id).style.display = "none" ;
   } else {
    document.getElementById(id).style.display = "block" ;
   }
   window.status =  document.getElementById(id).style.display;
 }
 
function OpenLayerEffect(lien,id){
	
	var objet = document.getElementById(id); // entre les deux ' tu mes le nom du div que tu veux faire apparaître !
	
	if(objet.style.display == "none" || !objet.style.display){
		objet.style.display = "block";
		objet.style.overflow = "hidden"; 
		lien.innerHTML = "-";
       
        var hFinal      =     500;  //Hauteur finale (la hauteur une fois que ça aura fini de déplier !)
        var hActuel     =     0;	 	//Hauteur initiale (la hauteur dès le début !)
       
        var timer;
        var fct =        function ()
        {
                hActuel  +=       20;     //Augmente la hauteur de 20px (tu peux modifier) tous les 40ms !
				
                objet.style.height     =	 hActuel      +     'px';
				
                if( hActuel > hFinal)
                {
                        clearInterval(timer);   //Arrête le timer
                        objet.style.overflow    =   'inherit';
                }
        };
        fct();

        
		timer = setInterval(fct,40);    //Toute les 40 ms
		
	}else if(objet.style.display == "block"){
		
		var hFinal      =     0;  //Hauteur finale (la hauteur une fois que ça aura fini de déplier !)
        var hActuel     =     500;	 	//Hauteur initiale (la hauteur dès le début !)
       
        var timer;
        var fct =        function ()
        {
                hActuel  -=   20;     //Augmente la hauteur de -20px (tu peux modifier) tous les 40ms !
				
                objet.style.height     =	 hActuel      +     'px';
				
                if( hActuel < hFinal)
                {
                        clearInterval(timer);   //Arrête le timer
                        objet.style.overflow    =   'inherit';
						objet.style.display     =   "none";
                }
        };
        fct();

        
		timer = setInterval(fct,40);    //Toute les 40 ms
		

		lien.innerHTML = "+";
		
	}
}