//-------------------------------------------------------------------
//Description 	 : Libreria de utilerias
//Author		 : Lorenzo Mendoza Jiménez
//Create Date 	 : 03 de febrero del 2003
//Last Modify by : 
//Last Date Mod. : 
//-------------------------------------------------------------------
var oldRow;
function PrintDocument(dvHidden)
{	//Descripcion: Imprime documento
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	
	if (dvHidden != null)
	{	dvHidden.style.display='none'; }

	window.print();

	if (dvHidden != null)
	{	dvHidden.style.display=''; }

	return (true);
}
function KeyNumber(e, TypeValida)
{	//Descripcion: Valida que unicamente se introduzcan números
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	e    = window.event;
	if( TypeValida== "1")
		chars= "1234567890.-";
	else if(TypeValida== "2")
		chars= "1234567890/";
	else if(TypeValida== "3")
		chars= "1234567890";
	else if(TypeValida== "4")
		chars= "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	else if(TypeValida== "5")
		chars= "1234567890,.";
	if(chars.indexOf(String.fromCharCode(e.keyCode))==-1) window.event.keyCode=0;
}

function KeyChar(e)
{	//Descripcion: Valida que unicamente se introduzcan los caracteres permitidos
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	e = window.event;
	chars= "().,@1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ- ";
	if( chars.indexOf(String.fromCharCode(e.keyCode))==-1) window.event.keyCode=0;
}

function ValidaFecha(dtmValue)
{	//Descripcion: Valida la fecha contenida en un String
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	var intPos;
	var strChar;
	var strSep;
	var strEval;
	var dtmNow;
	var strLimitYear;
	var intNumDays;
	var intYearNow;
	var intYear;
	strSep = '/';
	dtmNow = new Date();
	
	strLimitYear = "1900";
	intYearNow = dtmNow.getFullYear();
	intYearNow = intYearNow + 100;
	
	if (dtmValue.length != 10) return (false);
	strEval = dtmValue.substr(0, 2)	//Evalua el Día
	if (isNaN(strEval)) return (false);
	if (parseInt(strEval, 10) < 1 || parseInt(strEval, 10) > 31) return (false);
	if (dtmValue.charAt(2) != strSep || dtmValue.charAt(5) != strSep) return (false);
	strEval = dtmValue.substr(6, 4)	//Evalua el Año
	if (isNaN(strEval)) return (false);
	intYear = parseInt(strEval, 10)
	
	if (intYear < parseInt(strLimitYear, 10) || intYear > intYearNow) return (false);
	strEval = dtmValue.substr(3, 2)	//Evalua el Mes
	if (isNaN(strEval)) return (false);
	if (parseInt(strEval, 10) < 1 || parseInt(strEval, 10) > 12) return (false);
	switch (parseInt(strEval, 10))
		{
		case 1:
			intNumDays = 31;
			break;
		case 2:
			intNumDays = 28;
			if ((intYear % 4 == 0 &&  intYear % 100 != 0) ||intYear % 400 == 0) intNumDays = 29;
			break;
		case 3:
			intNumDays = 31;
			break;
		case 4:
			intNumDays = 30;
			break;
		case 5:
			intNumDays = 31;
			break;
		case 6:
			intNumDays = 30;
			break;
		case 7:
			intNumDays = 31;
			break;
		case 8:
			intNumDays = 31;
			break;
		case 9:
			intNumDays = 30;
			break;
		case 10:
			intNumDays = 31;
			break;
		case 11:
			intNumDays = 30;
			break;
		case 12:
			intNumDays = 31;
			break;
		}
	strEval = dtmValue.substr(0, 2)	//Evalua el Dia de acuerdo al Mes
	if (isNaN(strEval)) return (false);
	if (parseInt(strEval, 10) < 1 || parseInt(strEval, 10) > intNumDays) return (false);
	return (true);
}

