$(document).ready(function(){
	$('UL#photo-list LI.current').each(function(i){
		if(!i){
			var photoUrl = $(this).children('a').attr('href');
			loadPhoto( photoUrl );
		}
	});
	$('.thumbs A').click(function(){
		$('UL#photo-list LI').removeClass('current');
		$(this).parent('LI').addClass('current');
		var photoUrl = $(this).attr('href');
			$('#photo-preview').fadeOut(300, function(){
				loadPhoto( photoUrl );
			});	
			$('#photo-preview').fadeIn(300);
		return false;
	});

    $('INPUT.auto-hint').each(function(i, el){
        if($(this).val() == ''){
            $(this).val($(this).attr('title'));
        }
        $(el).focus(function(){
            if ($(this).val() == $(this).attr('title')) {
                $(this).val('');
            }       
        });
        $(el).blur(function(){
            if ($(this).val() == '') {
                $(this).val($(this).attr('title'));
            }
        });
    });
    
    $(".content-tab:first").css("display","block");
	$("div.tabs LI").click(function(){
		id = $(this).children('A').attr('href');
		$(".content-tab:visible").css("display", "none");
		$(id).css("display","block");	
	
		$("div.tabs LI.active").removeClass('active');
		$(this).addClass('active');
		return false;
	});	
	
	$('.products UL LI A.product-link').hover(function(){
		var bigImgLink = $(this).attr('href');
		var botText = $(this).find('span.name').html();
		var botPrice = $(this).find('span.price').html();
		$('#product-show').find('img').attr('src', bigImgLink);
		$('#product-show').find('span.name').html(botText);
		$('#product-show').find('span.price').html(botPrice);
	});
	
	$(document).bgStretcher({
	images: ['/layout/images/home/1.jpg', '/layout/images/home/2.jpg', '/layout/images/home/3.jpg'],
		imageWidth: 1258, imageHeight: 891
	});	
});

function loadPhoto(url){
	if(url == ''){ return; }
	var photo = new Image();
	$(photo).load(function(){
		$('#photo-preview').removeClass('loading').html('').append(this);
	}).attr('src', url); 
}
