// JavaScript Document

$(document).ready(function() {
	//$('.introimg').hide();		//											 	 	
	$('#gallery').fadeIn('slow');
	$('#main_image img').fadeIn('slow');		   				   		   
	$('#main_image h1').fadeIn('slow');
	$(".slideit").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
		circular: true,
		visible: 15,
		scroll: 5,
		//auto: 2000,
		speed: 500
    });
	
	//$('.introimg').fadeIn('slow');		//
	$('#load').hide();

	// fade out inactive thumbnails
	$('ul#gallery li.active').siblings().css({display:'none',opacity:'0.6'}).fadeIn(500);
	
	// thumbnails hover effects
	$('ul#gallery li').hover(function() {
			$(this).not('.active').fadeTo('fast',1);
			$(this).not('.active').css('position', 'relative').css('left', 0).css('top', 0); // Fixes Safari 2 rendering issue
		}, function() {
			$(this).not('.active').fadeTo('fast',0.6);
		}
	);
		
	$(document).keydown(function(e) {
		var code = (e.keyCode ? e.keyCode : e.which);
	
		switch(code) {
			case 37: $(".prev").trigger("click"); break; // left
			case 39: $(".next").trigger("click"); break; // right
		}
	});



// fade in default image
	$('ul#gallery li').click(function() {	
		var img = $(this).children('a').attr('href');
		$('.default').fadeOut('fast');
		$('#load').fadeIn('fast').show();
		// fade out and remove active classes on all other thumbnails								 
		$(this).siblings().removeClass('active').fadeTo('fast',0.4);	
		// set class for clicked thumbnail to active
		$(this).addClass('active')
		// get image source reference from the thumbnail link and store in a variable
		//$('#load').html('<img src="/assets/img/loading.gif" />').fadeIn(800);
		$('#main_image').html('<img src="/assets/img/loading.gif" border="0" class="noborderman" />').fadeTo(800, 1);
		//	$('#main_image').fadeIn(800, function() {
			$('#main_image').load("imageloader.asp?" + img).slideDown('slow');
		//$('#main_image').html('<img src="/assets/img/loading.gif" />').fadeTo(800);
		});
	//});
	//$("a[rel='orderphoto']").colorbox({width:"80%", height:"80%", iframe:true});//
});




