

/* Timeframe, version 0.2
 * (c) 2008 Stephen Celis
 *
 * Freely distributable under the terms of an MIT-style license. 
 * ------------------------------------------------------------- */

if (typeof Prototype == 'undefined' || parseFloat(Prototype.Version.substring(0, 3)) < 1.6)
  throw 'Timeframe requires Prototype version 1.6 or greater.';

// Checks for localized Datejs before defaulting to 'en-US'
var Locale = $H({
  format:     (typeof Date.CultureInfo == 'undefined' ? '%b %d, %Y' : Date.CultureInfo.formatPatterns.shortDate),
  monthNames: (typeof Date.CultureInfo == 'undefined' ? $w('January February March April May June July August September October November December') : Date.CultureInfo.monthNames),
  dayNames:   (typeof Date.CultureInfo == 'undefined' ? $w('Sun Mon Tues Wed Thurs Fri Sat') : Date.CultureInfo.dayNames),
  weekOffset: (typeof Date.CultureInfo == 'undefined' ? 0 : Date.CultureInfo.firstDayOfWeek)
});

var Timeframes = [];

var Timeframe = Class.create({
  Version: '0.2',

  initialize: function(element, options) {
    Timeframes.push(this);

    this.element = $(element);
    this.element.addClassName('timeframe_calendar')
    this.options = $H({ months: 2 }).merge(options || {});;
    this.months = this.options.get('months');

    this.weekdayNames = Locale.get('dayNames');
    this.monthNames   = Locale.get('monthNames');
    this.format       = this.options.get('format')     || Locale.get('format');
    this.weekOffset   = this.options.get('weekOffset') || Locale.get('weekOffset');
    this.maxRange = this.options.get('maxRange');
    this.minRange = this.options.get('minRange');

    this.buttons = $H({
      previous: $H({ label: '&larr;', element: $(this.options.get('previousButton')) }),
      today:    $H({ label: 'T',      element: $(this.options.get('todayButton')) }),
      reset:    $H({ label: 'R',      element: $(this.options.get('resetButton')) }),
      next:     $H({ label: '&rarr;', element: $(this.options.get('nextButton')) })
    })
    this.fields = $H({ start: $(this.options.get('startField')), end: $(this.options.get('endField')) });

    this.range = $H({});
    this._buildButtons()._buildFields();
    this.earliest = Date.parseToObject(this.options.get('earliest'));
    this.latest   = Date.parseToObject(this.options.get('latest'));

    this.calendars = [];
    this.element.insert(new Element('div', { id: this.element.id + '_container' }));
    this.months.times(function(month) { this.createCalendar(month) }.bind(this));

    this.register().populate().refreshRange();
  },

  // Scaffolding

  createCalendar: function() {
    var calendar = new Element('table', {
      id: this.element.id + '_calendar_' + this.calendars.length, border: 0, cellspacing: 0, cellpadding: 5
    });
    calendar.insert(new Element('caption'));

    var head = new Element('thead');
    var row  = new Element('tr');
    this.weekdayNames.length.times(function(column) {
      var weekday = this.weekdayNames[(column + this.weekOffset) % 7];
      var cell = new Element('th', { scope: 'col', abbr: weekday }).update(weekday);
      row.insert(cell);
    }.bind(this));
    head.insert(row);
    calendar.insert(head);

    var body = new Element('tbody');
    (6).times(function(rowNumber) {
      var row = new Element('tr');
      this.weekdayNames.length.times(function(column) {
        var cell = new Element('td');
        row.insert(cell);
      });
      body.insert(row);
    }.bind(this));
    calendar.insert(body);

    this.element.down('div#' + this.element.id + '_container').insert(calendar);
    this.calendars.push(calendar);
    this.months = this.calendars.length;
    return this;
  },

  destroyCalendar: function() {
    this.calendars.pop().remove();
    this.months = this.calendars.length;
    return this;
  },

  populate: function() {
    var month = this.date.neutral();
    month.setDate(1);

    if (this.earliest === null || this.earliest < month)
      this.buttons.get('previous').get('element').removeClassName('disabled');
    else
      this.buttons.get('previous').get('element').addClassName('disabled');

    this.calendars.each(function(calendar) {
      var caption = calendar.select('caption').first();
      caption.update(this.monthNames[month.getMonth()] + ' ' + month.getFullYear());

      var iterator = new Date(month);
      var offset = (iterator.getDay() - this.weekOffset) % 7;
      var inactive = offset > 0 ? 'pre beyond' : false;
      iterator.setDate(iterator.getDate() - offset);
      if (iterator.getDate() > 1 && !inactive) {
        iterator.setDate(iterator.getDate() - 7);
        if (iterator.getDate() > 1) inactive = 'pre beyond';
      }

      calendar.select('td').each(function(day) {
        day.date = new Date(iterator); // Is this expensive (we unload these later)? We could store the epoch time instead.
        day.update(day.date.getDate()).writeAttribute('class', inactive || 'active');
        if (this.jrs_populate_price_for_day(day) && (!this.earliest || day.date >= this.earliest) && (!this.latest || day.date <= this.latest))
          day.addClassName('selectable');
        else
          day.addClassName('unselectable');
        if (iterator.toString() === new Date().neutral().toString()) day.addClassName('today');
        day.baseClass = day.readAttribute('class');

        iterator.setDate(iterator.getDate() + 1);
        if (iterator.getDate() == 1) inactive = inactive ? false : 'post beyond';
			}.bind(this));

      month.setMonth(month.getMonth() + 1);
    }.bind(this));

    if (this.latest === null || this.latest > month)
      this.buttons.get('next').get('element').removeClassName('disabled');
    else
      this.buttons.get('next').get('element').addClassName('disabled');

    return this;
  },

	jrs_populate_price_for_day: function(day) {
		jrs_price = this.jrs_price_for_date(day.date);
		if(jrs_price) {
			day.insert("<div class='jrs_price'>$" + jrs_price + "</div>");
			return true;
		} else {
			day.insert("<div class='jrs_price'>N/A</div>");
			return false;
		}
	},
	
	jrs_price_for_date: function(d) {
		year = d.getFullYear() + "";
		month = d.getMonth() + 1;
		month = (month < 10 ? "0" : "") + month + "";
		day = d.getDate();
		day = (day < 10 ? "0" : "") + day + "";
		date_str = year + month + day;

		return jrs_prices[date_str];
	},

  _buildButtons: function() {
    var buttonList = new Element('ul', { id: this.element.id + '_menu', className: 'timeframe_menu' });
    this.buttons.each(function(pair) {
      if (pair.value.get('element'))
        pair.value.get('element').addClassName('timeframe_button').addClassName(pair.key);
      else {
        var item = new Element('li');
        var button = new Element('a', { className: 'timeframe_button ' + pair.key, href: '#', onclick: 'return false;' }).update(pair.value.get('label'));
        button.onclick = function() { return false; };
        pair.value.set('element', button);
        item.insert(button);
        buttonList.insert(item);
      }
    }.bind(this))
    if (buttonList.childNodes.length > 0) this.element.insert({ top: buttonList });
    this.clearButton = new Element('span', { className: 'clear' }).update(new Element('span').update('X'));
    return this;
  },

  _buildFields: function() {
    var fieldset = new Element('div', { id: this.element.id + '_fields', className: 'timeframe_fields' });
    this.fields.each(function(pair) {
      if (pair.value)
        pair.value.addClassName('timeframe_field').addClassName(pair.key);
      else {
        var container = new Element('div', { id: pair.key + this.element.id + '_field_container' });
        this.fields.set(pair.key, new Element('input', { id: this.element.id + '_' + pair.key + 'field', name: pair.key + 'field', type: 'text', value: '' }));
        container.insert(new Element('label', { 'for': pair.key + 'field' }).update(pair.key));
        container.insert(this.fields.get(pair.key));
        fieldset.insert(container);
      }
    }.bind(this));
    if (fieldset.childNodes.length > 0) this.element.insert(fieldset);
    this.parseField('start').refreshField('start').parseField('end').refreshField('end').initDate = new Date(this.date);
    return this;
  },

  // Event registration

  register: function() {
    document.observe('click', this.eventClick.bind(this));
    this.element.observe('mousedown', this.eventMouseDown.bind(this));
    this.element.observe('mouseover', this.eventMouseOver.bind(this));
    document.observe('mouseup', this.eventMouseUp.bind(this));
    document.observe('unload', this.unregister.bind(this));
    // mousemove listener for Opera in _disableTextSelection
    return this._registerFieldObserver('start')._registerFieldObserver('end')._disableTextSelection();
  },

  unregister: function() {
    this.element.select('td').each(function(day) { day.date = day.baseClass = null; });
  },

  _registerFieldObserver: function(fieldName) {
    var field = this.fields.get(fieldName);
    field.observe('focus', function() { field.hasFocus = true; this.parseField(fieldName, true); }.bind(this));
    field.observe('blur', function() { this.refreshField(fieldName); }.bind(this));
    new Form.Element.Observer(field, 0.2, function(element, value) { if (element.hasFocus) this.parseField(fieldName, true); }.bind(this));
    return this;
  },

  _disableTextSelection: function() {
    if (Prototype.Browser.IE) {
      this.element.onselectstart = function(event) {
        if (!/input|textarea/i.test(Event.element(event).tagName)) return false;
      };
    } else if (Prototype.Browser.Opera) {
      document.observe('mousemove', this.handleMouseMove.bind(this));
    } else {
      this.element.onmousedown = function(event) {
        if (!/input|textarea/i.test(Event.element(event).tagName)) return false;
      };
    }
    return this;
  },

  // Fields

  parseField: function(fieldName, populate) {
    var field = this.fields.get(fieldName);
    var date = Date.parseToObject($F(this.fields.get(fieldName)));
    var failure = this.validateField(fieldName, date);
    if (failure != 'hard') {
      this.range.set(fieldName, date);
      field.removeClassName('error');
    } else if (field.hasFocus)
      field.addClassName('error');
    var date = Date.parseToObject(this.range.get(fieldName));
    this.date = date || new Date();
    if (populate && date) this.populate()
    this.refreshRange();
    return this;
  },

  refreshField: function(fieldName) {
    var field = this.fields.get(fieldName);
    var initValue = $F(field);
    if (this.range.get(fieldName)) {
      field.setValue(typeof Date.CultureInfo == 'undefined' ?
        this.range.get(fieldName).strftime(this.format) :
        this.range.get(fieldName).toString(this.format));
    } else
      field.setValue('');
    field.hasFocus && $F(field) == '' && initValue != '' ? field.addClassName('error') : field.removeClassName('error');
    field.hasFocus = false;
    return this;
  },

  validateField: function(fieldName, date) {
    if (!date) return;
    var error;
    if ((this.earliest && date < this.earliest) || (this.latest && date > this.latest))
      error = 'hard';
    else if (fieldName == 'start' && this.range.get('end') && date > this.range.get('end'))
      error = 'soft';
    else if (fieldName == 'end' && this.range.get('start') && date < this.range.get('start'))
      error = 'soft';
    return error;
  },

  // Event handling

  eventClick: function(event) {
    if (!event.element().ancestors) return;
    var el;
    if (el = event.findElement('a.timeframe_button'))
      this.handleButtonClick(event, el);
  },

  eventMouseDown: function(event) {
    if (!event.element().ancestors) return;
    var el, em;
    if (el = event.findElement('span.clear')) {
      el.down('span').addClassName('active');
      if (em = event.findElement('td.selectable'))
        this.handleDateClick(em, true);
    } else if (el = event.findElement('td.selectable'))
      this.handleDateClick(el);
    else return;
  },

  handleButtonClick: function(event, element) {
    var el;
    var movement = this.months > 1 ? this.months - 1 : 1;
    if (element.hasClassName('next')) {
      if (!this.buttons.get('next').get('element').hasClassName('disabled'))
        this.date.setMonth(this.date.getMonth() + movement);
    } else if (element.hasClassName('previous')) {
      if (!this.buttons.get('previous').get('element').hasClassName('disabled'))
        this.date.setMonth(this.date.getMonth() - movement);
    } else if (element.hasClassName('today'))
      this.date = new Date();
    else if (element.hasClassName('reset'))
      this.reset();
    this.populate().refreshRange();
  },

  reset: function() {
    this.fields.get('start').setValue(this.fields.get('start').defaultValue || '');
    this.fields.get('end').setValue(this.fields.get('end').defaultValue || '');
    this.date = new Date(this.initDate);
    this.parseField('start').refreshField('start').parseField('end').refreshField('end');
  },

  clear: function() {
    this.clearRange();
    this.refreshRange();
  },

  handleDateClick: function(element, couldClear) {
    this.mousedown = this.dragging = true;
    if (this.stuck) {
      this.stuck = false;
      return;
    } else if (couldClear) {
      if (!element.hasClassName('startrange')) return;
    } else if (this.maxRange != 1) {
      this.stuck = true;
      setTimeout(function() { if (this.mousedown) this.stuck = false; }.bind(this), 200);
    }
    this.getPoint(element.date);
  },

  getPoint: function(date) {
    if (this.range.get('start') && this.range.get('start').toString() == date && this.range.get('end'))
      this.startdrag = this.range.get('end');
    else {
      this.clearButton.hide();
      if (this.range.get('end') && this.range.get('end').toString() == date)
        this.startdrag = this.range.get('start');
      else
        this.startdrag = this.range.set('start', this.range.set('end', date));
    }
    this.validateRange(date, date);
    this.refreshRange();
  },

  eventMouseOver: function(event) {
    var el;
    if (!this.dragging)
      this.toggleClearButton(event);
    else if (event.findElement('span.clear span.active'));
    else if (el = event.findElement('td.selectable'))
      this.extendRange(el.date);
    else this.toggleClearButton(event);
  },

  toggleClearButton: function(event) {
    var el;
    if (event.element().ancestors && event.findElement('td.selected')) {
      if (el = this.element.select('#' + this.calendars.first().id +  ' .pre.selected').first());
      else if (el = this.element.select('.active.selected').first());
      else if (el = this.element.select('.post.selected').first());
      if (el) Element.insert(el, { top: this.clearButton });
      this.clearButton.show().select('span').first().removeClassName('active');        
    } else
      this.clearButton.hide();
  },

  extendRange: function(date) {
    var start, end;
    this.clearButton.hide();
    if (date > this.startdrag) {
      start = this.startdrag;
      end = date;
    } else if (date < this.startdrag) {
      start = date;
      end = this.startdrag;
    } else
      start = end = date;
    this.validateRange(start, end);
    this.refreshRange();
  },

  validateRange: function(start, end) {
    if (this.maxRange) {
      var range = this.maxRange - 1;
      var days = parseInt((end - start) / 86400000);
      if (days > range) {
        if (start == this.startdrag) {
          end = new Date(this.startdrag);
          end.setDate(end.getDate() + range);
        } else {
          start = new Date(this.startdrag);
          start.setDate(start.getDate() - range);
        }
      }
    }
    if (this.minRange) {
      var range = this.minRange - 1;
      var days = parseInt((end - start) / 86400000);
      if (days < range) {
        if (start == this.startdrag) {
          end = new Date(this.startdrag);
          end.setDate(end.getDate() + range);
        } else {
          start = new Date(this.startdrag);
          start.setDate(start.getDate() - range);
        }
      }
    }
		var last_available = start;
		var total = 0;
		epoc = new Date(0);
		for (var d=start; d<=end; d = new Date((d-epoc) + 86400000)) {
			last_available = d;
			if (!(this.jrs_price_for_date(d) > 0)) {
				break;
			}
		}
		end = last_available;
    this.range.set('start', start);
    this.range.set('end', end);
  },

  eventMouseUp: function(event) {
    if (!this.dragging) return;
    if (!this.stuck) {
      this.dragging = false;
      if (event.findElement('span.clear span.active'))
        this.clearRange();
    }
    this.mousedown = false;
    this.refreshRange();
  },

  clearRange: function() {
    this.clearButton.hide().select('span').first().removeClassName('active');
    this.range.set('start', this.range.set('end', null));
    this.refreshField('start').refreshField('end');
    if (this.options.keys().include('onClear')) this.options.get('onClear')();
  },

  refreshRange: function() {
    this.element.select('td').each(function(day) {
      day.writeAttribute('class', day.baseClass);
      if (this.range.get('start') && this.range.get('end') && this.range.get('start') <= day.date && day.date <= this.range.get('end')) {
        var baseClass = day.hasClassName('beyond') ? 'beyond_' : day.hasClassName('today') ? 'today_' : null;
        var state = this.stuck || this.mousedown ? 'stuck' : 'selected';
        if (baseClass) day.addClassName(baseClass + state);
        day.addClassName(state);
        var rangeClass = '';
        if (this.range.get('start').toString() == day.date) rangeClass += 'start';
        if (this.range.get('end').toString() == day.date) rangeClass += 'end';
        if (rangeClass.length > 0) {
					day.addClassName(rangeClass + 'range');
				} else {
					day.addClassName('midrange');					
				}
      }
      if (Prototype.Browser.Opera) {
        day.unselectable = 'on'; // Trick Opera into refreshing the selection (FIXME)
        day.unselectable = null;
      }
    }.bind(this));
    if (this.dragging) this.refreshField('start').refreshField('end');
  },

  setRange: function(start, end) {
    var range = $H({ start: start, end: end });
    range.each(function(pair) {
      this.range.set(pair.key, Date.parseToObject(pair.value));
      this.refreshField(pair.key);
      this.parseField(pair.key, true);
    }.bind(this));
    return this;
  },

  handleMouseMove: function(event) {
    if (event.findElement('#' + this.element.id + ' td')) window.getSelection().removeAllRanges(); // More Opera trickery
  }
});

