function suycCalendar(m,y)

{

  if (typeof(_calendar_prototype_called) == 'undefined')

  {

    _calendar_prototype_called = true ;

  // Object methods
    this.BuildCalendar = _create ;
    this.createCanvass = _createCanvass ;
    this.showCalendar = _showCalendar ;
    this.goToCurrent = _goToCurrent ;
    this.toggleCalendar = _toggleCalendar ;
    this.moveTo = _positionCanvass ;
    this.hide = _hide ;
    this.show = _show ;
    this.init = _init ;
  }

  // Object properties

 this.name = 'default' ;
 this.rowBGColor = 'palegoldenrod' ;
 this.currentDay = 0 ;
 this.currentMonth = 0 ;
 this.currentYear = 0 ;
 this.visible = false ;
 this.posX = 10 ;
 this.posY = 10 ;
 this.isIE4 = '';
 this.isNav4 = '' ;

 // If you set hasEvents fo FALSE then the calendar face is dumbed out.

 this.hasEvents = true ;
 this.canvass = '' ;

 // The DIV || LAYER that we display the calendar on.

 this.bindToElement = '' ;
 
 // Bind to an ELEMENT on the page.

 // Array of day names
 this.days = new Array("Sunday", "Monday", "Tuesday", "Wednesday","Thursday","Friday", "Saturday");

 // Array of month names

 this.months = new Array("January", "February", "March", "April", "May","June", "July","August", "September", "October", "November", "December");

 // Array of total days in each month

 this.totalDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

 // Call the Initialize() event.

 this.init(m,y) ;

}



function _show()    
// This function displays the objects canvass.

{

  if(this.isNav4)

  {
   this.canvass.visibility = 'show' ;

   this.canvass.left = this.posX ;
   this.canvass.top = this.posY ;
  }
  else
  {

   this.canvass.style.visibility = 'visible' ;
   this.canvass.style.left = this.posX ;
   this.canvass.style.top = this.posY ;
  }

 this.visible = true ;

}



function _hide()
    // This function hides the objects canvass.
{

  if(this.isNav4)

  {
   this.canvass.visibility = 'hide' ;
  }
  else
  {

   this.canvass.style.visibility = 'hidden' ;
  }

 this.visible = false ;

}

function _init(m,y)

{

  if (parseInt(navigator.appVersion.charAt(0)) >= 4)
    // Browser check.
  {
   this.isNav4 = (navigator.appName == "Netscape") ? true : false ;

   this.isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false ;

  }


  // Populate the current Day|Month|Year properties

 var obj = new Date();
 this.currentDay = obj.getDate();
 this.currentMonth = obj.getMonth() + 1;
 this.currentYear = (obj.getYear() < 1000) ? obj.getYear() + 1900 : obj.getYear();

  /* The constructor optionally accepts m && y parameters
, if none are supplied,the calendar defaults to the current
 month 
*/


 this.month = m || this.currentMonth ;
 this.year = y || this.currentYear ;

 // Create the canvass that we will be displaying the calendar on
 this.createCanvass() ;
 obj = null ;

}



function _createCanvass()       //Create canvass for NN4+
{
  if (this.isNav4)
  {
   this.canvass = new Layer(200) ;
   this.canvass.left = this.posX ;
   this.canvass.top = this.posY ;
  }

 
 // Create canvass for IE4+

  if (this.isIE4)
  {
   var objDiv = document.createElement("<DIV STYLE='position: absolute;background:#E6F0D5;' class='l1'>") ;
   document.body.appendChild (objDiv) ;
   this.canvass = objDiv ;
   this.canvass.style.left = this.posX ;
   this.canvass.style.top = this.posY ;
  }

}



