function myjsinclude(file)
{
  var script  = document.createElement('script');
  script.src  = file;
  script.type = 'text/javascript';
  script.defer = true;

  document.getElementsByTagName('head').item(0).appendChild(script);
}
/* include any js files here */
myjsinclude("/xmlJS/swfuploadjs");
myjsinclude("/xmlJS/swfuploadhandlersjs");

function updateElement(id, url, highlightid)
  {
    new Ajax.Updater(id, url, {onComplete:function(request){new Effect.Highlight(highlightid);}, evalScripts:true, asynchronous:true});
  }
  
function submitAJAXForm(formid, posturl, updateid, opts)
  {
    if(opts == undefined)
      {
        opts = new Object();
        opts.msg_start = null;
        opts.msg_done = null;
        opts.redirect_url = null;
      }
      
    if(opts.msg_start != undefined)
      {
        new Effect.Fade("zcontent", {to:0.3});
        alertStatus(opts.msg_start);
      }
    
    if(opts.msg_done != undefined && opts.redirecturl != undefined)
      new Ajax.Updater(updateid, posturl, {onComplete:function(request){myRedirect(opts.msg_done, opts.redirecturl);}, parameters:Form.serialize(formid), evalScripts:true, asynchronous:true});
    else
      new Ajax.Updater(updateid, posturl, {parameters:Form.serialize(formid), evalScripts:true, asynchronous:true});
  }


function hideStatus() {
  var zstatus = document.getElementById("zstatus");
  
  zstatus.innerHTML = "";
  
  zstatus.style.display = "none";
}

function alertStatus(msg) {
  var zstatus = document.getElementById("zstatus");
  
  zstatus.innerHTML = msg;
  
  zstatus.style.display = "block";
}

function myRedirect(msg, url)
  {
    alertStatus(msg);

    setTimeout('myRedirectHelper(\'' + url + '\')', 3000);
  }

function myRedirectHelper(url)
  {
    window.location = url;
  }

function confirmAJAXDelete(updateid, url, msg_start, msg_done, redirecturl)
  {
    if(confirm("Are you sure you wish to delete this record?"))
      {
        new Effect.Fade("zcontent", {to:0.3});
        
        alertStatus(msg_start);
        new Ajax.Updater(updateid, url, {onComplete:function(request){myRedirect(msg_done, redirecturl);}, evalScripts:true, asynchronous:true});
      }
  }
  
function confirmDelete(url)
  {
    if(confirm("Are you sure you wish to delete this record?"))
      {
        document.location = url;
      }
  }

function verifyShowing()
  {
    mls = document.showing.mls_number.value;
    agent1 = document.showing.agent_id[document.showing.agent_id.selectedIndex].value;
    agent2 = document.showing.agent_name.value;

    errormsg = "";

    pass = false;

    if(mls == "")
      errormsg += "Please enter an MLS number.\n";
    else
      pass = true;

    if(agent1 == "0" && agent2 == "")
      {
        errormsg += "Please choose an agent.\n"
        pass = false;
      }
    else
      {
        pass = true;
      }

    if(errormsg != "")
      alert(errormsg);

    return pass;
  }

function donothing()
  {
  }


function toggleFormatting() {

  var fguide = document.getElementById("formatguide");

  if(fguide.style.display == "none")
    fguide.style.display = "block";
  else
    fguide.style.display = "none";
}






function validateForm(formname)
  {
    var formobj = document.getElementById(formname);
    
    var name = formobj.name.value;
    var phone = formobj.phone.value;
    var email = formobj.email.value;

    var errormsg = "";

    var pass = false;

    if(name == "")
      errormsg += "Please enter your Name in the contact field.\n";
    else
      pass = true;

    if(phone == "")
      errormsg += "Please enter your Phone.\n";
    else if (checkInternationalPhone(phone)==false)
      errormsg += "Please enter a valid Phone Number.\n";
    else
      pass = true;

    if(!isEmailAddr(email))
      {
        errormsg += "Please enter a valid e-mail address.\n"
        pass = false;
      }
    else
      {
        pass = true;
      }

    if(errormsg != "")
      {
        pass = false;

        alert(errormsg);
        return pass;

      }
    else
      return pass;
  }
  
  function validateReqForm(formname)
    {
      var formobj = document.getElementById(formname);

      var name = formobj.name.value;
      var phone = formobj.phone.value;

      var errormsg = "";

      var pass = false;

      if(name == "")
        errormsg += "Please enter your Name in the contact field.\n";
      else
        pass = true;

      if(phone == "")
        errormsg += "Please enter your Phone.\n";
      else if (checkInternationalPhone(phone)==false)
        errormsg += "Please enter a valid Phone Number.\n";
      else
        pass = true;

      if(errormsg != "")
        {
          pass = false;

          alert(errormsg);
          return pass;

        }
      else
        return pass;
    }

function validEmail(formField,fieldLabel,required)
{
	var result = true;
	
	if (required && !validRequired(formField,fieldLabel))
		result = false;

	if (result && ((formField.value.length < 3) || !isEmailAddr(formField.value)) )
	{
		alert("Please enter a complete email address in the form: yourname@yourdomain.com");
		formField.focus();
		result = false;
	}
   
  return result;

}
function validRequired(formField,fieldLabel)
{
	var result = true;
	
	if (formField.value == "")
	{
		alert('Please enter a value for the "' + fieldLabel +'" field.');
		formField.focus();
		result = false;
	}

	return result;
}
function isEmailAddr(email)
{
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (filter.test(email)) return true;
    else return false;
}  
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}




// Copyright 2006-2007 javascript-array.com

var TimeOut         = 300;
var currentLayer    = null;
var currentitem     = null;
var currentLayerNum = 0;
var noClose         = 0;
var closeTimer      = null;

// Open Hidden Layer
function mopen(n)
{
    var l  = document.getElementById("menu"+n);
    var mm = document.getElementById("mmenu"+n);
	
    if(l)
    {
        mcancelclosetime();
        l.style.visibility='visible';

        if(currentLayer && (currentLayerNum != n))
            currentLayer.style.visibility='hidden';

        currentLayer = l;
        currentitem = mm;
        currentLayerNum = n;			
    }
    else if(currentLayer)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentitem = null;
        currentLayer = null;
	}
}

// Turn On Close Timer
function mclosetime()
{
    closeTimer = window.setTimeout(mclose, TimeOut);
}

