/*----------------------------------------------------------------------------
 (c) 2003 JVolution Ltd. All rights reserved. 
 $Revision: 1.1 $
-----------------------------------------------------------------------------*/
var testundefined ;
var isNav4, isIE4, isNav6;
var days = new makeArray("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var months = new makeArray("January","February","March","April","May","June","July","August","September","October","November","December");
var calendars = new Array() ;

if (parseInt(navigator.appVersion.charAt(0)) >= 4) 
{
  isNav6 = navigator.userAgent.indexOf("Gecko")!=-1?true:false;
  isNav4 = (navigator.appName == "Netscape") ? true && !isNav6: false;
  isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
}

function getCalObj(name)
{
  var foundElement = null ;
  if (document.getElementById)
  {
  	foundElement = document.getElementById(name);
  }
  else if (document.all)
  {
	foundElement = document.all[name];
  }
  else if (document.layers)
  {
	foundElement = getObjNN4(document.forms[0],name);
  }
  return foundElement ;
}
function getObjNN4(obj,name)
{
	if (document.forms[0].name == name)
	{
		foundElement = document.forms[0];
		return foundElement ;
	}
	var x = obj.elements;
	for (var i=0;i<x.length;i++)
	{
		if (x[i] == null) continue ;
		if (x[i].name == name)	
		{
		 	foundElement = x[i];
			return foundElement ;
		}
	}
	return null ;
}

function makeArray() 
{
   for (i = 0; i<makeArray.arguments.length; i++)
    this[i] = makeArray.arguments[i];
}

function JVCalDate(closeimg) 
{
	this.id = calendars.length ;
	calendars[this.id] = this ;

        this.closeimg = closeimg ;
	this.currDay = null;
	this.eventCode = null ;
	this.eventMethod = null ;
	this.jvmonth = null;
	this.jvyear = null;
	this.menulinksactive = true ;
	this.jvdayStyle = "dayout" ;
	this.jvselectedStyle = "dayselected" ;
	this.jvdayflyoverStyle = "dayover" ;
	this.jvheaderStyle = "dateheader" ;
	this.jvbackground = null ;
	this.jvwidth = null ;
	this.jvsetfield = null ;
	this.jvfulldate = false ;
	this.firstupdate = true ;
	this.futureOnly = false ;
	this.savedindx = 0 ;
	this.closeMethod = null ;
        this.dayoffset = 0 ;

	this.setJVDateField = setJVDateField ;
	this.setJVDateColour = setJVDateColour ;
	this.setJVDateStyles = setJVDateStyles ;
	this.createJVCalendar = createJVCalendar ;
	this.setJVDate = setJVDate ;
	this.setJVDateEvent = setJVDateEvent ;
	this.setJVDateEventAction = setJVDateEventAction ;
	this.setJVDateEventMethod = setJVDateEventMethod ;
	this.setJVDateCloseMethod = setJVDateCloseMethod ;
	this.setFullJVDate = setFullJVDate ;
	this.setJVDateRange = setJVDateRange ;
	this.selectJVDate = selectJVDate ;
	this.setTodayJVDate = setTodayJVDate ;
	this.setDateJVDate = setDateJVDate ;
	this.displayCalendarJVDate = displayCalendarJVDate ;
	this.setJVDateWidth = setJVDateWidth ;
	this.setJVDateValue = setJVDateValue ;
	this.setJVDateOffset = setJVDateOffset ;
}
function setJVDateOffset(days)
{
	this.dayoffset = days ;
}
function setJVDateCloseMethod(closeMethod)
{
	this.closeMethod = closeMethod ;
}
function closeMe(id)
{
	if (typeof id != typeof testundefined)
		thisid = calendars[id] ;
	if (thisid.closeMethod != null)
		thisid.closeMethod() ;
}

function setFullJVDate(value)
{
	this.jvfulldate = value ;
}
function setJVDateField(datefield)
{
	this.jvsetfield = datefield ;
}
function setJVDateWidth(width)
{
	this.jvwidth = width ;
}
function setJVDateRange(future, maxdaycount)
{
	this.futureOnly = future ;
	if (typeof maxdaycount != typeof testundefined)
		this.maxdaycount = maxdaycount ;
}
function setJVDateColour(background)
{
	this.jvbackground = background ;
}
function setJVDateStyles(dayStyle, selectedStyle, flyoverStyle, headerStyle)
{
	this.jvdayStyle = dayStyle ;
	this.jvselectedStyle = selectedStyle ;
	this.jvdayflyoverStyle = flyoverStyle ;
	this.jvheaderStyle = headerStyle ;
}
function setJVDateValue(dateobj, e)
{
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return ;
	if (keycode	!=13 ) return ;

	var datefields = dateobj.value.split('/') ;
	if (datefields.length < 3)
	{
		alert("Invalid date field") ;
		dateobj.focus() ;
	}
	var datevalue = new Date(parseInt(datefields[2]),parseInt(datefields[1])-1,parseInt(datefields[0]));
	if (datevalue == "NaN") return ;
	this.setDateJVDate(datevalue) ;
	return false ;
}
function createJVCalendar()
{
	var calHtml ;
	calHtml = '<div id="divControls' + this.id + '"' ;
	if (this.jvbackground != null)
		calHtml = calHtml + ' style="background:' + this.jvbackground + ';' ;
	if (this.jvwidth != null)
		calHtml = calHtml + 'width:' + this.jvwidth + ';' ;
	if (this.jvbackground != null || this.jvwidth != null)
		calHtml = calHtml + '"' ;
	if (this.jvclass != null)
		calHtml = calHtml + ' class="' + this.jvclass + '"' ;
	calHtml = calHtml + '>' ;
	calHtml = calHtml + '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%" align="center">' ;
	calHtml = calHtml + '<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>' ;
	var i ;
	for (i = 0 ; i < 12 ; i++)
	{
		calHtml = calHtml + '<td align="center">' ;
		calHtml = calHtml + '<div class="month" name="jvmonth' + this.id + '_' + i + '" id="jvmonth' + this.id + '_' + i + '" onclick="setMonthJVDate(' + this.id + ',' + i + ')" ' ;
		calHtml+= ' onMouseOver="if (monthIsSelected(' + this.id + ',' + i + ')) return ; setCSS(0, \'jvmonth' + this.id + '_' + i + '\',\'monthover\');"' ;
		calHtml+= ' onMouseOut="if (monthIsSelected(' + this.id + ',' + i + ')) return ; setCSS(0, \'jvmonth' + this.id + '_' + i + '\',\'month\');" >' + months[i].substring(0,3) + '</div></td>' ;
		if (i == 5)
			calHtml = calHtml + '</tr><tr>' ;
	}
	calHtml = calHtml + '</td></tr></table></td>' ;
	if (this.closeMethod != null)
		calHtml = calHtml + '<td valign="top" align="right" width="5"><a href="#" onClick="closeMe(' + this.id + '); return false;"><img src="' + this.closeimg + '" border="0"></a></td>' ;
	calHtml = calHtml + '</tr>' ;
	calHtml = calHtml + '<tr><td align="center">' ;
	calHtml = calHtml + '<span class="year" name="jvpreviousyear' + this.id + '" id="jvpreviousyear' + this.id + '" onClick="setPreviousYearJVDate(' + this.id + '); return false;" style="cursor:hand;"' ;
	calHtml+= ' onMouseOver="return setCSS(0, \'jvpreviousyear' + this.id + '\',\'yearover\');"' ;
	calHtml+= ' onMouseOut="return setCSS(0, \'jvpreviousyear' + this.id + '\',\'year\');" >&LT;</span>' ;
	calHtml = calHtml + '<span class="monthyear" name="jvmonthyear' + this.id + '" id="jvmonthyear' + this.id + '"';
	calHtml+= ');" >Month-Year</span>' ;
	calHtml = calHtml + '<span class="year" name="jvnextyear' + this.id + '" id="jvnextyear' + this.id + '" onClick="setNextYearJVDate(' + this.id + ');return false;" style="cursor:hand;"' ;
	calHtml+= ' onMouseOver="return setCSS(0, \'jvnextyear' + this.id + '\',\'yearover\');"' ;
	calHtml+= ' onMouseOut="return setCSS(0, \'jvnextyear' + this.id + '\',\'year\');" >&GT;</span>' ;
	calHtml = calHtml + '</td>' ;
	calHtml = calHtml + '</tr></table></div><div name="divCal' + this.id + '" id="divCal' + this.id + '"' ;
	if (this.jvbackground != null)
		calHtml = calHtml + ' style="background:' + this.jvbackground + ';"' ;
	calHtml = calHtml + '></div>' ;
	document.write(calHtml) ;
}
function setJVDateEvent(code)
{
	this.eventCode = code ;
}
function setJVDateEventMethod(eventmethod)
{
	this.eventMethod = eventmethod ;
}
function setJVDateEventAction(status)
{
	this.menulinksactive = status ;
}
function setJVDate(id) 
{
	var thisid = this ;
	if (typeof id != typeof testundefined)
		thisid = calendars[id] ;
	else
		id = this.id ;
	// If a field is defined update that field
	if (this.jvsetfield != null)
	{
		var fields = this.jvsetfield.split(",") ;
		var i ;
		for (i = 0 ; i < fields.length ; i++)
		{
	   	var datefield ;
			if (document.layers)
	  			datefield=eval("document.divControls.document.all[\"" + fields[i] + "\"]");
			else
			if (isIE4)
	  			datefield=eval("document.all[\"" + fields[i] + "\"]");
			else
	     		datefield = document.getElementById(fields[i]);
			if (datefield != null && datefield.length > 0)
			{
				setDateJVDate(datefield.value) ;
			}
		}
	}

   var now   = new Date();
   var day   = now.getDate();
   var month = now.getMonth();
   var year  = now.getFullYear();
   
	setCSS(0, "jvmonth" + id + "_" + thisid.jvmonth,"month");

   if (document.layers)
   {
      top.main.document.location.reload();

      var allcookies = document.cookie;
      var pos = allcookies.indexOf('calDate=');
      if( pos != -1 )
      {
         pos += 8;
         var end = allcookies.indexOf(';',pos);
         if( end == -1 ) end = allcookies.length;
         var value = allcookies.substring(pos, end);
         var dateComps = value.split('-');
         day = dateComps[0];
         month = dateComps[1];
         year = dateComps[2];
      }
   }
	thisid.startday = day ;
	thisid.startmonth = month; 
	thisid.startyear = year; 
    thisid.currDay = day ;
	thisid.jvmonth = month; 
	thisid.jvyear = year; 

   thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear);
}
function monthIsSelected(id, monthno)
{
	var thisid = this ;
	if (typeof id != typeof testundefined)
		thisid = calendars[id] ;
	if (thisid.jvmonth == monthno)
		return true ; 
	else
		return false ;
}
function setMonthJVDate(id, monthno)
{
	var thisid = this ;
	if (typeof id != typeof testundefined)
		thisid = calendars[id] ;
		
	var now   = new Date();
	var month = now.getMonth();
	var year  = now.getFullYear();
	//if (thisid.jvyear == year && monthno < month) return false ;

	setCSS(0, "jvmonth" + id + "_" + thisid.jvmonth,"month");
	thisid.jvmonth = monthno; 
	setCSS(0, "jvmonth" + id + "_" + monthno,"monthselected");
	return thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear) ;
}
function checkKeyJVDate(thisid, event)
{
   // Check to see if the return key was pressed
   if( event.keyCode == 13 )
   {
      thisid.selectJVDate();     
   }
}
function setDateJVDate(datestr) 
{
	if (datestr == "")
	{
		this.setJVDate()
		return false ;
	}
   cmp = "0123456789/" ;
  	for (j = 0 ; j < datestr.length ; j++)
	{
   	tst = datestr.substring(j, j+1)
   	if (cmp.indexOf(tst) < 0)
		{
			return false ;
		}
	}
	dateFields = datestr.split("/") ;
	if (dateFields.length < 3)
		dateFields = datestr.split('\\') ;
	if (dateFields.length < 3)
		dateFields = datestr.split('-') ;
	if (dateFields.length < 3)
		dateFields = datestr.split('_') ;
	if (dateFields.length < 3)
		datefields = datestr.split('.') ;
	if (dateFields.length < 3)
		dateFields = datestr.split(',') ;
	if (dateFields.length < 3) return false
	if (dateFields[2] == undefined) return false ;

	var now   = new Date(dateFields[2]+"/"+dateFields[1]+"/"+dateFields[0]);
	var day   = now.getDate();
	var month = now.getMonth();
	var year  = now.getFullYear();

	this.startday = day ;
	this.startmonth = month; 
	this.startyear = year; 
	this.currDay = day;
	this.jvmonth = month; 
	this.jvyear = year; 
	return this.displayCalendarJVDate(day, month, year) ;
}
function setTodayJVDate() 
{
    var now   = new Date();
    var day   = now.getDate();
    var month = now.getMonth();
    var year  = now.getFullYear();

	setCSS(0, "jvmonth" + this.id + "_" + thisid.jvmonth,"month");
	this.startday = day ;
	this.startmonth = month; 
	this.startyear = year; 
	this.jvmonth = month; 
	this.jvyear = year; 
    this.currDay = day;

	setCSS(0, "jvmonth" + this.id + "_" + month,"monthselected");

    return this.displayCalendarJVDate(day, month, year);
}

