Date.prototype.asString=function(){var d=this.getDate().toString();var m=(this.getMonth()+1).toString();var y=this.getFullYear().toString();return(y+"-"+m+"-"+d)};Date.prototype.add=function(sInterval,iNum){var dTemp=this;if(!sInterval||iNum==0){return dTemp}switch(sInterval.toLowerCase()){case"ms":dTemp.setMilliseconds(dTemp.getMilliseconds()+iNum);break;case"s":dTemp.setSeconds(dTemp.getSeconds()+iNum);break;case"mi":dTemp.setMinutes(dTemp.getMinutes()+iNum);break;case"h":dTemp.setHours(dTemp.getHours()+iNum);break;case"d":dTemp.setDate(dTemp.getDate()+iNum);break;case"mo":dTemp.setMonth(dTemp.getMonth()+iNum);break;case"y":dTemp.setFullYear(dTemp.getFullYear()+iNum);break}return dTemp};Date.prototype.fillCombos=function(cboday,cbomonth,cboyear){this.fillCombo(cboyear,"year");this.fillCombo(cbomonth,"month");
this.fillCombo(cboday,"day")};Date.prototype.fillCombo=function(cbo,t){
	var type=(typeof(t)=="undefined")?((cbo.length>3)?((cbo.length>12)?"day":"month"):"year"):t;	
	var value=0;
	switch(type){
	case"day":
		value = (parseInt(this.getDate())-1);
		if(value==-1) value=0;
		cbo.selectedIndex=value;break;
	case"month":
		value = (parseInt(this.getMonth()));
		
		cbo.selectedIndex=value;
	break;
	case"year":for(n=0;n<cbo.options.length;n++){if(cbo.options[n].value==this.getFullYear()){cbo.selectedIndex=n}}break}};Date.prototype.setToDate=function(s){
		
		var dTemp=this;
		var a=s.split("-");
		try{
			dTemp.setFullYear(a[0]);
dTemp.setMonth(parseInt(Math.abs(a[1]))-1);dTemp.setDate(parseInt(Math.abs(a[2])));}catch(e){}return dTemp};Date.prototype.DaysDiff=function(dtcompare){var diff=Math.floor(this.getTime()/86400000)-Math.floor(dtcompare.getTime()/86400000);var days=diff;return days};

Date.prototype.addUnit = function( /**String*/unit, /**Number*/value ) {   
  
   unit = unit.replace( /s$/ ).toLowerCase();   
  
   switch ( unit ) {   
      case "year":   
         this.setYear( this.getYear() + value );   
         break;   
      case "month":   
         this.setMonth( this.getMonth() + value )   
         break;   
      case "week":   
         this.setTime( this.getTime() + value * 604800000 );   
         break;   
      case "day":   
         this.setTime( this.getTime() + value * 86400000 );   
         break;   
      case "hour":   
         this.setTime( this.getTime() + value * 3600000 );   
         break;   
      case "minute":   
         this.setTime( this.getTime() + value * 60000 );   
         break;   
      case "second":   
         this.setTime( this.getTime() + value * 1000 );   
         break;   
     
      default:   
         this.setTime( this.getTime() + value );   
         break;   
   }   
  
   return this;   
};   

Date.prototype.subtract = function( /**String*/unit, /**Number*/value ) {   
  
   unit = unit.replace( /s$/ ).toLowerCase();   
  
   switch ( unit ) {   
      case "year":   
         this.setYear( this.getYear() - value );   
         break;   
      case "month":   
         this.setMonth( this.getMonth() - value )   
         break;   
      case "week":   
         this.setTime( this.getTime() - value * 604800000 );   
         break;   
      case "day":   
         this.setTime( this.getTime() - value * 86400000 );   
         break;   
      case "hour":   
         this.setTime( this.getTime() - value * 3600000 );   
         break;   
      case "minute":   
         this.setTime( this.getTime() - value * 60000 );   
         break;   
      case "second":   
         this.setTime( this.getTime() - value * 1000 );   
         break;   
      case "nanosecond":   
         // Fall Through   
      default:   
         this.setTime( this.getTime() - value );   
         break;   
   }   
};   
  
Date.prototype.truncate = function( /**String*/to ) {   
  
   unit = unit.replace( /s$/ ).toLowerCase();   
  
   switch ( unit ) {   
      case "year":   
         this.setMonth( 0, 1 );   
         this.setHours( 0, 0, 0, 0 );   
         break;   
      case "month":   
         this.setDate( 1 );   
         this.setHours( 0, 0, 0, 0 );   
         break;   
      case "week":   
         this.subtract( "day", this.getDay() );   
         break;   
      case "day":   
         this.setMinutes( 0, 0, 0, 0 );   
         break;   
      case "hour":   
         this.setMinutes( 0, 0, 0 );   
         break;   
      case "minute":   
         this.setSeconds( 0, 0 );   
         break;   
      case "second":   
         this.setMilliseconds( 0 );   
         break;   
      default:   
         break;   
   }   
  
   return this;   
};  
