$(document).ready(function() {
	$('.fancy').fancybox();

	$('.buybtn, .buybtn2, .buybtn3').click(function() {
		
		var prod = $(this).parent().find('.prodid');
		if (prod.length > 0) {
			
			var prodid = parseInt(prod.val());
			$.post("/basket/add", { "prodid": prodid, "buy": "buy" },
			 function(data){
				location.href = "/basket";
				return false;
				// if (typeof(data.error) === 'undefined' && typeof(data.id) !== 'undefined' && typeof(data.cost) !== 'undefined') {
					// var itemcount = parseInt($('.cart_cnt').html());
				
					// $('.cart_cnt').html(itemcount + 1);
					// var totalcost = parseInt($('.cart_sum').html());
					// $('.cart_sum').html(parseInt(parseInt(totalcost) + parseInt(data.cost)));
				// }
			   
			 }, "json");
		}
		return false;
	});
	
	$('.authinp').focusout(function() {
		if ($(this).val().length == 0) {
			$(this).val($(this).attr('rel'));
		}
	});
	
	$('.authinp').focusin(function() {
		if ($(this).val() == $(this).attr('rel')) {
			$(this).val('');
		}
	});
	
	
	
	$('.submit_order').click (function () {
		$(".order").submit();
		return false;
	}); 
	
	$('.f_submit input#submit').hover (
		function () {
			$('.f_submit input#submit').css({'text-decoration' : 'underline'});
			$('.f_submit input#submit').css({'background-color' : '#eee'});
		},
		function () {
			$('.f_submit input#submit').css({'text-decoration': 'none'});
			$('.f_submit input#submit').css({'background-color' : '#ccc'});
		}
	);
	
	$('.f_submit input#clear').hover (
		function () {
			$('.f_submit input#clear').css({'text-decoration' : 'underline'});
			$('.f_submit input#clear').css({'background-color' : '#eee'});
		},
		function () {
			$('.f_submit input#clear').css({'text-decoration': 'none'});
			$('.f_submit input#clear').css({'background-color' : '#ccc'});
		}
	);
	
	jQuery('.top1').jcarousel({
		visible: 1,
		scroll: 1,
		auto: 4,
		vertical: true,
		wrap: 'circular',
		initCallback: function(carousel){
			//carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); });
		},
		buttonNextHTML: null,
		buttonPrevHTML: null
	}); 
	
	jQuery('.top2').jcarousel({
		visible: 1,
		scroll: 1,
		auto: 4,
		vertical: true,
		wrap: 'circular',
		initCallback: function(carousel){
			//carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); });
		},
		/*setupCallback: function(carousel) {
			carousel.stopAuto();
			setTimeout(function() { carousel.startAuto(); }, 1000); 
		},*/
		buttonNextHTML: null,
		buttonPrevHTML: null
	}); 
	
	jQuery('.top3').jcarousel({
		visible: 1,
		scroll: 1,
		auto: 4,
		vertical: true,
		wrap: 'circular',
		initCallback: function(carousel){
			//carousel.clip.hover(function() { carousel.stopAuto(); }, function() { carousel.startAuto(); });
		},
		/*setupCallback: function(carousel) {
			carousel.stopAuto();
			setTimeout(function() { carousel.startAuto(); }, 2000); 
		},*/
		buttonNextHTML: null,
		buttonPrevHTML: null
	}); 

});

