var send_completed = function(uuid)
{

	$.post("/ajax/transcription/"+uuid,
 		{ uuid : uuid },
   		function(data)
   		{
                        $('#saving_data_box').html('project saved...');
			window.location.href = '/account/';
   		},
		"json");

};

var send_slice = function(slice_num,slice_data)
{

	$.post("/ajax/slice",
 		{ slice_num	: slice_num,
		  slice_data	: slice_data,
		  c_total	: counter_val.total,
		  c_idle	: counter_val.idle,
		  c_input	: counter_val.mouse,
		  c_active	: counter_val.active
		},
   		function(data)
   		{
				//setTimeout(function()
				//{
				$("#slice_"+slice_num).removeClass('pending_slice_marker').addClass('completed_slice_marker');
				$("#slice_"+slice_num+" span").removeClass('slice_pending').addClass('slice_complete');
				//},10000);
   		},
		"json");
		

        reset_counters();
};

var cancel_project = function()
{
	$('#cancel_current').html('<img src="/images/sm_loading.gif" /> please wait while your cancelation is processed.');
	$.post("/ajax/cancel",
 		{},
   		function(data)
   		{
			window.location.href = '/projects/all/';
			//window.location.reload(true);
   		},
		"json");

};

var select_project = function(media_uuid,redirect_page,el_num)
{

	$('#select_'+el_num).html('<img src="/images/sm_loading.gif" /> please wait while your selection is processed.');

	$.post("/ajax/select",
 		{media_uuid:media_uuid},
   		function(data)
   		{
			if (data.status == 'error')
     		     	{
				$('#select_'+el_num).html('<img src="/images/error.png" /> Error while selecting project.<br />Please make sure you have completed or canceled your last selection before selecting a new project.<br /><a onclick="window.location.reload(true);" style="cursor:pointer;">reload project page</a>');
			} else {
		     		window.location.href = redirect_page;
		 	}
   		},
		"json");
	
};

var reset_counters = function()
{
	counter_val.total 	= 0;
	counter_val.idle 	= 0;
	counter_val.mouse 	= 0;
	counter_val.active 	= 0;
};


/*
$(document).ready(function()
{
	window.oncontextmenu=function(){return false;}
});
*/

