
if(window.location.href.indexOf("Rhythmyx/assembler/render") != -1){
	var resPath = "../web_resources/flu";
}
else if (window.location.href.indexOf("gov/flu/") != -1){
	var resPath = "/flu";
}
else if (window.location.href.indexOf("dev/flu/") != -1){
	var resPath = "/flu";
}
else if (window.location.href.indexOf("/enes/") != -1){
	var resPath = "http://www.flu.gov";
}
else if (window.location.href.indexOf("www_pandemicflu_gov") != -1){
	var resPath = "http://www.flu.gov";
}
else{
	var resPath = "";
}



$(document).ready(function () {		
	var slideIndx, sliderWidth, slideWidth, slideNum, totalSlide,padding,isMouseDown,slideNumTotal;
	var delay = 1000;
	var mousedown_sec = 1;
	
	slideIndx = 0;
	padding = 2;
	slideNumTotal = $(".slides li").size();
	sliderWidth = $(".slider").width();
	slideWidth = $("ul.slides li").width() + slideNumTotal;
	slideNum = Math.floor(sliderWidth / (slideWidth + padding));
	
	
	$(".buttons").prepend("<img id='slideLeft' alt='left' src='" + resPath + "/images/sys_images/sliderbuttonleft.gif'>");
	$(".buttons").append("<img id='slideRight' alt='right' src='" + resPath + "/images/sys_images/sliderbuttonright.gif'>");	
	$("#slideLeft").hide();
	
	
	
	$("img#slideLeft").click(function(){				;
		slide(-1 * ((slideWidth < slideIndx) ? slideWidth: slideIndx-padding));				
	});
	
	
	$("img#slideLeft").mousedown(function(){		
	  $(this).oneTime(200, function() {	  	
	  	$(this).everyTime(20, function() {	  		
	  		slide(-15);
	  	});
	  });
	}).mouseup(function(){
		$(this).stopTime();
	});	
	
	$("img#slideLeft").mouseover(function(){		
	  $(this).oneTime(500, function() {	  	
	  	$(this).everyTime(20, function() {	  		
	  		slide(-1);
	  	});
	  });
	}).mouseout(function(){
		$(this).stopTime();
	});	
	
	
	
	
	
	$("img#slideRight").click(function(){
		slide(slideWidth);		
	});
	
	$("img#slideRight").mousedown(function(){		
	  $(this).oneTime(200, function() {	  	
	  	$(this).everyTime(20, function() {	  		
	  		slide(15);
	  	});
	  });
	}).mouseup(function(){
		$(this).stopTime();
	});
	
	
	$("img#slideRight").mouseover(function(){		
	  $(this).oneTime(500, function() {	  	
	  	$(this).everyTime(20, function() {	  		
	  		slide(1);
	  	});
	  });
	}).mouseout(function(){
		$(this).stopTime();
	});
	
	


	
	
	
  function slide(val){
	if(val < 0)
		val -= padding;
	else
		val += padding;
	if( (slideIndx + val >= 0) && (slideIndx + val <= ((slideWidth+padding) * slideNumTotal) - sliderWidth) ){
		slideIndx += val;
		var slideIndxStr = '-' + slideIndx + "px";	
		$("div.slider ul.slides").css("margin-left",slideIndxStr);				
		if(slideIndx <= 0)
			$("#slideLeft").hide();
		else	
			$("#slideLeft").show();
			
		if(slideIndx + val > ((slideWidth+padding) * slideNumTotal - sliderWidth))
			$("#slideRight").hide();
		else
			$("#slideRight").show();
	}
	//$("p#number").html("Index: " + slideIndx + "&nbsp; &nbsp; Slider Width: " + sliderWidth + "&nbsp; &nbsp; Slide Width: " + slideWidth + "&nbsp; &nbsp; Slide number: " + slideNum + "&nbsp; &nbsp; Step:" + (slideWidth + padding));
}
  
});





