
<!--
// Use Freely as long as following disclaimer is intact ::
//----------------------------------------------------------
// Popup Calendar + Date Picker v1.2 30th November 2004
// This script written by Rik Comery. http://ricom.co.uk
// For support, visit the "Resources" section at http://ricom.co.uk
// All rights reserved.

// Calendar Configuration ============================================================================================================
popStatus = 1                       // Set calander as always visible, or popup.  0=always visible, 1=popup
scrollingMonth = 1                  // Allow user to scroll through months.  0=no, 1=yes
clickDate = 1                       // Allow users to click dates. 0=no, 1=yes
todayHighlight = 1                  // Highlight today's date. 0=no, 1=yes
dateBox = 1                         // Include a text box next to the calendar.  0=no, 1=yes
dateClickEvent = ""                 // Event(s) to run when a date is clicked. A useful one is closeCalendar(). separate with a ;
                                    // For example: dateClickEvent = "alert('this is a popup'); closeCalendar()"

outerBorder = "#003366";            // Colour of outer border.  For no border, enter "0"
monthBackground = "#003366";        // Background colour of month strap
monthColor = "#FFFFFF";             // Text colour of Month title
monthFace = "arial, sans-serif";    // Font of Month title
monthSize = "10pt"   ;              // Font size of Month title
monthWeight = "bold";               // Weight of Month title. (bold or normal)

dayBackground = "#AFAFAF";          // Background colour  of day labels
dayColor = "#FFFFFF";               // Text colour of day labels
dayFace = "arial, sans-serif";      // Font of day labels
daySize = "8pt"                     // Font size of day labels
dayWeight = "bold";                 // Weight of day labels. (bold or normal)

dateFace = "arial,sans-serif";      // Font of dates
dateSize = "8pt";                   // Font size of dates
dateColor = "#000000";              // Text colour of dates

dividingLine = "#ededed";           // Colour of dividing lines

emptyBack = "#E2F3FB";              // Background colour of empty date cells
fullBack = "#B3D4D8";               // Background colour of full date cells
fullWeekendBack = "#A2C0C3";        // Background colour of weekend cells
fullBackHover = "#FFFFCC";          // Background colour of date cells on mouse over

todayBorder = "#8AA3A5";            // Border colour to highlight today's date. Use "0" for no border. todayHighlight must be set to 1.
todayBack = "#CAEFF3";              // Background colour of today's date. todayHighlight must be set to 1.
todayColor = "#993300";             // Text colour of today's date. todayHighlight must be set to 1.
todayWeight = "bold";               // Weight of today's date. (bold or normal). todayHighlight must be set to 1.

plusSymbol = ">";                   // Symbol to forward month.  You may also us images. e.g. plusSymbol = "<img src='plus.gif' />";
minusSymbol = "<";                  // Symbol to reverse month.  You may also us images. e.g. minusSymbol = "<img src='minus.gif' />";

separateWeekend=1;                  // Places a dividing line between week days and weekends. 1=yes, 0=no

dateFormat = "DD MMMM YYYY";        // Format date will appear in text box. 
                                    // DD = date, 
                                    // MM = month in figures. eg 12 for December
                                    // MMM = Short Month. eg Dec
                                    // MMMM = Long Month. eg. December
                                    // yy = Short Year. eg. 04
                                    // yyyy = Long Year. eg. 2004
                                    
                                    // Other examples are:
                                    // DD - MMM - YYYY (25 - Dec - 2004)
                                    // YYYY-MM-DD (2004-12-25)
                                    // MMMM DD, YYYY (December 25, 2004)
 
// Month + Day Labels ======================================================================================================================
// Change the months and day labels as appropriate.  Ensure they remain within quotes.
rcMonths=new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
rcShortMonths=new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec")
rcDays=new Array("M","T","W","T","F","S","S")

// End Configuration. Do Not Edit Below This Line ==========================================================================================

