Date.prototype.getMySQL = function(withTime){
	
	if(isNaN(this.getFullYear()) || isNaN(this.getMonth()) || isNaN(this.getDate()) || isNaN(this.getHours()) || isNaN(this.getMinutes())){
		return null;
	}
	
	if(typeof(withTime) == "undefined"){
		withTime = false;
	}
	var mysqlDate = "";
	
	mysqlDate += this.getFullYear();
	mysqlDate += "-";
	if(this.getMonth() * 1 < 9){
		mysqlDate += "0";
	}
	mysqlDate += this.getMonth() * 1 + 1;
	mysqlDate += "-";
	if(this.getDate() * 1 < 9){
		mysqlDate += "0";
	}
	mysqlDate += this.getDate();
	
	if(!withTime){
		mysqlDate += " ";
		mysqlDate += this.getHours();
		mysqlDate += ":";
		mysqlDate += this.getMinutes();
		mysqlDate += ":";
		mysqlDate += this.getSeconds();
	}
	
	return mysqlDate;
}

Date.prototype.setMySQL = function(currDateTime){
	
	if(currDateTime != ""){
		var types = currDateTime.split(" ");
		if(types.length > 1){
			var currTime = types[1].split(":");
			this.setHours(currTime[0]);
			this.setMinutes(currTime[1]);
			this.setSeconds(currTime[2]);
		}
		var currDate = types[0].split("-");
		this.setFullYear(currDate[0]);
		this.setMonth(currDate[1] - 1);
		this.setDate(currDate[2]);
	}
}

Date.prototype.getTranslatedDayOfWeek = function(day, fullName){
	if(typeof(fullName) == "undefined" || !fullName){
		var Days = new Array("П", "В", "С", "Ч", "П", "С", "Н");
	}else{
		var Days = new Array("Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота", "Неделя");
	}
	
	if(typeof(day) == "undefined"){
		day = this.getDay();
	}
	
	return Days[day];
}
Date.prototype.getTranslatedMonth = function(month){
	var Months = new Array("Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември");
	
	if(typeof(month) == "undefined"){
		month = this.getMonth();
	}
	return Months[month];
}

Date.prototype.getTranslatedDate = function(){
	var trDate = '';
	trDate += this.getDate() + " ";
	trDate += this.getTranslatedMonth() + " ";
	trDate += this.getFullYear() + " ";
	trDate += this.getHours() + ":";
	trDate += this.getMinutes() + "";
	
	return trDate;
}

Date.prototype.getNumberOfDays = function(){
	var date = new Date();
	date.setFullYear(this.getFullYear());
	date.setMonth(this.getMonth());
	date.setDate(32);
	
	return (32 - date.getDate());
}

Date.prototype.compareWeekDays = function(monthDay, weekDay){
	var date = new Date();
	date.setFullYear(this.getFullYear());
	date.setMonth(this.getMonth());
	date.setDate(monthDay);
	
	return (date.getDay() == weekDay);
}
