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(n,l,h,f,g){if((h==null)&&(f==null)){return}if(l==null){this.gWinCal=ggWinCal}else{this.gWinCal=l}if(h==null){this.gMonthName=null;this.gMonth=null;this.gYearly=true}else{this.gMonthName=Calendar.get_month(h);this.gMonth=new Number(h);this.gYearly=false}this.gYear=f;this.gFormat=g;this.gBGColor="white";this.gFGColor="black";this.gTextColor="black";this.gHeaderColor="black";this.gReturnItem=n}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(b){return Calendar.Months[b]}function Calendar_get_daysofmonth(c,d){if((d%4)==0){if((d%100)==0&&(d%400)!=0){return Calendar.DOMonth[c]}return Calendar.lDOMonth[c]}else{return Calendar.DOMonth[c]}}function Calendar_calc_month_year(e,f,g){var h=new Array();if(g==-1){if(e==0){h[0]=11;h[1]=parseInt(f)-1}else{h[0]=parseInt(e)-1;h[1]=parseInt(f)}}else{if(g==1){if(e==11){h[0]=0;h[1]=parseInt(f)+1}else{h[0]=parseInt(e)+1;h[1]=parseInt(f)}}}return h}function Calendar_print(){ggWinCal.print()}function Calendar_calc_month_year(e,f,g){var h=new Array();if(g==-1){if(e==0){h[0]=11;h[1]=parseInt(f)-1}else{h[0]=parseInt(e)-1;h[1]=parseInt(f)}}else{if(g==1){if(e==11){h[0]=0;h[1]=parseInt(f)+1}else{h[0]=parseInt(e)+1;h[1]=parseInt(f)}}}return h}new Calendar();Calendar.prototype.getMonthlyCalendarCode=function(){var e="";var d="";var f="";e=e+'<TABLE BORDER=1 BGCOLOR="'+this.gBGColor+'">';d=this.cal_header();f=this.cal_data();e=e+d+f;e=e+"</TABLE>";return e};Calendar.prototype.show=function(){var n="";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("</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 p=Calendar.calc_month_year(this.gMonth,this.gYear,-1);var o=p[0];var r=p[1];var h=Calendar.calc_month_year(this.gMonth,this.gYear,1);var q=h[0];var l=h[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+"', '"+o+"', '"+r+"', '"+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+"', '"+q+"', '"+l+"', '"+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>");n=this.getMonthlyCalendarCode();this.wwrite(n);this.wwrite("</font></body></html>");this.gWinCal.document.close()};Calendar.prototype.showY=function(){var y="";var w;var B,u,s,t;var v=285;var A=200;var z=10;var C;if(isIE){C=75}else{if(isNav){C=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(w=0;w<12;w++){u=w%3;if(w>=0&&w<=2){B=0}if(w>=3&&w<=5){B=1}if(w>=6&&w<=8){B=2}if(w>=9&&w<=11){B=3}s=parseInt(v*u)+z;t=parseInt(A*B)+C;this.wwrite(".lclass"+w+" {position:absolute;top:"+t+";left:"+s+";}")}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 r=parseInt(this.gYear)-1;var D=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, '"+r+"', '"+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, '"+D+"', '"+this.gFormat+"');\">>></A>]</TD></TR></TABLE><BR>");var x;for(w=11;w>=0;w--){if(isIE){this.wwrite('<DIV ID="layer'+w+'" CLASS="lclass'+w+'">')}else{if(isNav){this.wwrite('<LAYER ID="layer'+w+'" CLASS="lclass'+w+'">')}}this.gMonth=w;this.gMonthName=Calendar.get_month(this.gMonth);y=this.getMonthlyCalendarCode();this.wwrite(this.gMonthName+"/"+this.gYear+"<BR>");this.wwrite(y);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(b){this.gWinCal.document.writeln(b)};Calendar.prototype.wwriteA=function(b){this.gWinCal.document.write(b)};Calendar.prototype.cal_header=function(){var b="";b=b+"<TR>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Sun</B></FONT></TD>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Mon</B></FONT></TD>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Tue</B></FONT></TD>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Wed</B></FONT></TD>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Thu</B></FONT></TD>";b=b+"<TD WIDTH='14%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Fri</B></FONT></TD>";b=b+"<TD WIDTH='16%'><FONT SIZE='2' FACE='"+fontface+"' COLOR='"+this.gHeaderColor+"'><B>Sat</B></FONT></TD>";b=b+"</TR>";return b};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(f){var g=gNow.getDate();var h=gNow.getMonth();var e=gNow.getFullYear();if(f==g&&this.gMonth==h&&this.gYear==e){return('<FONT COLOR="#FF8C00"><B>'+f+"</B></FONT>")}else{return(f)}};Calendar.prototype.write_weekend_string=function(d){var c;for(c=0;c<weekend.length;c++){if(d==weekend[c]){return(' BGCOLOR="'+weekendColor+'"')}}return""};Calendar.prototype.format_data=function(n){var r;var s=1+this.gMonth;s=(s.toString().length<2)?"0"+s:s;var q=Calendar.get_month(this.gMonth).substr(0,3).toUpperCase();var o=Calendar.get_month(this.gMonth).toUpperCase();var l=new String(this.gYear);var t=new String(this.gYear.substr(2,2));var p=(n.toString().length<2)?"0"+n:n;switch(this.gFormat){case"MM/DD/YYYY":r=s+"/"+p+"/"+l;break;case"MM/DD/YY":r=s+"/"+p+"/"+t;break;case"MM-DD-YYYY":r=s+"-"+p+"-"+l;break;case"MM-DD-YY":r=s+"-"+p+"-"+t;break;case"DD/MON/YYYY":r=p+"/"+q+"/"+l;break;case"DD/MON/YY":r=p+"/"+q+"/"+t;break;case"DD-MON-YYYY":r=p+"-"+q+"-"+l;break;case"DD-MON-YY":r=p+"-"+q+"-"+t;break;case"DD/MONTH/YYYY":r=p+"/"+o+"/"+l;break;case"DD/MONTH/YY":r=p+"/"+o+"/"+t;break;case"DD-MONTH-YYYY":r=p+"-"+o+"-"+l;break;case"DD-MONTH-YY":r=p+"-"+o+"-"+t;break;case"DD/MM/YYYY":r=p+"/"+s+"/"+l;break;case"DD/MM/YY":r=p+"/"+s+"/"+t;break;case"DD-MM-YYYY":r=p+"-"+s+"-"+l;break;case"DD-MM-YY":r=p+"-"+s+"-"+t;break;default:r=s+"/"+p+"/"+l}return r};function Build(n,h,f,g){var l=ggWinCal;gCal=new Calendar(n,l,h,f,g);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(g,h,e){if(h==null||h==""){h=new String(gNow.getFullYear().toString())}if(e==null||e==""){e="MM/DD/YYYY"}var f=window.open("","Calendar","scrollbars=yes");f.opener=self;ggWinCal=f;Build(g,null,h,e)};