//Browser Sniffer
if(navigator.appName.indexOf("Microsoft")>-1){browser="ie";}
if(navigator.appName.indexOf("Microsoft")>-1&&navigator.userAgent.indexOf("Opera")>-1){browser="opera";}
if(navigator.appName.indexOf("Netscape")>-1&&navigator.userAgent.indexOf("Netscape")<0){browser="moz";}
if(navigator.appName.indexOf("Netscape")>-1&&navigator.vendor.indexOf("Firefox")>-1){browser="firefox";}
if(navigator.appName.indexOf("Netscape")>-1&&navigator.vendorSub>6){browser="ns6";}

if(browser=="ie") var obj = "document.all";
else if(browser=="ns4") var obj = "document.layers";
else var obj = "document.getElementById";

style='<style type="text/css">';
style+='a{text-decoration:none}';
style+='.monthhead{font-family:'+monthFace+';font-size:'+monthSize+';background-color:'+monthBackground+';color:'+monthColor+'; font-weight:'+monthWeight+'}';
style+='.dayhead{font-family:'+dayFace+';font-size:'+daySize+';background-color:'+dayBackground+';color:'+dayColor+'; text-align:center; cursor:default; font-weight:'+monthWeight+'}';
style+='.divider{background-color:'+dividingLine+'}';
style+='.absent{background-color:'+emptyBack+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+dateColor+'; cursor:default}';
style+='.full{background-color:'+fullBack+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+dateColor+';';
if(clickDate==1){style+=' cursor:hand';}
style+='}';
style+='.fullweekend{background-color:'+fullWeekendBack+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+dateColor+';';
if(clickDate==1){style+=' cursor:hand';}
style+='}';
style+='.fullhover{background-color:'+fullBackHover+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+dateColor+'; cursor:hand}';
style+='.today{background-color:'+todayBack+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+todayColor+'; font-weight:'+todayWeight;
if (todayBorder !="0"){style+=';padding:2px;  border:1px solid '+todayBorder;}
if(clickDate==1){style+='; cursor:hand';}
style+='}';
style+='.todayhover{background-color:'+todayBack+'; font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+todayColor+'; font-weight:'+todayWeight;
if (todayBorder !="0"){style+=';padding:2px;  border:1px solid '+todayBorder;}
style+='; cursor:hand}';
style+='.close{font-family:'+dateFace+'; font-size:'+dateSize+'; color:'+dateColor+'; cursor:hand}';
style+='</style>';
document.writeln(style);

function doRCCalendar(){
  doCalc='<table border="0" cellpadding="0" cellspacing="0"><tr><td>';
  doCalc+='<div z-index="999" id="calendarDateDiv">';
  doCalc+='<table border="0" cellpadding="0" cellspacing="0"><tr><td nowrap="nowrap"><p>';
  if(dateBox==1){doCalc+='<input type="text" id="calendarDate" name="calendarDate">';}else{doCalc+='&nbsp;';}
  if(popStatus>0){
    doCalc+='&nbsp;<a href="javascript:void(0)" onClick="showCalendar()"><img src="images/calendar.gif" border="0"  alt="Calendar Popup" /><\/a>';
  }
  doCalc+='</p><\/td><\/tr><\/table>';
  doCalc+='<\/div>';
  doCalc+='<div z-index="1000" id="calendarBox" name="calendarBox" style="visibility:hidden; position:absolute;"><\/div>';
  doCalc+='</td></tr></table>';
  document.writeln(doCalc);
  getRCCalendar(); 
}

function showCalendar(when){
    if(when==""|| when==null){
      var dateBoxObj = eval(obj+'("calendarBox")')
      var dateDivObj = eval(obj+'("calendarDateDiv")')
      getOffset(dateDivObj,'top')
      getOffset(dateDivObj,'left')
      getOffset(dateDivObj,'width')
      
      dateBoxObj.style.left=oLeft+oWidth+10;    
      dateBoxObj.style.top=oTop;
      dateBoxObj.style.visibility = "visible"
    }else{
      if(popStatus==0){
        showCalendar();
      }
    }
}

function closeCalendar(){  
  var dateBoxObj = eval(obj+'("calendarBox")')
  dateBoxObj.style.visibility = "hidden";
}

function highlight(obj, state, rcMonth, rcYear){
  if(obj.id==nowDate&&rcMonth==nowMonth&&rcYear==nowYear&&todayHighlight==1){
    obj.className="todayhover";
  }else{
    obj.className=state;
  }
}

