function isMail(_email) {
     var emailReg = /^[a-z][a-z-_0-9\.]+@[a-z-_=>0-9\.]+\.[a-z]{2,3}$/i
     return emailReg.test(_email);
 }

function TrimRight( str ) {
	var resultStr = "";
	var i = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";
	
	if (str.length == 0) 
		resultStr = "";
	else {
  		// Loop through string starting at the end as long as there
  		// are spaces.
  		i = str.length - 1;
  		while ((i >= 0) && (str.charAt(i) == " "))
 			i--;
 			
 		// When the loop is done, we're sitting at the last non-space char,
 		// so return that char plus all previous chars of the string.
  		resultStr = str.substring(0, i + 1);
  	}
  	
  	return resultStr;  	
}

function IsNum( numstr ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	var isValid = true;
	var decCount = 0;		// number of decimal points in the string

	// convert to a string for performing string comparisons.
	numstr += "";	

	// Loop through string and test each character. If any
	// character is not a number, return a false result.
 	// Include special cases for negative numbers (first char == '-')
	// and a single decimal point (any one char in string == '.').   
	for (i = 0; i < numstr.length; i++) {
		// track number of decimal points
		if (numstr.charAt(i) == ".")
			decCount++;

    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || 
				(numstr.charAt(i) == "-") || (numstr.charAt(i) == "."))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) ||
				(numstr.charAt(i) == "." && numstr.length == 1) ||
			  (numstr.charAt(i) == "." && decCount > 1)) {
       	isValid = false;
       	break;
      }         	         	       
//if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9")) || 
   } // END for   
   
   	return isValid;
}  // end IsNum

function alphanumeric(alphane)
{
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}

function alphanumericx(alphane)
{
	return true;
	var numaric = alphane;
	for(var j=0; j<numaric.length; j++)	{
		var alphaa = numaric.charAt(j);
		var hh = alphaa.charCodeAt(0);
		/* 224 - 252 acentuadas ñ ü en System /// 160-165 en Terminal */
		if( ( hh >= 224 && hh<=252 ) || hh==154 || ( hh >= 160 && hh<=165 ) || hh==130 ||  hh==32 ||  hh==39 || ( hh > 47 && hh<59 ) || ( hh > 64 && hh<91 ) || ( hh > 96 && hh<123 ))  {
 		  }
		else{
			 return false;
			}
	}
 return true;  
}

function showPanel(front)
{
	if ( document.getElementById(front).style.display =="none"){
		document.getElementById(front).style.display = "block";
		document.getElementById("HR_" + front).innerHTML= document.getElementById("HR_" + front).innerHTML.replace('+','-')
	}
	else{
		document.getElementById(front).style.display = "none";
		document.getElementById("HR_" + front).innerHTML= document.getElementById("HR_" + front).innerHTML.replace('-','+')
	}
}

function setSelectValue(obj, value){
	for (i =0;i < Gelem(obj).options.length ; i++){
		if ( Gelem(obj).options[i].value==value ){
			Gelem(obj).options[i].selected= true ;
		}
	}	
}

function isChecked ( label ){
		return Gelem(label).checked;
}

function ValueOfSelect(obj){
	if ( Gelem(obj).selectedIndex !=-1)
		return  Gelem(obj).options[Gelem(obj).selectedIndex].value	
	else
		return null	
}


function Gelem (obj){
	return document.getElementById(obj)
}


function popup(ventana){ 
	win = window.open(ventana, '_blank','width=460,height=250,resizable=0,scrollbars=1');
	}

function popupg(ventana){ 
	win = window.open(ventana, '_blank','width=620,height=470,resizable=1,scrollbars=1');
	}


bClickeo = false
function noMorePress(){
	if ( bClickeo ) { 
		//alert('Por favor espere ...') 
		return false; 
	} 
	else 
		bClickeo = true 
}


function catch2(){
	/*alert('Solo cliquee una vez, por favor');*/
	/*return false;*/
}


/*
u=document.createElement('script')
u.src='http://www.google-analytics.com/urchin.js'
document.getElementsByTagName('head')[0].appendChild(u)


u2=document.createElement('script')
u2.text='_uacct = "UA-157220-4";urchinTracker();'
document.getElementsByTagName('head')[0].appendChild(u2)

*/

function FileUploadData(path, description, size ){
	this.path			= path;
	this.description	= description;
	this.size			= size;
}

