naver=navigator.appVersion.slice(0,navigator.appVersion.indexOf("."))
if (navigator.appName.slice(0,9) == "Microsoft" && naver > 3) {
	PDOK  = true;
}else{
	PDOK = false
}
PDVmonths = new Array('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC')
PDVdays = new Array('S','M','T','W','T','F','S');
PDVmiliday = 86400000
PDVnowdate = new Date()
PDVnowyr = PDVnowdate.getFullYear()
PDVnowmo = PDVnowdate.getMonth()	
PDVdayone=new Date()
PDVdayshow=new Date()
PDVnumyrs=2
PDVimg="pickdateV3.gif"
PDVdatefld=""
PDVopencal = false
function PDFblddate(fullname,initdate,xclass,onchngfunc) {
// Fields 	= fullname.Day_  (underscore suffix for sendit non send fields)
//			= fullname.Month_
//			= fullname.Year_
//			= fullname.Date  (hidden, format "dd mmm yyyy", mmm = text e.g. "Jan"
//									suitable for new Date(string)
    if (fullname.slice(0,9) != "document.") {
		fullname="document."+fullname}
	miliday = 86400000
	if (typeof xclass == 'undefined') {xclass=''}else{xclass='CLASS="'+xclass+'"'};
	params1=fullname.split('.')
	if (typeof params1[2] == 'undefined') {
		fldname=params1[1]
		formname=''
	}else{
		fldname=params1[2]
		formname=params1[1]
	}
	if (typeof onchngfunc != 'string') {onchngfunc=''}
	todayplus=0
	if (typeof initdate=='string') {
		if (initdate.slice(0,6)=='today+'){
			todayplus=initdate.slice(6)
		}
	}
	todaysel=new Date(PDVnowdate.getTime() + miliday * todayplus)
	xcode=' onchange="PDFsetdate('+"'"+fullname+"'"+');'+onchngfunc+'" '+xclass+'>'
	document.writeln('<SPAN '+xclass+'><SELECT name="'+fldname+'Day_" '+xcode)
	for (i = 1; i <= 31; i++) {
		document.writeln('<OPTION value="'+i+'">'+i+'</OPTION>')
	}
	document.writeln('</SELECT>')
	document.writeln('<SELECT name="'+fldname+'Month_" '+xcode)
	for (i = 0; i < 12; i++) {
		document.writeln('<OPTION value="'+PDVmonths[i]+'">'+PDVmonths[i]+'</OPTION>')
	}
	document.writeln('</SELECT>')
	document.writeln('<SELECT name="'+fldname+'Year_" '+xcode)	
	for (i = 0; i < PDVnumyrs; i++) {
		yearx=PDVnowyr+i
		document.writeln('<OPTION value="'+yearx+'">'+yearx+'</OPTION>')
	}
	document.writeln('</SELECT></SPAN>')
	daysel=todaysel.getDate()-1
	mosel=todaysel.getMonth()

	eval(fullname+"Day_.selectedIndex="+daysel)
	eval(fullname+"Month_.selectedIndex="+mosel)
	eval(fullname+"Year_.selectedIndex=0")
	document.writeln('<INPUT type="Hidden" name="'+fldname+'Date">')
	PDFsetdate(fullname)
	if (PDOK && PDVopencal) {
	  	document.writeln('<IMG border="0" style="cursor:pointer" src="'+PDVimg+'" name="'+fldname+'PDVimg" onclick="PDFopencal('+"'"+fullname+"'"+')">')
	}
return}

function PDFbldtime(name,xclass,onchngfunc) {
	if (typeof xclass == 'undefined') {xclass=''}else{xclass='CLASS="'+xclass+'"'};
	params3=name.split('.')
	if (typeof params3[1] == 'undefined') {
		form=''
	}else{
		name=params3[1]
		form=params3[0]
	}
	if (typeof onchngfunc != 'string') {onchngfunc=''}
	document.writeln('<SPAN '+xclass+'><SELECT name="'+name+'Time" onchange="'+onchngfunc+'" '+xclass+'>')
	xtimebeg = 8
	xtimeend = 21
	for (i = xtimebeg; i <= xtimeend; i++) {
		sel = i==8?'selected ':''
		if (i<12) {
			xtime = i
			xampm = "AM"
		}else{
			xampm = "PM"
			xtime = i>12?i - 12:i
		}
		document.writeln('<OPTION '+sel+'value="'+xtime+':00'+xampm+'">'+xtime+':00 '+xampm+'</OPTION>')
		document.writeln('<OPTION '+'value="'+xtime+':30'+xampm+'">'+xtime+':30 '+xampm+'</OPTION>')
	}
	document.writeln('</SELECT></SPAN>')
return} 

