$(document).ready(function () {
	InitDocument();

	$(function () {
		$('#slides-poster').slides({
			preload: true,
			generateNextPrev: false,
			effect: 'fade',
			play: 5000,
			pause: 2500,
			hoverPause: true
		});
	});

	$(function () {
		$('#slides-recommend').slides({
			preload: true,
			generateNextPrev: true,
			pagination: false,
			generatePagination: false
		});
	});

	$(function () {
		$('#slides-action').slides({
			preload: true,
			generateNextPrev: true,
			pagination: false,
			generatePagination: false
		});
	});

	$(function () {
		$('#photos').slides({
			preload: true,
			preloadImage: '/templates/public/images/loading.gif',
			effect: 'slide, fade',
			crossfade: true,
			slideSpeed: 350,
			fadeSpeed: 500,
			generateNextPrev: false,
			generatePagination: false
		});
	});


	$(".availability a, .product-left a:not(.basket)").tooltip({
		bodyHandler: function() {
			return $(this).parent().children(".avaiDesc").html();
		},
		showURL: false
	});

	$(".pavailability a").tooltip({
		bodyHandler: function() {
			return $(this).parent().children(".avaiDesc").html();
		},
		showURL: false
	});

	$("#products-rows table.product-table h3.product-name").tooltip({
		bodyHandler: function() {
			return $(this).parent().children(".titleTooltip").html();
		},
		showURL: false
	});

	$("#products h3.product-name").tooltip({
		bodyHandler: function() {
			return $(this).parent().children(".titleTooltip").html();
		},
		showURL: false
	});

	$('.detail a').tooltip({
		delay: 0,
		showURL: false,
		bodyHandler: function () {
			var index = $(this).attr("href").indexOf('#');
			var src = $(this).attr("href").substring(index + 1);
			//return $("&lt;img/&gt;").attr("src", src);
			return "<img src='" + src + "'  width='162' height='120' alt='' />";
		}
	});
});

function InitDocument() {

	Cufon.replace('h1, h2:not(#footer .col .title), h3:not(.product-name), h4, .cufon, #main-menu a', { fontFamily: 'Myriad Pro', hover: true });

	//$('#shortcuts ul li').hover(function(){
	//		Cufon.replace($(this).children('h3'), { fontFamily: 'Myriad Pro', hover: true, color: '#fff' });
	//	},function(){
	//		Cufon.replace($(this).children('h3'), { fontFamily: 'Myriad Pro', hover: true, color: '#EE2D24' });
	//	});

	//$('#main-menu>ul>li').hover(function(){},function(){
	//	  var color = '#3a3a3a';
	//	  if($(this).hasClass('active'))
	//	  {
	//	    color = '#fff';
	//	  }
	//	  Cufon.replace($(this).children('a'), { fontFamily: 'Myriad Pro', hover: true, color: color });
	//	});

	function callback(e) {
		setTimeout(function () {
			$(".effects-transfer").css({ border: "2px dotted #d61600" });
			PostBasket();
		}, 100);
	};

	$(".basket").click(function (e) {
		var options = { to: "#cart", className: 'effects-transfer', easing: 'easeInQuint' };
		$(this).effect("transfer", options, 550, callback);
		return false;
	});
}

function BasketChanged(price, amount) {
	$("#cart #price").html(price);
	$("#cart #amount").html(amount);
	$(".effects-transfer").fadeOut();
}

function AddToBasket(parameters, amountTextBox) {
	$("input[name='cart_amt']:hidden").val($('#' + amountTextBox).val());
	$("input[name='cart_par']:hidden").val(parameters);
	
	return false;
}

