

window.addEvent('domready', function() {
	   if($('submitter')){
	$('submitter').addEvent('click', function(e) {

		e.stop();
		for (i=0;i<document.add_to_cart.mode.length;i++) {

}


    $('submitter').innerHTML = "<img style='height:16px;width:16px;' src='/images/load.gif'></img>";
		         
        
              fadeoutcart();

				$('myForm').set('send', {onComplete: function(response) { 
              
									addtocart();	
								
					}});
				$('myForm').send();
	});
}
})

var addtocart = function(){
element = $('vertical_slide');
var myFx = new Fx.Tween(element);
        var element = $('vertical_slide');
                         var req = new Request({  
                      
             method: 'get',  
             link: 'ignore',
             url: '/adhocmini.php',  
         evalScripts: false,
             
               onComplete: function(response) { 
                           
	                    $('vertical_slide').innerHTML= response;
	              
                    
                      } 
  
         }).send().chain(function(){

    (function(){myFx.start('opacity', '0', '1');}).delay(50);
										$('submitter').innerHTML = "Add to Basket";
      });

 
 
}
 
var addtowish = function(){
element = $('wishlistheader');
var myFx = new Fx.Tween(element);
        var element = $('wishlistheader');
                         var req = new Request({  
                      
             method: 'get',  
             link: 'ignore',
             url: '/miniwish.php',  
         evalScripts: false,
             
               onComplete: function(response) { 
                           
	                    $('wishlistheader').innerHTML= response;
	              
                    
                      } 
  
         }).send().chain(function(){

    (function(){myFx.start('opacity', '0', '1');}).delay(50);
										$('submitter').innerHTML = "Add to Basket";
      });

 
 
}

var fadeoutcart = function(){
element = $('vertical_slide');
var myFx = new Fx.Tween(element);
var mySlide = myFx.start('opacity', '1', '0');

}

var fadeoutwish = function(){
element = $('wishlistheader');
var myFx = new Fx.Tween(element);
var mySlide = myFx.start('opacity', '1', '0');

}
 
 window.addEvent('domready', function() { 
	$$('.itembg input[type=checkbox],.itembg input[type=radio],.item input[type=radio]').each(function(el){
	
		el.addEvent('click',function(){
		
      lastchecked=this;

			calculate();
			
		}); 
	}); 	
});


  

  
 window.addEvent('domready', function() { 
   if($('thumbchange')){
	$$('.itembg').each(function(elh){
	
		elh.addEvent('mouseenter',function(){


				$('thumbchange').innerHTML = "<img src='/images/" + this.getProperty('id') + ".jpg'></img>";
		}); 
	}); 
  }	
});




function calculate(){


	
  var totaloptions = 0;
	var subtotal = 0;
		var abtotaloptions = 0;
		for(var i=1;i<=28;i++){		
		var tmp = '.group_q'+i;
		$$(tmp).each(function(el){
			if (el.getProperty('checked') == true){

			abtotaloptions++;
				
	
			};
		});			 
	}
	
	
	
	

	

	
	
	
	
	
	
	
	
	
	
	
	
	
	for(var i=1;i<=28;i++){		
		var tmp = '.group_q'+i;
		$$(tmp).each(function(el){
			if (el.getProperty('checked') == true){

			totaloptions++;
				var qVal = (myvar[el.getProperty('value')]);			
				subtotal += (qVal*1);
	
			}else if(el.getProperty('checked') == false){
			
		if(chocolatepizza==1)	{
if(abtotaloptions!=3){
			
			active_element = 	$(el.getParent().getProperty('id'))
      var myFx = new Fx.Tween(active_element);

      myFx.start('background-color', '#F4F0EC');
			
			}
			}
			
			};
		});			 
	}


		if(chocolatepizza==1)	{
if(totaloptions<4){

lastchecked.checked=true;


}



if(lastchecked.checked==true){

active_element = $(lastchecked.getParent().getProperty('id'));
var myFx = new Fx.Tween(active_element);

myFx.start('background-color', '#C1A885');



}

}
		if(chocolatepizza==1)	{
if((totaloptions>3)){

displayedoptions = (totaloptions - 1) + " Toppings";
	$('listprice').innerHTML = "<span style='font-size:13pt;'>&#163;" + ((listprice)+(subtotal*1)).toFixed(2) + " (" + displayedoptions + ") </span>";


}
}else{

	$('listprice').innerHTML = "<span style='font-size:13pt;'>&#163;" + ((listprice)+(subtotal*1)).toFixed(2) +"</span>";

}
 }










window.addEvent('domready', function(){

	   if($('events')){



	$$('#eventsheader','#events').addEvents({
		mouseenter: function(){
				
$('events').set('tween', {}).tween('height','162px');
    
    
    },
		mouseleave: function(){

			$('events').set('tween', {}).tween('height', '25px');
		}
	});


}
});























window.addEvent('domready', function(){

	   if($('vertical_slide')){
	   if($('cartbg')){


	$('vertical_slide').addEvents({
		mouseenter: function(){
				
$('cartbg').set('tween', {}).tween('height','195px');
    
    
    },
		mouseleave: function(){

			$('cartbg').set('tween', {}).tween('height', '0px');
		}
	});

}
}
});

window.addEvent('domready', function(){

	   if($('expand')){
	   if($('expandbg')){


	$$('#expand','#expandbg').addEvents({
		mouseenter: function(){
				
$('expandbg').set('tween', {}).tween('height','60px');

       
    
    },
		mouseleave: function(){

			$('expandbg').set('tween', {}).tween('height', '0px');

		}
	});

}
}
});



window.addEvent('load', function(){
  if($('morphTabs')){
element = $('morphTabs');
var myFx = new Fx.Tween(element);
var mySlide = myFx.start('opacity', '1');
}
})

