/***********************************************
*************  DYNAMIC CALENDAR  **************
************************************************/

/*  This is a modular approach to create and use dynamic calendar in HTML pages.
*   This application is supported by Netscape navigator 4.0 and above as well as IE4.0 and above.
*   Created by : Sunil B. Sil on January 22, 2000
*   Modified by : Sunil B. Sil on February 28, 2000	
*   Modified by : Sunil B. Sil on April 11, 2000
*/

/*               One can use this application in HTML pages by calling a function "makeCal(arguments)" with at least two mandatory arguments,
*    first argument is the reference to the positioned block on the screen where the calendar should appear(use <div>...</div>tags for creating positioned blocks)
*    and the second argument is the reference to the text box object where the selected date should appear.

*               Other than these two mandatory arguments, one can specify three more arguments out of which first two are numbers indicate the relative left and top position for the calendar in the positioned block,
*   and the third one is the date-format string in which you expect the date should be populated in the text box. The sequence " left-position > top-position > date-format " must be followed. 
*   You must either ignore both  left-position and top-position parameters or specify values for both. All these three non-mandatory parameters could be specified in the above mentioned order only after the mandatory parameters.
*
*     Important :  YOU MUST INCLUDE THIS FILE (calendar_smallest.js) IN YOUR HTML APPLICATION PRIOR TO CALL THE FUNCTION  " makeCal(arguments) "
*/

/*
***********************************************
******   Example ( how to use in your application) : *******
***********************************************
 Note : assumed that the file "calendar_smallest.js" is copied to the same directory where the HTML page resides.

<html>
<style type="text/css">
#divblock {
//position:relative;
visibility:hidden;
//top:68;top:10;
//left:313;left:13;
}
</style>

<head>
<title>DYNAMIC CALENDAR</title>
<script src="calendar_smallest.js"> </script>
</head>

<body bgcolor="#ffffff">
<form name="frmm1">
  <p>Date&nbsp; : &nbsp;<input type="text" name="enterdate" value="">
<input type="button" value="Calendar" name="btn" onclick="javascript: if(document.all) makeCal(document.all.divblock, window.document.frmm1.enterdate,10,20,'dd-mm-yyyy'); else makeCal(document.layers.divblock, window.document.frmm1.entereddate,10,20,'dd-mm-yyyy') "></p>
</form>

<div id="divblock"> </div>
</body>
</html>

*/


/******************************
   *****       START    ********
 ******************************/


if(!document.layers)
monthArray = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
else
monthArray = new Array(" &nbsp;January"," February","&nbsp;&nbsp;&nbsp; March","&nbsp;&nbsp;&nbsp;&nbsp; April","&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;May","&nbsp;&nbsp;&nbsp;&nbsp; June","&nbsp;&nbsp;&nbsp;&nbsp; July","&nbsp;&nbsp;&nbsp; August","September","  October"," November"," December");

todayDate=new Date();
date=todayDate.getDate();
month=todayDate.getMonth();
year=todayDate.getYear();
dd1=date;
mm1=month;

var first=1;
if(year < 1900) year+= 1900;
yyyy1=year;
var noofcal=0;
var objj;
var prevobjj;
var rg1=3;
var rg2=0;
var highlight;
var targetlayer;
var targetobj;
var header = monthArray[month] + ", " + year;
dayarr = new Array(45);

//start of function

function setDate(indd) {
	var dt = "";
	if(dayarr[indd] == " ") return false;
		if(document.layers) {
			if((highlight-10)%7 == 0)
			targetlayer.document.layers.lay1.document.layers[highlight].bgColor="#F5C9AD";
			else
			targetlayer.document.layers.lay1.document.layers[highlight].bgColor="#B9E3C0";
			targetlayer.document.layers.lay1.document.layers[indd+10].bgColor="yellow";
		highlight=indd+10;}

	else {
		if(rg1 != 3){
			if(rg1==1) 
			prevobjj.bgColor="#F5C9AD";
			else
			prevobjj.bgColor="#B9E3C0"; }
			objj.bgColor="yellow";
			prevobjj=objj;
			rg1=rg2;
		 }

	//dt += monthArray[month] + " " + dayarr[indd] + ", " + year;
                        dt =  setFormat(dayarr[indd], month, year);
	targetobj.value= dt;
	closecal();
	return;
}

//end of function


