var __cargando_solo_imagen = "<table border='0' cellspacing='0' cellpading='0'><tr><td><img src='../images/gif/cargando.gif' border='0' align='center' /></td></tr></table>";
var __cargando = "<table border='0' cellspacing='0' cellpading='0'><tr><td><img src='../images/gif/cargando.gif' border='0' align='center' /></td><td>Cargando ...</td></tr></table>";
var __funciontraerlote;
var __UBIGEO = '150141';

function resize(){
	resizeTo(1000,720);
	js_ventana = jQuery(window);
	js_ventana_height = js_ventana.height();
	js_ventana_width = js_ventana.width();
	
	jQuery('#divContenidoMunicipio')
	.css(
		{ width:js_ventana_width
		, height:js_ventana_height - 25 - (jQuery('#tblModTitulo').height() + jQuery('#divBarraEstado').height())
		, top:jQuery('#tblModTitulo').height() + 25
		}
	);
	jQuery('#divBarraEstado').css({ width:js_ventana_width, top:js_ventana_height - jQuery('#divBarraEstado').height()});
}


function innerHTML(dom, html){
	document.getElementById(dom).innerHTML = html;
}

function dom_focus(){
	jQuery('input').each(function(){ if( !jQuery(this).hasClass('sololectura') && jQuery(this).attr('readonly') ) jQuery(this).addClass('sololectura'); });
}

function mensaje_error(error){
	alert(error);
}

function mensaje_DB(error){
	alert(error);
}

function error_servidor(sistema, programa, mensajes, usuario){
	//,direcciones:"jjaimes@msb.gob.pe:Juan Jaimes Alvarado|jjaimesa@gmail.com:Juan Jaimes"
	jQuery.post(
		'../mail_error_programas.php'
		,{ cache : Math.random()
		 , modulo : sistema
		 , programa : programa
		 , error : mensajes
		 , usuario : usuario
		 , direcciones : 'jjaimes@msb.gob.pe:Juan Jaimes Alvarado'
		}
		,function(html){
			_html = html.split('&yen;');
			if( _html[1]!='1' ){
				alert('Ocurrio un error en los procesos del Servidor\n\nPongase en contacto con el Administrador del Sistema.\nindicando el siguiente problema:\n'+mensajes);
			} else{
				alert('Ocurrio un error en los procesos del Servidor.\nse ha procedido a enviar un correo al área de Sistemas para el analisis de lo ocurrido'); 
			}
		}
	);
}

function mensaje_proceso_basedatos(mensaje)
{
	if( jQuery.trim(mensaje) == '' ) mensaje = 'Ocurri\xF3 un error al momento de procesar en el Servidor';
	jAlert(mensaje, 'Mensaje del Servidor');
}

function mensaje(mensaje){ jAlert(mensaje, 'Mensaje del Sistema'); }

function confirmar(mensaje){
	jConfirm(mensaje, '<span>Confirmaci&oacute;n</span>', function(r){ return r; });
}

function retorna_acceso(pOpcion, pIdSistema, pUsuario)
{
	var retorna = false;
	var _url = '/intranet/index/accesos';
	var _data = { cache: Math.random() * 999999 
				, opcion : pOpcion
				, idsistema : pIdSistema
				, usuario : pUsuario
				};
	jQuery.ajaxSetup({async:false});
	jQuery.post(_url, _data,
		function(_rtnAjax){
			var _html=_rtnAjax.split('&yen;');
			if( jQuery.trim(_html[0]) != '' ){ alert(_html[0]); return false; }
			if(  jQuery.trim(_html[1]) == 1 ) retorna = true;			
			return retorna;
		}
	);
	return retorna;
	
	/*var retorna = false;
	jQuery.ajaxSetup({async:false});
	jQuery.post(
		'/sig/accesos.php'
		,{ cache : Math.random() * 99999
		, opcion : pOpcion
		, idsistema : pIdSistema
		, usuario : pUsuario
		}
		,function(html){
			var html=html.split("&yen;");
			if( jQuery.trim(html[0]) != "" ){ alert(html[0]); return false; }
			if( html[1]==1 ) retorna = true;
		}
	);
	return retorna;*/
}

function sinacceso()
{
	mensaje('<center>Usted no cuenta con accesos suficientes<br />para ejecutar \xE9sta opci\xF3n</center>')
}

