// JavaScript Document

	function trimString(stringText) {
		for (i = 0; i < stringText.length; ) {
			if (stringText.charAt(i) == " ")
				stringText = stringText.substring(i + 1, stringText.length);
			else
				break;
		}

		for (i = stringText.length - 1; i >= 0; i = stringText.length - 1) {
			if (stringText.charAt(i) == " ")
				stringText = stringText.substring(0, i);
			else
				break;
		}
		
		return stringText;
	}

//----------------------------------------------------------

	function checkSearch() {
		if (document.frmFind.txtFind.value == '') {
			alert('Por favor, escriba un criterio de búsqueda');
			document.frmFind.txtFind.focus();
			return false;
		}
	
		return true;
	}
	
	function checkBoxes() {
		for (i = 0; i < document.frmList.elements.length; i++) {
			var formObject = document.frmList.elements[i];
			
			if (formObject.type == 'checkbox' && formObject.name != 'chkAll')
				if ( formObject.checked )
					return true;
		}
		
		alert('Por favor, marque los registros que desea eliminar permanentemente');
		return false;
	}
	
	function checkDeletion() {
		if ( checkBoxes() )
			return confirm('¿Borrar el(los) registro(s) seleccionado(s)?');
		
		return false;
	}
	
	function checkAll() {
		for (var i = 0; i < document.frmList.elements.length; i++) {
			var formObject = document.frmList.elements[i];
			
			if (formObject.type == 'checkbox' && formObject.name != 'chkAll')
				formObject.checked = document.frmList.chkAll.checked;
		}
	}

//----------------------------------------------------------

	function checkDeletion2() {
		if ( confirm('¿Está segur@ de que desea eliminar permanentemente este registro?') ) {
			document.forms[0].hdnSave.value = -1;
			document.forms[0].submit();
		} else
			return false;
	}

//----------------------------------------------------------

	function openWindow(windowWidth, windowHeight, windowLocation) {
		screenWidth = 1024;
		screenHeight = 768;
		
		windowTop = (screenHeight - windowHeight) / 2;
		windowLeft = (screenWidth - windowWidth) / 2;
		
		window.open(windowLocation, "myWindow", "directories=0,left=" + windowLeft + ",height=" + windowHeight + ",location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,width=" + windowWidth + ",top=" + windowTop);
	}

	function resizeWindow(newWidth, newHeight) {
		self.moveTo( (screen.width - newWidth) / 2, (screen.height - newHeight) / 2 );
		self.resizeTo(newWidth, newHeight);
	}
