

$(function()
{
	$("#scrollleft").click(function(e)
	{
		if(parseInt($("#contentholder").css("left")) < 0)
		{
			if($("#contentholder").is(":not(:animated)"))
				$("#contentholder").animate({left:"+=100px"},"fast","easeOutQuad");
		}
	});
	
	$("#scrollright").click(function(e)
	{
		$theright = parseInt($("#contentholder").css("left")) + $("#contentholder").width();
		if($theright > $("#contentholder").parent().width())
		{
			if($("#contentholder").is(":not(:animated)"))
				$("#contentholder").animate({left:"-=100px"},"fast","easeOutQuad");
		}
	});
	
	
	
	$(".gotoPage").click(function(e)
	{
		$thepage = $(this).attr("rel");
		flippingBook.getFlippingBookReference().flipGotoPage($thepage);
		
		$(".pagenumlistitem").removeClass("active");
		$(this).addClass("active");
	});
	
	$("#flipNextPage").click(function(e)
	{
		flippingBook.flipForward();
	});
	
	$("#flipPreviousPage").click(function(e)
	{
		flippingBook.flipBack();
	});
	
	$("#switchissue").change(function(e)
	{
		$theIssue = $(this).val();
		document.location.href = "http://www.flyfishersinc.com/index.cfm/Issue/"+$theIssue;
	});
	
	$("#pastissues").click(function(e)
	{
		e.preventDefault();
		$("#pastissueslist").slideToggle();
	});
	
	$("#subscribelink").click(function()
	{
		$.blockUI({
			message:$("#overlayform").load("http://www.flyfishersinc.com/_ffi_subscribeform.cfm"),
			css:{
				top:"50px",
				width:"390px",
				left:"50%",
				
				"background-color":"#666666",
				"border":"1px solid #999999",
				"margin-left":"-195px",
				cursor:"default"
			},
			overlayCSS:{
				opacity:0.9,
				cursor:"default"
			}
		});
	});
	
	$("#sendtofriendlink").click(function()
	{
		$.blockUI({
			message:$("#overlayform").load("http://www.flyfishersinc.com/_ffi_sendtofriendform.cfm"),
			css:{
				top:"50px",
				width:"580px",
				left:"50%",
				
				"background-color":"#666666",
				"border":"1px solid #999999",
				"margin-left":"-290px",
				cursor:"default"
			},
			overlayCSS:{
				opacity:0.9,
				cursor:"default"
			}
		});
	});
	
	$("#closeoverlay").expire().livequery("click",function()
	{
		$("#overlayform").html("");
		$.unblockUI();
	});
});

function goToPage(num)
{
	$thepage = num;
	flippingBook.getFlippingBookReference().flipGotoPage($thepage);
	
	$(".pagenumlistitem").removeClass("active");
	$(this).addClass("active");
}

function subscribelink()
{
	$("#subscribelink").click();
}

function openlink(link)
{
	window.open(link);
}

function testBlock()
{
	$.blockUI({message:$("#overlayvideo")});
}

function overlayvideo(videofile, hdvideofile)
{
	$theflipbookid = $("#theflipbookid").val();
	
	if(arguments.length > 0)
	{
		switch(arguments.length)
		{
			case 1:
				$thepath = "http://www.flyfishersinc.com/flipbook/" + $theflipbookid + "/supportingfiles/" + videofile;
				$.blockUI({
					message:$("#overlayvideo").load("http://www.flyfishersinc.com/_getvideo.cfm", {videofile:$thepath}),
					css:{
						top:"50px",
						width:"640px",
						left:"50%",
						height:"550px",
						"background-color":"#000000",
						"margin-left":"-320px",
						cursor:"default"
					},
					overlayCSS:{
						opacity:0.9,
						cursor:"default"
					}
				});
				break;
			case 2:
				$thepath = "http://www.flyfishersinc.com/flipbook/" + $theflipbookid + "/supportingfiles/" + videofile;
				$thehdpath = "http://www.flyfishersinc.com/flipbook/" + $theflipbookid + "/supportingfiles/" + hdvideofile;
				$.blockUI({
					message:$("#overlayvideo").load("http://www.flyfishersinc.com/_getvideo.cfm", {videofile:$thepath, hdvideofile:$thehdpath}),
					css:{
						top:"50px",
						width:"640px",
						left:"50%",
						height:"550px",
						"background-color":"#000000",
						"margin-left":"-320px",
						cursor:"default"
					},
					overlayCSS:{
						opacity:0.9,
						cursor:"default"
					}
				});
				break;
			default:
				alert("Wrong number of arguments")
		}
	}
}




