// ACL Ui
// (c) Bruno Fagúndez - 2008
$(document.body).ready(function(){

	// Menu lava top
	$(".topmenu").lavaLamp({ fx: "backout", speed: 700 });
	
	//Clean portfolio submenu :)
	$(".topmenu li").hover(
		function () {
			if($('#portfolio_hover:visible') && !$(this).hasClass('portfolio') && !$(this).hasClass('back') && !$('body').hasClass('portfoliopage') ){
				//console.info('have to hide!',$(this));
				$('#portfolio_hover').hide("fast");
				isopen_portfoliosubmenu = false;
			}
		},
		function () {}
	);
	
	// Portfolio menu rollover
	$(".topmenu li.portfolio").hover(
	  function () {
		// In
        $('#portfolio_hover').show("fast");	
		isopen_portfoliosubmenu = true;
      }, 
      function () {}
	);
	
	// Menu lava portfolio
	$(".menu_portfolio_lava").lavaLamp({ fx: "backout", speed: 700 });
	
	//Product slider
	$('#productSliderOutside').serialScroll({
		target:'#productWrapper',
		items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'a.previous',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'a.next',// Selector to the 'next' button (absolute too)
		axis:'x',// The default is 'y' scroll on both ways
		duration:300,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)		
		lazy:false,
		cycle:false,
		onBefore:function( e, elem, $pane, $items, pos ){},
		onAfter:function( elem ){}
	});
	
	// Form Validation
	$("#commentForm").validate();
	
	// Signup to newsletter
	$('#signup').submit(function() {
		
		// Update user interface
		$('#response').text('Adding email address...').show();
		
		// Send AJAX request with data
		var myAjax = $.get("newsletter/store-address.php", { ajax: "true", email: escape($('#email').val()) },
						   function(data){
								$('#response').text(data).show();
							});

		return false; // Stop form from submitting when JS is enabled
	});

});