/// <reference path="/layout/js/jquery.js" />

var J = jQuery.noConflict();

J(document).ready(function ($) {


	$('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'));
			}
		});
	});

	if ($('body').hasClass('home')) {
		$(document).bgStretcher({
			images: ['/layout/images/pictures/splash-image.jpg'],
			imageWidth: 1200, imageHeight: 771, slideShow: false
		});
	}
	/* Tabs */
	$('.tab-content:first').css('display', 'block');
	$('.tabs LI').click(function () {
		if ($(this).hasClass('active')) {
			return false;
		} else {
			id = $(this).children('A').attr('href');
			$('.tab-content:visible').fadeOut(300, function () {
				$(id).fadeIn(300);
			});
			$('.tabs LI.active').removeClass('active');
			$(this).addClass('active');
			return false;
		}
	});
	/* Product Details */
	$('UL#photo-list LI.current').each(function (i) {
		if (!i) {
			var photoUrl = $(this).children('a').attr('href');
			loadPhoto(photoUrl);
		}
	});

	//	$('.thumnbnails-list 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;
	//	});


});
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);
}

