//CREATE AN ARRAY
function SetNameArray(item)
{
this.length = item
return this
}
//SET MONTH AND DAY NAME ARRAYS
function SetNameArray(item)
{
this.length = item
return this
}
//SET MONTH AND DAY NAME ARRAYS
Month = new SetNameArray(12)
Month[1] = "enero"
Month[2] = "febrero"
Month[3] = "marzo"
Month[4] = "abril"
Month[5] = "mayo"
Month[6] = "junio"
Month[7] = "julio"
Month[8] = "agosto"
Month[9] = "septiembre"
Month[10] = "octubre"
Month[11] = "noviembre" 
Month[12] = "diciembre"
Day = new SetNameArray(7)
Day[1] = "Domingo"
Day[2] = "Lunes"
Day[3] = "Martes"
Day[4] = "Miércoles"
Day[5] = "Jueves"
Day[6] = "Viernes"
Day[7] = "Sábado"
//CALC THE DATE INFORMATION
function TodaysDate(theDate)
{
var thisday = Day[theDate.getDay() + 1]
var thismonth = Month[theDate.getMonth() + 1]
var todayDate=new Date()
var thisdate=todayDate.getDate()
var thisyear=todayDate.getYear()
thisyear = thisyear % 100;
thisyear = ((thisyear < 50) ? (2000 + thisyear) : (1900 + thisyear))
return thisday + " " + thisdate + " de " + thismonth + " de "  + thisyear
}


//funcion para calcular la posicion de un dato en un arreglo de despliegue de reportes por meses
function calc_indice(key){
	var temp;
	temp=yacreados.indexOf("|"+key+"=")+key.length+2; //inicio del indice
	return(yacreados.substring(temp,yacreados.indexOf("|",temp+1)));
}

//funcion para insertar un dato al arreglo de despliegue de reportes por meses
function ins_al_arreglo(clavereng,col,dato_ins){
	var temp,indice;
	if (yacreados.indexOf("|"+clavereng+"=")<0){ //si no existe el arreglo
		maxindice++;
		yacreados=yacreados+"|"+clavereng+"="+maxindice+"|";  //añadirlo a la lista de ya creados
		dato[maxindice]= new Array;  //crear el arreglo
		indice=maxindice;
	}
	else{ //si ya existia el arreglo
		indice=calc_indice(clavereng);
	}
	dato[indice][col]=dato_ins;
}


// funcion para separar numeros por miles con comas
function comas(num){
	var entero="0";
	if (!num){ num="0"; }
	num=num+""; // convertir la variable a cadena
	var pos_punto = num.indexOf("."); // determinar la posicion del punto
	if (pos_punto>-1){
		entero=num.substring(0,pos_punto);
		num=num.substring(pos_punto,num.length);
	}
	else{
		entero=num;
		num="";
	}
	while(entero.length>0){
		if (entero.length>3){
			num=","+entero.substring(entero.length-3,entero.length)+num;
			entero=entero.substring(0,entero.length-3);
		}
		else{
			num=entero+""+num;
			entero="";
		}
	}
	return(num);
}
