Cufon.replace("#navigation ul li a", {hover: true});
Cufon.replace("#left h1");
Cufon.replace("#right h3");
Cufon.replace(".data h4");

jQuery(document).ready(function() { 

	/*
	$("#draggable").draggable({
        axis: 'x'
    });
    */
    
	//$('#pagePeel').pagePeel({ adLink: 'http://www.prontoscooter.nl' });
	
	$('#slider-end').click(function() {
		$('div#models').scrollTo('+=201px', {duration:500});
	});
	
	$('#slider-start').click(function() {
		$('div#models').scrollTo('-=201px', {duration:500});
	});

	
	$("select[rel^=option]").change(function() {
		var the_option = $(this).val();
		var the_price = $("#option_"+the_option).attr('rel');
		var the_i = $("#option_"+the_option).attr('class');
		
		$("#option_price_"+the_i).val(the_price);
		
	  	calculate_options();
	  	calculate_total();
	});
	
	$(".cart_quantity").change(function() {
	
		$("#cart").submit();
	
	});
	
	$(".model_swap_image").click(function() {
	
		var new_image = $(this).attr('id');
		
		if(new_image != "") {
		
			$("#model_image").attr('src', new_image);
			$("#model_image_url").attr('href', new_image);
			
		}
		
	});
	
	
	$('.lightbox a').lightBox(); // Select all links that contains lightbox in the attribute rel
	$('.tooltip').tooltip({showURL: false});

});

function calculate_options() {

	$("[id^=option_total_]").calc(
		// the equation to use for the calculation
		"price * quantity",
		// define the variables used in the equation, these can be a jQuery object
		{
			price: $("[id^=option_price_]"),
			quantity: $("[id^=option_quantity_]")
		},
		// define the formatting callback, the results of the calculation are passed to this function
		function (s){
			// return the number as a dollar amount
			return "" + s.toFixed(2);
		},
		// define the finish callback, this runs after the calculation has been complete
		function ($this){
			// sum the total of the $("[id^=total_item]") selector
			var sum = $this.sum();
			
			$("#total_options").val(
				// round the results to 2 digits
				"" + sum.toFixed(2)
			);
		}
	);
	

}

function calculate_total() {

	var grand_total = $("input[id^='total_']").sum()
	
	$("#grandTotal").html("&euro; "+
		grand_total.toFixed(2)

	);

}

var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');
}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#jsddm > li').bind('mouseover', jsddm_open)
   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

document.onclick = jsddm_close;



