$(document).ready(function () {
	
	$("a#cart-preview-button").click(
		function () {
		$(".cart-preview-overlay").slideDown("fast");
		});
	
	$("a.cart-close-button").click(
		function () {	
		$(".cart-preview-overlay").slideUp("fast");
		});
		
	var searchResult = $('#quickbuyshowmessages').html();
	//alert(searchResult.length);
	if (searchResult != ""){
		$("#quickbuyshowmessages").addClass("quickbuy-padding");
		$("#quickbuy-search-results-messages-head").show();
	
	}else{
		$("#quickbuyshowmessages").removeClass("quickbuy-padding");
		$("#quickbuy-search-results-messages-head").hide();
		
	}
	$("#quickorder-item-number").keyup(function()
	{	
	
		var itemnumber=$($(this)).val();
		var processv=$("#processfolder").val();
		
		$("#quickbuy-search-results-messages-head").show();
		$("#quickbuyshowmessages").html('');
		$("#searchresult").addClass("searchresult-placeholder");/*.activity({segments: 8, steps: 3, opacity: 0.3, width: 4, space: 0, length: 5, padding: 20, speed: 1.5});*/
		
		$.get(processv,{'action':1,'q' : itemnumber,'sh':'header'},
			function(data)
			{
				$("#searchresult").html(data);
				$("#searchresult").addClass('pad-top-bottom');
				$(".selectedautoropdownlist").click(function()
				{
					var element = $(this);
					var Id = element.attr("id");
					var i=Id.substring(18);	
					var result_container = $("#searchresult");
					var content = result_container.find('#span'+i).html();				
					var content = $('#span'+i).html();
					var skucode=content.split(' --');
					$("#quickorder-item-number").val(skucode[0]);
					
				});	
			});
			
			var searchResult = $("#searchresult").html();
			if (searchResult != ""){
					$("#quickbuyshowmessages").removeClass("searchresult-placeholder");/*.activity(false)*/
				}
	});	
	$("#CloseQuickbuy").click(function()
	{
		$("#searchresult").html('');
		$("#quickbuy-search-results-messages-head").hide();
		$("#quickbuyshowmessages").removeClass("quickbuy-padding");
		$("#quickbuyshowmessages").html('');/*.activity(false)*/
	});	
	
	
	
	/*! Main Navigation */

$("#product-list a").click(

	function () {
		/*$("#product-list").children('.sub-sub-category').hide(000);*/
		$(this).addClass("current").children(".drop-side").show("blind","fast");
		var subCat = $(this).children(".sub-sub-category").length; 
		$('ul.drop-side2').hide();
		/*if( subCat > 0){*/
			 $(this).children('.sub-sub-category').show();
		/*}*/
		
	});

$("#product-list").hoverIntent(

	function () {
		$("#product-list").children('.sub-sub-category').hide(000);
		$(this).addClass("current").children(".drop-side").show("blind","fast");
		var subCat = $(this).children(".sub-sub-category").length; 
		$('ul.drop-side2').hide();
		if( subCat > 0){
			 $(this).children('.sub-sub-category').show();
		}
		
	}, function () {
		$(".main-category ul.drop-side li").removeClass("current");
		$(this).removeClass("current");
		$(".drop-side").attr("style", "display: none;");
		$('ul.drop-side2').hide();
		$("#product-list").children('.sub-sub-category').hide(000);
	});
	
	
	
$(".main-category ul.drop-side li").hoverIntent(

	function () {
		var classList =$(this).attr('class').split(/\s+/);
		var categoryClass = classList[0];
		$('.sub-sub-category ul.drop-side2').hide(00);
		$('.sub-sub-category ul.'+categoryClass).show(00);
		$(".main-category ul.drop-side li").delay(2000).removeClass("current");
		$(this).addClass("current");

	}, function () {
		
		

});


});