function PDFbuildcal() {
	xleft=0
	xtop=0
	PDwin.document.writeln('<html><head><title>PickDate</title><style>')
	PDwin.document.writeln('.pdbody {background : #E4E4E4;margin : 0;border : 1px solid #000000;}')
	PDwin.document.writeln('.pdform {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : #CCCCCC;text-decoration : none;color : #000000;font-weight : bold;}')
	PDwin.document.writeln('.pdhd {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : CCCCCC;text-decoration : none;color : #000000;font : bold;border-color : #cccccc #cccccc;#cccccc #cccccc}')
	PDwin.document.writeln('.pdhd2 {font-family: Arial, Helvetica, sans-serif;font-size: 8pt;background : #CCCCCC;text-decoration : none;color : #000000;font-weight : bold;}')
	PDwin.document.writeln('.pdhd2hi {font-family: Arial, Helvetica, sans-serif;font-size: 8pt;background : #666666;text-decoration : none;color : #FFFFFF;font-weight : bold;}')
	PDwin.document.writeln('.pdday {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : #FFFFFF;text-decoration : none;text-align : right;color : #000000;}')
	PDwin.document.writeln('.pddayhi {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : #666666;text-decoration : none;text-align : right;color : #FFFFFF;}')
	PDwin.document.writeln('.pdxday {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : #EEEEEE;text-decoration : none;text-align : right;color : #666666;}')
	PDwin.document.writeln('.pdxdayhi {font-family: Arial, Helvetica, sans-serif;font-size: 7pt;background : #666666;text-decoration : none;text-align : right;color : #FFFFFF;}')
	PDwin.document.writeln('.pdnow {font-family: Arial, Helvetica, sans-serif;font-size:7pt;color: #990000;background : #FFFFFF;text-decoration : none;border : 1px solid #CCCCCC;}')
	PDwin.document.writeln('.pdnowhi {font-family: Arial, Helvetica, sans-serif;font-size:7pt;color: #FFCCCC;background : #666666;text-decoration : none;border : 1px solid #CCCCCC;}')
	PDwin.document.writeln('</style></head>')
	PDwin.document.writeln('<body bottommargin="0" leftmargin="0" rightmargin="0" topmargin="0" onmouseout="PDFclose()">')
	PDwin.document.writeln('<table cellpadding="0" cellspacing="0" border="1" align="center">')
	PDwin.document.writeln('<tr><td class="pdhd2">')
	xoverout='style="cursor: hand;" onmouseover="PDFmover()" onmouseout="PDFmout()"'
	PDwin.document.writeln('<a class="pdhd2" onClick="PDFprevmo()" '+xoverout+'>')
	PDwin.document.writeln('&nbsp;&nbsp;&nbsp;&lt;&nbsp;&nbsp;&nbsp;</a></td>')	
	PDwin.document.writeln('<td class="pdhd2">')
	PDwin.document.writeln('<a class="pdhd2" onClick="PDFtoday()" '+xoverout+'>')
	PDwin.document.writeln('&nbsp;Today&nbsp;</a></td>')
	PDwin.document.writeln('<td class="pdhd2">')
	PDwin.document.writeln('<a class="pdhd2" onClick="PDFnextmo()" '+xoverout+'>')
	PDwin.document.writeln('&nbsp;&nbsp;&nbsp;&gt;&nbsp;&nbsp;&nbsp;</a></td></tr></table>')	
	PDFbuildhd()
	PDwin.document.writeln('</body>')

	PDwin.document.writeln('<script>')
	PDwin.document.writeln('PDVmiliday = 86400000')
	PDwin.document.writeln('PDVnowdate = new Date()')
	PDwin.document.writeln('PDVnowyr = PDVnowdate.getFullYear()')
	PDwin.document.writeln('PDVnowmo = PDVnowdate.getMonth()')
	PDwin.document.writeln('PDVdayone=new Date()')
	PDwin.document.writeln('PDVdayshow=new Date()')

	PDwin.document.writeln('function PDFreturn(xrow,xcol) {')
	PDwin.document.writeln('xdays=xrow*7+xcol')
	PDwin.document.writeln('retmili=PDVdayone.getTime()+(PDVmiliday*xdays)')
	PDwin.document.writeln('retdate=new Date(retmili)')
	PDwin.document.writeln('if (retdate < PDVnowdate) {alert("You may only pick a date in the future"); return}')
	PDwin.document.writeln('xretday=retdate.getDate()-1')
	PDwin.document.writeln('eval("window.opener."+PDVdatefld+"Day_.selectedIndex="+xretday)')
	PDwin.document.writeln('eval("window.opener."+PDVdatefld+"Month_.selectedIndex="+retdate.getMonth())')
	PDwin.document.writeln('eval("window.opener."+PDVdatefld+"Year_.selectedIndex=PDselyr.selectedIndex")')
	PDwin.document.writeln('eval("window.opener."+PDVdatefld+"Day_.onchange()")')
	PDwin.document.writeln('window.close()}')

	PDwin.document.writeln('function PDFclose() {')
	PDwin.document.writeln('winbegx=window.screenLeft')
	PDwin.document.writeln('winbegy=window.screenTop')
	PDwin.document.writeln('winendx=document.body.offsetWidth+winbegx')
	PDwin.document.writeln('winendy=document.body.offsetHeight+winbegy')
	PDwin.document.writeln('eventx=event.screenX')
	PDwin.document.writeln('eventy=event.screenY')
	PDwin.document.writeln('if (eventx >= winbegx && eventx <= winendx && eventy >= winbegy && eventy <= winendy) {return}')
	PDwin.document.writeln('if (typeof event.srcElement.name == "string" && event.srcElement.name.slice(0,5) == "PDsel") {return}')
	PDwin.document.writeln('window.close()}')

	PDwin.document.writeln('function PDFmover() {')
	PDwin.document.writeln('xclass=event.srcElement.className+"hi"')
	PDwin.document.writeln('event.srcElement.className=xclass}')
	PDwin.document.writeln('function PDFmout() {')
	PDwin.document.writeln('xclass=event.srcElement.className.replace(/hi/,"")')
	PDwin.document.writeln('event.srcElement.className=xclass}')
	PDwin.document.writeln('function PDFprevmo() {')
	PDwin.document.writeln('mo=PDVdayshow.getMonth()')
	PDwin.document.writeln('if (mo == 0) {')
	PDwin.document.writeln('if (PDVdayshow.getFullYear() == PDselyr.options[0].value){return')
	PDwin.document.writeln('}else{PDVdayshow.setMonth(11)')
	PDwin.document.writeln('PDVdayshow.setFullYear(PDVdayshow.getFullYear()-1)}')
	PDwin.document.writeln('}else{PDVdayshow.setMonth(mo-1)}')
	PDwin.document.writeln('PDFsetcal()}')
	PDwin.document.writeln('function PDFnextmo() {')
	PDwin.document.writeln('mo=PDVdayshow.getMonth()')
	PDwin.document.writeln('if (mo == 11) {')
	PDwin.document.writeln('if (PDVdayshow.getFullYear() == PDselyr.options[PDselyr.options.length-1].value){return')
	PDwin.document.writeln('}else{PDVdayshow.setMonth(0)')
	PDwin.document.writeln('PDVdayshow.setFullYear(PDVdayshow.getFullYear()+1)}')
	PDwin.document.writeln('}else{PDVdayshow.setMonth(mo+1)}')
	PDwin.document.writeln('PDFsetcal()}')
	PDwin.document.writeln('function PDFtoday() {')
	PDwin.document.writeln('PDVdayshow = new Date()')
	PDwin.document.writeln('PDFsetcal()}')
	PDwin.document.writeln('function PDFnewcal() {')
	PDwin.document.writeln('PDVdayshow = new Date()')
	PDwin.document.writeln('PDVdayshow.setDate(1)')
	PDwin.document.writeln('PDVdayshow.setMonth(PDselmo.selectedIndex)')
	PDwin.document.writeln('PDVdayshow.setFullYear(PDselyr.options[PDselyr.selectedIndex].value)')
	PDwin.document.writeln('PDFsetcal()}')

	PDwin.document.writeln('function PDFsetcal() {')
	PDwin.document.writeln('for (i=0; i<PDselyr.options.length; i++) {')
	PDwin.document.writeln('if (PDVdayshow.getFullYear()==PDselyr.options[i].value) {')
	PDwin.document.writeln('PDselyr.options[i].selected="true"')
	PDwin.document.writeln('break}}')
	PDwin.document.writeln('PDselmo.options[PDVdayshow.getMonth()].selected="true"')
	PDwin.document.writeln('PDVdayone=new Date(PDVdayshow)')
	PDwin.document.writeln('PDVdayone.setDate(1)')
	PDwin.document.writeln('dayoweek=PDVdayone.getDay()')
	PDwin.document.writeln('PDVdayone.setTime(PDVdayone.getTime() - PDVmiliday * dayoweek)')
	PDwin.document.writeln('xdate=new Date(PDVdayone)')
	PDwin.document.writeln('for (i=1;i<7;i++) {')
	PDwin.document.writeln('for (j=0;j<7;j++) {')
	PDwin.document.writeln('PDtable.rows(i).cells(j).innerText=xdate.getDate()')
	PDwin.document.writeln('x1=xdate.getDate()+"/"+xdate.getMonth()+"/"+xdate.getFullYear()')
	PDwin.document.writeln('x2=PDVnowdate.getDate()+"/"+PDVnowdate.getMonth()+"/"+PDVnowdate.getFullYear()')
	PDwin.document.writeln('if (x1 == x2) {')
	PDwin.document.writeln('PDtable.rows(i).cells(j).className="pdnow"')
	PDwin.document.writeln('}else{')
	PDwin.document.writeln('if (xdate.getMonth() == PDVdayshow.getMonth()) {')
	PDwin.document.writeln('PDtable.rows(i).cells(j).className="pdday"')
	PDwin.document.writeln('}else{PDtable.rows(i).cells(j).className="pdxday"}}')
	PDwin.document.writeln('xdate.setTime(xdate.getTime()+PDVmiliday)}}')

	PDwin.document.writeln('}')
	
	PDwin.document.writeln('</script>')
	
	PDwin.document.writeln('</html>')
return}

