/* These prototypes are  made by Jojoxx  (johan@jojoxx.net) and are
free to use for none commercial applications as long as these lines
remain intact. For questions or comments, contact me at the address
above.                                            www.jojoxx.net */

Date.Months=new Array('januari','februari','mars','april','maj','juni','juli','augusti','september','oktober','november','december');
Date.MonthsShort=new Array('jan','feb','mar','apr','maj','jun','jul','august','sep','okt','nov','dec');
Date.Days=new Array('söndag','måndag','tisdag','onsdag','torsdag','fredag','lördag');
Date.DaysShort=new Array('sön','mån','tis','ons','tor','fre','lör');
Date.prototype.format=function(str){
	var a=str.split('%%'); for(var i=0;i<a.length;i++){
	a[i]=a[i].replace(/%d/g,this.getDate());
	a[i]=a[i].replace(/%D/g,("0"+this.getDate()).substring(("0"+this.getDate()).length-2));
	a[i]=a[i].replace(/%Y/g,this.getFullYear());
	a[i]=a[i].replace(/%y/g,(this.getFullYear()+"").substring((this.getFullYear()+"").length-2));
	a[i]=a[i].replace(/%W/g,Date.Days[this.getDay()]);
	a[i]=a[i].replace(/%w/g,Date.DaysShort[this.getDay()]);
	a[i]=a[i].replace(/%M/g,Date.Months[this.getMonth()]);
	a[i]=a[i].replace(/%m/g,Date.MonthsShort[this.getMonth()]);
	a[i]=a[i].replace(/%n/g,this.getMonth()+1);
	a[i]=a[i].replace(/%N/g,("0"+(this.getMonth()+1)).substring(("0"+(this.getMonth()+1)).length-2));
	a[i]=a[i].replace(/%s/g,this.getSeconds());
	a[i]=a[i].replace(/%S/g,("0"+this.getSeconds()).substring(("0"+this.getSeconds()).length-2));
	a[i]=a[i].replace(/%i/g,this.getMinutes());
	a[i]=a[i].replace(/%I/g,("0"+this.getMinutes()).substring(("0"+this.getMinutes()).length-2));
	a[i]=a[i].replace(/%h/g,this.getHours());
	a[i]=a[i].replace(/%H/g,("0"+this.getHours()).substring(("0"+this.getHours()).length-2));
	}
	return(a.join('%%'));
}
Date.prototype.getWeek=function(){
	var nywd=(new Date(this.getFullYear(),0,1).getDay()==0)?7:new Date(this.getFullYear(),0,1).getDay();
	var w=Math.ceil((this.getTime()+nywd*86400000-new Date(this.getFullYear(),0,1).getTime())/(604800000))
	if(nywd>4){w--;}
	if(w==0){ return new Date(this.getFullYear()-1,11,31).getWeek()}
	if(w==53 && new Date(this.getFullYear()+1,0,1).getDay()<=4){w=1}
	return w
}

// http://www.lysator.liu.se/alma/alma.cgi