Object.extend(Date, {
  parseToObject: function(string) {
    var date = Date.parse(string);
    if (!date) return null;
    date = new Date(date);
    return (date == 'Invalid Date' || date == 'NaN') ? null : date.neutral();
  }
});

Object.extend(Date.prototype, {
  // modified from http://alternateidea.com/blog/articles/2008/2/8/a-strftime-for-prototype
  strftime: function(format) {
    var day = this.getDay(), month = this.getMonth();
    var hours = this.getHours(), minutes = this.getMinutes();
    function pad(num) { return num.toPaddedString(2); };

    return format.gsub(/\%([aAbBcdHImMpSwyY])/, function(part) {
      switch(part[1]) {
        case 'a': return Locale.get('dayNames').invoke('substring', 0, 3)[day].escapeHTML(); break;
        case 'A': return Locale.get('dayNames')[day].escapeHTML(); break;
        case 'b': return Locale.get('monthNames').invoke('substring', 0, 3)[month].escapeHTML(); break;
        case 'B': return Locale.get('monthNames')[month].escapeHTML(); break;
        case 'c': return this.toString(); break;
        case 'd': return pad(this.getDate()); break;
        case 'H': return pad(hours); break;
        case 'I': return (hours % 12 == 0) ? 12 : pad(hours % 12); break;
        case 'm': return pad(month + 1); break;
        case 'M': return pad(minutes); break;
        case 'p': return hours >= 12 ? 'PM' : 'AM'; break;
        case 'S': return pad(this.getSeconds()); break;
        case 'w': return day; break;
        case 'y': return pad(this.getFullYear() % 100); break;
        case 'Y': return this.getFullYear().toString(); break;
      }
    }.bind(this));
  },

  neutral: function() {
    return new Date(this.getFullYear(), this.getMonth(), this.getDate(), 12);
  }
});
;



