// JavaScript Document

var $j = jQuery.noConflict();

$j(function(){
//===================================== section ========================================//

//===================================== drop down menu ==========================================//


 $j("ul.dropdown li").hover(function(){
    
        $j(this).addClass("hover");
        $j('ul:first',this).css('visibility', 'visible');
    
    }, function(){
    
        $j(this).removeClass("hover");
        $j('ul:first',this).css('visibility', 'hidden');
    
    });
    
    $j("ul.dropdown li ul li:has(ul)")
		.find("a:first")
		.append(" &raquo; ") /*THIS PUTS THE >> AFTER THE WORD*/
		/*.prepend(" &laquo; ") THIS PUTS THE << BEFORE TO THE WORD*/
		;



//===================================== fancyZoom ==========================================//

/*$('#product-images a').fancyZoom();
    $('.quick-look-link').fancyZoom();
    $('.popup-link').fancyZoom();
*/
//===================================== sidebar nav ==========================================//

	/*$j(".pagenav ul li:has('ul')").find("li").hide();*/
	
   $j("#sidebar li:has('ul') > a").css("text-indent", 0).parent("li").prepend("<div class='menu-arrow'></div>");/* */
	/*$j("#sidebar li:has('ul') > a").css("text-indent", 0).parent("li").addClass("menu-arrow");*/
    
    $j("#sidebar .menu-arrow").click(function() {
        
            $j(this).toggleClass("showing").parent().find("ul:first").stop(true, true).slideToggle("fast");
            
        });
  /*  */
    // show submenu if active page is buried
    /*$j("#sidebar strong").parent().find("ul").show().end().parent().show();*/
	$j(".current_page_item").parents().show();/**/



//===================================== slider ==========================================//


//Speed of the slideshow
	var speed = 6000;
	
	//You have to specify width and height in #slider CSS properties
	//After that, the following script will set the width and height accordingly
	$j('#mask-gallery, #gallery li').width($j('#slider').width());	
	$j('#gallery').width($j('#slider').width() * $j('#gallery li').length);
	$j('#mask-gallery, #gallery li, #mask-excerpt, #excerpt li').height($j('#slider').height());
	
	//Assign a timer, so it will run periodically
	var run = setInterval('newsslider(0)', speed);	
	
	$j('#gallery li:first, #excerpt li:first').addClass('selected');

	//Pause the slidershow with clearInterval
	$j('#btn-pause').click(function () {
		clearInterval(run);
		return false;
	});

	//Continue the slideshow with setInterval
	$j('#btn-play').click(function () {
		run = setInterval('newsslider(0)', speed);	
		return false;
	});
	
	//Next Slide by calling the function
	$j('#btn-next').click(function () {
		newsslider(0);	
		return false;
	});	

	//Previous slide by passing prev=1
	$j('#btn-prev').click(function () {
		newsslider(1);	
		return false;
	});	
	
	//Mouse over, pause it, on mouse out, resume the slider show
	$j('#slider').hover(
	
		function() {
			clearInterval(run);
		}, 
		function() {
			run = setInterval('newsslider(0)', speed);	
		}
	); 	
	




	
//===================================== end ==========================================//	
});//doc ready
	
	
	
function newsslider(prev) {

	//Get the current selected item (with selected class), if none was found, get the first item
	var current_image = $j('#gallery li.selected').length ? $j('#gallery li.selected') : $j('#gallery li:first');
	var current_excerpt = $j('#excerpt li.selected').length ? $j('#excerpt li.selected') : $j('#excerpt li:first');

	//if prev is set to 1 (previous item)
	if (prev) {
		
		//Get previous sibling
		var next_image = (current_image.prev().length) ? current_image.prev() : $j('#gallery li:last');
		var next_excerpt = (current_excerpt.prev().length) ? current_excerpt.prev() : $j('#excerpt li:last');
	
	//if prev is set to 0 (next item)
	} else {
		
		//Get next sibling
		var next_image = (current_image.next().length) ? current_image.next() : $j('#gallery li:first');
		var next_excerpt = (current_excerpt.next().length) ? current_excerpt.next() : $j('#excerpt li:first');
	}

	//clear the selected class
	$j('#excerpt li, #gallery li').removeClass('selected');
	
	//reassign the selected class to current items
	next_image.addClass('selected');
	next_excerpt.addClass('selected');

	//Scroll the items
	$j('#mask-gallery').scrollTo(next_image, 800);		
	$j('#mask-excerpt').scrollTo(next_excerpt, 800);		

}	


	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