function _positionCanvass(x,y) // if either x or y were not supplied, default to the current settings.
{

  if(x==null || y==null)
  {
   x=this.posX; y=this.posY ; return ;
  }
  if(isNaN(x) || isNaN(y))
  {
   alert('You can only enter numbers for the x/y co-ordinates') ;
   return ;

  }

  // apply the new settings for NN

  if (this.isNav4)
  {
   this.canvass.left = this.posX = x ;
   this.canvass.top = this.posY = y ;
  }

 
  //apply the new settings for NN
  if (this.isIE4)
  {
   this.canvass.style.left = this.posX = x ;
   this.canvass.style.top = this.posY = y ;
  }
}



function _goToCurrent()

{
 this.year = this.currentYear ;
 this.month = this.currentMonth ;
 this.BuildCalendar() ;
}



function _toggleCalendar(n)
{

 var currentMonth = this.month ;
 var currentYear = this.year ;
  if((currentMonth + n) == 0)
  {
   this.year = currentYear-1 ;
   this.month = 12 ;
  }
  else if((currentMonth + n) == 13)
  {
   this.year = currentYear+1 ;
   this.month = 1 ;
  }
  else
  {
   this.month = currentMonth + n ;
  }

  this.BuildCalendar() ;

}



// Create and Display Calendar.


function _create()  
    // Counters to count rows and days, String to store calendar output.
{
 var rowCount = 0 ;
 var numRows = 0 ;
 var sOut = new String() ;
 
  // Leap year correction
  if (this.year % 4 == 0 && (this.year % 100 != 0 || this.year % 400 == 0))
  {
   this.totalDays[1] = 29 ;
  }
 var obj = new Date(this.year, this.month-1, 1);
 var firstDayOfMonth = obj.getDay();
 obj.setDate(31);
 var lastDayOfMonth = obj.getDay();
 obj = null ;
 sOut = "<table border=1 cellpadding=0 cellspacing=0 class=calCalendar width=200 rules=none style='BORDER-COLLAPSE: collapse' borderColor='#007D31'>" ;

 /*  Write the TABLE header (month/year) */


 sOut += "<tr CLASS='UM10'><td width=267 background='/thendral/images/snbtnbk.gif' height=17 colspan=6 align=left><span style=\"font-size: '12';color:#FFFFFF;\">&nbsp;<b>" + this.months[this.month-1] + " " + this.year + "</b></span></td>" ;

 sOut += "<td ALIGN='right'  background='/thendral/images/snbtnbk.gif' height=17><A HREF=\"javascript:  ;\" onClick='calClose() ; return false ;' TITLE='Close'><img src='/thendral/images/x.gif' border='0'></A></td>" ;

 sOut += "</tr>" ;

 /*  Write the abbreviated day names */
 sOut += "<tr class='calMonthsheader'>" ;

  for (x=0; x<7; x++)
  {
   sOut += "<td class='calMonthsheader'><span style='font-size: smaller'>" + this.days[x].substring(0,2) + "</span></td>" ;

  }
  
  sOut += "</tr>" ;

  sOut += "<tr  class='calbody'>" ;
  numRows++ ;

  for(x=1; x<=firstDayOfMonth; x++)
  {
   rowCount++;
   sOut += "<td><span style='font-size: smaller'>&nbsp;</span></td>" ;
  }

  this.dayCount=1;
  while (this.dayCount <= this.totalDays[this.month-1])
  {

   if (rowCount % 7 == 0)
   {
    sOut += "</tr>\n<tr  class='calbody'>" ;
    numRows++ ;
   }
   sOut += "<td align=center CLASS='calbody' onMouseOver=\"this.className = 'calbody';\" onMouseOut=\"this.className = 'calbody';\"><A HREF=\"javascript:  ;\""

  if (this.hasEvents)
   sOut += " onClick='clickhandler(" + this.dayCount + "," + this.month + "," + this.year + ") ;'" ;
   sOut += "CLASS='calbody'>" + this.dayCount + "</A>";
   sOut += "</td>" ;
   this.dayCount++ ;
   rowCount++ ;
  }
  while (rowCount % 7 != 0)
  {
   /* pad the blank days at the end of the month. */
   rowCount++ ;
   sOut += "<td><span style='font-size: smaller'>&nbsp;</span></td>" ;
  }
  sOut += "</tr>" ;
  // End of BODY
  // Write the Calendar Navigator.
  if(this.hasEvents)
  {
   sOut += "<tr>" ;
   sOut += "<td colspan=2 align=left>" ;
   sOut += "<A HREF=\"javascript:  ;\" onClick='toggleCalendar(-1) ; return false ;' CLASS='calbody'  onMouseOver=\"this.className = 'calbody';\" onMouseOut=\"this.className = 'calbody';\" TITLE='Previous Month' /><img src=images/left.gif border=0 hspace=3 vspace=1></A>" ;

   sOut += "</td>" ;
   sOut += "<td colspan=3 align=center>" ;
   sOut += "</td>" ;
   sOut += "<td colspan=2 align=right>" ;
   sOut += "<A HREF=\"javascript:  ;\" onClick='toggleCalendar(1) ; return false ;' CLASS='calbody'  onMouseOver=\"this.className = 'calbody';\" onMouseOut=\"this.className = 'calbody';\" TITLE='Next Month' /><img src=images/right.gif border=0 hspace=3 vspace=1></A>" ;

   
   sOut += "</td>" ;
   sOut += "</tr>" ;
  }
  sOut += "</table>";

  // Render the calendar
  this.showCalendar (sOut) ;
}