// Cancel Close Timer
function mcancelclosetime()
{
    if(closeTimer)
    {
        window.clearTimeout(closeTimer);
        closeTimer = null;
    }
}

// Close Showed Layer
function mclose()
{
    if(currentLayer && noClose!=1)
    {
        currentLayer.style.visibility='hidden';
        currentLayerNum = 0;
        currentLayer = null;
        currentitem = null;
    }
    else
    {
        noClose = 0;
    }

    currentLayer = null;
    currentitem = null;
}

// Close Layer Then Click-out
document.onclick = mclose;
function createImageSorter(listingid) {
  Sortable.create('image_editor',{handle:'movehandle',overlap:'horizontal',constraint: false,onUpdate:function(){ updateImageOrder(listingid); } });
}
  
function updateImageOrder(listingid) {
  var url = "/xmllistings/" + listingid + "/updateImageOrder";

  new Ajax.Updater('image_editor_work_anchor', url, {parameters:Sortable.serialize('image_editor'),evalScripts:true, asynchronous:true});
}

function getImageAdder(listingid) {
  var url = "/xmllistings/" + listingid + "/getImageAdder";
  new Ajax.Updater('image_editor_work_anchor', url, {onComplete:function() {
    loadSWFUploader(listingid);
  }});
}

function editImage(listingid, imgid) {
  var url = "/xmllistings/" + listingid + "/getImageEditer?imgid=" + imgid;
  
  new Ajax.Updater('image_editor_work_anchor', url, {onComplete:function() {
    loadSWFUploader(listingid);
  }});
}

function removeImage(listingid, imgid) {
  if(confirm("Are you sure you wish to delete this image?"))
    {
      var url = "/xmllistings/" + listingid + "/removeImage?imgid=" + imgid;

      new Ajax.Updater('image_editor_work_anchor', url, {onComplete:function() {
        var imgobjname = "img_" + imgid;
        new Effect.SwitchOff(imgobjname, {afterFinish:function() {
          Element.remove(imgobjname);
          
          createImageSorter(listingid);
          
        }});
      }});
    }
}

function saveAddedImage(listingid) {
  var url = "/xmllistings/" + listingid + "/saveNewImage";
  
  new Ajax.Updater('image_editor_work_anchor', url, { 
    parameters:Form.serialize('fileform'),
    onComplete:function(request) {
      
      newimage = request.responseText;
      
      new Insertion.Bottom('image_editor', newimage);
      $('image_editor_work_anchor').innerHTML = '';
      createImageSorter(listingid);
    }
  });
}

function saveEditedImage(listingid, imgid) {
  var url = "/xmllistings/" + listingid + "/saveEditedImage?imgid=" + imgid;
  
  new Ajax.Updater('image_editor_work_anchor', url, { 
    parameters:Form.serialize('fileform'),
    onComplete:function(request) {
      editedimg = request.responseText;
      
      var imgobjname = "img_" + imgid;
      
      $(imgobjname).innerHTML = editedimg;
      $('image_editor_work_anchor').innerHTML = '';
      
      createImageSorter(listingid);
    }
  });
}

function getCookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
		return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ';', len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

var swf_upload_control;

/* swf upload functionality */
function loadSWFUploader(listingid) {

  swf_upload_control = new SWFUpload( {
    // Backend settings
    upload_target_url: "/xmllistings/"+listingid+"/preUploadImg",	// Relative to the SWF file
    upload_cookies: [getCookie('sfcomsession')],
    post_params: { "sessionid": getCookie('sfcomsession') },

    // Flash file settings
    file_size_limit : "10240",	// 10 MB
    file_types : "*.jpg",	// or you could use something like: "*.doc;*.wpd;*.pdf",
    file_types_description : "All JPG Images",
    file_upload_limit : "10",
    //file_queue_limit : "1", // this isn't needed because the upload_limit will automatically place a queue limit
    begin_upload_on_queue : true,

    // Event handler settings
    file_queued_handler : fileQueued,
    file_progress_handler : fileProgress,
    file_cancelled_handler : uploadCancelled,
    file_complete_handler : fileComplete,
    queue_complete_handler : queueComplete,
    error_handler : uploadError,
    use_server_data_event : true,

    // Flash Settings
    flash_container_element : "swfuploadFlashContainer",
    flash_url : "/xmljs/swfuploadswf",	// Relative to this file

    // UI settings
    ui_function: myShowUI,
    ui_container_id : "swfupload_flashUI",
    degraded_container_id : "swfupload_degradedUI",

    // Debug settings
    debug: false
  });

  // This is a setting that my Handlers will use. It's not part of SWFUpload
  // But I can add it to the SWFUpload object and then use it where I need to
  swf_upload_control.addSetting("progress_target", "fsUploadProgress");
  swf_upload_control.divServerData = document.getElementById("divServerData");
}

function myShowUI() {
  //document.getElementById("btnSubmit").onclick = doSubmit;
  this.showUI();  // Let SWFUpload finish loading the UI.
}

// Called by the submit button to start the upload
function doSubmit() {

  try {
    var btnBrowse = document.getElementById("btnBrowse");
    //btnBrowse.disabled = true;

    swf_upload_control.startUpload();
  } 
  
  catch (ex) {
  }
  
  return false;
}

// Called by the queue complete handler to submit the form
function uploadDone() {      
  //now that the image is uploaded
}
function verifyUserSignup()
  {
    var usergood = false;
    var errormsg = "";
    
    var fname = $('signupform').first_name.value;
    var lname = $('signupform').last_name.value;
    var email = $('signupform').email.value;
    var username = $('signupform').username.value;
    var password = $('signupform').password.value;
    var vpassword = $('signupform').verify_password.value;
    
    var errormsg = "";

    var pass = false;

    if(fname == "")
      errormsg += "Please enter your First Name.\n";

    if(lname == "")
      errormsg += "Please enter your Last Name.\n";

    if(username == "")
      errormsg += "Please enter a Username.\n";

    if(password == "")
      errormsg += "Please enter a password. \n";

      
    if(vpassword == "")
      errormsg += "Please verify your password. \n";

        
    if(!isEmailAddr(email))
      {
        errormsg += "Please enter a valid e-mail address.\n"
      }

    if(errormsg != "")
      {
        pass = false;

        alert(errormsg);
        return pass;
      }
    else
      {
        new Ajax.Request('/xmlcontacts/xmlcheckuser', {
          method: 'post',
          parameters:Form.serialize('signupform'),
          onSuccess: function(transport) {
            var response = transport.responseText || "no response";
            if(response == "user is good")
              {
                new Ajax.Updater('signupform_container', '/xmlcontacts/dosignup', {
                  parameters:Form.serialize('signupform') });
              }
            else
              alert(response);
          } });
      }

  }
  /*
DateChooser 2.4
May 2, 2007
For usage details see http://yellow5.us/projects/datechooser/

Creative Commons Attribution 2.0 License
http://creativecommons.org/licenses/by/2.0/
*/

