var windowImagen;
var textoIdioma1 = " (Se abre en ventana nueva)";
var textoIdioma2 = " (Open in a new window)";


function inicializar() {
	cargarUtilidades();
	imgAdjuntas(1);
}

function cargarUtilidades() {
	// Tratamiento de los botones de Servicios Generales
	oMenuAuxiliarImprimir = document.getElementById("menuAuxiliarImprimir")
	oMenuAuxiliarImprimir.src="pages/img/comunes/botones/imprimir.gif";
	oMenuAuxiliarImprimir.style.cursor = "pointer";

	oAtajoVolver = document.getElementById("atajoVolver");
	if (oAtajoVolver) {
		oAtajoVolver.href = "javascript:volver();";
	}
}

function imprimir() {
	window.print();
}

function abrirCalendarioFormulario(control, formulario, campo, tipo, compara, x, y) {
    Calendario(control, formulario, document.getElementById(campo), tipo, compara, 'dd/mm/yyyy', 'es', x, y);
}

function volver() {
	history.go(-1);
}

// Limpia el value del objeto
function limpiar(obj) {
	obj.value = "";
}

//---------------------------------------- IMAGEN ADJUNTA -------------------------------------//
//Esta funcion modifica el alt de la imagenes que tiene imagen adjunta, advirtiendo que la aplicacion se abrira en ventana nueva
function imgAdjuntas(iIdidioma){
	 var imgs = document.getElementsByTagName("img");
	 if (imgs!=null) {
	 for (var i=0; i<imgs.length; i++) {
		var img = imgs[i];
		if (img.onclick!=null && img.onclick.toString().indexOf("verImagen") != -1){
		   	img.className = img.className + " cursorAdjunto";
			if(iIdidioma==1){
		   		img.alt = img.alt + textoIdioma1;
		   	}
		   	if(iIdidioma==2){
		   		img.alt = img.alt + textoIdioma2;
		   	}  	
	  }
	 }
	 }	
}

function obtenerDescripcionImagen(iIdImagen,iIdioma) {
	var sNuevoAlt = document.getElementById("Imagen_" + iIdImagen).alt.toString();
 	if(iIdioma==1){
 		sNuevoAlt = sNuevoAlt.replace(textoIdioma1, "");
 	}
 	if(iIdioma==2){
 		sNuevoAlt = sNuevoAlt.replace(textoIdioma2, "");
 	}
	return sNuevoAlt;
}

function verImagen(iIdImagen){
	var descripcion = obtenerDescripcionImagen(iIdImagen,1);
	windowImagen = window.open("abrirImagenAdjunta.do?identificador="+iIdImagen+"&descripcion="+descripcion,"Imagen","width=100,height=100,top=10,left=10,scrollbars=yes,resizable=yes");

}


