// JavaScript Document
function moveLeft()
{
	var left = $("#archiveList").css("margin-left");
	left = left.replace(/px/, '');
	left = eval(left-10);
	if(left > -1550)
	{
		$("#archiveList").css({"margin-left": left+'px'})	
	} else {
		$("#arrowRight").hide();	
	}
	if(left < 0)
	{
		$("#arrowLeft").show();
	}
}

function moveRight()
{
	var left = $("#archiveList").css("margin-left");
	left = left.replace(/px/, '');
	left=eval(left) + 10;
	if(left<10)
	{
		$("#archiveList").css({"margin-left": left+'px'})	
	}
	if(left >= 0)
	{
		$("#arrowLeft").hide();
	}
	if(left > -1578)
	{
		$("#arrowRight").show();		
	}
}

var moveInterval;
	function updateAfterLoad()
	{
		$("#blackBox").add("a#close").click(function ()
		{
			$("#blackBox").add("#formHolder").fadeOut('normal', function ()
			{
				$("#blackBox").add("#formHolder").remove();
			});
		});
		$("#contactForm textarea").css({width: '250', height: '80'});
		$("#friendMessage").focus(function() { $(this).blur()});
		$("#yourName").add("#friendMessage").change(function ()
		{
					var newGreet = "Hi. " + $("#yourName").val() + " thought";
					var message = "Hi. I thought you should check out www.dailyflounder.com. It's a quick daily offering of cartoons, drawings and musings to brighten your day. Hope you enjoy it.";
					$("#friendMessage").val(message.replace("Hi. I thought", newGreet));
				//$(this).css({color: "#000"});
				//friendMessageDefault = false;
		});
		
		$("#friendForm").submit(function ()
		{
			if($("#friendForm #yourName").val() == "" || $("#friendForm #yourEmail").val() == "" || $("#friendForm #friendEmail1").val() == "")
			{
				return false;
			} else {
				return true;	
			}
		});
		
	}
	var dropTimer;

$(document).ready(function ()
{	
	$("body").pngFix();
	/*
	$("#commentHover").click(function ()
	{
		$("#blackBox").add("#formHolder").remove();
		$("body").prepend("<div id=\"blackBox\"></div>");
		$("#blackBox").css({'position': 'absolute', 'z-index':200, 'width': "100%", 'height': "100%", background: "#000", opacity: "0.6"});
		$("body").prepend("<div id=\"formHolder\"></div>");
		$("#formHolder").css({'border':'4px solid #ddd', 'position': 'absolute', width: '300px', 'margin-left': '40%', 'margin-top': '100px', 'z-index':201, background: "#fff"});
		$("#formHolder").load("/form.html?cacheBuster=" + (new Date).valueOf());
		setTimeout('$("#antiCaptcha").val("Valid");', 50);
		setTimeout('$("#antiCaptcha").val("Valid");', 200);
		setTimeout('$("#antiCaptcha").val("Valid");', 1000);
		updateAfterLoad();
		setTimeout('updateAfterLoad();', 200);
		setTimeout('updateAfterLoad();', 1000);
	});
	*/
	$(".sendToFriend").click(function ()
	{
		friendMessageDefault = true;
		$("#blackBox").add("#formHolder").remove();
		$("body").prepend("<div id=\"blackBox\"></div>");
		$("#blackBox").css({'position': 'absolute', 'z-index':200, 'width': "100%", 'height': "100%", background: "#000", opacity: "0.6"});
		$("body").prepend("<div id=\"formHolder\"></div>");
		$("#formHolder").css({'border':'4px solid #ddd', 'position': 'absolute', width: '360px', height:'510px', 'margin-left': '40%', 'margin-top': '100px', 'z-index':201, background: "#fff"});
		$("#formHolder").load("/friendform.php?cacheBuster=" + (new Date).valueOf());
		setTimeout('$("#antiCaptcha").val("dFlounder Friend Message");', 50);
		setTimeout('$("#antiCaptcha").val("dFlounder Friend Message");', 200);
		setTimeout('$("#antiCaptcha").val("dFlounder Friend Message");', 1000);
		updateAfterLoad();
		setTimeout('updateAfterLoad();', 50);
		setTimeout('updateAfterLoad();', 100);
		setTimeout('updateAfterLoad();', 200);
		setTimeout('updateAfterLoad();', 1000);
	});
	
	
	if($("#isSingle").val() == "yes")
	{
		$("#archiveLink").add("#archiveLinkFooter").addClass("currentPage");
	}
	
	//Hide show hack for ie6
	$("#navDrop").hide();
	
	$("#commentHover").hover(function ()
	{
		clearTimeout(dropTimer);
		$("#navDrop").slideDown();
		
	}, function ()
	{
		dropTimer = setTimeout('$("#navDrop").slideUp()', 1000);	
	});
	
	$("#navDrop").hover(function ()
	{
		clearTimeout(dropTimer);
	}, function ()
	{
		dropTimer = setTimeout('$("#navDrop").slideUp()', 1000);	
	});
	
	$("#arrowRight").hover(function () { moveInterval = setInterval("moveLeft()", 50); }, function(){ clearInterval(moveInterval)});
	$("#arrowLeft").hover(function () { moveInterval = setInterval("moveRight()", 50); }, function(){ clearInterval(moveInterval)});
	var startLeft = $("#On").attr('title') * 62;
	$("#archiveList").css({"margin-left": -startLeft + "px"});
	$("#archiveList").each(function () {
		
		var left = '0px';
		left = $("#archiveList").css("margin-left");
		left = eval(left.replace(/px/, ''));
		if(left >= 0)
		{
			$("#arrowLeft").hide();
		}
		if(left <= -1500)
		{
			$("#arrowRight").hide();
		}
							});
	
});