function setcal(value) {

	if(value == 0) {
		if(month == 0) { 
			year = year - 1; month = 11; }
		 else {
			  month = (month - 1); }
		 }
	else if(value==1) {
		  if(month == 11) {
 			year = year + 1; month = 0; }
		else {
			  month = (month + 1); }
		}
	else if(value==2) {
		year = year - 1; }
	else {
		year = year+1; }

	header=monthArray[month]+", " + year;
           
	noofcal = noofcal - 1;
	makeCal(targetlayer,targetobj); 
	return true; 
}



function closecal() {
	if(noofcal != 1) return;
	if(!document.layers){
		targetlayer.innerHTML = ""; 
		targetlayer.style.visibility = "hidden"
		}
	else {
		targetlayer.document.write(""); 
		targetlayer.document.close();
		targetlayer.visibility= "hidden"
		}
	noofcal -= 1;


if(document.layers) document.releaseEvents(Event.MOUSEMOVE |Event.MOUSEUP);



/*
	date=todayDate.getDate();
	month=todayDate.getMonth();
	year=todayDate.getYear();
	if(year < 1900) year+= 1900;
	header = monthArray[month] + ", " + year;
	first=1;
	lftval = 0;
	topval = 0;
	formatdate = "";
	*/
}

//start of function datecal()

function datecal(mon, yr) {
	var totdays;
	var p = 0;
	var len = 0;
	var cumdays = new Array("0","31","59","90","120","151","181","212","243","273","304","334","365");

		if(yr*10 + mon > 20001) {
			totdays = (yr - 2000)*365 + parseInt(cumdays[mon]) - parseInt(cumdays[2]);
			var ppp= Math.floor((yr*10+mon - 20002)/40);
			totdays += ppp;
			p = totdays%7;
			p = (p + 3)%7;

			len = cumdays[mon+1] - cumdays[mon]; 
				if(yr%4==0 && mon==1) len += 1; }

		else {
			  totdays = (2000 - yr)*365 + parseInt(cumdays[2]) - parseInt(cumdays[mon]);
			var ppp= Math.floor((20001 - (yr*10+mon) )/40);
			totdays += ppp;
			p = totdays%7;
			p =(9 - p)%7;
			len = cumdays[mon+1] - cumdays[mon]; 
				if(mon == 1 && yr%4 == 0) len += 1;}

					for(var i=0; i<45; i++) {
						if(i >= p && i < p+len) dayarr[i] =  (i - p + 1);
						else dayarr[i] = " ";
					  }
				if(first==1) {
					if(document.layers)
						highlight = p+date+9; 
					else {
						highlight= p+date-1;
						  }
			}
}



//end of function datecal()



var lftval = 0;
var topval = 0;
var formatdate = "";


//Start of function makeCal