function selectJVDate(id) 
{
	thisid = this ;
	if (typeof id != typeof testundefined)
		thisid = calendars[id] ;
   var year  = thisid.jvyear ;
   if (isFourDigitYearJVDate(year)) 
   {
      var month = thisid.jvmonth ;
      return thisid.displayCalendarJVDate(thisid.currDay, month, year) ;
   }
	return true ;
}

function setPreviousYearJVDate(id) 
{
	var thisid = calendars[id] ;

	var now   = new Date();
	var month = now.getMonth();
	var year  = now.getFullYear();
	//if (thisid.jvyear > year)
		thisid.jvyear--;
	if (thisid.jvyear == year && thisid.jvmonth < month) 
		setMonthJVDate(id, month) ;

	thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear) ;
}

function setPreviousMonthJVDate(id) 
{
	var thisid = calendars[id] ;

	if (thisid.jvmonth == 0) 
   {
      thisid.jvmonth = 11;
      if (thisid.jvyear > 1000) thisid.jvyear--;
	}
	else 
		thisid.jvmonth--;

	thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear) ;
}

function setNextMonthJVDate(id) 
{
	var thisid = calendars[id] ;

	if (thisid.jvmonth == 11) 
	{
	   thisid.jvmonth = 0;
	   thisid.jvyear++;
	}
 	else 
	   thisid.jvmonth++;

	thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear) ;
}