function substr(pstrmodif, pini, plength)
{	//Descripcion: Regresa una subcadena 
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	var strtemp='';
	items =(parseInt(plength)+parseInt(pini));
	for (var i=pini;i<items;i++) 
	{ strtemp += pstrmodif.charAt(i); 	  
	}
	return(strtemp);
}
function ConvertDate(sDate)
{	//Descripcion: Recupera solo el dia, mes y año de un string de fecha y omite las diagonales
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002
	var strtemp="", intC=0;
	var objArgument = new Array (0,1);
	var strString =new String(sDate);
	var strDateConvert;
	for (var i=0;i<strString.length;i++)
	{	if (strString.charAt(i)!="/")
		{	strtemp += strString.charAt(i); }
		else
		{	objArgument[intC] = strtemp;
			strtemp = "";
			intC = intC + 1
		}
	}
	objArgument[intC] = strtemp;
	strDateConvert = objArgument[2] + objArgument[1] + objArgument[0]
	return (strDateConvert);
}

function ViewCtes(ctrl, pImg)
	//Descripcion: Navega dentro de un arbol de opciones
	//Elaboro    : Freddy Jarquín M - 15 de octubre del 2002

	{	if ( ctrl.style.display == '') 
		{	ctrl.style.display = 'none'; 
			pImg.src = '../images/IBEX_plus+.gif'; 
		}
		else 
		{	ctrl.style.display = ''; 
			pImg.src = '../images/IBEX_minus-.gif'; 
		}
		return (true);
	}

function serchchar(pstrserch, pstrFind)
{	//Descripcion: regresa el indice de la primera incidencia de una subcadena
	//Elaboro    : Lorenzo Mendoza - 17 de octubre del 2002
	for (var i=0;i<pstrserch.length;i++){
			if (pstrserch.charAt(i)==pstrFind)
			return(i+1)
		}  		
	return(-1)
}
function SetFormatDate(event, objText)
{	//---------------------------------------------------------------------
	//Descripcion: Agrega por default una diagonal "/" a un cuadro de fecha
	//Elaboro    : Lorenzo Mendoza - 18 de octubre del 2002
	//---------------------------------------------------------------------
	var sKeyCodeDiagonal=47;
	var intCode;
	
	intCode = window.event.keyCode;
	if (intCode==sKeyCodeDiagonal)
		return true;
	
	if (intCode==8|| intCode==0) //8=Blackspace; 0=Supr
		return true;
		
	if((objText.value.length == 2) && ('/'.indexOf(objText.value.charAt(objText.value.length-1)) == -1) )
		objText.value = objText.value + '/';

	if((objText.value.length == 5) && ('/'.indexOf(objText.value.charAt(objText.value.length-1)) == -1) )
		objText.value = objText.value + '/';
}

function SimilMouseOut(sObj)
{	//Descripcion: Quita la lina en el ref de alguna leyenda
	//Elaboro    : Lorenzo Mendoza - 18 de octubre del 2002
	sObj.style.textDecoration = 'none';
	sObj.style.cursor = '';
}

function SimilMouseOver(sObj)
{	//Descripcion: Muestra una lines en el ref de alguna leyenda
	//Elaboro    : Lorenzo Mendoza - 18 de octubre del 2002
	sObj.style.textDecoration = 'underline';
	sObj.style.cursor = 'hand';
}

function ValidaError(pstrLevel)
{	//Descripcion: Modulo general para manejo de errores
	//Elaboro    : Lorenzo Mendoza - 22 de octubre del 2002
	var f1 = document.frmError;
	if (pstrLevel==null) pstrLevel='';
	//alert(those);
	if(f1.txtHResultOp.value!='')
		window.showModalDialog(pstrLevel+"ErrorManager.php?strResult="+f1.txtHResultOp.value,"", "dialogWidth:380px; dialogHeight: 180px; center: Yes; help: No; scroll:Yes; resizable: No; status: No;");
}

