/*//////////////////////////////////////////////////////////////////////////////////////////
	Global Variables
//////////////////////////////////////////////////////////////////////////////////////////*/

	var debug = false;
	var floatingInfoAutoHide = true;
	var cartAutoHide = true;


/*//////////////////////////////////////////////////////////////////////////////////////////

	Utils
	
//////////////////////////////////////////////////////////////////////////////////////////*/

	function getUrlHash()
	{
		return $(location).attr('href').split('#')[1];
	}

	var traceCurrentLine = 1;
	function trace(content){

		$('#trace').append("<p>"+traceCurrentLine+"|"+content+"</p>");
		$("#trace-wrapper").scrollTop($("#trace")[0].scrollHeight);
		traceCurrentLine++;
		
	}

	function scrollPageTo(id){
		//alert("scrollPageTo "+id);
		
		$target = $(id);
		var targetOffset = $target.offset().top;
		$('html,body').stop();
		$('html,body').animate(
			{
				scrollTop: targetOffset
			},
			700,
			"easeOutQuint",
			function(){
				//Animation complete
				//location.href = id;	
			}
		);
		
	}


/*//////////////////////////////////////////////////////////////////////////////////////////

	Functions
	
//////////////////////////////////////////////////////////////////////////////////////////*/
	
	
	$(document).ready(function(){
		readyHandler()
	});
	
	
	function readyHandler()
	{

		if(debug) $('#trace-wrapper').css('display', 'block');
		
		initFooter();
		initShoppingSteps();
		initShoppingCart(true);
		initFloatingInfo();
		InputNumberIncrementable();
		//initDropDownList();
		//initCategoriesDropDown();
		
		$('ul.sf-menu').superfish();
		
		$('.dropdown-list ul li a').append('<div class="clearboth"></div>');
		
	}
	
	function initFooter()
	{
		$('#footer .footer-beneficios ul li a').click(function(){
			showClaimDesc($(this));
			return false;
		});
		
		$('.footer-content-wrapper-close').click(function(){
			hideClaimDesc();
			return false;
		});
	}
	
	function showClaimDesc(claim){
		var ind = claim.attr("id").substring(('claim-').length, claim.attr("id").length);
		
		$('#footer .footer-beneficios ul li a').removeClass('current');
		claim.addClass('current');
		
		$('#footer .footer-content-wrapper .beneficio-desc').removeClass('current');
		$('#footer .footer-content-wrapper').addClass('open');
		$('#footer .footer-content-wrapper #beneficio-desc-'+ind+'.beneficio-desc').addClass('current');
		
		scrollPageTo('#footer');
	}

	function hideClaimDesc(ind){
		$('html,body').stop();
		$('#footer .footer-beneficios ul li a').removeClass('current');
		$('#footer .footer-content-wrapper').removeClass('open');
	}

	function initShoppingSteps()
	{
		// Set Background according to the current step
		//$('#shopping-steps').addClass('step_'+step);
		
		// Set the current step as active
		$('li#'+step).addClass('current');
		
		// Set the actions for the non-current steps
		$('#shopping-steps li:not(.current)').click(function(){
			//window.location = '?step='+$(this).attr('id');
			//window.location = $(this).attr("href");
			//return false;
		});
		
		// Remove default steps link
		//$('#shopping-steps li a').removeAttr("href");
		
	}


		
	/*//////////////////////////////////////////////////////////////////////////////////////////
	
		DropDownList
		
	//////////////////////////////////////////////////////////////////////////////////////////*/
	
	function initDropDownList()
	{
		$('.dropdown-list a.dropdown-button').mouseenter(function(){
			openDropDownList($(this).parent().attr("id"));
		});
		
		$('.dropdown-list').mouseleave(function(){
			closeDropDownList($(this).attr("id"));
		});
		
		$('.dropdown-list').each(function(){
			setDropDownListSize($(this).attr("id"));
		});
	}
	
	function setDropDownListSize(id)
	{
		
		var dropDownWidth;
		
		if($('#'+id).hasClass('top-rounded')){
			dropDownWidth = $('#'+id+' a.dropdown').outerWidth();
			$('#'+id+' .dropdown-list-ul-wrapper').css('width', $('#'+id).outerWidth()+'px');
		}else{
			dropDownWidth = $('#'+id).outerWidth();
		}
		
		
		var dropDownHeight = $('#'+id+' a.dropdown').outerHeight();
		if(id=="header-customer-dropdown-list"){
			trace('hola');
			trace($('#'+id+' a.dropdown').outerWidth() +" - "+ $('#'+id).outerWidth());
		}
		
		
		$('#'+id).parent().css('width', dropDownWidth+"px");
		$('#'+id).parent().css('height', dropDownHeight+"px");
		
	}
	function openDropDownList(id)
	{
		if(id && !$('#'+id+'.dropdown-list').hasClass('open')){
			
			$('#'+id+'.dropdown-list').addClass('open');
			$('#'+id+'.dropdown-list a.dropdown-button').addClass('hover');
			var UL = $('#'+id+'.dropdown-list ul');
			
			UL.css('height', 'auto');
			var newHeight = UL.height();
			UL.css('height', '0px');
			
			UL.stop();
			UL.animate(
				{
					height: newHeight+'px'
				},
				200,
				"easeOutQuad",
				function(){
					//trace("Open complete");
				}
			);
		}
	}

	function closeDropDownList(id)
	{
		if(id){
			var UL = $('#'+id+'.dropdown-list ul');
			var newHeight = 0;
			
			UL.stop();
			UL.animate(
				{
					height: newHeight+'px'
				},
				200,
				"easeOutQuad",
				function(){
					//trace("Close complete");
					$('#'+id+'.dropdown-list').removeClass('open');
					$('#'+id+'.dropdown-list a.dropdown-button').removeClass('hover');
				}
			);
		}
	}
	
	function initCategoriesDropDown()
	{
		/*
		$('.header-menu-dropdown-list-dropdown').click(function(){
			$('.header-menu-dropdown-list').hasClass('open') ? hideCategoriesDropDown() : showCategoriesDropDown();
		});
		
		$('.header-menu-dropdown-list').mouseenter(function(){
			showCategoriesDropDown();
		});
		
		$('.header-menu-dropdown-list').mouseleave(function(){
			hideCategoriesDropDown();
		});
		*/
		
		$('.dropdown-list-wrapper a.rounded-button.dropdown').click(function(){
			//$('.dropdown-list-wrapper').hasClass('open') ? hideCategoriesDropDown() : showCategoriesDropDown();
		});
		
		$('.dropdown-list-wrapper').mouseenter(function(){
			showCategoriesDropDown();
		});
		
		$('.dropdown-list-wrapper').mouseleave(function(){
			hideCategoriesDropDown();
		});
	}
	
	function showCategoriesDropDown()
	{
		//$('.dropdown-list-wrapper').addClass('open');
		
		$('.dropdown-list-wrapper ul').css('display', 'block');
		
		$('.dropdown-list-wrapper ul').css('width', 'auto');
		var newWidth = $('.dropdown-list-wrapper ul').width();
		$('.dropdown-list-wrapper ul').css('width', '0px');
		
		$('.dropdown-list-wrapper ul').stop();
		$('.dropdown-list-wrapper ul').animate(
			{
				width: newWidth+'px'
			},
			200,
			"easeOutQuad",
			function(){
				//trace("Show complete");
			}
		);

		/*
		$('.header-menu-dropdown-list').addClass('open');
		
		if($('.header-menu-dropdown-list').outerWidth() < $('.header-menu-dropdown-list ul').outerWidth()){
			var newLeft = $('.header-menu-dropdown-list').position().left+$('.header-menu-dropdown-list').outerWidth()-$('.header-menu-dropdown-list ul').outerWidth();
			$('.header-menu-dropdown-list ul').css('left', newLeft+'px');
			$('.header-menu-dropdown-list ul li a span').css('text-align', 'right');
		}
		*/
	}

	function hideCategoriesDropDown()
	{
		//$('.dropdown-list-wrapper').removeClass('open');

		$('.dropdown-list-wrapper ul').stop();
		$('.dropdown-list-wrapper ul').animate(
			{
				width: "0px"
			},
			200,
			"easeOutQuad",
			function(){
				//trace("Hide complete");
				$('.dropdown-list-wrapper ul').css('display', 'none');
			}
		);
		
		/*
		$('.header-menu-dropdown-list').removeClass('open');
		*/
		
	}


	
	/*//////////////////////////////////////////////////////////////////////////////////////////
	
		Text Input
		
	//////////////////////////////////////////////////////////////////////////////////////////*/
	
	
	function initTextInput(input, isPassword)
	{
		//trace("initTextInput "+input);
		input.each(function(){
			if(input.val()==""){
				setDefaultTextInput($(this).attr('id'), $(this).attr('title'), $(this).attr('type')=='password');
			}else{
				removeDefaultTextInput($(this).attr('id'), $(this).attr('type')=='password');
			}
		});
		
		input.focus(function(){
			if($(this).attr('type')!='password'){
				removeDefaultTextInput($(this).attr('id'), $(this).attr('type')=='password');
			}
		});
		
		input.focusout(function(){
			if($(this).val()==""){
				setDefaultTextInput($(this).attr('id'), $(this).attr('title'), $(this).attr('type')=='password');
			}
		});

		
		
		dummyInput = $('#'+input.attr('id')+'-default-text');
		
		dummyInput.each(function(){
			setDefaultTextInput($(this).attr('id'), $(this).attr('title'));
		});
		
		dummyInput.focus(function(){
			removeDefaultTextInput(input.attr('id'), true);
		});
		
		dummyInput.focusout(function(){
			if($(this).val()==""){
				//setDefaultTextInput(input.attr('id'), $(this).attr('title'), true);
			}
		});

	}
	
	function removeDefaultTextInput(id, isPassword)
	{
		var input = $('#'+id);
		
		if(!isPassword){
			if(input.hasClass('default-input-value')){
				setDefaultTextInput(input.attr('id'), "");
				input.removeClass('default-input-value');
			}
		}else{
			// Show Password Input
			dummyInput = $('#'+input.attr('id')+'-default-text');
			dummyInput.css('display', 'none');
			input.css('display', 'block');
			input.focus();
		}
	}
	
	function setDefaultTextInput(id, value, isPassword)
	{
		var input = $('#'+id);
		
		if(!isPassword){
			input.addClass('default-input-value');
			input.val(value);
		}else{
			// Show Dummy Text
			dummyInput = $('#'+input.attr('id')+'-default-text');
			dummyInput.css('display', 'block');
			input.css('display', 'none');
		}
	}
	
	
	
	/*//////////////////////////////////////////////////////////////////////////////////////////
	
		Floating Info
		
	//////////////////////////////////////////////////////////////////////////////////////////*/
	
	
	function initFloatingInfo()
	{
		//trace("initFloatingInfo");

		//$('.featured-product-info').css('display', 'none');
		
		
		$('.featured-product-dummy').mouseenter(function(){
			if($(this).parent().hasClass('hidden')) showFloatingInfo($(this).parent().attr("id"));
		});
		
		$('.featured-product').mouseleave(function(){
			showFloatingInfo($(this).attr("id"), true);
		});
		
		$('.featured-category').mouseenter(function(){
			if($(this).hasClass('hidden')) showCategoryFloatingInfo($(this).attr("id"));
		});
		
		$('.featured-category').mouseleave(function(){
			showCategoryFloatingInfo($(this).attr("id"), true);
		});
		
		$('.featured-panoramic-button').mouseenter(function(){
			if($(this).hasClass('hidden')) showPanoramicButtonFloatingInfo($(this).attr("id"));
		});
		
		$('.featured-panoramic-button').mouseleave(function(){
			showPanoramicButtonFloatingInfo($(this).attr("id"), true);
		});
		
		/*
		$('.featured-product').each(function(){
			showFloatingInfo($(this).attr("id"));
			if(floatingInfoAutoHide == true) showFloatingInfo($(this).attr("id"), true);
		});
		*/
		
	}
	
	function showCategoryFloatingInfo(id, hide){
		//trace("showCategoryFloatingInfo "+hide);
		
		var panoramicWidth = $('#panoramica-wrapper').width();
		var panoramicHeight = $('#panoramica-wrapper').height();
		
		var category = $("#"+id);
		category.css('z-index', '320');	
		if(hide) {
			
			if(floatingInfoAutoHide == true){
			
				// HIDE THE INFO
				category.css('z-index', '320');
				category.removeClass('shown').addClass('hidden');
			}
			
		}else{
			
			
			category.removeClass('hidden').addClass('shown');

			// PUT ON TOP
			category.css('z-index', '320');
			
		}
		
	}
	
	function showPanoramicButtonFloatingInfo(id, hide){
		//trace("showPanoramicButtonFloatingInfo "+hide);
		
		var panoramicWidth = $('#panoramica-wrapper').width();
		var panoramicHeight = $('#panoramica-wrapper').height();
		
		var panoramic_button = $("#"+id);
		var productDummy = $("#"+id+" .featured-panoramic-button-button");
		var productInfo = $("#"+id+" .featured-product-info");
				
		if(hide) {
			
			if(floatingInfoAutoHide == true){
			
				
			
				// HIDE THE INFO
				
				//productInfo.css('display', 'none');
				var productDummyWidth = productDummy.outerWidth();
				var productDummyHeight = productDummy.outerHeight();
				
				panoramic_button.css('z-index', '319');
				/*
				productArea.css('top', 0);
				productArea.css('left', 0);
				productArea.css('width', productDummyWidth+'px');
				productArea.css('height', productDummyHeight+'px');
				*/
				
				if(productInfo.length > 0){
					productInfo.stop();
					productInfo.animate(
						{
							opacity: 0
						},
						200,
						"easeOutQuint",
						function(){
							//trace("Hide complete");
							//productInfo.css('top', '0px');
							//productInfo.css('left', '0px');
							productInfo.css('display', 'none');
							panoramic_button.removeClass('shown');
							panoramic_button.addClass('hidden');
						}
					);
				}else{
					// HIDE THE INFO
					panoramic_button.css('z-index', '319');
					panoramic_button.removeClass('shown').addClass('hidden');
				}
			}
			
		}else{
			
			
			panoramic_button.removeClass('hidden').addClass('shown');

			// PUT ON TOP
			panoramic_button.css('z-index', '320');


			// SET INFO POSITION
			var margin = 0;
			var productTop = panoramic_button.position().top;
			var productLeft = panoramic_button.position().left;
			var productWidth = panoramic_button.outerWidth();
			var productHeight = panoramic_button.outerHeight();
			var productDummyWidth = productDummy.outerWidth();
			var productDummyHeight = productDummy.outerHeight();
			var productInfoWidth = productInfo.outerWidth();
			var productInfoHeight = productInfo.outerHeight();
			
			var productInfoTop = 0;
			productInfoTop = Math.min(Math.max(productInfoTop, -productTop+margin), panoramicHeight-productTop-productInfoHeight-margin);
			
			// Set to the right
			var productInfoLeft = productDummyWidth+margin;
			productInfoLeft = Math.min(Math.max(productInfoLeft, -productLeft), panoramicWidth-productLeft-productInfoWidth-margin);
	
			if(productDummyWidth+margin>productInfoLeft){
				// Info superpuesta al producto --> Set to the left
				var productInfoLeft = -margin-productInfoWidth;
			}
	
			productInfo.css('top', Number(productInfoTop+5)+'px');
			productInfo.css('left', productInfoLeft+'px');
	
	
			if(floatingInfoAutoHide == true){


				productInfo.css('display', 'block');
	
				// SET ACTIVE ZONE POSITION AND SIZE
				
				var productAreaTop = Math.min(0, productInfoTop);
				var productAreaLeft = Math.min(0, productInfoLeft);
				var productAreaWidth = productInfoWidth+productDummyWidth+margin;
				var productAreaHeight = Math.max(productInfoHeight, (productInfoHeight+productInfoTop));
				
	
				// SHOW IT!
				
				productInfo.stop();
				productInfo.animate(
					{
						opacity: 1,
						top: productInfoTop+'px'
					},
					500,
					"easeOutQuint",
					function(){
						//trace("Show complete");
					}
				);
			}			
		}
		
	}
	
	
	function showFloatingInfo(id, hide){
		//trace("showFloatingInfo "+hide);
		
		var panoramicWidth = $('#panoramica-wrapper').width();
		var panoramicHeight = $('#panoramica-wrapper').height();
		
		var product = $("#"+id);
		var productArea = $("#"+id+" .featured-product-area");
		var productDummy = $("#"+id+" .featured-product-dummy");
		var productInfo = $("#"+id+" .featured-product-info");
		
		if(hide) {
			
			if(floatingInfoAutoHide == true){
			
				// HIDE THE INFO
				
				//productInfo.css('display', 'none');
				var productDummyWidth = productDummy.outerWidth();
				var productDummyHeight = productDummy.outerHeight();
				
				product.css('z-index', '0');
				productArea.css('top', 0);
				productArea.css('left', 0);
				productArea.css('width', productDummyWidth+'px');
				productArea.css('height', productDummyHeight+'px');
					
				productInfo.stop();
				productInfo.animate(
					{
						opacity: 0
					},
					200,
					"easeOutQuint",
					function(){
						//trace("Hide complete");
						//productInfo.css('top', '0px');
						//productInfo.css('left', '0px');
						productInfo.css('display', 'none');
						product.removeClass('shown');
						product.addClass('hidden');
					}
				);
			}
			
		}else{
			
			
			product.removeClass('hidden');
			product.addClass('shown');

			// PUT ON TOP
			product.css('z-index', '100');
			
			
			// SET INFO POSITION
			var margin = 0;
			var productTop = product.position().top;
			var productLeft = product.position().left;
			var productWidth = product.outerWidth();
			var productHeight = product.outerHeight();
			var productDummyWidth = productDummy.outerWidth();
			var productDummyHeight = productDummy.outerHeight();
			var productInfoWidth = productInfo.outerWidth();
			var productInfoHeight = productInfo.outerHeight();
			
			var productInfoTop = -20;
			productInfoTop = Math.min(Math.max(productInfoTop, -productTop+margin), panoramicHeight-productTop-productInfoHeight-margin);
			
			// Set to the right
			var productInfoLeft = productDummyWidth+margin;
			productInfoLeft = Math.min(Math.max(productInfoLeft, -productLeft), panoramicWidth-productLeft-productInfoWidth-margin);
	
			if(productDummyWidth+margin>productInfoLeft){
				// Info superpuesta al producto --> Set to the left
				var productInfoLeft = -margin-productInfoWidth;
			}
	
			productInfo.css('top', Number(productInfoTop+5)+'px');
			productInfo.css('left', productInfoLeft+'px');
	
	
			if(floatingInfoAutoHide == true){


				productInfo.css('display', 'block');
	
				// SET ACTIVE ZONE POSITION AND SIZE
				
				var productAreaTop = Math.min(0, productInfoTop);
				var productAreaLeft = Math.min(0, productInfoLeft);
				var productAreaWidth = productInfoWidth+productDummyWidth+margin;
				var productAreaHeight = Math.max(productInfoHeight, (productInfoHeight+productInfoTop));
				
				productArea.css('top', productAreaTop+'px');
				productArea.css('left', productAreaLeft+'px');
				productArea.css('width', productAreaWidth+'px');
				productArea.css('height', productAreaHeight+'px');
			
	
				// SHOW IT!
				
				productInfo.stop();
				productInfo.animate(
					{
						opacity: 1,
						top: productInfoTop+'px'
					},
					500,
					"easeOutQuint",
					function(){
						//trace("Show complete");
					}
				);
			}

		}
		
	}

		
	
	/*//////////////////////////////////////////////////////////////////////////////////////////
	
		Shopping Cart
		
	//////////////////////////////////////////////////////////////////////////////////////////*/
	
	var cartItemHeight = 94;
	var maxCartItems = 2;
	var currentCartPosition = 0;
	var cartScrollTime = 400;
	var cartScrollEase = "easeOutQuint";
	var cartState = "shown";


	function initShoppingCart(isFirstTime)
	{
		if(isFirstTime) {
		
			if(cartAutoHide){
				$(document).unbind('click');
				$(document).click(function(e) {
					if($(e.target).parents().index($('#column_left')) == -1 && !$(e.target).parents('.add_to_cart').hasClass('add_to_cart') && (cartState=="showing" || cartState=="shown") ) {
						hideShoppingCart(true);
					}
				});
			}
			
			
			// Hide column left on start
			
			if(cartAutoHide){
				hideShoppingCart();
				$('.module-cart-tear').css('display', 'block');
			}else{
				showShoppingCart();
				$('.module-cart-tear').css('display', 'none');
			}
	
	
	
			// Roll Over / Roll Out / Click --> Show / Hide
			
			$('.common-home #shopping-steps li#1.current a.step').unbind('click');
			$('.common-home #shopping-steps li#1.current a.step').click(function(){
				if((cartState=="showing" || cartState=="shown")){
					hideShoppingCart(true);
				}else{
					showShoppingCart(true);
				}
				
				return false;
			});
	
			$('.module-cart-tear').unbind('click');
			$('.module-cart-tear').click(function(){
				if(cartState != 'shown'){
					showShoppingCart(true);
				}else{
					hideShoppingCart(true);
				}
				
			});
			
		}
		
		/*
		$('#shopping-steps li#1').mouseenter(function(){
			if(cartState != "hidden") showShoppingCart(true);
		});
		
		$('#shopping-steps li#1').mouseleave(function(){
			if(cartState != "hidden") hideShoppingCart(true);
		});
		*/
		
		var advanced_scrolling = true;
		if($.browser.version == "7.0" || $.browser.version == "6.0"){
			advanced_scrolling = false;
		}
		
		
		if(advanced_scrolling){
			
			// Arrows & Scroll
			
			// Remove Scroll & Resize Column Left since scroll is no longer needed
			//$('#column_left').css('width', '242px');
			$('#module-cart-content').css('overflow', 'hidden');
			
			// Set cart maxHeight
			$('#module-cart-content').css('maxHeight', function(){
				return cartItemHeight*maxCartItems;
			});
			
			// Set Cart Scroll on position = 0
			$('#module-cart-content').scrollTop(currentCartPosition);
			
			//Arrow up actions
			$('#module-cart-arrow-up').unbind('click');
			$('#module-cart-arrow-up').click(function(){
				scrollShoppingCartUp();
			});
			
			//Arrow down actions
			$('#module-cart-arrow-down').unbind('click');
			$('#module-cart-arrow-down').click(function(){
				scrollShoppingCartDown();
			});
			
		} else {
			$('#module-cart-arrow-up').css('display', 'none');
			$('#module-cart-arrow-down').css('display', 'none');
		}
	}
	
	function showShoppingCart(animate){
		//trace("showShoppingCart");
		
		cartState = "showing";
		$('#module-cart-wrapper').attr('class', 'shown');
		
		$.doTimeout('shadows-timeout');
		$.doTimeout('shadows-timeout', 300,function() {
			$('#module-cart-shadow-up').css('display', 'block');
			$('#module-cart-shadow-down').css('display', 'block');
		});
		
		var module_cart = $('#module-cart');
		var margin_top = 0;
		
		if($.browser.version == "8.0"){
			//$('.module-cart-sumup .big-button').css('visibility', 'visible');
		}

		if(!animate){
			//$('#module-cart').css('display', 'block');
			module_cart.css('margin-top', margin_top+'px');
			$('#module-cart-wrapper').attr('class', 'shown');
			
			cartState = "shown";
		}else{
			module_cart.stop();
			module_cart.animate(
				{
					marginTop: margin_top+'px'
				},
				700,
				"easeOutQuint",
				function(){
					//Animation complete
					cartState = "shown";
				}
			);
		}
		
		// Set Keyboard Arrows Event
		$(document).keydown(function(event) {
			if(event.keyCode == '38') scrollShoppingCartUp();
			else if(event.keyCode == '40') scrollShoppingCartDown();
		});
	}
	
	function hideShoppingCart(animate){
		//trace("hideShoppingCart");
		
		if(cartAutoHide){
			
			cartState = "hiding";
	
			// Stop timeout
			$.doTimeout('shadows-timeout');
				
			$('#module-cart-shadow-up').css('display', 'none');
			$('#module-cart-shadow-down').css('display', 'none');
	
			var module_cart = $('#module-cart');
	
			var margin_top = -(module_cart.height()-2);
			//var margin_top = -(module_cart.height()-53); // show the button in the cart
			
			
			if($.browser.version == "8.0"){
				//margin_top = -(module_cart.height()-30);
			}
			
			
			if(!animate){
				//module_cart.css('display', 'none');
				module_cart.css('margin-top', margin_top+'px');
				$('#module-cart-wrapper').attr('class', 'hidden');
				
				if($.browser.version == "8.0"){
					//$('.module-cart-sumup .big-button').css('visibility', 'hidden');
				}
				
				cartState = "hidden";
			}else{
				module_cart.stop();
				module_cart.animate(
					{
						marginTop: margin_top+'px'
					},
					500,
					//"easeOutQuint",
					"easeInQuad",
					function(){
						//Animation complete
						$('#module-cart-wrapper').attr('class', 'hidden');
						
						if($.browser.version == "8.0"){
							//$('.module-cart-sumup .big-button').css('visibility', 'hidden');
						}
						
						cartState = "hidden";
					}
				);
			}
			
			// Remove Keyboard Arrows Event
			$(document).unbind('keydown');
		}
	}
	
	function scrollShoppingCartUp()
	{
		
		var newPosition = currentCartPosition-cartItemHeight;
		var lastPositionAvailable = 0;
		
		if(newPosition>=lastPositionAvailable){
			//trace(currentCartPosition+" --> "+newPosition+">="+lastPositionAvailable);
			currentCartPosition = newPosition;
			$('#module-cart-content').stop(true, true);
			$('#module-cart-content').animate(
				{
					scrollTop: newPosition
				},
				cartScrollTime,
				cartScrollEase,
				function(){
					//Animation complete
				}
			);
		}else{
			//hideShoppingCart(true);
		}
	}
	
	function scrollShoppingCartDown()
	{
		
		var newPosition = currentCartPosition+cartItemHeight;
		var lastPositionAvailable = $('#module-cart-content ul').height()-cartItemHeight*(maxCartItems-1);
		
		if(newPosition<lastPositionAvailable){
			//trace(currentCartPosition+" --> "+newPosition+"<"+lastPositionAvailable);
			currentCartPosition = newPosition;
			$('#module-cart-content').stop(true, true);
			$('#module-cart-content').animate(
				{
					scrollTop: newPosition
				},
				cartScrollTime,
				cartScrollEase,
				function(){
					//Animation complete
				}
			);
		}
	}
	
	function scrollShoppingCartTop()
	{
		scrollShoppingCartUp();
	}
	
	function scrollShoppingCartBottom()
	{
		scrollShoppingCartDown();
	}


	
	
	
	
	