function setNextYearJVDate(id) 
{
	var thisid = calendars[id] ;

   thisid.jvyear++;

	thisid.displayCalendarJVDate(thisid.currDay, thisid.jvmonth, thisid.jvyear) ;
}

function validateJVDateRange(message1, message2)
{
	return checkDateRange(message1, message2, this.currDay, this.jvmonth, jvyear) ;	
}

function checkDateRange(message1, message2, day, month, year)
{
	if (false == this.firstupdate)
	{
		var now   = new Date();
		var nowday   = now.getDate();
		var nowmonth = now.getMonth();
		var nowyear  = now.getFullYear();
		now = new Date(nowyear,nowmonth,nowday) ;
		var theDate = new Date(year,month,day) ;
		if (this.futureOnly)
		{
			if (theDate < now)
			{
				alert(message1) ;
				return false ;
			}
		}
		if (this.maxdaycount)
		{
			var nextDate = new Date(nowyear,nowmonth,nowday) ; with (nextDate) setDate(getDate()+this.maxdaycount) ;
			if (theDate > nextDate)
			{
				alert(message2 + " " + formatJVDate(nextDate)) ;
				return false ;
			}
		}
	}
	return true ;
}
function displayCalendarJVDate(day, month, year) 
{
	setCSS(0, "jvmonth" + this.id + "_" + month,"monthselected");

   var calHtml = '';

   calHtml += '<center><table border="0" cellpadding="0" cellspacing="0" width="95%">';
   calHtml += '<tr>' ;
   calHtml += '<td width="14%" align="center">'
+ '<DIV class="' + this.jvheaderStyle + '">m</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">t</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">w</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">t</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">f</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">s</DIV>'
+ '</td><td width="14%" align="center"><DIV class="' + this.jvheaderStyle + '">s</DIV>'
+ '</td></tr><tr>';

   var month = parseInt(this.jvmonth);
   var year = parseInt(this.jvyear);
   var days = getDaysInMonthJVDate(month+1,year);
   var firstOfMonth = new Date (year, month, 1);
   var startingPos  = firstOfMonth.getDay()-1;
   if (startingPos < 0) startingPos = 6 ;
   days += startingPos;
   var bitOfPreviousMonth = new Date (year, month, 1-startingPos);
   var previousMonthDate  = bitOfPreviousMonth.getDate();
   if (document.layers)
    	document.cookie = 'calDate='+firstOfMonth.getDay()+'-'+month+'-'+year;
   for (i = 0; i < startingPos; i++) 
   {
	     calHtml += '<td align="center"><DIV class="dayother">' + previousMonthDate++ + '</DIV></td>' ;
		bitOfPreviousMonth = new Date (year, month-1, previousMonthDate);
   }
   var dayOfMonth = 0;
   var numCalRows = 1;

   for (i = startingPos; i < days; i++)
   {
      dayOfMonth = (i-startingPos+1);
     if( (i % 7) == 0 && i > 0)
      {
         calHtml += '</tr><tr>';
      }
      calHtml+= '<td align="middle">';

		var todayDate = new Date() ;
                if (this.dayoffset != null) //this.dayoffset > 0)
                       todayDate.setDate(todayDate.getDate()+this.dayoffset);
		todayDate = new Date(todayDate.getFullYear(), todayDate.getMonth(), todayDate.getDate()) ;
		thisDate = new Date (year, month, dayOfMonth);
		if (thisDate < todayDate)
		{
	      calHtml += '<DIV class="dayother">'  + dayOfMonth + '</DIV>' ;
		}
		else		
      if( dayOfMonth == this.startday && this.jvmonth == this.startmonth && this.jvyear == this.startyear)
      {
        calHtml+= '<a href="#" onClick="return clickDateJVDate(' + this.id + ',' + dayOfMonth + ');">' ;
      	calHtml+= '<DIV NAME="DAY_' + dayOfMonth + '_' + this.id + '" ID="DAY_' + dayOfMonth + '_' + this.id + '" class="dayselected">' + dayOfMonth + '</DIV>' ;
        calHtml+= '</a>';
      }
      else
      {
        calHtml+= '<a href="#" onClick="return clickDateJVDate(' + this.id + ',' + dayOfMonth + ');"' ;
		calHtml+= ' onMouseOver="return setCSS(0, \'DAY_' + dayOfMonth + '_' + this.id + '\',\'dayover\');"' ;
		calHtml+= ' onMouseOut="return setCSS(0, \'DAY_' + dayOfMonth + '_' + this.id + '\',\'dayout\');" >' ;
      	calHtml+= '<DIV NAME="DAY_' + dayOfMonth + '_' + this.id + '" ID="DAY_' + dayOfMonth + '_' + this.id + '" class="dayout">' + dayOfMonth + '</DIV>' ;
        calHtml+= '</a>';
      }
      calHtml += '</td>\n';
   }

	var shownextmonth = true ;
   for (i=days; i<42; i++)  
   {
      if( (i % 7) == 0 )
      {
         calHtml += '</tr>\n<tr>';
         ++numCalRows;
			shownextmonth = false ;
      }
		if (shownextmonth)
		{
			var bitOfNextMonth = new Date(this.jvyear, this.jvmonth+1, i-days+1) ;
			if (bitOfNextMonth >= this.fromDate && bitOfNextMonth <= this.toDate)
	      	calHtml += '<td align="center" class="cal"><DIV class="dayselected">' + eval(i-days+1) + '</DIV></td>\n';
			else
	      	calHtml += '<td align="center" class="cal"><DIV class="dayother">' + eval(i-days+1) + '</DIV></td>\n';
		}
		else
   	   calHtml += '<td class="cal">&nbsp;</td>\n';
   }
   calHtml += '</tr>';
   calHtml += '</table></center>';
 
	var elm ;

   if( document.layers )
   {
	elm = getCalObj("divCal" + this.id);
      with( elm )
      {
         open();
         writeln(calHtml);
         close();
      }
   }
   else
   {      
	elm = getCalObj("divCal" + this.id);
	elm.innerHTML=calHtml;
   }

	if (this.eventMethod != null) eval(this.eventMethod) ;

	// Only do events on other loads
	if (this.firstupdate)
	{
		this.firstupdate = false ;

		this.monthyearobj = getCalObj("jvmonthyear" + this.id);
		if (this.monthyearobj.innerText)
			this.monthyearobj.innerText = this.jvyear ;
		else
			this.monthyearobj.textContent = this.jvyear ;
		return ;
	}
	if (this.monthyearobj.innerText)
		this.monthyearobj.innerText = this.jvyear ;
	else
		this.monthyearobj.textContent = this.jvyear ;
	return ;
	// Do any events on select
	if (this.eventCode != null)
	{
		if (this.menulinksactive == false)
			alert("Events are disable, code/link is " + this.eventCode) ;
		else
			parent.location = this.eventCode ;
	}
	return true ;
}