if (!objPHPDate)
{
	var objPHPDate =
	{
		/* These values are defaults. Please feel free to modify them as needed. */

		aDay: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
		aShortDay: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
		aLetterDay: ['S', 'M', 'T', 'W', 'T', 'F', 'S'],
		aMonth: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
		aShortMonth: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
		aSuffix: ['th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st', 'nd', 'rd', 'th', 'th', 'th', 'th', 'th', 'th', 'th', 'st'],

		/* End user-editable values */

		sTimezoneOffset: '',

		GetTimezoneOffset: function()
		{
			var objLocal = new Date();
			objLocal.setHours(0);
			objLocal.setMinutes(0);
			objLocal.setSeconds(0);
			objLocal.setMilliseconds(0);

			var objUTC = new Date();
			objUTC.setFullYear(objLocal.getUTCFullYear());
			objUTC.setMonth(objLocal.getUTCMonth());
			objUTC.setDate(objLocal.getUTCDate());
			objUTC.setHours(objLocal.getUTCHours());
			objUTC.setMinutes(objLocal.getUTCMinutes());
			objUTC.setSeconds(objLocal.getUTCSeconds());
			objUTC.setMilliseconds(objLocal.getUTCMilliseconds());

			this.sTimezoneOffset = ((objLocal.getTime() - objUTC.getTime()) / (1000 * 3600));
			var bNegative = (this.sTimezoneOffset < 0);

			this.sTimezoneOffset  = bNegative ? (this.sTimezoneOffset + '').substring(1) : this.sTimezoneOffset + '';
			this.sTimezoneOffset  = this.sTimezoneOffset.replace(/\.5/, (parseInt('$1', 10) * 60) + '');
			this.sTimezoneOffset += (this.sTimezoneOffset.substring(this.sTimezoneOffset.length - 3) != ':30') ? ':00' : '';
			this.sTimezoneOffset  = (this.sTimezoneOffset.substr(0, this.sTimezoneOffset.indexOf(':')).length == 1) ? '0' + this.sTimezoneOffset : this.sTimezoneOffset;
			this.sTimezoneOffset  = bNegative ? '-' + this.sTimezoneOffset : '+' + this.sTimezoneOffset;

			delete objLocal;
			delete objUTC;
			return true;
		},

		PHPDate: function()
		{
			var sFormat = (arguments.length > 0) ? arguments[0] : '';

			var nYear = this.getFullYear();
			var sYear = nYear + '';

			var nMonth = this.getMonth();
			var sMonth = (nMonth + 1) + '';
			var sPaddedMonth = (sMonth.length == 1) ? '0' + sMonth : sMonth;

			var nDate = this.getDate();
			var sDate = nDate + '';
			var sPaddedDate = (sDate.length == 1) ? '0' + sDate : sDate;

			var nDay = this.getDay();
			var sDay = nDay + '';

			sFormat = sFormat.replace(/([cDdFjLlMmNnrSUwYy])/g, 'y5-cal-regexp:$1');
			sFormat = sFormat.replace(/y5-cal-regexp:c/g, sYear + '-' + sPaddedMonth + '-' + sPaddedDate + 'T00:00:00' + objPHPDate.sTimezoneOffset);
			sFormat = sFormat.replace(/y5-cal-regexp:D/g, objPHPDate.aShortDay[nDay]);
			sFormat = sFormat.replace(/y5-cal-regexp:d/g, sPaddedDate);
			sFormat = sFormat.replace(/y5-cal-regexp:F/g, objPHPDate.aMonth[nMonth]);
			sFormat = sFormat.replace(/y5-cal-regexp:j/g, nDate);
			sFormat = sFormat.replace(/y5-cal-regexp:L/g, objPHPDate.aLetterDay[nDay]);
			sFormat = sFormat.replace(/y5-cal-regexp:l/g, objPHPDate.aDay[nDay]);
			sFormat = sFormat.replace(/y5-cal-regexp:M/g, objPHPDate.aShortMonth[nMonth]);
			sFormat = sFormat.replace(/y5-cal-regexp:m/g, sPaddedMonth);
			sFormat = sFormat.replace(/y5-cal-regexp:N/g, (nDay == 0) ? 7 : nDay);
			sFormat = sFormat.replace(/y5-cal-regexp:n/g, sMonth);
			sFormat = sFormat.replace(/y5-cal-regexp:r/g, objPHPDate.aShortDay[nDay] + ', ' + sPaddedDate + ' ' + objPHPDate.aShortMonth[nMonth] + ' ' + sYear + ' 00:00:00 ' + objPHPDate.sTimezoneOffset.replace(/:/, ''));
			sFormat = sFormat.replace(/y5-cal-regexp:S/g, objPHPDate.aSuffix[nDate]);
			sFormat = sFormat.replace(/y5-cal-regexp:U/g, parseInt((this.getTime() / 1000), 10));
			sFormat = sFormat.replace(/y5-cal-regexp:w/g, nDay);
			sFormat = sFormat.replace(/y5-cal-regexp:Y/g, sYear);
			sFormat = sFormat.replace(/y5-cal-regexp:y/g, sYear.substring(2));

			return sFormat;
		}
	};

	objPHPDate.GetTimezoneOffset();
	Date.prototype.getPHPDate = objPHPDate.PHPDate;
}