var jrs_prices = new Array();
	jrs_prices["20100208"]="119.00";
	jrs_prices["20100209"]="99.00";
	jrs_prices["20100210"]="99.00";
	jrs_prices["20100211"]="119.00";
	jrs_prices["20100215"]="119.00";
	jrs_prices["20100216"]="99.00";
	jrs_prices["20100217"]="119.00";
	jrs_prices["20100219"]="149.00";
	jrs_prices["20100220"]="149.00";
	jrs_prices["20100221"]="149.00";
	jrs_prices["20100222"]="99.00";
	jrs_prices["20100223"]="129.00";
	jrs_prices["20100224"]="119.00";
	jrs_prices["20100225"]="119.00";
	jrs_prices["20100226"]="159.00";
	jrs_prices["20100227"]="159.00";
	jrs_prices["20100228"]="189.00";
	jrs_prices["20100301"]="129.00";
	jrs_prices["20100302"]="99.00";
	jrs_prices["20100303"]="119.00";
	jrs_prices["20100304"]="119.00";
	jrs_prices["20100305"]="179.00";
	jrs_prices["20100306"]="179.00";
	jrs_prices["20100307"]="149.00";
	jrs_prices["20100308"]="139.00";
	jrs_prices["20100309"]="119.00";
	jrs_prices["20100310"]="119.00";
	jrs_prices["20100311"]="119.00";
	jrs_prices["20100312"]="159.00";
	jrs_prices["20100313"]="149.00";
	jrs_prices["20100314"]="159.00";
	jrs_prices["20100315"]="119.00";
	jrs_prices["20100316"]="119.00";
	jrs_prices["20100317"]="119.00";
	jrs_prices["20100318"]="119.00";
	jrs_prices["20100319"]="179.00";
	jrs_prices["20100320"]="149.00";
	jrs_prices["20100321"]="159.00";
	jrs_prices["20100322"]="159.00";
	jrs_prices["20100323"]="149.00";
	jrs_prices["20100324"]="149.00";
	jrs_prices["20100325"]="99.00";
	jrs_prices["20100326"]="149.00";
	jrs_prices["20100327"]="149.00";
	jrs_prices["20100328"]="149.00";
	jrs_prices["20100329"]="119.00";
	jrs_prices["20100330"]="99.00";
	jrs_prices["20100331"]="99.00";
	jrs_prices["20100401"]="99.00";
	jrs_prices["20100402"]="149.00";
	jrs_prices["20100403"]="149.00";
	jrs_prices["20100404"]="149.00";
	jrs_prices["20100405"]="99.00";
	jrs_prices["20100406"]="99.00";
	jrs_prices["20100407"]="99.00";
	jrs_prices["20100408"]="99.00";
	jrs_prices["20100409"]="149.00";
	jrs_prices["20100410"]="149.00";
	jrs_prices["20100411"]="149.00";
	jrs_prices["20100412"]="99.00";
	jrs_prices["20100413"]="99.00";
	jrs_prices["20100414"]="99.00";
	jrs_prices["20100415"]="99.00";
	jrs_prices["20100416"]="149.00";
	jrs_prices["20100417"]="189.00";
	jrs_prices["20100418"]="189.00";
	jrs_prices["20100419"]="139.00";
	jrs_prices["20100420"]="99.00";
	jrs_prices["20100421"]="99.00";
	jrs_prices["20100422"]="99.00";
	jrs_prices["20100423"]="149.00";
	jrs_prices["20100424"]="149.00";
	jrs_prices["20100425"]="149.00";
	jrs_prices["20100426"]="99.00";
	jrs_prices["20100427"]="99.00";
	jrs_prices["20100428"]="99.00";
	jrs_prices["20100429"]="99.00";
	jrs_prices["20100430"]="149.00";
	jrs_prices["20100501"]="149.00";
	jrs_prices["20100502"]="149.00";
	jrs_prices["20100503"]="99.00";
	jrs_prices["20100504"]="99.00";
	jrs_prices["20100505"]="99.00";
	jrs_prices["20100506"]="99.00";
	jrs_prices["20100507"]="149.00";
	jrs_prices["20100508"]="149.00";
	jrs_prices["20100509"]="159.00";
	jrs_prices["20100510"]="119.00";
	jrs_prices["20100511"]="99.00";
	jrs_prices["20100512"]="99.00";
	jrs_prices["20100513"]="99.00";
	jrs_prices["20100514"]="149.00";
	jrs_prices["20100515"]="149.00";
	jrs_prices["20100516"]="149.00";
	jrs_prices["20100517"]="99.00";
	jrs_prices["20100518"]="99.00";
	jrs_prices["20100519"]="99.00";
	jrs_prices["20100520"]="99.00";
	jrs_prices["20100521"]="159.00";
	jrs_prices["20100522"]="159.00";
	jrs_prices["20100523"]="149.00";
	jrs_prices["20100524"]="99.00";
	jrs_prices["20100525"]="99.00";
	jrs_prices["20100526"]="99.00";
	jrs_prices["20100527"]="99.00";
	jrs_prices["20100528"]="149.00";
	jrs_prices["20100529"]="149.00";
	jrs_prices["20100530"]="149.00";
	jrs_prices["20100531"]="99.00";
	jrs_prices["20100601"]="99.00";
	jrs_prices["20100602"]="99.00";
	jrs_prices["20100603"]="99.00";
	jrs_prices["20100604"]="149.00";
	jrs_prices["20100605"]="149.00";
	jrs_prices["20100606"]="149.00";
	jrs_prices["20100607"]="99.00";
	jrs_prices["20100608"]="99.00";
	jrs_prices["20100609"]="99.00";
	jrs_prices["20100610"]="99.00";
	jrs_prices["20100611"]="149.00";
	jrs_prices["20100612"]="149.00";
	jrs_prices["20100613"]="149.00";
	jrs_prices["20100614"]="99.00";
	jrs_prices["20100615"]="99.00";
	jrs_prices["20100616"]="99.00";
	jrs_prices["20100617"]="99.00";
	jrs_prices["20100618"]="149.00";
	jrs_prices["20100619"]="149.00";
	jrs_prices["20100620"]="149.00";
	jrs_prices["20100621"]="99.00";
	jrs_prices["20100622"]="99.00";
	jrs_prices["20100623"]="99.00";
	jrs_prices["20100624"]="99.00";
	jrs_prices["20100625"]="149.00";
	jrs_prices["20100626"]="149.00";
	jrs_prices["20100627"]="149.00";
	jrs_prices["20100628"]="99.00";
	jrs_prices["20100629"]="99.00";
	jrs_prices["20100630"]="99.00";
	jrs_prices["20100701"]="99.00";
	jrs_prices["20100702"]="149.00";
	jrs_prices["20100703"]="149.00";
	jrs_prices["20100704"]="149.00";
	jrs_prices["20100705"]="99.00";
	jrs_prices["20100706"]="99.00";
	jrs_prices["20100707"]="99.00";
	jrs_prices["20100708"]="99.00";
	jrs_prices["20100709"]="149.00";
	jrs_prices["20100710"]="149.00";
	jrs_prices["20100711"]="149.00";
	jrs_prices["20100712"]="99.00";
	jrs_prices["20100713"]="99.00";
	jrs_prices["20100714"]="99.00";
	jrs_prices["20100715"]="99.00";
	jrs_prices["20100716"]="149.00";
	jrs_prices["20100717"]="149.00";
	jrs_prices["20100718"]="149.00";
	jrs_prices["20100719"]="99.00";
	jrs_prices["20100720"]="99.00";
	jrs_prices["20100721"]="99.00";
	jrs_prices["20100722"]="99.00";
	jrs_prices["20100723"]="149.00";
	jrs_prices["20100724"]="149.00";
	jrs_prices["20100725"]="149.00";
	jrs_prices["20100726"]="99.00";
	jrs_prices["20100727"]="99.00";
	jrs_prices["20100728"]="99.00";
	jrs_prices["20100729"]="99.00";
	jrs_prices["20100730"]="149.00";
	jrs_prices["20100731"]="149.00";
	jrs_prices["20100801"]="149.00";
	jrs_prices["20100802"]="99.00";
	jrs_prices["20100803"]="99.00";
	jrs_prices["20100804"]="99.00";
	jrs_prices["20100805"]="99.00";
	jrs_prices["20100806"]="149.00";
	jrs_prices["20100807"]="149.00";
	jrs_prices["20100808"]="149.00";
	jrs_prices["20100809"]="99.00";
	jrs_prices["20100810"]="99.00";
	jrs_prices["20100811"]="99.00";
	jrs_prices["20100812"]="99.00";
	jrs_prices["20100813"]="149.00";
	jrs_prices["20100814"]="149.00";
	jrs_prices["20100815"]="149.00";
	jrs_prices["20100816"]="99.00";
	jrs_prices["20100817"]="99.00";
	jrs_prices["20100818"]="99.00";
	jrs_prices["20100819"]="99.00";
	jrs_prices["20100820"]="149.00";
	jrs_prices["20100821"]="149.00";
	jrs_prices["20100822"]="149.00";
	jrs_prices["20100823"]="99.00";
	jrs_prices["20100824"]="99.00";
	jrs_prices["20100825"]="99.00";
	jrs_prices["20100826"]="99.00";
	jrs_prices["20100827"]="149.00";
	jrs_prices["20100828"]="149.00";
	jrs_prices["20100829"]="149.00";
	jrs_prices["20100830"]="99.00";
	jrs_prices["20100831"]="99.00";
	jrs_prices["20100901"]="99.00";
	jrs_prices["20100902"]="99.00";
	jrs_prices["20100903"]="149.00";
	jrs_prices["20100904"]="149.00";
	jrs_prices["20100905"]="149.00";
	jrs_prices["20100906"]="99.00";
	jrs_prices["20100907"]="99.00";
	jrs_prices["20100908"]="99.00";
	jrs_prices["20100909"]="99.00";
	jrs_prices["20100910"]="149.00";
	jrs_prices["20100911"]="149.00";
	jrs_prices["20100912"]="149.00";
	jrs_prices["20100913"]="99.00";
	jrs_prices["20100914"]="99.00";
	jrs_prices["20100915"]="99.00";
	jrs_prices["20100916"]="99.00";
	jrs_prices["20100917"]="149.00";
	jrs_prices["20100918"]="149.00";
	jrs_prices["20100919"]="149.00";
	jrs_prices["20100920"]="99.00";
	jrs_prices["20100921"]="99.00";
	jrs_prices["20100922"]="99.00";
	jrs_prices["20100923"]="99.00";
	jrs_prices["20100924"]="149.00";
	jrs_prices["20100925"]="149.00";
	jrs_prices["20100926"]="149.00";
	jrs_prices["20100927"]="99.00";
	jrs_prices["20100928"]="99.00";
	jrs_prices["20100929"]="99.00";
	jrs_prices["20100930"]="99.00";
	jrs_prices["20101001"]="149.00";
	jrs_prices["20101002"]="149.00";
	jrs_prices["20101003"]="149.00";
	jrs_prices["20101004"]="99.00";
	jrs_prices["20101005"]="99.00";
	jrs_prices["20101006"]="99.00";
	jrs_prices["20101007"]="99.00";
	jrs_prices["20101008"]="149.00";
	jrs_prices["20101009"]="149.00";
	jrs_prices["20101010"]="149.00";
	jrs_prices["20101011"]="99.00";
	jrs_prices["20101012"]="99.00";
	jrs_prices["20101013"]="99.00";
	jrs_prices["20101014"]="99.00";
	jrs_prices["20101015"]="149.00";
	jrs_prices["20101016"]="149.00";
	jrs_prices["20101017"]="149.00";
	jrs_prices["20101018"]="99.00";
	jrs_prices["20101019"]="99.00";
	jrs_prices["20101020"]="99.00";
	jrs_prices["20101021"]="99.00";
	jrs_prices["20101022"]="149.00";
	jrs_prices["20101023"]="149.00";
	jrs_prices["20101024"]="149.00";
	jrs_prices["20101025"]="99.00";
	jrs_prices["20101026"]="99.00";
	jrs_prices["20101027"]="99.00";
	jrs_prices["20101028"]="99.00";
	jrs_prices["20101029"]="149.00";
	jrs_prices["20101030"]="149.00";
	jrs_prices["20101031"]="149.00";
	jrs_prices["20101101"]="99.00";
	jrs_prices["20101102"]="99.00";
	jrs_prices["20101103"]="99.00";
	jrs_prices["20101104"]="99.00";
	jrs_prices["20101105"]="149.00";
	jrs_prices["20101106"]="149.00";
	jrs_prices["20101107"]="149.00";
	jrs_prices["20101108"]="99.00";
	jrs_prices["20101109"]="99.00";
	jrs_prices["20101110"]="99.00";
	jrs_prices["20101111"]="99.00";
	jrs_prices["20101112"]="149.00";
	jrs_prices["20101113"]="149.00";
	jrs_prices["20101114"]="149.00";
	jrs_prices["20101115"]="99.00";
	jrs_prices["20101116"]="99.00";
	jrs_prices["20101117"]="99.00";
	jrs_prices["20101118"]="99.00";
	jrs_prices["20101119"]="149.00";
	jrs_prices["20101120"]="149.00";
	jrs_prices["20101121"]="149.00";
	jrs_prices["20101122"]="99.00";
	jrs_prices["20101123"]="99.00";
	jrs_prices["20101124"]="99.00";
	jrs_prices["20101125"]="99.00";
	jrs_prices["20101126"]="149.00";
	jrs_prices["20101127"]="149.00";
	jrs_prices["20101128"]="149.00";
	jrs_prices["20101129"]="99.00";
	jrs_prices["20101130"]="99.00";
	jrs_prices["20101201"]="99.00";
	jrs_prices["20101202"]="99.00";
	jrs_prices["20101203"]="149.00";
	jrs_prices["20101204"]="149.00";
	jrs_prices["20101205"]="149.00";
	jrs_prices["20101206"]="99.00";
	jrs_prices["20101207"]="99.00";
	jrs_prices["20101208"]="99.00";
	jrs_prices["20101209"]="99.00";
	jrs_prices["20101210"]="149.00";
	jrs_prices["20101211"]="149.00";
	jrs_prices["20101212"]="149.00";
	jrs_prices["20101213"]="99.00";
	jrs_prices["20101214"]="99.00";
	jrs_prices["20101215"]="99.00";
	jrs_prices["20101216"]="99.00";
	jrs_prices["20101217"]="149.00";
	jrs_prices["20101218"]="149.00";
	jrs_prices["20101219"]="149.00";
	jrs_prices["20101220"]="99.00";
	jrs_prices["20101221"]="99.00";
	jrs_prices["20101222"]="99.00";
	jrs_prices["20101223"]="99.00";
	jrs_prices["20101224"]="149.00";
	jrs_prices["20101225"]="149.00";
	jrs_prices["20101226"]="149.00";
	jrs_prices["20101227"]="99.00";
	jrs_prices["20101228"]="99.00";
	jrs_prices["20101229"]="99.00";
	jrs_prices["20101230"]="99.00";
	jrs_prices["20101231"]="149.00";
	jrs_prices["20110101"]="149.00";
	jrs_prices["20110102"]="149.00";
	jrs_prices["20110103"]="99.00";
	jrs_prices["20110104"]="99.00";
	jrs_prices["20110105"]="99.00";
	jrs_prices["20110106"]="99.00";
	jrs_prices["20110107"]="149.00";
	jrs_prices["20110108"]="149.00";
	jrs_prices["20110109"]="149.00";
	jrs_prices["20110110"]="99.00";
	jrs_prices["20110111"]="99.00";
	jrs_prices["20110112"]="99.00";
	jrs_prices["20110113"]="99.00";
	jrs_prices["20110114"]="149.00";
	jrs_prices["20110115"]="149.00";
	jrs_prices["20110116"]="149.00";
	jrs_prices["20110117"]="99.00";
	jrs_prices["20110118"]="99.00";
	jrs_prices["20110119"]="99.00";
	jrs_prices["20110120"]="99.00";
	jrs_prices["20110121"]="149.00";
	jrs_prices["20110122"]="149.00";
	jrs_prices["20110123"]="149.00";
	jrs_prices["20110124"]="99.00";
	jrs_prices["20110125"]="99.00";
	jrs_prices["20110126"]="99.00";
	jrs_prices["20110127"]="99.00";
	jrs_prices["20110128"]="149.00";
	jrs_prices["20110129"]="149.00";
	jrs_prices["20110130"]="149.00";
	jrs_prices["20110131"]="99.00";
	jrs_prices["20110201"]="99.00";
	jrs_prices["20110202"]="99.00";
	jrs_prices["20110203"]="99.00";