function getDaysInMonthJVDate(month,year)  
{
   var days;
   if (month==1 || month==3 || month==5 || month==7 || month==8 ||
       month==10 || month==12)  days=31;
   else if (month==4 || month==6 || month==9 || month==11) days=30;
   else if (month==2)  
   {
      if (isLeapYearJVDate(year)) 
      {
         days=29;
      }
      else 
      {
         days=28;
      }
   }
   return (days);
}

function isLeapYearJVDate(Year) 
{
   if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) 
   {
      return (true);
   }
   else 
   {
      return (false);
   }
}

function clickDateJVDate(id, inDay)
{
	var thisid = calendars[id] ;
    var day   = inDay;
    var month = thisid.jvmonth;
    var year  = thisid.jvyear;

    thisid.currDay = inDay;
	thisid.startday = thisid.currDay ;
	thisid.startmonth = thisid.jvmonth; 
	thisid.startyear = thisid.jvyear; 

   thisid.displayCalendarJVDate(thisid.currDay, month, year);

	// If a field is defined update that field
	if (thisid.jvsetfield != null)
	{
		var fields = thisid.jvsetfield.split(",") ;
		var i ;
		for (i = 0 ; i < fields.length ; i++)
		{
	   		var datefield = getCalObj(fields[i]);
			if (datefield != null)
			{
				if (datefield.type == "text" || datefield.type == "input" || datefield.type == "hidden")
					datefield.value = formatShortJVDate(day, month+1, year) ;
				else
					datefield.innerHTML = formatShortJVDate(day, month+1, year) ;
			}
			datefield.focus() ;
		}
	}

	if (thisid.eventMethod != null) thisid.eventMethod() ;

   return false;
}

