// Cargo la página en el frame indicado
function carga_pagina( pagina, frame ){
	parent.frames[frame].document.location = pagina;
	return void(0);
}

//Es un número entero
function esEntero(inputStr){
	for (i = 0; i < inputStr.length; i++){
		oneChar = inputStr.charAt(i);
		if ( oneChar < "0" || oneChar > "9" ){
			return false;
		}
	}
	return true;
}

// Eliminar los espacios en blanco del principio y del fin
function trim(inputStr){
	var strTemp;
	strTemp = inputStr;

	// Quitar los espacios delanteros	
	i = 0;
	inputStrLength = inputStr.length;
	oneChar = inputStr.charAt(i)
	while (oneChar == ' ' && i < inputStrLength){
		oneChar = inputStr.charAt(++i);
	}
	if (oneChar != ' '){
		strTemp = inputStr.substring(i, inputStrLength)
	}

	// Quitar los espacios de atrás
	i = strTemp.length - 1;
	oneChar = strTemp.charAt(i)
	while (oneChar == ' ' && i > 0){
		oneChar = strTemp.charAt(--i);
	}
	if (oneChar != ' '){
		strTemp = strTemp.substring(0, i + 1);
	}
	return strTemp;
}

function limpia_claves( claves ){
	var clave;
	var strTemp = claves;
	var claves_final;
	claves_final = "";
	strTemp = trim( strTemp );
	while ( (pos = strTemp.indexOf(",")) != -1 ){
		clave = trim(strTemp.substring(0, pos));
		claves_final = claves_final + clave + ",";
		strTemp = strTemp.substr(pos + 1, strTemp.length);
	} 
	if ( strTemp.length > 0 ) claves_final = claves_final + trim(strTemp);
	else claves_final = claves_final.substring(0, claves_final.length - 1);
	return claves_final;
}

function chequea_fecha( dia, mes, anyo ){
	if ( dia > 31 || mes > 12 ) return false;
	if ( ( mes == 4 || mes == 6 || mes == 9 || mes == 11 ) && ( dia == 31 ) ) return false;
	if ( mes == 2 && dia > 29 ) return false;
	if ( mes == 2 && dia == 29 && !es_bisiesto( anyo ) ) return false;
	return true;
}

function es_bisiesto( anyo ){
	if ( ( ( anyo % 4 == 0 ) && ( anyo % 100 != 0 ) ) || ( anyo % 400 == 0 ) ) return true;
	else return false;
}

function muestra_contenido( documento ){
	window.open( "/intranet/elementos/muestra_contenido.jsp?doc=" + documento, "Contenido", "alwaysRaised=YES, width=750, height=520, toolbar=no, location=0, directories=0, status=no, menubar=no, scrollbars=YES, resizable=YES");
}

function muestra_texto_contenido( id_elemento ){
	window.open( "/intranet/elementos/muestra_texto_contenido.jsp?doc=" + id_elemento, "Contenido", "alwaysRaised=YES, width=750, height=520, toolbar=no, location=0, directories=0, status=no, menubar=no, scrollbars=YES, resizable=YES");
}

function muestra_contenido_web( documento ){
	window.open( "/documentos/" + documento, "Contenido", "alwaysRaised=YES, width=750, height=520, toolbar=no, location=0, directories=0, status=no, menubar=no, scrollbars=YES, resizable=YES");
}

function muestra_texto_contenido_web( id_elemento ){
	window.open( "/muestra_texto_contenido.jsp?doc=" + id_elemento, "Contenido", "alwaysRaised=YES, width=750, height=520, toolbar=no, location=0, directories=0, status=no, menubar=no, scrollbars=YES, resizable=YES");
}
