/*********************** FILES FUNCTIONS ***********/

function showUpload() {
	$('#uploadNewFile').show('normal'); 
	return false; 
}
function deleteFile (id) {
	if (confirm("Are you sure you want to delete this file? This operation cannot be undone.")) {
		$.post("/files/delete/"+id, { ok_to_delete: "1" },
			function (data) {
				$('#file_'+id).css('background-color','red').fadeOut('slow');
			});
	}
	return false;
}
function showShare (id) {
	$('#file_'+id+'_share').show('slow');
	return false;
}
function hideShare (id) {
	$('#file_'+id+'_share').hide('normal');
	return false;
}
function selectFile (id) {
	if ($('#file_'+id+' input[type=checkbox]').get(0).checked)
		$('#file_'+id).addClass('selected');
	else
		$('#file_'+id).removeClass('selected');
	return false;
}

function showfilerename () {
	$('#filename').hide();
	$('#filename_rename').show();
	return false;
}
function cancelfilerename () {
	$('#filename_rename').hide();
	$('#filename').show();
	return false;
}

/************* USER FUNCTIONS **************/
function deleteUser (id) {
	if (confirm("Are you sure you want to delete this user? This operation cannot be undone.")) {
		$.post("/users/delete/"+id, { ok_to_delete: "1" },
			function (data) {
				$('#user_'+id).css('background-color','red').fadeOut('slow');
			});
	}
	return false;
}



function popout (url, w, h)
{
	if (!w)
		w = 500;
	if (!h)
		h = 400;
	window.open(url, "", "width="+w+", height="+h+", location=no, resizable=yes, scrollbars=yes, toolbar=no");
	return false;
}
function popouta (e, w, h)
{
	var width = 400;
	var height = 400;
	if (w) width = w;
	if (h) height = h;
	var url = window.location;
	if (e) {
		if (e.href)
			url = e.href;
		else if (e.src)
			url = e.src;
		else
			url = e;
	}
	window.open(url, "help", "width="+width+", height="+height+", location=no, resizable=yes, scrollbars=yes, toolbar=no");
	return false;
}

// GLOBAL START FUNCTION CALL
$(function ()  {
	$('div.flash .message').animate( {backgroundColor: 'yellow' }, 300).animate( {backgroundColor: '#CFEBF7' }, 1400);
	$('div.flash .success').animate( {backgroundColor: 'green' }, 300).animate( {backgroundColor: '#CFEBF7' }, 1400);
	$('div.flash .error').animate( {backgroundColor: 'red' }, 300).animate( {backgroundColor: '#CFEBF7' }, 1400);
});