function getIsoDateJVDate()
{
   return formatIsoDateJVDate(this.currDay, this.jvmonth+1, jvyear);
}

function formatIsoDateJVDate(day, month, year)
{
   var isoDate = '';

   isoDate +=year;
   if( month < 10 )
   {
      isoDate += '0';
   }
   isoDate +=month;
   if( day < 10 )
   {
      isoDate+='0';
   }
   isoDate += day;

   return isoDate;
}

function getShortJVDate()
{
   return formatShortJVDate(this.currDay, this.jvmonth+1, jvyear);
}
function formatShortJVDate(day, month, year)
{
   var shortDate = '';

   if( day < 10 )
   {
      shortDate+='0';
   }
   shortDate += day + '/';
   if( month < 10 )
   {
      shortDate += '0';
   }
   shortDate +=month + '/';
   shortDate +=year;

   return shortDate;
}

function getJVDate()
{
	if (this.jvfulldate)
		return getDateJVDate(this.currDay) ;
	else
		return getShortJVDate() ;
}
function getDateJVDate(indate)
{
   var selDate = new Date(Date.UTC(jvyear, this.jvmonth, indate));
   var dateString = "";
   dateString += days[selDate.getDay()];
   dateString += " ";
   dateString += indate;
	if (indate == 1 || indate == 21 || indate == 31)
   	dateString += "st" ;
	else
	if (indate == 2 || indate == 22)
   	dateString += "nd" ;
	else
	if (indate == 3 || indate == 23)
   	dateString += "rd" ;
	else
   	dateString += "th" ;

   dateString += " ";
   dateString += months[this.jvmonth];
   dateString += " ";
   dateString += jvyear;
   return dateString;
}