// Find positioning for calendar
function getOffset(obj, dim) 
{
  if(dim=="left") 
  {     
    oLeft = obj.offsetLeft; 
    while(obj.offsetParent!=null) 
    {    
      oParent = obj.offsetParent     
      oLeft += oParent.offsetLeft 
      obj = oParent 	
    }
    return oLeft
  }
  else if(dim=="top")
  {
    oTop = obj.offsetTop;
    while(obj.offsetParent!=null) 
    {
      oParent = obj.offsetParent
      oTop += oParent.offsetTop
      obj = oParent 	
    }
    return oTop
  }
  else if(dim=="width")
  {
    oWidth = obj.offsetWidth
    return oWidth
  }  
  else if(dim=="height")
  {
    oHeight = obj.offsetHeight
    return oHeight
  }    
  else
  {
    alert("Error: invalid offset dimension '" + dim + "' in getOffset()")
    return false;
  }
}

function showDate(year, month, date){
  if(dateFormat.indexOf("MM")>-1 && dateFormat.indexOf("MMM")<0){month = month-1;}
  newDate=new Date(year, month, date)
  if(dateFormat.indexOf("MM")>-1 && dateFormat.indexOf("MMM")<0){month = month+1;}  
  day = makeString(newDate.getDate());
  if(dateFormat.indexOf("MMM")<0){month = makeString(month)}
  year = newDate.getYear();
  if (year < 1000) {year += 1900}
  year = makeString(year)
  shortMonth=rcShortMonths[month];
  longMonth=rcMonths[month];
  year = (dateFormat.indexOf("YYYY")>-1)?year:year.substring(2,4);
  newDateFormat=dateFormat.replace(/DD/g, day).replace(/MMMM/g, longMonth).replace(/MMM/g, shortMonth).replace(/Y{1,4}/g, year).replace(/MM/g, month)

  eval(obj+'("calendarDate").value=newDateFormat')

}

function makeString(value){
  return ((value<10)?"0":"")+value
}

function clearForm(){
eval(obj+'("calendarDate").value=""') 
}

