//Set needed variables
	var currentSpot = 0;
	var currentLeft = 0;
	var nextLeft = 0;
	var PFcurrentWidth = 0;
	var PFliSize = 0;
	var PFulSize = 0;
	var lastButton = "shopYourWay";

$(function(){	
	

	
	//put in the current list and settings
	function loadList(currentButton){
	PFcurrentWidth = $("#PF_scrollerContainer #PF_scrollerBox #"+currentButton+"List li").length;
	PFliSize = 100 / PFcurrentWidth;
	if(PFcurrentWidth >= 8){
		PFulSize = (PFcurrentWidth * 12.5);
	} else {
		PFulSize = (PFcurrentWidth * (100 / PFcurrentWidth));
	}
	$("#PF_scrollerContainer #PF_scrollerBox ul li").css("width", PFliSize+"%");
	$("#PF_scrollerContainer #PF_scrollerBox ul").css("width",PFulSize+"%");
 	$("#PF_scrollerContainer #PF_scrollerBox #"+currentButton+"List li").eq(PFcurrentWidth -1).css("margin-right","-20px");
	
	currentSpot = 0;
	currentLeft = 0;
	nextLeft = 0;
	$("#pf_scroll_left_arrow").css("display","none");
		if(PFcurrentWidth > 8){
			$("#pf_scroll_right_arrow").css("display","block");
		} else {
			$("#pf_scroll_right_arrow").css("display","none");
		}
		clearOthers(currentButton);
	}
	
	//hide other lists
	function clearOthers(currentButton){
		$("#"+currentButton+"List").css("display","block").css("left","0");
		if(currentButton == "shopYourWay"){
			$("#destinationList").css("display","none");
			$("#brandsList").css("display","none");
			$("#sweepStakesList").css("display","none");
		} else if(currentButton == "destination"){
			$("#shopYourWayList").css("display","none");
			$("#brandsList").css("display","none");
			$("#sweepStakesList").css("display","none");
		} else if(currentButton == "sweepStakes"){
			$("#shopYourWayList").css("display","none");
			$("#brandsList").css("display","none");
			$("#destinationList").css("display","none");
		} else {
			$("#destinationList").css("display","none");
			$("#shopYourWayList").css("display","none");
			$("#sweepStakesList").css("display","none");
		}
		$("#" + lastButton).css("background-position","-109px 0").css("color","#0084cc");
		$("#" + currentButton).css("background-position","-236px 0").css("color","white");
		lastButton = currentButton;
	}
	
	//load the default list
	loadList("shopYourWay");
	
	//click the right arrow.
	$("#pf_scroll_right_arrow").click(function(){
		var fullBoxWidth = $("#PF_scrollerContainer #PF_scrollerBox").width();
		currentSpot++;
		var percentLeft = PFulSize - (currentSpot * 100);
		if(percentLeft > 100){
			percentLeft = 100;
		}
		nextLeft = (fullBoxWidth * percentLeft * -.01);
		nextLeft = (currentSpot-1)*(-1*fullBoxWidth) + nextLeft;
		$("#PF_scrollerContainer #PF_scrollerBox ul").animate({ left: nextLeft },500 );
		currentLeft = nextLeft; 
		if(percentLeft < 100){
			$("#pf_scroll_right_arrow").css("display","none");
		}
		$("#pf_scroll_left_arrow").css("display","block");
		PFlastScrollerWidth =  fullBoxWidth;
	});
	
	//click the left arrow
	$("#pf_scroll_left_arrow").click(function(){
		var fullBoxWidth = $("#PF_scrollerContainer #PF_scrollerBox").width();
		currentSpot--;
		var percentLeft = 100;
		if(currentSpot == 0){
			nextLeft = 0;
			$("#pf_scroll_left_arrow").css("display","none");
		} else {
			nextLeft = (fullBoxWidth * percentLeft * -.01);

			nextLeft = (currentSpot-1)*(-1*fullBoxWidth) + nextLeft;
			$("#PF_scrollerContainer #PF_scrollerBox ul").animate({ left: nextLeft },500 );
			/*nextLeft = (fullBoxWidth * percentLeft * .01);
			nextLeft = currentLeft + nextLeft;*/
		}
		$("#PF_scrollerContainer #PF_scrollerBox ul").animate({ left: nextLeft },500 );
		$("#pf_scroll_right_arrow").css("display","block");
		currentLeft = nextLeft;
		PFlastScrollerWidth =  fullBoxWidth; 
		
	}); 
	
	//click desitnations
	$("#PF_scrollerBanner ul li").click(function(){
		var thisID = $(this).attr("id");
		loadList(thisID);	
	});
	
	
});

setTimeout("PFWidthCheck()",2000);
var PFlastScrollerWidth = $("#PF_scrollerContainer #PF_scrollerBox").width();
function PFWidthCheck(){
var PFnewScrollerWidth = $("#PF_scrollerContainer #PF_scrollerBox").width();
if(currentSpot != 0){
	if(PFnewScrollerWidth != PFlastScrollerWidth){
		nextLeft = ((PFnewScrollerWidth*currentLeft)/PFlastScrollerWidth); 
		$("#PF_scrollerContainer #PF_scrollerBox ul").animate({ left: nextLeft },500 );
		PFlastScrollerWidth = PFnewScrollerWidth;
		currentLeft = nextLeft;
	}
	
}
setTimeout("PFWidthCheck()",2000);
}

