// JavaScript Document
function get(funcion, parametro, jfunc) 
{
	var url = "parser.php?"; 
	http.open("GET", url + "f=" + escape(funcion) + "&p=" + escape(parametro), true); 
	http.onreadystatechange = jfunc; 
	http.send(null);
}

var http = getHTTPObject();

function getHTTPObject() {

  var xmlhttp;

  /*@cc_on

  @if (@_jscript_version >= 5)

    try {

      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

    } catch (e) {

      try {

        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

      } catch (E) {

        xmlhttp = false;

      }

    }

  @else

  xmlhttp = false;

  @end @*/

  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {

    try {

      xmlhttp = new XMLHttpRequest();

    } catch (e) {

      xmlhttp = false;

    }

  }

  return xmlhttp;

}

function onlyNumbers(evt)
{
         var charCode = (evt.which) ? evt.which : event.keyCode
		 if (charCode == 46) return true;
         if (charCode > 31 && (charCode < 48 || charCode > 57))
            return false;

         return true;
}

function tabE(elements,obj,e,on)
{
	var e=(typeof event!='undefined')?window.event:e;// IE : Moz
	if(e.keyCode==13)
	{
		var ele = elements;
		for(var i=0;i<ele.length;i++)
		{
			var q=(i==ele.length-1)?0:i+1;// if last element : if any other
			if(obj==ele[i])
			{
				ele[q].focus();
				ele[q].select();
				break
			}
		}
		return false;
	}
	if(on == 1)
	{
		return onlyNumbers(e);
	}
}


function populateData(form,sel,name) { 
  var ie4 = document.all;
  var ns4 = document.layers;
  var ns6 = document.getElementById && !document.all; 
  

	select	= window.document.forms[form][sel]; 
	string	= ""; 
	count	= 0; 
	select.options.length = count; 
	for( i = 0; i < arrayData.length; i++ ) { 
		string = arrayData[i].split( "|" ); 
		if( string[0] == name ) {
		   if(ns4 || ns6)
		   { 
			 select.options[count++] = new Option(string[1],string[2]); 
		   }
		   else
		   {
		     var newElem = document.createElement("OPTION");
			 newElem.text = string[1];
			 newElem.value = string[2];
			 select.options.add(newElem);
		   }
		} 
	} 
   
} 

var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
{
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menub ar=no,scrollbar=no,resizable=no,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
}

var isNN = ( navigator.appName.indexOf( "Netscape" ) != -1 ); 
 
function autoTab( input,len, e ) { 
	var keyCode	= ( isNN ) ? e.which : e.keyCode; 
	var filter	= ( isNN ) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46]; 
	if( input.value.length >= len && !containsElement( filter, keyCode )) { 
	input.value = input.value.slice( 0, len ); 
	input.form[( getIndex( input ) + 1 ) % input.form.length].focus(); 
	} 
	return true; 
} 
 
function containsElement( arr, ele ) { 
	var found = false, index = 0; 
	while( !found && index < arr.length ) 
	if( arr[index] == ele ) { 
		found = true; 
	} else { 
		index++; 
	} 
	return found; 
} 
 
function getIndex( input ) { 
	var index = -1, i = 0, found = false; 
	while ( i < input.form.length && index == -1 ) 
	if ( input.form[i] == input ) { 
		index = i; 
	} else { 
		i++; 
	} 
	return index; 
}
function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		formField.focus();
		result = false;
	}
	
	return result;
}

function inValidCharSet(str,charset)
{
	var result = true;

	// Note: doesn't use regular expressions to avoid early Mac browser bugs	
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0)
		{
			result = false;
			break;
		}
	
	return result;
}

function allDigits(str)
{
	return inValidCharSet(str,"0123456789");
}

function validNum(formField,fieldLabel,required)
{
	var result = true;

	if (required && !validRequired(formField,fieldLabel))
		result = false;
  
 	if (result)
 	{
 		if (!allDigits(formField.value))
 		{
			formField.focus();		
			result = false;
		}
	} 
	
	return result;
}

function loadPage(pagina)
{
	window.location.href = pagina;
}