function AbrirVentana(capa, titulo, ancho, alto){
	if( jQuery('#Vent_'+capa).length == 0 )
		jQuery('body').prepend('<div id="Vent_'+capa+'" title="'+titulo+'" class="flora" style="margin:0px;"><div id="'+capa+'" style="overflow:auto; overflow-x:hidden;"></div></div>');
		
	jQuery('#'+capa).css({ width:ancho, height:alto - 25 });

	innerHTML(capa, '');

	jQuery('#Vent_'+capa)
	.dialog(
		{
			modal:true
			,overlay:{ opacity: 0.7, background: 'black' }
			,width:ancho
			,height:alto
			,resizable:false
		}
	);
}

function CerrarVentana(capa){
	jQuery('#Vent_'+capa).dialog('close');
}

function mueveReloj(){ 
    momentoActual = new Date();
    dia = momentoActual.getDay();
    mes = momentoActual.getMonth();
    hora = momentoActual.getHours();
    minuto = momentoActual.getMinutes();
    segundo = momentoActual.getSeconds();
	
	if( hora < 10 ) hora = "0" + hora;
	if( minuto < 10 ) minuto = "0" + minuto;
	if( segundo < 10 ) segundo = "0" + segundo;

    horaImprimible = hora + ":" + minuto + ":" + segundo;

    jQuery('#spanHora').html(horaImprimible);
	
	setTimeout('mueveReloj()', 1000);
}

function fecha_a_texto(fecha)
{
	if(fecha==''){ return '';}
	else{
		var texto='';
		var mes= new Array('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre');
		texto += fecha.substring(0,2) + ' de ' ;
		texto += mes[parseInt(fecha.substr(3,2)) - 1];
		texto += ' del ' + fecha.substring(6,10);
		return texto;
	}
}

function numero(num){
	if( num=='' ) num=0;
	return parseFloat(quitar_comas(num));
}

function repetir(cadena, veces){
	var cadena_repetida = '';
	for(var i = 0; i < veces; i++){ 
		cadena_repetida += cadena ;
	}
	return cadena_repetida;
}

function llenar_ceros(cadena, largo){
	return repetir(cadena, largo - cadena.length);
}