function _showCalendar (s)
{
  if(this.isNav4)
  {
   this.canvass.document.open() ;
   this.canvass.document.writeln(s) ;
   this.canvass.document.close() ;
  }
  else
  {
   this.canvass.innerHTML = s ;
  }
    this.show() ;

}



	function produceCalendar (bindToFld)
	{
	    if(typeof(obj1) != 'object') obj1 = new suycCalendar() ;	    
	    if (obj1.isIE4) 
			{
				obj1.posX = window.event.clientX + 0 ;
				obj1.posY = window.event.clientY + 10 ;
			}
	    else 
			{
				obj1.posX = 250 ;
				obj1.posY = 150 ;    
			}
	    if( obj1.visible && bindToFld == obj1.bindToElement )
			{
				obj1.hide() ;
				return ;
			}
		else
			{
				obj1.bindToElement = bindToFld ;
			}
	    obj1.BuildCalendar() ;
	}

function positionCalendar(f)
	{
	    var x = f.txtPosX.value;
	    var y = f.txtPosY.value;
	    if(typeof(obj1) != 'object') produceCalendar () ;
	    if( isNaN(x) || isNaN(y) )
	    {
	        alert('You can only enter numbers for the x/y co-ordinates') ;
	        return ;
	    } else {
	        obj1.moveTo(x,y)
	    }
	}
function comparedate(date1,date2)
{
	var d1 = new Date(date1);
	var d2 = new Date(date2); //alert(date1 +" *** " + date2);
	//return true
	//Need to Comment above line and uncomment next line By Srikanth on October 18 2006
	return (d1<=d2);
}	
function compare30(date1,date2)
{
	var d1 = new Date(date1);
	var d2 = new Date(date2); //alert(date1 +" *** " + date2);
	return (d1<=d2);
}		
function clickhandler (d,m,y)
	{
		var objFld = eval("document.Form1." + obj1.bindToElement) ;  
		var dtemp=new Date();
		tempdate=dtemp.getDate();
		tempmonth=dtemp.getMonth()+1;
		tempyear=dtemp.getFullYear();
		
		newtemp=tempmonth+"/"+tempdate+"/"+tempyear;
		newtemp1=m+"/"+d+"/"+y;
		//alert("newtemp" + newtemp);
		//alert("newtemp1" + newtemp1);
		//alert(m);
		//changed
		var nextmonth=dtemp.getMonth()+2;
		
		nextmonthdate=nextmonth+"/"+tempdate+"/"+tempyear;
		//alert(nextmonthdate);
		//end changes
		verify=comparedate(newtemp,newtemp1);
		//verify30=compare30(newtemp1,nextmonthdate);
		//alert(verify30);
		if (verify==true)
			{
			objFld.disabled = false ;
			objFld.value = d + '-' + obj1.months[obj1.month-1].substring(0,3) + '-' + y ;			
			objFld.disabled = false ;
			obj1.hide() ;	
			}
		else
			{
				
				alert ("Oooops!!!\n\nYou can choose only\n\nToday or a Later date");
			}
		
	    
	}

