jQuery(document).ready(function() 
{
	$("a.spam_flag, a.delete_spam").click(function() {
		var Answer = confirm("If this is Spam then we better delete it! Are you sure you want to delete this?");
		if (!Answer)
		{
			return false;
		}
	});

	$("a.delete").click(function() {
		var Answer = confirm("Are you sure you wish to delete this poll? You will not be able to resurrect it without the help of a site administrator. No results will be visible again for this poll. Delete it?");
		if (!Answer)
		{
			return false;
		}
	});

	$("a.delete_answer").click(function() {
		var Answer = confirm("Are you sure you wish to delete this answer? It will not be marked as Spam but will be deleted. The person that suggested it will be able to suggest more answers in the future.");
		if (!Answer)
		{
			return false;
		}
	});

	$("a.delete_answer_traditional").click(function() {
		var Answer = confirm("Are you sure you wish to delete this answer?");
		if (!Answer)
		{
			return false;
		}
	});
	
	$("a.delete_ad_link").click(function() {
		var Answer = confirm("Are you sure you wish to delete this link? If it is associated with any running polls then it will no longer appear!");
		if (!Answer)
		{
			return false;
		}
	});
	
	$("a.delete_ad_blurb").click(function() {
		var Answer = confirm("Are you sure you wish to delete this blurb? If it is associated with any running polls then it will no longer appear!");
		if (!Answer)
		{
			return false;
		}
	});
		
	// fade out the warning messages after some time
	$("div#message").delay(15000).slideUp("slow");
	
	// user clicks on * next to an edited answer or question - show the previous value
	$("a.edit_info").click(function() {
		alert($(this).attr("title"));
		return false;
	});

	$("a.alert_title").click(function() {
		alert($(this).attr("title"));
		return false;
	});
	
	
	$("a.vid_vis_toggle").click(function() {
		if ($(this).html() == "Hide Video")
		{	
			$("div.youtube_video").slideUp();
			$(this).html("Watch a demonstration video!");
		}
		else
		{
			$("div.youtube_video").slideDown("fast");
			$(this).html("Hide Video");
		}
		
		return false;
	});
	
	$("a.read_more_about_dynapoll").click(function() {
		$("div#read_more_about_dynapoll_content").slideDown("fast", function() {
			$("a.read_more_about_dynapoll").fadeOut();
		});
		return false;
	});
	
	$("a.dismiss_message").click(function() {
		var the_url = $(this).attr("href");
		var the_msg_id = $(this).attr("id");
		
		// post to dismiss_message function
		$.post(the_url, { message_id : the_msg_id }, function(data) {
			
			if (data.action == 'show_message')
			{
				// show the new message
				$("span.admin_message_from").html(data.message_from);
				$("span.admin_message_subject").html(data.message_subject);
				$("span.admin_message_content").html(data.message_content);
				$("a.dismiss_message").attr("id", data.message_id); 
				
				$("div#admin_message_area").fadeIn("fast");
			}
			else
			{
				$("div#admin_message_area").fadeOut("slow");
			}
			
		}, "json");
		
		return false;
	});
	
	$("a.open_send_admin_message_form").click(function() {
		// if this is a reply then also dismiss message and grab the subject
		
		if ( $(this).html() == 'Reply' )  {
			
			$("a.dismiss_message").click();
			
			var reply_subject = "RE: " + $("span.admin_message_subject").html();
		
			$("input#message_subject").val(reply_subject);
		}
		
		$("div#send_admin_message").slideDown(1000);
		
		return false;
	});
	
	/* put a temporary thing to stop going to account if they click on the link on home page */
	//$("a#account_link").click(function() {
	//	alert("This feature will be coming soon. In the meantime - enjoy your free polls. All new free polls will be given the same number of allowed votes and views as a paid Standard Poll until the paid features of this site are completed. That's 1000 votes or 10,000 views!! Enjoy while it lasts :)");
		
	//	return false;
	//});
	
});

