var session = Get_Cookie('PHPSESSID');
function Get_Cookie( name ) {
	
var start = document.cookie.indexOf( name + "=" );
var len = start + name.length + 1;
if ( ( !start ) &&
( name != document.cookie.substring( 0, name.length ) ) )
{
return null;
}
if ( start == -1 ) return null;
var end = document.cookie.indexOf( ";", len );
if ( end == -1 ) end = document.cookie.length;
return unescape( document.cookie.substring( len, end ) );
}

function cancelFileUpload(file_id) {
	document.getElementById("FileUpload").cancelFile(file_id);
}

function uploadProgress(file, bytesLoaded) {

	if (file.size > 10485760) { 
		alert('The express upload is limited to 10 MB, you must login to upload larger files.');
		//alert('Le upload express est limité ŕ 10 megs veuillez entrer dans votre compte pour uploader des fichiers de plus de 10 megs.');
		cancelFileUpload(file.id);
		return;
	}
	
	document.getElementById("UploadStep1").style.display = "none";
	document.getElementById("UploadStep2").style.display = "inline";
	
	var progress = document.getElementById("UploadStep2Progress");	
	var percent = Math.ceil((bytesLoaded / file.size) * 100);
	progress.style.width = percent + "%";
}

function uploadFileComplete(file) {
	window.location.href = "uploaded_media.php";
}
function uploadFileComplete2(file) {
	window.location.href = "add_media.php";
}
function uploadFileComplete3(file) {
	//document.getElementById("UploadStep2").style.display = "none";
	//document.getElementById("UploadStep3").style.display = "inline";
	ajaxpage('_add_media_uploader.php', 'media_upload');
}