function toggleCalendar (i)
	{
		obj1.toggleCalendar(i) ;
	}

function toggleCurrent ()
	{
		obj1.goToCurrent() ;
	}

function calClose ()
	{
		obj1.hide() ;
	}
function check(id)
	{
	if (confirm("Are you sure you want to delete?"))
		{
		document.cookie="del=" + id			
		return true;
		}
	else
		return false;
	}
function textenable()
	{
	var checkdate=document.Form1.dtDate1.value;
	if(checkdate=="") 
	    {
	    	alert("Select Date \nby clicking \nCalendar Icon");
		    document.Form1.dtDate1.focus();
			return false;											
			document.Form1.dtDate1.enabled=true
	    }
	//document.Form1.dtDate1.enabled=true
	}
	
//----------------------------------------------------------------------------	
	//for BuddyEvents
	String.prototype.trim = function() 
		{
			// skip leading and trailing whitespace
			// and return everything in between
			var x=this;
			x=x.replace(/^\s*(.*)/, "$1");
			x=x.replace(/(.*?)\s*$/, "$1");
			return x;
		}
		function validatename(obj) 
		{
				var val=obj.value;
				var lenval=obj.value.trim().length;
				if(lenval==0)
				{
					return false
				}
		}
		function chkSplChar()
		{
			if ((event.keyCode > 34 && event.keyCode < 38)||(event.keyCode > 39 && event.keyCode < 40)||(event.keyCode > 41 && event.keyCode < 44) ||(event.keyCode > 46 && event.keyCode < 48)|| (event.keyCode > 59 && event.keyCode < 65) || (event.keyCode > 90 && event.keyCode < 97)) event.returnValue = false;
		//alert(event.keyCode);
		}
		function getDate(date1)
		{
			var my_array = date1.split("-");
			var dd=my_array[0];
			var mm=my_array[1];
			var yyyy=my_array[2];
			if(mm=='Jan') mm=1;
			if(mm=='Feb') mm=2;
			if(mm=='Mar') mm=3;
			if(mm=='Apr') mm=4;
			if(mm=='May') mm=5;
			if(mm=='Jun') mm=6;
			if(mm=='Jul') mm=7;
			if(mm=='Aug') mm=8;
			if(mm=='Sep') mm=9;
			if(mm=='Oct') mm=10;
			if(mm=='Nov') mm=11;
			if(mm=='Dec') mm=12;
			var fulldate1=mm + '/' + dd + '/' + yyyy;
			return fulldate1;
		}
		function comparedates(date1,date2)
		{
			var datevalue1=date1;
			var datevalue2=date2;
			/*alert(date1 +" *** " + date2);
			alert(getDate(date1));
			alert(getDate(date2));*/
			var d1 = new Date(getDate(date1));
			var d2 = new Date(getDate(date2)); 
			//alert(d1<=d2);
			return (d1<=d2);
		}	
		function validate()
		{
			//comparedates(document.Form1.txtStart.value,document.Form1.dtDate1.value);
			
			if(validatename(document.Form1.dtDate1)==false)
			{
				alert('Please select a Date');
				return false;
			}
			var flaginterests=false;
			for(i=0;i<document.Form1.elements.length;i++)
			{
				if(document.Form1.elements[i].type=='radio')
				{
					if(document.Form1.elements[i].checked)
					{
					flaginterests=true;
					break;
					}
				}
			}	
			if(flaginterests==false)
			{
				alert('Please choose a from the list');
				return false;		
			}
		return true;	
		}

