/*
 **************************************************************************************************
 *    Copyright (c) 2010-2012 Just Another Video script
 *
 * 	  This file is part of Just Another Video Script.
 *    Version 1.4.3
 *    info@justanothervideoscript.com
 **************************************************************************************************
 *    Come to website for support or buying additional plugins/modules.
 *    http://justanothervideoscript.com/
 **************************************************************************************************
 *    By using this software you agree that you have read and acknowledged our End-User License
 *    Agreement available at http://justanothervideoscript.com/license and can be bound by it.
 **********************************************************************************
 */
var ajaxfriendlyurl = document.getElementById('ajax').value;

//new jquery for version 1.4.3
$(document).ready(function() {


window.onload = $('#download').hide();

	
	$("#play_flag").click(function() {
		var dataString = 'func=flag' + '&vid_id=' + video_id;
		$.ajax({
				type: "GET",
				url: ajaxfriendlyurl+"ajaxglobalfunc.php",
				cache: "false",
				data: dataString,
				success: function() {
					$("#play_flag").hide();
				}
		});
	return false;
	});
	$("#play_addfav").click(function() {
		var dataString = 'func=addfav' + '&vid_id=' + video_id;
		$.ajax({
				type: "GET",
				url: ajaxfriendlyurl+"ajaxglobalfunc.php",
				cache: "false",
				data: dataString,
				success: function() {
					$("#play_addfav").hide();
				}
		});
	return false;
	});	
	$("#play_down").click(function() {
		var dataString = 'func=download' + '&vid_id=' + video_id;
		$.ajax({
				type: "GET",
				url: ajaxfriendlyurl+"ajaxglobalfunc.php",
				cache: "false",
				data: dataString,
				success: function(result) {
					$('#download').fadeIn('slow');
					$("#download").html(result);
				}
		});
	return false;
	});	


 });
 
$(document).ready(function() {
   $.get(ajaxfriendlyurl+"ajaxfunc.php",
       {id: 1, tags: $("#tags").html(), poster: $("#posterz").html()},
	   
       function(data)
       {
         $("#resultz").html(data);
       });
    $("#tags").hide();
 });

$(document).ready(function() {
   $.get(ajaxfriendlyurl+"ajaxfunc.php",
       {id: 4, vidid: video_id},
       function(data)
       {
         $("#commentz").append(data);
       });
 });

function doRelated(tagz,posterz)
{
	$.get(ajaxfriendlyurl+"ajaxfunc.php",
       {id:1, tags: tagz, poster: posterz},
       function(data)
       {
          $("#resultz").html(data);
       });							
}

function doUser(tagz,posterz)
{
	
	$.get(ajaxfriendlyurl+"ajaxfunc.php",
       {id: 2, tags: tagz, poster: posterz}, 
       function(data)
       {
          $("#resultz").html(data);
       });							
}


function RefreshComments()
{
   $.get(ajaxfriendlyurl+"ajaxfunc.php",
       {id: 4, vidid: video_id},
       function(data)
       {
         $("#commentz").html(data);
       });
}

function Mcomment(vidid, loggedIn)
{	
	$.get(ajaxfriendlyurl+"ajaxfunc.php",
		  {id: 3, name: $("#name").val(), comment: $("#text").val(), scode2: $("#security_code").val(), visitor: $("#visitor").val(), vidid: vidid, loggedIn: loggedIn},
		 function(data)
		 {
			  RefreshComments();
			 $("#Cstats").html(data);
			 $("#text").val("");
			 $("#security_code").val("");
		 });
}