function makeCal(lay,targ) {	

if(noofcal != 0) { 
	targetobj = targ;	
		if(makeCal.arguments.length == 5) 	formatdate = makeCal.arguments[4];
 	return false;	
		}
	 if(makeCal.arguments.length <2 || makeCal.arguments.length > 5) {
 		  alert("Argument mismatch !"); return; }
	else if(makeCal.arguments.length == 3) {
		     formatdate = makeCal.arguments[2]; }
	else if(makeCal.arguments.length == 4) {
		   lftval = parseInt( makeCal.arguments[2]);
		 topval = parseInt( makeCal.arguments[3]); 
                        				}
	else if(makeCal.arguments.length == 5) {
		   lftval = parseInt( makeCal.arguments[2]);
		 topval = parseInt( makeCal.arguments[3]);
		  formatdate = makeCal.arguments[4]; }

	if(mm1==month && yyyy1==year) first=1;
	noofcal += 1;

if(document.layers) document.captureEvents(Event.MOUSEMOVE |Event.MOUSEUP);

document.onmousemove = dragCal;
document.onmouseup = stopDrag;




	targetlayer = lay;
		if(document.all){
			targetlayer.style.visibility = "visible" }
		else {
			targetlayer.visibility = "visible"
		}
	
             
	targetobj = targ;

	var day=0;
                 var   calcon = "";

	datecal(month, parseInt(year));

	if(!document.layers) {
		calcon = "<table border=1  cellpadding=0   bgcolor='#b1b1ff' bordercolor='#0000FF' bordercolorlight='#34928A' bordercolordark='#34928A' style='position:relative; top:"
		calcon += topval;
		calcon += "; left:"
		calcon += lftval;
		calcon += ";'><tr ><td style=' font-size:8pt;'  bgColor='#ccbbbb'><img src='images/ScrollLeftArrow.gif' alt='previous month'  height=13 width=17 onclick='setcal(0)'></td><td style=' font-size:8pt; '   align='center' bgcolor='#7EB5B8' colspan='5' onMousedown='startDrag()' onmouseover='this.bgColor=\"#efefff\"' onmouseout='this.bgColor=\"#7Eb5B8\"'><font  color='blue' ><b>"
		calcon += header;
		calcon += "</B></font></td><td style=' font-size:8pt;' bgColor='#ccbbbb'><img src='images/ScrollRightArrow.gif' alt='next month'  height=13 width=17 onclick='setcal(1)'></td></tr>";
 
		calcon +="<tr><td style=' font-size:7pt;' align='center' bgcolor='#FF7700'><font  color='#eeee00'><strong>S</strong></font></td>";
		calcon +="<td style=' font-size:7pt;' align='center' bgcolor='#B9EE00'><font  color='blue'><strong>M</strong></font></td>";
		calcon +="<td style=' font-size:7pt;'  align='center' bgcolor='#B9EE00'>&nbsp;<font  color='blue'><strong>T</strong></font>&nbsp;</td>";
		calcon +="<td style=' font-size:7pt;'  align='center' bgcolor='#B9EE00'><font color='blue'><strong>W</strong></font></td>";
		calcon +="<td style=' font-size:7pt;' align='center' bgcolor='#B9EE00' ><font  color='blue'><strong>T</strong></font></td>";
		calcon +="<td style=' font-size:7pt;' align='center' bgcolor='#B9EE00'><font  color='blue'>&nbsp;<strong>F</strong>&nbsp;</font></td>";
		calcon +="<td style=' font-size:7pt;' align='center' bgcolor='#B9EE00'><font  color='blue'><strong>S</strong></font></td></tr>";


	for(var i=0; i<6; i++) {
		calcon +="<tr><td style=' font-size:8pt; font-weight:bold;' id='tab"
		calcon += day;
	if(day == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+day+");' onclick='rg2=1; objj=this; setDate(";
	else
		calcon +="' align='center' bgcolor='#F5C9AD'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+day+");' onclick='rg2=1; objj=this; setDate(";
		calcon += day;
		calcon += ")'>"
		calcon += dayarr[day];
		calcon += "&nbsp;</td>";
		calcon +="<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+1);
	if((day+1) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+1)+");' onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="'  align='center' bgcolor='#B9E3C0'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+1)+");' onclick='rg2=0; objj=this; setDate(";
		calcon += (day + 1);
		calcon += ")'>"
		calcon += dayarr[day+1];
		calcon += "&nbsp;</td>";

		calcon +="<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+2);
	if((day+2) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff' onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+2)+");'  onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="' align='center' bgcolor='#B9E3C0' onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+2)+");'  onclick='rg2=0; objj=this; setDate(";
		calcon += (day+2);
		calcon += ")'>"
		calcon += dayarr[day + 2];
		calcon += "&nbsp;</td>";
		calcon += "<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+3);
	if((day+3) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+3)+");'  onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="'  align='center' bgcolor='#B9E3C0'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+3)+");' onclick='rg2=0; objj=this; setDate(";
		calcon += (day+3);
		calcon += ")'>"
		calcon += dayarr[day + 3];
		calcon += "&nbsp;</td>";
		calcon +="<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+4);
	if((day+4) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff' prevobjj=this  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+4)+");'  onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="' align='center' bgcolor='#B9E3C0'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+4)+");' onclick='rg2=0; objj=this; setDate(";
		calcon += (day + 4);
		calcon += ")'>"
		calcon += dayarr[day + 4];
		calcon +="&nbsp;</td>";
		calcon +="<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+5);
	if((day+5) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff'   onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+5)+");' onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="'   align='center'  bgcolor='#B9E3C0'   onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+5)+");' onclick='rg2=0; objj=this; setDate(";
		calcon += (day+5);
		calcon += ")'>"
		calcon += dayarr[day + 5];
		calcon +="&nbsp;</td>";
		calcon +="<td style=' font-size:8pt;  font-weight:bold;' id='tab"
		calcon += (day+6);
	if((day+6) == highlight && first==1)
		calcon +="' align='center' bgcolor='#00ffff' onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+6)+");'  onclick='rg2=0; objj=this; setDate(";
	else
		calcon +="'  align='center' bgcolor='#B9E3C0'  onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+6)+");' onclick='rg2=0; objj=this; setDate(";
		calcon += (day+6);
		calcon += ")'>"
		calcon += dayarr[day + 6];
		calcon += "&nbsp;</td></tr>";

	day += 7;
	}


//		calcon += "<tr><td style=' font-size:8pt;' bgColor='#bbdddd'><img src='../images/ScrollLeftArrow.gif' alt='previous year'  height=13 width=19 onclick='setcal(2)'></td><td style=' font-size:8pt;' align='center' bgcolor='#7EB5B8' colspan='5'>"
//		to remove year funtionality


		calcon += "<tr><td style=' font-size:8pt;' bgColor='#bbdddd'>&nbsp;</td><td style=' font-size:8pt;' align='center' bgcolor='#7EB5B8' colspan='5'>"

//		calcon += "<img src='../images/Close.gif' alt='close calendar' height=13 width=15 onclick='closecal()'></td><td style=' font-size:8pt;' bgColor='#bbdddd'><img src='../images/ScrollRightArrow.gif' alt='next year'  height=13 width=19 onclick='setcal(3)'></td></tr></table>";
//		to remove year funtionality


		calcon += "<img src='images/Close.gif' alt='close calendar' height=13 width=15 onclick='closecal()'></td><td style=' font-size:8pt;' bgColor='#bbdddd'>&nbsp;</td></tr></table>";

	}

else 
	{
                   calcon = "";
	 calcon = "<layer   name='lay1' bgColor='#96789B' position='relative' top='"
		calcon += topval;
		calcon += "' left='"
		calcon += lftval;
		calcon += "'  height='162'  >";
		calcon += "<layer bgColor='#ccbbbb' position=relative height=17px width=17px top=3px left=3px onfocus='setcal(0);'><img src='../images/ScrollLeftArrow.gif' alt='previous month'  height=17 width=17></layer>" 
		calcon += "<layer name='headerlay' position=relative height=17px width=93px top=3px left=22px"
		calcon += " align='center' bgcolor='#7Eb5B8' onFocus='startDrag()' onmouseover='this.bgColor=\"#efefff\"' onmouseout='this.bgColor=\"#7Eb5B8\"'><font color='#cc0000'  POINT-SIZE=9>&nbsp;"
		calcon += header;
	
		calcon += "</font></layer>"
		calcon += "<layer   position=relative bgColor='#ccbbbb' height=17px width=17px top=3px left=117px onfocus='setcal(1);'><img src='../images/ScrollRightArrow.gif' alt='previous year'  height=17 width=17></layer>" 

		calcon += "<layer   position=relative height=8px width=17px top=22px left=3px"
		calcon += " bgcolor='#ff7700'><font  POINT-SIZE=9 color='#eeee00'><b>&nbsp;S</b></font></layer>"
		calcon += "<layer   position=relative height=8px width=17px top=22px left=22px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;M</b></font></layer>"
		calcon += "<layer   position=relative height=8px width=17px top=22px left=41px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;T</b></font></layer>"
		calcon += "<layer   position=relative height=8px width=17px top=22px left=60px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;W</b></font></layer>"
		calcon += "<layer   position=relative height=8px width=17px top=22px left=79px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;T</b></font></layer>"
		calcon += "<layer  position=relative height=8px width=17px top=22px left=98px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;&nbsp;F</b></font></layer>"
		calcon += "<layer   position=relative height=8px width=17px top=22px left=117px"
		calcon += " bgcolor='#B9EE00'><font  POINT-SIZE=9 color='blue'><b>&nbsp;S</b></font></layer>"

	for(var i=0; i<6; i++) {

		calcon += "<layer   position=relative height=8px width=17px bgcolor='#F5C9AD' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 3;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+day+");' onfocus=' setDate(";
		calcon += day;
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day];
		calcon += "</b></font></layer>";

		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 22;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+1)+"); ' onfocus=' setDate(";
		calcon += (day+1);
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day+1];
		calcon += "</b></font></layer>";

		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 41;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+2)+"); ' onfocus=' setDate(";
		calcon += (day+2);
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day + 2];
		calcon += "</b></font></layer>";
		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 60;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+3)+"); ' onfocus=' setDate(";
		calcon += (day+3);
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day + 3];
		calcon +="</b></font></layer>";
		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon +=79;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+4)+"); ' onfocus=' setDate(";
		calcon += (day+4);
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day + 4];
		calcon +="</b></font></layer>";

		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 98;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+5)+"); ' onfocus=' setDate(";
		calcon += (day+5);
		calcon += "); return false;'><font  POINT-SIZE=9><b>&nbsp;"
		calcon += dayarr[day + 5];
		calcon +="</b></font></layer>";

		calcon +="<layer   position=relative height=8px width=17px bgcolor='#B9E3C0' top="
		calcon += (i+2)*17 +5;
		calcon += " left ="
		calcon += 117;
		calcon += " onmouseout='chkColor2(this); ' onmouseover='chkColor1(this,"+(day+6)+"); ' onfocus='setDate(";
		calcon += (day+6);
		calcon += "); return false;'><font  POINT-SIZE=9 ><b>&nbsp;"
		calcon += dayarr[day + 6];
		calcon += "</b></font></layer>";

	day += 7;
	}


		calcon += "<layer   position=relative height=17px width=134px top=138px left=3px >"
		//calcon += "<layer   position=relative bgColor='#bbd0d0' height=17px width=17px top=3px left=0px onfocus='setcal(2);'><img src='../images/ScrollLeftArrow.gif' alt='previous year'  height=17 width=17></layer>" 
		//calcon += "<layer   position=relative  bgcolor='#7EB5B8' width=93 left=19 height=17 top=3 onfocus='closecal()'><font POINT-SIZE=9>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><img src='../images/Close.gif' alt='close calendar' height=15 width=15 ></layer>"
		//calcon += "<layer   position=relative bgColor='#bbd0d0' height=17px width=17px top=3px left=114px onfocus='setcal(3);'><img src='../images/ScrollRightArrow.gif' alt='next year'  height=17 width=17></layer>" 

		calcon += "<layer   position=relative bgColor='#bbd0d0' height=17px width=17px top=3px left=0px ></layer>" 
		calcon += "<layer   position=relative  bgcolor='#7EB5B8' width=93 left=19 height=17 top=3 onfocus='closecal()'><font POINT-SIZE=9>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</font><img src='../images/Close.gif' alt='close calendar' height=15 width=15 ></layer>"
		calcon += "<layer   position=relative bgColor='#bbd0d0' height=17px width=17px top=3px left=114px ></layer>" 

		calcon += "</layer></layer>";

	}




	if(!document.layers){
    
		targetlayer.innerHTML = calcon; 
			if(first==1)
				first=0;
			}
		else {
                            
                                            
                       //  targetlayer.document.write("");
                                                                    
                                                 if(1) {
			targetlayer.document.write(calcon);
                                                                 }
			targetlayer.document.close();
		targetlayer.document.layers.lay1.document.headerlay.document.captureEvents(Event.MOUSEDOWN);
	targetlayer.document.layers.lay1.document.headerlay.document.onmousedown=startDrag;		
	if(first==1){
		targetlayer.document.layers.lay1.document.layers[highlight].bgColor="#00ffff" 
			first=0;
			}

			}
		}