function PDFbuildhd() {
	PDwin.document.writeln('<table cellpadding="0" cellspacing="0" align="center">')
	PDwin.document.writeln('<tr><td class="pdhd"><SELECT class="pdhd" name="PDselmo" onchange="PDFnewcal()">')
	for (i in PDVmonths) {
		PDwin.document.writeln('<OPTION value="'+PDVmonths[i]+'">'+PDVmonths[i]+'</OPTION>')
	}
	PDwin.document.writeln('</SELECT>&nbsp;')
	PDwin.document.writeln('<SELECT class="pdhd" name="PDselyr" onchange="PDFnewcal()">')
	for (i = 0; i < PDVnumyrs; i++) {
		yearx=PDVnowyr+i
		PDwin.document.writeln('<OPTION value="'+yearx+'">'+yearx+'</OPTION>')
	}
	PDwin.document.writeln('</SELECT></td></tr></table>')
	PDwin.document.writeln('<table cellspacing="0" cellpadding="0" border="1" align="center" class="pdday" id="PDtable">')
	PDwin.document.writeln('<TR>')
	for (i in PDVdays) {
		PDwin.document.writeln('<TD class="pdhd" align="center">' + PDVdays[i] + '</TD>')
	}
	PDwin.document.writeln('</TR>')
	for (i=0;i<6;i++) {
		PDwin.document.writeln('<TR>')
		for (j=0;j<7;j++) {
			PDwin.document.writeln('<TD align="right" onClick="PDFreturn('+i+','+j+')" '+xoverout+'>&nbsp;</TD>')
		}
		PDwin.document.writeln('</TR>')
	}
	PDwin.document.writeln('</table>')
}