function MM_preloadImages() 
{ //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//Funciones para el Progrees Bar
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////

var duration=5 // duración del progrees en segundos
var _progressWidth = 50;	// Tiempo para desplgegar el progres tamaño de la forma

var _progressBar = new String("");
var _progressEnd = 10;
var _progressAt = 0;

//Centra el progrees bar
function ProgressCreate(end) {
	_progressEnd = end;
	_progressAt = 0;

	progress.className = 'show';
	progress.style.left = (document.body.clientWidth/2) - (progress.offsetWidth/2);
	progress.style.top = document.body.scrollTop+(document.body.clientHeight) - (progress.offsetHeight);
	ProgressUpdate();
}

//Oculta el progrees baar 
function ProgressDestroy() {
	progress.className = 'hide';
}

// Incrementa el progress 
function ProgressStepIt() {
	_progressAt++;
	if(_progressAt > _progressEnd) _progressAt = _progressAt % _progressEnd;
	ProgressUpdate();
}

// Actualiza el progress con el estado actual
function ProgressUpdate() {
	var n = (_progressWidth / _progressEnd) * _progressAt;
	var bar = dialog.bar;
	var temp = _progressBar.substring(0, n);
	bar.value = temp;
}

// Inicializa progress
function ProgressStart() {
	ProgressCreate(10);
	window.setTimeout("Click()", 1);
}

function Click() {
	ProgressStepIt();
	window.setTimeout("Click()", (duration-1)*1000/10);
}

function CallJS(jsStr) { 
  return eval(jsStr)
}


/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////
//Fin Progrees Bar
/////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////

function ValidaNumero(pCtrl)
{	//---------------------------------------------------------------------
	//Descripcion: El valor de la caja de texto debe ser numero, de lo
	//			   contrario, lo transforma en CERO
	//Elaboro    : Lorenzo Mendoza - 14 de noviembre del 2002
	//---------------------------------------------------------------------
	valueTMP = pCtrl.value;
	if (isNaN(valueTMP)) { pCtrl.value = 0; }
}

function ValidaTexto(pCtrl)
{	//---------------------------------------------------------------------
	//Descripcion: El valor de la caja de texto lo convierte en mayusculas
	//Elaboro    : Lorenzo Mendoza - 15 de abril del 2004
	//---------------------------------------------------------------------
	var strString =new String(pCtrl.value);
	pCtrl.value= strString.toUpperCase();
}

//***********************************************************
// Esta función hace las funciones del Trim comun de VB
//***********************************************************
function Trim(obj)
{
	var checkSpace = " ";
	var checkStr = obj.value;
	var posRight = -1;
	var posLeft = -1;
	var cadena = "";
		for(i=0;i<checkStr.length;i++)
		{
			chkchar=checkStr.charAt(i);
			if (chkchar != checkSpace)
			{
				posRight = i;
				break;
			}
		}
		for(i=(checkStr.length - 1);i>=0;i--)
		{
			chkchar=checkStr.charAt(i);
			if (chkchar != checkSpace)
			{
				posLeft = i;
				break;
			}
		}
		for(i=0;i<checkStr.length;i++)
		{
			chkchar=checkStr.charAt(i);
			if ((i  >= posRight) && (i <= posLeft))
			{
				cadena = cadena + chkchar;
			}
		}
	obj.value = cadena;
	return(cadena);
}

function SendPrintRep(TypeProcess)
{	//Envia a imprimir las repetitivas
	var objArgument = new Array (0);
	var sTitle='';
	
	if(xmlDoc.XMLDocument.documentElement.selectSingleNode("//MODEL_DATA") == null) 
	{	alert('No hay datos a imprimir.');
		return(false); 
	}
	SetStatWork("Preparando información, porfavor espere...");
	objArgument[0]=xmlDoc.xml;
	objArgument[1]=document.parentWindow.parent.frames("fraHeader").document.getElementById("idClient").value
	window.showModalDialog("PrintRep.php?TypeProcess="+TypeProcess, objArgument, "dialogWidth:750px; dialogHeight: 520px; center: Yes; help: No; scroll:Yes; resizable: No; status: No;");
	SetStatWork("");
	return (true);
}

function SerchString(pstrserch, pstrFind)
{	//Descripcion: regresa true si encuentra la primera instancia de la cadena solicitada
	//Elaboro    : Freddy Jarquín - 19 de Diciembre del 2002
	lenFind=pstrFind.length;
	contFind=0;
	for (var i=0;i<pstrserch.length;i++){
			if (pstrserch.charAt(i)==pstrFind.charAt(contFind))
			{	contFind=contFind+1;
				if(contFind==lenFind) return(true);
			}
			else{
				contFind=0;
			}
		}  		
	return(false)
}

function SetStatWork(sTextStat, sLevel)
{	//sLevel = Opcional, solo se usa cuando se llama desde un "iframe"
	if(sLevel!=null)
		sParent = document.parentWindow.parent.parent;
	else
		sParent = document.parentWindow.parent;
	
	if(sTextStat=="")
	{	//Limpiando, entonces muestra el ticker
		//sParent.frames("fraStatWork").trOperation.style.display='none';
		sParent.frames("fraStatWork").trTicker.style.display='';
	}
	else
	{	//Muestra el mensaje de la opreacion y oculta el ticker
		//sParent.frames("fraStatWork").trOperation.style.display='';
		//sParent.frames("fraStatWork").trTicker.style.display='none';
		//sParent.frames("fraStatWork").spStatWork.innerHTML=sTextStat;
	}
		
}
function ShowHelp()
{	var sTypePage;
	sTypePage=document.parentWindow.parent.frames("fraHeader").intTipoOpcion;
	window.open("help/help.php?typePage="+sTypePage,'help','width=780,height=450,resizable=yes, scrollbars=Yes, center=Yes' );
}

function closeframe(blnDisplay)
{	var oFrame = window.parent.frames.fraGeneral1;
	if (blnDisplay)
	{
		oFrame.cols = "0,*";
		document.parentWindow.parent.fraHeader.imgMenu.style.display="";
	}
	else
	{
		oFrame.cols = "185,*";
		document.parentWindow.parent.fraHeader.imgMenu.style.display="none";
	}
	
}
function CurrencyFormat(pdblValue, pblnSet)
{	pdblValue = deletechar(pdblValue,"$");
	pdblValue = deletechar(pdblValue,",");
	if (isNaN(pdblValue)) { pdblValue = 0; }
	if (pdblValue==0) { pdblValue = 0; }
	if (pblnSet) 
	{ pdblValue = Curformat(pdblValue);}
	return(pdblValue);
}

function deletechar(pstrString, pstrFind)
{
	var strtemp;
	strtemp="";
	var strString =new String(pstrString);
	for (var i=0;i<strString.length;i++){
		if (strString.charAt(i)!=pstrFind)
		strtemp += strString.charAt(i);			
	}  		
	return (strtemp);
}

function Curformat(pdblvalue)
{	var strvalue =new String(pdblvalue);		
	var index=serchchar(strvalue,'.');
	var strresult='$';	
	if (index == -1)
	{	var mod = (strvalue.length % 3);
		var length = strvalue.length-mod;
		var cicles = parseInt(length/3)
		if (mod>0){ strresult += substr(strvalue,0,mod);}
		if (mod<length && mod!=0){ strresult += ',';}
		for (i=0;i<cicles;i++)
		{ strresult += substr(strvalue,((i*3)+mod),3)	
		  if (i+1<cicles){strresult+=','}	
		}
		return(strresult+'.00');			
	}
	else
	{ var strvalue2 = substr(strvalue,0,index-1)
	  var strdecimals = substr(strvalue,index-1,strvalue.length-(index-1))	
		var mod = (strvalue2.length % 3);
		var length = strvalue2.length-mod;
		var cicles = parseInt(length/3)
		if (mod>0){ strresult += substr(strvalue2,0,mod);}
		if (mod<length && mod!=0){ strresult += ',';}
		for (i=0;i<cicles;i++)
		{ strresult += substr(strvalue2,((i*3)+mod),3)	
		  if (i+1<cicles){strresult+=','}	
		}
		return(strresult + strdecimals);			
	}
}



function blankRowSelected()
{
	origColor='';

	if (oldRow != null)
	{
	for(intCountCol=0;intCountCol<oldRow.childNodes.length;intCountCol++)
		{
			oldRow.childNodes[intCountCol].style.backgroundColor=origColor;
		}
	}
}

function procTipoPersona()
{
if (document.getElementsByName("cmbTPersona")[0].selectedIndex==0)
	{
		trTitle.cells[5].style.display="none";
		trTitle.cells[6].style.display="";
		trTitle.cells[7].style.display="";
		trTitle.cells[8].style.display="";
		for(intCountTr=0;intCountTr<numRows;intCountTr++)
		{
			document.getElementById("tr" + intCountTr).cells[5].style.display="none";
			document.getElementById("tr" + intCountTr).cells[6].style.display="";
			document.getElementById("tr" + intCountTr).cells[7].style.display="";
			document.getElementById("tr" + intCountTr).cells[8].style.display="";
		}
	}
	else
	{
		trTitle.cells[5].style.display="";
		trTitle.cells[6].style.display="none";
		trTitle.cells[7].style.display="none";
		trTitle.cells[8].style.display="none";
		for(intCountTr=0;intCountTr<numRows;intCountTr++)
		{
			document.getElementById("tr" + intCountTr).cells[5].style.display="";
			document.getElementById("tr" + intCountTr).cells[6].style.display="none";
			document.getElementById("tr" + intCountTr).cells[7].style.display="none";
			document.getElementById("tr" + intCountTr).cells[8].style.display="none";
		}
	}
}

function nextPage()
{
	buttonBack.style.visibility="visible";
	globalNodeFirst=globalNodeFirst+numRows;
	if ((TotalNodes-globalNodeFirst)>numRows)
	{
		buttonNext.style.visibility="visible";
		sizeArray=numRows;
		globalSequence=globalSequence+numRows;
	}
	else
	{
		buttonNext.style.visibility="hidden";
		sizeArray=TotalNodes-globalSequence;
		globalSequence=TotalNodes;
	}
	parent.document.frames("fraStatUseReg").document.location="blank.php";
	blankRowSelected();
	moveRegister(globalNodeFirst,sizeArray);
}

function backPage()
{
	buttonNext.style.visibility="visible";
	globalNodeFirst=globalNodeFirst-numRows;
	if ((TotalNodes-globalNodeFirst)<TotalNodes)
	{
		buttonBack.style.visibility="visible";
		globalSequence=globalNodeFirst+numRows;
	}
	else
	{
		buttonBack.style.visibility="hidden";
		globalSequence=numRows;
	}
	parent.document.frames("fraStatUseReg").document.location="blank.php";
	blankRowSelected();
	moveRegister(globalNodeFirst,numRows);
}

function SelRow(sCtrol)
{	//Descripcion: Selecciona un renglon especifico y quita la marca del anterior
	//Elaboro    : Lorenzo Mendoza - 11 de octubre del 2002

	//var origColor=sCtrol.parentNode.parentNode.style.backgroundColor;
	var origColor='';
	sCtrol.parentNode.parentNode.style.backgroundColor='#FFCC66';
	if (oldRow != null)// && oldRow.id!=sCtrol.parentNode.parentNode.id)
	{	
		for(intCountCol=0;intCountCol<oldRow.childNodes.length;intCountCol++)
		{
			oldRow.childNodes[intCountCol].style.backgroundColor='#FFFFFF';
		}

	}
		
	for(intCountCol=0;intCountCol<sCtrol.parentNode.parentNode.childNodes.length;intCountCol++)
	{

		sCtrol.parentNode.parentNode.childNodes[intCountCol].style.backgroundColor='#FFCC66';
	}
	oldRow=sCtrol.parentNode.parentNode;
}


function moveRegister(firstReg,sizeArray)
{
	var strColorstatus;
	cleanScreen();

	for(intCountNodesGral=0;intCountNodesGral<sizeArray;intCountNodesGral++)
	{
			document.getElementById("lblDiv" + eval((intCountNodesGral*10)+1)).innerHTML= objNode[intCountNodesGral+firstReg].selectSingleNode("F1").text;
			document.getElementById("lblDiv" + eval((intCountNodesGral*10)+2)).innerHTML = objNode[intCountNodesGral+firstReg].selectSingleNode("F0").text;
	     	document.getElementById("lblDiv" + eval((intCountNodesGral*10)+3)).innerHTML = objNode[intCountNodesGral+firstReg].selectSingleNode("F3").text;
			document.getElementById("lblDiv" + eval((intCountNodesGral*10)+4)).innerHTML = objNode[intCountNodesGral+firstReg].selectSingleNode("F4").text;			
			document.getElementById("lblDivMensaje" + intCountNodesGral).innerHTML=substr(objNode[intCountNodesGral+firstReg].selectSingleNode("F2").text,0,50)+"......";			
			document.getElementById("tr" + intCountNodesGral).style.display='';
	}
}

function GetDate(objDate)
{	//-------------------------------------------------
	//Descripcion: Levanta el calendario en forma modal
	//Autor: Lorenzo Mendoza
	//-------------------------------------------------
	var objArguments = new Array (0);
	objArguments[0]=-1;
	dialogWindow = window.showModalDialog("Calendar.php",objArguments, "dialogWidth:250px; dialogHeight: 190px; center: Yes; help: No; scroll:Yes; resizable: No; status: No;");
	if (objArguments[0]!= -1) objDate.value = objArguments[0];
}

function KeyValidate(e, TypeValida)
{	//Descripcion: Valida que no pueda capturar caracteres raros
	//Elaboro    : Freddy Jarquín 14/04/2003
	e    = window.event;
	if( TypeValida== "1")
		chars= "<>&";
	else if(TypeValida== "2")
		chars= "";
	if(chars.indexOf(String.fromCharCode(e.keyCode))!=-1) window.event.keyCode=0;
}

function ResizeDiv()
{	
	if (window.parent.frames.fraGeneral1.children.fraContent.width > 0)
	{	
		dvSubHeader.style.width = window.parent.frames.fraGeneral1.children.fraContent.width-3;
	}
}

function bgMouserOver(sRow)
{	if (sRow.style.backgroundColor!='#003F40')
		sRow.style.backgroundColor='#99CCFF'; //'#8AAFA7'; 
}

function bgMouseOut(sRow)
{	if (sRow.style.backgroundColor=='#99CCFF') //#8AAFA7
		sRow.style.backgroundColor== '#003F40'; //'#003F40';
	else
		sRow.style.backgroundColor='';
}
function bmDown(src,clase)
{	if (!src.contains(event.fromElement))
		src.className = clase;
}

function bmOvr(src,clase)
{	if (!src.contains(event.fromElement))
	{	src.style.cursor = 'hand';
		src.className = clase;
	}
}

function bmOut(src,clase)
{	if (!src.contains(event.toElement))
	{	src.style.cursor = 'default';
		src.className = clase;
	}
}
/*
function bgMouserOver(sRow)
{	if (sRow.style.backgroundColor!='#003F40')
	{	sRow.style.backgroundColor='#8AAFA7'; }
}
function bgMouseOut(sRow)
{	if (sRow.style.backgroundColor=='#8AAFA7')
		sRow.style.backgroundColor=='#003F40';
	else
		sRow.style.backgroundColor='';
}
*/
function SelectAll(sRef)
{
   	sRef.select();
}

function AplyFormat(pCtrl,DefDecimal)
{	var valueTMP=0;
	if(DefDecimal=='')
		DefDecimal=2;
	pCtrl.value= CurrencyFormat(pCtrl.value, false);
	var objNumber = new Number(pCtrl.value);
	pCtrl.value =roundit(objNumber, DefDecimal);
	valueTMP = pCtrl.value;
	if (isNaN(valueTMP))
	{	pCtrl.value = 0; valueTMP=0;	}
	else
	{	pCtrl.value= CurrencyFormat(pCtrl.value, true); }
}

function roundit(Num, Places)
{
   if (Places > 0) {
      if ((Num.toString().length - Num.toString().lastIndexOf('.')) > (Places + 1)) {
         var Rounder = Math.pow(10, Places);
         return Math.round(Num * Rounder) / Rounder;
      }
      else return Num;
   }
   else return Math.round(Num);
}

function esInt(n)
{
	//Valida que si un numero es entero
	var x=quitaCeros(n);
	var x2=x+"";
	x=parseInt(x)+"";
	if(x!=x2) return true;
	else return false;
}
		
function quitaCeros(n)
{
	var x=0;n=n+""; for(var i=0;i<n.length;i++)
	if(n.substring(i,(i+1))==0) x++;
	else return(n.substring(x,n.length));
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 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 beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

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;  	
}