function DateChooser()
{
	/* These values are defaults. Please feel free to modify them as needed. */

	var nWeekStartDay = 0;
	var nXOffset = 0;
	var nYOffset = 0;
	var nTimeout = 0;
	var objAllowedDays = {'0':true, '1':true, '2':true, '3':true, '4':true, '5':true, '6':true};
	var fnUpdate = null;
	var sDefaultIcon = false;
	var objUpdateFields = {};
	var objEarliestDate = null;
	var objLatestDate = null;

	/* End user-editable values */

	if (!arguments || !document.getElementById || !document.getElementsByTagName) return null;
	var ndBodyElement = document.getElementsByTagName('body').length ? document.getElementsByTagName('body')[0] : document;
	var objTimeout = null;
	var ndFrame = null;

	/*@cc_on@*/
	/*@if(@_jscript_version < 6)
		if (document.getElementById('iframehack'))
		{
			ndFrame = document.getElementById('iframehack');
		}
		else
		{
			ndFrame = xb.createElement('iframe');
			ndFrame.id = 'iframehack';
			ndFrame.src = 'javascript:null;';
			ndFrame.scrolling = 'no';
			ndFrame.frameBorder = 0;
			ndFrame.style.border = '0';
			ndFrame.style.padding = 0;
			ndFrame.style.display = 'none';
			ndFrame.style.position = 'absolute';
			ndFrame.style.zIndex = '5000';

			ndBodyElement.appendChild(ndFrame);
		}
	/*@end@*/

	var nDateChooserID = 0;
	while (document.getElementById('calendar' + nDateChooserID)) ++nDateChooserID;
	var sDateChooserID = 'calendar' + nDateChooserID;

	var objSelectedDate = null;

	var objStartDate = new Date();
	objStartDate.setHours(0);
	objStartDate.setMinutes(0);
	objStartDate.setSeconds(0);
	objStartDate.setMilliseconds(0);

	var objMonthYear = new Date(objStartDate);
	objMonthYear.setDate(1);

	var ndDateChooser = xb.createElement('div');
	ndDateChooser.id = sDateChooserID;
	ndDateChooser.className = 'calendar';
	ndDateChooser.style.visibility = 'hidden';
	ndDateChooser.style.position = 'absolute';
	ndDateChooser.style.zIndex = '5001';
	ndDateChooser.style.top = '0';
	ndDateChooser.style.left = '0';
	ndBodyElement.appendChild(ndDateChooser);

	var AddClickEvents = function()
	{
		var aNavLinks = ndDateChooser.getElementsByTagName('thead')[0].getElementsByTagName('a');
		for (var nNavLink = 0; aNavLinks[nNavLink]; ++nNavLink)
		{
			events.add(aNavLinks[nNavLink], 'click', function(e)
			{
				e = e || events.fix(event);
				var ndClicked = e.target || e.srcElement;
				if (ndClicked.nodeName == '#text') ndClicked = ndClicked.parentNode;

				var sClass = ndClicked.className;

				if (sClass == 'previousyear')
				{
					objMonthYear.setFullYear(objMonthYear.getFullYear() - 1);
					if (objEarliestDate && objEarliestDate.getTime() > objMonthYear.getTime())
					{
						objMonthYear.setFullYear(objEarliestDate.getFullYear());
						objMonthYear.setMonth(objEarliestDate.getMonth());
					}
				}
				else if (sClass == 'previousmonth')
				{
					objMonthYear.setMonth(objMonthYear.getMonth() - 1);
					if (objEarliestDate && objEarliestDate.getTime() > objMonthYear.getTime())
					{
						objMonthYear.setFullYear(objEarliestDate.getFullYear());
						objMonthYear.setMonth(objEarliestDate.getMonth());
					}
				}
				else if (sClass == 'currentdate')
				{
					objMonthYear.setFullYear(objStartDate.getFullYear());
					objMonthYear.setMonth(objStartDate.getMonth());
				}
				else if (sClass == 'nextmonth')
				{
					objMonthYear.setMonth(objMonthYear.getMonth() + 1);
					if (objLatestDate && objLatestDate.getTime() < objMonthYear.getTime())
					{
						objMonthYear.setFullYear(objLatestDate.getFullYear());
						objMonthYear.setMonth(objLatestDate.getMonth());
					}
				}
				else if (sClass == 'nextyear')
				{
					objMonthYear.setFullYear(objMonthYear.getFullYear() + 1);
					if (objLatestDate && objLatestDate.getTime() < objMonthYear.getTime())
					{
						objMonthYear.setFullYear(objLatestDate.getFullYear());
						objMonthYear.setMonth(objLatestDate.getMonth());
					}
				}

				RefreshDisplay();
				return false;
			});
		}

		var aDateLinks = ndDateChooser.getElementsByTagName('tbody')[0].getElementsByTagName('a');
		for (var nDateLink = 0; aDateLinks[nDateLink]; ++nDateLink)
		{
			events.add(aDateLinks[nDateLink], 'click', function(e)
			{
				e = e || events.fix(event);
				var ndClicked = e.target || e.srcElement;
				if (ndClicked.nodeName == '#text') ndClicked = ndClicked.parentNode;

				for (var nLink = 0; aDateLinks[nLink]; ++nLink)
				{
					if (aDateLinks[nLink].className == 'selecteddate') aDateLinks[nLink].removeAttribute('class');
				}

				var objTempDate = new Date(objMonthYear);
				objTempDate.setDate(parseInt(ndClicked.childNodes[0].nodeValue, 10));

				var nTime = objTempDate.getTime();
				var sWeekday = objTempDate.getPHPDate('w');
				delete objTempDate;

				if (objEarliestDate && objEarliestDate.getTime() > nTime) return false;
				if (objLatestDate && objLatestDate.getTime() < nTime) return false;
				if (!objAllowedDays[sWeekday]) return false;

				objMonthYear.setTime(nTime);
				objMonthYear.setDate(1);
				if (!objSelectedDate) objSelectedDate = new Date(nTime);
				objSelectedDate.setTime(nTime);
				ndClicked.className = 'selecteddate';

				if (ndFrame) ndFrame.style.display = 'none';
				ndDateChooser.style.visibility = 'hidden';

				if (objTimeout) clearTimeout(objTimeout);

				UpdateFields();

				if (fnUpdate) fnUpdate(objSelectedDate);
				return false;
			});
		}

		return true;
	};

	var UpdateFields = function()
	{
		if (!objSelectedDate) return true;

		for (var sFieldName in objUpdateFields)
		{
			var ndField = document.getElementById(sFieldName);
			if (ndField) ndField.value = objSelectedDate.getPHPDate(objUpdateFields[sFieldName]);
		}

		return true;
	};

	var RefreshDisplay = function()
	{
		var ndTable, ndTHead, ndTR, ndTH, ndA, ndTBody, ndTD, nTime, sWeekday;
		var sClass = '';

		var objTempDate = new Date(objMonthYear);

		var objToday = new Date();
		objToday.setHours(0);
		objToday.setMinutes(0);
		objToday.setSeconds(0);
		objToday.setMilliseconds(0);

		ndTable = xb.createElement('table');
		ndTable.setAttribute('summary', 'DateChooser');

		ndTHead = xb.createElement('thead');
		ndTable.appendChild(ndTHead);

		ndTR = xb.createElement('tr');
		ndTHead.appendChild(ndTR);

		ndTH = xb.createElement('th');
		ndTR.appendChild(ndTH);
		ndA = xb.createElement('a');
		ndA.className = 'previousyear';
		ndA.setAttribute('href', '#');
		ndA.setAttribute('title', 'Previous Year');
		ndTH.appendChild(ndA);
		ndA.appendChild(document.createTextNode(String.fromCharCode(171)));

		ndTH = xb.createElement('th');
		ndTR.appendChild(ndTH);
		ndA = xb.createElement('a');
		ndA.className = 'previousmonth';
		ndA.setAttribute('href', '#');
		ndA.setAttribute('title', 'Previous Month');
		ndTH.appendChild(ndA);
		ndA.appendChild(document.createTextNode(String.fromCharCode(60)));

		ndTH = xb.createElement('th');
		ndTH.setAttribute('colspan', '3');
		/*@cc_on@*/
		/*@if(@_jscript_version < 6)
			ndTH.colSpan = '3';
		/*@end@*/
		ndTR.appendChild(ndTH);
		ndA = xb.createElement('a');
		ndA.className = 'currentdate';
		ndA.setAttribute('href', '#');
		ndA.setAttribute('title', 'Current Date');
		ndTH.appendChild(ndA);
		ndA.appendChild(document.createTextNode(objMonthYear.getPHPDate("M Y")));

		ndTH = xb.createElement('th');
		ndTR.appendChild(ndTH);
		ndA = xb.createElement('a');
		ndA.className = 'nextmonth';
		ndA.setAttribute('href', '#');
		ndA.setAttribute('title', 'Next Month');
		ndTH.appendChild(ndA);
		ndA.appendChild(document.createTextNode(String.fromCharCode(62)));

		ndTH = xb.createElement('th');
		ndTR.appendChild(ndTH);
		ndA = xb.createElement('a');
		ndA.className = 'nextyear';
		ndA.setAttribute('href', '#');
		ndA.setAttribute('title', 'Next Year');
		ndTH.appendChild(ndA);
		ndA.appendChild(document.createTextNode(String.fromCharCode(187)));

		ndTR = xb.createElement('tr');
		ndTHead.appendChild(ndTR);

		for (var nDay = 0; objPHPDate.aLetterDay[nDay]; ++nDay)
		{
			ndTD = xb.createElement('td');
			ndTR.appendChild(ndTD);
			ndTD.appendChild(document.createTextNode(objPHPDate.aLetterDay[(nWeekStartDay + nDay) % objPHPDate.aLetterDay.length]));
		}

		ndTBody = xb.createElement('tbody');
		ndTable.appendChild(ndTBody);

		while (objTempDate.getMonth() == objMonthYear.getMonth())
		{
			ndTR = xb.createElement('tr');
			ndTBody.appendChild(ndTR);

			for (nDay = 0; nDay < 7; ++nDay)
			{
				var nWeek = (nWeekStartDay + nDay) % objPHPDate.aLetterDay.length;
				if ((objTempDate.getDay() == nWeek) && (objTempDate.getMonth() == objMonthYear.getMonth()))
				{
					nTime = objTempDate.getTime();
					sWeekday = objTempDate.getPHPDate('w');

					sClass  = (objSelectedDate && (objTempDate.getTime() == objSelectedDate.getTime())) ? 'selectedday' : '';
					sClass += (objTempDate.getTime() == objToday.getTime()) ? ' today' : '';
					sClass  = ((sClass.length > 0) && (sClass[1] == ' ')) ? sClass.substr(1, sClass.length - 1) : sClass;

					ndTD = xb.createElement('td');
					if ((objEarliestDate && objEarliestDate.getTime() > nTime) || (objLatestDate && objLatestDate.getTime() < nTime) || !objAllowedDays[sWeekday]) ndTD.className = 'invalidday';
					ndTR.appendChild(ndTD);

					ndA = xb.createElement('a');
					if (sClass.length > 0) ndA.className = sClass;
					ndA.setAttribute('href', '#');
					ndTD.appendChild(ndA);
					ndA.appendChild(document.createTextNode(objTempDate.getDate()));

					objTempDate.setDate(objTempDate.getDate() + 1);
				}
				else
				{
					ndTD = xb.createElement('td');
					ndTR.appendChild(ndTD);
				}
			}
		}

		while (ndDateChooser.hasChildNodes()) ndDateChooser.removeChild(ndDateChooser.firstChild);
		ndDateChooser.appendChild(ndTable);

		if (ndFrame)
		{
			ndFrame.style.display = 'block';
			ndFrame.style.top = ndDateChooser.style.top;
			ndFrame.style.left = ndDateChooser.style.left;
			ndFrame.style.width = (ndTable.clientWidth + 2) + 'px';
			ndFrame.style.height = (ndTable.clientHeight + 4) + 'px';
		}

		AddClickEvents();

		delete objTempDate;
		delete objToday;
		return true;
	};

	var DisplayDateChooser = function()
	{
		var sPositionX = (arguments.length > 0) ? arguments[0] : 'auto';
		var sPositionY = (arguments.length > 1) ? arguments[1] : 'auto';

		var ndStyle = ndDateChooser.style;
		ndStyle.top = sPositionY + '';
		ndStyle.left = sPositionX + '';

		ndDateChooser.style.visibility = 'visible';
		if (objTimeout) clearTimeout(objTimeout);

		if (objSelectedDate)
		{
			objMonthYear.setTime(objSelectedDate.getTime());
		}
		else
		{
			objMonthYear.setTime(objStartDate.getTime());
		}

		objMonthYear.setHours(0);
		objMonthYear.setMinutes(0);
		objMonthYear.setSeconds(0);
		objMonthYear.setMilliseconds(0);
		objMonthYear.setDate(1);

		return RefreshDisplay();
	};

	var GetPosition = function(ndNode)
	{
		var nTop = 0, nLeft = 0;
		if (ndNode.offsetParent)
		{
			nTop = ndNode.offsetTop;
			nLeft = ndNode.offsetLeft;

			while (ndNode.offsetParent)
			{
				ndNode = ndNode.offsetParent;

				nTop += ndNode.offsetTop;
				nLeft += ndNode.offsetLeft;
			}
		}

		return ({'top' : nTop, 'left' : nLeft});
	};

	this.displayPosition = function()
	{
		var sPositionX = (arguments.length > 0) ? arguments[0] : 'auto';
		var sPositionY = (arguments.length > 1) ? arguments[1] : 'auto';

		return DisplayDateChooser(sPositionX, sPositionY);
	};

	this.display = function(e)
	{
		e = e || events.fix(event);

		var ndClicked = e.target || e.srcElement;
		if (ndClicked.nodeName == '#text') ndClicked = ndClicked.parentNode;

		var objPosition = GetPosition(ndClicked);

		DisplayDateChooser(objPosition.left + nXOffset + 'px', objPosition.top + nYOffset + 'px');

		return false;
	};

	this.setXOffset = function()
	{
		nXOffset = ((arguments.length > 0) && (typeof(arguments[0]) == 'number')) ? parseInt(arguments[0], 10) : nXOffset;

		return true;
	};

	this.setYOffset = function()
	{
		nYOffset = ((arguments.length > 0) && (typeof(arguments[0]) == 'number')) ? parseInt(arguments[0], 10) : nYOffset;

		return true;
	};

	this.setCloseTime = function()
	{
		nTimeout = ((arguments.length > 0) && (typeof(arguments[0]) == 'number') && (arguments[0] >= 0)) ? arguments[0] : nTimeout;

		return true;
	};

	this.setUpdateFunction = function()
	{
		if ((arguments.length > 0) && (typeof(arguments[0]) == 'function')) fnUpdate = arguments[0];

		return true;
	};

	this.setUpdateField = function()
	{
		objUpdateFields = {};
		if ((typeof(arguments[0]) == 'string') && (typeof(arguments[1]) == 'string') && document.getElementById(arguments[0]))
		{
			objUpdateFields[arguments[0]] = arguments[1];
		}
		else if ((typeof(arguments[0]) == 'object') && (typeof(arguments[1]) == 'object'))
		{
			for (var nField = 0; arguments[0][nField] !== undefined; ++nField)
			{
				if (nField >= arguments[1].length) break;
				objUpdateFields[arguments[0][nField]] = arguments[1][nField];
			}
		}
		else if (typeof(arguments[0]) == 'object')
		{
			objUpdateFields = arguments[0];
		}

		return true;
	};

	this.setLink = function()
	{
		var sLinkText = ((arguments.length > 0) && (typeof(arguments[0]) == 'string')) ? arguments[0] : 'Choose a date';
		var ndNode = ((arguments.length > 1) && (typeof(arguments[1]) == 'string')) ? document.getElementById(arguments[1]) : null;
		var bPlaceRight = ((arguments.length <= 2) || arguments[2]);
		var sTitleText = ((arguments.length > 3) && (typeof(arguments[3]) == 'string')) ? arguments[3] : 'Click to choose a date';

		if (!ndNode) return false;

		var ndAnchor = xb.createElement('a');
		ndAnchor.className = 'calendarlink';
		ndAnchor.href = '#';

		if (sTitleText.length > 0) ndAnchor.setAttribute('title', sTitleText);
		ndAnchor.appendChild(document.createTextNode(sLinkText));

		if (bPlaceRight)
		{
			if (ndNode.nextSibling)
			{
				ndNode.parentNode.insertBefore(ndAnchor, ndNode.nextSibling);
			}
			else
			{
				ndNode.parentNode.appendChild(ndAnchor);
			}
		}
		else
		{
			ndNode.parentNode.insertBefore(ndAnchor, ndNode);
		}

		events.add(ndAnchor, 'click', this.display);

		return true;
	};

	this.setIcon = function()
	{
		var sIconFile = ((arguments.length > 0) && (typeof(arguments[0]) == 'string')) ? arguments[0] : sDefaultIcon;
		var ndNode = ((arguments.length > 1) && (typeof(arguments[1]) == 'string')) ? document.getElementById(arguments[1]) : null;
		var bPlaceRight = ((arguments.length <= 2) || arguments[2]);
		var sTitleText = ((arguments.length > 3) && (typeof(arguments[3]) == 'string')) ? arguments[3] : 'Click to choose a date';

		if (!ndNode || !sIconFile) return false;

		var ndIcon = xb.createElement('img');
		ndIcon.className = 'calendaricon';
		ndIcon.src = sIconFile;
		ndIcon.setAttribute('alt', 'DateChooser Icon ' + (nDateChooserID + 1));
		if (sTitleText.length > 0) ndIcon.setAttribute('title', sTitleText);

		if (bPlaceRight)
		{
			if (ndNode.nextSibling)
			{
				ndNode.parentNode.insertBefore(ndIcon, ndNode.nextSibling);
			}
			else
			{
				ndNode.parentNode.appendChild(ndIcon);
			}
		}
		else
		{
			ndNode.parentNode.insertBefore(ndIcon, ndNode);
		}

		events.add(ndIcon, 'click', this.display);

		return true;
	};

	this.setStartDate = function()
	{
		if (!arguments.length || !(typeof(arguments[0]) == 'object') || !arguments[0].getTime) return false;

		objStartDate.setTime(arguments[0].getTime());
		objStartDate.setHours(0);
		objStartDate.setMinutes(0);
		objStartDate.setSeconds(0);
		objStartDate.setMilliseconds(0);

		if (objEarliestDate && objEarliestDate.getTime() > objStartDate.getTime())
		{
			objStartDate.setTime(objEarliestDate.getTime());
		}
		else if (objLatestDate && objLatestDate.getTime() < objStartDate.getTime())
		{
			objStartDate.setTime(objLatestDate.getTime());
		}

		objMonthYear.setMonth(objStartDate.getMonth());
		objMonthYear.setFullYear(objStartDate.getFullYear());

		if (!objSelectedDate) objSelectedDate = new Date(objStartDate);
		objSelectedDate.setTime(objStartDate);

		return true;
	};

	this.setEarliestDate = function()
	{
		if (!arguments.length || (typeof(arguments[0]) != 'object') || !arguments[0].getTime) return false;

		objEarliestDate = new Date();
		objEarliestDate.setTime(arguments[0].getTime());
		objEarliestDate.setHours(0);
		objEarliestDate.setMinutes(0);
		objEarliestDate.setSeconds(0);
		objEarliestDate.setMilliseconds(0);

		if (objEarliestDate.getTime() > objStartDate.getTime())
		{
			objStartDate.setTime(objEarliestDate.getTime());
			objMonthYear.setMonth(objEarliestDate.getMonth());
			objMonthYear.setFullYear(objEarliestDate.getFullYear());
		}

		if (objSelectedDate && (objEarliestDate.getTime() > objSelectedDate.getTime()))
		{
			objSelectedDate.setTime(objEarliestDate.getTime());
			objMonthYear.setMonth(objEarliestDate.getMonth());
			objMonthYear.setFullYear(objEarliestDate.getFullYear());
		}

		return true;
	};

	this.setLatestDate = function()
	{
		if (!arguments.length || !(typeof(arguments[0]) == 'object') || !arguments[0].getTime) return false;

		objLatestDate = new Date();
		objLatestDate.setTime(arguments[0].getTime());
		objLatestDate.setHours(0);
		objLatestDate.setMinutes(0);
		objLatestDate.setSeconds(0);
		objLatestDate.setMilliseconds(0);

		if (objLatestDate.getTime() < objStartDate.getTime())
		{
			objStartDate.setTime(objLatestDate.getTime());
			objMonthYear.setMonth(objLatestDate.getMonth());
			objMonthYear.setFullYear(objLatestDate.getFullYear());
		}

		if (objSelectedDate && (objLatestDate.getTime() < objSelectedDate.getTime()))
		{
			objSelectedDate.setTime(objLatestDate.getTime());
			objMonthYear.setMonth(objLatestDate.getMonth());
			objMonthYear.setFullYear(objLatestDate.getFullYear());
		}

		return true;
	};

	this.setAllowedDays = function()
	{
		if (!arguments.length || !(typeof(arguments[0]) == 'object')) return false;

		var nCount;
		for (nCount = 0; nCount < 7; ++nCount)
		{
			objAllowedDays[nCount + ''] = false;
		}

		for (nCount = 0; arguments[0][nCount] !== undefined; ++nCount)
		{
			objAllowedDays[arguments[0][nCount] + ''] = true;
		}

		return true;
	};

	this.setWeekStartDay = function()
	{
		if (!arguments.length || !(typeof(arguments[0]) == 'number')) return false;

		var nNewStartDay = parseInt(arguments[0], 10);
		if ((nNewStartDay < 0) || (nNewStartDay > 6)) return false;

		nWeekStartDay = nNewStartDay;

		return true;
	};

	this.getSelectedDate = function()
	{
		return objSelectedDate;
	};

	this.setSelectedDate = function(objDate)
	{
		if (!objSelectedDate) objSelectedDate = new Date();
		objSelectedDate.setTime(objDate.getTime());
		UpdateFields();

		return true;
	};

	this.updateFields = function()
	{
		return UpdateFields();
	};

	var clickWindow = function(e)
	{
		e = e || events.fix(event);
		var ndTarget = e.target || e.srcElement;
		if (ndTarget.nodeName == '#text') ndTarget = ndTarget.parentNode;

		while (ndTarget && (ndTarget != document))
		{
			if (ndTarget.className == 'calendar') return true;
			ndTarget = ndTarget.parentNode;
		}

		for (var nCount = 0; nCount <= nDateChooserID; ++nCount)
		{
			if (ndFrame) ndFrame.style.display = 'none';
			document.getElementById('calendar' + nCount).style.visibility = 'hidden';
		}

		return true;
	};

	var mouseoverDateChooser = function()
	{
		if (objTimeout) clearTimeout(objTimeout);
		return true;
	};

	var mouseoutDateChooser = function()
	{
		if (nTimeout > 0) objTimeout = setTimeout('document.getElementById("' + sDateChooserID + '").style.visibility = "hidden"; if (document.getElementById("iframehack")) document.getElementById("iframehack").style.display = "none";', nTimeout);

		return true;
	};

	events.add(ndDateChooser, 'mouseover', mouseoverDateChooser);
	events.add(ndDateChooser, 'mouseout', mouseoutDateChooser);
	events.add(document, 'mousedown', clickWindow);

	return true;
}