function geturlparam( name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

function traerLote(pCoords){
	pCoords=pCoords.toString();
	var _url = _raiz + '/general/lote/traerlotexcoordenada';
	var _data = { cache: Math.random() * 999999 
				, pCoords: pCoords
		 		};
	jQuery.post(_url, _data,
		function(html){
			eval(__funciontraerlote + '(' + jQuery.trim(html) + ');');
		}
	);	
}

var Utf8 = {
    // public method for url encoding
    encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // public method for url decoding
    decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

function isDefined(o){return typeof o!="undefined";}

function sprintf(){
	if(!arguments||arguments.length<1||!RegExp||!arguments[0]){return;}
	var str=arguments[0];
	for(var i=1;i<arguments.length;i++){
		var _165=isDefined(arguments[i])?arguments[i]:"";
		str=str.replace(new RegExp("%"+i,"g"),_165);
	}
	return str;
}


/***
MODO DE USO
var input = "'30' -> decimal: %d / bin = %b / oct = %o / hex = %x / HEX = %X";
alert(sprintf(input, 30, 30, 30, 30, 30));

$sql = sprintf("SELECT nombre FROM tabla WHERE id = %d;",$numero);
mysql_query($sql);
**/
function sprintf_completa() {
	if (!arguments || arguments.length < 1 || !RegExp) {
		return;
	}
	var str = arguments[0];
	var re = /([^%]*)%('.|0|\x20)?(-)?(\d+)?(\.\d+)?(%|b|c|d|u|f|o|s|x|X)(.*)/;
	var a = b = [], numSubstitutions = 0, numMatches = 0;
	while (a = re.exec(str)) {
		var leftpart = a[1], pPad = a[2], pJustify = a[3], pMinLength = a[4];
		var pPrecision = a[5], pType = a[6], rightPart = a[7];
		numMatches++;
		if (pType == '%') {
			subst = '%';
		} else {
			numSubstitutions++;
			if (numSubstitutions >= arguments.length) {
				alert('Error! Not enough function arguments (' + (arguments.length - 1) + ', excluding the string)\nfor the number of substitution parameters in string (' + numSubstitutions + ' so far).');
			}
			var param = arguments[numSubstitutions];
			var pad = '';
			if (pPad && pPad.substr(0,1) == "'") pad = leftpart.substr(1,1);
			else if (pPad) pad = pPad;
			var justifyRight = true;
			if (pJustify && pJustify === "-") justifyRight = false;
			var minLength = -1;
			if (pMinLength) minLength = parseInt(pMinLength);
			var precision = -1;
			if (pPrecision && pType == 'f') precision = parseInt(pPrecision.substring(1));
			var subst = param;
			if (pType == 'b') subst = parseInt(param).toString(2);
			else if (pType == 'c') subst = String.fromCharCode(parseInt(param));
			else if (pType == 'd') subst = parseInt(param) ? parseInt(param) : 0;
			else if (pType == 'u') subst = Math.abs(param);
			else if (pType == 'f') subst = (precision > -1) ? Math.round(parseFloat(param) * Math.pow(10, precision)) / Math.pow(10, precision): parseFloat(param);
			else if (pType == 'o') subst = parseInt(param).toString(8);
			else if (pType == 's') subst = param;
			else if (pType == 'x') subst = ('' + parseInt(param).toString(16)).toLowerCase();
			else if (pType == 'X') subst = ('' + parseInt(param).toString(16)).toUpperCase();
		}
		str = leftpart + subst + rightPart;
	}
	return str;
}

var vbCr = "\r";
var vbLf = "\n";
var vbCrLf = vbCr+vbLf;
var vbTab = "\t";

function IsEmpty(aTextField) {
   if ((aTextField.value.length==0) ||
   (aTextField.value==null)) {
      return true;
   }
   else { return false; }
}	


function Left(s, n){
	// Devuelve los n primeros caracteres de la cadena
	if(n>s.length)
		n=s.length;
		
	return s.substring(0, n);
}


function Right(s, n){
	// Devuelve los n últimos caracteres de la cadena
	var t=s.length;
	if(n>t)
		n=t;
		
	return s.substring(t-n, t);
}


function Mid(s, n, c){
	// Devuelve una cadena desde la posición n, con c caracteres
	// Si c = 0 devolver toda la cadena desde la posición n
	
	var numargs=Mid.arguments.length;
	
	// Si sólo se pasan los dos primeros argumentos
	if(numargs<3)
		c=s.length-n+1;
		
	if(c<1)
		c=s.length-n+1;
	if(n+c >s.length)
		c=s.length-n+1;
	if(n>s.length)
		return "";
		
	return s.substring(n-1,n+c-1);
}


function LTrim(s){
	// Devuelve una cadena sin los espacios del principio
	var i=0;
	var j=0;
	
	// Busca el primer caracter <> de un espacio
	for(i=0; i<=s.length-1; i++)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(j, s.length);
}


function RTrim(s){
	// Quita los espacios en blanco del final de la cadena
	var j=0;
	
	// Busca el último caracter <> de un espacio
	for(var i=s.length-1; i>-1; i--)
		if(s.substring(i,i+1) != ' '){
			j=i;
			break;
		}
	return s.substring(0, j+1);
}


function AllTrim(s){
	// Quita los espacios del principio y del final
	return LTrim(RTrim(s));
}


function InStr(n, s1, s2){
	// Devuelve la posición de la primera ocurrencia de s2 en s1
	// Si se especifica n, se empezará a comprobar desde esa posición
	// Sino se especifica, los dos parámetros serán las cadenas
	var numargs=InStr.arguments.length;
	
	if(numargs<3)
		return n.indexOf(s1)+1;
	else
		return s1.indexOf(s2, n)+1;
}


function RInStr(n, s1, s2){
	// Devuelve la posición de la última ocurrencia de s2 en s1
	// Si se especifica n, se empezará a comprobar desde esa posición
	// Sino se especifica, los dos parámetros serán las cadenas
	var numargs=RInStr.arguments.length;
	
	if(numargs<3)
		return n.lastIndexOf(s1)+1;
	else
		return s1.lastIndexOf(s2, n)+1;
}


function Space(n){
	// Devuelve una cadena con n espacios
	var t="";
	
	for(var i=1; i<=n; i++)
		t=t+" ";
	
	return t;
}


function jString(n, c){
	// Devuelve n veces el caracter c
	var t="";
	
	for(var i=1; i<=n; i++)
		t=t+c;
	return t;
}


function UCase(s){
	// Devuelve la cadena convertida a mayúsculas
	return s.toUpperCase();
}

function LCase(s){
	// Devuelve la cadena convertida en minúsculas
	return s.toLowerCase();
}


function Len(s){
	// Devuelve la longitud de la cadena s
	return s.length;
}


function StrReverse(s){
	// Invierte la cadena
	var i=s.length;
	var t="";
	
	while(i>-1){
		t=t+ s.substring(i,i+1);
		i--;
	}
	return t;
}


function vacio(q) {
	for ( i = 0; i < q.length; i++ ) {
		if ( q.charAt(i) != " " ) {
			return true
		}
	}
	return false
}


function Error500(){
	alert("MENSAJE DE ERROR: "+Mid(http.responseText,InStr(1,http.responseText,"Tipo de error")+18,InStr(1,http.responseText,"Tipo de explorador")-InStr(1,http.responseText,"Tipo de error")-38));
	//alert("MENSAJE DE ERROR: "+Mid(http.responseText,InStr(1,http.responseText,"Tipo de error")+18,1000));
}

//
//-----------------------------------------------------------------------------
// Fin del código con las funciones de conversión de VBScript para JavaScript
//-----------------------------------------------------------------------------
//

//-->
function AbreCierraDiv(cCapa){
	if (eval(cCapa + ".style.display == 'none'") ) { eval(cCapa + ".style.display = ''") ;}
	else { eval(cCapa + ".style.display = 'none'") ;}
}


//Remueve los espacios de la izquierda
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;
}


//Remueve los espacios de la derecha
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;  	
}


//Remueve los espacios
function Trim( str ) {
	var resultStr = "";
	
	resultStr = TrimLeft(str);
	resultStr = TrimRight(resultStr);
	
	return resultStr;
}


//Validar números
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


//Validar números integrales
function IsInt( numstr, allowNegatives ) {
	// Return immediately if an invalid value was passed in
	if (numstr+"" == "undefined" || numstr+"" == "null" || numstr+"" == "")	
		return false;

	// Default allowNegatives to true when undefined or null
	if (allowNegatives+"" == "undefined" || allowNegatives+"" == "null")	
		allowNegatives = true;

	var isValid = true;

	// 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 case for negative numbers (first char == '-').   
	for (i = 0; i < numstr.length; i++) {
    	if (!((numstr.charAt(i) >= "0") && (numstr.charAt(i) <= "9") || (numstr.charAt(i) == "-"))) {
       	isValid = false;
       	break;
		} else if ((numstr.charAt(i) == "-" && i != 0) || 
				(numstr.charAt(i) == "-" && !allowNegatives)) {
       	isValid = false;
       	break;
      }
         	         	       
   } // END for   
   
   	return isValid;
}  // end IsInt


//Obtener el valor de un botón radio
function GetRadioValue( radioObject ) { 
	var value = null;

	// Validate parameter value
//***	if (radioObject+"" == "undefined" || radioObject == null)
	if (radioObject == null)
		return null;

	for (var i=0; i < radioObject.length; i++) { 
		if (radioObject[i].checked) { 
			value = radioObject[i].value;
			break;
		} 
	} // end for loop 
	
	return value;
} 


//Validar caracteres alfanuméricos
function IsAlphaNum( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z"))))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   
   	return isValid;
}  // end IsAlphaNum


//Obtener Fecha actual
Date.prototype.getActualDay = GetActualDay;
function GetActualDay() { 
return this.getDay() + 1;
}


//Redondear numeros
function redondear(cantidad, decimales) {
var cantidad = parseFloat(cantidad);
var decimales = parseFloat(decimales);
decimales = (!decimales ? 2 : decimales);
return Math.round(cantidad * Math.pow(10, decimales)) / Math.pow(10, decimales);
}  


//Pregunta
function pregunta() {
   return Confirmar("¿Estás seguro?");
}


//Solo permite numeros
function soloNumeros(evt) { 
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0)); 
    if (charCode > 31 && (charCode < 48 || charCode > 57)) { 
        alert("Solo se permiten números en este campo."); 
        return false; 
    } 
    return true; 
 } 
 

 
 
