// JavaScript Document
$(function(){
					 
	/**
		Engraving service
	**/
	
	var max_chars = 9;
	
	$('.input-text').html('');
	$('.engraving-text').val('');
	
	$('.engraving-text').keyup(function(data){
		var text = $(this).val();
		if(text.length <= max_chars){
			$('.input-text').html(text);
		}
	});
	
	/**
		Wish list
	**/
	$(".product-options .add-wish-list").click(function(){
		var url = $(this).attr('href');
		if(url !== "/wishlist/"){
			var product_id = $(this).attr('rel');
			$.get('/wishlist/add/'+product_id+'/', function(){
			});
			$(this).html("View Wish List").attr('href','/wishlist/');
			return false;
		}
	});

	/**
		product page tabs
	**/

	$(".tab-content-item").hide();
	$(".tabs li a:first").addClass('active');
	$(".tab-content-item:first").show();
	
	$(".tabs li a").click(function(){
		$(".tabs li a").removeClass('active');
		$(this).addClass('active');
		var contentDiv = $(this).attr('rel');
		if(contentDiv.length > 0){
			$(".tab-content-item").hide();
			$("."+contentDiv).show();
		}
		return false;
	});
	
	$(".stockname").click(function(){ if($(this).val() == 'Name'){ $(this).val(''); } });
	$(".stockname").blur(function(){if($(this).val() == ''){$(this).val('Name'); } 	});

	$(".stockemail").click(function(){ if($(this).val() == 'Email'){ $(this).val(''); } });
	$(".stockemail").blur(function(){if($(this).val() == ''){$(this).val('Email'); } 	});
	
	$("#view-packaging").click(function(){
		$("#product-360").hide();	
		visible_360 = 0;
	});
	
	$(".product-thumb-image").click(function(){
		$("#product-360").hide();
		visible_360 = 0;
	});
	
	var visible_360 = 0;
	$(".view-360").click(function(){
		if (visible_360 == 0){
			$("#product-360").show();	
			visible_360 = 1;
		} else {
			$("#product-360").hide();	
			visible_360 = 0;
		}
		return false;
	});
		if($('.related-products').length){
			$('.related-products').slide({
				Width: 230,
				Height: 240,
				Offset: 4,
				PrevClass: 'gallery-left',
				NextClass: 'gallery-right',
				Direction: 'horizontal',
				Restart: false,
				Extra: 0,
				Speed: 500
			});
		}		

});

