
//building the calendar object itself (modal dialog).

var fCal=true
var oTdexpDate //the text box which we put the expired date in
var sVer=navigator.appVersion;
var	nPlace=sVer.indexOf("MSIE");
var fIe5
if(nPlace==-1) {
	//window.location.href="intranet"
	}
else {
	sVer=sVer.charAt(nPlace+5);
} if(sVer=="5") {
	fIe5="true";
} else {
	fIe5="false"; 
}
// Set date definitions
var monthNames = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
var curMn;
var curYr;
var showWW;
var selDayBg;
var oDate=new Date()
var nThisMonth=oDate.getMonth()
var nThisYear=oDate.getFullYear()
var nThisDate=oDate.getDate()
//starting the definition of the calendar
function initCalendar(captionBg,selBg,WW)
{

if (captionBg==null){captionBg='blue'};
	if (selBg==null){selBg='yellow'};
	if (WW==null){WW='true'};
	showWW='false';
	selDayBg=selBg;
}

//building the calendar
function calendar(target,yr,mn,dy)
{
   var fBold
   var cMeets=0
   var today ;
   var sin
   var thisDay;
   var red="red"	
   var monthDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30,31, 30, 31);
   var calStr='';
   var nLeft
   var nTop
   var year
   fOk=false
   if (mn==null ||yr==null)
   {
   	today= new Date();	
   }
   else
   {
   	ady=dy;
    if (ady==null){ ady=1 };
		today=new Date(yr,mn,ady);
   }
   
   year = today.getFullYear() ;
   thisDay = today.getDate();
   
	 //shana meoobert
   if (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))
      monthDays[1] = 29;

   nDays = monthDays[today.getMonth()];

   curYr=year;
   curMn=today.getMonth();
   
  	ww=-1;
	for (k=0;k<curMn;k++)
	{
	ww=(ww+monthDays[k]);
	}
	
	{ww=Math.ceil(ww/7)+1;}

   firstDay = today;
   firstDay.setDate(1); // works fine for most systems
   testMe = firstDay.getDate();
   
   if (testMe == 2)
        firstDay.setDate(0);    
	 //the caledar string	 
   startDay = firstDay.getDay();
   calStr +=  '<table bgcolor=white cellspacing="0" cellpadding="2" class="cal1">'
   calStr +=  '<tr><td colspan=8 align=center bgcolor="#006699" style="border-right: solid 1px gray;">'
   calStr +=  '	<table border=0 cellspacing=0 cellpadding=2 class=mnyr>'
   calStr +=  '		<tr>'
   calStr +=  '			<td><span class="tdcal" onclick="prevMn();" onmouseover=this.style.cursor="hand" style="color:white;">&lt;&lt;</span></td>'
   calStr +=  '			<td class="tdcal"><font color="white">' + monthNames[curMn] + '</td>'
   calStr +=  '			<td><span onclick="nextMn();"onmouseover=this.style.cursor="hand" style="color:white;">&gt;&gt;</span></td>'
   calStr +=  '			<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>'
   calStr +=  '			<td><span class="tdcal" onclick="prevYr();" onmouseover=this.style.cursor="hand" style="color:white;">&lt;&lt;</span></td>'
   calStr +=  '			<td><font class="tdcal" color="white">' + curYr + '</td>'
   calStr +=  '			<td><span onclick="nextYr();" onmouseover=this.style.cursor="hand" style="color:white;">&gt;&gt;</span></td>'
   calStr +=  '		</tr>'
   calStr +=  '</table>'
   calStr +=  '</td></tr>'
   calStr +=  '<tr>'
   if (showWW!='false'){
	calStr+=  '	<td>ww</td>'
   }
   calStr +=  '	<td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td style="border-right: solid 1px gray;">Sat</td>'
   calStr +=  '	</tr><tr>'
   column = 0;
   if (showWW!='false'){
	calStr=calStr+('<td>'+formatWw(ww)+'</td>');
   }
   for (i=0; i<startDay; i++)
   {
      calStr=calStr+('<td style="border-top: solid 1px gray;border-right: solid 1px gray;">&nbsp;</td>');
      column++;
   }
   for (i=1; i<=nDays; i++)
   {
      fBold=false
      calStr=calStr+('<td onmouseover="MouseOverTd(this)" onmouseout="MouseOffTd(this)" onclick="TdClicked(this,'+i+','+curMn+','+curYr+')" align="right" ww="'+formatWw(ww)+'"  id='+i );
      if (i==nThisDate && nThisMonth==curMn && nThisYear==curYr)
	    {
				fBold=true
				//calStr=calStr+(' style="background:'+selDayBg+';font-weight:bold" ')
			}	 
			if(fBold)
				sin="<font color='red'><b>"+i+"</b></font>"
			else
		 sin=i 
      calStr += ' style="border-top: solid 1px gray;border-right: solid 1px gray;">' + sin + '</td>'
	  column++;
      if (column == 7 && i<nDays)
      {
	  	 ww++;
         calStr=calStr+('</tr><tr>'); 
		 if (showWW!='false')
		 {
		 calStr=calStr+('<td>'+formatWw(ww)+'</td>');
		 }
         column = 0;
      }
   }
   if (column>0)
   {
	   for (i=column;i<7;i++)
	   {
	   	calStr=calStr+("<td style='border-top: solid 1px gray;border-right: solid 1px gray;'>&nbsp</td>");
	   }
   }
   calStr=calStr+("</tr></table>");
	var obj=document.getElementById(target)
	obj=eval(obj)
	obj.innerHTML=calStr;
	nLeft=0
	nTop=0
	caldiv.style.visibility="visible"
	//putting the calendar in top
	/*if(!fCal){	
		obj.style.posTop=nTop
		obj.style.posLeft=nLeft
		fCal=true
 }*/
}

function closecal(){
		caldiv.style.visibility="hidden"
}

//dispaying the weeks
function formatWw(ww)
{
	if (ww==53) ww=1;
	if (ww<10) ww="0"+ww;
	return ww;
}

// displaying the next month in the calendar 
function nextMn()
{
	if (curMn==11)
	{
		curMn=0;
		if (curYr<9999)
		curYr++;
	}
	else
	{
		curMn++;
	}
	calendar('caldiv',curYr,curMn);
}

// displaying the prev month in the calendar
function prevMn()
{
	if (curMn==0)
	{
		curMn=11;
		if (curYr>1900)
		curYr--;
	}
	else
	{
		curMn--;
	}
	calendar('caldiv',curYr,curMn);
}

// displaying the next year in the calendar
function nextYr()
{
		if (curYr<9999)
		{
		curYr++;
		sLocation="getmeetingsdays.asp?month="+curMn+"&year="+curYr
		calendar('caldiv',curYr,curMn);
		}
}

// displaying the prev year in the calendar
function prevYr()
{
   if (curYr>1900)
		{
		curYr--;
		sLocation="getmeetingsdays.asp?month="+curMn+"&year="+curYr
		calendar('caldiv',curYr,curMn);
		}
}

initCalendar()