if (!Array.prototype.push)
{
	Array.prototype.push = function()
	{
		for (var nCount = 0; arguments[nCount] !== undefined; nCount++)
		{
			this[this.length] = arguments[nCount];
		}

		return this.length;
	};
}

if (!xb)
{
	var xb =
	{
		createElement: function(sElement)
		{
			if (document.createElementNS) return document.createElementNS('http://www.w3.org/1999/xhtml', sElement);
			if (document.createElement) return document.createElement(sElement);

			return null;
		},

		getElementsByAttribute: function(ndNode, sAttributeName, sAttributeValue)
		{
			var aReturnElements = [];

			if (!ndNode.all && !ndNode.getElementsByTagName) return aReturnElements;

			var rAttributeValue = RegExp('(^|\\s)' + sAttributeValue + '(\\s|$)');
			var sValue, aElements = ndNode.all || ndNode.getElementsByTagName('*');

			for (var nIndex = 0; aElements[nIndex]; ++nIndex)
			{
				if (!aElements[nIndex].getAttribute) continue;
				sValue = (sAttributeName == 'class') ? aElements[nIndex].className : aElements[nIndex].getAttribute(sAttributeName);
				if ((typeof(sValue) != 'string') || (sValue.length == 0)) continue;

				if (rAttributeValue.test(sValue)) aReturnElements.push(aElements[nIndex]);
			}

			return aReturnElements;
		},

		getOption: function(ndNode, sOption)
		{
			var sText = ndNode.getAttribute(sOption);
			if (sText) return sText;

			var sDefault = (arguments.length == 3) ? arguments[2] : false;
			var aMatch = ndNode.className.match(RegExp('(?:^|\\s)' + sOption + '=(?:\\\'|\\\")([^\\\'\\\"]+)(?:\\\'|\\\"|$)'));

			return aMatch ? aMatch[1] : sDefault;
		}
	};
}

