function showcalender(str,datFormat){
	var w="<html><head><title>Select Date</title></head><body onLoad='jWDAddData()' leftmargin=11 topmargin=10 marginwidth=10 marginheight=10>\r\n<table width=175 cellpadding=2 cellspacing=0 border=0><tr>"
		w=w + "<td align=left><form name='f'><select name='mon' width=50 onChange='javascript:jWDUpdateMiddleString(self.document.h.yea.options[self.document.h.yea.options.selectedIndex].value,self.document.f.mon.options[self.document.f.mon.options.selectedIndex].value)'><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option></select></form></td>"
		w=w + "<td align=right><FORM name='h'><select name='yea' width=60 onChange='javascript:jWDUpdateMiddleString(self.document.h.yea.options[self.document.h.yea.options.selectedIndex].value,self.document.f.mon.options[self.document.f.mon.options.selectedIndex].value)'><option>&nbsp;</option><option>&nbsp;</option><option>&nbsp;</option></select></form></td>"
		w=w + "</tr></table><span id='DatePart' style=\"left:11px;position:absolute;top:42px;\"></span></body></html><" + "script language='Javascript'>" 
		w=w + "function jWDAddData(){\r\n"
		w=w + "var m=Array('','Jan','Feb','März','Apr','Mai','Juni','Juli','Aug','Sept','Okt','Nov','Dez');\r\n"
		w=w + "var D=new Date(),Y=D.getFullYear(),M=D.getMonth()+1,i=0;self.document.f.mon.options.length=0;\r\n"
		w=w + "for(i=1;i<m.length;i++)self.document.f.mon.options[self.document.f.mon.options.length]=new Option(m[i],i);\r\n"
		w=w + "self.document.f.mon.options[M-1].selected=true;self.document.h.yea.options.length=0;\r\n"    
		w=w + "for(i=1900;i<2101;i++)self.document.h.yea.options[self.document.h.yea.options.length]=new Option(i,i);\r\n"
		w=w + "self.document.h.yea.options[Y-1900].selected=true;jWDUpdateMiddleString(Y,M);}\r\n"
		w=w + "function jWDUpdateMiddleString(Year,Month){\r\n"
		w=w + "var w=window.opener.getcalendertable(Year,Month);"
		w=w + "if(self.document.all)document.all['DatePart'].innerHTML=w;"
		w=w + "else{self.document.DatePart.document.open();self.document.DatePart.document.write(w);self.document.DatePart.document.close();}}\r\n"
		w=w + "function jWDGiveDate(Day){window.opener." + str + ".value=opener.createdate(self.document.h.yea.options[self.document.h.yea.options.selectedIndex].value,self.document.f.mon.options[self.document.f.mon.options.selectedIndex].value,Day,'" + datFormat + "');window.close();}\r\n</SCRIPT>" 
	var l=open('','DateBox',"scrollbars=no,titlebar=no,height=180,width=190,top="+((screen.height)/2 - 100)+",left="+((screen.width)/2 - 100));
	l.document.write(w);
	l.document.close();
	l.focus();
}

function createdate(Year,Month,Day,datFormat){
	var m=new Array('','Jan','Feb','März','Apr','Mai','Juni','Juli','Aug','Sept','Okt','Nov','Dez');
	if(datFormat==0){
		return Day + '.' + Month + '.' + Year;
	}
	if(datFormat==1){
		return Day + '/' + Month + '/' + Year;
	}
	if(datFormat==2){
		return Month + '.' + Day + '.' + Year;
	}
	if(datFormat==3){
		return Month + '/' + Day + '/' + Year;
	}
	if(datFormat==4){
		return Day + ' ' + m[Month] + ' ' + Year;
	}
	if(datFormat==5){
		return m[Month] + ' ' + Day + '.' + Year;
	}
	if(datFormat==6){
		return m[Month] + ' ' + Day + '/' + Year;
	}	
	return Day + '.' + Month + '.' + Year;
}

function getcalendertable(Year,Month){
	var D=new Date(),L=new Array('So','Mo','Di','Mi','Do','Fr','Sa');			
	D.setYear(Year);D.setMonth(Month-1);D.setDate(1);
	var C=D.getDay(),i,w;
	w='<TABLE width=170 cellpadding=2 cellspacing=0 border=0><TR bgcolor=#E0E0E0>';
	for(i=0;i<7;i++) w+='<TD align=center><FONT face=arial size=2><B>' + L[i] + '</B></FONT></TD>';
	w+='</TR><TR>';
	if(C>0) for(i=0;i<C;i++) w+='<TD bgcolor=#F0F0F0>&nbsp;</TD>';
	for(i=1;i<=daycount(Year,Month);i++){
		w+="<TD bgcolor=#F0F0F0 align=center><A href=javascript:jWDGiveDate('" + i + "') style='TEXT-DECORATION: none'><FONT color=black size=1 face=arial>" + i + "</FONT></A></TD>";
		C++;
		if(C==7){w+='</TR><TR>';C=0;}
	}
	if(C>0){
		for(i=C;i<7;i++) w+='<TD bgcolor=#F0F0F0>&nbsp;</TD>';
		w+='</TR>';
	}
	else
		w+='<TD height=1></TD><TR>';
	return w + '</TABLE>';
}

function daycount(Year,Month){
	var D=new Array(0,31,28,31,30,31,30,31,31,30,31,30,31);
	if(Month==2&&((Year%100==0 && Year%400==0)||(Year%100!=0 && Year%4==0))) return 29;
	return D[Month];		
}

function mid(exp,start,len){
	if(start<0||len<0)return "";
	var L=String(exp).length;
    return String(exp).substring(start,(start+len>L)?L:start+len);
}

function instrrev(exp,find){
	var e=exp.length,f=String(find).length,i;
	if(e>=f&&f>0) for(i=e-1;i>=0;i--) if(exp.substr(i,f)==find) return ++i;
	return 0;
}