function submitFile(form){
	form.submit();
	startUpload();
}

function startUpload(){
	var boxFile = document.getElementById('boxFile');
	var file_error = document.getElementById('file_error');
	if (file_error.style.display == 'inline'){
		file_error.style.display = 'none';
	}
	boxFile.style.height = '21px';
	document.getElementById('upload_process').style.visibility = 'visible';
    document.getElementById('upload_form').style.display = 'none';
	return true;
}

function stopUpload(success,msg,temp_name,filename,filesize,web,archivo_subido,borrar,borrando_archivo,actual_width,actual_height){
	var boxFile = document.getElementById('boxFile');
	var upload_process = document.getElementById('upload_process');
	var file_success = document.getElementById('file_success');
	var upload_form = document.getElementById('upload_form');
	var file_error = document.getElementById('file_error');
	
	var result = '';	
	if (success == 1){
		result = '<span class="msgFile"><img src="'+web+'/images/icons/file.png" width="12" height="12" alt="'+archivo_subido+'" />'+filename+' ('+filesize+') <a href="javascript:void(0)" onclick="fileDeleted(\''+temp_name+'\',\''+web+'\',\''+borrando_archivo+'\')">'+borrar+'<\/a><\/span>';
		file_success.style.display = 'inline';
		file_success.innerHTML = result;
		document.getElementById('btnmini').disabled = false;
	}
	else{
		result = '<span class="msgFile req">'+msg+'<\/span>';
		boxFile.style.height = '34px';
		upload_form.style.display = 'inline';
		file_error.style.display = 'inline';
		file_error.innerHTML = result;
	}
	upload_process.style.visibility = 'hidden';
	
	document.getElementById('hid_temp_foto').value = temp_name;
	document.getElementById('hid_width_foto').value = actual_width;
	document.getElementById('hid_height_foto').value = actual_height;
	document.getElementById('hid_path_foto').value = document.getElementById('file_foto').value;
	return true;
}

function fileDeleted(temp_name,web,borrando_archivo){
	var file_success = document.getElementById('file_success');
	var upload_form = document.getElementById('upload_form');
	var file_error = document.getElementById('file_error');
	var file_foto = document.getElementById('file_foto');
	var boxFile = document.getElementById('boxFile');
	
	var ajax = crearAjax();
	ajax.open("GET", ''+web+'/modulos/monteverde-photos/update.php?temp_file='+temp_name, true);
	ajax.onreadystatechange = function(){ 
		if (ajax.readyState == 1){
			file_success.innerHTML = '<span class="msgFile"><img src="'+web+'/images/icons/working.gif" width="16" height="16" alt="'+borrando_archivo+'" />'+borrando_archivo+'...</span>';
		}
		if (ajax.readyState == 4){
			file_success.style.display = 'none';
			upload_form.style.display = 'inline';
			file_foto.value = '';
			file_success.innerHTML = '';
		}
	}
	ajax.send(null);
}