$(document).ready(function () {
							
	// slidedown functions						
	$('.slidecontrol').click(function(){
		var $this = $(this);
		var divID = $this.attr("id").replace("slidecontrol_", "slidedisplay_");
		var $div = $('#'+divID);
		if ($div.is(':visible')) {
			$div.slideUp(500);
		} else {
			$div.slideDown(500);
		}
		return false;
	});	
	
	// add prices based on checkbox ticks
	
	$(':checkbox').click(function () {
	var $this = $(this);
	var divID = $this.attr("id");
	if ($this.attr('checked')) {
	divID = parseFloat(divID);
	}
	else divID = parseFloat(0-divID);
	
	// get current total price from hidden field
	totalprice = $( '#hiddentotal').attr('value');
	totalprice = parseFloat(totalprice);
	// adjust
	newtotalprice = (totalprice+divID)
	
	// display new total price
	$( "#pricewithoptions").html(newtotalprice.toFixed(2));
	$( "#hiddentotal").attr('value', newtotalprice.toFixed(2) );
	});
		
		
		
	// validate
	$('.date-pick').datePicker({autoFocusNextInput: true});
	
	$("#orderForm").validate(function() {
		$(".changer").val('Loading...');
		});
	
	$("#orderForm").ajaxForm(function() { 
	$(".bookingform").html("<strong>Thanks for your booking.</strong><br/<br/>A copy of your details has been dispatched to the email address provided.<br/>We will contact you to discuss your booking as soon as possible."); 	
	});

	
	
});




 



function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 6000 );
});


function mySbOpen(){
        var c = Shadowbox.getCurrent();
        var pageLink = c.link.ownerDocument.URL;
        if(pageLink.indexOf('?')>1){
                pageLink = pageLink.split('?')[0]
        }
        var link2image = pageLink+"?the_item="+c.link.shadowboxCacheKey;
        var newDiv = $('<div id="sb-mylink">'+
                                   '<a id="printMe" href="#" title="Print me"><img src="../images/print.png" border="0"></a></div>');
        if($('div#sb-mylink')!=null){
                $('div#sb-mylink').remove();
        }
        newDiv.insertAfter($('div#sb-counter'));
        $('a#printMe').click(function(){
                    var theWork =  window.open('','PrintWindow');
                var html = "<html><head><title>Print An Image</title>";
                        html = html + "<link rel='stylesheet' href='../css/shadowbox.css' type='text/css' /><style>#sb-info{display:none;}div#sb-wrapper{left:20px !important;top:40px !important}</style></head>";
                        html = html + "<body><div id='myprint'>"+$('#sb-container').clone().html()+"</div></body></html>";
                        
                        theWork.document.open();
                        theWork.document.write(html);
                        theWork.document.close();
                        theWork.print();
                        theWork.close()
      return false;
                                                                  
        });
}


