// JavaScript Document

function setRedirect(pagina){ window.location = pagina;	 }



function getId(varid){
	return document.getElementById(varid);
}

function mostrardirectorio(nombre){
	if(getId(nombre).style.display == "block"){
	   getId(nombre).style.display = "none";
	   getId('divmin').style.display = "none";
	   getId('divmax').style.display = "block";
	}else{
	   getId(nombre).style.display = "block";
	   getId('divmin').style.display = "block";
	   getId('divmax').style.display = "none";
	}
}



var popUpWin=0;

function getView(URLStr, left, top, width, height){

	if(popUpWin){

		if(!popUpWin.closed) popUpWin.close();

	}

	popUpWin = open('oportunidades-popup.php?img=' + URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbar=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+((screen.width/2)-(width/2))+', top='+((screen.height/2)-(height/2))+',screenX='+((screen.width/2)-(width/2))+',screenY='+((screen.height/2)-(height/2))+'');

}

function deleteImage(urldelete) {
	if (confirm("¡Aviso!  Va a eliminar una imagen.\n¿Realmente desea eliminarla?")) {
		window.location = urldelete + "&mmActionImage=del";	

	}

}



function getTrim(cadena) {
while (cadena.substring(0,1) == ' ') { cadena = cadena.substring(1,cadena.length);} 

while (cadena.substring(cadena.length-1,cadena.length) == ' ') { cadena = cadena.substring(0,cadena.length-1); } 

return cadena; 

}

function getFileExt(file){

	var nPunto = file.lastIndexOf(".",file.length)+1;

	return file.substring(nPunto, file.length).toUpperCase();

}





function ValidaImagen(){

	var bEstado = true;

		var sImagen = getTrim( getId("txImagen").value );

		if( sImagen == "" ){

			alert("¡Aviso!  Primero debe seleccionar una imagen. ");

			bEstado = false;

		}else if( ",JPG".indexOf(getFileExt(sImagen),0) == -1 ){

			alert("¡Aviso! Solo se puede agregar archivos JPG");

			bEstado = false;

		}

		return bEstado;

	}



function EnviaImagen() {

	if(ValidaImagen()) {

		document.getElementById('EstadoImagen').value=1;

		document.RegistroAviso.submit();

	}

}