document.write('<div id="jrs_calendars_base">                                                                                       \n');
document.write('  <div id="jrs_calendars"></div>                                                                                      \n');
document.write('  <div id="jrs_calendars_buttons">                                                                                    \n');
document.write('    <form action="http://florida-bookdirect.com/redirect.php"  method="get" accept-charset="utf-8">      \n');
document.write('      <input type="hidden" id="cloneID" name="cloneID" value="151" />                                    \n');
document.write('      <input type="hidden" id="group_id" name="group_id" value="497" />                                  \n');
document.write('      <input type="hidden" id="catID" name="catID" value="103" />                                                     \n');
document.write('      <input type="hidden" id="linkTypeID" name="linkTypeID" value="5" />                                             \n');
document.write('      <input type="hidden" id="clickSourceID" name="clickSourceID" value="14" />                                      \n');
document.write('      <input type="hidden" id="eventID" name="eventID" value="14014" />                                    \n');
document.write('      <table border="0">                                                                                              \n');
document.write('        <tr>                                                                                                          \n');
document.write('          <td>                                                                                                        \n');
document.write('            <a href="#" id="previous" class="previous" onclick="return false;">&lt;&lt;</a>                           \n');
document.write('            <a href="#" id="today" class="today" onclick="return false;">Today</a>                                    \n');
document.write('            <a href="#" id="reset" class="reset" onclick="return false;">Reset</a>                                    \n');
document.write('            <a href="#" id="next" class="next" onclick="return false;">&gt;&gt;</a>                                   \n');
document.write('          </td><td>                                                                                                   \n');
document.write('            Arrive <input type="text" id="sDate" name="sDate" value="02/08/2010"/>        \n');
document.write('            Depart <input type="text" id="eDate" name="eDate" value="02/09/2010"/>  \n');
document.write('          </td><td>                                                                                                   \n');
document.write('            <input type="image" src="/images/bookdirect_button.gif" width="75" height="28" />                         \n');
document.write('          </td>                                                                                                       \n');
document.write('        </tr>                                                                                                         \n');
document.write('      </table>                                                                                                        \n');
document.write('    </form>                                                                                                           \n');
document.write('  </div>                                                                                                              \n');
document.write('</div>                                                                                                              \n');

jrs_timeframe_latest = new Date(); 
jrs_timeframe_latest.setFullYear(jrs_timeframe_latest.getFullYear() + 1);

new Timeframe('jrs_calendars', {
  startField: 'sDate',
  endField: 'eDate',
  earliest: new Date(),
  latest: jrs_timeframe_latest,
  previousButton: 'previous',
  todayButton: 'today',
  nextButton: 'next',
  resetButton: 'reset',
  format: '%m/%d/%Y',
  maxRange: 31,
  minRange: 2,
  months: 2
});
  

