// calendar.js
// created 2004-00-00 by fadilku


function calendar(element, lang, format )
{
	if(!format)
		format = "dd.mm.yyyy";
	if(!lang)
	{
		lang = "en";
		format = "yyyy/mm/dd";
	}	
	var win = window.open("about:blank", "Calendar", "width=210px, height=220px, status=no, resize=no, top=500px, left=180px");
	win.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\r\n<html>\r\n\t<head>\r\n\t\t<title>Calendar</title>\r\n\t\t<script type='text/javascript'>\r\n\t\t\tvar element = opener.document.getElementById('"+element+"');\r\n\t\t\tvar format = '"+format+"';\r\n\t\t\tvar day;\r\n\t\t\tvar month;\r\n\t\t\tvar year;\r\n\t\t\tvar MonthName;\r\n\t\t\tvar DayName;\r\n\t\t\tvar aktiv;\r\n\t\t\tvar thisD;\r\n\t\t\tvar thisM;\r\n\t\t\tvar thisY;\r\n\t\t\tvar formDat = element.value.replace(/ /ig,'') != '' && element.value.match(/(\\d{1,2})(\\/|\\.|\\-|\\,)(\\d{1,2})(\\/|\\.|\\-|\\,)(\\d{4})/ig) ? element.value.replace(/ /ig,'') : format;\r\n\t\t\tvar spliter = format.match(/\\/|\\-|\\.|\\,/);\r\n\t\t\tvar dIndex;\r\n\t\t\tvar mIndex;\r\n\t\t\tvar yIndex;\r\n\t\t\tvar f = format.split(spliter);\r\n\t\t\tfor(var i=0; i<f.length; ++i)\r\n\t\t\t{\r\n\t\t\t\tif(f[i] == 'dd')\r\n\t\t\t\t\tdIndex = i;\r\n\t\t\t\tif(f[i] == 'mm')\r\n\t\t\t\t\tmIndex = i;\r\n\t\t\t\tif(f[i] == 'yyyy')\r\n\t\t\t\t\tyIndex = i;\r\n\t\t\t}\r\n\t\t\tformDat = formDat.split(spliter);\r\n\t\t\tnowDat = new Date();\r\n\t\t\tif(formDat[dIndex].charAt(0) == '0')\r\n\t\t\t\tformDat[dIndex] = formDat[dIndex].charAt(1);\r\n\t\t\tif(formDat[mIndex].charAt(0) == '0')\r\n\t\t\t\tformDat[mIndex] = formDat[mIndex].charAt(1);\r\n\t\t\tday = parseInt(formDat[dIndex]) ? parseInt(formDat[dIndex]) : nowDat.getDate();\r\n\t\t\tmonth = parseInt(formDat[mIndex]) ? parseInt(formDat[mIndex]) : nowDat.getMonth()+1;\r\n\t\t\tyear = parseInt(formDat[yIndex]) ? parseInt(formDat[yIndex]) : (nowDat.getYear() < 999 ? nowDat.getYear()+1900 : nowDat.getYear());\r\n\t\t\tswitch('"+lang+"')\r\n\t\t\t{\r\n\t\t\t\tcase 'en':\r\n\t\t\t\t\tMonthName = new Array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');\r\n\t\t\t\t\tDayName = new Array('Mo','Tu','We','Th','Fr','Sa','Su');\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'ba':\r\n\t\t\t\t\tMonthName = new Array ('Januar', 'Februar', 'Mart', 'April', 'Maj', 'Juni', 'Juli', 'August', 'Septembar', 'Oktobar', 'Novembar', 'Decembar');\r\n\t\t\t\t\tDayName = new Array('Po','Ut','Sr','Ce','Pe','Su','Ne');\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tcase 'de':\r\n\t\t\t\t\tMonthName = new Array	('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');\r\n\t\t\t\t\tDayName = new Array('Mo','Di','Mi','Do','Fr','Sa','So');\r\n\t\t\t\t\tbreak;\r\n\t\t\t\tdefault:\r\n\t\t\t\t\tMonthName = new Array	('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');\r\n\t\t\t\t\tDayName = new Array('Mo','Di','Mi','Do','Fr','Sa','So');\r\n\t\t\t}\r\n\t\t\tfunction setValues()\r\n\t\t\t{\r\n\t\t\t\tvar date = new Date(year, month-1, 1);\r\n\t\t\t\tvar start = date.getDay();\r\n\t\t\t\tif(start == 0) start = 7;\r\n\t\t\t\tvar stop = 31;\r\n\t\t\t\tif(month==4 || month==6 || month==9 || month==11)\r\n\t\t\t\t\t--stop;\r\n\t\t\t\tif(month==2)\r\n\t\t\t\t{\r\n\t\t\t\t\tstop = stop-3;\r\n\t\t\t\t\tif((year%4)==0)\r\n\t\t\t\t\t\t++stop;\r\n\t\t\t\t\tif(year%100==0)\r\n\t\t\t\t\t\t--stop;\r\n\t\t\t\t\tif(year%400==0)\r\n\t\t\t\t\t\t++stop;\r\n\t\t\t\t}\r\n\t\t\t\tdocument.getElementById('m').replaceChild(document.createTextNode(MonthName[month-1]), document.getElementById('m').firstChild);\r\n\t\t\t\tdocument.getElementById('y').replaceChild(document.createTextNode(year), document.getElementById('y').firstChild);\r\n\t\t\t\tdocument.getElementById('mon').replaceChild(document.createTextNode(DayName[0]),document.getElementById('mon').firstChild);\r\n\t\t\t\tdocument.getElementById('tue').replaceChild(document.createTextNode(DayName[1]),document.getElementById('tue').firstChild);\r\n\t\t\t\tdocument.getElementById('wed').replaceChild(document.createTextNode(DayName[2]),document.getElementById('wed').firstChild);\r\n\t\t\t\tdocument.getElementById('thu').replaceChild(document.createTextNode(DayName[3]),document.getElementById('thu').firstChild);\r\n\t\t\t\tdocument.getElementById('fri').replaceChild(document.createTextNode(DayName[4]),document.getElementById('fri').firstChild);\r\n\t\t\t\tdocument.getElementById('sat').replaceChild(document.createTextNode(DayName[5]),document.getElementById('sat').firstChild);\r\n\t\t\t\tdocument.getElementById('sun').replaceChild(document.createTextNode(DayName[6]),document.getElementById('sun').firstChild);\r\n\n\t\t\t\tstop += start;\r\n\t\t\t\tvar d = 1;\r\n\t\t\t\tfor(var i=1; i<43; ++i)\r\n\t\t\t\t{\r\n\t\t\t\t\tdocument.getElementById('d'+i).style.color = 'black';\r\n\t\t\t\t\tif(start<=i && stop>i)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdatastr = d;\r\n\t\t\t\t\t\tif(day+start-1 == i && day>=0)\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tdocument.getElementById('d'+i).style.color = 'red';\r\n\t\t\t\t\t\t\tthisD = document.getElementById('d'+i);\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t\t++d;\r\n\t\t\t\t\t\tdocument.getElementById('d'+i).style.cursor = 'pointer';\r\n\t\t\t\t\t}\r\n\t\t\t\t\telse\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tdatastr = ' ';\r\n\t\t\t\t\t\tdocument.getElementById('d'+i).style.cursor = 'default';\r\n\t\t\t\t\t}\r\n\t\t\t\t\tdata = document.createTextNode(datastr);\r\n\t\t\t\t\tdocument.getElementById('d'+i).replaceChild(data, document.getElementById('d'+i).firstChild);\r\n\t\t\t\t}\r\n\t\t\t\tshowDate();\r\n\t\t\t}\r\n\t\t\tfunction showDate()\r\n\t\t\t{\r\n\t\t\t\tdatumString = format;\r\n\t\t\t\tdatumString = datumString.replace(/dd/,(day<10 ? '0' : '')+day);\r\n\t\t\t\tdatumString = datumString.replace(/mm/,(month<10 ? '0' : '')+month);\r\n\t\t\t\tdatumString = datumString.replace(/yyyy/,year);\r\n\t\t\t\t//datumString = document.createTextNode((day<10 ? '0' : '')+day+'-'+(month<10 ? '0' : '')+month+'-'+year);\r\n\t\t\t\tdocument.getElementById('datum').replaceChild(document.createTextNode(datumString), document.getElementById('datum').firstChild);\r\n\t\t\t}\r\n\t\t\tfunction stop()\r\n\t\t\t{\r\n\t\t\t\twindow.clearTimeout(aktiv);\r\n\t\t\t\taktiv = null;\r\n\t\t\t}\r\n\t\t\tfunction setNewDate(element)\r\n\t\t\t{\r\n\t\t\t\tif(element.firstChild.data != ' ')\r\n\t\t\t\t{\r\n\t\t\t\t\tthisD.style.color = 'black';\r\n\t\t\t\t\telement.style.color = 'red';\r\n\t\t\t\t\tthisD=element;\r\n\t\t\t\t\tday = element.firstChild.data;\r\n\t\t\t\t\tshowDate();\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tfunction setNewMonth(element)\r\n\t\t\t{\r\n\t\t\t\tif(!element)\r\n\t\t\t\t\telement = thisM;\r\n\t\t\t\telse\r\n\t\t\t\t\tthisM = element;\r\n\t\t\t\tif(element.id == 'pm')\r\n\t\t\t\t\tmonth = month-1<1?12:month-1;\r\n\t\t\t\tif(element.id == 'nm')\r\n\t\t\t\t\tmonth = month+1>12?1:month+1\r\n\t\t\t\tsetValues();\r\n\t\t\t\taktiv = window.setTimeout('setNewMonth(null)', '100');\r\n\t\t\t}\r\n\t\t\tfunction setNewYear(element)\r\n\t\t\t{\r\n\t\t\t\tif(!element)\r\n\t\t\t\t\telement = thisY;\r\n\t\t\t\telse\r\n\t\t\t\t\tthisY = element\r\n\t\t\t\tif(element.id == 'py')\r\n\t\t\t\t\t--year;\r\n\t\t\t\tif(element.id == 'ny')\r\n\t\t\t\t\t++year;\r\n\t\t\t\tsetValues();\r\n\t\t\t\taktiv = window.setTimeout('setNewYear(null)', '100');\r\n\t\t\t}\r\n\t\t\tfunction setDate()\r\n\t\t\t{\r\n\t\t\t\telement.value = document.getElementById('datum').firstChild.data;\r\n\t\t\t\twindow.close();\r\n\t\t\t}\r\n\t\t</script>\r\n\t</head>\r\n\t<body bgcolor='#8A90A4' style='margin-left:0px; margin-right:0px;'>\r\n\t\t<table border='0' cellpadding='0' cellspacing='0' width='210px' align='center'>\r\n\t\t\t<tr align='center'>\r\n\t\t\t\t<td colspan='4' height='25px' bgcolor='#8A90A4' align='center'>\r\n\t\t\t\t\t<table border='0' cellpadding='0' cellspacing='1px' style='border:1px solid white; color:white; font-family:verdana; font-size:11px; font-weight:bold' width='90%'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' id='pm' onmousedown='setNewMonth(this)' onmouseup='stop()' onmouseout='stop()' style='cursor:pointer'><b>&nbsp;&lsaquo;&nbsp;</b></td>\r\n\t\t\t\t\t\t\t<td align='center' id='m' width='100%'>&#160;</td>\r\n\t\t\t\t\t\t\t<td align='center' id='nm' onmousedown='setNewMonth(this)' onmouseup='stop()' onmouseout='stop()' style='cursor:pointer'><b>&nbsp;&rsaquo;&nbsp;</b></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t\t<td colspan='3' height='25px' bgcolor='#8A90A4' align='center'>\r\n\t\t\t\t\t<table border='0' cellpadding='0' cellspacing='1px' style='border:1px solid white; color:white; font-family:verdana; font-size:11px; font-weight:bold' width='90%'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td align='center' id='py' onmousedown='setNewYear(this)' onmouseup='stop()' onmouseout='stop()' style='cursor:pointer'><b>&nbsp;&lsaquo;&nbsp;</b></td>\r\n\t\t\t\t\t\t\t<td align='center' id='y' width='100%'>&#160;</td>\r\n\t\t\t\t\t\t\t<td align='center' id='ny' onmousedown='setNewYear(this)' onmouseup='stop()' onmouseout='stop()' style='cursor:pointer'><b>&nbsp;&rsaquo;&nbsp;</b></td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' bgcolor='#8A90A4' style='font-family:verdana; font-size:11px; font-weight:bold; color:white;'>\r\n\t\t\t\t<td id='mon'>&#160;</td>\r\n\t\t\t\t<td id='tue'>&#160;</td>\r\n\t\t\t\t<td id='wed'>&#160;</td>\r\n\t\t\t\t<td id='thu'>&#160;</td>\r\n\t\t\t\t<td id='fri'>&#160;</td>\r\n\t\t\t\t<td id='sat'>&#160;</td>\r\n\t\t\t\t<td id='sun' style='color:red'>&#160;</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d1' onclick='setNewDate(this)' width='30px' height='20px'>&#160;1</td>\r\n\t\t\t\t<td id='d2' onclick='setNewDate(this)' width='30px' height='20px'>&#160;2</td>\r\n\t\t\t\t<td id='d3' onclick='setNewDate(this)' width='30px' height='20px'>&#160;3</td>\r\n\t\t\t\t<td id='d4' onclick='setNewDate(this)' width='30px' height='20px'>&#160;4</td>\r\n\t\t\t\t<td id='d5' onclick='setNewDate(this)' width='30px' height='20px'>&#160;5</td>\r\n\t\t\t\t<td id='d6' onclick='setNewDate(this)' width='30px' height='20px'>&#160;6</td>\r\n\t\t\t\t<td id='d7' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;7</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d8' onclick='setNewDate(this)' width='30px' height='20px'>&#160;8</td>\r\n\t\t\t\t<td id='d9' onclick='setNewDate(this)' width='30px' height='20px'>&#160;9</td>\r\n\t\t\t\t<td id='d10' onclick='setNewDate(this)' width='30px' height='20px'>&#160;10</td>\r\n\t\t\t\t<td id='d11' onclick='setNewDate(this)' width='30px' height='20px'>&#160;11</td>\r\n\t\t\t\t<td id='d12' onclick='setNewDate(this)' width='30px' height='20px'>&#160;12</td>\r\n\t\t\t\t<td id='d13' onclick='setNewDate(this)' width='30px' height='20px'>&#160;13</td>\r\n\t\t\t\t<td id='d14' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;14</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d15' onclick='setNewDate(this)' width='30px' height='20px'>&#160;15</td>\r\n\t\t\t\t<td id='d16' onclick='setNewDate(this)' width='30px' height='20px'>&#160;16</td>\r\n\t\t\t\t<td id='d17' onclick='setNewDate(this)' width='30px' height='20px'>&#160;17</td>\r\n\t\t\t\t<td id='d18' onclick='setNewDate(this)' width='30px' height='20px'>&#160;18</td>\r\n\t\t\t\t<td id='d19' onclick='setNewDate(this)' width='30px' height='20px'>&#160;19</td>\r\n\t\t\t\t<td id='d20' onclick='setNewDate(this)' width='30px' height='20px'>&#160;20</td>\r\n\t\t\t\t<td id='d21' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;21</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d22' onclick='setNewDate(this)' width='30px' height='20px'>&#160;22</td>\r\n\t\t\t\t<td id='d23' onclick='setNewDate(this)' width='30px' height='20px'>&#160;23</td>\r\n\t\t\t\t<td id='d24' onclick='setNewDate(this)' width='30px' height='20px'>&#160;24</td>\r\n\t\t\t\t<td id='d25' onclick='setNewDate(this)' width='30px' height='20px'>&#160;25</td>\r\n\t\t\t\t<td id='d26' onclick='setNewDate(this)' width='30px' height='20px'>&#160;26</td>\r\n\t\t\t\t<td id='d27' onclick='setNewDate(this)' width='30px' height='20px'>&#160;27</td>\r\n\t\t\t\t<td id='d28' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;28</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d29' onclick='setNewDate(this)' width='30px' height='20px'>&#160;29</td>\r\n\t\t\t\t<td id='d30' onclick='setNewDate(this)' width='30px' height='20px'>&#160;30</td>\r\n\t\t\t\t<td id='d31' onclick='setNewDate(this)' width='30px' height='20px'>&#160;31</td>\r\n\t\t\t\t<td id='d32' onclick='setNewDate(this)' width='30px' height='20px'>&#160;32</td>\r\n\t\t\t\t<td id='d33' onclick='setNewDate(this)' width='30px' height='20px'>&#160;33</td>\r\n\t\t\t\t<td id='d34' onclick='setNewDate(this)' width='30px' height='20px'>&#160;34</td>\r\n\t\t\t\t<td id='d35' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;35</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr align='center' style='font-family:verdana; font-size:11px; font-weight:bold; background-color:white'>\r\n\t\t\t\t<td id='d36' onclick='setNewDate(this)' width='30px' height='20px'>&#160;36</td>\r\n\t\t\t\t<td id='d37' onclick='setNewDate(this)' width='30px' height='20px'>&#160;37</td>\r\n\t\t\t\t<td id='d38' onclick='setNewDate(this)' width='30px' height='20px'>&#160;38</td>\r\n\t\t\t\t<td id='d39' onclick='setNewDate(this)' width='30px' height='20px'>&#160;39</td>\r\n\t\t\t\t<td id='d40' onclick='setNewDate(this)' width='30px' height='20px'>&#160;40</td>\r\n\t\t\t\t<td id='d41' onclick='setNewDate(this)' width='30px' height='20px'>&#160;41</td>\r\n\t\t\t\t<td id='d42' bgcolor='#ffdddd' onclick='setNewDate(this)' width='30px' height='20px'>&#160;42</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td align='center' colspan='7' bgcolor='#8A90A4' id='datum' style='font-family:verdana; font-size:11px; font-weight:bold; color:white; padding:3px'>&#160;</td>\r\n\t\t\t</tr>\r\n\t\t\t<tr>\r\n\t\t\t\t<td colspan='7' bgcolor='#8A90A4' align='center'>\r\n\t\t\t\t\t<table border='0' cellpadding='1px' cellspacing='3px' style='color:white; font-family:verdana; font-size:11px; font-weight:bold' align='center'>\r\n\t\t\t\t\t\t<tr>\r\n\t\t\t\t\t\t\t<td width='80px' style='border:1px solid white; cursor:pointer;' onclick='setDate()' align='center'>Ok</td>\r\n\t\t\t\t\t\t\t<td width='80px' style='border:1px solid white; cursor:pointer;' onclick='window.close()' align='center'>"+(lang == "de" ? "Abbrechen" : "Cancel")+"</td>\r\n\t\t\t\t\t\t</tr>\r\n\t\t\t\t\t</table>\r\n\t\t\t\t</td>\r\n\t\t\t</tr>\r\n\t\t</table>\r\n\t<script type='text/javascript'>setValues();</script></body>\r\n</html>");
	win.document.close();
	win.focus();
}	
function writeCalendar(lang)
{
  document.write('<a href="javascript:calendar(\'dfrom\',\''+lang+'\');" class="calendarIcon"><img name="clicker" src="menu/cal_s.gif" width="16" height="15" border="0" alt="Klicken Sie hier, um ein Datum aus dem Kalender zu wählen" title="Klicken Sie hier, um ein Datum aus dem Kalender zu wählen" /></a>');
}	
