var weekend=[0,6];var weekendColor="#e0e0e0";var fontface="Verdana";var fontsize=2;var gNow=new Date();var ggWinCal;isNav=(navigator.appName.indexOf("Netscape")!=-1)?true:false;isIE=(navigator.appName.indexOf("Microsoft")!=-1)?true:false;Calendar.Months=["January","February","March","April","May","June","July","August","September","October","November","December"];Calendar.DOMonth=[31,28,31,30,31,30,31,31,30,31,30,31];Calendar.lDOMonth=[31,29,31,30,31,30,31,31,30,31,30,31];function Calendar(d,e,a,c,b){if((a==null)&&(c==null)){return}if(e==null){this.gWinCal=ggWinCal}else{this.gWinCal=e}if(a==null){this.gMonthName=null;this.gMonth=null;this.gYearly=true}else{this.gMonthName=Calendar.get_month(a);this.gMonth=new Number(a);this.gYearly=false}this.gYear=c;this.gFormat=b;this.gBGColor="white";this.gFGColor="black";this.gTextColor="black";this.gHeaderColor="black";this.gReturnItem=d}Calendar.get_month=Calendar_get_month;Calendar.get_daysofmonth=Calendar_get_daysofmonth;Calendar.calc_month_year=Calendar_calc_month_year;Calendar.print=Calendar_print;function Calendar_get_month(a){return Calendar.Months[a]}function Calendar_get_daysofmonth(b,a){if((a%4)==0){if((a%100)==0&&(a%400)!=0){return Calendar.DOMonth[b]}return Calendar.lDOMonth[b]}else{return Calendar.DOMonth[b]}}function Calendar_calc_month_year(b,a,d){var c=new Array();if(d==-1){if(b==0){c[0]=11;c[1]=parseInt(a)-1}else{c[0]=parseInt(b)-1;c[1]=parseInt(a)}}else{if(d==1){if(b==11){c[0]=0;c[1]=parseInt(a)+1}else{c[0]=parseInt(b)+1;c[1]=parseInt(a)}}}return c}function Calendar_print(){ggWinCal.print()}function Calendar_calc_month_year(b,a,d){var c=new Array();if(d==-1){if(b==0){c[0]=11;c[1]=parseInt(a)-1}else{c[0]=parseInt(b)-1;c[1]=parseInt(a)}}else{if(d==1){if(b==11){c[0]=0;c[1]=parseInt(a)+1}else{c[0]=parseInt(b)+1;c[1]=parseInt(a)}}}return c}new Calendar();Calendar.prototype.getMonthlyCalendarCode=function(){var a="";var b="";var c="";a=a+'<TABLE BORDER=1 BGCOLOR="'+this.gBGColor+'">';b=this.cal_header();c=this.cal_data();a=a+b+c;a=a+"</TABLE>";return a};Calendar.prototype.show=function(){var g="";this.gWinCal.document.open();this.wwrite("<html>");this.wwrite("<head><title>Date Picker: DISCOVERY Portal&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title>");this.wwrite("</head>");this.wwrite("<script language='javascript'>");this.wwrite("function ufSetModified(asOrigDate, asNewDate)");this.wwrite("{");this.wwrite("if ((self.opener.document."+this.gReturnItem+".getAttribute('excludeonConfirmDiscard') == null) ||	(self.opener.document."+this.gReturnItem+".getAttribute('excludeonConfirmDiscard').toLowerCase()!='true')){");this.wwrite("	if (asOrigDate != asNewDate)");this.wwrite("	{");this.wwrite("		var oModified = window.opener.document.getElementById('hfModified');");this.wwrite("		if (oModified)");this.wwrite("		{");this.wwrite("			oModified.value = 'true';");this.wwrite("		}");if(navigator.userAgent.indexOf("Mac")==-1){this.wwrite("		self.opener."+p_item+".fireEvent('onchange');")}else{this.wwrite("		self.opener."+p_item+".onchange();")}this.wwrite("	}");this.wwrite("}");this.wwrite("}");this.wwrite("<\/script>");this.wwrite('<body onBlur=self.focus() onload="self.focus();" onUnload="self.opener.'+p_item+'.focus();" link="'+this.gLinkColor+'" vlink="'+this.gLinkColor+'" alink="'+this.gLinkColor+'" text="'+this.gTextColor+'">');this.wwriteA("<FONT FACE='"+fontface+"' SIZE=2><B>");this.wwriteA(this.gMonthName+" "+this.gYear);this.wwriteA("</B><BR>");var e=Calendar.calc_month_year(this.gMonth,this.gYear,-1);var f=e[0];var c=e[1];var b=Calendar.calc_month_year(this.gMonth,this.gYear,1);var d=b[0];var a=b[1];this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', '"+this.gMonth+"', '"+(parseInt(this.gYear)-1)+"', '"+this.gFormat+"');\"><<</A>]</TD><TD ALIGN=center>");this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', '"+f+"', '"+c+"', '"+this.gFormat+"');\"><</A>]</TD><TD ALIGN=center>");this.wwrite('[<A HREF="javascript:window.print();">Print</A>]</TD><TD ALIGN=center>');this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', '"+d+"', '"+a+"', '"+this.gFormat+"');\">></A>]</TD><TD ALIGN=center>");this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', '"+this.gMonth+"', '"+(parseInt(this.gYear)+1)+"', '"+this.gFormat+"');\">>></A>]</TD></TR></TABLE><BR>");g=this.getMonthlyCalendarCode();this.wwrite(g);this.wwrite("</font></body></html>");this.gWinCal.document.close()};Calendar.prototype.showY=function(){var p="";var b;var l,d,f,e;var c=285;var n=200;var o=10;var h;if(isIE){h=75}else{if(isNav){h=25}}this.gWinCal.document.open();this.wwrite("<html>");this.wwrite("<head><title>Date Picker: GRADEBOOK&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</title>");this.wwrite("<style type='text/css'>\n<!--");for(b=0;b<12;b++){d=b%3;if(b>=0&&b<=2){l=0}if(b>=3&&b<=5){l=1}if(b>=6&&b<=8){l=2}if(b>=9&&b<=11){l=3}f=parseInt(c*d)+o;e=parseInt(n*l)+h;this.wwrite(".lclass"+b+" {position:absolute;top:"+e+";left:"+f+";}")}this.wwrite("-->\n</style>");this.wwrite("</head>");this.wwrite('<body onBlur=self.focus()link="'+this.gLinkColor+'" vlink="'+this.gLinkColor+'" alink="'+this.gLinkColor+'" text="'+this.gTextColor+'">');this.wwrite("<FONT FACE='"+fontface+"' SIZE=2><B>");this.wwrite("Year : "+this.gYear);this.wwrite("</B><BR>");var g=parseInt(this.gYear)-1;var q=parseInt(this.gYear)+1;this.wwrite("<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=0 BGCOLOR='#e0e0e0'><TR><TD ALIGN=center>");this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', null, '"+g+"', '"+this.gFormat+"');\" alt='Prev Year'><<</A>]</TD><TD ALIGN=center>");this.wwrite('[<A HREF="javascript:window.print();">Print</A>]</TD><TD ALIGN=center>');this.wwrite("[<A HREF=\"javascript:window.opener.Build('"+this.gReturnItem+"', null, '"+q+"', '"+this.gFormat+"');\">>></A>]</TD></TR></TABLE><BR>");var a;for(b=11;b>=0;b--){if(isIE){this.wwrite('<DIV ID="layer'+b+'" CLASS="lclass'+b+'">')}else{if(isNav){this.wwrite('<LAYER ID="layer'+b+'" CLASS="lclass'+b+'">')}}this.gMonth=b;this.gMonthName=Calendar.get_month(this.gMonth);p=this.getMonthlyCalendarCode();this.wwrite(this.gMonthName+"/"+this.gYear+"<BR>");this.wwrite(p);if(isIE){this.wwrite("</DIV>")}else{if(isNav){this.wwrite("</LAYER>")}}}this.wwrite("</font><BR></body></html>");this.gWinCal.document.close()};Calendar.prototype.wwrite=function(a){this.gWinCal.document.writeln(a)};Calendar.prototype.wwriteA=function(a){this.gWinCal.document.write(a)};Calendar.prototype.cal_header=function(){var a="";a=a+"<TR>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Sun</B></FONT></TD>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Mon</B></FONT></TD>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Tue</B></FONT></TD>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Wed</B></FONT></TD>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Thu</B></FONT></TD>";a=a+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Fri</B></FONT></TD>";a=a+"<TD WIDTH='16%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Sat</B></FONT></TD>";a=a+"</TR>";return a};Calendar.prototype.cal_data=function(){var vDate=new Date();vDate.setDate(1);vDate.setMonth(this.gMonth);vDate.setFullYear(this.gYear);var vFirstDay=vDate.getDay();var vDay=1;var vLastDay=Calendar.get_daysofmonth(this.gMonth,this.gYear);var vOnLastDay=0;var vCode="";vCode=vCode+"<TR>";for(i=0;i<vFirstDay;i++){vCode=vCode+"<TD WIDTH='14%'"+this.write_weekend_string(i)+"><FONT SIZE='2' FACE='"+fontface+"'> </FONT></TD>"}for(j=vFirstDay;j<7;j++){var lsOrigDate=eval(p_item+".value");vCode=vCode+"<TD WIDTH='14%'"+this.write_weekend_string(j)+"><FONT SIZE='2' FACE='"+fontface+"'><A HREF='#' onClick=\"ufSetModified('"+lsOrigDate+"', '"+this.format_data(vDay)+"'); self.opener.document."+this.gReturnItem+".value='"+this.format_data(vDay)+"';window.close();\">"+this.format_day(vDay)+"</A></FONT></TD>";vDay=vDay+1}vCode=vCode+"</TR>";for(k=2;k<7;k++){vCode=vCode+"<TR>";for(j=0;j<7;j++){var lsOrigDate=eval(p_item+".value");vCode=vCode+"<TD WIDTH='14%'"+this.write_weekend_string(j)+"><FONT SIZE='2' FACE='"+fontface+"'><A HREF='#' onClick=\"ufSetModified('"+lsOrigDate+"', '"+this.format_data(vDay)+"'); self.opener.document."+this.gReturnItem+".value='"+this.format_data(vDay)+"';window.close();\">"+this.format_day(vDay)+"</A></FONT></TD>";vDay=vDay+1;if(vDay>vLastDay){vOnLastDay=1;break}}if(j==6){vCode=vCode+"</TR>"}if(vOnLastDay==1){break}}for(m=1;m<(7-j);m++){if(this.gYearly){vCode=vCode+"<TD WIDTH='14%'"+this.write_weekend_string(j+m)+"><FONT SIZE='2' FACE='"+fontface+"' COLOR='gray'> </FONT></TD>"}else{vCode=vCode+"<TD WIDTH='14%'"+this.write_weekend_string(j+m)+"><FONT SIZE='2' FACE='"+fontface+"' COLOR='gray'>"+m+"</FONT></TD>"}}return vCode};Calendar.prototype.format_day=function(a){var d=gNow.getDate();var c=gNow.getMonth();var b=gNow.getFullYear();if(a==d&&this.gMonth==c&&this.gYear==b){return('<FONT COLOR="#FF8C00"><B>'+a+"</B></FONT>")}else{return(a)}};Calendar.prototype.write_weekend_string=function(a){var b;for(b=0;b<weekend.length;b++){if(a==weekend[b]){return(' BGCOLOR="'+weekendColor+'"')}}return""};Calendar.prototype.format_data=function(g){var c;var b=1+this.gMonth;b=(b.toString().length<2)?"0"+b:b;var d=Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();var f=Calendar.get_month(this.gMonth).toUpperCase();var h=new String(this.gYear);var a=new String(this.gYear.substr(2,2));var e=(g.toString().length<2)?"0"+g:g;switch(this.gFormat){case"MM/DD/YYYY":c=b+"/"+e+"/"+h;break;case"MM/DD/YY":c=b+"/"+e+"/"+a;break;case"MM-DD-YYYY":c=b+"-"+e+"-"+h;break;case"MM-DD-YY":c=b+"-"+e+"-"+a;break;case"DD/MON/YYYY":c=e+"/"+d+"/"+h;break;case"DD/MON/YY":c=e+"/"+d+"/"+a;break;case"DD-MON-YYYY":c=e+"-"+d+"-"+h;break;case"DD-MON-YY":c=e+"-"+d+"-"+a;break;case"DD/MONTH/YYYY":c=e+"/"+f+"/"+h;break;case"DD/MONTH/YY":c=e+"/"+f+"/"+a;break;case"DD-MONTH-YYYY":c=e+"-"+f+"-"+h;break;case"DD-MONTH-YY":c=e+"-"+f+"-"+a;break;case"DD/MM/YYYY":c=e+"/"+b+"/"+h;break;case"DD/MM/YY":c=e+"/"+b+"/"+a;break;case"DD-MM-YYYY":c=e+"-"+b+"-"+h;break;case"DD-MM-YY":c=e+"-"+b+"-"+a;break;default:c=b+"/"+e+"/"+h}return c};function Build(d,a,c,b){var e=ggWinCal;gCal=new Calendar(d,e,a,c,b);gCal.gBGColor="white";gCal.gLinkColor="black";gCal.gTextColor="black";gCal.gHeaderColor="navy";if(gCal.gYearly){gCal.showY()}else{gCal.show()}}function show_calendar(){p_item=arguments[0];if(arguments[1]==null){p_month=new String(gNow.getMonth())}else{p_month=arguments[1]}if(arguments[2]==""||arguments[2]==null){p_year=new String(gNow.getFullYear().toString())}else{p_year=arguments[2]}if(arguments[3]==null){p_format="MM/DD/YYYY"}else{p_format=arguments[3]}vWinCal=window.open("","Calendar","width=250,height=250,status=no,resizable=no,top=200,left=200");vWinCal.opener=self;ggWinCal=vWinCal;Build(p_item,p_month,p_year,p_format)}function show_yearly_calendar(d,c,b){if(c==null||c==""){c=new String(gNow.getFullYear().toString())}if(b==null||b==""){b="MM/DD/YYYY"}var a=window.open("","Calendar","scrollbars=yes");a.opener=self;ggWinCal=a;Build(d,null,c,b)};
