
// starting the script on page ready
$(document).ready(function($){
	
	//Highlight current page
	try{
		if(currentPage!=null)
		$("#nav_cnr ul > li").eq(currentPage-1).addClass("active");
	}
	catch(e){
	}
	
	//Dropdown 
	$("#nav_cnr ul li").hover(function(){
		var $dropdown = $(this).find(">ul");
		$dropdown.height("auto")
		$dropdown.clearQueue().show().parent().addClass("hovered");
	},function(){
		var $dropdown = $(this).find(">ul");
		$dropdown.delay(300).slideUp(0, function(){$dropdown.parent().removeClass("hovered")});
	});
	
	//Nivo
	// $(window).load(function() {
        $('.nivoSlider').nivoSlider({
			pauseTime: 4000,
			directionNavHide: false,
			effect: 'fade'
		});
  //  });
	
	//slider-1
	$("#slider-1").powerSlider({
		nextSelector : "#slider-1 .next",
		prevSelector : "#slider-1 .prev",
		autoSlide: true,
		slideInterval : 8000
	});
	
	//gallery-list
	$(".gallery-list a").lightBox();
	
	//Eyewear
	
	//Init
	$(".brandlogo-list li:not(.main-logo)").css("opacity", 0.4);	
	$("#product-list").html($("#brands ul:eq(0)").html());
		
	$("#product-list").jcarousel({
		scroll: 3
	});
	
	//#brand-select
	$("#brand-select .target"). click(function(){
		var  $this = $(this);		
		if(!$(this).is(".clicked")){
			$("#brand-select ul").slideDown(300);
			$this.addClass("clicked");
		}else{
			$("#brand-select ul").slideUp(300);
			$this.removeClass("clicked")
		}
		return false;
	});
	//#brand-select inner
	$("#brand-select ul a").click(function(){
		var $this = $(this);		
		$("#brand-select ul").hide();
		
		if(!$this.is(".active")){
			var text = $this.text();
			$("#brand-select ul .active").removeClass("active");
			$this.addClass("active");
			$("#brand-select .target").text(text).removeClass("clicked");
			$(".brandlogo-list .main-logo").html('<img src="'+$this.attr("rel")+'" alt="" />&nbsp;');
			reloadProducts($this.attr("href"));
		}
		
		return false;
	});
	
	
	//function reloadProducts
	function reloadProducts(id){
				
		$("#product-carousel").html("").append('<ul id="product-list"></ul>');
		$("#product-list").html($(id).html())
		
		$("#product-list").jcarousel({
			scroll: 3
		});
	}	
	
	
});