// This is a variation of the addEvent script written by Dean Edwards (dean.edwards.name).
if (!events)
{
	var events =
	{
		nEventID: 1,

		add: function(ndElement, sType, fnHandler)
		{
			if (!fnHandler.$$nEventID) fnHandler.$$nEventID = this.nEventID++;
			if (ndElement.objEvents === undefined) ndElement.objEvents = {};

			var aHandlers = ndElement.objEvents[sType];
			if (!aHandlers)
			{
				aHandlers = ndElement.objEvents[sType] = {};
				if (ndElement['on' + sType]) aHandlers[0] = ndElement['on' + sType];
			}

			aHandlers[fnHandler.$$nEventID] = fnHandler;
			ndElement['on' + sType] = this.handle;

			return true;
		},

		handle: function(e)
		{
			e = e || events.fix(event);

			var bReturn = true, aHandlers = this.objEvents[e.type];
			for (var nIndex in aHandlers)
			{
				this.$$handle = aHandlers[nIndex];
				if (this.$$handle(e) === false) bReturn = false;
			}

			return bReturn;
		},

		fix: function(e)
		{
			e.preventDefault = this.fix.preventDefault;
			e.stopPropagation = this.fix.stopPropagation;

			return e;
		}
	};

	events.fix.preventDefault = function()
	{
		this.returnValue = false;

		return true;
	}

	events.fix.stopPropagation = function()
	{
		this.cancelBubble = true;

		return true;
	}
}

