$("document").ready(function(){
//alert($("ul li").children().next().html()	);
//var a=document.getElementById("fuck").innerHTML;

// ***************   Hottest Prod 	***************	

if($("#listhottest").length > 0)
{
	
	if ( $.browser.msie ) {
	$("#listhottest #prodcontent").css("margin-top","-74px");


	}
	else
	{
	
$("#listhottest #prodcontent").hide();

$("#listhottest ").mouseenter(function(){
		$("#listhottest #prodcontent").fadeOut("slow");		
	$(this).children("#prodcontent").fadeTo("fast",0.8).fadeIn("slow");
									  
														 
														 
												});
	}

}

// ***************   Hottest Prod 	***************	




// ***************   jM Feature Description 	***************	


if($("#feature-number").length > 0)
{
	$("#slide-list").hide();

	var slide= $("#slide-list #slide-prod")[0] ; 
	$("#feature-number #slide-show").html(slide);



		
	$("#slidwshown").bind("click",function(){
										   
	
	var data=$("#slide-show").html(); 
	
		$("#slide-list").append(data);	
		
	var slide=	$("#slide-list #slide-prod")[0] ; 
		$("#slide-show").html(slide).children('#slide-prod').hide();
		$("#slide-show #slide-prod").fadeIn("slow");
		
	
										  
										  });
	$("#slidwshowb").bind("click",function(){
					   
	var numslide=$("#slide-list #slide-prod").size();
	var slide=	$("#slide-list #slide-prod")[numslide-1]; 
	var data= $("#slide-show").html(); 
		$("#slide-list").prepend(data);								  
		$("#slide-show").html(slide).children('#slide-prod').hide();						  
		$("#slide-show #slide-prod").fadeIn("slow");					  
										  
										  });
}



// ***************   jM Feature Description 	***************	



// ***************   jM Feature Image 	***************	


if($("#feature-img").length > 0)
{
	$("#slide-list-img").hide();
	var slide= $("#slide-list-img a")[0] ; 
	$("#slide-show-img").html(slide);
	
	$("#feature-img #slidwshowb").css({
						position:'absolute',
	
						left:$("#slide-show-img").offset().left + 'px',												
						top:$("#slide-show-img").offset().top+ $("#slide-show-img").height()/3 + 'px'
	
									});
	$("#feature-img #slidwshown").css({
						position:'absolute',
	
						left:$("#slide-show-img").offset().left + $("#slide-show-img a").width() - 55 + 'px',												
						top:$("#slide-show-img").offset().top+ $("#slide-show-img").height()/3 + 'px'
						
									});
	

		
	$("#slidwshown").bind("click",function(){
										   
	
	var data=$("#slide-show-img").html(); 
	
		$("#slide-list-img").append(data);	
		
	var slide=	$("#slide-list-img a")[0] ; 
		$("#slide-show-img").html(slide).children('a').hide();
		$("#slide-show-img a").fadeIn("slow");
		
	
										  
										  });
	$("#slidwshowb").bind("click",function(){
					   
	var numslide=$("#slide-list-img a").size();
	var slide=	$("#slide-list-img a")[numslide-1]; 
	var data= $("#slide-show-img").html(); 
		$("#slide-list-img").prepend(data);								  
		$("#slide-show-img").html(slide).children('a').hide();						  
		$("#slide-show-img a").fadeIn("slow");					  
										  
										  });
}



// ***************   jM Feature Image 	***************	


// ***************   jM Menu 	***************		

	
if($("#jm-menu-vertical").length > 0)
{
	
	$("#jm-menu-vertical ul li").children().next().hide();
	
	$("#jm-menu-vertical ul li").bind("mouseover",function(){
	//alert($(this).parent().height()	);		
	
	$(this).children().next().css({
									   
		position:'absolute',
		left: $(this).offset().left  + 'px',
		top: $(this).offset().top + $(this).parent().height()-10 + 'px',
		width:	$(this).width() + 40+  'px'						   
									   
						   });	
	$(this).children().next().children().children().next().css({
									   
		position:'absolute',
		left: $(this).width() + $(this).children().offset().left - 40  + 'px',
		top: '4px',
		width:	  $(this).width() + 40+  'px'							   
									   
						  									 });	

	$(this).children().next().show();								
												  			});
	
	$("#jm-menu-vertical ul li").bind("mouseout",function(){

	$(this).children().next().hide();												 
	 
														 });

}




if($("#jm-menu").length > 0)
{
	
	$("#jm-menu ul li").children().next().hide();
	
	$("#jm-menu ul li").bind("mouseover",function(){
	//alert($(this).width()	);							  
	$(this).children().next().css({
									   

		left: $(this).width() + $(this).children().offset().left  + 'px',
		top: $(this).offset().top + 5 + 'px',
		width:	'100%'						   
									   
						   });	
	$(this).children().next().children().children().next().css({
									   

		left: $(this).width() + $(this).children().offset().left - 40  + 'px',
		top: '4px',
		width:	  $(this).width() + 40+  'px'							   
									   
						   });	
	
	$(this).children().css({
	color:'#333'
	});	
	
	$(this).children().next().show();								
												  });
	
	$("#jm-menu ul li").bind("mouseout",function(){
	$(this).children().css({
	color:'#666'
	 });
	$(this).children().next().hide();												 
										 
												 
												 });
	$("#jm-menu ul li ul li").bind("mouseout",function(){
		
	$(this).children().css({
	color:'#666'
	 });
											 
										 
												 
												 });
}
// ***************   jM Menu 	***************		

//alert($("#jm-menu ul li").children().html()	);
$("#description-left").css("height",$("#image-left").height());	
//alert($("#boxform").height());
//$("#boxform").css("height",$("#boxform").height());	

// ***************   Fancybox 	***************		
$("a#image-fan").fancybox();
// ***************   Fancybox 	***************		


$("#list-img ul li").bind("mouseover",function(){
//alert($(this).children('a').attr("href"));											   
$("#showed-img a").attr("href",$(this).children('a').attr("href"));
$("#showed-img img").attr("src",$(this).children('a').attr("href"));

											   });							 
$("#image-fan").bind("click",function(){
		
$('#showed-img a').trigger('click');		
									   
									   });						 
$(".listprod .contentprod").hide();							 
$(".listprod").mouseenter(function(){
//$(this).children().next().next().css("display","block");		
$(".listprod .contentprod").fadeOut("fast");
$(this).children().next().next().fadeIn("fast");
				
										 })
//alert($("#showproduct #content").height());

$('#searchitem').bind('click', function() {
							
		url = $('base').attr('href') + 'index.php?route=product/search';
				 
		var filter_name = $('input[name=\'filter_name\']').attr('value')
		
		if (filter_name) {
			url += '&filter_name=' + encodeURIComponent(filter_name);
		}
		
		location = url;
	});
$('#formsearch input[name=\'filter_name\']').keydown(function(e) {
		if (e.keyCode == 13) {
			url = $('base').attr('href') + 'index.php?route=product/search';
			 
			var filter_name = $('input[name=\'filter_name\']').attr('value')
			
			if (filter_name) {
				url += '&filter_name=' + encodeURIComponent(filter_name);
			}
			
			location = url;
		}
	});
							 });

function addToCart(product_id) {
	$.ajax({
		url: 'index.php?route=checkout/cart/update',
		type: 'post',
		data: 'product_id=' + product_id,
		dataType: 'json',
		success: function(json) {

			if (json['redirect']) {
				location = json['redirect'];
			}
		
			if (json['success']) {
	
				
				$('#totalitem').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
}

function addToWishList(product_id) {
	$.ajax({
		url: 'index.php?route=account/wishlist/update',
		type: 'post',
		data: 'product_id=' + product_id,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information').remove();
						
			if (json['success']) {
				
				$('#wishlist_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 				
			}	
		}
	});
}

function addToCompare(product_id) { 
	$.ajax({
		url: 'index.php?route=product/compare/update',
		type: 'post',
		data: 'product_id=' + product_id,
		dataType: 'json',
		success: function(json) {
			$('.success, .warning, .attention, .information').remove();
						
			if (json['success']) {

				
				$('#compare_total').html(json['total']);
				
				$('html, body').animate({ scrollTop: 0 }, 'slow'); 
			}	
		}
	});
}

