// videopage functions

var favo_url = 'http://amateurgalore.net/index/add_to_favorites/' + entry_id;
var send_to_friend_url = 'http://amateurgalore.net/index/ajax_send_to_friend/' + entry_id;
var favo_related_video_url = 'http://amateurgalore.net/index/ajax_related_videos/?id=' + entry_id;


$(document).ready(function(){
   	
	// Open favorite submit

    $("#add_to_favorites").click(function () {
		
      if ($("#fav_content").is(":hidden")) {
		
		// clear html
		$("#fav_content").html('');

        $("#fav_content").slideDown("fast", function () {
								
				// set loading and load page
		 	    $("#fav_content").html('<center><img src=/images/site/2008/loading_form.gif></center>');
				setTimeout("load_favorite_form()", 1000);
		});
      } else {
        $("#fav_content").hide();
      }
	 });
	
	// Open send to friend submit

    $("#send_to_friend").click(function () {
		
      if ($("#friend_content").is(":hidden")) {

		
		// clear html
		$("#friend_content").html('');

        $("#friend_content").slideDown("fast", function () {

				// set loading and load page
		 	    $("#friend_content").html('<center><img src=/images/site/2008/loading_form.gif></center>');
				setTimeout("load_stf_form()", 1000);
		});
      } else {
        $("#friend_content").hide();
      }
	 });

	 // Switch div for favorites related items

    $("#favo_related_switch").click(function () {
		
      if ($("#favo_related_content").is(":hidden")) 
	  {
		$("#thumbs_favor").html('<center><img src=/images/site/2008/loading_form.gif></center>');
		$("#favo_related_content").show();
		$("#favo_related_switch").html('<img border="0" align="right" src="/images/site/2008/icon_up.gif">');
		$("#thumbs_favor").load(favo_related_video_url);
      } 
	  else 
	  {
        $("#favo_related_content").hide();
		$("#favo_related_switch").html('<img border="0" align="right" src="/images/site/2008/icon_down.gif">');
      }

	}); 

	// Like / hate functions

	$("#like").click(function () {
		
		$.ajax({
		  url: "/index/ajax_like_or_hate?vote=like&entry_id="+entry_id,
		  cache: false,
		  success: function(data){
			$("#like_result").html(data);
		  }
		});		

	});

	$("#dislike").click(function () {
		
		$.ajax({
		  url: "/index/ajax_like_or_hate?vote=dislike&entry_id="+entry_id,
		  cache: false,
		  success: function(data){
			$("#like_result").html(data);
		  }
		});		

	});

	// Not avail. msg box

    $("#video_download").click(function () {
		$.prompt('Sorry, this function is unavailable at the moment.',
		{ 
			buttons: { Ok: true}
		});		
	});

});

function load_favorite_form() {
	$("#fav_content").load(favo_url);
}

function load_stf_form() {
	$("#friend_content").load(send_to_friend_url);
}

