Date.prototype.YearPrev = function (){ this.setYear(this.getFullYear()-1); return this; }
Date.prototype.YearNext = function (){ this.setYear(this.getFullYear()+1); return this; }
Date.prototype.MonthPrev = function (){ this.setMonth(this.getMonth()-1); return this; }
Date.prototype.MonthNext = function (){ this.setMonth(this.getMonth()+1); return this; }
Date.prototype.DayPrev = function (){ this.setDate(this.getDate()-1); return this; }
Date.prototype.DayNext = function (){ this.setDate(this.getDate()+1); return this; }
Date.prototype.getDaysPerMonth = function (){ 
	var m=this.getMonth();
	var n=this.DPM[m];
	if((m==1)&&(this.getFullYear()%4)==0)
		n++;
	return n;
}
Date.prototype.DPM=[31,28,31,30,31,30,31,31,30,31,30,31];
Date.prototype.DoW=["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота","воскресенье"];
Date.prototype.Months=["январь","февраль","март","апрель","май","июнь","июль","август","сентябрь","октябрь","ноябрь","декабрь"]; 
Date.prototype.MonthStr = function (){ 
	return this.Months[this.getMonth()]; 
}
Date.prototype.getDayOfWeek = function (nday){ 
	var d=new Date(this);
   if(nday)
		d.setDate(nday);
   var n=d.getDay()-1;
	if(n<0)
	   n+=7;
	return n; 
}
Date.prototype.DayOfWeekStr = function (){ 
	return this.DoW[this.getDay()]; 
}
Date.prototype.getMonthWeekNum = function (nday){ 
	if(!nday)
		nday=this.getDate();
	var d=new Date(this);
	d.setDate(1);
	var n=d.getDay();
	var offs=(n==0)?5:(n-2);
	return Math.round((nday+offs)/7-0.5);
}
Date.prototype.getWeekDay = function (nweek,nday){
	var d=new Date(this);
	d.setDate(1);
	var n=d.getDay();
	var offs=(n==0)?5:(n-2);
	n=(nweek*7+nday-offs);
	if(n>this.DPM[this.getMonth()] || n<0)
	   n=-1;
	return n;
}
Date.prototype.toStringYMD = function (){
	var yy,mm,dd,m,d;
	yy=this.getFullYear().toString();
	m=this.getMonth(); mm=(m+1).toString();
	d=this.getDate(); dd=d.toString();
	if(m<9)
	   mm="0"+mm;
	if(d<10)
	   dd="0"+dd;
	return yy+"-"+mm+"-"+dd;
}
Date.prototype.toStringDMY = function (){
	var yy,mm,dd,m,d;
	yy=this.getFullYear().toString();
	m=this.getMonth(); mm=(m+1).toString();
	d=this.getDate(); dd=d.toString();
	if(m<9)
	   mm="0"+mm;
	if(d<10)
	   dd="0"+dd;
	return dd+"-"+mm+"-"+yy;
}
Date.prototype.getDateStampDiff = function (dt){ 
	return this.getDateStamp()-dt.getDateStamp();
}
Date.prototype.getDateStamp = function (){ 
	var d=new Date(this);
	return (d.getFullYear()*100+d.getMonth())*100+d.getDate();
}