//Retorna 1 si es cero
function si0entonces1(valor) { 
	if (valor == 0) return 1;
	return valor
}

// Retorna cadena reemplazada
function replaceChars(entry) {
	out = "&"; // reemplaza la letra a
	add = "|"; // por la letra ba
	temp = "" + entry;

	//bucle mientras se encuentre la cadena de busqueda
	while (temp.indexOf(out)>-1)
	{
		//pos es igual a la posicion donde se encuentra la coincidencia
		pos=temp.indexOf(out);
		//coge la cadena desde el principio hasta la primera coincidencia, añade
		// el caracter de reemplazo, y coge el resto de cadena, realizando de esta
		// mantera el reemplazo
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
	}
	return temp;
}

//Objeto oNumero
function oNumero(numero)
{
	//Propiedades 
	this.valor = numero || 0
	this.dec = -1;
	//Métodos 
	this.formato = numFormat;
	this.ponValor = ponValor;
	
	//Definición de los métodos 
	function ponValor(cad)
	{
		if (cad =='-' || cad=='+') return
		if (cad.length ==0) return
		if (cad.indexOf('.') >=0)
				this.valor = parseFloat(cad);
		else 
				this.valor = parseInt(cad);
	} 
	
	function numFormat(dec, miles)
	{
		var num = this.valor, signo=3, expr;
		var cad = ""+this.valor;
		var ceros = "", pos, pdec, i;
		for (i=0; i < dec; i++)
		ceros += '0';
		pos = cad.indexOf('.')
		if (pos < 0)
				cad = cad+"."+ceros;
		else
				{
				pdec = cad.length - pos -1;
				if (pdec <= dec)
						{
						for (i=0; i< (dec-pdec); i++)
								cad += '0';
						}
				else
						{
						num = num*Math.pow(10, dec);
						num = Math.round(num);
						num = num/Math.pow(10, dec);
						cad = new String(num);
						}
				}
		pos = cad.indexOf('.')
		if (pos < 0) pos = cad.lentgh
		if (cad.substr(0,1)=='-' || cad.substr(0,1) == '+') 
					 signo = 4;
		if (miles && pos > signo)
				do{
						expr = /([+-]?\d)(\d{3}[\.\,]\d*)/;
						cad.match(expr);
						cad=cad.replace(expr, RegExp.$1+','+RegExp.$2);
						}
		while (cad.indexOf(',') > signo)
				if (dec<0) cad = cad.replace(/\./,'')
						return cad;
	}
}//Fin del objeto oNumero:


