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

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

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