function my_insertHiddenField(elementId, elementValue, parentForm) {
	var element = document.getElementById(elementId);
	if (element != null) {
		element.value = elementValue;
		return;
	}
	var newElement = document.createElement('input');
	newElement.type = 'hidden';
	newElement.id = elementId;
	newElement.value = elementValue;
	newElement.name = elementId;
	parentForm.appendChild(newElement);
}

function XDS() {
}

XDS.FocusManager = function() {
}

XDS.FocusManager.SetFocus = function(formInst, elementInst) 
{
	document.forms[formInst].elements[elementInst - 1].focus();
}

XDS.FocusManager.SetFocusToFirstInput = function() 
{
	var bFound = false;

	// para cada formulario
	for (f=0; f < document.forms.length; f++)
	{
    	   // para cada elemento del formulario
    	   for (i=0; i < document.forms[f].length; i++)
           {
                // si el elemento no está oculto
                if (document.forms[f][i].type != "hidden")
                {
        	    // y si no está inhabilitado
                    if (document.forms[f][i].disabled != true)
                    {
                        // asigna el focus a este
                        document.forms[f][i].focus();
                        var bFound = true;
                    }
                }
                // si ya se asignó el focus se detiene el loop
                if (bFound == true)
                    break;
           }
           // si el focus se asignó se detiene el loop
           if (bFound == true)
           break;
       } 
}

XDS.Math = function() {
}

XDS.Math.Random = function(inf, sup) 
{
    var numPosibilidades = sup - inf; 
    var aleat = Math.random() * numPosibilidades;
    var aleat = Math.floor(aleat);
    return parseInt(inf) + aleat ;
}

XDS.Browser = function() {
}

XDS.Browser.userAgent = navigator.userAgent.toLowerCase();

XDS.Browser.isIE = function () {
    return ((XDS.Browser.userAgent.indexOf('msie')) != -1);
}

XDS.Browser.versionIE = function () {
    if (XDS.Browser.isIE)
    {
        var g_arVersion = navigator.appVersion.split("MSIE");
        return parseFloat(g_arVersion[1]);
    }
    else
        return 0;
}
