$(window).load(function() {

	/*-- page load animations --*/
	$('#homeslides').animate({'opacity':1}, 300, function() {
		initHomeSlides(); 
	});
	
	/*-- page load animations end --*/
	
});


$(document).ready (function()
{						

	$(document).viewport();

	$('#homeslides, #homeslides li').css({'display':'block', 'opacity':0});


	$("#menucloudopen").click (function() 
	{
		$("#menucloud").fadeIn(500);
	});

	$("#menucloud a").click (function() 
	{
		$("#menucloud").hide();
	});

	$("#storeopen").click (function() 
	{
		$("#amazoniframe").attr('src', 'http://astore.amazon.com/danadelanypag-20/');
		$("#storewindow").fadeIn(500);
	});

	$("#storeclose").click (function() 
	{
		$("#storewindow").fadeOut(500, function()
		{
			$("#amazoniframe").attr('src', 'iframedefault.html');
			$("#storewindow").css({top:0});
		});
	});
	
	$(".shoplink").click (function()
	{
		$("#amazoniframe").attr('src', 'http://astore.amazon.com/danadelanypag-20/detail/'+$(this).attr('name'));
		topTemp = $(window).scrollTop()-110; /*-- subtract top of content div since storewindow top is relative to that--*/
		$("#storewindow").css({top:topTemp});
		$("#storewindow").fadeIn(500);
	});


	$(".morebutton").click (function() 
	{
		$("#"+$(this).attr('id')+"holder").show();
		$(this).hide();
	});

	$(".addHTML").click (function() {
		x = $("#fld_message").val()+$(this).attr("rel");
		$("#fld_message").val(x);								   
		counterUpdate();
	});

	$(".addLink").click (function() {

		jPrompt('Enter your URL here', 'http://', 'Add Link', function(r) {
																	   
			jPrompt('Enter your link text', '', 'Add Link', function(u) {																	   
																	   
				if(( r ) && (r!="http://") && ( u )) 
				{
					x = $("#fld_message").val()+"<a href=\""+r+"\" target=\"_blank\">"+u+"</a>";
					$("#fld_message").val(x);		
					counterUpdate();
				}
			});
		});
	});

	$(".addImage").click (function() {
		jPrompt('Enter your image URL here', '', 'Add Image', function(r) {
			if( r ) 
			{
				x = $("#fld_message").val()+"<img src=\""+r+"\" border=\"0\" />";
				$("#fld_message").val(x);		
				counterUpdate();
			}
		});
		
	});
	
	$(".addEmoticon").click (function() {
		x = $("#fld_message").val()+"<img src=\"http://www.danadelany.com/images/emoticons/"+$(this).attr("rel")+"\">";
		$("#fld_message").val(x);								   
			counterUpdate();
	});

	$("#fld_message").keyup (function() {
		counterUpdate();
	});

	$("#fld_message").click (function() {
		counterUpdate();
	});


	$("#frmforum").submit (function() {
		x1 = $("#fld_name").val();
		x2 = $("#fld_message").val();
		if (x1=="")
		{
			jAlert("Please make sure you've entered your name");
			return false;
		}
		if (x2=="")
		{
			jAlert("Please make sure you've entered your message");
			return false;
		}
		if (x2.length>1500)
		{
			if (($('#fld_name').val()!="Dana Delany") && ($('#fld_name').val()!="Reg (webmaster)"))
			{
				jAlert("Please make sure your message is not longer than 1500 characters");
				return false;
			}
		}
		return true;
	});
								

});


function counterUpdate()
{
	$("#counter").css({'background':'none'});
	x = $("#fld_message").val().length;
	$("#counter").html('<b>Message Length</b> '+x);
}
