	$(document).ready(function(){	
		
		// Slider Content (Home)
		$("#slider").easySlider({
			controlsBefore: '<p id="controls">',
			controlsAfter: '</p>',
			auto: true,
			continuous: true
		});		
		$("#slider2").easySlider({
			controlsBefore:	'<p id="controls2">',
			controlsAfter: '</p>',
			prevId: 'prevBtn2',
			nextId: 'nextBtn2',
			pause: 8500,
			auto: true,
			continuous: true 
		});
		$("#slider3").easySlider({
			pause: 7000,
			controlsShow: false,
			prevId: 'prevBtn3',
			nextId: 'nextBtn3',
			auto: true,
			continuous: true
		});

		// Menu Hover
		function MenuOver(obj,action){
			if (action){
				$(obj).addClass('opened');
			}
			else{
				$(obj).removeClass('opened');
			}
		};
		$('.topmenu > li').bind('mouseenter',function(){ MenuOver($(this),true);}).bind('mouseleave',function(){ MenuOver($(this),false);})
		
		// Light Box (Cases))
		$("a.lightbox").lightBox();
		
		// Overlays (Features)
		$('.featuresclass').layer();

	});
	//**********************************************************************************************************************
	//	Open Layer
	//**********************************************************************************************************************
	(function($){$.fn.layer = function(settings) {
			var jQueryObj = this;
			var html = '<div class="layer"><div class="bg">&nbsp;</div><div class="content"><div id="PopUpNavigationLeft"><a href="#" style="display: block; height: 35px;"><img height="35" border="0" width="35" src="../images/navigation_left.jpg"></a></div><div id="PopUpNavigationRight"><a href="" style="display: block; height: 35px;"><img height="35" border="0" width="35" src="../images/navigation_right.jpg"></a></div><div id="MainPopUpContainer"></div><div id="PopUpNavigation"><div id="ClosePopUp"><a class="close" href="#" style="display: block; height: 35px;"><img height="35" border="0" width="35" src="../images/close_popup.jpg"></a></div><div class="pag" style="float: right; margin-top: 10px; padding-right: 10px;">1 of 14</div></div></div>'
			var idx = 0;
			var totalItens = $(jQueryObj).find('li').length;
			
			$(jQueryObj).find('li').bind('click',function(){createLayer($(this));return false;});
			
			function createLayer(obj){
				
				//append html
				$('body').append(html);
				//animate
				$('.layer').css({'display':'block'}).find('.bg,.content').css({'opacity':0}).not('.bg').css({'top':$(window).scrollTop()});
				$('.layer').find('.bg').animate({'opacity':0.5},200,function(){
					$('.layer').find('.content').animate({'opacity':1},300);
				});
				
				idx = $(jQueryObj).find('li').index(obj) + 1;

				// set texts
				populeLayer(0);
				
				//Remove layer
				$('.layer').find('.close,.bg').bind('click',function(){removeLayer();return false;});
				
				// bind change layer
				$('.layer #PopUpNavigationLeft a').bind('click',function(){ populeLayer( 'prev' );return false; });
				$('.layer #PopUpNavigationRight a').bind('click',function(){ populeLayer( 'next' );return false; });
				
			}
			
			function populeLayer(action){
			
				if(action == 'prev' && idx > 1){
					idx = idx - 1;
				}
				if(action == 'next' &&  idx < totalItens){
					idx = idx + 1;
				}
				
				// set texts
				var h1 = $(jQueryObj).find('li').eq(idx - 1).find('#FeaturesText a').html();
				var p = $(jQueryObj).find('li').eq(idx - 1).find('#FeaturesText div').html();
				var text = '<h1>'+h1+'</h1>'+p;
				$('#MainPopUpContainer').html(text);			
				
				$('.layer .pag').html(idx + ' of ' + totalItens );
				
			}
			
			function removeLayer(){
				$('.layer').find('.content').animate({'opacity':0},100,function(){
					$('.layer').find('.bg').animate({'opacity':0},300,function(){
						$('.layer').remove();
					})
				});				
			}
		}
	})(jQuery);
