// JavaScript Document

$(document).ready(prepSlider);

var animT = 250;

function prepSlider() {
	var listItems = $('.sliding_promo ul.sliding_slots li');
	$(listItems).hide();
	if($('.sliding_promo').hasClass('navdots')) {
		$('.sliding_promo').append('<span class="indicator"></span>');
		$(listItems).each(function() {
			$('.sliding_promo .indicator').append('<span>&bull;&nbsp;</span>');
		});
	}
	$('.sliding_promo ul.sliding_slots li:first-child').show();
	$('.sliding_promo ul.sliding_slots li:first-child, .sliding_promo .indicator :first-child').addClass('active');
	
	
	$('.sliding_nav .next').click(sliderNext);
	$('.sliding_nav .prev').click(sliderPrev);
}

function sliderNext() {
	var current = $('.sliding_promo ul.sliding_slots li.active')
	if(!$(current).is(':last-child')) {
		if($(current).is(':first-child')) $('#adlib2').hide("slide", { direction: "down" }, animT);
		var next = $(current).next();
		$(current).hide("slide", { direction: "left" }, animT);
		$(current).removeClass('active');
		$(next).addClass('active');
		$(next).show("slide", { direction: "right" }, animT);
		var currentInd = $('.sliding_promo .indicator .active');
		var nextInd = $(currentInd).next();
		$(currentInd).removeClass('active');
		$(nextInd).addClass('active');
	}
	
	return false;
}

function sliderPrev() {
	var current = $('.sliding_promo ul.sliding_slots li.active')
	if(!$(current).is(':first-child')) {
		var prev = $(current).prev();
		$(current).hide("slide", { direction: "right" }, animT);
		$(current).removeClass('active');
		$(prev).addClass('active');
		$(prev).show("slide", { direction: "left" }, animT, function() { if($(current).prev().is(':first-child')) $('#adlib2').show("slide", { direction: "down" }, animT); });
		var currentInd = $('.sliding_promo .indicator .active');
		var nextInd = $(currentInd).prev();
		$(currentInd).removeClass('active');
		$(nextInd).addClass('active');
	}
	
	return false;
}

$(document).ready(function() {
	
	//disabled for Incident 005598 - When doing a search for product, if term is entered, and the user clicks within the search box, entered text disappears.
	//$('.input_search').click(function() {		
	//	$(this).attr('value',''); 
	//});					   
});