function formato_numero(oNumeroSimple, oDecimales, oComa){
	var numero = new oNumero(oNumeroSimple);
	return numero.formato(oDecimales, oComa);
}


function formatAsMoney(mnt) { 
mnt -= 0; 
mnt = (Math.round(mnt*100))/100; 
return (mnt == Math.floor(mnt)) ? mnt + '.00' 
: ( (mnt*10 == Math.floor(mnt*10)) ? 
mnt + '0' : mnt); 
}


function formatCurrency(num) { 
	num = num.toString().replace(/$|,/g,''); 
	if(isNaN(num)) 
	num = "0"; 
	sign = (num == (num = Math.abs(num))); 
	num = Math.floor(num*100+0.50000000001); 
	cents = num%100; 
	num = Math.floor(num/100).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 + '.' + cents); 
}


function formatCurrencyMoney(num) { 
	num = num.toString().replace(/$|,/g,''); 
	if(isNaN(num)) 
	num = "0"; 
	sign = (num == (num = Math.abs(num))); 
	num = Math.floor(num*100+0.50000000001); 
	cents = num%100; 
	num = Math.floor(num/100).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 + '.' + cents); 
}


function quitar_comas(entry) {
	out = ","; // reemplaza la letra a
	add = ""; // por la letra ba
	temp = "" + entry;

	//bucle mientras se encuentre la cadena de busqueda
	while (temp.indexOf(out)>-1)
	{
		//pos es igual a la posicion donde se encuentra la coincidencia
		pos=temp.indexOf(out);
		//coge la cadena desde el principio hasta la primera coincidencia, añade
		// el caracter de reemplazo, y coge el resto de cadena, realizando de esta
		// mantera el reemplazo
		temp = "" + (temp.substring(0, pos) + add + temp.substring((pos + out.length), temp.length));
	}

	return temp;
}

function devuelve_random() {
	return parseInt(Math.random()*9999999999);
}

function llena_espacios(cadena, longitud){
	var nueva_cadena = $.trim(cadena);
	var espacios = longitud - nueva_cadena.length;
	if (espacios > 0) for (i=0; i<=espacios; i++) nueva_cadena += " ";
	return nueva_cadena;
}

function ceros_izq(cadena, longitud){
	var nueva_cadena = "";
	var espacios = longitud - $.trim(cadena).length;
	if (espacios > 0) for (i=1; i<=espacios; i++) nueva_cadena += "0";
	return nueva_cadena + $.trim(cadena);
}

//FUNCION PARA EJECUTAR JAVASCRIPT
function execFuncModule(code){
	var dj_global = this;
	if (window.execScript){
		window.execScript(code);
		return null;
	}
	return dj_global.eval ? dj_global.eval(code) : eval(code);
}