function getRCCalendar(year, month){
  now=new Date()
  nowDate=now.getDate()
  nowMonth=now.getMonth()
  nowYear=now.getYear()  
  if (nowYear < 1000) {nowYear += 1900}

  
  if(year==null || month==null){rcNow = new Date()}
  else{rcNow = new Date(year, month, 1)}
  var rcDate = rcNow.getDate()
  var rcMonth = rcNow.getMonth()
  var rcYear = rcNow.getYear()
  if (rcYear < 1000) {rcYear += 1900}

  
  whatMonth=rcMonth;
  whatMonths=rcMonths[whatMonth]  
  thisMonth = new Date(rcYear, whatMonth, 1)
  nextMonth = new Date(rcYear, whatMonth+1, 1)
  
  totalDays=Math.round((nextMonth.getTime() - thisMonth.getTime()) / (1000 * 60 * 60 * 24));
  
  firstDay = thisMonth.getDay();
  lastDay = new Date(rcYear, whatMonth, totalDays).getDay()
  
  cal='<table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2">';
  cal+='<table border="0" cellpadding="3" cellspacing="0" align="center"'; if(outerBorder!="0") {cal+=' style="border:1px solid '+outerBorder+'"';} cal+='><tr class="monthhead"><td align="center">';
  if(scrollingMonth==1){cal+='<a href="javascript:void(0)" onClick="getRCCalendar('+rcYear+','+(rcMonth-1)+')" class="monthhead">'+minusSymbol+'<\/a>';}
  else{cal+='<p>&nbsp;</p>'}
  cal+='<\/td><td colspan="5" align="center" nowrap="nowrap" style="cursor:default; color: #FFFFFF">'+whatMonths+' '+rcYear+'<\/td><td align="center">';  
  if(scrollingMonth==1){cal+='<a href="javascript:void(0)" onClick="getRCCalendar('+rcYear+','+(rcMonth+1)+')" class="monthhead">'+plusSymbol+'<\/a>';}
  else{cal+='<p>&nbsp;</p>';}
  cal+='<\/td><\/tr><tr>';
  for(x=0;x<7;x++){cal+='<td style="padding:0px" class="divider"><img src="blank.gif" height="1" width="22" alt="" /><\/td>';}
  cal+='<\/tr>';
  for(y=0;y<7;y++){
    cal+='<td class="dayhead"';
    if(y<6){cal+='style="border-right:1px solid '+dividingLine+'"';}
    cal+='>'+rcDays[y]+'<\/td>';   
  }
  cal+='<\/tr>';
  for(x=0;x<7;x++){cal+='<td style="padding:0px" class="divider"><img src="blank.gif" height="1" width="19" alt="" /><\/td>';}
  cal+='<\/tr><tr>';
  displayDate=1;
  cellID=1;
  
  while (displayDate <= totalDays)
  {
  
    if(cellID<firstDay)
    {cal+='<td class="absent"><p>&nbsp;<\/p><\/td>';}
    else
    {
      if(!(cellID%7-6)||!(cellID%7)){newClass="fullweekend";}
      else{
        if(displayDate==nowDate&&rcMonth==nowMonth&&rcYear==nowYear&&todayHighlight==1)
        {newClass="today"; linkColor=todayColor}
        else{newClass="full"; linkColor=dateColor;}
      }
      extender=(dateFormat.indexOf("MMM")>-1)?0:1
      cal+='<td id="'+displayDate+'" class="'+newClass+'"';
      if(!(cellID%7-5)&&separateWeekend==1){cal+='style="border-right:1px solid '+dividingLine+'"';}
      cal+=' align="center"';
      if(clickDate==1){
        if(dateClickEvent==""){
          cal+='onClick="if(dateBox==1){showDate(\''+rcYear+'\',\''+(rcMonth+extender)+'\',\''+displayDate+'\');}';
          cal+=' window.status=rcMonths['+rcMonth+']+\' \'+'+displayDate+'+\', \'+'+rcYear+';';
          if(popStatus==1){cal+=' closeCalendar();';}
          cal+=' return true"';
        }else{cal+='onClick="'+dateClickEvent+'"'}
        cal+=' onMouseOver="highlight(this,\'fullhover\',\''+rcMonth+'\',\''+rcYear+'\'); window.status=rcMonths['+rcMonth+']+\' \'+'+displayDate+'+\', \'+'+rcYear+'; return true"';
        cal+=' onMouseOut="highlight(this,\''+newClass+'\',\''+rcMonth+'\',\''+rcYear+'\'); window.status=\'\'">';
        cal+='<a href="javascript:void(0)" style="color:'+linkColor+'" >'+displayDate+'<\/a>';
      }else{cal+='<span class="staticdate">'+displayDate+'</span>'}
      cal+='<\/td>';
    }
    if (!(cellID%7)) {cal+='<\/tr>'}  
    if(cellID>=firstDay){displayDate++; }
    cellID++
    
  }
  while(((cellID-1)%7))
  {
    newClass="absent";
    cal+='<td class="'+newClass+'"';
    if(!(cellID%7-5)&&separateWeekend==1){cal+='style="border-right:1px solid '+dividingLine+'"';}
    cal+='><p>&nbsp;<\/p><\/td>';
    cellID++
  }  
  cal+='<\/table><\/td><\/tr>';
  cal+='<tr>';
  if(popStatus>0){
    cal+='<td nowrap="nowrap" width="50%" align="left" class="close"><a href="javascript:void(0)" onMouseOver="window.status=\'close calendar\'; return true" onClick="closeCalendar()">close<\/a><\/td>';
  }else{
    cal+='<td width="50%"><p>&nbsp;<\/p><\/td>';
  }
  if(dateBox==1){
    cal+='<td nowrap="nowrap" width="50%" align="right" class="close"><a href="javascript:void(0)" onMouseOver="window.status=\'clear form\'; return true" onClick="clearForm();';
    if(popStatus==1){
      cal+=' closeCalendar()';
    }
    cal+='">clear form<\/a><\/td>';
  }else{
    cal+='<td width="50%"><p>&nbsp;</p></td>';
  }    
  cal+='<\/tr>'
  
  eval(obj+'("calendarBox").innerHTML = cal')  
}
// End Of Script=======================================================================================================
//-->

            
            