function PDFsetdate(xfld) {
    if (xfld.slice(0,9) != "document.") {
		xfld="document."+xfld}
	eval("xevday="+xfld+"Day_.options["+xfld+"Day_.selectedIndex].value")
	eval("xevmo="+xfld+"Month_.options["+xfld+"Month_.selectedIndex].value")
	eval("xevyr="+xfld+"Year_.options["+xfld+"Year_.selectedIndex].value")
	eval(xfld+"Date.value=xevday+' '+xevmo+' '+xevyr")
return}


//pickdate.js

function PDFopencal(fullname,x,y) {
	x=window.event.screenX-window.event.offsetX
	y=window.event.screenY-window.event.offsetY
	wide=102
	hi=136
	adjhi=30
	scrollx=document.body.scrollLeft
	scrolly=document.body.scrollTop
	_PDmonth=eval(fullname+"Month_")
	_PDday=eval(fullname+"Day_")
	_PDyear=eval(fullname+"Year_")
	xleft = x > screen.availWidth-wide-10?screen.availWidth-wide-10:x
	xtop = y > screen.availHeight-hi-adjhi?screen.availHeight-hi-adjhi:y
	xtoday = new Date()
	if (_PDmonth.selectedIndex == -1 || _PDyear.selectedIndex == -1) {
		mo=xtoday.getMonth()
		yr=xtoday.getUTCFullYear()
	}else{
		mo=_PDmonth.selectedIndex
		yr=_PDyear.options[_PDyear.selectedIndex].value
	}
	if (typeof PDwin == "object") {
		if (PDwin.closed != true) {
			PDwin.close()
		}
	}
	winfeats='top=' + xtop + ',left=' + xleft + ',dependent=yes,width=' + wide + ',height=' + hi + ',screenX=' + xleft + ',screenY=' + xtop + ',titlebar=yes,status=yes,menubar=yes,toolbar=yes'
	winfeats='top=' + xtop + ',left=' + xleft + ',dependent=yes,width=' + wide + ',height=' + hi + ',screenX=' + xleft + ',screenY=' + xtop + ',titlebar=no,status=no'
	PDwin = window.open('','Pick',winfeats);
	PDFbuildcal()

	eval("showdate="+fullname+"Date.value")
	PDwin.PDVdatefld=fullname
	PDwin.PDVdayshow=new Date(showdate)
	PDwin.PDFsetcal() 
}

