 function formatCurrency(num, decimalPlace, simboloMoneda) {
 var demcimalPlaces = '00000000000000000000000';
 var decimal = 1+demcimalPlaces.substr(1,decimalPlace);
 
 num = num.toString().replace(/\$|\,/g,'');
 if(isNaN(num))
  num = "0";
  
 sign = (num == (num = Math.abs(num)));
 num = Math.floor(num*decimal+0.50000000001);
 cents = num%decimal;
 num = Math.floor(num/decimal).toString();
 
 if(cents<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))+'.'+num.substring(num.length-(4*i+3));
  
 return (((sign)?'':'-') + num.replace(',','.') + ((decimalPlace > 0)?',' + cents:'') 
+ ' ' + simboloMoneda);
 }

 function ValorEnPesetas(pTotal){
  return formatCurrency(pTotal, 0,'');
 }
 
 function ValorEnEuros(pTotal){
  return formatCurrency(pTotal / 166.386, 2,'');
 }
 
 function EscribeValorEnCasilla(pElemName, pElemValue){
  document.forms[gvFormName].elements[pElemName].value = pElemValue;  
 }
 function TextoEnFormatoXml(pXmlNodeName, pXmlNodeValue){
  return '<'+String(pXmlNodeName)+'>'+String(pXmlNodeValue)+'</'+String(pXmlNodeName)+'>';
 }
 
 function DevuelveValorCasillaEnFormatoXml(pElemName){
  return String(TextoEnFormatoXml(pElemName, DevuelveValorCasilla(pElemName)));
 }
 
 function DevuelveValorCasillaEnFormatoNumerico(pElemName){
	var vVal = DevuelveValorCasilla(pElemName);
	
	if(IT_EsNumero(vVal))
		return Number(vVal);
	else
		return 0;
 }
 
 function DevuelveValorCasilla(pElemName){
  return document.forms[gvFormName].elements[pElemName].value;
 }
  
 function EscribeDentroIdHTML(PElemName, pNewValue){
  document.getElementById(PElemName).innerHTML=pNewValue;
 }
 
 function SiCeroBorra(){
  var vValue='',i,args=SiCeroBorra.arguments;
  
  for (i=1; i<(args.length-1); i+=2) { 
   if(vValue=='')vValue=args[0];      
   vInput=args[i]; vTipo=args[i+1];
   if (Number(vValue) <= 0 && vInput !== ''){
    if (vTipo == 'casilla')
     EscribeValorEnCasilla(vInput, '');
    if (vTipo == 'idHTML')
     EscribeDentroIdHTML(vInput, '');   
   }
  }
 }
 
function EsNumero(event){
    var nav4 = window.Event ? true : false; 
    var key = nav4 ? event.which : event.keyCode; 
    if ((key<48 || key>57) && key != 8 && key != 0){
		return false;
	} 
}


function IT_EsNumero (pValor){
	var checkOK = 	"0123456789.,-";
	var checkStr = pValor;

	if(!isUndefined(checkStr))
		return IT_EsCheckOk(checkStr,checkOK);
	else
		return false;
}

function IT_EsCheckOk(checkStr,checkOK){
	 var allValid = true;
	 for (i = 0;  i < checkStr.length;  i++)
	 {
	 	ch = checkStr.charAt(i);
    		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
		        		break;
    			if (j == checkOK.length)
			{
			      	allValid = false;
				break;
			}
  	}
	return allValid;
}

function isUndefined(a) {
    return typeof a == 'undefined';
} 


function EsValorEnRango(vVal, vRangInf, vRangSup){
  if(vVal>=vRangInf && vVal<=vRangSup)
	return true;
  else
	return false;
}