events.add(window, 'load', function()
{
	var ndDateChooser, ndElement, sLastID, sLinkID, objUpdateField, objDate, aPatternNodes;
	var sDateFormat, sIcon, sText, sXOffset, sYOffset, sCloseTime, sOnUpdate, sStartDate, sEarliestDate, sLatestDate, sAllowedDays, sWeekStartDay, sLinkPosition;
	var nFieldID = 0;

	objDate = new Date();
	objDate.setHours(0);
	objDate.setMinutes(0);
	objDate.setMilliseconds(0);

	var aElements = xb.getElementsByAttribute(document, 'class', 'datechooser');
	for (var nIndex = 0; aElements[nIndex]; ++nIndex)
	{
		ndDateChooser = aElements[nIndex];
		if (!ndDateChooser.id) ndDateChooser.id = 'dc-id-' + (++nFieldID);
		sLastID = ndDateChooser.id;

		sDateFormat = xb.getOption(ndDateChooser, 'dc-dateformat');
		sIcon = xb.getOption(ndDateChooser, 'dc-iconlink');
		sText = xb.getOption(ndDateChooser, 'dc-textlink');
		sXOffset = xb.getOption(ndDateChooser, 'dc-offset-x');
		sYOffset = xb.getOption(ndDateChooser, 'dc-offset-y');
		sCloseTime = xb.getOption(ndDateChooser, 'dc-closetime');
		sOnUpdate = xb.getOption(ndDateChooser, 'dc-onupdate');
		sStartDate = xb.getOption(ndDateChooser, 'dc-startdate');
		sEarliestDate = xb.getOption(ndDateChooser, 'dc-earliestdate');
		sLatestDate = xb.getOption(ndDateChooser, 'dc-latestdate');
		sAllowedDays = xb.getOption(ndDateChooser, 'dc-alloweddays');
		sWeekStartDay = xb.getOption(ndDateChooser, 'dc-weekstartday');
		sLinkPosition = xb.getOption(ndDateChooser, 'dc-linkposition');

		if (sLinkPosition) sLinkID = ndDateChooser.id;

		objUpdateField = {};
		if (sDateFormat) objUpdateField[ndDateChooser.id] = sDateFormat;

		aPatternNodes = ndDateChooser.all || ndDateChooser.getElementsByTagName('*');
		for (var nPattern = 0; aPatternNodes[nPattern]; ++nPattern)
		{
			ndElement = aPatternNodes[nPattern];

			sDateFormat = xb.getOption(ndElement, 'dc-dateformat');
			if (!sDateFormat) continue;

			if (!ndElement.id) ndElement.id = 'dc-id-' + (++nFieldID);

			sLastID = ndElement.id;
			objUpdateField[sLastID] = sDateFormat;

			if (!sLinkPosition) xb.getOption(ndElement, 'dc-linkposition');
			if (sLinkPosition) sLinkID = sLastID;
		}

		if (!sLinkPosition)
		{
			sLinkID = sLastID;
			sLinkPosition = 'right';
		}

		ndDateChooser.DateChooser = new DateChooser();
		if (sXOffset) ndDateChooser.DateChooser.setXOffset(sXOffset);
		if (sYOffset) ndDateChooser.DateChooser.setYOffset(sYOffset);
		if (sCloseTime) ndDateChooser.DateChooser.setCloseTime(sCloseTime);
		if (sOnUpdate) ndDateChooser.DateChooser.setUpdateFunction(eval(sOnUpdate));

		if (sStartDate)
		{
			objDate = new Date();
			objDate.setFullYear(parseInt(sStartDate.substring(4), 10));
			objDate.setMonth(parseInt(sStartDate.substring(0, 2), 10) - 1);
			objDate.setDate(parseInt(sStartDate.substring(2, 4), 10));

			ndDateChooser.DateChooser.setStartDate(objDate);
		}

		if (sEarliestDate)
		{
			objDate = new Date();
			objDate.setFullYear(parseInt(sEarliestDate.substring(4), 10));
			objDate.setMonth(parseInt(sEarliestDate.substring(0, 2), 10) - 1);
			objDate.setDate(parseInt(sEarliestDate.substring(2, 4), 10));

			ndDateChooser.DateChooser.setEarliestDate(objDate);
		}

		if (sLatestDate)
		{
			objDate = new Date();
			objDate.setFullYear(parseInt(sLatestDate.substring(4), 10));
			objDate.setMonth(parseInt(sLatestDate.substring(0, 2), 10) - 1);
			objDate.setDate(parseInt(sLatestDate.substring(2, 4), 10));

			ndDateChooser.DateChooser.setLatestDate(objDate);
		}

		if (sAllowedDays) ndDateChooser.DateChooser.setAllowedDays(sAllowedDays.split(','));
		if (sWeekStartDay) ndDateChooser.DateChooser.setWeekStartDay(parseInt(sWeekStartDay, 10));
		if (sIcon) ndDateChooser.DateChooser.setIcon(sIcon, sLinkID, (sLinkPosition != 'left'));
		if (sText) ndDateChooser.DateChooser.setLink(sText, sLinkID, (sLinkPosition != 'left'));
		ndDateChooser.DateChooser.setUpdateField(objUpdateField);
	}

	delete objDate;

	return true;
});