//End of function makeCal

function setFormat(day,mon,yer) {
	if(formatdate == null || formatdate=="")  {
		if(day <10) day = "0" + day;
			return( monthArray[mon] + " " + day + ", " + yer);   
					}
	else {
		var monarr = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		var formated_date = formatdate;
		if(day <10) day = "0" + day;
			var mmm = ((mon+ 1) <10)?"0"+(mon+1):(mon+1);

			formated_date= formated_date.replace(/[dD][dD]/,day);
			formated_date= formated_date.replace(/[mM][mM]/,mmm);
			formated_date= formated_date.replace(/[yY][yY]+/,yer);
			formated_date= formated_date.replace(/[mM][oO][nN]/,monarr[mon]);

	return(formated_date);
	}
}	


//---------------------------

//if(document.layers) document.captureEvents(Event.MOUSEMOVE |Event.MOUSEUP);


document.onmousemove = dragCal;
document.onmouseup = stopDrag;

drgindic=1;


function stopDrag(e) {
drgindic=1;
return true;
}

	

function startDrag(e) {
	drgindic=0;	
return false;
}


function dragCal(e) {
if(drgindic == 1) return false;
var x, y;
if(document.layers) {
x = e.pageX;
y = e.pageY;

targetlayer.top = y - 10 - topval;
targetlayer.left = x - 65 - lftval;

}
else if(document.all) {
calLocBod = document.body;

x = event.clientX;
y = event.clientY;	

targetlayer.style.top = y + calLocBod.scrollTop - 10 - topval;
targetlayer.style.left = x + calLocBod.scrollLeft  - 80 - lftval;

}
}

function donothingfalse() {
return false;
}	

function donothingtrue() {
return true;
}


function chkColor1(lay,dayno){
 xx = lay.bgColor;
yy = (dayarr[dayno]==" ")?false:true;
if(yy)  lay.bgColor="#F500"; 		// highlight color for the instant mouseover
return yy;

}
	
function chkColor2(lay){
lay.bgColor=xx;

}

 
/********************
****** END **********
*********************/