function formatJVDate(selDate)
{
   var dateString = "";
   dateString += days[selDate.getDay()];
   dateString += " ";
	var indate = selDate.getDate() ;
   dateString += indate;
	if (indate == 1 || indate == 21 || indate == 31)
   	dateString += "st" ;
	else
	if (indate == 2 || indate == 22)
   	dateString += "nd" ;
	else
	if (indate == 3 || indate == 23)
   	dateString += "rd" ;
	else
   	dateString += "th" ;

   dateString += " ";
   dateString += months[selDate.getMonth()];
   dateString += " ";
   dateString += selDate.getFullYear();
   return dateString;
}

function getWeekEndDateJVDate()
{
   var selDate = new Date(Date.UTC(jvyear, this.jvmonth, this.currDay));
   var weekEnd = null;

   var adjustDays = 7 - selDate.getDay();
   if( adjustDays < 7 )
   {
      selDate.setTime(selDate.getTime()+ 1000*60*60*24*adjustDays)
   }

   return formatIsoDateJVDate(selDate.getDate(), selDate.getMonth()+1, selDate.getFullYear());
}

function setCSS(selected, name, cssname)
{
	if (selected == 1) return false ;
	var elm = getCalObj(name);
	if (elm != null)
		elm.className = cssname ;
	return false ;
}

