function Fecha() {
	if (Fecha.arguments[1]!=undefined) {
		Fecha.arguments[1]--;
	}
	switch (Fecha.arguments.length) {
		case 7:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1], Fecha.arguments[2], Fecha.arguments[3], Fecha.arguments[4], Fecha.arguments[5], Fecha.arguments[6]);
			break;
		case 6:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1], Fecha.arguments[2], Fecha.arguments[3], Fecha.arguments[4], Fecha.arguments[5]);
			break;
		case 5:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1], Fecha.arguments[2], Fecha.arguments[3], Fecha.arguments[4]);
			break;
		case 4:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1], Fecha.arguments[2], Fecha.arguments[3]);
			break;
		case 3:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1], Fecha.arguments[2]);
			break;
		case 2:
			this.fecha=new Date(Fecha.arguments[0], Fecha.arguments[1]);
			break;
		case 1:
			this.fecha=new Date(Fecha.arguments[0]);
			break;
		default:
			this.fecha=new Date();
			break;
	
	}
}

Fecha.prototype.NOMBRE_DIAS=new Array("Lunes", "Martes", "Miércoles", "Jueves", "Viernes", "Sábado", "Domingo");
Fecha.prototype.NOMBRE_MES=new Array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre");

Fecha.prototype.isLeapYear=function() {
	return (this.getYear()%4==0) && (((this.getYear()%100==0) && (this.getYear()%400==0)) || (this.getYear()%100!=0));
}
Fecha.prototype.getYear=function() {
	return this.fecha.getFullYear();
}

Fecha.prototype.getMonth=function() {
	return this.fecha.getMonth()+1;
}
Fecha.prototype.getMonthName=function() {
	return this.NOMBRE_MES[this.getMonth()-1];
}
Fecha.prototype.getMonthDays=function() {
	var DIAS_MES=new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	return DIAS_MES[this.getMonth()-1] + ((this.getMonth()==2)?this.isLeapYear():0);
}

Fecha.prototype.getMonthDay=function() {
	return this.fecha.getDate();
}
Fecha.prototype.getWeekDay=function() {
	return (this.fecha.getDay()?this.fecha.getDay()-1:6);
}
Fecha.prototype.getDayName=function() {
	return this.NOMBRE_DIAS[this.getWeekDay()];
}

Fecha.prototype.getHours=function() {
	return this.fecha.getHours();
}
Fecha.prototype.getMinutes=function() {
	return this.fecha.getMinutes();
}
Fecha.prototype.getSeconds=function() {
	return this.fecha.getSeconds();
}

Fecha.prototype.getDate=function(format) {
	var date;
	if (format=="dd-mm-yyyy") {
		date=((this.getMonthDay()<10)?"0":"") + this.getMonthDay() + "-" + ((this.getMonth()<10)?"0":"") + this.getMonth() + "-" + this.getYear();
	} else {
		date=this.getYear() + "-" + ((this.getMonth()<10)?"0":"") + this.getMonth() + "-" + ((this.getMonthDay()<10)?"0":"") + this.getMonthDay();
	}
	return date; 
}
Fecha.prototype.getFullDate=function() {
	return this.getDate() + " " + ((this.getHours()<10)?"0":"") + this.getHours() + ":" + ((this.getMinutes()<10)?"0":"") + this.getMinutes() + ":" + ((this.getSeconds()<10)?"0":"") + this.getSeconds();
}

Fecha.prototype.getMonthWeeks=function() {
	var firstDay=new Fecha(this.getYear(),this.getMonth());
	return Math.ceil((firstDay.getWeekDay()+this.getMonthDays())/7);
}
Fecha.prototype.getMonthWeek=function() {
	var firstDay=new Fecha(this.getYear(),this.getMonth());
	return Math.ceil((firstDay.getWeekDay()+this.getMonthDay())/7);
}
Fecha.prototype.getYearWeek=function() {
	var firstDay=new Fecha(this.getYear(),1);
	var days=0;
	for (var i=1; i<this.getMonth();i++) {
		var date=new Fecha(this.getYear(),i);
		days+=date.getMonthDays();
	}
	days+=this.getMonthDay();		
	return Math.ceil((firstDay.getWeekDay()+days)/7);
}