function NumberFormat(num, numDec, decSep, thousandSep){ 
var arg; 
var Dec; 
Dec = Math.pow(10, numDec); 
if (typeof(num) == 'undefined') return; 
if (typeof(decSep) == 'undefined') decSep = ','; 
if (typeof(thousandSep) == 'undefined') thousandSep = '.'; 
if (thousandSep == '.') 
 arg=/./g; 
else 
 if (thousandSep == ',') arg=/,/g; 
if (typeof(arg) != 'undefined') num = num.toString().replace(arg,''); 
num = num.toString().replace(/,/g, '.'); 
if (isNaN(num)) num = "0"; 
sign = (num == (num = Math.abs(num))); 
num = Math.floor(num * Dec + 0.50000000001); 
cents = num % Dec; 
num = Math.floor(num/Dec).toString(); 
if (cents < (Dec / 10)) cents = "0" + cents; 
for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) 
 num = num.substring(0, num.length - (4 * i + 3)) + thousandSep + num.substring(num.length - (4 * i + 3)); 
if (Dec == 1) 
 return (((sign)? '': '-') + num); 
else 
 return (((sign)? '': '-') + num + decSep + cents); 
} 

function EvaluateText(cadena, obj){ 
opc = false; 
if (cadena == "%d") 
 if (event.keyCode > 47 && event.keyCode < 58) 
  opc = true; 
if (cadena == "%f"){ 
 if (event.keyCode > 47 && event.keyCode < 58) 
  opc = true; 
 if (obj.value.search("[.*]") == -1 && obj.value.length != 0) 
  if (event.keyCode == 46) 
   opc = true; 
} 
if(opc == false) 
 event.returnValue = false; 
} 

function tikiTiki (idTabla){
	
	if ( document.getElementById(idTabla))
	{
		attachRowMouseEvents (document.getElementById(idTabla).getElementsByTagName('tr') )	
	}	
}

function attachRowMouseEvents(rows)
{
	for(var i = 0; i < rows.length; i++){
		var row = rows[i];
		row.onmouseover =	function() 
							{ 
								this.setAttribute('oldClass', this.className);
								this.className = 'selected';
							}
		
		row.onmouseout =	function() 
							{ 
								this.className = this.getAttribute('oldClass');
							}
	}
}

function tikiTD (idTabla){
	if ( document.getElementById(idTabla))
	{
		attachCellMouseEvents (document.getElementById(idTabla).getElementsByTagName('td') )
	}
}

function attachCellMouseEvents(cells)
{
	for ( var j =0; j< cells.length ; j++ )	
	{		
		var cell = 	cells[j];
		cell.onmouseover =	function() 
							{ 
								this.setAttribute('oldClass', this.className);
								this.className = 'selected';
							}
		
		cell.onmouseout =	function() 
							{ 
								this.className = this.getAttribute('oldClass');
							}
	}
}


/*----------------------------------------------------------------*/
/* pila simple
/*----------------------------------------------------------------*/
function stack(){	
	var  _stack = new Array();

	this.constructor = function() {
	}

	this.length = _stack.length;

	this.push = function(value){
		_stack.push (value)
	}

	this.pop = function(){
		return _stack.pop()	
	}

	this.top = function(){
		if (  _stack.length  > 0 )	
			return  _stack[ _stack.length -1];
		
		else
			return null;
	}

	this.getElementByIndex = function (index){
		return  _stack[index];
	}	
}

/*--------------------------------------------------------------*/
/* menulocation  
/*--------------------------------------------------------------*/

function menulocation  (){
	var _href	;
	var _title	;

	this.constructor = function(sHref, sTitle) {
		_href	= sHref;
		_title	= sTitle;
	}


	this.href	=  function() { return _href };
	this.title	=  function() { return _title} ;
}

//document.ondblclick=catch2;



//var common_stackLocations ;

function pilaPush( target) {

	//top.frames['navBar'].window.stackLocationsBase.push (new menulocation(href,title));
	top.frames['navBar'].window.stackLocationsBase.push ( thisURL );
	document.location  = target;
}

function pilaPop()	{
	if (top.frames['navBar'].window.stackLocationsBase.top()!= null )	
		window.location = top.frames['navBar'].window.stackLocationsBase.pop()
	
	else 
			// llamar al volver de la pagina
		Volver()	
	
}

function ventanafulldemo( sMovie, sTitle ){
	window.open('/flash/showDemo.asp?Movie='+sMovie+'&title='+ sTitle,'demo','height=600;width =800;top=0;left=0 ')
}


function ventanaImprimir(id,fmt){
	w= window.open('/includes/printer.asp?id='+id+'&fmt='+fmt,'print','height=20;width=20;top=0;left=0;" ');
	

}