/* FUNCIONES ADJUNTOS*/
	
function myShowUI() {
	var btnSubmit = document.getElementById("btnSubmit");
	
	btnSubmit.onclick = doSubmit;
/*	btnSubmit.disabled = false;
	
	txttipo.onchange = validateForm;
	txtdescripcioncas.onchange = validateForm;
	txtdescripcioncat.onchange = validateForm;
	txtFileName.onchange = validateForm;  */
	
	
	SWFUpload.swfUploadLoaded.apply(this);  // Let SWFUpload finish loading the UI.
	validateForm();
}

function validateForm() {
	
}

function fileBrowse() {
	var txtFileName = document.getElementById("txtFileName");
	txtFileName.value = "";

	this.cancelUpload();
	this.selectFile();
}


// Called by the submit button to start the upload
function doSubmit(e) {
	/* IF PARA CONTROLAR SI ES UN ADJUNTO DE NOTICIA O DE TICKET*/
	var txtFileName = document.getElementById("txtFileName").value;
	var hidFileID = document.getElementById("hidFileID").value;
	var resume_degraded = document.getElementById("resume_degraded").value;
	/* IF PARA PODER USAR EL UPLOAD EN LOS TICKETS SIN CONTROLAR ESTOS CAMPOS*/
	document.forms[0].urladjunto.value=txtFileName;
	var nombre = document.getElementById("nombre").value;
	if(nombre==""){
		alert("Introduce el titulo de la imagen");
		return false;
	}
	
	e = e || window.event;
	if (e.stopPropagation) e.stopPropagation();
	e.cancelBubble = true;
	
	try {
		if(document.forms[0].txtFileName){
			if(document.forms[0].txtFileName.value == "" && document.forms[0].modifica.value == ""){
				alert("Elija el archivo que quiere adjuntar");
				return false;
			}
			
			if(document.forms[0].txtFileName.value == "" && document.forms[0].modifica.value != ""){
				//alert("Si sale esto, es porque es una modificacion sin cambiar el archivo");
			   document.forms[0].submit();
			}else{
				swf_upload_control.startUpload();
			}
		}else{
			swf_upload_control.startUpload();
		}

	} catch (ex) {

	}
	return false;
}

 // Called by the queue complete handler to submit the form
function uploadDone() {
	try {
		if(document.forms[0].txtFileName){
			document.forms[0].submit();
		}else{
			document.forms[1].submit();
		}
	} catch (ex) {
		alert("Error submitting form");
	}
}


function deleteadj(tipo,idadj,iddoc){
	 if(!confirm("Està segur de voler eliminar l'adjunt?")) {
		 return false;
	 }else{ 
		document.location="/" + tipo + "/alta/adj/?id=" + iddoc + "&idadj="+idadj+"&option=delete";
	 }   
	
}

function modifyadj(tipo,idadj,iddoc){
	if(!confirm("Está seguro de voler modificar l'adjunt?")) {
		 return false;
	}else{ 
		document.location="/" + tipo + "/alta/adj/?id=" + iddoc + "&idadj="+idadj+"&option=modify";
	}
}

/* FIN FUNCIONES ADJUNTOS*/
