var page = window.location.toString();

if(page.substring(7,10).toLowerCase()!="www") {
    window.location = "http://www."+page.substring(7,page.length);
}

$(document).ready(function(){
						   
	$("#slideshow_orange_link").click(function(event){
	 	slideSwitch("image_orange");
	});
	
	$("#slideshow_blue_link").click(function(event){
	 	slideSwitch("image_blue");
	});
	
	$("#slideshow_white_link").click(function(event){
	 	slideSwitch("image_white");
	});
	
});


function slideSwitch(imageId) {
 
 	var $active = $('#slideshow IMG.active');
	
	if ($active.attr('id') == imageId) {
		clearInterval(intervalId);
		return;	
	}

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

	var $next;

 	if (typeof(imageId) != 'undefined') {
		clearInterval(intervalId);
		$next = $('#'+imageId);	
	} else {	
		// use this to pull the images in the order they appear in the markup
		$next =  $active.next().length ? $active.next()
			: $('#slideshow IMG:first');
	}
	
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1500, function() {
            $active.removeClass('active last-active');
        });
		
	$('#slideshow_caption_wrapper').animate({
		top: '448px'
	},{ 
		duration: 750,
		complete: function() {
			$('.caption_active').addClass('caption_inactive').removeClass('caption_active');
			$('#caption_'+$next.attr('id').substring(6)).addClass('caption_active').removeClass('caption_inactive');					
		}
	});	
		
	$('#slideshow_caption_wrapper').animate({
		top: '365px'
	},{ 
		duration: 750
	});	
	
	
}

$(function() {
   intervalId = setInterval( "slideSwitch()", 10000 );
});

