function slideSwitch() {
    var $active = $('#slideshow2 IMG.active');
 
    if ( $active.length == 0 ) $active = $('#slideshow2 IMG:last');
 
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow2 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()", 5000 );
});

if(window.jQuery){jQuery(function(){
	
	var $tabs = $("#tabs").tabs();
								  
	jQuery('a.tellAFriendLink').bind('click', function(event, ui){var target = jQuery('div#tellAFriendSlider'); target.toggle('slide', { direction: 'down' }, 0)});
	jQuery('a.vehicleEnquiryLink').bind('click', function(event, ui){var target = jQuery('div#vehicleEnquirySlider'); target.toggle('slide', { direction: 'down' }, 0)});
	jQuery('a.testDriveLink').bind('click', function(event, ui){var target = jQuery('div#testDriveSlider'); target.toggle('slide', { direction: 'down' }, 0)});
	
	jQuery('a#tab1').bind('click', function(event, ui){setCookie('openTab', 1, 1)});
	jQuery('a#tab2').bind('click', function(event, ui){setCookie('openTab', 2, 1)});
	jQuery('a#tab3').bind('click', function(event, ui){setCookie('openTab', 3, 1)});
	jQuery('a#tab4').bind('click', function(event, ui){setCookie('openTab', 4, 1)});
	jQuery('a#tab5').bind('click', function(event, ui){setCookie('openTab', 5, 1)});
	jQuery('a#tab6').bind('click', function(event, ui){setCookie('openTab', 6, 1)});
	
})};
