
// JScript File
var CAL_MO_NAME = ['JAN', 'FEB', 'MAR', 'APR', 'MAY', 'JUN', 'JUL', 'AUG', 'SEP', 'OCT', 'NOV', 'DEC'];
var CAL_ARRAY = [];

AtsCalendar=function()
{
	CAL_ARRAY[CAL_ARRAY.length]=this;
	this.ix=CAL_ARRAY.length-1;
	this.bod='';
	this.bix='';
	this.list='';
	this.exec=function (p){
		if(typeof(p.box)==='number'){this.bix=p.box;p.box=p.L[p.box];
		/*p.L.splice(this.bix,1);*/}else this.bix='';
		this.list=(p.L&& typeof(p.L.length)==='number')?p.L:[];
		this.calOpen(p.T, p.box, p.X, p.Y, p.XX, p.YY);
	}
	this.calOpen=function (t,o,x,y,xff,yff){
	this.offsetX = x;
	this.offsetY = y;
	this.offsetXff = xff;
	this.offsetYff = yff;    
	if(!t||t=='')t='&nbsp';
	this.box=o;
	this.title=t;
	this.Show(0,1);
	}

	this.Show=function (ix,init){
		if(ix>0&&!this.CAL_STRING[ix]){
			var dt2=new Date(2008,4,14,0,0,0);dt2.setDate(1);dt2.setMonth(dt2.getMonth()+(ix*6));
			this.CAL_STRING[ix]=this.calGen(dt2);var dt2;
		}
		if(!init)
			createPopup(runHook('ol_content_caption', FALTERNATE, o3_css, this.CAL_STRING[ix], o3_cap, o3_close));
		else
		{
			if (navigator.appName == "Netscape")     //FIREFOX
				overlib(this.CAL_STRING[ix], TEXTCOLOR, '', CELLPAD, 0, VAUTO, HAUTO, WIDTH, 388, STICKY, CAPTIONSIZE, '11px', BORDER, 1, BGCOLOR, '#2138a5', DRAGGABLE, ALTCUT, CAPTION, '<div style=\'text-align: right; height: 14px; padding: 5px; background-color: #2138a5\'><span style=\'float: left; color:#ffffff;\'><label onmousedown=\"this.style.cursor = \'move\'\" onmouseup=\"this.style.cursor = \'\'\">'+this.title+'</label></span><a style=\'cursor:pointer\' onclick=\'javascript:cClick();CAL_ARRAY['+this.ix+'].list="";\'><div style=\"float: right; width: 14px; height: 14px; background-image:url(\'/images/close.gif\')\"></div></a><div>', CENTER, ANCHOR, this.box.id, ANCHORALIGN, 'UR', ANCHORX, this.offsetXff, ANCHORY, this.offsetYff);
			else // IE
				overlib(this.CAL_STRING[ix], TEXTCOLOR, '', CELLPAD, 0, VAUTO, HAUTO, WIDTH, 388, STICKY, CAPTIONSIZE, '11px', BORDER, 1, BGCOLOR, '#2138a5', DRAGGABLE, ALTCUT, CAPTION, '<div style=\'text-align: right; height: 14px; padding: 5px; background-color: #2138a5\'><span style=\'float: left; color:#ffffff;\'><label onmousedown=\"this.style.cursor = \'move\'\" onmouseup=\"this.style.cursor = \'\'\">'+this.title+'</label></span><a style=\'cursor:pointer\' onclick=\'javascript:cClick();CAL_ARRAY['+this.ix+'].list="";\'><div style=\"float: right; width: 14px; height: 14px; background-image:url(\'/images/close.gif\')\"></div></a><div>', CENTER, ANCHOR, this.box.id, ANCHORALIGN, 'UR', ANCHORX, this.offsetX, ANCHORY, this.offsetY);
		}

		var d=new Date(2008,4,14,0,0,0);
		var ob=objGet(CAL_MO_NAME[d.getMonth()]+d.getDate());if(ob!=null)ob.className='now';
		if(this.list!=''){
			for(var i=0;i< this.list.length;i++)if(this.list[i].value!=''){
			var d=parseDate(this.list[i].value);
			if(d!=null){

				ob=objGet(CAL_MO_NAME[d.getMonth()]+d.getDate());if(ob!=null)ob.className='dt'+(1+i);
			}
			var d,ob;
			}
		}else{
			var d=parseDate(this.box.value);
			if(d!=null){ob=objGet(CAL_MO_NAME[d.getMonth()]+d.getDate());if(ob!=null)ob.className='dt1';}
			var d,ob;
		}
	}
	
	this.calGen=function (dt){
		var d=(dt)?new Date(dt):new Date();d.setDate(1);
		var moreOrLessBool = d.getMonth()==this.now.getMonth();
		var moreOrLess=(moreOrLessBool)?'<div class="button" style="margin-top: 5px"><a href="javascript:CAL_ARRAY['+this.ix+'].Show(1);">Next&nbsp;&#187;</a></div><br />':'<div class="button" style="margin-top: 5px"><a href="javascript:CAL_ARRAY['+this.ix+'].Show(0);">&#171&nbsp;Previous</a></div><br />';
	     
		var h='<table border="0" cellpadding="0" cellspacing="5" class="cal">'
					+'<tr>'
					+'<td colspan="3">'
					+'</td>'
					+'</tr>'
					+'<tr>'
					  +'<td>';
		for(var m=1;m<=6;m++){
			h+=this.calM(d);
			if (m==3)h+='</td></tr><tr><td>';
			else if(m<6)h+='</td><td>';
			d.setMonth(d.getMonth()+1);
       }
		h+='</td>'
					  +'</tr>'
	                  
		   + '<tr><td colspan="3">' + moreOrLess + '</td></tr>'           
	                  
					+'</table>';
		return h;
	}
	 
	this.now=new Date(2008,4,14,0,0,0);
	var min_date = new Date(2008,4,14,0,0,0);min_date.setDate(min_date.getDate()+1);
	this.calM=function (md){
		var d=new Date(md),rc=1;
		var m=d.getMonth();mm=CAL_MO_NAME[m],fd=d.getDay();
		var h='<table border="0" cellpadding="2" cellspacing="1" class="calTbl">'
			  +'<tr>'
				+'<td colspan="7" class="mo">'+mm+' '+d.getFullYear()+'</td>'
			  +'</tr>'
			  +'<tr>'
				+'<th>S</th>'
				+'<th>M</th>'
				+'<th>T</th>'
				+'<th>W</th>'
				+'<th>T</th>'
				+'<th>F</th>'
				+'<th>S</th>'
			  +'</tr>'
			  + '<tr>';
		for(var i=0;i< fd;i++){h+='<td id="e">&nbsp</td>';}
		while(d.getMonth()==m){
		var dn=mm+d.getDate();

		h+=(d.getTime()< min_date.getTime())?'<td id="'+dn+'" class="dis">'+d.getDate()+'</td>':'<td id="'+dn+'" onmouseover="calDyIn(this)" onmouseout="calDyOut(this)" onclick="calDyClk('+this.ix+','+d.getTime()+')">'+d.getDate()+'</td>';
		if(d.getDay()==6){rc++;
		var d1 = new Date(d);d1.setDate(d1.getDate()+1);if(m==d1.getMonth())h+='</tr><tr>';
		}
		d.setDate(d.getDate()+1);
		}if(d.getDay()==0)rc--;
		while(d.getDay()!=0){h+='<td id="e">&nbsp</td>';d.setDate(d.getDate()+1);}
		while(rc<6){rc++;h+='</tr><tr>';for(var i=1;i<=7;i++)h+='<td id="e">&nbsp</td>';}
		h+='</tr>'
		  +'</table>';
		return h;
	}
	this.CAL_STRING=[];
	this.CAL_STRING[0]=this.calGen();
	this.CAL_STRING[1]=false;
}

var cal_cls;
function calDyIn(k){cal_cls=k.className;k.className='sel';}
function calDyOut(k){k.className=cal_cls;}

function calDyClk(ix,d){cClick();CAL_ARRAY[ix].list="";var nd=new Date(d);CAL_ARRAY[ix].box.value=formatDate(nd,'MM/dd/yyyy'); removeExpirationHint(CAL_ARRAY[ix].box);}
