/**
 * xform_funcs
 *
 * JavaScript forms general functions
 * 
 * @package
 * @version 1.0
 * @access public
 * @example none given
 * @date 2003-11-23
 * @author Marcelo Pecimut <pecimut@yahoo.com>
 * @comment 
 *
 */

//----------------------------------------------------------------
function INPUT_onlyDigits() {
/*
permite ingresar solo digitos en un campo de un formulario
llamar en el evento onkeypress
Ej.: form_td_input_text(...,TR_NO,INPUT_onlyDigits);
*/

	var _ret = true;

	//if (window.event.keyCode < 46 || window.event.keyCode > 57) {
	if (!isDigitKey(window.event.keyCode)){
		window.event.keyCode = 0;
		_ret = false;
	}
	return (_ret);
}

//----------------------------------------------------------------
function INPUT_onlyNumbers() {
/*
permite ingresar solo numeros con parte decimal o no

Ej.: form_td_input_text(...,TR_NO,INPUT_onlyNumbers);
*/

	var _ret = true;

	if (!isNumericKey(window.event.keyCode)){
		window.event.keyCode = 0;
		_ret = false;
	}

	return (_ret);

	
}
var pos = 1;
//----------------------------------------------------------------
function INPUT_onlyISODate() {
/*
permite ingresar solo digitos en un campo de un formulario
llamar en el evento onkeypress
Ej.: form_td_input_text(...,TR_NO,INPUT_onlyDigits);
*/

	var _ret = true;
	
	//if (window.event.keyCode < 46 || window.event.keyCode > 57) {

/*	
	// control de final de campo
	if (pos > 10){
		window.event.keyCode = 0;
		return(false);
	}
*/
	
	if (pos == 5 || pos == 8 ){
		if (window.event.keyCode != 45){
			window.event.keyCode = 0;
			_ret = false;
		}
	}
	else{
		
		if (!isDigitKey(window.event.keyCode)){
			window.event.keyCode = 0;
			_ret = false;
		}
	}
	
	if (_ret)
		pos = pos + 1;


		
	return (_ret);
}


//----------------------------------------------------------------
function INPUT_locked() {
/*
no permite ingresar ningun caracter en un campo de un formulario
usar como alternativa a objeto.disabled
llamar en el evento onkeypress
Ej.: form_td_input_text(...,TR_NO,INPUT_locked);
*/
	
	window.event.keyCode = 0;		
	return (false);
}


//---------------------------------------
/**
 * Permit only alphanumerics chars
 */
function INPUT_onlyAlphanNumeric()
{

	var _ret = true;
	if (!IsAlphaNumeric(window.event.keyCode)){
		window.event.keyCode = 0;
		_ret = false;
	}
	return (_ret);
}


//---------------------------------------
/**
 * Permit only valid SQL chars (all exept ' and \ )
 */
function INPUT_onlySQLValidChars()
{

	var _ret = true;
	if (!IsSQLValidChar(window.event.keyCode)){
		window.event.keyCode = 0;
		_ret = false;
	}
	return (_ret);
}



//----------------------------------------------------------------
function set_focus(objeto) {
/*
setea el foco al objeto
*/


if (!objeto.disabled)
    objeto.focus();

}


//----------------------------------------------------------------
function radio_get_value(radio_group) {
// retorna el valor de un radio button

rvalue = 0;

for (var i = 0; i < radio_group.length; i++) {

	if (radio_group[i].checked) {
		rvalue	= radio_group[i].value;
	break;
	}

}

return rvalue;

}


//----------------------------------------------------------------
function confirm_exec(txt_confirm, location_exec){                  

if (confirm(txt_confirm)) { 
	document.location = location_exec;
}
	
return false; 
}

//----------------------------------------------------------------
// las siguientes funciones no se usan actualmente 

//----------------------------------------------------------------
function setChekBoxValue(objeto) {
// cambia el valor de un checkbox.  para que cuando no este checkeado valga 0 y no ""
// no funciona
/*
if (objeto.checked == true)
   objeto.value = 1;
else
   objeto.value = 0;
*/   

}

function testx(){
alert('testx');
}
