function positionInfo(object) {

  var p_elm = object;

  this.getElementLeft = getElementLeft;
  function getElementLeft() {
    var x = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      x+= elm.offsetLeft;
      elm = elm.offsetParent;
    }
    return parseInt(x);
  }

  this.getElementWidth = getElementWidth;
  function getElementWidth(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetWidth);
  }

  this.getElementRight = getElementRight;
  function getElementRight(){
    return getElementLeft(p_elm) + getElementWidth(p_elm);
  }

  this.getElementTop = getElementTop;
  function getElementTop() {
    var y = 0;
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    while (elm != null) {
      y+= elm.offsetTop;
      elm = elm.offsetParent;
    }
    return parseInt(y);
  }

  this.getElementHeight = getElementHeight;
  function getElementHeight(){
    var elm;
    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    return parseInt(elm.offsetHeight);
  }

  this.getElementBottom = getElementBottom;
  function getElementBottom(){
    return getElementTop(p_elm) + getElementHeight(p_elm);
  }
}

function CalendarControl() {

  var calendarId = 'CalendarControl';
  var currentYear = 0;
  var currentMonth = 0;
  var currentDay = 0;

  var selectedYear = 0;
  var selectedMonth = 0;
  var selectedDay = 0;

  var months = ['January','February','March','April','May','June','July','August','September','October','November','December'];
  var dateField = null;

  function getProperty(p_property){
    var p_elm = calendarId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if (elm != null){
      if(elm.style){
        elm = elm.style;
        if(elm[p_property]){
          return elm[p_property];
        } else {
          return null;
        }
      } else {
        return null;
      }
    }
  }

  function setElementProperty(p_property, p_value, p_elmId){
    var p_elm = p_elmId;
    var elm = null;

    if(typeof(p_elm) == "object"){
      elm = p_elm;
    } else {
      elm = document.getElementById(p_elm);
    }
    if((elm != null) && (elm.style != null)){
      elm = elm.style;
      elm[ p_property ] = p_value;
    }
  }

  function setProperty(p_property, p_value) {
    setElementProperty(p_property, p_value, calendarId);
  }

  function getDaysInMonth(year, month) {
    return [31,((!(year % 4 ) && ( (year % 100 ) || !( year % 400 ) ))?29:28),31,30,31,30,31,31,30,31,30,31][month-1];
  }

  function getDayOfWeek(year, month, day) {
    var date = new Date(year,month-1,day)
    return date.getDay();
  }

  this.clearDate = clearDate;
  function clearDate() {
    dateField.value = '';
    hide();
  }

  this.setDate = setDate;
  function setDate(year, month, day) {
    if (dateField) {
      if (month < 10) {month = "0" + month;}
      if (day < 10) {day = "0" + day;}

      var dateString = month+"-"+day+"-"+year;
      dateField.value = dateString;
      hide();
    }
    return;
  }

  this.changeMonth = changeMonth;
  function changeMonth(change) {
    currentMonth += change;
    currentDay = 0;
    if(currentMonth > 12) {
      currentMonth = 1;
      currentYear++;
    } else if(currentMonth < 1) {
      currentMonth = 12;
      currentYear--;
    }

    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  this.changeYear = changeYear;
  function changeYear(change) {
    currentYear += change;
    currentDay = 0;
    calendar = document.getElementById(calendarId);
    calendar.innerHTML = calendarDrawTable();
  }

  function getCurrentYear() {
    var year = new Date().getYear();
    if(year < 1900) year += 1900;
    return year;
  }

  function getCurrentMonth() {
    return new Date().getMonth() + 1;
  } 

  function getCurrentDay() {
    return new Date().getDate();
  }

  function calendarDrawTable() {

    var dayOfMonth = 1;
    var validDay = 0;
    var startDayOfWeek = getDayOfWeek(currentYear, currentMonth, dayOfMonth);
    var daysInMonth = getDaysInMonth(currentYear, currentMonth);
    var css_class = null; //CSS class for each day

    var table = "<table cellspacing='0' cellpadding='0' border='0'>";
    table = table + "<tr class='header'>";
    table = table + "  <td colspan='2' class='previous'><a href='javascript:changeCalendarControlMonth(-1);'>&lt;</a> <a href='javascript:changeCalendarControlYear(-1);'>&laquo;</a></td>";
    table = table + "  <td colspan='3' class='title'>" + months[currentMonth-1] + "<br>" + currentYear + "</td>";
    table = table + "  <td colspan='2' class='next'><a href='javascript:changeCalendarControlYear(1);'>&raquo;</a> <a href='javascript:changeCalendarControlMonth(1);'>&gt;</a></td>";
    table = table + "</tr>";
    table = table + "<tr><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>";

    for(var week=0; week < 6; week++) {
      table = table + "<tr>";
      for(var dayOfWeek=0; dayOfWeek < 7; dayOfWeek++) {
        if(week == 0 && startDayOfWeek == dayOfWeek) {
          validDay = 1;
        } else if (validDay == 1 && dayOfMonth > daysInMonth) {
          validDay = 0;
        }

        if(validDay) {
          if (dayOfMonth == selectedDay && currentYear == selectedYear && currentMonth == selectedMonth) {
            css_class = 'current';
          } else if (dayOfWeek == 0 || dayOfWeek == 6) {
            css_class = 'weekend';
          } else {
            css_class = 'weekday';
          }

          table = table + "<td><a class='"+css_class+"' href=\"javascript:setCalendarControlDate("+currentYear+","+currentMonth+","+dayOfMonth+")\">"+dayOfMonth+"</a></td>";
          dayOfMonth++;
        } else {
          table = table + "<td class='empty'>&nbsp;</td>";
        }
      }
      table = table + "</tr>";
    }

    table = table + "<tr class='header'><th colspan='7' style='padding: 3px;'><a href='javascript:clearCalendarControl();'>Clear</a> | <a href='javascript:hideCalendarControl();'>Close</a></td></tr>";
    table = table + "</table>";

    return table;
  }

  this.show = show;
  function show(field) {
    can_hide = 0;
  
    // If the calendar is visible and associated with
    // this field do not do anything.
    if (dateField == field) {
      return;
    } else {
      dateField = field;
    }

    if(dateField) {
      try {
        var dateString = new String(dateField.value);
        var dateParts = dateString.split("-");
        
        selectedMonth = parseInt(dateParts[0],10);
        selectedDay = parseInt(dateParts[1],10);
        selectedYear = parseInt(dateParts[2],10);
      } catch(e) {}
    }

    if (!(selectedYear && selectedMonth && selectedDay)) {
      selectedMonth = getCurrentMonth();
      selectedDay = getCurrentDay();
      selectedYear = getCurrentYear();
    }

    currentMonth = selectedMonth;
    currentDay = selectedDay;
    currentYear = selectedYear;

    if(document.getElementById){

      calendar = document.getElementById(calendarId);
      calendar.innerHTML = calendarDrawTable(currentYear, currentMonth);

      setProperty('display', 'block');

      var fieldPos = new positionInfo(dateField);
      var calendarPos = new positionInfo(calendarId);

      var x = fieldPos.getElementLeft();
      var y = fieldPos.getElementBottom();

      setProperty('left', x + "px");
      setProperty('top', y + "px");
 
      if (document.all) {
        setElementProperty('display', 'block', 'CalendarControlIFrame');
        setElementProperty('left', x + "px", 'CalendarControlIFrame');
        setElementProperty('top', y + "px", 'CalendarControlIFrame');
        setElementProperty('width', calendarPos.getElementWidth() + "px", 'CalendarControlIFrame');
        setElementProperty('height', calendarPos.getElementHeight() + "px", 'CalendarControlIFrame');
      }
    }
  }

  this.hide = hide;
  function hide() {
    if(dateField) {
      setProperty('display', 'none');
      setElementProperty('display', 'none', 'CalendarControlIFrame');
      dateField = null;
    }
  }

  this.visible = visible;
  function visible() {
    return dateField
  }

  this.can_hide = can_hide;
  var can_hide = 0;
}

var calendarControl = new CalendarControl();

function showCalendarControl(textField) {
  // textField.onblur = hideCalendarControl;
  calendarControl.show(textField);
}

function clearCalendarControl() {
  calendarControl.clearDate();
}

function hideCalendarControl() {
  if (calendarControl.visible()) {
    calendarControl.hide();
  }
}

function setCalendarControlDate(year, month, day) {
  calendarControl.setDate(year, month, day);
}

function changeCalendarControlYear(change) {
  calendarControl.changeYear(change);
}

function changeCalendarControlMonth(change) {
  calendarControl.changeMonth(change);
}

document.write("<iframe id='CalendarControlIFrame' src='javascript:false;' frameBorder='0' scrolling='no'></iframe>");
document.write("<div id='CalendarControl'></div>");
var Prototype={Version:'1.5.1',Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf('AppleWebKit/')>-1,Gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')==-1},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:(document.createElement('div').__proto__!==document.createElement('form').__proto__)},ScriptFragment:'<script[^>]*>([\u0001-\uFFFF]*?)</script>',JSONFilter:/^\/\*-secure-\s*(.*)\s*\*\/\s*$/,emptyFunction:function(){},K:function(x){return x}};var Class={create:function(){return function(){this.initialize.apply(this,arguments)}}};var Abstract=new Object();Object.extend=function(a,b){for(var c in b){a[c]=b[c]}return a};Object.extend(Object,{inspect:function(a){try{if(a===undefined)return'undefined';if(a===null)return'null';return a.inspect?a.inspect():a.toString()}catch(e){if(e instanceof RangeError)return'...';throw e;}},toJSON:function(a){var b=typeof a;switch(b){case'undefined':case'function':case'unknown':return;case'boolean':return a.toString()}if(a===null)return'null';if(a.toJSON)return a.toJSON();if(a.ownerDocument===document)return;var c=[];for(var d in a){var e=Object.toJSON(a[d]);if(e!==undefined)c.push(d.toJSON()+': '+e)}return'{'+c.join(', ')+'}'},keys:function(a){var b=[];for(var c in a)b.push(c);return b},values:function(a){var b=[];for(var c in a)b.push(a[c]);return b},clone:function(a){return Object.extend({},a)}});Function.prototype.bind=function(){var a=this,args=$A(arguments),object=args.shift();return function(){return a.apply(object,args.concat($A(arguments)))}};Function.prototype.bindAsEventListener=function(b){var c=this,args=$A(arguments),b=args.shift();return function(a){return c.apply(b,[a||window.event].concat(args))}};Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(a){$R(0,this,true).each(a);return this},toPaddedString:function(a,b){var c=this.toString(b||10);return'0'.times(a-c.length)+c},toJSON:function(){return isFinite(this)?this.toString():'null'}});Date.prototype.toJSON=function(){return'"'+this.getFullYear()+'-'+(this.getMonth()+1).toPaddedString(2)+'-'+this.getDate().toPaddedString(2)+'T'+this.getHours().toPaddedString(2)+':'+this.getMinutes().toPaddedString(2)+':'+this.getSeconds().toPaddedString(2)+'"'};var Try={these:function(){var a;for(var i=0,length=arguments.length;i<length;i++){var b=arguments[i];try{a=b();break}catch(e){}}return a}};var PeriodicalExecuter=Class.create();PeriodicalExecuter.prototype={initialize:function(a,b){this.callback=a;this.frequency=b;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},stop:function(){if(!this.timer)return;clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.callback(this)}finally{this.currentlyExecuting=false}}}};Object.extend(String,{interpret:function(a){return a==null?'':String(a)},specialChar:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','\\':'\\\\'}});Object.extend(String.prototype,{gsub:function(a,b){var c='',source=this,match;b=arguments.callee.prepareReplacement(b);while(source.length>0){if(match=source.match(a)){c+=source.slice(0,match.index);c+=String.interpret(b(match));source=source.slice(match.index+match[0].length)}else{c+=source,source=''}}return c},sub:function(b,c,d){c=this.gsub.prepareReplacement(c);d=d===undefined?1:d;return this.gsub(b,function(a){if(--d<0)return a[0];return c(a)})},scan:function(a,b){this.gsub(a,b);return this},truncate:function(a,b){a=a||30;b=b===undefined?'...':b;return this.length>a?this.slice(0,a-b.length)+b:this},strip:function(){return this.replace(/^\s+/,'').replace(/\s+$/,'')},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'')},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,'img'),'')},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,'img');var c=new RegExp(Prototype.ScriptFragment,'im');return(this.match(b)||[]).map(function(a){return(a.match(c)||['',''])[1]})},evalScripts:function(){return this.extractScripts().map(function(a){return eval(a)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var c=document.createElement('div');c.innerHTML=this.stripTags();return c.childNodes[0]?(c.childNodes.length>1?$A(c.childNodes).inject('',function(a,b){return a+b.nodeValue}):c.childNodes[0].nodeValue):''},toQueryParams:function(e){var f=this.strip().match(/([^?#]*)(#.*)?$/);if(!f)return{};return f[1].split(e||'&').inject({},function(a,b){if((b=b.split('='))[0]){var c=decodeURIComponent(b.shift());var d=b.length>1?b.join('='):b[0];if(d!=undefined)d=decodeURIComponent(d);if(c in a){if(a[c].constructor!=Array)a[c]=[a[c]];a[c].push(d)}else a[c]=d}return a})},toArray:function(){return this.split('')},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){var b='';for(var i=0;i<a;i++)b+=this;return b},camelize:function(){var a=this.split('-'),len=a.length;if(len==1)return a[0];var b=this.charAt(0)=='-'?a[0].charAt(0).toUpperCase()+a[0].substring(1):a[0];for(var i=1;i<len;i++)b+=a[i].charAt(0).toUpperCase()+a[i].substring(1);return b},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,'/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase()},dasherize:function(){return this.gsub(/_/,'-')},inspect:function(c){var d=this.gsub(/[\x00-\x1f\\]/,function(a){var b=String.specialChar[a[0]];return b?b:'\\u00'+a[0].charCodeAt().toPaddedString(2,16)});if(c)return'"'+d.replace(/"/g,'\\"')+'"';return"'"+d.replace(/'/g,'\\\'')+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,'#{1}')},evalJSON:function(a){var b=this.unfilterJSON();try{if(!a||(new RegExp('^("(\\\\.|[^"\\\\\\n\\r])'+'*'+'?"|[,:{}\\[\\]0-9.\\-+Eaeflnr-u \\n\\r\\t])+?$').test(b))){return eval('('+b+')')}}catch(e){}throw new SyntaxError('Badly formed JSON string: '+this.inspect());},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var d=this.length-a.length;return d>=0&&this.lastIndexOf(a)===d},empty:function(){return this==''},blank:function(){return/^\s*$/.test(this)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')},unescapeHTML:function(){return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')}})}String.prototype.gsub.prepareReplacement=function(b){if(typeof b=='function')return b;var c=new Template(b);return function(a){return c.evaluate(a)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement('div'),text:document.createTextNode('')});with(String.prototype.escapeHTML)div.appendChild(text);var Template=Class.create();Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;Template.prototype={initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(c){return this.template.gsub(this.pattern,function(a){var b=a[1];if(b=='\\')return a[2];return b+String.interpret(c[a[3]])})}};var $break={};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Enumerable={each:function(b){var c=0;try{this._each(function(a){b(a,c++)})}catch(e){if(e!=$break)throw e;}return this},eachSlice:function(a,b){var c=-a,slices=[],array=this.toArray();while((c+=a)<array.length)slices.push(array.slice(c,c+a));return slices.map(b)},all:function(c){var d=true;this.each(function(a,b){d=d&&!!(c||Prototype.K)(a,b);if(!d)throw $break;});return d},any:function(c){var d=false;this.each(function(a,b){if(d=!!(c||Prototype.K)(a,b))throw $break;});return d},collect:function(c){var d=[];this.each(function(a,b){d.push((c||Prototype.K)(a,b))});return d},detect:function(c){var d;this.each(function(a,b){if(c(a,b)){d=a;throw $break;}});return d},findAll:function(c){var d=[];this.each(function(a,b){if(c(a,b))d.push(a)});return d},grep:function(d,e){var f=[];this.each(function(a,b){var c=a.toString();if(c.match(d))f.push((e||Prototype.K)(a,b))});return f},include:function(b){var c=false;this.each(function(a){if(a==b){c=true;throw $break;}});return c},inGroupsOf:function(b,c){c=c===undefined?null:c;return this.eachSlice(b,function(a){while(a.length<b)a.push(c);return a})},inject:function(c,d){this.each(function(a,b){c=d(c,a,b)});return c},invoke:function(b){var c=$A(arguments).slice(1);return this.map(function(a){return a[b].apply(a,c)})},max:function(c){var d;this.each(function(a,b){a=(c||Prototype.K)(a,b);if(d==undefined||a>=d)d=a});return d},min:function(c){var d;this.each(function(a,b){a=(c||Prototype.K)(a,b);if(d==undefined||a<d)d=a});return d},partition:function(c){var d=[],falses=[];this.each(function(a,b){((c||Prototype.K)(a,b)?d:falses).push(a)});return[d,falses]},pluck:function(c){var d=[];this.each(function(a,b){d.push(a[c])});return d},reject:function(c){var d=[];this.each(function(a,b){if(!c(a,b))d.push(a)});return d},sortBy:function(e){return this.map(function(a,b){return{value:a,criteria:e(a,b)}}).sort(function(c,d){var a=c.criteria,b=d.criteria;return a<b?-1:a>b?1:0}).pluck('value')},toArray:function(){return this.map()},zip:function(){var c=Prototype.K,args=$A(arguments);if(typeof args.last()=='function')c=args.pop();var d=[this].concat(args).map($A);return this.map(function(a,b){return c(d.pluck(b))})},size:function(){return this.toArray().length},inspect:function(){return'#<Enumerable:'+this.toArray().inspect()+'>'}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});var $A=Array.from=function(a){if(!a)return[];if(a.toArray){return a.toArray()}else{var b=[];for(var i=0,length=a.length;i<length;i++)b.push(a[i]);return b}};if(Prototype.Browser.WebKit){$A=Array.from=function(a){if(!a)return[];if(!(typeof a=='function'&&a=='[object NodeList]')&&a.toArray){return a.toArray()}else{var b=[];for(var i=0,length=a.length;i<length;i++)b.push(a[i]);return b}}}Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(a){for(var i=0,length=this.length;i<length;i++)a(this[i])},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(a){return a!=null})},flatten:function(){return this.inject([],function(a,b){return a.concat(b&&b.constructor==Array?b.flatten():[b])})},without:function(){var b=$A(arguments);return this.select(function(a){return!b.include(a)})},indexOf:function(a){for(var i=0,length=this.length;i<length;i++)if(this[i]==a)return i;return-1},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(d){return this.inject([],function(a,b,c){if(0==c||(d?a.last()!=b:!a.include(b)))a.push(b);return a})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']'},toJSON:function(){var c=[];this.each(function(a){var b=Object.toJSON(a);if(b!==undefined)c.push(b)});return'['+c.join(', ')+']'}});Array.prototype.toArray=Array.prototype.clone;function $w(a){a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var a=[];for(var i=0,length=this.length;i<length;i++)a.push(this[i]);for(var i=0,length=arguments.length;i<length;i++){if(arguments[i].constructor==Array){for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++)a.push(arguments[i][j])}else{a.push(arguments[i])}}return a}}var Hash=function(a){if(a instanceof Hash)this.merge(a);else Object.extend(this,a||{})};Object.extend(Hash,{toQueryString:function(d){var e=[];e.add=arguments.callee.addPair;this.prototype._each.call(d,function(b){if(!b.key)return;var c=b.value;if(c&&typeof c=='object'){if(c.constructor==Array)c.each(function(a){e.add(b.key,a)});return}e.add(b.key,c)});return e.join('&')},toJSON:function(c){var d=[];this.prototype._each.call(c,function(a){var b=Object.toJSON(a.value);if(b!==undefined)d.push(a.key.toJSON()+': '+b)});return'{'+d.join(', ')+'}'}});Hash.toQueryString.addPair=function(a,b,c){a=encodeURIComponent(a);if(b===undefined)this.push(a);else this.push(a+'='+(b==null?'':encodeURIComponent(b)))};Object.extend(Hash.prototype,Enumerable);Object.extend(Hash.prototype,{_each:function(a){for(var b in this){var c=this[b];if(c&&c==Hash.prototype[b])continue;var d=[b,c];d.key=b;d.value=c;a(d)}},keys:function(){return this.pluck('key')},values:function(){return this.pluck('value')},merge:function(c){return $H(c).inject(this,function(a,b){a[b.key]=b.value;return a})},remove:function(){var a;for(var i=0,length=arguments.length;i<length;i++){var b=this[arguments[i]];if(b!==undefined){if(a===undefined)a=b;else{if(a.constructor!=Array)a=[a];a.push(b)}}delete this[arguments[i]]}return a},toQueryString:function(){return Hash.toQueryString(this)},inspect:function(){return'#<Hash:{'+this.map(function(a){return a.map(Object.inspect).join(': ')}).join(', ')+'}>'},toJSON:function(){return Hash.toJSON(this)}});function $H(a){if(a instanceof Hash)return a;return new Hash(a)};if(function(){var i=0,Test=function(a){this.key=a};Test.prototype.key='foo';for(var b in new Test('bar'))i++;return i>1}())Hash.prototype._each=function(a){var b=[];for(var c in this){var d=this[c];if((d&&d==Hash.prototype[c])||b.include(c))continue;b.push(c);var e=[c,d];e.key=c;e.value=d;a(e)}};ObjectRange=Class.create();Object.extend(ObjectRange.prototype,Enumerable);Object.extend(ObjectRange.prototype,{initialize:function(a,b,c){this.start=a;this.end=b;this.exclusive=c},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start)return false;if(this.exclusive)return a<this.end;return a<=this.end}});var $R=function(a,b,c){return new ObjectRange(a,b,c)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject('Msxml2.XMLHTTP')},function(){return new ActiveXObject('Microsoft.XMLHTTP')})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a))this.responders.push(a)},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(b,c,d,f){this.each(function(a){if(typeof a[b]=='function'){try{a[b].apply(a,[c,d,f])}catch(e){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=function(){};Ajax.Base.prototype={setOptions:function(a){this.options={method:'post',asynchronous:true,contentType:'application/x-www-form-urlencoded',encoding:'UTF-8',parameters:''};Object.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(typeof this.options.parameters=='string')this.options.parameters=this.options.parameters.toQueryParams()}};Ajax.Request=Class.create();Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Request.prototype=Object.extend(new Ajax.Base(),{_complete:false,initialize:function(a,b){this.transport=Ajax.getTransport();this.setOptions(b);this.request(a)},request:function(a){this.url=a;this.method=this.options.method;var b=Object.clone(this.options.parameters);if(!['get','post'].include(this.method)){b['_method']=this.method;this.method='post'}this.parameters=b;if(b=Hash.toQueryString(b)){if(this.method=='get')this.url+=(this.url.include('?')?'&':'?')+b;else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))b+='&_='}try{if(this.options.onCreate)this.options.onCreate(this.transport);Ajax.Responders.dispatch('onCreate',this,this.transport);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous)setTimeout(function(){this.respondToReadyState(1)}.bind(this),10);this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=='post'?(this.options.postBody||b):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType)this.onStateChange()}catch(e){this.dispatchException(e)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete))this.respondToReadyState(this.transport.readyState)},setRequestHeaders:function(){var b={'X-Requested-With':'XMLHttpRequest','X-Prototype-Version':Prototype.Version,'Accept':'text/javascript, text/html, application/xml, text/xml, */*'};if(this.method=='post'){b['Content-type']=this.options.contentType+(this.options.encoding?'; charset='+this.options.encoding:'');if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005)b['Connection']='close'}if(typeof this.options.requestHeaders=='object'){var c=this.options.requestHeaders;if(typeof c.push=='function')for(var i=0,length=c.length;i<length;i+=2)b[c[i]]=c[i+1];else $H(c).each(function(a){b[a.key]=a.value})}for(var d in b)this.transport.setRequestHeader(d,b[d])},success:function(){return!this.transport.status||(this.transport.status>=200&&this.transport.status<300)},respondToReadyState:function(a){var b=Ajax.Request.Events[a];var c=this.transport,json=this.evalJSON();if(b=='Complete'){try{this._complete=true;(this.options['on'+this.transport.status]||this.options['on'+(this.success()?'Success':'Failure')]||Prototype.emptyFunction)(c,json)}catch(e){this.dispatchException(e)}var d=this.getHeader('Content-type');if(d&&d.strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i))this.evalResponse()}try{(this.options['on'+b]||Prototype.emptyFunction)(c,json);Ajax.Responders.dispatch('on'+b,this,c,json)}catch(e){this.dispatchException(e)}if(b=='Complete'){this.transport.onreadystatechange=Prototype.emptyFunction}},getHeader:function(a){try{return this.transport.getResponseHeader(a)}catch(e){return null}},evalJSON:function(){try{var a=this.getHeader('X-JSON');return a?a.evalJSON():null}catch(e){return null}},evalResponse:function(){try{return eval((this.transport.responseText||'').unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch('onException',this,a)}});Ajax.Updater=Class.create();Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(c,d,e){this.container={success:(c.success||c),failure:(c.failure||(c.success?null:c))};this.transport=Ajax.getTransport();this.setOptions(e);var f=this.options.onComplete||Prototype.emptyFunction;this.options.onComplete=(function(a,b){this.updateContent();f(a,b)}).bind(this);this.request(d)},updateContent:function(){var a=this.container[this.success()?'success':'failure'];var b=this.transport.responseText;if(!this.options.evalScripts)b=b.stripScripts();if(a=$(a)){if(this.options.insertion)new this.options.insertion(a,b);else a.update(b)}if(this.success()){if(this.onComplete)setTimeout(this.onComplete.bind(this),10)}}});Ajax.PeriodicalUpdater=Class.create();Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(a,b,c){this.setOptions(c);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=b;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(a){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++)elements.push($(arguments[i]));return elements}if(typeof a=='string')a=document.getElementById(a);return Element.extend(a)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(a,b){var c=[];var d=document.evaluate(a,$(b)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,length=d.snapshotLength;i<length;i++)c.push(d.snapshotItem(i));return c};document.getElementsByClassName=function(a,b){var q=".//*[contains(concat(' ', @class, ' '), ' "+a+" ')]";return document._getElementsByXPath(q,b)}}else{document.getElementsByClassName=function(a,b){var c=($(b)||document.body).getElementsByTagName('*');var d=[],child;for(var i=0,length=c.length;i<length;i++){child=c[i];if(Element.hasClassName(child,a))d.push(Element.extend(child))}return d}}if(!window.Element)var Element={};Element.extend=function(a){var F=Prototype.BrowserFeatures;if(!a||!a.tagName||a.nodeType==3||a._extended||F.SpecificElementExtensions||a==window)return a;var b={},tagName=a.tagName,cache=Element.extend.cache,T=Element.Methods.ByTag;if(!F.ElementExtensions){Object.extend(b,Element.Methods),Object.extend(b,Element.Methods.Simulated)}if(T[tagName])Object.extend(b,T[tagName]);for(var c in b){var d=b[c];if(typeof d=='function'&&!(c in a))a[c]=cache.findOrStore(d)}a._extended=Prototype.emptyFunction;return a};Element.extend.cache={findOrStore:function(a){return this[a]=this[a]||function(){return a.apply(null,[this].concat($A(arguments)))}}};Element.Methods={visible:function(a){return $(a).style.display!='none'},toggle:function(a){a=$(a);Element[Element.visible(a)?'hide':'show'](a);return a},hide:function(a){$(a).style.display='none';return a},show:function(a){$(a).style.display='';return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){b=typeof b=='undefined'?'':b.toString();$(a).innerHTML=b.stripScripts();setTimeout(function(){b.evalScripts()},10);return a},replace:function(a,b){a=$(a);b=typeof b=='undefined'?'':b.toString();if(a.outerHTML){a.outerHTML=b.stripScripts()}else{var c=a.ownerDocument.createRange();c.selectNodeContents(a);a.parentNode.replaceChild(c.createContextualFragment(b.stripScripts()),a)}setTimeout(function(){b.evalScripts()},10);return a},inspect:function(d){d=$(d);var e='<'+d.tagName.toLowerCase();$H({'id':'id','className':'class'}).each(function(a){var b=a.first(),attribute=a.last();var c=(d[b]||'').toString();if(c)e+=' '+attribute+'='+c.inspect(true)});return e+'>'},recursivelyCollect:function(a,b){a=$(a);var c=[];while(a=a[b])if(a.nodeType==1)c.push(Element.extend(a));return c},ancestors:function(a){return $(a).recursivelyCollect('parentNode')},descendants:function(a){return $A($(a).getElementsByTagName('*')).each(Element.extend)},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1)a=a.nextSibling;return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild))return[];while(a&&a.nodeType!=1)a=a.nextSibling;if(a)return[a].concat($(a).nextSiblings());return[]},previousSiblings:function(a){return $(a).recursivelyCollect('previousSibling')},nextSiblings:function(a){return $(a).recursivelyCollect('nextSibling')},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(a,b){if(typeof b=='string')b=new Selector(b);return b.match($(a))},up:function(a,b,c){a=$(a);if(arguments.length==1)return $(a.parentNode);var d=a.ancestors();return b?Selector.findElement(d,b,c):d[c||0]},down:function(a,b,c){a=$(a);if(arguments.length==1)return a.firstDescendant();var d=a.descendants();return b?Selector.findElement(d,b,c):d[c||0]},previous:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.previousElementSibling(a));var d=a.previousSiblings();return b?Selector.findElement(d,b,c):d[c||0]},next:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.nextElementSibling(a));var d=a.nextSiblings();return b?Selector.findElement(d,b,c):d[c||0]},getElementsBySelector:function(){var a=$A(arguments),element=$(a.shift());return Selector.findChildElements(element,a)},getElementsByClassName:function(a,b){return document.getElementsByClassName(b,a)},readAttribute:function(a,b){a=$(a);if(Prototype.Browser.IE){if(!a.attributes)return null;var t=Element._attributeTranslations;if(t.values[b])return t.values[b](a,b);if(t.names[b])b=t.names[b];var c=a.attributes[b];return c?c.nodeValue:null}return a.getAttribute(b)},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a)))return;var c=a.className;if(c.length==0)return false;if(c==b||c.match(new RegExp("(^|\\s)"+b+"(\\s|$)")))return true;return false},addClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a).add(b);return a},removeClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a).remove(b);return a},toggleClassName:function(a,b){if(!(a=$(a)))return;Element.classNames(a)[a.hasClassName(b)?'remove':'add'](b);return a},observe:function(){Event.observe.apply(Event,arguments);return $A(arguments).first()},stopObserving:function(){Event.stopObserving.apply(Event,arguments);return $A(arguments).first()},cleanWhitespace:function(a){a=$(a);var b=a.firstChild;while(b){var c=b.nextSibling;if(b.nodeType==3&&!/\S/.test(b.nodeValue))a.removeChild(b);b=c}return a},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(a,b){a=$(a),b=$(b);while(a=a.parentNode)if(a==b)return true;return false},scrollTo:function(a){a=$(a);var b=Position.cumulativeOffset(a);window.scrollTo(b[0],b[1]);return a},getStyle:function(a,b){a=$(a);b=b=='float'?'cssFloat':b.camelize();var c=a.style[b];if(!c){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}if(b=='opacity')return c?parseFloat(c):1.0;return c=='auto'?null:c},getOpacity:function(a){return $(a).getStyle('opacity')},setStyle:function(a,b,c){a=$(a);var d=a.style;for(var e in b)if(e=='opacity')a.setOpacity(b[e]);else d[(e=='float'||e=='cssFloat')?(d.styleFloat===undefined?'cssFloat':'styleFloat'):(c?e:e.camelize())]=b[e];return a},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==='')?'':(b<0.00001)?0:b;return a},getDimensions:function(a){a=$(a);var b=$(a).getStyle('display');if(b!='none'&&b!=null)return{width:a.offsetWidth,height:a.offsetHeight};var c=a.style;var d=c.visibility;var e=c.position;var f=c.display;c.visibility='hidden';c.position='absolute';c.display='block';var g=a.clientWidth;var h=a.clientHeight;c.display=f;c.position=e;c.visibility=d;return{width:g,height:h}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,'position');if(b=='static'||!b){a._madePositioned=true;a.style.position='relative';if(window.opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=''}return a},makeClipping:function(a){a=$(a);if(a._overflow)return a;a._overflow=a.style.overflow||'auto';if((Element.getStyle(a,'overflow')||'visible')!='hidden')a.style.overflow='hidden';return a},undoClipping:function(a){a=$(a);if(!a._overflow)return a;a.style.overflow=a._overflow=='auto'?'':a._overflow;a._overflow=null;return a}};Object.extend(Element.Methods,{childOf:Element.Methods.descendantOf,childElements:Element.Methods.immediateDescendants});if(Prototype.Browser.Opera){Element.Methods._getStyle=Element.Methods.getStyle;Element.Methods.getStyle=function(a,b){switch(b){case'left':case'top':case'right':case'bottom':if(Element._getStyle(a,'position')=='static')return null;default:return Element._getStyle(a,b)}}}else if(Prototype.Browser.IE){Element.Methods.getStyle=function(a,b){a=$(a);b=(b=='float'||b=='cssFloat')?'styleFloat':b.camelize();var c=a.style[b];if(!c&&a.currentStyle)c=a.currentStyle[b];if(b=='opacity'){if(c=(a.getStyle('filter')||'').match(/alpha\(opacity=(.*)\)/))if(c[1])return parseFloat(c[1])/100;return 1.0}if(c=='auto'){if((b=='width'||b=='height')&&(a.getStyle('display')!='none'))return a['offset'+b.capitalize()]+'px';return null}return c};Element.Methods.setOpacity=function(a,b){a=$(a);var c=a.getStyle('filter'),style=a.style;if(b==1||b===''){style.filter=c.replace(/alpha\([^\)]*\)/gi,'');return a}else if(b<0.00001)b=0;style.filter=c.replace(/alpha\([^\)]*\)/gi,'')+'alpha(opacity='+(b*100)+')';return a};Element.Methods.update=function(b,c){b=$(b);c=typeof c=='undefined'?'':c.toString();var d=b.tagName.toUpperCase();if(['THEAD','TBODY','TR','TD'].include(d)){var e=document.createElement('div');switch(d){case'THEAD':case'TBODY':e.innerHTML='<table><tbody>'+c.stripScripts()+'</tbody></table>';depth=2;break;case'TR':e.innerHTML='<table><tbody><tr>'+c.stripScripts()+'</tr></tbody></table>';depth=3;break;case'TD':e.innerHTML='<table><tbody><tr><td>'+c.stripScripts()+'</td></tr></tbody></table>';depth=4}$A(b.childNodes).each(function(a){b.removeChild(a)});depth.times(function(){e=e.firstChild});$A(e.childNodes).each(function(a){b.appendChild(a)})}else{b.innerHTML=c.stripScripts()}setTimeout(function(){c.evalScripts()},10);return b}}else if(Prototype.Browser.Gecko){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==='')?'':(b<0.00001)?0:b;return a}}Element._attributeTranslations={names:{colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){var b=a.getAttributeNode('title');return b.specified?b.nodeValue:null}}};(function(){Object.extend(this,{href:this._getAttr,src:this._getAttr,type:this._getAttr,disabled:this._flag,checked:this._flag,readonly:this._flag,multiple:this._flag})}).call(Element._attributeTranslations.values);Element.Methods.Simulated={hasAttribute:function(a,b){var t=Element._attributeTranslations,node;b=t.names[b]||b;node=$(a).getAttributeNode(b);return node&&node.specified}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement('div').__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement('div').__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.hasAttribute=function(a,b){if(a.hasAttribute)return a.hasAttribute(b);return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(g){var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;if(!g){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{"FORM":Object.clone(Form.Methods),"INPUT":Object.clone(Form.Element.Methods),"SELECT":Object.clone(Form.Element.Methods),"TEXTAREA":Object.clone(Form.Element.Methods)})}if(arguments.length==2){var h=g;g=arguments[1]}if(!h)Object.extend(Element.Methods,g||{});else{if(h.constructor==Array)h.each(extend);else extend(h)}function extend(a){a=a.toUpperCase();if(!Element.Methods.ByTag[a])Element.Methods.ByTag[a]={};Object.extend(Element.Methods.ByTag[a],g)}function copy(a,b,c){c=c||false;var d=Element.extend.cache;for(var e in a){var f=a[e];if(!c||!(e in b))b[e]=d.findOrStore(f)}}function findDOMClass(a){var b;var c={"OPTGROUP":"OptGroup","TEXTAREA":"TextArea","P":"Paragraph","FIELDSET":"FieldSet","UL":"UList","OL":"OList","DL":"DList","DIR":"Directory","H1":"Heading","H2":"Heading","H3":"Heading","H4":"Heading","H5":"Heading","H6":"Heading","Q":"Quote","INS":"Mod","DEL":"Mod","A":"Anchor","IMG":"Image","CAPTION":"TableCaption","COL":"TableCol","COLGROUP":"TableCol","THEAD":"TableSection","TFOOT":"TableSection","TBODY":"TableSection","TR":"TableRow","TH":"TableCell","TD":"TableCell","FRAMESET":"FrameSet","IFRAME":"IFrame"};if(c[a])b='HTML'+c[a]+'Element';if(window[b])return window[b];b='HTML'+a+'Element';if(window[b])return window[b];b='HTML'+a.capitalize()+'Element';if(window[b])return window[b];window[b]={};window[b].prototype=document.createElement(a).__proto__;return window[b]}if(F.ElementExtensions){copy(Element.Methods,HTMLElement.prototype);copy(Element.Methods.Simulated,HTMLElement.prototype,true)}if(F.SpecificElementExtensions){for(var i in Element.Methods.ByTag){var j=findDOMClass(i);if(typeof j=="undefined")continue;copy(T[i],j.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag};var Toggle={display:Element.toggle};Abstract.Insertion=function(a){this.adjacency=a};Abstract.Insertion.prototype={initialize:function(a,b){this.element=$(a);this.content=b.stripScripts();if(this.adjacency&&this.element.insertAdjacentHTML){try{this.element.insertAdjacentHTML(this.adjacency,this.content)}catch(e){var c=this.element.tagName.toUpperCase();if(['TBODY','TR'].include(c)){this.insertContent(this.contentFromAnonymousTable())}else{throw e;}}}else{this.range=this.element.ownerDocument.createRange();if(this.initializeRange)this.initializeRange();this.insertContent([this.range.createContextualFragment(this.content)])}setTimeout(function(){b.evalScripts()},10)},contentFromAnonymousTable:function(){var a=document.createElement('div');a.innerHTML='<table><tbody>'+this.content+'</tbody></table>';return $A(a.childNodes[0].childNodes[0].childNodes)}};var Insertion=new Object();Insertion.Before=Class.create();Insertion.Before.prototype=Object.extend(new Abstract.Insertion('beforeBegin'),{initializeRange:function(){this.range.setStartBefore(this.element)},insertContent:function(b){b.each((function(a){this.element.parentNode.insertBefore(a,this.element)}).bind(this))}});Insertion.Top=Class.create();Insertion.Top.prototype=Object.extend(new Abstract.Insertion('afterBegin'),{initializeRange:function(){this.range.selectNodeContents(this.element);this.range.collapse(true)},insertContent:function(b){b.reverse(false).each((function(a){this.element.insertBefore(a,this.element.firstChild)}).bind(this))}});Insertion.Bottom=Class.create();Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion('beforeEnd'),{initializeRange:function(){this.range.selectNodeContents(this.element);this.range.collapse(this.element)},insertContent:function(b){b.each((function(a){this.element.appendChild(a)}).bind(this))}});Insertion.After=Class.create();Insertion.After.prototype=Object.extend(new Abstract.Insertion('afterEnd'),{initializeRange:function(){this.range.setStartAfter(this.element)},insertContent:function(b){b.each((function(a){this.element.parentNode.insertBefore(a,this.element.nextSibling)}).bind(this))}});Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(b){this.element.className.split(/\s+/).select(function(a){return a.length>0})._each(b)},set:function(a){this.element.className=a},add:function(a){if(this.include(a))return;this.set($A(this).concat(a).join(' '))},remove:function(a){if(!this.include(a))return;this.set($A(this).without(a).join(' '))},toString:function(){return $A(this).join(' ')}};Object.extend(Element.ClassNames.prototype,Enumerable);var Selector=Class.create();Selector.prototype={initialize:function(a){this.expression=a.strip();this.compileMatcher()},compileMatcher:function(){if(Prototype.BrowserFeatures.XPath&&!(/\[[\w-]*?:/).test(this.expression))return this.compileXPathMatcher();var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(typeof c[i]=='function'?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],'');break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join('\n'));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var e=this.expression,ps=Selector.patterns,x=Selector.xpath,le,m;if(Selector._cache[e]){this.xpath=Selector._cache[e];return}this.matcher=['.//*'];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){if(m=e.match(ps[i])){this.matcher.push(typeof x[i]=='function'?x[i](m):new Template(x[i]).evaluate(m));e=e.replace(m[0],'');break}}}this.xpath=this.matcher.join('');Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;if(this.xpath)return document._getElementsByXPath(this.xpath,a);return this.matcher(a)},match:function(a){return this.findElements(document).include(a)},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}};Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:'/following-sibling::*',tagName:function(m){if(m[1]=='*')return'';return"[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(m){m[3]=m[5]||m[6];return new Template(Selector.xpath.operators[m[2]]).evaluate(m)},pseudo:function(m){var h=Selector.xpath.pseudos[m[1]];if(!h)return'';if(typeof h==='function')return h(m);return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m)},operators:{'=':"[@#{1}='#{3}']",'!=':"[@#{1}!='#{3}']",'^=':"[starts-with(@#{1}, '#{3}')]",'$=':"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']",'*=':"[contains(@#{1}, '#{3}')]",'~=':"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]",'|=':"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{'first-child':'[not(preceding-sibling::*)]','last-child':'[not(following-sibling::*)]','only-child':'[not(preceding-sibling::* or following-sibling::*)]','empty':"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",'checked':"[@checked]",'disabled':"[@disabled]",'enabled':"[not(@disabled)]",'not':function(m){var e=m[6],p=Selector.patterns,x=Selector.xpath,le,m,v;var a=[];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in p){if(m=e.match(p[i])){v=typeof x[i]=='function'?x[i](m):new Template(x[i]).evaluate(m);a.push("("+v.substring(1,v.length-1)+")");e=e.replace(m[0],'');break}}}return"[not("+a.join(" and ")+")]"},'nth-child':function(m){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m)},'nth-last-child':function(m){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m)},'nth-of-type':function(m){return Selector.xpath.pseudos.nth("position() ",m)},'nth-last-of-type':function(m){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m)},'first-of-type':function(m){m[6]="1";return Selector.xpath.pseudos['nth-of-type'](m)},'last-of-type':function(m){m[6]="1";return Selector.xpath.pseudos['nth-last-of-type'](m)},'only-of-type':function(m){var p=Selector.xpath.pseudos;return p['first-of-type'](m)+p['last-of-type'](m)},nth:function(c,m){var d,formula=m[6],predicate;if(formula=='even')formula='2n+0';if(formula=='odd')formula='2n+1';if(d=formula.match(/^(\d+)$/))return'['+c+"= "+d[1]+']';if(d=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(d[1]=="-")d[1]=-1;var a=d[1]?Number(d[1]):1;var b=d[2]?Number(d[2]):0;predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(predicate).evaluate({fragment:c,a:a,b:b})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);   c = false;',className:'n = h.className(n, r, "#{1}", c); c = false;',id:'n = h.id(n, r, "#{1}", c);        c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}"); c = false;',attr:function(m){m[3]=(m[5]||m[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m)},pseudo:function(m){if(m[6])m[6]=m[6].replace(/"/g,'\\"');return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:new RegExp('^\\s'+'*'+'~\\s*'),child:new RegExp('^\\s'+'*'+'>\\s*'),adjacent:new RegExp('^\\s'+'*'+'\\+\\s*'),descendant:/^\s/,tagName:new RegExp('^\\s*'+'(\\'+'*|[\\w\\-]+)(\\b|$)?'),id:new RegExp('^#([\\w\\-\\'+'*]+)(\\b|$)'),className:new RegExp('^\\.([\\w\\-\\'+'*]+)(\\b|$)'),pseudo:new RegExp('^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\\((.*?)\\))?(\\b|$|\\s||(?=:))'),attrPresence:new RegExp('^\\[([\\w]+)\\]'),attr:new RegExp('\\[((?:[\\w-]*:)?[\\w-]+)\\s*(?:([!^$*~|]?=)\\s*(([\'"])([^\\]]*?)\\4|([^\'"][^\\]]*?)))?\\]')},handlers:{concat:function(a,b){for(var i=0,node;node=b[i];i++)a.push(node);return a},mark:function(a){for(var i=0,node;node=a[i];i++)node._counted=true;return a},unmark:function(a){for(var i=0,node;node=a[i];i++)node._counted=undefined;return a},index:function(a,b,c){a._counted=true;if(b){for(var d=a.childNodes,i=d.length-1,j=1;i>=0;i--){node=d[i];if(node.nodeType==1&&(!c||node._counted))node.nodeIndex=j++}}else{for(var i=0,j=1,d=a.childNodes;node=d[i];i++)if(node.nodeType==1&&(!c||node._counted))node.nodeIndex=j++}},unique:function(a){if(a.length==0)return a;var b=[],n;for(var i=0,l=a.length;i<l;i++)if(!(n=a[i])._counted){n._counted=true;b.push(Element.extend(n))}return Selector.handlers.unmark(b)},descendant:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)h.concat(results,node.getElementsByTagName('*'));return results},child:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++){for(var j=0,children=[],child;child=node.childNodes[j];j++)if(child.nodeType==1&&child.tagName!='!')results.push(child)}return results},adjacent:function(a){for(var i=0,results=[],node;node=a[i];i++){var b=this.nextElementSibling(node);if(b)results.push(b)}return results},laterSibling:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)h.concat(results,Element.nextSiblings(node));return results},nextElementSibling:function(a){while(a=a.nextSibling)if(a.nodeType==1)return a;return null},previousElementSibling:function(a){while(a=a.previousSibling)if(a.nodeType==1)return a;return null},tagName:function(a,b,c,d){c=c.toUpperCase();var e=[],h=Selector.handlers;if(a){if(d){if(d=="descendant"){for(var i=0,node;node=a[i];i++)h.concat(e,node.getElementsByTagName(c));return e}else a=this[d](a);if(c=="*")return a}for(var i=0,node;node=a[i];i++)if(node.tagName.toUpperCase()==c)e.push(node);return e}else return b.getElementsByTagName(c)},id:function(a,b,c,d){var e=$(c),h=Selector.handlers;if(!a&&b==document)return e?[e]:[];if(a){if(d){if(d=='child'){for(var i=0,node;node=a[i];i++)if(e.parentNode==node)return[e]}else if(d=='descendant'){for(var i=0,node;node=a[i];i++)if(Element.descendantOf(e,node))return[e]}else if(d=='adjacent'){for(var i=0,node;node=a[i];i++)if(Selector.handlers.previousElementSibling(e)==node)return[e]}else a=h[d](a)}for(var i=0,node;node=a[i];i++)if(node==e)return[e];return[]}return(e&&Element.descendantOf(e,b))?[e]:[]},className:function(a,b,c,d){if(a&&d)a=this[d](a);return Selector.handlers.byClassName(a,b,c)},byClassName:function(a,b,c){if(!a)a=Selector.handlers.descendant([b]);var d=' '+c+' ';for(var i=0,results=[],node,nodeClassName;node=a[i];i++){nodeClassName=node.className;if(nodeClassName.length==0)continue;if(nodeClassName==c||(' '+nodeClassName+' ').include(d))results.push(node)}return results},attrPresence:function(a,b,c){var d=[];for(var i=0,node;node=a[i];i++)if(Element.hasAttribute(node,c))d.push(node);return d},attr:function(a,b,c,d,e){if(!a)a=b.getElementsByTagName("*");var f=Selector.operators[e],results=[];for(var i=0,node;node=a[i];i++){var g=Element.readAttribute(node,c);if(g===null)continue;if(f(g,d))results.push(node)}return results},pseudo:function(a,b,c,d,e){if(a&&e)a=this[e](a);if(!a)a=d.getElementsByTagName("*");return Selector.pseudos[b](a,c,d)}},pseudos:{'first-child':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(Selector.handlers.previousElementSibling(node))continue;results.push(node)}return results},'last-child':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(Selector.handlers.nextElementSibling(node))continue;results.push(node)}return results},'only-child':function(a,b,c){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)if(!h.previousElementSibling(node)&&!h.nextElementSibling(node))results.push(node);return results},'nth-child':function(a,b,c){return Selector.pseudos.nth(a,b,c)},'nth-last-child':function(a,b,c){return Selector.pseudos.nth(a,b,c,true)},'nth-of-type':function(a,b,c){return Selector.pseudos.nth(a,b,c,false,true)},'nth-last-of-type':function(a,b,c){return Selector.pseudos.nth(a,b,c,true,true)},'first-of-type':function(a,b,c){return Selector.pseudos.nth(a,"1",c,false,true)},'last-of-type':function(a,b,c){return Selector.pseudos.nth(a,"1",c,true,true)},'only-of-type':function(a,b,c){var p=Selector.pseudos;return p['last-of-type'](p['first-of-type'](a,b,c),b,c)},getIndices:function(a,b,d){if(a==0)return b>0?[b]:[];return $R(1,d).inject([],function(c,i){if(0==(i-b)%a&&(i-b)/a>=0)c.push(i);return c})},nth:function(c,d,e,f,g){if(c.length==0)return[];if(d=='even')d='2n+0';if(d=='odd')d='2n+1';var h=Selector.handlers,results=[],indexed=[],m;h.mark(c);for(var i=0,node;node=c[i];i++){if(!node.parentNode._counted){h.index(node.parentNode,f,g);indexed.push(node.parentNode)}}if(d.match(/^\d+$/)){d=Number(d);for(var i=0,node;node=c[i];i++)if(node.nodeIndex==d)results.push(node)}else if(m=d.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(m[1]=="-")m[1]=-1;var a=m[1]?Number(m[1]):1;var b=m[2]?Number(m[2]):0;var k=Selector.pseudos.getIndices(a,b,c.length);for(var i=0,node,l=k.length;node=c[i];i++){for(var j=0;j<l;j++)if(node.nodeIndex==k[j])results.push(node)}}h.unmark(c);h.unmark(indexed);return results},'empty':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(node.tagName=='!'||(node.firstChild&&!node.innerHTML.match(/^\s*$/)))continue;results.push(node)}return results},'not':function(a,b,c){var h=Selector.handlers,selectorType,m;var d=new Selector(b).findElements(c);h.mark(d);for(var i=0,results=[],node;node=a[i];i++)if(!node._counted)results.push(node);h.unmark(d);return results},'enabled':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(!node.disabled)results.push(node);return results},'disabled':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(node.disabled)results.push(node);return results},'checked':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(node.checked)results.push(node);return results}},operators:{'=':function(a,v){return a==v},'!=':function(a,v){return a!=v},'^=':function(a,v){return a.startsWith(v)},'$=':function(a,v){return a.endsWith(v)},'*=':function(a,v){return a.include(v)},'~=':function(a,v){return(' '+a+' ').include(' '+v+' ')},'|=':function(a,v){return('-'+a.toUpperCase()+'-').include('-'+v.toUpperCase()+'-')}},matchElements:function(a,b){var c=new Selector(b).findElements(),h=Selector.handlers;h.mark(c);for(var i=0,results=[],element;element=a[i];i++)if(element._counted)results.push(element);h.unmark(c);return results},findElement:function(a,b,c){if(typeof b=='number'){c=b;b=false}return Selector.matchElements(a,b||'*')[c||0]},findChildElements:function(a,b){var c=b.join(','),b=[];c.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){b.push(m[1].strip())});var d=[],h=Selector.handlers;for(var i=0,l=b.length,selector;i<l;i++){selector=new Selector(b[i].strip());h.concat(d,selector.findElements(a))}return(l>1)?h.unique(d):d}});function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(d,e){var f=d.inject({},function(a,b){if(!b.disabled&&b.name){var c=b.name,value=$(b).getValue();if(value!=null){if(c in a){if(a[c].constructor!=Array)a[c]=[a[c]];a[c].push(value)}else a[c]=value}}return a});return e?f:Hash.toQueryString(f)}};Form.Methods={serialize:function(a,b){return Form.serializeElements(Form.getElements(a),b)},getElements:function(c){return $A($(c).getElementsByTagName('*')).inject([],function(a,b){if(Form.Element.Serializers[b.tagName.toLowerCase()])a.push(Element.extend(b));return a})},getInputs:function(a,b,c){a=$(a);var d=a.getElementsByTagName('input');if(!b&&!c)return $A(d).map(Element.extend);for(var i=0,matchingInputs=[],length=d.length;i<length;i++){var e=d[i];if((b&&e.type!=b)||(c&&e.name!=c))continue;matchingInputs.push(Element.extend(e))}return matchingInputs},disable:function(a){a=$(a);Form.getElements(a).invoke('disable');return a},enable:function(a){a=$(a);Form.getElements(a).invoke('enable');return a},findFirstElement:function(b){return $(b).getElements().find(function(a){return a.type!='hidden'&&!a.disabled&&['input','select','textarea'].include(a.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(a,b){a=$(a),b=Object.clone(b||{});var c=b.parameters;b.parameters=a.serialize(true);if(c){if(typeof c=='string')c=c.toQueryParams();Object.extend(b.parameters,c)}if(a.hasAttribute('method')&&!b.method)b.method=a.method;return new Ajax.Request(a.readAttribute('action'),b)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Hash.toQueryString(c)}}return''},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},clear:function(a){$(a).value='';return a},present:function(a){return $(a).value!=''},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!='input'||!['button','reset','submit'].include(a.type)))a.select()}catch(e){}return a},disable:function(a){a=$(a);a.blur();a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a){switch(a.type.toLowerCase()){case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(a);default:return Form.Element.Serializers.textarea(a)}},inputSelector:function(a){return a.checked?a.value:null},textarea:function(a){return a.value},select:function(a){return this[a.type=='select-one'?'selectOne':'selectMany'](a)},selectOne:function(a){var b=a.selectedIndex;return b>=0?this.optionValue(a.options[b]):null},selectMany:function(a){var b,length=a.length;if(!length)return null;for(var i=0,b=[];i<length;i++){var c=a.options[i];if(c.selected)b.push(this.optionValue(c))}return b},optionValue:function(a){return Element.extend(a).hasAttribute('value')?a.value:a.text}};Abstract.TimedObserver=function(){};Abstract.TimedObserver.prototype={initialize:function(a,b,c){this.frequency=b;this.element=$(a);this.callback=c;this.lastValue=this.getValue();this.registerCallback()},registerCallback:function(){setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},onTimerEvent:function(){var a=this.getValue();var b=('string'==typeof this.lastValue&&'string'==typeof a?this.lastValue!=a:String(this.lastValue)!=String(a));if(b){this.callback(this.element,a);this.lastValue=a}}};Form.Element.Observer=Class.create();Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create();Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=function(){};Abstract.EventObserver.prototype={initialize:function(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=='form')this.registerFormCallbacks();else this.registerCallback(this.element)},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback.bind(this))},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case'checkbox':case'radio':Event.observe(a,'click',this.onElementEvent.bind(this));break;default:Event.observe(a,'change',this.onElementEvent.bind(this));break}}}};Form.Element.EventObserver=Class.create();Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create();Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event=new Object()}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,element:function(a){return $(a.target||a.srcElement)},isLeftClick:function(a){return(((a.which)&&(a.which==1))||((a.button)&&(a.button==1)))},pointerX:function(a){return a.pageX||(a.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft))},pointerY:function(a){return a.pageY||(a.clientY+(document.documentElement.scrollTop||document.body.scrollTop))},stop:function(a){if(a.preventDefault){a.preventDefault();a.stopPropagation()}else{a.returnValue=false;a.cancelBubble=true}},findElement:function(a,b){var c=Event.element(a);while(c.parentNode&&(!c.tagName||(c.tagName.toUpperCase()!=b.toUpperCase())))c=c.parentNode;return c},observers:false,_observeAndCache:function(a,b,c,d){if(!this.observers)this.observers=[];if(a.addEventListener){this.observers.push([a,b,c,d]);a.addEventListener(b,c,d)}else if(a.attachEvent){this.observers.push([a,b,c,d]);a.attachEvent('on'+b,c)}},unloadCache:function(){if(!Event.observers)return;for(var i=0,length=Event.observers.length;i<length;i++){Event.stopObserving.apply(this,Event.observers[i]);Event.observers[i][0]=null}Event.observers=false},observe:function(a,b,c,d){a=$(a);d=d||false;if(b=='keypress'&&(Prototype.Browser.WebKit||a.attachEvent))b='keydown';Event._observeAndCache(a,b,c,d)},stopObserving:function(a,b,c,d){a=$(a);d=d||false;if(b=='keypress'&&(Prototype.Browser.WebKit||a.attachEvent))b='keydown';if(a.removeEventListener){a.removeEventListener(b,c,d)}else if(a.detachEvent){try{a.detachEvent('on'+b,c)}catch(e){}}}});if(Prototype.Browser.IE)Event.observe(window,'unload',Event.unloadCache,false);var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},realOffset:function(a){var b=0,valueL=0;do{b+=a.scrollTop||0;valueL+=a.scrollLeft||0;a=a.parentNode}while(a);return[valueL,b]},cumulativeOffset:function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;a=a.offsetParent}while(a);return[valueL,b]},positionedOffset:function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;a=a.offsetParent;if(a){if(a.tagName=='BODY')break;var p=Element.getStyle(a,'position');if(p=='relative'||p=='absolute')break}}while(a);return[valueL,b]},offsetParent:function(a){if(a.offsetParent)return a.offsetParent;if(a==document.body)return a;while((a=a.parentNode)&&a!=document.body)if(Element.getStyle(a,'position')!='static')return a;return document.body},within:function(a,x,y){if(this.includeScrollOffsets)return this.withinIncludingScrolloffsets(a,x,y);this.xcomp=x;this.ycomp=y;this.offset=this.cumulativeOffset(a);return(y>=this.offset[1]&&y<this.offset[1]+a.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+a.offsetWidth)},withinIncludingScrolloffsets:function(a,x,y){var b=this.realOffset(a);this.xcomp=x+b[0]-this.deltaX;this.ycomp=y+b[1]-this.deltaY;this.offset=this.cumulativeOffset(a);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+a.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+a.offsetWidth)},overlap:function(a,b){if(!a)return 0;if(a=='vertical')return((this.offset[1]+b.offsetHeight)-this.ycomp)/b.offsetHeight;if(a=='horizontal')return((this.offset[0]+b.offsetWidth)-this.xcomp)/b.offsetWidth},page:function(a){var b=0,valueL=0;var c=a;do{b+=c.offsetTop||0;valueL+=c.offsetLeft||0;if(c.offsetParent==document.body)if(Element.getStyle(c,'position')=='absolute')break}while(c=c.offsetParent);c=a;do{if(!window.opera||c.tagName=='BODY'){b-=c.scrollTop||0;valueL-=c.scrollLeft||0}}while(c=c.parentNode);return[valueL,b]},clone:function(a,b){var c=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});a=$(a);var p=Position.page(a);b=$(b);var d=[0,0];var e=null;if(Element.getStyle(b,'position')=='absolute'){e=Position.offsetParent(b);d=Position.page(e)}if(e==document.body){d[0]-=document.body.offsetLeft;d[1]-=document.body.offsetTop}if(c.setLeft)b.style.left=(p[0]-d[0]+c.offsetLeft)+'px';if(c.setTop)b.style.top=(p[1]-d[1]+c.offsetTop)+'px';if(c.setWidth)b.style.width=a.offsetWidth+'px';if(c.setHeight)b.style.height=a.offsetHeight+'px'},absolutize:function(a){a=$(a);if(a.style.position=='absolute')return;Position.prepare();var b=Position.positionedOffset(a);var c=b[1];var d=b[0];var e=a.clientWidth;var f=a.clientHeight;a._originalLeft=d-parseFloat(a.style.left||0);a._originalTop=c-parseFloat(a.style.top||0);a._originalWidth=a.style.width;a._originalHeight=a.style.height;a.style.position='absolute';a.style.top=c+'px';a.style.left=d+'px';a.style.width=e+'px';a.style.height=f+'px'},relativize:function(a){a=$(a);if(a.style.position=='relative')return;Position.prepare();a.style.position='relative';var b=parseFloat(a.style.top||0)-(a._originalTop||0);var c=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=b+'px';a.style.left=c+'px';a.style.height=a._originalHeight;a.style.width=a._originalWidth}};if(Prototype.Browser.WebKit){Position.cumulativeOffset=function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,'position')=='absolute')break;a=a.offsetParent}while(a);return[valueL,b]}}Element.addMethods();var Builder={NODEMAP:{AREA:"map",CAPTION:"table",COL:"table",COLGROUP:"table",LEGEND:"fieldset",OPTGROUP:"select",OPTION:"select",PARAM:"object",TBODY:"table",TD:"table",TFOOT:"table",TH:"table",THEAD:"table",TR:"table"},node:function(a){a=a.toUpperCase();var b=this.NODEMAP[a]||"div";var c=document.createElement(b);try{c.innerHTML="<"+a+"></"+a+">"}catch(e){}var d=c.firstChild||null;if(d&&d.tagName.toUpperCase()!=a){d=d.getElementsByTagName(a)[0]}if(!d){d=document.createElement(a)}if(!d){return}if(arguments[1]){if(this._isStringOrNumber(arguments[1])||arguments[1]instanceof Array||arguments[1].tagName){this._children(d,arguments[1])}else{var f=this._attributes(arguments[1]);if(f.length){try{c.innerHTML="<"+a+" "+f+"></"+a+">"}catch(e){}d=c.firstChild||null;if(!d){d=document.createElement(a);for(attr in arguments[1]){d[attr=="class"?"className":attr]=arguments[1][attr]}}if(d.tagName.toUpperCase()!=a){d=c.getElementsByTagName(a)[0]}}}}if(arguments[2]){this._children(d,arguments[2])}return d},_text:function(a){return document.createTextNode(a)},ATTR_MAP:{className:"class",htmlFor:"for"},_attributes:function(a){var b=[];for(attribute in a){b.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+"=\""+a[attribute].toString().escapeHTML().gsub(/"/,"&quot;")+"\"")}return b.join(" ")},_children:function(a,b){if(b.tagName){a.appendChild(b);return}if(typeof b=="object"){b.flatten().each(function(e){if(typeof e=="object"){a.appendChild(e)}else if(Builder._isStringOrNumber(e)){a.appendChild(Builder._text(e))}})}else if(Builder._isStringOrNumber(b)){a.appendChild(Builder._text(b))}},_isStringOrNumber:function(a){return typeof a=="string"||typeof a=="number"},build:function(a){var b=this.node("div");$(b).update(a.strip());return b.down()},dump:function(b){if(typeof b!="object"&&typeof b!="function"){b=window}var c="A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR".split(/\s+/);c.each(function(a){b[a]=function(){return Builder.node.apply(Builder,[a].concat($A(arguments)))}})}};String.prototype.parseColor=function(){var a="#";if(this.slice(0,4)=="rgb("){var b=this.slice(4,this.length-1).split(",");var i=0;do{a+=parseInt(b[i]).toColorPart()}while(++i<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var i=1;i<4;i++){a+=(this.charAt(i)+this.charAt(i)).toLowerCase()}}if(this.length==7){a=this.toLowerCase()}}}return a.length==7?a:arguments[0]||this};Element.collectTextNodes=function(b){return $A($(b).childNodes).collect(function(a){return a.nodeType==3?a.nodeValue:a.hasChildNodes()?Element.collectTextNodes(a):""}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(b,c){return $A($(b).childNodes).collect(function(a){return a.nodeType==3?a.nodeValue:a.hasChildNodes()&&!Element.hasClassName(a,c)?Element.collectTextNodesIgnoreClass(a,c):""}).flatten().join("")};Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:b/100+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var n=document.createTextNode(" ");a.appendChild(n);a.removeChild(n)}catch(e){}};Array.prototype.call=function(){var a=arguments;this.each(function(f){f.apply(this,a)})};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},tagifyText:function(c){if(typeof Builder=="undefined"){throw"Effect.tagifyText requires including script.aculo.us' builder.js library";}var d="position:relative";if(Prototype.Browser.IE){d+=";zoom:1"}c=$(c);$A(c.childNodes).each(function(b){if(b.nodeType==3){b.nodeValue.toArray().each(function(a){c.insertBefore(Builder.node("span",{style:d},a==" "?String.fromCharCode(160):a),b)});Element.remove(b)}})},multiple:function(c,d){var e;if((typeof c=="object"||typeof c=="function")&&c.length){e=c}else{e=$(c).childNodes}var f=Object.extend({speed:0.1,delay:0},arguments[2]||{});var g=f.delay;$A(e).each(function(a,b){new d(a,Object.extend(f,{delay:b*f.speed+g}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(a,b){a=$(a);b=(b||"appear").toLowerCase();var c=Object.extend({queue:{position:"end",scope:a.id||"global",limit:1}},arguments[2]||{});Effect[a.visible()?Effect.PAIRS[b][1]:Effect.PAIRS[b][0]](a,c)}};var Effect2=Effect;Effect.Transitions={linear:Prototype.K,sinoidal:function(a){return-Math.cos(a*Math.PI)/2+0.5},reverse:function(a){return 1-a},flicker:function(a){var a=-Math.cos(a*Math.PI)/4+0.75+Math.random()/4;return a>1?1:a},wobble:function(a){return-Math.cos(a*Math.PI*(9*a))/2+0.5},pulse:function(a,b){b=b||5;return Math.round(a%(1/b)*b)==0?a*b*2-Math.floor(a*b*2):1-(a*b*2-Math.floor(a*b*2))},none:function(a){return 0},full:function(a){return 1}};Effect.ScopedQueue=Class.create();Object.extend(Object.extend(Effect.ScopedQueue.prototype,Enumerable),{initialize:function(){this.effects=[];this.interval=null},_each:function(a){this.effects._each(a)},add:function(a){var b=(new Date).getTime();var c=typeof a.options.queue=="string"?a.options.queue:a.options.queue.position;switch(c){case"front":this.effects.findAll(function(e){return e.state=="idle"}).each(function(e){e.startOn+=a.finishOn;e.finishOn+=a.finishOn});break;case"with-last":b=this.effects.pluck("startOn").max()||b;break;case"end":b=this.effects.pluck("finishOn").max()||b;break;default:}a.startOn+=b;a.finishOn+=b;if(!a.options.queue.limit||this.effects.length<a.options.queue.limit){this.effects.push(a)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(a){this.effects=this.effects.reject(function(e){return e==a});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var a=(new Date).getTime();for(var i=0,len=this.effects.length;i<len;i++){this.effects[i]&&this.effects[i].loop(a)}}});Effect.Queues={instances:$H(),get:function(a){if(typeof a!="string"){return a}if(!this.instances[a]){this.instances[a]=new Effect.ScopedQueue}return this.instances[a]}};Effect.Queue=Effect.Queues.get("global");Effect.DefaultOptions={transition:Effect.Transitions.sinoidal,duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"};Effect.Base=function(){};Effect.Base.prototype={position:null,start:function(c){function codeForEvent(a,b){return(a[b+"Internal"]?"this.options."+b+"Internal(this);":"")+(a[b]?"this.options."+b+"(this);":"")}if(c.transition===false){c.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),c||{});this.currentFrame=0;this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+this.options.duration*1000;this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;this.totalFrames=this.options.fps*this.options.duration;eval("this.render = function(pos){ "+"if(this.state==\"idle\"){this.state=\"running\";"+codeForEvent(c,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(c,"afterSetup")+"};if(this.state==\"running\"){"+"pos=this.options.transition(pos)*"+this.fromToDelta+"+"+this.options.from+";"+"this.position=pos;"+codeForEvent(c,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(c,"afterUpdate")+"}}");this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).add(this)}},loop:function(a){if(a>=this.startOn){if(a>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return}var b=(a-this.startOn)/this.totalTime,frame=Math.round(b*this.totalFrames);if(frame>this.currentFrame){this.render(b);this.currentFrame=frame}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(a){if(this.options[a+"Internal"]){this.options[a+"Internal"](this)}if(this.options[a]){this.options[a](this)}},inspect:function(){var a=$H();for(property in this){if(typeof this[property]!="function"){a[property]=this[property]}}return"#<Effect:"+a.inspect()+",options:"+$H(this.options).inspect()+">"}};Effect.Parallel=Class.create();Object.extend(Object.extend(Effect.Parallel.prototype,Effect.Base.prototype),{initialize:function(a){this.effects=a||[];this.start(arguments[1])},update:function(a){this.effects.invoke("render",a)},finish:function(b){this.effects.each(function(a){a.render(1);a.cancel();a.event("beforeFinish");if(a.finish){a.finish(b)}a.event("afterFinish")})}});Effect.Event=Class.create();Object.extend(Object.extend(Effect.Event.prototype,Effect.Base.prototype),{initialize:function(){var a=Object.extend({duration:0},arguments[0]||{});this.start(a)},update:Prototype.emptyFunction});Effect.Opacity=Class.create();Object.extend(Object.extend(Effect.Opacity.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);if(!this.element){throw Effect._elementDoesNotExistError;}if(Prototype.Browser.IE&&!this.element.currentStyle.hasLayout){this.element.setStyle({zoom:1})}var b=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(b)},update:function(a){this.element.setOpacity(a)}});Effect.Move=Class.create();Object.extend(Object.extend(Effect.Move.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);if(!this.element){throw Effect._elementDoesNotExistError;}var b=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(b)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(a){this.element.setStyle({left:Math.round(this.options.x*a+this.originalLeft)+"px",top:Math.round(this.options.y*a+this.originalTop)+"px"})}});Effect.MoveBy=function(a,b,c){return new Effect.Move(a,Object.extend({x:c,y:b},arguments[3]||{}))};Effect.Scale=Class.create();Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{initialize:function(a,b){this.element=$(a);if(!this.element){throw Effect._elementDoesNotExistError;}var c=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:b},arguments[2]||{});this.start(c)},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each((function(k){this.originalStyle[k]=this.element.style[k]}).bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var b=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each((function(a){if(b.indexOf(a)>0){this.fontSize=parseFloat(b);this.fontSizeType=a}}).bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]}},update:function(a){var b=this.options.scaleFrom/100+this.factor*a;if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*b+this.fontSizeType})}this.setDimensions(this.dims[0]*b,this.dims[1]*b)},finish:function(a){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(a,b){var d={};if(this.options.scaleX){d.width=Math.round(b)+"px"}if(this.options.scaleY){d.height=Math.round(a)+"px"}if(this.options.scaleFromCenter){var c=(a-this.dims[0])/2;var e=(b-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){d.top=this.originalTop-c+"px"}if(this.options.scaleX){d.left=this.originalLeft-e+"px"}}else{if(this.options.scaleY){d.top=-c+"px"}if(this.options.scaleX){d.left=-e+"px"}}}this.element.setStyle(d)}});Effect.Highlight=Class.create();Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);if(!this.element){throw Effect._elementDoesNotExistError;}var b=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(b)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return}this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color")}this._base=$R(0,2).map((function(i){return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16)}).bind(this));this._delta=$R(0,2).map((function(i){return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i]}).bind(this))},update:function(a){this.element.setStyle({backgroundColor:$R(0,2).inject("#",(function(m,v,i){return m+Math.round(this._base[i]+this._delta[i]*a).toColorPart()}).bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=Class.create();Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{initialize:function(a){this.element=$(a);this.start(arguments[1]||{})},setup:function(){Position.prepare();var a=Position.cumulativeOffset(this.element);if(this.options.offset){a[1]+=this.options.offset}var b=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);this.scrollStart=Position.deltaY;this.delta=(a[1]>b?b:a[1])-this.scrollStart},update:function(a){Position.prepare();window.scrollTo(Position.deltaX,this.scrollStart+a*this.delta)}});Effect.Fade=function(b){b=$(b);var c=b.getInlineOpacity();var d=Object.extend({from:b.getOpacity()||1,to:0,afterFinishInternal:function(a){if(a.options.to!=0){return}a.element.hide().setStyle({opacity:c})}},arguments[1]||{});return new Effect.Opacity(b,d)};Effect.Appear=function(b){b=$(b);var c=Object.extend({from:b.getStyle("display")=="none"?0:b.getOpacity()||0,to:1,afterFinishInternal:function(a){a.element.forceRerendering()},beforeSetup:function(a){a.element.setOpacity(a.options.from).show()}},arguments[1]||{});return new Effect.Opacity(b,c)};Effect.Puff=function(b){b=$(b);var c={opacity:b.getInlineOpacity(),position:b.getStyle("position"),top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};return new Effect.Parallel([new Effect.Scale(b,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(a){Position.absolutize(a.effects[0].element)},afterFinishInternal:function(a){a.effects[0].element.hide().setStyle(c)}},arguments[1]||{}))};Effect.BlindUp=function(b){b=$(b);b.makeClipping();return new Effect.Scale(b,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(a){a.element.hide().undoClipping()}},arguments[1]||{}))};Effect.BlindDown=function(b){b=$(b);var c=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:c.height,originalWidth:c.width},restoreAfterFinish:true,afterSetup:function(a){a.element.makeClipping().setStyle({height:"0px"}).show()},afterFinishInternal:function(a){a.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(c){c=$(c);var d=c.getInlineOpacity();return new Effect.Appear(c,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(b){new Effect.Scale(b.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(a){a.element.makePositioned().makeClipping()},afterFinishInternal:function(a){a.element.hide().undoClipping().undoPositioned().setStyle({opacity:d})}})}},arguments[1]||{}))};Effect.DropOut=function(b){b=$(b);var c={top:b.getStyle("top"),left:b.getStyle("left"),opacity:b.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(b,{x:0,y:100,sync:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(a){a.effects[0].element.makePositioned()},afterFinishInternal:function(a){a.effects[0].element.hide().undoPositioned().setStyle(c)}},arguments[1]||{}))};Effect.Shake=function(g){g=$(g);var h={top:g.getStyle("top"),left:g.getStyle("left")};return new Effect.Move(g,{x:20,y:0,duration:0.05,afterFinishInternal:function(f){new Effect.Move(f.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(e){new Effect.Move(e.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(d){new Effect.Move(d.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(c){new Effect.Move(c.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(b){new Effect.Move(b.element,{x:-20,y:0,duration:0.05,afterFinishInternal:function(a){a.element.undoPositioned().setStyle(h)}})}})}})}})}})}})};Effect.SlideDown=function(b){b=$(b).cleanWhitespace();var c=b.down().getStyle("bottom");var d=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:d.height,originalWidth:d.width},restoreAfterFinish:true,afterSetup:function(a){a.element.makePositioned();a.element.down().makePositioned();if(window.opera){a.element.setStyle({top:""})}a.element.makeClipping().setStyle({height:"0px"}).show()},afterUpdateInternal:function(a){a.element.down().setStyle({bottom:a.dims[0]-a.element.clientHeight+"px"})},afterFinishInternal:function(a){a.element.undoClipping().undoPositioned();a.element.down().undoPositioned().setStyle({bottom:c})}},arguments[1]||{}))};Effect.SlideUp=function(b){b=$(b).cleanWhitespace();var c=b.down().getStyle("bottom");return new Effect.Scale(b,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(a){a.element.makePositioned();a.element.down().makePositioned();if(window.opera){a.element.setStyle({top:""})}a.element.makeClipping().show()},afterUpdateInternal:function(a){a.element.down().setStyle({bottom:a.dims[0]-a.element.clientHeight+"px"})},afterFinishInternal:function(a){a.element.hide().undoClipping().undoPositioned().setStyle({bottom:c});a.element.down().undoPositioned()}},arguments[1]||{}))};Effect.Squish=function(b){return new Effect.Scale(b,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(a){a.element.makeClipping()},afterFinishInternal:function(a){a.element.hide().undoClipping()}})};Effect.Grow=function(c){c=$(c);var d=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var e={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var f=c.getDimensions();var g,initialMoveY;var h,moveY;switch(d.direction){case"top-left":g=initialMoveY=h=moveY=0;break;case"top-right":g=f.width;initialMoveY=moveY=0;h=-f.width;break;case"bottom-left":g=h=0;initialMoveY=f.height;moveY=-f.height;break;case"bottom-right":g=f.width;initialMoveY=f.height;h=-f.width;moveY=-f.height;break;case"center":g=f.width/2;initialMoveY=f.height/2;h=-f.width/2;moveY=-f.height/2;break;default:}return new Effect.Move(c,{x:g,y:initialMoveY,duration:0.01,beforeSetup:function(a){a.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(b){new Effect.Parallel([new Effect.Opacity(b.element,{sync:true,to:1,from:0,transition:d.opacityTransition}),new Effect.Move(b.element,{x:h,y:moveY,sync:true,transition:d.moveTransition}),new Effect.Scale(b.element,100,{scaleMode:{originalHeight:f.height,originalWidth:f.width},sync:true,scaleFrom:window.opera?1:0,transition:d.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(a){a.effects[0].element.setStyle({height:"0px"}).show()},afterFinishInternal:function(a){a.effects[0].element.undoClipping().undoPositioned().setStyle(e)}},d))}})};Effect.Shrink=function(b){b=$(b);var c=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var d={top:b.style.top,left:b.style.left,height:b.style.height,width:b.style.width,opacity:b.getInlineOpacity()};var e=b.getDimensions();var f,moveY;switch(c.direction){case"top-left":f=moveY=0;break;case"top-right":f=e.width;moveY=0;break;case"bottom-left":f=0;moveY=e.height;break;case"bottom-right":f=e.width;moveY=e.height;break;case"center":f=e.width/2;moveY=e.height/2;break;default:}return new Effect.Parallel([new Effect.Opacity(b,{sync:true,to:0,from:1,transition:c.opacityTransition}),new Effect.Scale(b,window.opera?1:0,{sync:true,transition:c.scaleTransition,restoreAfterFinish:true}),new Effect.Move(b,{x:f,y:moveY,sync:true,transition:c.moveTransition})],Object.extend({beforeStartInternal:function(a){a.effects[0].element.makePositioned().makeClipping()},afterFinishInternal:function(a){a.effects[0].element.hide().undoClipping().undoPositioned().setStyle(d)}},c))};Effect.Pulsate=function(b){b=$(b);var c=arguments[1]||{};var d=b.getInlineOpacity();var e=c.transition||Effect.Transitions.sinoidal;var f=function(a){return e(1-Effect.Transitions.pulse(a,c.pulses))};f.bind(e);return new Effect.Opacity(b,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(a){a.element.setStyle({opacity:d})}},c),{transition:f}))};Effect.Fold=function(c){c=$(c);var d={top:c.style.top,left:c.style.left,width:c.style.width,height:c.style.height};c.makeClipping();return new Effect.Scale(c,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(b){new Effect.Scale(c,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(a){a.element.hide().undoClipping().setStyle(d)}})}},arguments[1]||{}))};Effect.Morph=Class.create();Object.extend(Object.extend(Effect.Morph.prototype,Effect.Base.prototype),{initialize:function(c){this.element=$(c);if(!this.element){throw Effect._elementDoesNotExistError;}var d=Object.extend({style:{}},arguments[1]||{});if(typeof d.style=="string"){if(d.style.indexOf(":")==-1){var e="",selector="."+d.style;$A(document.styleSheets).reverse().each(function(b){if(b.cssRules){cssRules=b.cssRules}else if(b.rules){cssRules=b.rules}$A(cssRules).reverse().each(function(a){if(selector==a.selectorText){e=a.style.cssText;throw $break;}});if(e){throw $break;}});this.style=e.parseStyle();d.afterFinishInternal=function(b){b.element.addClassName(b.options.style);b.transforms.each(function(a){if(a.style!="opacity"){b.element.style[a.style]=""}})}}else{this.style=d.style.parseStyle()}}else{this.style=$H(d.style)}this.start(d)},setup:function(){function parseColor(a){if(!a||["rgba(0, 0, 0, 0)","transparent"].include(a)){a="#ffffff"}a=a.parseColor();return $R(0,2).map(function(i){return parseInt(a.slice(i*2+1,i*2+3),16)})}this.transforms=this.style.map((function(a){var b=a[0],value=a[1],unit=null;if(value.parseColor("#zzzzzz")!="#zzzzzz"){value=value.parseColor();unit="color"}else if(b=="opacity"){value=parseFloat(value);if(Prototype.Browser.IE&&!this.element.currentStyle.hasLayout){this.element.setStyle({zoom:1})}}else if(Element.CSS_LENGTH.test(value)){var c=value.match(/^([\+\-]?[0-9\.]+)(.*)$/);value=parseFloat(c[1]);unit=c.length==3?c[2]:null}var d=this.element.getStyle(b);return{style:b.camelize(),originalValue:unit=="color"?parseColor(d):parseFloat(d||0),targetValue:unit=="color"?parseColor(value):value,unit:unit}}).bind(this)).reject(function(a){return a.originalValue==a.targetValue||a.unit!="color"&&(isNaN(a.originalValue)||isNaN(a.targetValue))})},update:function(a){var b={},transform,i=this.transforms.length;while(i--){b[(transform=this.transforms[i]).style]=transform.unit=="color"?"#"+Math.round(transform.originalValue[0]+(transform.targetValue[0]-transform.originalValue[0])*a).toColorPart()+Math.round(transform.originalValue[1]+(transform.targetValue[1]-transform.originalValue[1])*a).toColorPart()+Math.round(transform.originalValue[2]+(transform.targetValue[2]-transform.originalValue[2])*a).toColorPart():transform.originalValue+Math.round((transform.targetValue-transform.originalValue)*a*1000)/1000+transform.unit}this.element.setStyle(b,true)}});Effect.Transform=Class.create();Object.extend(Effect.Transform.prototype,{initialize:function(a){this.tracks=[];this.options=arguments[1]||{};this.addTracks(a)},addTracks:function(c){c.each((function(a){var b=$H(a).values().first();this.tracks.push($H({ids:$H(a).keys().first(),effect:Effect.Morph,options:{style:b}}))}).bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){var b=[$(a.ids)||$$(a.ids)].flatten();return b.map(function(e){return new a.effect(e,Object.extend({sync:true},a.options))})}).flatten(),this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.prototype.parseStyle=function(){var b=document.createElement("div");b.innerHTML="<div style=\""+this+"\"></div>";var c=b.childNodes[0].style,styleRules=$H();Element.CSS_PROPERTIES.each(function(a){if(c[a]){styleRules[a]=c[a]}});if(Prototype.Browser.IE&&this.indexOf("opacity")>-1){styleRules.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]}return styleRules};Element.morph=function(a,b){new Effect.Morph(a,Object.extend({style:b},arguments[2]||{}));return a};["getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","morph"].each(function(f){Element.Methods[f]=Element[f]});Element.Methods.visualEffect=function(a,b,c){s=b.dasherize().camelize();effect_class=s.charAt(0).toUpperCase()+s.substring(1);new Effect[effect_class](a,c);return $(a)};Element.addMethods();if(typeof Effect=="undefined"){throw"dragdrop.js requires including script.aculo.us' effects.js library";}var Droppables={drops:[],remove:function(a){this.drops=this.drops.reject(function(d){return d.element==$(a)})},add:function(a){a=$(a);var b=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(b.containment){b._containers=[];var d=b.containment;if(typeof d=="object"&&d.constructor==Array){d.each(function(c){b._containers.push($(c))})}else{b._containers.push($(d))}}if(b.accept){b.accept=[b.accept].flatten()}Element.makePositioned(a);b.element=a;this.drops.push(b)},findDeepestChild:function(a){deepest=a[0];for(i=1;i<a.length;++i){if(Element.isParent(a[i].element,deepest.element)){deepest=a[i]}}return deepest},isContained:function(a,b){var d;if(b.tree){d=a.treeNode}else{d=a.parentNode}return b._containers.detect(function(c){return d==c})},isAffected:function(a,b,c){return c.element!=b&&(!c._containers||this.isContained(b,c))&&(!c.accept||Element.classNames(b).detect(function(v){return c.accept.include(v)}))&&Position.within(c.element,a[0],a[1])},deactivate:function(a){if(a.hoverclass){Element.removeClassName(a.element,a.hoverclass)}this.last_active=null},activate:function(a){if(a.hoverclass){Element.addClassName(a.element,a.hoverclass)}this.last_active=a},show:function(b,c){if(!this.drops.length){return}var d=[];if(this.last_active){this.deactivate(this.last_active)}this.drops.each(function(a){if(Droppables.isAffected(b,c,a)){d.push(a)}});if(d.length>0){drop=Droppables.findDeepestChild(d);Position.within(drop.element,b[0],b[1]);if(drop.onHover){drop.onHover(c,drop.element,Position.overlap(drop.overlap,drop.element))}Droppables.activate(drop)}},fire:function(a,b){if(!this.last_active){return}Position.prepare();if(this.isAffected([Event.pointerX(a),Event.pointerY(a)],b,this.last_active)){if(this.last_active.onDrop){this.last_active.onDrop(b,this.last_active.element,a);return true}}},reset:function(){if(this.last_active){this.deactivate(this.last_active)}}};var Draggables={drags:[],observers:[],register:function(a){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(a)},unregister:function(a){this.drags=this.drags.reject(function(d){return d==a});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},activate:function(a){if(a.options.delay){this._timeout=setTimeout((function(){Draggables._timeout=null;window.focus();Draggables.activeDraggable=a}).bind(this),a.options.delay)}else{window.focus();this.activeDraggable=a}},deactivate:function(){this.activeDraggable=null},updateDrag:function(a){if(!this.activeDraggable){return}var b=[Event.pointerX(a),Event.pointerY(a)];if(this._lastPointer&&this._lastPointer.inspect()==b.inspect()){return}this._lastPointer=b;this.activeDraggable.updateDrag(a,b)},endDrag:function(a){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeDraggable){return}this._lastPointer=null;this.activeDraggable.endDrag(a);this.activeDraggable=null},keyPress:function(a){if(this.activeDraggable){this.activeDraggable.keyPress(a)}},addObserver:function(a){this.observers.push(a);this._cacheObserverCallbacks()},removeObserver:function(a){this.observers=this.observers.reject(function(o){return o.element==a});this._cacheObserverCallbacks()},notify:function(a,b,c){if(this[a+"Count"]>0){this.observers.each(function(o){if(o[a]){o[a](a,b,c)}})}if(b.options[a]){b.options[a](b,c)}},_cacheObserverCallbacks:function(){["onStart","onEnd","onDrag"].each(function(a){Draggables[a+"Count"]=Draggables.observers.select(function(o){return o[a]}).length})}};var Draggable=Class.create();Draggable._dragging={};Draggable.prototype={initialize:function(e){var f={handle:false,reverteffect:function(a,b,c){var d=Math.sqrt(Math.abs(b^2)+Math.abs(c^2))*0.02;new Effect.Move(a,{x:-c,y:-b,duration:d,queue:{scope:"_draggable",position:"end"}})},endeffect:function(a){var b=typeof a._opacity=="number"?a._opacity:1;new Effect.Opacity(a,{duration:0.2,from:0.7,to:b,queue:{scope:"_draggable",position:"end"},afterFinish:function(){Draggable._dragging[a]=false}})},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||typeof arguments[1].endeffect=="undefined"){Object.extend(f,{starteffect:function(a){a._opacity=Element.getOpacity(a);Draggable._dragging[a]=true;new Effect.Opacity(a,{duration:0.2,from:a._opacity,to:0.7})}})}var g=Object.extend(f,arguments[1]||{});this.element=$(e);if(g.handle&&typeof g.handle=="string"){this.handle=this.element.down("."+g.handle,0)}if(!this.handle){this.handle=$(g.handle)}if(!this.handle){this.handle=this.element}if(g.scroll&&!g.scroll.scrollTo&&!g.scroll.outerHTML){g.scroll=$(g.scroll);this._isScrollChild=Element.childOf(this.element,g.scroll)}Element.makePositioned(this.element);this.delta=this.currentDelta();this.options=g;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this)},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this)},currentDelta:function(){return[parseInt(Element.getStyle(this.element,"left")||"0"),parseInt(Element.getStyle(this.element,"top")||"0")]},initDrag:function(a){if(typeof Draggable._dragging[this.element]!="undefined"&&Draggable._dragging[this.element]){return}if(Event.isLeftClick(a)){var b=Event.element(a);if((tag_name=b.tagName.toUpperCase())&&(tag_name=="INPUT"||tag_name=="SELECT"||tag_name=="OPTION"||tag_name=="BUTTON"||tag_name=="TEXTAREA")){return}var c=[Event.pointerX(a),Event.pointerY(a)];var d=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(i){return c[i]-d[i]});Draggables.activate(this);Event.stop(a)}},startDrag:function(a){this.dragging=true;if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,"z-index")||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);Position.absolutize(this.element);this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.scroll){if(this.options.scroll==window){var b=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=b.left;this.originalScrollTop=b.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}Draggables.notify("onStart",this,a);if(this.options.starteffect){this.options.starteffect(this.element)}},updateDrag:function(a,b){if(!this.dragging){this.startDrag(a)}if(!this.options.quiet){Position.prepare();Droppables.show(b,this.element)}Draggables.notify("onDrag",this,a);this.draw(b);if(this.options.change){this.options.change(this)}if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)}var c=[0,0];if(b[0]<p[0]+this.options.scrollSensitivity){c[0]=b[0]-(p[0]+this.options.scrollSensitivity)}if(b[1]<p[1]+this.options.scrollSensitivity){c[1]=b[1]-(p[1]+this.options.scrollSensitivity)}if(b[0]>p[2]-this.options.scrollSensitivity){c[0]=b[0]-(p[2]-this.options.scrollSensitivity)}if(b[1]>p[3]-this.options.scrollSensitivity){c[1]=b[1]-(p[3]-this.options.scrollSensitivity)}this.startScrolling(c)}if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(a)},finishDrag:function(a,b){this.dragging=false;if(this.options.quiet){Position.prepare();var c=[Event.pointerX(a),Event.pointerY(a)];Droppables.show(c,this.element)}if(this.options.ghosting){Position.relativize(this.element);Element.remove(this._clone);this._clone=null}var e=false;if(b){e=Droppables.fire(a,this.element);if(!e){e=false}}if(e&&this.options.onDropped){this.options.onDropped(this.element)}Draggables.notify("onEnd",this,a);var f=this.options.revert;if(f&&typeof f=="function"){f=f(this.element)}var d=this.currentDelta();if(f&&this.options.reverteffect){if(e==0||f!="failure"){this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0])}}else{this.delta=d}if(this.options.zindex){this.element.style.zIndex=this.originalZ}if(this.options.endeffect){this.options.endeffect(this.element)}Draggables.deactivate(this);Droppables.reset()},keyPress:function(a){if(a.keyCode!=Event.KEY_ESC){return}this.finishDrag(a,false);Event.stop(a)},endDrag:function(a){if(!this.dragging){return}this.stopScrolling();this.finishDrag(a,true);Event.stop(a)},draw:function(a){var b=Position.cumulativeOffset(this.element);if(this.options.ghosting){var r=Position.realOffset(this.element);b[0]+=r[0]-Position.deltaX;b[1]+=r[1]-Position.deltaY}var d=this.currentDelta();b[0]-=d[0];b[1]-=d[1];if(this.options.scroll&&this.options.scroll!=window&&this._isScrollChild){b[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;b[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var p=[0,1].map((function(i){return a[i]-b[i]-this.offset[i]}).bind(this));if(this.options.snap){if(typeof this.options.snap=="function"){p=this.options.snap(p[0],p[1],this)}else{if(this.options.snap instanceof Array){p=p.map((function(v,i){return Math.round(v/this.options.snap[i])*this.options.snap[i]}).bind(this))}else{p=p.map((function(v){return Math.round(v/this.options.snap)*this.options.snap}).bind(this))}}}var c=this.element.style;if(!this.options.constraint||this.options.constraint=="horizontal"){c.left=p[0]+"px"}if(!this.options.constraint||this.options.constraint=="vertical"){c.top=p[1]+"px"}if(c.visibility=="hidden"){c.visibility=""}},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null}},startScrolling:function(a){if(!(a[0]||a[1])){return}this.scrollSpeed=[a[0]*this.options.scrollSpeed,a[1]*this.options.scrollSpeed];this.lastScrolled=new Date;this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var a=new Date;var b=a-this.lastScrolled;this.lastScrolled=a;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=b/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*b/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*b/1000}Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify("onDrag",this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*b/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*b/1000;if(Draggables._lastScrollPointer[0]<0){Draggables._lastScrollPointer[0]=0}if(Draggables._lastScrollPointer[1]<0){Draggables._lastScrollPointer[1]=0}this.draw(Draggables._lastScrollPointer)}if(this.options.change){this.options.change(this)}},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else if(w.document.body){T=body.scrollTop;L=body.scrollLeft}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}return{top:T,left:L,width:W,height:H}}};var SortableObserver=Class.create();SortableObserver.prototype={initialize:function(a,b){this.element=$(a);this.observer=b;this.lastValue=Sortable.serialize(this.element)},onStart:function(){this.lastValue=Sortable.serialize(this.element)},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element)){this.observer(this.element)}}};var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(a){while(a.tagName.toUpperCase()!="BODY"){if(a.id&&Sortable.sortables[a.id]){return a}a=a.parentNode}},options:function(a){a=Sortable._findRootElement($(a));if(!a){return}return Sortable.sortables[a.id]},destroy:function(a){var s=Sortable.options(a);if(s){Draggables.removeObserver(s.element);s.droppables.each(function(d){Droppables.remove(d)});s.draggables.invoke("destroy");delete Sortable.sortables[s.element.id]}},create:function(b){b=$(b);var c=Object.extend({element:b,tag:"li",dropOnEmpty:false,tree:false,treeTag:"ul",overlap:"vertical",constraint:"vertical",containment:b,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});this.destroy(b);var d={revert:true,quiet:c.quiet,scroll:c.scroll,scrollSpeed:c.scrollSpeed,scrollSensitivity:c.scrollSensitivity,delay:c.delay,ghosting:c.ghosting,constraint:c.constraint,handle:c.handle};if(c.starteffect){d.starteffect=c.starteffect}if(c.reverteffect){d.reverteffect=c.reverteffect}else if(c.ghosting){d.reverteffect=function(a){a.style.top=0;a.style.left=0}}if(c.endeffect){d.endeffect=c.endeffect}if(c.zindex){d.zindex=c.zindex}var f={overlap:c.overlap,containment:c.containment,tree:c.tree,hoverclass:c.hoverclass,onHover:Sortable.onHover};var g={onHover:Sortable.onEmptyHover,overlap:c.overlap,containment:c.containment,hoverclass:c.hoverclass};Element.cleanWhitespace(b);c.draggables=[];c.droppables=[];if(c.dropOnEmpty||c.tree){Droppables.add(b,g);c.droppables.push(b)}(c.elements||this.findElements(b,c)||[]).each(function(e,i){var a=c.handles?$(c.handles[i]):c.handle?$(e).getElementsByClassName(c.handle)[0]:e;c.draggables.push(new Draggable(e,Object.extend(d,{handle:a})));Droppables.add(e,f);if(c.tree){e.treeNode=b}c.droppables.push(e)});if(c.tree){(Sortable.findTreeElements(b,c)||[]).each(function(e){Droppables.add(e,g);e.treeNode=b;c.droppables.push(e)})}this.sortables[b.id]=c;Draggables.addObserver(new SortableObserver(b,c.onUpdate))},findElements:function(a,b){return Element.findChildren(a,b.only,b.tree?true:false,b.tag)},findTreeElements:function(a,b){return Element.findChildren(a,b.only,b.tree?true:false,b.treeTag)},onHover:function(a,b,c){if(Element.isParent(b,a)){return}if(c>0.33&&c<0.66&&Sortable.options(b).tree){return}else if(c>0.5){Sortable.mark(b,"before");if(b.previousSibling!=a){var d=a.parentNode;a.style.visibility="hidden";b.parentNode.insertBefore(a,b);if(b.parentNode!=d){Sortable.options(d).onChange(a)}Sortable.options(b.parentNode).onChange(a)}}else{Sortable.mark(b,"after");var e=b.nextSibling||null;if(e!=a){var d=a.parentNode;a.style.visibility="hidden";b.parentNode.insertBefore(a,e);if(b.parentNode!=d){Sortable.options(d).onChange(a)}Sortable.options(b.parentNode).onChange(a)}}},onEmptyHover:function(a,b,c){var d=a.parentNode;var e=Sortable.options(b);if(!Element.isParent(b,a)){var f;var g=Sortable.findElements(b,{tag:e.tag,only:e.only});var h=null;if(g){var i=Element.offsetSize(b,e.overlap)*(1-c);for(f=0;f<g.length;f+=1){if(i-Element.offsetSize(g[f],e.overlap)>=0){i-=Element.offsetSize(g[f],e.overlap)}else if(i-Element.offsetSize(g[f],e.overlap)/2>=0){h=f+1<g.length?g[f+1]:null;break}else{h=g[f];break}}}b.insertBefore(a,h);Sortable.options(d).onChange(a);e.onChange(a)}},unmark:function(){if(Sortable._marker){Sortable._marker.hide()}},mark:function(a,b){var c=Sortable.options(a.parentNode);if(c&&!c.ghosting){return}if(!Sortable._marker){Sortable._marker=($("dropmarker")||Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)}var d=Position.cumulativeOffset(a);Sortable._marker.setStyle({left:d[0]+"px",top:d[1]+"px"});if(b=="after"){if(c.overlap=="horizontal"){Sortable._marker.setStyle({left:d[0]+a.clientWidth+"px"})}else{Sortable._marker.setStyle({top:d[1]+a.clientHeight+"px"})}}Sortable._marker.show()},_tree:function(a,b,c){var d=Sortable.findElements(a,b)||[];for(var i=0;i<d.length;++i){var e=d[i].id.match(b.format);if(!e){continue}var f={id:encodeURIComponent(e?e[1]:null),element:a,parent:c,children:[],position:c.children.length,container:$(d[i]).down(b.treeTag)};if(f.container){this._tree(f.container,b,f)}c.children.push(f)}return c},tree:function(a){a=$(a);var b=this.options(a);var c=Object.extend({tag:b.tag,treeTag:b.treeTag,only:b.only,name:a.id,format:b.format},arguments[1]||{});var d={id:null,parent:null,children:[],container:a,position:0};return Sortable._tree(a,c,d)},_constructIndex:function(a){var b="";do{if(a.id){b="["+a.position+"]"+b}}while((a=a.parent)!=null);return b},sequence:function(b){b=$(b);var c=Object.extend(this.options(b),arguments[1]||{});return $(this.findElements(b,c)||[]).map(function(a){return a.id.match(c.format)?a.id.match(c.format)[1]:""})},setSequence:function(b,c){b=$(b);var d=Object.extend(this.options(b),arguments[2]||{});var e={};this.findElements(b,d).each(function(n){if(n.id.match(d.format)){e[n.id.match(d.format)[1]]=[n,n.parentNode]}n.parentNode.removeChild(n)});c.each(function(a){var n=e[a];if(n){n[1].appendChild(n[0]);delete e[a]}})},serialize:function(b){b=$(b);var c=Object.extend(Sortable.options(b),arguments[1]||{});var d=encodeURIComponent(arguments[1]&&arguments[1].name?arguments[1].name:b.id);if(c.tree){return Sortable.tree(b,arguments[1]).children.map(function(a){return[d+Sortable._constructIndex(a)+"[id]="+encodeURIComponent(a.id)].concat(a.children.map(arguments.callee))}).flatten().join("&")}else{return Sortable.sequence(b,arguments[1]).map(function(a){return d+"[]="+encodeURIComponent(a)}).join("&")}}};Element.isParent=function(a,b){if(!a.parentNode||a==b){return false}if(a.parentNode==b){return true}return Element.isParent(a.parentNode,b)};Element.findChildren=function(b,c,d,f){if(!b.hasChildNodes()){return null}f=f.toUpperCase();if(c){c=[c].flatten()}var g=[];$A(b.childNodes).each(function(e){if(e.tagName&&e.tagName.toUpperCase()==f&&(!c||Element.classNames(e).detect(function(v){return c.include(v)}))){g.push(e)}if(d){var a=Element.findChildren(e,c,d,f);if(a){g.push(a)}}});return g.length>0?g.flatten():[]};Element.offsetSize=function(a,b){return a["offset"+(b=="vertical"||b=="height"?"Height":"Width")]};if(typeof Effect=="undefined"){throw"controls.js requires including script.aculo.us' effects.js library";}var Autocompleter={};Autocompleter.Base=function(){};Autocompleter.Base.prototype={baseInitialize:function(c,d,e){c=$(c);this.element=c;this.update=$(d);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;if(this.setOptions){this.setOptions(e)}else{this.options=e||{}}this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(a,b){if(!b.style.position||b.style.position=="absolute"){b.style.position="absolute";Position.clone(a,b,{setHeight:false,offsetTop:a.offsetHeight})}Effect.Appear(b,{duration:0.15})};this.options.onHide=this.options.onHide||function(a,b){new Effect.Fade(b,{duration:0.15})};if(typeof this.options.tokens=="string"){this.options.tokens=new Array(this.options.tokens)}this.observer=null;this.element.setAttribute("autocomplete","off");Element.hide(this.update);Event.observe(this.element,"blur",this.onBlur.bindAsEventListener(this));Event.observe(this.element,"keypress",this.onKeyPress.bindAsEventListener(this));Event.observe(window,"beforeunload",function(){c.setAttribute("autocomplete","on")})},show:function(){if(Element.getStyle(this.update,"display")=="none"){this.options.onShow(this.element,this.update)}if(!this.iefix&&Prototype.Browser.IE&&Element.getStyle(this.update,"position")=="absolute"){new Insertion.After(this.update,"<iframe id=\""+this.update.id+"_iefix\" "+"style=\"display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);\" "+"src=\"javascript:false;\" frameborder=\"0\" scrolling=\"no\"></iframe>");this.iefix=$(this.update.id+"_iefix")}if(this.iefix){setTimeout(this.fixIEOverlapping.bind(this),50)}},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:!this.update.style.height});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix)},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,"display")!="none"){this.options.onHide(this.element,this.update)}if(this.iefix){Element.hide(this.iefix)}},startIndicator:function(){if(this.options.indicator){Element.show(this.options.indicator)}},stopIndicator:function(){if(this.options.indicator){Element.hide(this.options.indicator)}},onKeyPress:function(a){if(this.active){switch(a.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(a);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(a);return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:this.markPrevious();this.render();if(Prototype.Browser.WebKit){Event.stop(a)}return;case Event.KEY_DOWN:this.markNext();this.render();if(Prototype.Browser.WebKit){Event.stop(a)}return;default:}}else if(a.keyCode==Event.KEY_TAB||a.keyCode==Event.KEY_RETURN||Prototype.Browser.WebKit>0&&a.keyCode==0){return}this.changed=true;this.hasFocus=true;if(this.observer){clearTimeout(this.observer)}this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000)},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices()},onHover:function(a){var b=Event.findElement(a,"LI");if(this.index!=b.autocompleteIndex){this.index=b.autocompleteIndex;this.render()}Event.stop(a)},onClick:function(a){var b=Event.findElement(a,"LI");this.index=b.autocompleteIndex;this.selectEntry();this.hide()},onBlur:function(a){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false},render:function(){if(this.entryCount>0){for(var i=0;i<this.entryCount;i++){this.index==i?Element.addClassName(this.getEntry(i),"selected"):Element.removeClassName(this.getEntry(i),"selected")}if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index>0){this.index--}else{this.index=this.entryCount-1}this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1){this.index++}else{this.index=0}this.getEntry(this.index).scrollIntoView(false)},getEntry:function(a){return this.update.firstChild.childNodes[a]},getCurrentEntry:function(){return this.getEntry(this.index)},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry())},updateElement:function(a){if(this.options.updateElement){this.options.updateElement(a);return}var b="";if(this.options.select){var c=document.getElementsByClassName(this.options.select,a)||[];if(c.length>0){b=Element.collectTextNodes(c[0],this.options.select)}}else{b=Element.collectTextNodesIgnoreClass(a,"informal")}var d=this.findLastToken();if(d!=-1){var e=this.element.value.substr(0,d+1);var f=this.element.value.substr(d+1).match(/^\s+/);if(f){e+=f[0]}this.element.value=e+b}else{this.element.value=b}this.element.focus();if(this.options.afterUpdateElement){this.options.afterUpdateElement(this.element,a)}},updateChoices:function(a){if(!this.changed&&this.hasFocus){this.update.innerHTML=a;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var i=0;i<this.entryCount;i++){var b=this.getEntry(i);b.autocompleteIndex=i;this.addObservers(b)}}else{this.entryCount=0}this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide()}else{this.render()}}},addObservers:function(a){Event.observe(a,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(a,"click",this.onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}},getToken:function(){var a=this.findLastToken();if(a!=-1){var b=this.element.value.substr(a+1).replace(/^\s+/,"").replace(/\s+$/,"")}else{var b=this.element.value}return/\n/.test(b)?"":b},findLastToken:function(){var a=-1;for(var i=0;i<this.options.tokens.length;i++){var b=this.element.value.lastIndexOf(this.options.tokens[i]);if(b>a){a=b}}return a}};Ajax.Autocompleter=Class.create();Object.extend(Object.extend(Ajax.Autocompleter.prototype,Autocompleter.Base.prototype),{initialize:function(a,b,c,d){this.baseInitialize(a,b,d);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=c},getUpdatedChoices:function(){this.startIndicator();var a=encodeURIComponent(this.options.paramName)+"="+encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,a):a;if(this.options.defaultParams){this.options.parameters+="&"+this.options.defaultParams}new Ajax.Request(this.url,this.options)},onComplete:function(a){this.updateChoices(a.responseText)}});Autocompleter.Local=Class.create();Autocompleter.Local.prototype=Object.extend(new Autocompleter.Base,{initialize:function(a,b,c,d){this.baseInitialize(a,b,d);this.options.array=c},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this))},setOptions:function(h){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(a){var b=[];var c=[];var d=a.getToken();var e=0;for(var i=0;i<a.options.array.length&&b.length<a.options.choices;i++){var f=a.options.array[i];var g=a.options.ignoreCase?f.toLowerCase().indexOf(d.toLowerCase()):f.indexOf(d);while(g!=-1){if(g==0&&f.length!=d.length){b.push("<li><strong>"+f.substr(0,d.length)+"</strong>"+f.substr(d.length)+"</li>");break}else if(d.length>=a.options.partialChars&&a.options.partialSearch&&g!=-1){if(a.options.fullSearch||/\s/.test(f.substr(g-1,1))){c.push("<li>"+f.substr(0,g)+"<strong>"+f.substr(g,d.length)+"</strong>"+f.substr(g+d.length)+"</li>");break}}g=a.options.ignoreCase?f.toLowerCase().indexOf(d.toLowerCase(),g+1):f.indexOf(d,g+1)}}if(c.length){b=b.concat(c.slice(0,a.options.choices-b.length))}return"<ul>"+b.join("")+"</ul>"}},h||{})}});Field.scrollFreeActivate=function(a){setTimeout(function(){Field.activate(a)},1)};Ajax.InPlaceEditor=Class.create();Ajax.InPlaceEditor.defaultHighlightColor="#FFFF99";Ajax.InPlaceEditor.prototype={initialize:function(c,d,e){this.url=d;this.element=$(c);this.options=Object.extend({paramName:"value",okButton:true,okLink:false,okText:"ok",cancelButton:false,cancelLink:true,cancelText:"cancel",textBeforeControls:"",textBetweenControls:"",textAfterControls:"",savingText:"Saving...",clickToEditText:"Click to edit",okText:"ok",rows:1,onComplete:function(a,b){new Effect.Highlight(b,{startcolor:this.options.highlightcolor})},onFailure:function(a){alert("Error communicating with the server: "+a.responseText.stripTags())},callback:function(a){return Form.serialize(a)},handleLineBreaks:true,loadingText:"Loading...",savingClassName:"inplaceeditor-saving",loadingClassName:"inplaceeditor-loading",formClassName:"inplaceeditor-form",highlightcolor:Ajax.InPlaceEditor.defaultHighlightColor,highlightendcolor:"#FFFFFF",externalControl:null,submitOnBlur:false,ajaxOptions:{},evalScripts:false},e||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+"-inplaceeditor";if($(this.options.formId)){this.options.formId=null}}if(this.options.externalControl){this.options.externalControl=$(this.options.externalControl)}this.originalBackground=Element.getStyle(this.element,"background-color");if(!this.originalBackground){this.originalBackground="transparent"}this.element.title=this.options.clickToEditText;this.onclickListener=this.enterEditMode.bindAsEventListener(this);this.mouseoverListener=this.enterHover.bindAsEventListener(this);this.mouseoutListener=this.leaveHover.bindAsEventListener(this);Event.observe(this.element,"click",this.onclickListener);Event.observe(this.element,"mouseover",this.mouseoverListener);Event.observe(this.element,"mouseout",this.mouseoutListener);if(this.options.externalControl){Event.observe(this.options.externalControl,"click",this.onclickListener);Event.observe(this.options.externalControl,"mouseover",this.mouseoverListener);Event.observe(this.options.externalControl,"mouseout",this.mouseoutListener)}},enterEditMode:function(a){if(this.saving){return}if(this.editing){return}this.editing=true;this.onEnterEditMode();if(this.options.externalControl){Element.hide(this.options.externalControl)}Element.hide(this.element);this.createForm();this.element.parentNode.insertBefore(this.form,this.element);if(!this.options.loadTextURL){Field.scrollFreeActivate(this.editField)}if(a){Event.stop(a)}return false},createForm:function(){this.form=document.createElement("form");this.form.id=this.options.formId;Element.addClassName(this.form,this.options.formClassName);this.form.onsubmit=this.onSubmit.bind(this);this.createEditField();if(this.options.textarea){var a=document.createElement("br");this.form.appendChild(a)}if(this.options.textBeforeControls){this.form.appendChild(document.createTextNode(this.options.textBeforeControls))}if(this.options.okButton){var b=document.createElement("input");b.type="submit";b.value=this.options.okText;b.className="editor_ok_button";this.form.appendChild(b)}if(this.options.okLink){var c=document.createElement("a");c.href="#";c.appendChild(document.createTextNode(this.options.okText));c.onclick=this.onSubmit.bind(this);c.className="editor_ok_link";this.form.appendChild(c)}if(this.options.textBetweenControls&&(this.options.okLink||this.options.okButton)&&(this.options.cancelLink||this.options.cancelButton)){this.form.appendChild(document.createTextNode(this.options.textBetweenControls))}if(this.options.cancelButton){var d=document.createElement("input");d.type="submit";d.value=this.options.cancelText;d.onclick=this.onclickCancel.bind(this);d.className="editor_cancel_button";this.form.appendChild(d)}if(this.options.cancelLink){var e=document.createElement("a");e.href="#";e.appendChild(document.createTextNode(this.options.cancelText));e.onclick=this.onclickCancel.bind(this);e.className="editor_cancel editor_cancel_link";this.form.appendChild(e)}if(this.options.textAfterControls){this.form.appendChild(document.createTextNode(this.options.textAfterControls))}},hasHTMLLineBreaks:function(a){if(!this.options.handleLineBreaks){return false}return a.match(/<br/i)||a.match(/<p>/i)},convertHTMLLineBreaks:function(a){return a.replace(/<br>/gi,"\n").replace(/<br\/>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<p>/gi,"")},createEditField:function(){var a;if(this.options.loadTextURL){a=this.options.loadingText}else{a=this.getText()}var b=this;if(this.options.rows==1&&!this.hasHTMLLineBreaks(a)){this.options.textarea=false;var c=document.createElement("input");c.obj=this;c.type="text";c.name=this.options.paramName;c.value=a;c.style.backgroundColor=this.options.highlightcolor;c.className="editor_field";var d=this.options.size||this.options.cols||0;if(d!=0){c.size=d}if(this.options.submitOnBlur){c.onblur=this.onSubmit.bind(this)}this.editField=c}else{this.options.textarea=true;var e=document.createElement("textarea");e.obj=this;e.name=this.options.paramName;e.value=this.convertHTMLLineBreaks(a);e.rows=this.options.rows;e.cols=this.options.cols||40;e.className="editor_field";if(this.options.submitOnBlur){e.onblur=this.onSubmit.bind(this)}this.editField=e}if(this.options.loadTextURL){this.loadExternalText()}this.form.appendChild(this.editField)},getText:function(){return this.element.innerHTML},loadExternalText:function(){Element.addClassName(this.form,this.options.loadingClassName);this.editField.disabled=true;new Ajax.Request(this.options.loadTextURL,Object.extend({asynchronous:true,onComplete:this.onLoadedExternalText.bind(this)},this.options.ajaxOptions))},onLoadedExternalText:function(a){Element.removeClassName(this.form,this.options.loadingClassName);this.editField.disabled=false;this.editField.value=a.responseText.stripTags();Field.scrollFreeActivate(this.editField)},onclickCancel:function(){this.onComplete();this.leaveEditMode();return false},onFailure:function(a){this.options.onFailure(a);if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML;this.oldInnerHTML=null}return false},onSubmit:function(){var a=this.form;var b=this.editField.value;this.onLoading();if(this.options.evalScripts){new Ajax.Request(this.url,Object.extend({parameters:this.options.callback(a,b),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this),asynchronous:true,evalScripts:true},this.options.ajaxOptions))}else{new Ajax.Updater({success:this.element,failure:null},this.url,Object.extend({parameters:this.options.callback(a,b),onComplete:this.onComplete.bind(this),onFailure:this.onFailure.bind(this)},this.options.ajaxOptions))}if(arguments.length>1){Event.stop(arguments[0])}return false},onLoading:function(){this.saving=true;this.removeForm();this.leaveHover();this.showSaving()},showSaving:function(){this.oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;Element.addClassName(this.element,this.options.savingClassName);this.element.style.backgroundColor=this.originalBackground;Element.show(this.element)},removeForm:function(){if(this.form){if(this.form.parentNode){Element.remove(this.form)}this.form=null}},enterHover:function(){if(this.saving){return}this.element.style.backgroundColor=this.options.highlightcolor;if(this.effect){this.effect.cancel()}Element.addClassName(this.element,this.options.hoverClassName)},leaveHover:function(){if(this.options.backgroundColor){this.element.style.backgroundColor=this.oldBackground}Element.removeClassName(this.element,this.options.hoverClassName);if(this.saving){return}this.effect=new Effect.Highlight(this.element,{startcolor:this.options.highlightcolor,endcolor:this.options.highlightendcolor,restorecolor:this.originalBackground})},leaveEditMode:function(){Element.removeClassName(this.element,this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this.originalBackground;Element.show(this.element);if(this.options.externalControl){Element.show(this.options.externalControl)}this.editing=false;this.saving=false;this.oldInnerHTML=null;this.onLeaveEditMode()},onComplete:function(a){this.leaveEditMode();this.options.onComplete.bind(this)(a,this.element)},onEnterEditMode:function(){},onLeaveEditMode:function(){},dispose:function(){if(this.oldInnerHTML){this.element.innerHTML=this.oldInnerHTML}this.leaveEditMode();Event.stopObserving(this.element,"click",this.onclickListener);Event.stopObserving(this.element,"mouseover",this.mouseoverListener);Event.stopObserving(this.element,"mouseout",this.mouseoutListener);if(this.options.externalControl){Event.stopObserving(this.options.externalControl,"click",this.onclickListener);Event.stopObserving(this.options.externalControl,"mouseover",this.mouseoverListener);Event.stopObserving(this.options.externalControl,"mouseout",this.mouseoutListener)}}};Ajax.InPlaceCollectionEditor=Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype,Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype,{createEditField:function(){if(!this.cached_selectTag){var c=document.createElement("select");var d=this.options.collection||[];var f;d.each((function(e,i){f=document.createElement("option");f.value=e instanceof Array?e[0]:e;if(typeof this.options.value=="undefined"&&(e instanceof Array?this.element.innerHTML==e[1]:e==f.value)){f.selected=true}if(this.options.value==f.value){f.selected=true}f.appendChild(document.createTextNode(e instanceof Array?e[1]:e));c.appendChild(f)}).bind(this));this.cached_selectTag=c}this.editField=this.cached_selectTag;if(this.options.loadTextURL){this.loadExternalText()}this.form.appendChild(this.editField);this.options.callback=function(a,b){return"value="+encodeURIComponent(b)}}});Form.Element.DelayedObserver=Class.create();Form.Element.DelayedObserver.prototype={initialize:function(a,b,c){this.delay=b||0.5;this.element=$(a);this.callback=c;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,"keyup",this.delayedListener.bindAsEventListener(this))},delayedListener:function(a){if(this.lastValue==$F(this.element)){return}if(this.timer){clearTimeout(this.timer)}this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element)},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element))}};if(!Control){var Control={}}Control.Slider=Class.create();Control.Slider.prototype={initialize:function(a,b,c){var d=this;if(a instanceof Array){this.handles=a.collect(function(e){return $(e)})}else{this.handles=[$(a)]}this.track=$(b);this.options=c||{};this.axis=this.options.axis||"horizontal";this.increment=this.options.increment||1;this.step=parseInt(this.options.step||"1");this.range=this.options.range||$R(0,1);this.value=0;this.values=this.handles.map(function(){return 0});this.spans=this.options.spans?this.options.spans.map(function(s){return $(s)}):false;this.options.startSpan=$(this.options.startSpan||null);this.options.endSpan=$(this.options.endSpan||null);this.restricted=this.options.restricted||false;this.maximum=this.options.maximum||this.range.end;this.minimum=this.options.minimum||this.range.start;this.alignX=parseInt(this.options.alignX||"0");this.alignY=parseInt(this.options.alignY||"0");this.trackLength=this.maximumOffset()-this.minimumOffset();this.handleLength=this.isVertical()?this.handles[0].offsetHeight!=0?this.handles[0].offsetHeight:this.handles[0].style.height.replace(/px$/,""):this.handles[0].offsetWidth!=0?this.handles[0].offsetWidth:this.handles[0].style.width.replace(/px$/,"");this.active=false;this.dragging=false;this.disabled=false;if(this.options.disabled){this.setDisabled()}this.allowedValues=this.options.values?this.options.values.sortBy(Prototype.K):false;if(this.allowedValues){this.minimum=this.allowedValues.min();this.maximum=this.allowedValues.max()}this.eventMouseDown=this.startDrag.bindAsEventListener(this);this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.update.bindAsEventListener(this);this.handles.each(function(h,i){i=d.handles.length-1-i;d.setValue(parseFloat((d.options.sliderValue instanceof Array?d.options.sliderValue[i]:d.options.sliderValue)||d.range.start),i);Element.makePositioned(h);Event.observe(h,"mousedown",d.eventMouseDown)});Event.observe(this.track,"mousedown",this.eventMouseDown);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);this.initialized=true},dispose:function(){var a=this;Event.stopObserving(this.track,"mousedown",this.eventMouseDown);Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);this.handles.each(function(h){Event.stopObserving(h,"mousedown",a.eventMouseDown)})},setDisabled:function(){this.disabled=true},setEnabled:function(){this.disabled=false},getNearestValue:function(b){if(this.allowedValues){if(b>=this.allowedValues.max()){return this.allowedValues.max()}if(b<=this.allowedValues.min()){return this.allowedValues.min()}var c=Math.abs(this.allowedValues[0]-b);var d=this.allowedValues[0];this.allowedValues.each(function(v){var a=Math.abs(v-b);if(a<=c){d=v;c=a}});return d}if(b>this.range.end){return this.range.end}if(b<this.range.start){return this.range.start}return b},setValue:function(a,b){if(!this.active){this.activeHandleIdx=b||0;this.activeHandle=this.handles[this.activeHandleIdx];this.updateStyles()}b=b||this.activeHandleIdx||0;if(this.initialized&&this.restricted){if(b>0&&a<this.values[b-1]){a=this.values[b-1]}if(b<this.handles.length-1&&a>this.values[b+1]){a=this.values[b+1]}}a=this.getNearestValue(a);this.values[b]=a;this.value=this.values[0];this.handles[b].style[this.isVertical()?"top":"left"]=this.translateToPx(a);this.drawSpans();if(!this.dragging||!this.event){this.updateFinished()}},setValueBy:function(a,b){this.setValue(this.values[b||this.activeHandleIdx||0]+a,b||this.activeHandleIdx||0)},translateToPx:function(a){return Math.round((this.trackLength-this.handleLength)/(this.range.end-this.range.start)*(a-this.range.start))+"px"},translateToValue:function(a){return a/(this.trackLength-this.handleLength)*(this.range.end-this.range.start)+this.range.start},getRange:function(a){var v=this.values.sortBy(Prototype.K);a=a||0;return $R(v[a],v[a+1])},minimumOffset:function(){return this.isVertical()?this.alignY:this.alignX},maximumOffset:function(){return this.isVertical()?(this.track.offsetHeight!=0?this.track.offsetHeight:this.track.style.height.replace(/px$/,""))-this.alignY:(this.track.offsetWidth!=0?this.track.offsetWidth:this.track.style.width.replace(/px$/,""))-this.alignY},isVertical:function(){return this.axis=="vertical"},drawSpans:function(){var a=this;if(this.spans){$R(0,this.spans.length-1).each(function(r){a.setSpan(a.spans[r],a.getRange(r))})}if(this.options.startSpan){this.setSpan(this.options.startSpan,$R(0,this.values.length>1?this.getRange(0).min():this.value))}if(this.options.endSpan){this.setSpan(this.options.endSpan,$R(this.values.length>1?this.getRange(this.spans.length-1).max():this.value,this.maximum))}},setSpan:function(a,b){if(this.isVertical()){a.style.top=this.translateToPx(b.start);a.style.height=this.translateToPx(b.end-b.start+this.range.start)}else{a.style.left=this.translateToPx(b.start);a.style.width=this.translateToPx(b.end-b.start+this.range.start)}},updateStyles:function(){this.handles.each(function(h){Element.removeClassName(h,"selected")});Element.addClassName(this.activeHandle,"selected")},startDrag:function(a){if(Event.isLeftClick(a)){if(!this.disabled){this.active=true;var b=Event.element(a);var c=[Event.pointerX(a),Event.pointerY(a)];var d=b;if(d==this.track){var e=Position.cumulativeOffset(this.track);this.event=a;this.setValue(this.translateToValue((this.isVertical()?c[1]-e[1]:c[0]-e[0])-this.handleLength/2));var e=Position.cumulativeOffset(this.activeHandle);this.offsetX=c[0]-e[0];this.offsetY=c[1]-e[1]}else{while(this.handles.indexOf(b)==-1&&b.parentNode){b=b.parentNode}if(this.handles.indexOf(b)!=-1){this.activeHandle=b;this.activeHandleIdx=this.handles.indexOf(this.activeHandle);this.updateStyles();var e=Position.cumulativeOffset(this.activeHandle);this.offsetX=c[0]-e[0];this.offsetY=c[1]-e[1]}}}Event.stop(a)}},update:function(a){if(this.active){if(!this.dragging){this.dragging=true}this.draw(a);if(Prototype.Browser.WebKit){window.scrollBy(0,0)}Event.stop(a)}},draw:function(a){var b=[Event.pointerX(a),Event.pointerY(a)];var c=Position.cumulativeOffset(this.track);b[0]-=this.offsetX+c[0];b[1]-=this.offsetY+c[1];this.event=a;this.setValue(this.translateToValue(this.isVertical()?b[1]:b[0]));if(this.initialized&&this.options.onSlide){this.options.onSlide(this.values.length>1?this.values:this.value,this)}},endDrag:function(a){if(this.active&&this.dragging){this.finishDrag(a,true);Event.stop(a)}this.active=false;this.dragging=false},finishDrag:function(a,b){this.active=false;this.dragging=false;this.updateFinished()},updateFinished:function(){if(this.initialized&&this.options.onChange){this.options.onChange(this.values.length>1?this.values:this.value,this)}this.event=null}};Sound={tracks:{},_enabled:true,template:new Template("<embed style=\"height:0\" id=\"sound_#{track}_#{id}\" src=\"#{url}\" loop=\"false\" autostart=\"true\" hidden=\"true\"/>"),enable:function(){Sound._enabled=true},disable:function(){Sound._enabled=false},play:function(c){if(!Sound._enabled){return}var d=Object.extend({track:"global",url:c,replace:false},arguments[1]||{});if(d.replace&&this.tracks[d.track]){$R(0,this.tracks[d.track].id).each(function(a){var b=$("sound_"+d.track+"_"+a);b.Stop&&b.Stop();b.remove()});this.tracks[d.track]=null}if(!this.tracks[d.track]){this.tracks[d.track]={id:0}}else{this.tracks[d.track].id++}d.id=this.tracks[d.track].id;if(Prototype.Browser.IE){var e=document.createElement("bgsound");e.setAttribute("id","sound_"+d.track+"_"+d.id);e.setAttribute("src",d.url);e.setAttribute("loop","1");e.setAttribute("autostart","true");$$("body")[0].appendChild(e)}else{new Insertion.Bottom($$("body")[0],Sound.template.evaluate(d))}}};if(Prototype.Browser.Gecko&&navigator.userAgent.indexOf("Win")>0){if(navigator.plugins&&$A(navigator.plugins).detect(function(p){return p.name.indexOf("QuickTime")!=-1})){Sound.template=new Template("<object id=\"sound_#{track}_#{id}\" width=\"0\" height=\"0\" type=\"audio/mpeg\" data=\"#{url}\"/>")}else{Sound.play=function(){}}}var Builder = {NODEMAP:{AREA:"map", CAPTION:"table", COL:"table", COLGROUP:"table", LEGEND:"fieldset", OPTGROUP:"select", OPTION:"select", PARAM:"object", TBODY:"table", TD:"table", TFOOT:"table", TH:"table", THEAD:"table", TR:"table"}, node:function (elementName) {elementName = elementName.toUpperCase();var parentTag = this.NODEMAP[elementName] || "div";var parentElement = document.createElement(parentTag);try {parentElement.innerHTML = "<" + elementName + "></" + elementName + ">";} catch (e) {}var element = parentElement.firstChild || null;if (element && element.tagName.toUpperCase() != elementName) {element = element.getElementsByTagName(elementName)[0];}if (!element) {element = document.createElement(elementName);}if (!element) {return;}if (arguments[1]) {if (this._isStringOrNumber(arguments[1]) || arguments[1] instanceof Array || arguments[1].tagName) {this._children(element, arguments[1]);} else {var attrs = this._attributes(arguments[1]);if (attrs.length) {try {parentElement.innerHTML = "<" + elementName + " " + attrs + "></" + elementName + ">";} catch (e) {}element = parentElement.firstChild || null;if (!element) {element = document.createElement(elementName);for (attr in arguments[1]) {element[attr == "class" ? "className" : attr] = arguments[1][attr];}}if (element.tagName.toUpperCase() != elementName) {element = parentElement.getElementsByTagName(elementName)[0];}}}}if (arguments[2]) {this._children(element, arguments[2]);}return element;}, _text:function (text) {return document.createTextNode(text);}, ATTR_MAP:{className:"class", htmlFor:"for"}, _attributes:function (attributes) {var attrs = [];for (attribute in attributes) {attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + "=\"" + attributes[attribute].toString().escapeHTML().gsub(/"/, "&quot;") + "\"");}return attrs.join(" ");}, _children:function (element, children) {if (children.tagName) {element.appendChild(children);return;}if (typeof children == "object") {children.flatten().each(function (e) {if (typeof e == "object") {element.appendChild(e);} else if (Builder._isStringOrNumber(e)) {element.appendChild(Builder._text(e));}});} else if (Builder._isStringOrNumber(children)) {element.appendChild(Builder._text(children));}}, _isStringOrNumber:function (param) {return typeof param == "string" || typeof param == "number";}, build:function (html) {var element = this.node("div");$(element).update(html.strip());return element.down();}, dump:function (scope) {if (typeof scope != "object" && typeof scope != "function") {scope = window;}var tags = "A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR".split(/\s+/);tags.each(function (tag) {scope[tag] = function () {return Builder.node.apply(Builder, [tag].concat($A(arguments)));};});}};String.prototype.parseColor = function () {var color = "#";if (this.slice(0, 4) == "rgb(") {var cols = this.slice(4, this.length - 1).split(",");var i = 0;do {color += parseInt(cols[i]).toColorPart();} while (++i < 3);} else {if (this.slice(0, 1) == "#") {if (this.length == 4) {for (var i = 1; i < 4; i++) {color += (this.charAt(i) + this.charAt(i)).toLowerCase();}}if (this.length == 7) {color = this.toLowerCase();}}}return color.length == 7 ? color : arguments[0] || this;};Element.collectTextNodes = function (element) {return $A($(element).childNodes).collect(function (node) {return node.nodeType == 3 ? node.nodeValue : node.hasChildNodes() ? Element.collectTextNodes(node) : "";}).flatten().join("");};Element.collectTextNodesIgnoreClass = function (element, className) {return $A($(element).childNodes).collect(function (node) {return node.nodeType == 3 ? node.nodeValue : node.hasChildNodes() && !Element.hasClassName(node, className) ? Element.collectTextNodesIgnoreClass(node, className) : "";}).flatten().join("");};Element.setContentZoom = function (element, percent) {element = $(element);element.setStyle({fontSize:percent / 100 + "em"});if (Prototype.Browser.WebKit) {window.scrollBy(0, 0);}return element;};Element.getInlineOpacity = function (element) {return $(element).style.opacity || "";};Element.forceRerendering = function (element) {try {element = $(element);var n = document.createTextNode(" ");element.appendChild(n);element.removeChild(n);} catch (e) {}};Array.prototype.call = function () {var args = arguments;this.each(function (f) {f.apply(this, args);});};var Effect = {_elementDoesNotExistError:{name:"ElementDoesNotExistError", message:"The specified DOM element does not exist, but is required for this effect to operate"}, tagifyText:function (element) {if (typeof Builder == "undefined") {throw "Effect.tagifyText requires including script.aculo.us' builder.js library";}var tagifyStyle = "position:relative";if (Prototype.Browser.IE) {tagifyStyle += ";zoom:1";}element = $(element);$A(element.childNodes).each(function (child) {if (child.nodeType == 3) {child.nodeValue.toArray().each(function (character) {element.insertBefore(Builder.node("span", {style:tagifyStyle}, character == " " ? String.fromCharCode(160) : character), child);});Element.remove(child);}});}, multiple:function (element, effect) {var elements;if ((typeof element == "object" || typeof element == "function") && element.length) {elements = element;} else {elements = $(element).childNodes;}var options = Object.extend({speed:0.1, delay:0}, arguments[2] || {});var masterDelay = options.delay;$A(elements).each(function (element, index) {new effect(element, Object.extend(options, {delay:index * options.speed + masterDelay}));});}, PAIRS:{slide:["SlideDown", "SlideUp"], blind:["BlindDown", "BlindUp"], appear:["Appear", "Fade"]}, toggle:function (element, effect) {element = $(element);effect = (effect || "appear").toLowerCase();var options = Object.extend({queue:{position:"end", scope:element.id || "global", limit:1}}, arguments[2] || {});Effect[element.visible() ? Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);}};var Effect2 = Effect;Effect.Transitions = {linear:Prototype.K, sinoidal:function (pos) {return - Math.cos(pos * Math.PI) / 2 + 0.5;}, reverse:function (pos) {return 1 - pos;}, flicker:function (pos) {var pos = - Math.cos(pos * Math.PI) / 4 + 0.75 + Math.random() / 4;return pos > 1 ? 1 : pos;}, wobble:function (pos) {return - Math.cos(pos * Math.PI * (9 * pos)) / 2 + 0.5;}, pulse:function (pos, pulses) {pulses = pulses || 5;return Math.round(pos % (1 / pulses) * pulses) == 0 ? pos * pulses * 2 - Math.floor(pos * pulses * 2) : 1 - (pos * pulses * 2 - Math.floor(pos * pulses * 2));}, none:function (pos) {return 0;}, full:function (pos) {return 1;}};Effect.ScopedQueue = Class.create();Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {initialize:function () {this.effects = [];this.interval = null;}, _each:function (iterator) {this.effects._each(iterator);}, add:function (effect) {var timestamp = (new Date).getTime();var position = typeof effect.options.queue == "string" ? effect.options.queue : effect.options.queue.position;switch (position) {case "front":this.effects.findAll(function (e) {return e.state == "idle";}).each(function (e) {e.startOn += effect.finishOn;e.finishOn += effect.finishOn;});break;case "with-last":timestamp = this.effects.pluck("startOn").max() || timestamp;break;case "end":timestamp = this.effects.pluck("finishOn").max() || timestamp;break;default:;}effect.startOn += timestamp;effect.finishOn += timestamp;if (!effect.options.queue.limit || this.effects.length < effect.options.queue.limit) {this.effects.push(effect);}if (!this.interval) {this.interval = setInterval(this.loop.bind(this), 15);}}, remove:function (effect) {this.effects = this.effects.reject(function (e) {return e == effect;});if (this.effects.length == 0) {clearInterval(this.interval);this.interval = null;}}, loop:function () {var timePos = (new Date).getTime();for (var i = 0, len = this.effects.length; i < len; i++) {this.effects[i] && this.effects[i].loop(timePos);}}});Effect.Queues = {instances:$H(), get:function (queueName) {if (typeof queueName != "string") {return queueName;}if (!this.instances[queueName]) {this.instances[queueName] = new Effect.ScopedQueue;}return this.instances[queueName];}};Effect.Queue = Effect.Queues.get("global");Effect.DefaultOptions = {transition:Effect.Transitions.sinoidal, duration:1, fps:100, sync:false, from:0, to:1, delay:0, queue:"parallel"};Effect.Base = function () {};Effect.Base.prototype = {position:null, start:function (options) {
function codeForEvent(options, eventName) {return (options[eventName + "Internal"] ? "this.options." + eventName + "Internal(this);" : "") + (options[eventName] ? "this.options." + eventName + "(this);" : "");}
if (options.transition === false) {options.transition = Effect.Transitions.linear;}this.options = Object.extend(Object.extend({}, Effect.DefaultOptions), options || {});this.currentFrame = 0;this.state = "idle";this.startOn = this.options.delay * 1000;this.finishOn = this.startOn + this.options.duration * 1000;this.fromToDelta = this.options.to - this.options.from;this.totalTime = this.finishOn - this.startOn;this.totalFrames = this.options.fps * this.options.duration;eval("this.render = function(pos){ " + "if(this.state==\"idle\"){this.state=\"running\";" + codeForEvent(options, "beforeSetup") + (this.setup ? "this.setup();" : "") + codeForEvent(options, "afterSetup") + "};if(this.state==\"running\"){" + "pos=this.options.transition(pos)*" + this.fromToDelta + "+" + this.options.from + ";" + "this.position=pos;" + codeForEvent(options, "beforeUpdate") + (this.update ? "this.update(pos);" : "") + codeForEvent(options, "afterUpdate") + "}}");this.event("beforeStart");if (!this.options.sync) {Effect.Queues.get(typeof this.options.queue == "string" ? "global" : this.options.queue.scope).add(this);}}, loop:function (timePos) {if (timePos >= this.startOn) {if (timePos >= this.finishOn) {this.render(1);this.cancel();this.event("beforeFinish");if (this.finish) {this.finish();}this.event("afterFinish");return;}var pos = (timePos - this.startOn) / this.totalTime, frame = Math.round(pos * this.totalFrames);if (frame > this.currentFrame) {this.render(pos);this.currentFrame = frame;}}}, cancel:function () {if (!this.options.sync) {Effect.Queues.get(typeof this.options.queue == "string" ? "global" : this.options.queue.scope).remove(this);}this.state = "finished";}, event:function (eventName) {if (this.options[eventName + "Internal"]) {this.options[eventName + "Internal"](this);}if (this.options[eventName]) {this.options[eventName](this);}}, inspect:function () {var data = $H();for (property in this) {if (typeof this[property] != "function") {data[property] = this[property];}}return "#<Effect:" + data.inspect() + ",options:" + $H(this.options).inspect() + ">";}};Effect.Parallel = Class.create();Object.extend(Object.extend(Effect.Parallel.prototype, Effect.Base.prototype), {initialize:function (effects) {this.effects = effects || [];this.start(arguments[1]);}, update:function (position) {this.effects.invoke("render", position);}, finish:function (position) {this.effects.each(function (effect) {effect.render(1);effect.cancel();effect.event("beforeFinish");if (effect.finish) {effect.finish(position);}effect.event("afterFinish");});}});Effect.Event = Class.create();Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), {initialize:function () {var options = Object.extend({duration:0}, arguments[0] || {});this.start(options);}, update:Prototype.emptyFunction});Effect.Opacity = Class.create();Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), {initialize:function (element) {this.element = $(element);if (!this.element) {throw Effect._elementDoesNotExistError;}if (Prototype.Browser.IE && !this.element.currentStyle.hasLayout) {this.element.setStyle({zoom:1});}var options = Object.extend({from:this.element.getOpacity() || 0, to:1}, arguments[1] || {});this.start(options);}, update:function (position) {this.element.setOpacity(position);}});Effect.Move = Class.create();Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), {initialize:function (element) {this.element = $(element);if (!this.element) {throw Effect._elementDoesNotExistError;}var options = Object.extend({x:0, y:0, mode:"relative"}, arguments[1] || {});this.start(options);}, setup:function () {this.element.makePositioned();this.originalLeft = parseFloat(this.element.getStyle("left") || "0");this.originalTop = parseFloat(this.element.getStyle("top") || "0");if (this.options.mode == "absolute") {this.options.x = this.options.x - this.originalLeft;this.options.y = this.options.y - this.originalTop;}}, update:function (position) {this.element.setStyle({left:Math.round(this.options.x * position + this.originalLeft) + "px", top:Math.round(this.options.y * position + this.originalTop) + "px"});}});Effect.MoveBy = function (element, toTop, toLeft) {return new Effect.Move(element, Object.extend({x:toLeft, y:toTop}, arguments[3] || {}));};Effect.Scale = Class.create();Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {initialize:function (element, percent) {this.element = $(element);if (!this.element) {throw Effect._elementDoesNotExistError;}var options = Object.extend({scaleX:true, scaleY:true, scaleContent:true, scaleFromCenter:false, scaleMode:"box", scaleFrom:100, scaleTo:percent}, arguments[2] || {});this.start(options);}, setup:function () {this.restoreAfterFinish = this.options.restoreAfterFinish || false;this.elementPositioning = this.element.getStyle("position");this.originalStyle = {};["top", "left", "width", "height", "fontSize"].each((function (k) {this.originalStyle[k] = this.element.style[k];}).bind(this));this.originalTop = this.element.offsetTop;this.originalLeft = this.element.offsetLeft;var fontSize = this.element.getStyle("font-size") || "100%";["em", "px", "%", "pt"].each((function (fontSizeType) {if (fontSize.indexOf(fontSizeType) > 0) {this.fontSize = parseFloat(fontSize);this.fontSizeType = fontSizeType;}}).bind(this));this.factor = (this.options.scaleTo - this.options.scaleFrom) / 100;this.dims = null;if (this.options.scaleMode == "box") {this.dims = [this.element.offsetHeight, this.element.offsetWidth];}if (/^content/.test(this.options.scaleMode)) {this.dims = [this.element.scrollHeight, this.element.scrollWidth];}if (!this.dims) {this.dims = [this.options.scaleMode.originalHeight, this.options.scaleMode.originalWidth];}}, update:function (position) {var currentScale = this.options.scaleFrom / 100 + this.factor * position;if (this.options.scaleContent && this.fontSize) {this.element.setStyle({fontSize:this.fontSize * currentScale + this.fontSizeType});}this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);}, finish:function (position) {if (this.restoreAfterFinish) {this.element.setStyle(this.originalStyle);}}, setDimensions:function (height, width) {var d = {};if (this.options.scaleX) {d.width = Math.round(width) + "px";}if (this.options.scaleY) {d.height = Math.round(height) + "px";}if (this.options.scaleFromCenter) {var topd = (height - this.dims[0]) / 2;var leftd = (width - this.dims[1]) / 2;if (this.elementPositioning == "absolute") {if (this.options.scaleY) {d.top = this.originalTop - topd + "px";}if (this.options.scaleX) {d.left = this.originalLeft - leftd + "px";}} else {if (this.options.scaleY) {d.top = - topd + "px";}if (this.options.scaleX) {d.left = - leftd + "px";}}}this.element.setStyle(d);}});Effect.Highlight = Class.create();Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {initialize:function (element) {this.element = $(element);if (!this.element) {throw Effect._elementDoesNotExistError;}var options = Object.extend({startcolor:"#ffff99"}, arguments[1] || {});this.start(options);}, setup:function () {if (this.element.getStyle("display") == "none") {this.cancel();return;}this.oldStyle = {};if (!this.options.keepBackgroundImage) {this.oldStyle.backgroundImage = this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"});}if (!this.options.endcolor) {this.options.endcolor = this.element.getStyle("background-color").parseColor("#ffffff");}if (!this.options.restorecolor) {this.options.restorecolor = this.element.getStyle("background-color");}this._base = $R(0, 2).map((function (i) {return parseInt(this.options.startcolor.slice(i * 2 + 1, i * 2 + 3), 16);}).bind(this));this._delta = $R(0, 2).map((function (i) {return parseInt(this.options.endcolor.slice(i * 2 + 1, i * 2 + 3), 16) - this._base[i];}).bind(this));}, update:function (position) {this.element.setStyle({backgroundColor:$R(0, 2).inject("#", (function (m, v, i) {return m + Math.round(this._base[i] + this._delta[i] * position).toColorPart();}).bind(this))});}, finish:function () {this.element.setStyle(Object.extend(this.oldStyle, {backgroundColor:this.options.restorecolor}));}});Effect.ScrollTo = Class.create();Object.extend(Object.extend(Effect.ScrollTo.prototype, Effect.Base.prototype), {initialize:function (element) {this.element = $(element);this.start(arguments[1] || {});}, setup:function () {Position.prepare();var offsets = Position.cumulativeOffset(this.element);if (this.options.offset) {offsets[1] += this.options.offset;}var max = window.innerHeight ? window.height - window.innerHeight : document.body.scrollHeight - (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight);this.scrollStart = Position.deltaY;this.delta = (offsets[1] > max ? max : offsets[1]) - this.scrollStart;}, update:function (position) {Position.prepare();window.scrollTo(Position.deltaX, this.scrollStart + position * this.delta);}});Effect.Fade = function (element) {element = $(element);var oldOpacity = element.getInlineOpacity();var options = Object.extend({from:element.getOpacity() || 1, to:0, afterFinishInternal:function (effect) {if (effect.options.to != 0) {return;}effect.element.hide().setStyle({opacity:oldOpacity});}}, arguments[1] || {});return new Effect.Opacity(element, options);};Effect.Appear = function (element) {element = $(element);var options = Object.extend({from:element.getStyle("display") == "none" ? 0 : element.getOpacity() || 0, to:1, afterFinishInternal:function (effect) {effect.element.forceRerendering();}, beforeSetup:function (effect) {effect.element.setOpacity(effect.options.from).show();}}, arguments[1] || {});return new Effect.Opacity(element, options);};Effect.Puff = function (element) {element = $(element);var oldStyle = {opacity:element.getInlineOpacity(), position:element.getStyle("position"), top:element.style.top, left:element.style.left, width:element.style.width, height:element.style.height};return new Effect.Parallel([new Effect.Scale(element, 200, {sync:true, scaleFromCenter:true, scaleContent:true, restoreAfterFinish:true}), new Effect.Opacity(element, {sync:true, to:0})], Object.extend({duration:1, beforeSetupInternal:function (effect) {Position.absolutize(effect.effects[0].element);}, afterFinishInternal:function (effect) {effect.effects[0].element.hide().setStyle(oldStyle);}}, arguments[1] || {}));};Effect.BlindUp = function (element) {element = $(element);element.makeClipping();return new Effect.Scale(element, 0, Object.extend({scaleContent:false, scaleX:false, restoreAfterFinish:true, afterFinishInternal:function (effect) {effect.element.hide().undoClipping();}}, arguments[1] || {}));};Effect.BlindDown = function (element) {element = $(element);var elementDimensions = element.getDimensions();return new Effect.Scale(element, 100, Object.extend({scaleContent:false, scaleX:false, scaleFrom:0, scaleMode:{originalHeight:elementDimensions.height, originalWidth:elementDimensions.width}, restoreAfterFinish:true, afterSetup:function (effect) {effect.element.makeClipping().setStyle({height:"0px"}).show();}, afterFinishInternal:function (effect) {effect.element.undoClipping();}}, arguments[1] || {}));};Effect.SwitchOff = function (element) {element = $(element);var oldOpacity = element.getInlineOpacity();return new Effect.Appear(element, Object.extend({duration:0.4, from:0, transition:Effect.Transitions.flicker, afterFinishInternal:function (effect) {new Effect.Scale(effect.element, 1, {duration:0.3, scaleFromCenter:true, scaleX:false, scaleContent:false, restoreAfterFinish:true, beforeSetup:function (effect) {effect.element.makePositioned().makeClipping();}, afterFinishInternal:function (effect) {effect.element.hide().undoClipping().undoPositioned().setStyle({opacity:oldOpacity});}});}}, arguments[1] || {}));};Effect.DropOut = function (element) {element = $(element);var oldStyle = {top:element.getStyle("top"), left:element.getStyle("left"), opacity:element.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(element, {x:0, y:100, sync:true}), new Effect.Opacity(element, {sync:true, to:0})], Object.extend({duration:0.5, beforeSetup:function (effect) {effect.effects[0].element.makePositioned();}, afterFinishInternal:function (effect) {effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle);}}, arguments[1] || {}));};Effect.Shake = function (element) {element = $(element);var oldStyle = {top:element.getStyle("top"), left:element.getStyle("left")};return new Effect.Move(element, {x:20, y:0, duration:0.05, afterFinishInternal:function (effect) {new Effect.Move(effect.element, {x:-40, y:0, duration:0.1, afterFinishInternal:function (effect) {new Effect.Move(effect.element, {x:40, y:0, duration:0.1, afterFinishInternal:function (effect) {new Effect.Move(effect.element, {x:-40, y:0, duration:0.1, afterFinishInternal:function (effect) {new Effect.Move(effect.element, {x:40, y:0, duration:0.1, afterFinishInternal:function (effect) {new Effect.Move(effect.element, {x:-20, y:0, duration:0.05, afterFinishInternal:function (effect) {effect.element.undoPositioned().setStyle(oldStyle);}});}});}});}});}});}});};Effect.SlideDown = function (element) {element = $(element).cleanWhitespace();var oldInnerBottom = element.down().getStyle("bottom");var elementDimensions = element.getDimensions();return new Effect.Scale(element, 100, Object.extend({scaleContent:false, scaleX:false, scaleFrom:window.opera ? 0 : 1, scaleMode:{originalHeight:elementDimensions.height, originalWidth:elementDimensions.width}, restoreAfterFinish:true, afterSetup:function (effect) {effect.element.makePositioned();effect.element.down().makePositioned();if (window.opera) {effect.element.setStyle({top:""});}effect.element.makeClipping().setStyle({height:"0px"}).show();}, afterUpdateInternal:function (effect) {effect.element.down().setStyle({bottom:effect.dims[0] - effect.element.clientHeight + "px"});}, afterFinishInternal:function (effect) {effect.element.undoClipping().undoPositioned();effect.element.down().undoPositioned().setStyle({bottom:oldInnerBottom});}}, arguments[1] || {}));};Effect.SlideUp = function (element) {element = $(element).cleanWhitespace();var oldInnerBottom = element.down().getStyle("bottom");return new Effect.Scale(element, window.opera ? 0 : 1, Object.extend({scaleContent:false, scaleX:false, scaleMode:"box", scaleFrom:100, restoreAfterFinish:true, beforeStartInternal:function (effect) {effect.element.makePositioned();effect.element.down().makePositioned();if (window.opera) {effect.element.setStyle({top:""});}effect.element.makeClipping().show();}, afterUpdateInternal:function (effect) {effect.element.down().setStyle({bottom:effect.dims[0] - effect.element.clientHeight + "px"});}, afterFinishInternal:function (effect) {effect.element.hide().undoClipping().undoPositioned().setStyle({bottom:oldInnerBottom});effect.element.down().undoPositioned();}}, arguments[1] || {}));};Effect.Squish = function (element) {return new Effect.Scale(element, window.opera ? 1 : 0, {restoreAfterFinish:true, beforeSetup:function (effect) {effect.element.makeClipping();}, afterFinishInternal:function (effect) {effect.element.hide().undoClipping();}});};Effect.Grow = function (element) {element = $(element);var options = Object.extend({direction:"center", moveTransition:Effect.Transitions.sinoidal, scaleTransition:Effect.Transitions.sinoidal, opacityTransition:Effect.Transitions.full}, arguments[1] || {});var oldStyle = {top:element.style.top, left:element.style.left, height:element.style.height, width:element.style.width, opacity:element.getInlineOpacity()};var dims = element.getDimensions();var initialMoveX, initialMoveY;var moveX, moveY;switch (options.direction) {case "top-left":initialMoveX = initialMoveY = moveX = moveY = 0;break;case "top-right":initialMoveX = dims.width;initialMoveY = moveY = 0;moveX = - dims.width;break;case "bottom-left":initialMoveX = moveX = 0;initialMoveY = dims.height;moveY = - dims.height;break;case "bottom-right":initialMoveX = dims.width;initialMoveY = dims.height;moveX = - dims.width;moveY = - dims.height;break;case "center":initialMoveX = dims.width / 2;initialMoveY = dims.height / 2;moveX = - dims.width / 2;moveY = - dims.height / 2;break;default:;}return new Effect.Move(element, {x:initialMoveX, y:initialMoveY, duration:0.01, beforeSetup:function (effect) {effect.element.hide().makeClipping().makePositioned();}, afterFinishInternal:function (effect) {new Effect.Parallel([new Effect.Opacity(effect.element, {sync:true, to:1, from:0, transition:options.opacityTransition}), new Effect.Move(effect.element, {x:moveX, y:moveY, sync:true, transition:options.moveTransition}), new Effect.Scale(effect.element, 100, {scaleMode:{originalHeight:dims.height, originalWidth:dims.width}, sync:true, scaleFrom:window.opera ? 1 : 0, transition:options.scaleTransition, restoreAfterFinish:true})], Object.extend({beforeSetup:function (effect) {effect.effects[0].element.setStyle({height:"0px"}).show();}, afterFinishInternal:function (effect) {effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);}}, options));}});};Effect.Shrink = function (element) {element = $(element);var options = Object.extend({direction:"center", moveTransition:Effect.Transitions.sinoidal, scaleTransition:Effect.Transitions.sinoidal, opacityTransition:Effect.Transitions.none}, arguments[1] || {});var oldStyle = {top:element.style.top, left:element.style.left, height:element.style.height, width:element.style.width, opacity:element.getInlineOpacity()};var dims = element.getDimensions();var moveX, moveY;switch (options.direction) {case "top-left":moveX = moveY = 0;break;case "top-right":moveX = dims.width;moveY = 0;break;case "bottom-left":moveX = 0;moveY = dims.height;break;case "bottom-right":moveX = dims.width;moveY = dims.height;break;case "center":moveX = dims.width / 2;moveY = dims.height / 2;break;default:;}return new Effect.Parallel([new Effect.Opacity(element, {sync:true, to:0, from:1, transition:options.opacityTransition}), new Effect.Scale(element, window.opera ? 1 : 0, {sync:true, transition:options.scaleTransition, restoreAfterFinish:true}), new Effect.Move(element, {x:moveX, y:moveY, sync:true, transition:options.moveTransition})], Object.extend({beforeStartInternal:function (effect) {effect.effects[0].element.makePositioned().makeClipping();}, afterFinishInternal:function (effect) {effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle);}}, options));};Effect.Pulsate = function (element) {element = $(element);var options = arguments[1] || {};var oldOpacity = element.getInlineOpacity();var transition = options.transition || Effect.Transitions.sinoidal;var reverser = function (pos) {return transition(1 - Effect.Transitions.pulse(pos, options.pulses));};reverser.bind(transition);return new Effect.Opacity(element, Object.extend(Object.extend({duration:2, from:0, afterFinishInternal:function (effect) {effect.element.setStyle({opacity:oldOpacity});}}, options), {transition:reverser}));};Effect.Fold = function (element) {element = $(element);var oldStyle = {top:element.style.top, left:element.style.left, width:element.style.width, height:element.style.height};element.makeClipping();return new Effect.Scale(element, 5, Object.extend({scaleContent:false, scaleX:false, afterFinishInternal:function (effect) {new Effect.Scale(element, 1, {scaleContent:false, scaleY:false, afterFinishInternal:function (effect) {effect.element.hide().undoClipping().setStyle(oldStyle);}});}}, arguments[1] || {}));};Effect.Morph = Class.create();Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), {initialize:function (element) {this.element = $(element);if (!this.element) {throw Effect._elementDoesNotExistError;}var options = Object.extend({style:{}}, arguments[1] || {});if (typeof options.style == "string") {if (options.style.indexOf(":") == -1) {var cssText = "", selector = "." + options.style;$A(document.styleSheets).reverse().each(function (styleSheet) {if (styleSheet.cssRules) {cssRules = styleSheet.cssRules;} else if (styleSheet.rules) {cssRules = styleSheet.rules;}$A(cssRules).reverse().each(function (rule) {if (selector == rule.selectorText) {cssText = rule.style.cssText;throw $break;}});if (cssText) {throw $break;}});this.style = cssText.parseStyle();options.afterFinishInternal = function (effect) {effect.element.addClassName(effect.options.style);effect.transforms.each(function (transform) {if (transform.style != "opacity") {effect.element.style[transform.style] = "";}});};} else {this.style = options.style.parseStyle();}} else {this.style = $H(options.style);}this.start(options);}, setup:function () {
function parseColor(color) {if (!color || ["rgba(0, 0, 0, 0)", "transparent"].include(color)) {color = "#ffffff";}color = color.parseColor();return $R(0, 2).map(function (i) {return parseInt(color.slice(i * 2 + 1, i * 2 + 3), 16);});}
this.transforms = this.style.map((function (pair) {var property = pair[0], value = pair[1], unit = null;if (value.parseColor("#zzzzzz") != "#zzzzzz") {value = value.parseColor();unit = "color";} else if (property == "opacity") {value = parseFloat(value);if (Prototype.Browser.IE && !this.element.currentStyle.hasLayout) {this.element.setStyle({zoom:1});}} else if (Element.CSS_LENGTH.test(value)) {var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/);value = parseFloat(components[1]);unit = components.length == 3 ? components[2] : null;}var originalValue = this.element.getStyle(property);return {style:property.camelize(), originalValue:unit == "color" ? parseColor(originalValue) : parseFloat(originalValue || 0), targetValue:unit == "color" ? parseColor(value) : value, unit:unit};}).bind(this)).reject(function (transform) {return transform.originalValue == transform.targetValue || transform.unit != "color" && (isNaN(transform.originalValue) || isNaN(transform.targetValue));});}, update:function (position) {var style = {}, transform, i = this.transforms.length;while (i--) {style[(transform = this.transforms[i]).style] = transform.unit == "color" ? "#" + Math.round(transform.originalValue[0] + (transform.targetValue[0] - transform.originalValue[0]) * position).toColorPart() + Math.round(transform.originalValue[1] + (transform.targetValue[1] - transform.originalValue[1]) * position).toColorPart() + Math.round(transform.originalValue[2] + (transform.targetValue[2] - transform.originalValue[2]) * position).toColorPart() : transform.originalValue + Math.round((transform.targetValue - transform.originalValue) * position * 1000) / 1000 + transform.unit;}this.element.setStyle(style, true);}});Effect.Transform = Class.create();Object.extend(Effect.Transform.prototype, {initialize:function (tracks) {this.tracks = [];this.options = arguments[1] || {};this.addTracks(tracks);}, addTracks:function (tracks) {tracks.each((function (track) {var data = $H(track).values().first();this.tracks.push($H({ids:$H(track).keys().first(), effect:Effect.Morph, options:{style:data}}));}).bind(this));return this;}, play:function () {return new Effect.Parallel(this.tracks.map(function (track) {var elements = [$(track.ids) || $$(track.ids)].flatten();return elements.map(function (e) {return new track.effect(e, Object.extend({sync:true}, track.options));});}).flatten(), this.options);}});Element.CSS_PROPERTIES = $w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.prototype.parseStyle = function () {var element = document.createElement("div");element.innerHTML = "<div style=\"" + this + "\"></div>";var style = element.childNodes[0].style, styleRules = $H();Element.CSS_PROPERTIES.each(function (property) {if (style[property]) {styleRules[property] = style[property];}});if (Prototype.Browser.IE && this.indexOf("opacity") > -1) {styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];}return styleRules;};Element.morph = function (element, style) {new Effect.Morph(element, Object.extend({style:style}, arguments[2] || {}));return element;};["getInlineOpacity", "forceRerendering", "setContentZoom", "collectTextNodes", "collectTextNodesIgnoreClass", "morph"].each(function (f) {Element.Methods[f] = Element[f];});Element.Methods.visualEffect = function (element, effect, options) {s = effect.dasherize().camelize();effect_class = s.charAt(0).toUpperCase() + s.substring(1);new Effect[effect_class](element, options);return $(element);};Element.addMethods();if (typeof Effect == "undefined") {throw "dragdrop.js requires including script.aculo.us' effects.js library";}var Droppables = {drops:[], remove:function (element) {this.drops = this.drops.reject(function (d) {return d.element == $(element);});}, add:function (element) {element = $(element);var options = Object.extend({greedy:true, hoverclass:null, tree:false}, arguments[1] || {});if (options.containment) {options._containers = [];var containment = options.containment;if (typeof containment == "object" && containment.constructor == Array) {containment.each(function (c) {options._containers.push($(c));});} else {options._containers.push($(containment));}}if (options.accept) {options.accept = [options.accept].flatten();}Element.makePositioned(element);options.element = element;this.drops.push(options);}, findDeepestChild:function (drops) {deepest = drops[0];for (i = 1; i < drops.length; ++i) {if (Element.isParent(drops[i].element, deepest.element)) {deepest = drops[i];}}return deepest;}, isContained:function (element, drop) {var containmentNode;if (drop.tree) {containmentNode = element.treeNode;} else {containmentNode = element.parentNode;}return drop._containers.detect(function (c) {return containmentNode == c;});}, isAffected:function (point, element, drop) {return drop.element != element && (!drop._containers || this.isContained(element, drop)) && (!drop.accept || Element.classNames(element).detect(function (v) {return drop.accept.include(v);})) && Position.within(drop.element, point[0], point[1]);}, deactivate:function (drop) {if (drop.hoverclass) {Element.removeClassName(drop.element, drop.hoverclass);}this.last_active = null;}, activate:function (drop) {if (drop.hoverclass) {Element.addClassName(drop.element, drop.hoverclass);}this.last_active = drop;}, show:function (point, element) {if (!this.drops.length) {return;}var affected = [];if (this.last_active) {this.deactivate(this.last_active);}this.drops.each(function (drop) {if (Droppables.isAffected(point, element, drop)) {affected.push(drop);}});if (affected.length > 0) {drop = Droppables.findDeepestChild(affected);Position.within(drop.element, point[0], point[1]);if (drop.onHover) {drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element));}Droppables.activate(drop);}}, fire:function (event, element) {if (!this.last_active) {return;}Position.prepare();if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) {if (this.last_active.onDrop) {this.last_active.onDrop(element, this.last_active.element, event);return true;}}}, reset:function () {if (this.last_active) {this.deactivate(this.last_active);}}};var Draggables = {drags:[], observers:[], register:function (draggable) {if (this.drags.length == 0) {this.eventMouseUp = this.endDrag.bindAsEventListener(this);this.eventMouseMove = this.updateDrag.bindAsEventListener(this);this.eventKeypress = this.keyPress.bindAsEventListener(this);Event.observe(document, "mouseup", this.eventMouseUp);Event.observe(document, "mousemove", this.eventMouseMove);Event.observe(document, "keypress", this.eventKeypress);}this.drags.push(draggable);}, unregister:function (draggable) {this.drags = this.drags.reject(function (d) {return d == draggable;});if (this.drags.length == 0) {Event.stopObserving(document, "mouseup", this.eventMouseUp);Event.stopObserving(document, "mousemove", this.eventMouseMove);Event.stopObserving(document, "keypress", this.eventKeypress);}}, activate:function (draggable) {if (draggable.options.delay) {this._timeout = setTimeout((function () {Draggables._timeout = null;window.focus();Draggables.activeDraggable = draggable;}).bind(this), draggable.options.delay);} else {window.focus();this.activeDraggable = draggable;}}, deactivate:function () {this.activeDraggable = null;}, updateDrag:function (event) {if (!this.activeDraggable) {return;}var pointer = [Event.pointerX(event), Event.pointerY(event)];if (this._lastPointer && this._lastPointer.inspect() == pointer.inspect()) {return;}this._lastPointer = pointer;this.activeDraggable.updateDrag(event, pointer);}, endDrag:function (event) {if (this._timeout) {clearTimeout(this._timeout);this._timeout = null;}if (!this.activeDraggable) {return;}this._lastPointer = null;this.activeDraggable.endDrag(event);this.activeDraggable = null;}, keyPress:function (event) {if (this.activeDraggable) {this.activeDraggable.keyPress(event);}}, addObserver:function (observer) {this.observers.push(observer);this._cacheObserverCallbacks();}, removeObserver:function (element) {this.observers = this.observers.reject(function (o) {return o.element == element;});this._cacheObserverCallbacks();}, notify:function (eventName, draggable, event) {if (this[eventName + "Count"] > 0) {this.observers.each(function (o) {if (o[eventName]) {o[eventName](eventName, draggable, event);}});}if (draggable.options[eventName]) {draggable.options[eventName](draggable, event);}}, _cacheObserverCallbacks:function () {["onStart", "onEnd", "onDrag"].each(function (eventName) {Draggables[eventName + "Count"] = Draggables.observers.select(function (o) {return o[eventName];}).length;});}};var Draggable = Class.create();Draggable._dragging = {};Draggable.prototype = {initialize:function (element) {var defaults = {handle:false, reverteffect:function (element, top_offset, left_offset) {var dur = Math.sqrt(Math.abs(top_offset ^ 2) + Math.abs(left_offset ^ 2)) * 0.02;new Effect.Move(element, {x:- left_offset, y:- top_offset, duration:dur, queue:{scope:"_draggable", position:"end"}});}, endeffect:function (element) {var toOpacity = typeof element._opacity == "number" ? element._opacity : 1;new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, queue:{scope:"_draggable", position:"end"}, afterFinish:function () {Draggable._dragging[element] = false;}});}, zindex:1000, revert:false, quiet:false, scroll:false, scrollSensitivity:20, scrollSpeed:15, snap:false, delay:0};if (!arguments[1] || typeof arguments[1].endeffect == "undefined") {Object.extend(defaults, {starteffect:function (element) {element._opacity = Element.getOpacity(element);Draggable._dragging[element] = true;new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});}});}var options = Object.extend(defaults, arguments[1] || {});this.element = $(element);if (options.handle && typeof options.handle == "string") {this.handle = this.element.down("." + options.handle, 0);}if (!this.handle) {this.handle = $(options.handle);}if (!this.handle) {this.handle = this.element;}if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) {options.scroll = $(options.scroll);this._isScrollChild = Element.childOf(this.element, options.scroll);}Element.makePositioned(this.element);this.delta = this.currentDelta();this.options = options;this.dragging = false;this.eventMouseDown = this.initDrag.bindAsEventListener(this);Event.observe(this.handle, "mousedown", this.eventMouseDown);Draggables.register(this);}, destroy:function () {Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);Draggables.unregister(this);}, currentDelta:function () {return [parseInt(Element.getStyle(this.element, "left") || "0"), parseInt(Element.getStyle(this.element, "top") || "0")];}, initDrag:function (event) {if (typeof Draggable._dragging[this.element] != "undefined" && Draggable._dragging[this.element]) {return;}if (Event.isLeftClick(event)) {var src = Event.element(event);if ((tag_name = src.tagName.toUpperCase()) && (tag_name == "INPUT" || tag_name == "SELECT" || tag_name == "OPTION" || tag_name == "BUTTON" || tag_name == "TEXTAREA")) {return;}var pointer = [Event.pointerX(event), Event.pointerY(event)];var pos = Position.cumulativeOffset(this.element);this.offset = [0, 1].map(function (i) {return pointer[i] - pos[i];});Draggables.activate(this);Event.stop(event);}}, startDrag:function (event) {this.dragging = true;if (this.options.zindex) {this.originalZ = parseInt(Element.getStyle(this.element, "z-index") || 0);this.element.style.zIndex = this.options.zindex;}if (this.options.ghosting) {this._clone = this.element.cloneNode(true);Position.absolutize(this.element);this.element.parentNode.insertBefore(this._clone, this.element);}if (this.options.scroll) {if (this.options.scroll == window) {var where = this._getWindowScroll(this.options.scroll);this.originalScrollLeft = where.left;this.originalScrollTop = where.top;} else {this.originalScrollLeft = this.options.scroll.scrollLeft;this.originalScrollTop = this.options.scroll.scrollTop;}}Draggables.notify("onStart", this, event);if (this.options.starteffect) {this.options.starteffect(this.element);}}, updateDrag:function (event, pointer) {if (!this.dragging) {this.startDrag(event);}if (!this.options.quiet) {Position.prepare();Droppables.show(pointer, this.element);}Draggables.notify("onDrag", this, event);this.draw(pointer);if (this.options.change) {this.options.change(this);}if (this.options.scroll) {this.stopScrolling();var p;if (this.options.scroll == window) {with (this._getWindowScroll(this.options.scroll)) {p = [left, top, left + width, top + height];}} else {p = Position.page(this.options.scroll);p[0] += this.options.scroll.scrollLeft + Position.deltaX;p[1] += this.options.scroll.scrollTop + Position.deltaY;p.push(p[0] + this.options.scroll.offsetWidth);p.push(p[1] + this.options.scroll.offsetHeight);}var speed = [0, 0];if (pointer[0] < p[0] + this.options.scrollSensitivity) {speed[0] = pointer[0] - (p[0] + this.options.scrollSensitivity);}if (pointer[1] < p[1] + this.options.scrollSensitivity) {speed[1] = pointer[1] - (p[1] + this.options.scrollSensitivity);}if (pointer[0] > p[2] - this.options.scrollSensitivity) {speed[0] = pointer[0] - (p[2] - this.options.scrollSensitivity);}if (pointer[1] > p[3] - this.options.scrollSensitivity) {speed[1] = pointer[1] - (p[3] - this.options.scrollSensitivity);}this.startScrolling(speed);}if (Prototype.Browser.WebKit) {window.scrollBy(0, 0);}Event.stop(event);}, finishDrag:function (event, success) {this.dragging = false;if (this.options.quiet) {Position.prepare();var pointer = [Event.pointerX(event), Event.pointerY(event)];Droppables.show(pointer, this.element);}if (this.options.ghosting) {Position.relativize(this.element);Element.remove(this._clone);this._clone = null;}var dropped = false;if (success) {dropped = Droppables.fire(event, this.element);if (!dropped) {dropped = false;}}if (dropped && this.options.onDropped) {this.options.onDropped(this.element);}Draggables.notify("onEnd", this, event);var revert = this.options.revert;if (revert && typeof revert == "function") {revert = revert(this.element);}var d = this.currentDelta();if (revert && this.options.reverteffect) {if (dropped == 0 || revert != "failure") {this.options.reverteffect(this.element, d[1] - this.delta[1], d[0] - this.delta[0]);}} else {this.delta = d;}if (this.options.zindex) {this.element.style.zIndex = this.originalZ;}if (this.options.endeffect) {this.options.endeffect(this.element);}Draggables.deactivate(this);Droppables.reset();}, keyPress:function (event) {if (event.keyCode != Event.KEY_ESC) {return;}this.finishDrag(event, false);Event.stop(event);}, endDrag:function (event) {if (!this.dragging) {return;}this.stopScrolling();this.finishDrag(event, true);Event.stop(event);}, draw:function (point) {var pos = Position.cumulativeOffset(this.element);if (this.options.ghosting) {var r = Position.realOffset(this.element);pos[0] += r[0] - Position.deltaX;pos[1] += r[1] - Position.deltaY;}var d = this.currentDelta();pos[0] -= d[0];pos[1] -= d[1];if (this.options.scroll && this.options.scroll != window && this._isScrollChild) {pos[0] -= this.options.scroll.scrollLeft - this.originalScrollLeft;pos[1] -= this.options.scroll.scrollTop - this.originalScrollTop;}var p = [0, 1].map((function (i) {return point[i] - pos[i] - this.offset[i];}).bind(this));if (this.options.snap) {if (typeof this.options.snap == "function") {p = this.options.snap(p[0], p[1], this);} else {if (this.options.snap instanceof Array) {p = p.map((function (v, i) {return Math.round(v / this.options.snap[i]) * this.options.snap[i];}).bind(this));} else {p = p.map((function (v) {return Math.round(v / this.options.snap) * this.options.snap;}).bind(this));}}}var style = this.element.style;if (!this.options.constraint || this.options.constraint == "horizontal") {style.left = p[0] + "px";}if (!this.options.constraint || this.options.constraint == "vertical") {style.top = p[1] + "px";}if (style.visibility == "hidden") {style.visibility = "";}}, stopScrolling:function () {if (this.scrollInterval) {clearInterval(this.scrollInterval);this.scrollInterval = null;Draggables._lastScrollPointer = null;}}, startScrolling:function (speed) {if (!(speed[0] || speed[1])) {return;}this.scrollSpeed = [speed[0] * this.options.scrollSpeed, speed[1] * this.options.scrollSpeed];this.lastScrolled = new Date;this.scrollInterval = setInterval(this.scroll.bind(this), 10);}, scroll:function () {var current = new Date;var delta = current - this.lastScrolled;this.lastScrolled = current;if (this.options.scroll == window) {with (this._getWindowScroll(this.options.scroll)) {if (this.scrollSpeed[0] || this.scrollSpeed[1]) {var d = delta / 1000;this.options.scroll.scrollTo(left + d * this.scrollSpeed[0], top + d * this.scrollSpeed[1]);}}} else {this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000;this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000;}Position.prepare();Droppables.show(Draggables._lastPointer, this.element);Draggables.notify("onDrag", this);if (this._isScrollChild) {Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer);Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000;Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000;if (Draggables._lastScrollPointer[0] < 0) {Draggables._lastScrollPointer[0] = 0;}if (Draggables._lastScrollPointer[1] < 0) {Draggables._lastScrollPointer[1] = 0;}this.draw(Draggables._lastScrollPointer);}if (this.options.change) {this.options.change(this);}}, _getWindowScroll:function (w) {var T, L, W, H;with (w.document) {if (w.document.documentElement && documentElement.scrollTop) {T = documentElement.scrollTop;L = documentElement.scrollLeft;} else if (w.document.body) {T = body.scrollTop;L = body.scrollLeft;}if (w.innerWidth) {W = w.innerWidth;H = w.innerHeight;} else if (w.document.documentElement && documentElement.clientWidth) {W = documentElement.clientWidth;H = documentElement.clientHeight;} else {W = body.offsetWidth;H = body.offsetHeight;}}return {top:T, left:L, width:W, height:H};}};var SortableObserver = Class.create();SortableObserver.prototype = {initialize:function (element, observer) {this.element = $(element);this.observer = observer;this.lastValue = Sortable.serialize(this.element);}, onStart:function () {this.lastValue = Sortable.serialize(this.element);}, onEnd:function () {Sortable.unmark();if (this.lastValue != Sortable.serialize(this.element)) {this.observer(this.element);}}};var Sortable = {SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, sortables:{}, _findRootElement:function (element) {while (element.tagName.toUpperCase() != "BODY") {if (element.id && Sortable.sortables[element.id]) {return element;}element = element.parentNode;}}, options:function (element) {element = Sortable._findRootElement($(element));if (!element) {return;}return Sortable.sortables[element.id];}, destroy:function (element) {var s = Sortable.options(element);if (s) {Draggables.removeObserver(s.element);s.droppables.each(function (d) {Droppables.remove(d);});s.draggables.invoke("destroy");delete Sortable.sortables[s.element.id];}}, create:function (element) {element = $(element);var options = Object.extend({element:element, tag:"li", dropOnEmpty:false, tree:false, treeTag:"ul", overlap:"vertical", constraint:"vertical", containment:element, handle:false, only:false, delay:0, hoverclass:null, ghosting:false, quiet:false, scroll:false, scrollSensitivity:20, scrollSpeed:15, format:this.SERIALIZE_RULE, elements:false, handles:false, onChange:Prototype.emptyFunction, onUpdate:Prototype.emptyFunction}, arguments[1] || {});this.destroy(element);var options_for_draggable = {revert:true, quiet:options.quiet, scroll:options.scroll, scrollSpeed:options.scrollSpeed, scrollSensitivity:options.scrollSensitivity, delay:options.delay, ghosting:options.ghosting, constraint:options.constraint, handle:options.handle};if (options.starteffect) {options_for_draggable.starteffect = options.starteffect;}if (options.reverteffect) {options_for_draggable.reverteffect = options.reverteffect;} else if (options.ghosting) {options_for_draggable.reverteffect = function (element) {element.style.top = 0;element.style.left = 0;};}if (options.endeffect) {options_for_draggable.endeffect = options.endeffect;}if (options.zindex) {options_for_draggable.zindex = options.zindex;}var options_for_droppable = {overlap:options.overlap, containment:options.containment, tree:options.tree, hoverclass:options.hoverclass, onHover:Sortable.onHover};var options_for_tree = {onHover:Sortable.onEmptyHover, overlap:options.overlap, containment:options.containment, hoverclass:options.hoverclass};Element.cleanWhitespace(element);options.draggables = [];options.droppables = [];if (options.dropOnEmpty || options.tree) {Droppables.add(element, options_for_tree);options.droppables.push(element);}(options.elements || this.findElements(element, options) || []).each(function (e, i) {var handle = options.handles ? $(options.handles[i]) : options.handle ? $(e).getElementsByClassName(options.handle)[0] : e;options.draggables.push(new Draggable(e, Object.extend(options_for_draggable, {handle:handle})));Droppables.add(e, options_for_droppable);if (options.tree) {e.treeNode = element;}options.droppables.push(e);});if (options.tree) {(Sortable.findTreeElements(element, options) || []).each(function (e) {Droppables.add(e, options_for_tree);e.treeNode = element;options.droppables.push(e);});}this.sortables[element.id] = options;Draggables.addObserver(new SortableObserver(element, options.onUpdate));}, findElements:function (element, options) {return Element.findChildren(element, options.only, options.tree ? true : false, options.tag);}, findTreeElements:function (element, options) {return Element.findChildren(element, options.only, options.tree ? true : false, options.treeTag);}, onHover:function (element, dropon, overlap) {if (Element.isParent(dropon, element)) {return;}if (overlap > 0.33 && overlap < 0.66 && Sortable.options(dropon).tree) {return;} else if (overlap > 0.5) {Sortable.mark(dropon, "before");if (dropon.previousSibling != element) {var oldParentNode = element.parentNode;element.style.visibility = "hidden";dropon.parentNode.insertBefore(element, dropon);if (dropon.parentNode != oldParentNode) {Sortable.options(oldParentNode).onChange(element);}Sortable.options(dropon.parentNode).onChange(element);}} else {Sortable.mark(dropon, "after");var nextElement = dropon.nextSibling || null;if (nextElement != element) {var oldParentNode = element.parentNode;element.style.visibility = "hidden";dropon.parentNode.insertBefore(element, nextElement);if (dropon.parentNode != oldParentNode) {Sortable.options(oldParentNode).onChange(element);}Sortable.options(dropon.parentNode).onChange(element);}}}, onEmptyHover:function (element, dropon, overlap) {var oldParentNode = element.parentNode;var droponOptions = Sortable.options(dropon);if (!Element.isParent(dropon, element)) {var index;var children = Sortable.findElements(dropon, {tag:droponOptions.tag, only:droponOptions.only});var child = null;if (children) {var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1 - overlap);for (index = 0; index < children.length; index += 1) {if (offset - Element.offsetSize(children[index], droponOptions.overlap) >= 0) {offset -= Element.offsetSize(children[index], droponOptions.overlap);} else if (offset - Element.offsetSize(children[index], droponOptions.overlap) / 2 >= 0) {child = index + 1 < children.length ? children[index + 1] : null;break;} else {child = children[index];break;}}}dropon.insertBefore(element, child);Sortable.options(oldParentNode).onChange(element);droponOptions.onChange(element);}}, unmark:function () {if (Sortable._marker) {Sortable._marker.hide();}}, mark:function (dropon, position) {var sortable = Sortable.options(dropon.parentNode);if (sortable && !sortable.ghosting) {return;}if (!Sortable._marker) {Sortable._marker = ($("dropmarker") || Element.extend(document.createElement("DIV"))).hide().addClassName("dropmarker").setStyle({position:"absolute"});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);}var offsets = Position.cumulativeOffset(dropon);Sortable._marker.setStyle({left:offsets[0] + "px", top:offsets[1] + "px"});if (position == "after") {if (sortable.overlap == "horizontal") {Sortable._marker.setStyle({left:offsets[0] + dropon.clientWidth + "px"});} else {Sortable._marker.setStyle({top:offsets[1] + dropon.clientHeight + "px"});}}Sortable._marker.show();}, _tree:function (element, options, parent) {var children = Sortable.findElements(element, options) || [];for (var i = 0; i < children.length; ++i) {var match = children[i].id.match(options.format);if (!match) {continue;}var child = {id:encodeURIComponent(match ? match[1] : null), element:element, parent:parent, children:[], position:parent.children.length, container:$(children[i]).down(options.treeTag)};if (child.container) {this._tree(child.container, options, child);}parent.children.push(child);}return parent;}, tree:function (element) {element = $(element);var sortableOptions = this.options(element);var options = Object.extend({tag:sortableOptions.tag, treeTag:sortableOptions.treeTag, only:sortableOptions.only, name:element.id, format:sortableOptions.format}, arguments[1] || {});var root = {id:null, parent:null, children:[], container:element, position:0};return Sortable._tree(element, options, root);}, _constructIndex:function (node) {var index = "";do {if (node.id) {index = "[" + node.position + "]" + index;}} while ((node = node.parent) != null);return index;}, sequence:function (element) {element = $(element);var options = Object.extend(this.options(element), arguments[1] || {});return $(this.findElements(element, options) || []).map(function (item) {return item.id.match(options.format) ? item.id.match(options.format)[1] : "";});}, setSequence:function (element, new_sequence) {element = $(element);var options = Object.extend(this.options(element), arguments[2] || {});var nodeMap = {};this.findElements(element, options).each(function (n) {if (n.id.match(options.format)) {nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode];}n.parentNode.removeChild(n);});new_sequence.each(function (ident) {var n = nodeMap[ident];if (n) {n[1].appendChild(n[0]);delete nodeMap[ident];}});}, serialize:function (element) {element = $(element);var options = Object.extend(Sortable.options(element), arguments[1] || {});var name = encodeURIComponent(arguments[1] && arguments[1].name ? arguments[1].name : element.id);if (options.tree) {return Sortable.tree(element, arguments[1]).children.map(function (item) {return [name + Sortable._constructIndex(item) + "[id]=" + encodeURIComponent(item.id)].concat(item.children.map(arguments.callee));}).flatten().join("&");} else {return Sortable.sequence(element, arguments[1]).map(function (item) {return name + "[]=" + encodeURIComponent(item);}).join("&");}}};Element.isParent = function (child, element) {if (!child.parentNode || child == element) {return false;}if (child.parentNode == element) {return true;}return Element.isParent(child.parentNode, element);};Element.findChildren = function (element, only, recursive, tagName) {if (!element.hasChildNodes()) {return null;}tagName = tagName.toUpperCase();if (only) {only = [only].flatten();}var elements = [];$A(element.childNodes).each(function (e) {if (e.tagName && e.tagName.toUpperCase() == tagName && (!only || Element.classNames(e).detect(function (v) {return only.include(v);}))) {elements.push(e);}if (recursive) {var grandchildren = Element.findChildren(e, only, recursive, tagName);if (grandchildren) {elements.push(grandchildren);}}});return elements.length > 0 ? elements.flatten() : [];};Element.offsetSize = function (element, type) {return element["offset" + (type == "vertical" || type == "height" ? "Height" : "Width")];};if (typeof Effect == "undefined") {throw "controls.js requires including script.aculo.us' effects.js library";}var Autocompleter = {};Autocompleter.Base = function () {};Autocompleter.Base.prototype = {baseInitialize:function (element, update, options) {element = $(element);this.element = element;this.update = $(update);this.hasFocus = false;this.changed = false;this.active = false;this.index = 0;this.entryCount = 0;if (this.setOptions) {this.setOptions(options);} else {this.options = options || {};}this.options.paramName = this.options.paramName || this.element.name;this.options.tokens = this.options.tokens || [];this.options.frequency = this.options.frequency || 0.4;this.options.minChars = this.options.minChars || 1;this.options.onShow = this.options.onShow || function (element, update) {if (!update.style.position || update.style.position == "absolute") {update.style.position = "absolute";Position.clone(element, update, {setHeight:false, offsetTop:element.offsetHeight});}Effect.Appear(update, {duration:0.15});};this.options.onHide = this.options.onHide || function (element, update) {new Effect.Fade(update, {duration:0.15});};if (typeof this.options.tokens == "string") {this.options.tokens = new Array(this.options.tokens);}this.observer = null;this.element.setAttribute("autocomplete", "off");Element.hide(this.update);Event.observe(this.element, "blur", this.onBlur.bindAsEventListener(this));Event.observe(this.element, "keypress", this.onKeyPress.bindAsEventListener(this));Event.observe(window, "beforeunload", function () {element.setAttribute("autocomplete", "on");});}, show:function () {if (Element.getStyle(this.update, "display") == "none") {this.options.onShow(this.element, this.update);}if (!this.iefix && Prototype.Browser.IE && Element.getStyle(this.update, "position") == "absolute") {new Insertion.After(this.update, "<iframe id=\"" + this.update.id + "_iefix\" " + "style=\"display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);\" " + "src=\"javascript:false;\" frameborder=\"0\" scrolling=\"no\"></iframe>");this.iefix = $(this.update.id + "_iefix");}if (this.iefix) {setTimeout(this.fixIEOverlapping.bind(this), 50);}}, fixIEOverlapping:function () {Position.clone(this.update, this.iefix, {setTop:!this.update.style.height});this.iefix.style.zIndex = 1;this.update.style.zIndex = 2;Element.show(this.iefix);}, hide:function () {this.stopIndicator();if (Element.getStyle(this.update, "display") != "none") {this.options.onHide(this.element, this.update);}if (this.iefix) {Element.hide(this.iefix);}}, startIndicator:function () {if (this.options.indicator) {Element.show(this.options.indicator);}}, stopIndicator:function () {if (this.options.indicator) {Element.hide(this.options.indicator);}}, onKeyPress:function (event) {if (this.active) {switch (event.keyCode) {case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(event);case Event.KEY_ESC:this.hide();this.active = false;Event.stop(event);return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:this.markPrevious();this.render();if (Prototype.Browser.WebKit) {Event.stop(event);}return;case Event.KEY_DOWN:this.markNext();this.render();if (Prototype.Browser.WebKit) {Event.stop(event);}return;default:;}} else if (event.keyCode == Event.KEY_TAB || event.keyCode == Event.KEY_RETURN || Prototype.Browser.WebKit > 0 && event.keyCode == 0) {return;}this.changed = true;this.hasFocus = true;if (this.observer) {clearTimeout(this.observer);}this.observer = setTimeout(this.onObserverEvent.bind(this), this.options.frequency * 1000);}, activate:function () {this.changed = false;this.hasFocus = true;this.getUpdatedChoices();}, onHover:function (event) {var element = Event.findElement(event, "LI");if (this.index != element.autocompleteIndex) {this.index = element.autocompleteIndex;this.render();}Event.stop(event);}, onClick:function (event) {var element = Event.findElement(event, "LI");this.index = element.autocompleteIndex;this.selectEntry();this.hide();}, onBlur:function (event) {setTimeout(this.hide.bind(this), 250);this.hasFocus = false;this.active = false;}, render:function () {if (this.entryCount > 0) {for (var i = 0; i < this.entryCount; i++) {this.index == i ? Element.addClassName(this.getEntry(i), "selected") : Element.removeClassName(this.getEntry(i), "selected");}if (this.hasFocus) {this.show();this.active = true;}} else {this.active = false;this.hide();}}, markPrevious:function () {if (this.index > 0) {this.index--;} else {this.index = this.entryCount - 1;}this.getEntry(this.index).scrollIntoView(true);}, markNext:function () {if (this.index < this.entryCount - 1) {this.index++;} else {this.index = 0;}this.getEntry(this.index).scrollIntoView(false);}, getEntry:function (index) {return this.update.firstChild.childNodes[index];}, getCurrentEntry:function () {return this.getEntry(this.index);}, selectEntry:function () {this.active = false;this.updateElement(this.getCurrentEntry());}, updateElement:function (selectedElement) {if (this.options.updateElement) {this.options.updateElement(selectedElement);return;}var value = "";if (this.options.select) {var nodes = document.getElementsByClassName(this.options.select, selectedElement) || [];if (nodes.length > 0) {value = Element.collectTextNodes(nodes[0], this.options.select);}} else {value = Element.collectTextNodesIgnoreClass(selectedElement, "informal");}var lastTokenPos = this.findLastToken();if (lastTokenPos != -1) {var newValue = this.element.value.substr(0, lastTokenPos + 1);var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/);if (whitespace) {newValue += whitespace[0];}this.element.value = newValue + value;} else {this.element.value = value;}this.element.focus();if (this.options.afterUpdateElement) {this.options.afterUpdateElement(this.element, selectedElement);}}, updateChoices:function (choices) {if (!this.changed && this.hasFocus) {this.update.innerHTML = choices;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if (this.update.firstChild && this.update.down().childNodes) {this.entryCount = this.update.down().childNodes.length;for (var i = 0; i < this.entryCount; i++) {var entry = this.getEntry(i);entry.autocompleteIndex = i;this.addObservers(entry);}} else {this.entryCount = 0;}this.stopIndicator();this.index = 0;if (this.entryCount == 1 && this.options.autoSelect) {this.selectEntry();this.hide();} else {this.render();}}}, addObservers:function (element) {Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this));Event.observe(element, "click", this.onClick.bindAsEventListener(this));}, onObserverEvent:function () {this.changed = false;if (this.getToken().length >= this.options.minChars) {this.getUpdatedChoices();} else {this.active = false;this.hide();}}, getToken:function () {var tokenPos = this.findLastToken();if (tokenPos != -1) {var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/, "").replace(/\s+$/, "");} else {var ret = this.element.value;}return /\n/.test(ret) ? "" : ret;}, findLastToken:function () {var lastTokenPos = -1;for (var i = 0; i < this.options.tokens.length; i++) {var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]);if (thisTokenPos > lastTokenPos) {lastTokenPos = thisTokenPos;}}return lastTokenPos;}};Ajax.Autocompleter = Class.create();Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {initialize:function (element, update, url, options) {this.baseInitialize(element, update, options);this.options.asynchronous = true;this.options.onComplete = this.onComplete.bind(this);this.options.defaultParams = this.options.parameters || null;this.url = url;}, getUpdatedChoices:function () {this.startIndicator();var entry = encodeURIComponent(this.options.paramName) + "=" + encodeURIComponent(this.getToken());this.options.parameters = this.options.callback ? this.options.callback(this.element, entry) : entry;if (this.options.defaultParams) {this.options.parameters += "&" + this.options.defaultParams;}new Ajax.Request(this.url, this.options);}, onComplete:function (request) {this.updateChoices(request.responseText);}});Autocompleter.Local = Class.create();Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base, {initialize:function (element, update, array, options) {this.baseInitialize(element, update, options);this.options.array = array;}, getUpdatedChoices:function () {this.updateChoices(this.options.selector(this));}, setOptions:function (options) {this.options = Object.extend({choices:10, partialSearch:true, partialChars:2, ignoreCase:true, fullSearch:false, selector:function (instance) {var ret = [];var partial = [];var entry = instance.getToken();var count = 0;for (var i = 0; i < instance.options.array.length && ret.length < instance.options.choices; i++) {var elem = instance.options.array[i];var foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase()) : elem.indexOf(entry);while (foundPos != -1) {if (foundPos == 0 && elem.length != entry.length) {ret.push("<li><strong>" + elem.substr(0, entry.length) + "</strong>" + elem.substr(entry.length) + "</li>");break;} else if (entry.length >= instance.options.partialChars && instance.options.partialSearch && foundPos != -1) {if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos - 1, 1))) {partial.push("<li>" + elem.substr(0, foundPos) + "<strong>" + elem.substr(foundPos, entry.length) + "</strong>" + elem.substr(foundPos + entry.length) + "</li>");break;}}foundPos = instance.options.ignoreCase ? elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : elem.indexOf(entry, foundPos + 1);}}if (partial.length) {ret = ret.concat(partial.slice(0, instance.options.choices - ret.length));}return "<ul>" + ret.join("") + "</ul>";}}, options || {});}});Field.scrollFreeActivate = function (field) {setTimeout(function () {Field.activate(field);}, 1);};Ajax.InPlaceEditor = Class.create();Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";Ajax.InPlaceEditor.prototype = {initialize:function (element, url, options) {this.url = url;this.element = $(element);this.options = Object.extend({paramName:"value", okButton:true, okLink:false, okText:"ok", cancelButton:false, cancelLink:true, cancelText:"cancel", textBeforeControls:"", textBetweenControls:"", textAfterControls:"", savingText:"Saving...", clickToEditText:"Click to edit", okText:"ok", rows:1, onComplete:function (transport, element) {new Effect.Highlight(element, {startcolor:this.options.highlightcolor});}, onFailure:function (transport) {alert("Error communicating with the server: " + transport.responseText.stripTags());}, callback:function (form) {return Form.serialize(form);}, handleLineBreaks:true, loadingText:"Loading...", savingClassName:"inplaceeditor-saving", loadingClassName:"inplaceeditor-loading", formClassName:"inplaceeditor-form", highlightcolor:Ajax.InPlaceEditor.defaultHighlightColor, highlightendcolor:"#FFFFFF", externalControl:null, submitOnBlur:false, ajaxOptions:{}, evalScripts:false}, options || {});if (!this.options.formId && this.element.id) {this.options.formId = this.element.id + "-inplaceeditor";if ($(this.options.formId)) {this.options.formId = null;}}if (this.options.externalControl) {this.options.externalControl = $(this.options.externalControl);}this.originalBackground = Element.getStyle(this.element, "background-color");if (!this.originalBackground) {this.originalBackground = "transparent";}this.element.title = this.options.clickToEditText;this.onclickListener = this.enterEditMode.bindAsEventListener(this);this.mouseoverListener = this.enterHover.bindAsEventListener(this);this.mouseoutListener = this.leaveHover.bindAsEventListener(this);Event.observe(this.element, "click", this.onclickListener);Event.observe(this.element, "mouseover", this.mouseoverListener);Event.observe(this.element, "mouseout", this.mouseoutListener);if (this.options.externalControl) {Event.observe(this.options.externalControl, "click", this.onclickListener);Event.observe(this.options.externalControl, "mouseover", this.mouseoverListener);Event.observe(this.options.externalControl, "mouseout", this.mouseoutListener);}}, enterEditMode:function (evt) {if (this.saving) {return;}if (this.editing) {return;}this.editing = true;this.onEnterEditMode();if (this.options.externalControl) {Element.hide(this.options.externalControl);}Element.hide(this.element);this.createForm();this.element.parentNode.insertBefore(this.form, this.element);if (!this.options.loadTextURL) {Field.scrollFreeActivate(this.editField);}if (evt) {Event.stop(evt);}return false;}, createForm:function () {this.form = document.createElement("form");this.form.id = this.options.formId;Element.addClassName(this.form, this.options.formClassName);this.form.onsubmit = this.onSubmit.bind(this);this.createEditField();if (this.options.textarea) {var br = document.createElement("br");this.form.appendChild(br);}if (this.options.textBeforeControls) {this.form.appendChild(document.createTextNode(this.options.textBeforeControls));}if (this.options.okButton) {var okButton = document.createElement("input");okButton.type = "submit";okButton.value = this.options.okText;okButton.className = "editor_ok_button";this.form.appendChild(okButton);}if (this.options.okLink) {var okLink = document.createElement("a");okLink.href = "#";okLink.appendChild(document.createTextNode(this.options.okText));okLink.onclick = this.onSubmit.bind(this);okLink.className = "editor_ok_link";this.form.appendChild(okLink);}if (this.options.textBetweenControls && (this.options.okLink || this.options.okButton) && (this.options.cancelLink || this.options.cancelButton)) {this.form.appendChild(document.createTextNode(this.options.textBetweenControls));}if (this.options.cancelButton) {var cancelButton = document.createElement("input");cancelButton.type = "submit";cancelButton.value = this.options.cancelText;cancelButton.onclick = this.onclickCancel.bind(this);cancelButton.className = "editor_cancel_button";this.form.appendChild(cancelButton);}if (this.options.cancelLink) {var cancelLink = document.createElement("a");cancelLink.href = "#";cancelLink.appendChild(document.createTextNode(this.options.cancelText));cancelLink.onclick = this.onclickCancel.bind(this);cancelLink.className = "editor_cancel editor_cancel_link";this.form.appendChild(cancelLink);}if (this.options.textAfterControls) {this.form.appendChild(document.createTextNode(this.options.textAfterControls));}}, hasHTMLLineBreaks:function (string) {if (!this.options.handleLineBreaks) {return false;}return string.match(/<br/i) || string.match(/<p>/i);}, convertHTMLLineBreaks:function (string) {return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");}, createEditField:function () {var text;if (this.options.loadTextURL) {text = this.options.loadingText;} else {text = this.getText();}var obj = this;if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {this.options.textarea = false;var textField = document.createElement("input");textField.obj = this;textField.type = "text";textField.name = this.options.paramName;textField.value = text;textField.style.backgroundColor = this.options.highlightcolor;textField.className = "editor_field";var size = this.options.size || this.options.cols || 0;if (size != 0) {textField.size = size;}if (this.options.submitOnBlur) {textField.onblur = this.onSubmit.bind(this);}this.editField = textField;} else {this.options.textarea = true;var textArea = document.createElement("textarea");textArea.obj = this;textArea.name = this.options.paramName;textArea.value = this.convertHTMLLineBreaks(text);textArea.rows = this.options.rows;textArea.cols = this.options.cols || 40;textArea.className = "editor_field";if (this.options.submitOnBlur) {textArea.onblur = this.onSubmit.bind(this);}this.editField = textArea;}if (this.options.loadTextURL) {this.loadExternalText();}this.form.appendChild(this.editField);}, getText:function () {return this.element.innerHTML;}, loadExternalText:function () {Element.addClassName(this.form, this.options.loadingClassName);this.editField.disabled = true;new Ajax.Request(this.options.loadTextURL, Object.extend({asynchronous:true, onComplete:this.onLoadedExternalText.bind(this)}, this.options.ajaxOptions));}, onLoadedExternalText:function (transport) {Element.removeClassName(this.form, this.options.loadingClassName);this.editField.disabled = false;this.editField.value = transport.responseText.stripTags();Field.scrollFreeActivate(this.editField);}, onclickCancel:function () {this.onComplete();this.leaveEditMode();return false;}, onFailure:function (transport) {this.options.onFailure(transport);if (this.oldInnerHTML) {this.element.innerHTML = this.oldInnerHTML;this.oldInnerHTML = null;}return false;}, onSubmit:function () {var form = this.form;var value = this.editField.value;this.onLoading();if (this.options.evalScripts) {new Ajax.Request(this.url, Object.extend({parameters:this.options.callback(form, value), onComplete:this.onComplete.bind(this), onFailure:this.onFailure.bind(this), asynchronous:true, evalScripts:true}, this.options.ajaxOptions));} else {new Ajax.Updater({success:this.element, failure:null}, this.url, Object.extend({parameters:this.options.callback(form, value), onComplete:this.onComplete.bind(this), onFailure:this.onFailure.bind(this)}, this.options.ajaxOptions));}if (arguments.length > 1) {Event.stop(arguments[0]);}return false;}, onLoading:function () {this.saving = true;this.removeForm();this.leaveHover();this.showSaving();}, showSaving:function () {this.oldInnerHTML = this.element.innerHTML;this.element.innerHTML = this.options.savingText;Element.addClassName(this.element, this.options.savingClassName);this.element.style.backgroundColor = this.originalBackground;Element.show(this.element);}, removeForm:function () {if (this.form) {if (this.form.parentNode) {Element.remove(this.form);}this.form = null;}}, enterHover:function () {if (this.saving) {return;}this.element.style.backgroundColor = this.options.highlightcolor;if (this.effect) {this.effect.cancel();}Element.addClassName(this.element, this.options.hoverClassName);}, leaveHover:function () {if (this.options.backgroundColor) {this.element.style.backgroundColor = this.oldBackground;}Element.removeClassName(this.element, this.options.hoverClassName);if (this.saving) {return;}this.effect = new Effect.Highlight(this.element, {startcolor:this.options.highlightcolor, endcolor:this.options.highlightendcolor, restorecolor:this.originalBackground});}, leaveEditMode:function () {Element.removeClassName(this.element, this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor = this.originalBackground;Element.show(this.element);if (this.options.externalControl) {Element.show(this.options.externalControl);}this.editing = false;this.saving = false;this.oldInnerHTML = null;this.onLeaveEditMode();}, onComplete:function (transport) {this.leaveEditMode();this.options.onComplete.bind(this)(transport, this.element);}, onEnterEditMode:function () {}, onLeaveEditMode:function () {}, dispose:function () {if (this.oldInnerHTML) {this.element.innerHTML = this.oldInnerHTML;}this.leaveEditMode();Event.stopObserving(this.element, "click", this.onclickListener);Event.stopObserving(this.element, "mouseover", this.mouseoverListener);Event.stopObserving(this.element, "mouseout", this.mouseoutListener);if (this.options.externalControl) {Event.stopObserving(this.options.externalControl, "click", this.onclickListener);Event.stopObserving(this.options.externalControl, "mouseover", this.mouseoverListener);Event.stopObserving(this.options.externalControl, "mouseout", this.mouseoutListener);}}};Ajax.InPlaceCollectionEditor = Class.create();Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);Object.extend(Ajax.InPlaceCollectionEditor.prototype, {createEditField:function () {if (!this.cached_selectTag) {var selectTag = document.createElement("select");var collection = this.options.collection || [];var optionTag;collection.each((function (e, i) {optionTag = document.createElement("option");optionTag.value = e instanceof Array ? e[0] : e;if (typeof this.options.value == "undefined" && (e instanceof Array ? this.element.innerHTML == e[1] : e == optionTag.value)) {optionTag.selected = true;}if (this.options.value == optionTag.value) {optionTag.selected = true;}optionTag.appendChild(document.createTextNode(e instanceof Array ? e[1] : e));selectTag.appendChild(optionTag);}).bind(this));this.cached_selectTag = selectTag;}this.editField = this.cached_selectTag;if (this.options.loadTextURL) {this.loadExternalText();}this.form.appendChild(this.editField);this.options.callback = function (form, value) {return "value=" + encodeURIComponent(value);};}});Form.Element.DelayedObserver = Class.create();Form.Element.DelayedObserver.prototype = {initialize:function (element, delay, callback) {this.delay = delay || 0.5;this.element = $(element);this.callback = callback;this.timer = null;this.lastValue = $F(this.element);Event.observe(this.element, "keyup", this.delayedListener.bindAsEventListener(this));}, delayedListener:function (event) {if (this.lastValue == $F(this.element)) {return;}if (this.timer) {clearTimeout(this.timer);}this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);this.lastValue = $F(this.element);}, onTimerEvent:function () {this.timer = null;this.callback(this.element, $F(this.element));}};if (!Control) {var Control = {};}Control.Slider = Class.create();Control.Slider.prototype = {initialize:function (handle, track, options) {var slider = this;if (handle instanceof Array) {this.handles = handle.collect(function (e) {return $(e);});} else {this.handles = [$(handle)];}this.track = $(track);this.options = options || {};this.axis = this.options.axis || "horizontal";this.increment = this.options.increment || 1;this.step = parseInt(this.options.step || "1");this.range = this.options.range || $R(0, 1);this.value = 0;this.values = this.handles.map(function () {return 0;});this.spans = this.options.spans ? this.options.spans.map(function (s) {return $(s);}) : false;this.options.startSpan = $(this.options.startSpan || null);this.options.endSpan = $(this.options.endSpan || null);this.restricted = this.options.restricted || false;this.maximum = this.options.maximum || this.range.end;this.minimum = this.options.minimum || this.range.start;this.alignX = parseInt(this.options.alignX || "0");this.alignY = parseInt(this.options.alignY || "0");this.trackLength = this.maximumOffset() - this.minimumOffset();this.handleLength = this.isVertical() ? this.handles[0].offsetHeight != 0 ? this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/, "") : this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth : this.handles[0].style.width.replace(/px$/, "");this.active = false;this.dragging = false;this.disabled = false;if (this.options.disabled) {this.setDisabled();}this.allowedValues = this.options.values ? this.options.values.sortBy(Prototype.K) : false;if (this.allowedValues) {this.minimum = this.allowedValues.min();this.maximum = this.allowedValues.max();}this.eventMouseDown = this.startDrag.bindAsEventListener(this);this.eventMouseUp = this.endDrag.bindAsEventListener(this);this.eventMouseMove = this.update.bindAsEventListener(this);this.handles.each(function (h, i) {i = slider.handles.length - 1 - i;slider.setValue(parseFloat((slider.options.sliderValue instanceof Array ? slider.options.sliderValue[i] : slider.options.sliderValue) || slider.range.start), i);Element.makePositioned(h);Event.observe(h, "mousedown", slider.eventMouseDown);});Event.observe(this.track, "mousedown", this.eventMouseDown);Event.observe(document, "mouseup", this.eventMouseUp);Event.observe(document, "mousemove", this.eventMouseMove);this.initialized = true;}, dispose:function () {var slider = this;Event.stopObserving(this.track, "mousedown", this.eventMouseDown);Event.stopObserving(document, "mouseup", this.eventMouseUp);Event.stopObserving(document, "mousemove", this.eventMouseMove);this.handles.each(function (h) {Event.stopObserving(h, "mousedown", slider.eventMouseDown);});}, setDisabled:function () {this.disabled = true;}, setEnabled:function () {this.disabled = false;}, getNearestValue:function (value) {if (this.allowedValues) {if (value >= this.allowedValues.max()) {return this.allowedValues.max();}if (value <= this.allowedValues.min()) {return this.allowedValues.min();}var offset = Math.abs(this.allowedValues[0] - value);var newValue = this.allowedValues[0];this.allowedValues.each(function (v) {var currentOffset = Math.abs(v - value);if (currentOffset <= offset) {newValue = v;offset = currentOffset;}});return newValue;}if (value > this.range.end) {return this.range.end;}if (value < this.range.start) {return this.range.start;}return value;}, setValue:function (sliderValue, handleIdx) {if (!this.active) {this.activeHandleIdx = handleIdx || 0;this.activeHandle = this.handles[this.activeHandleIdx];this.updateStyles();}handleIdx = handleIdx || this.activeHandleIdx || 0;if (this.initialized && this.restricted) {if (handleIdx > 0 && sliderValue < this.values[handleIdx - 1]) {sliderValue = this.values[handleIdx - 1];}if (handleIdx < this.handles.length - 1 && sliderValue > this.values[handleIdx + 1]) {sliderValue = this.values[handleIdx + 1];}}sliderValue = this.getNearestValue(sliderValue);this.values[handleIdx] = sliderValue;this.value = this.values[0];this.handles[handleIdx].style[this.isVertical() ? "top" : "left"] = this.translateToPx(sliderValue);this.drawSpans();if (!this.dragging || !this.event) {this.updateFinished();}}, setValueBy:function (delta, handleIdx) {this.setValue(this.values[handleIdx || this.activeHandleIdx || 0] + delta, handleIdx || this.activeHandleIdx || 0);}, translateToPx:function (value) {return Math.round((this.trackLength - this.handleLength) / (this.range.end - this.range.start) * (value - this.range.start)) + "px";}, translateToValue:function (offset) {return offset / (this.trackLength - this.handleLength) * (this.range.end - this.range.start) + this.range.start;}, getRange:function (range) {var v = this.values.sortBy(Prototype.K);range = range || 0;return $R(v[range], v[range + 1]);}, minimumOffset:function () {return this.isVertical() ? this.alignY : this.alignX;}, maximumOffset:function () {return this.isVertical() ? (this.track.offsetHeight != 0 ? this.track.offsetHeight : this.track.style.height.replace(/px$/, "")) - this.alignY : (this.track.offsetWidth != 0 ? this.track.offsetWidth : this.track.style.width.replace(/px$/, "")) - this.alignY;}, isVertical:function () {return this.axis == "vertical";}, drawSpans:function () {var slider = this;if (this.spans) {$R(0, this.spans.length - 1).each(function (r) {slider.setSpan(slider.spans[r], slider.getRange(r));});}if (this.options.startSpan) {this.setSpan(this.options.startSpan, $R(0, this.values.length > 1 ? this.getRange(0).min() : this.value));}if (this.options.endSpan) {this.setSpan(this.options.endSpan, $R(this.values.length > 1 ? this.getRange(this.spans.length - 1).max() : this.value, this.maximum));}}, setSpan:function (span, range) {if (this.isVertical()) {span.style.top = this.translateToPx(range.start);span.style.height = this.translateToPx(range.end - range.start + this.range.start);} else {span.style.left = this.translateToPx(range.start);span.style.width = this.translateToPx(range.end - range.start + this.range.start);}}, updateStyles:function () {this.handles.each(function (h) {Element.removeClassName(h, "selected");});Element.addClassName(this.activeHandle, "selected");}, startDrag:function (event) {if (Event.isLeftClick(event)) {if (!this.disabled) {this.active = true;var handle = Event.element(event);var pointer = [Event.pointerX(event), Event.pointerY(event)];var track = handle;if (track == this.track) {var offsets = Position.cumulativeOffset(this.track);this.event = event;this.setValue(this.translateToValue((this.isVertical() ? pointer[1] - offsets[1] : pointer[0] - offsets[0]) - this.handleLength / 2));var offsets = Position.cumulativeOffset(this.activeHandle);this.offsetX = pointer[0] - offsets[0];this.offsetY = pointer[1] - offsets[1];} else {while (this.handles.indexOf(handle) == -1 && handle.parentNode) {handle = handle.parentNode;}if (this.handles.indexOf(handle) != -1) {this.activeHandle = handle;this.activeHandleIdx = this.handles.indexOf(this.activeHandle);this.updateStyles();var offsets = Position.cumulativeOffset(this.activeHandle);this.offsetX = pointer[0] - offsets[0];this.offsetY = pointer[1] - offsets[1];}}}Event.stop(event);}}, update:function (event) {if (this.active) {if (!this.dragging) {this.dragging = true;}this.draw(event);if (Prototype.Browser.WebKit) {window.scrollBy(0, 0);}Event.stop(event);}}, draw:function (event) {var pointer = [Event.pointerX(event), Event.pointerY(event)];var offsets = Position.cumulativeOffset(this.track);pointer[0] -= this.offsetX + offsets[0];pointer[1] -= this.offsetY + offsets[1];this.event = event;this.setValue(this.translateToValue(this.isVertical() ? pointer[1] : pointer[0]));if (this.initialized && this.options.onSlide) {this.options.onSlide(this.values.length > 1 ? this.values : this.value, this);}}, endDrag:function (event) {if (this.active && this.dragging) {this.finishDrag(event, true);Event.stop(event);}this.active = false;this.dragging = false;}, finishDrag:function (event, success) {this.active = false;this.dragging = false;this.updateFinished();}, updateFinished:function () {if (this.initialized && this.options.onChange) {this.options.onChange(this.values.length > 1 ? this.values : this.value, this);}this.event = null;}};Sound = {tracks:{}, _enabled:true, template:new Template("<embed style=\"height:0\" id=\"sound_#{track}_#{id}\" src=\"#{url}\" loop=\"false\" autostart=\"true\" hidden=\"true\"/>"), enable:function () {Sound._enabled = true;}, disable:function () {Sound._enabled = false;}, play:function (url) {if (!Sound._enabled) {return;}var options = Object.extend({track:"global", url:url, replace:false}, arguments[1] || {});if (options.replace && this.tracks[options.track]) {$R(0, this.tracks[options.track].id).each(function (id) {var sound = $("sound_" + options.track + "_" + id);sound.Stop && sound.Stop();sound.remove();});this.tracks[options.track] = null;}if (!this.tracks[options.track]) {this.tracks[options.track] = {id:0};} else {this.tracks[options.track].id++;}options.id = this.tracks[options.track].id;if (Prototype.Browser.IE) {var sound = document.createElement("bgsound");sound.setAttribute("id", "sound_" + options.track + "_" + options.id);sound.setAttribute("src", options.url);sound.setAttribute("loop", "1");sound.setAttribute("autostart", "true");$$("body")[0].appendChild(sound);} else {new Insertion.Bottom($$("body")[0], Sound.template.evaluate(options));}}};if (Prototype.Browser.Gecko && navigator.userAgent.indexOf("Win") > 0) {if (navigator.plugins && $A(navigator.plugins).detect(function (p) {return p.name.indexOf("QuickTime") != -1;})) {Sound.template = new Template("<object id=\"sound_#{track}_#{id}\" width=\"0\" height=\"0\" type=\"audio/mpeg\" data=\"#{url}\"/>");} else {Sound.play = function () {};}}addEvent(window, "load", sortables_init);

var SORT_COLUMN_INDEX;

function sortables_init() {
    // Find all tables with class sortable and make them sortable
    if (!document.getElementsByTagName) return;
    tbls = document.getElementsByTagName("table");
    for (ti=0;ti<tbls.length;ti++) {
        thisTbl = tbls[ti];
        if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) {
            //initTable(thisTbl.id);
            ts_makeSortable(thisTbl);
        }
    }
}

function ts_makeSortable(table) {
    if (table.rows && table.rows.length > 0) {
        var firstRow = table.rows[0];
    }
    if (!firstRow) return;
    
    // We have a first row: assume it's the header, and make its contents clickable links
    for (var i=0;i<firstRow.cells.length;i++) {
        var cell = firstRow.cells[i];
        var txt = ts_getInnerText(cell);
        cell.innerHTML = '<a href="#" class="sortheader" '+ 
        'onclick="ts_resortTable(this, '+i+');return false;">' + 
        txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
    }
}

function ts_getInnerText(el) {
	if (typeof el == "string") return el;
	if (typeof el == "undefined") { return el };
	if (el.innerText) return el.innerText;	//Not needed but it is faster
	var str = "";
	
	var cs = el.childNodes;
	var l = cs.length;
	for (var i = 0; i < l; i++) {
		switch (cs[i].nodeType) {
			case 1: //ELEMENT_NODE
				str += ts_getInnerText(cs[i]);
				break;
			case 3:	//TEXT_NODE
				str += cs[i].nodeValue;
				break;
		}
	}
	return str;
}

function ts_resortTable(lnk,clid) {
    // get the span
    var span;
    for (var ci=0;ci<lnk.childNodes.length;ci++) {
        if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci];
    }
    var spantext = ts_getInnerText(span);
    var td = lnk.parentNode;
    var column = clid || td.cellIndex;
    var table = getParent(td,'TABLE');
    
    // Work out a type for the column
    if (table.rows.length <= 1) return;
    var itm = ts_getInnerText(table.rows[1].cells[column]);
    sortfn = ts_sort_caseinsensitive;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
    if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
    if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
    SORT_COLUMN_INDEX = column;
    var firstRow = new Array();
    var newRows = new Array();
    for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
    for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }

    newRows.sort(sortfn);

    if (span.getAttribute("sortdir") == 'down') {
        ARROW = '&nbsp;&nbsp;&uarr;';
        newRows.reverse();
        span.setAttribute('sortdir','up');
    } else {
        ARROW = '&nbsp;&nbsp;&darr;';
        span.setAttribute('sortdir','down');
    }
    
    // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones
    // don't do sortbottom rows
    for (i=0;i<newRows.length;i++) { if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) table.tBodies[0].appendChild(newRows[i]);}
    // do sortbottom rows only
    for (i=0;i<newRows.length;i++) { if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) table.tBodies[0].appendChild(newRows[i]);}
    
    // Delete any other arrows there may be showing
    var allspans = document.getElementsByTagName("span");
    for (var ci=0;ci<allspans.length;ci++) {
        if (allspans[ci].className == 'sortarrow') {
            if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us?
                allspans[ci].innerHTML = '&nbsp;&nbsp;&nbsp;';
            }
        }
    }
        
    span.innerHTML = ARROW;
}

function getParent(el, pTagName) {
	if (el == null) return null;
	else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())	// Gecko bug, supposed to be uppercase
		return el;
	else
		return getParent(el.parentNode, pTagName);
}
function ts_sort_date(a,b) {
    // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa.length == 10) {
        dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
    } else {
        yr = aa.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
    }
    if (bb.length == 10) {
        dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
    } else {
        yr = bb.substr(6,2);
        if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; }
        dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
    }
    if (dt1==dt2) return 0;
    if (dt1<dt2) return -1;
    return 1;
}

function ts_sort_currency(a,b) { 
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,'');
    return parseFloat(aa) - parseFloat(bb);
}

function ts_sort_numeric(a,b) { 
    aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX]));
    if (isNaN(aa)) aa = 0;
    bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); 
    if (isNaN(bb)) bb = 0;
    return aa-bb;
}

function ts_sort_caseinsensitive(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase();
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase();
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}

function ts_sort_default(a,b) {
    aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]);
    bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]);
    if (aa==bb) return 0;
    if (aa<bb) return -1;
    return 1;
}


function addEvent(elm, evType, fn, useCapture)
// addEvent and removeEvent
// cross-browser event handling for IE5+,  NS6 and Mozilla
// By Scott Andrew
{
  if (elm.addEventListener){
    elm.addEventListener(evType, fn, useCapture);
    return true;
  } else if (elm.attachEvent){
    var r = elm.attachEvent("on"+evType, fn);
    return r;
  } else {
    alert("Handler could not be removed");
  }
} 
/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* Version 1.5.4.1 (2007-01-05)
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) {},
			onElementValidate : function(result, elm) {}
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
		}
		this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					switch (elm.type.toLowerCase()) {
						case 'checkbox':
						case 'radio':
							var p = elm.parentNode;
							if(p) {
								new Insertion.Bottom(p, advice);
							} else {
								new Insertion.After(elm, advice);
							}
							break;
						default:
							new Insertion.After(elm, advice);
				    }
					advice = Validation.getAdvice(name, elm);
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', 'This is a required field.', function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', 'Please enter a valid number in this field.', function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', 'Please use numbers only in this field. please avoid spaces or other characters such as dots or commas.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', 'Please use letters only (a-z) in this field.', function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', 'Please use only letters (a-z) or numbers (0-9) only in this field. No spaces or other characters are allowed.', function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-date', 'Please enter a valid date.', function(v) {
				var test = new Date(v);
				return Validation.get('IsEmpty').test(v) || !isNaN(test);
			}],
	['validate-email', 'Please enter a valid email address. For example fred@domain.com .', function (v) {
				return Validation.get('IsEmpty').test(v) || /\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/.test(v)
			}],
	['validate-url', 'Please enter a valid URL.', function (v) {
				return Validation.get('IsEmpty').test(v) || /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', 'Please use this date format: dd/mm/yyyy. For example 17/03/2006 for the 17th of March, 2006.', function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-currency-dollar', 'Please enter a valid $ amount. For example $100.00 .', function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
	['validate-selection', 'Please make a selection', function(v,elm){
				return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
			}],
	['validate-one-required', 'Please select one of the above options.', function (v,elm) {
				var p = elm.parentNode;
				var options = p.getElementsByTagName('INPUT');
				return $A(options).any(function(elm) {
					return $F(elm);
				});
			}]
]);/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
/*=:project
    scalable Inman Flash Replacement (sIFR) version 3, beta 1

  =:file
    Copyright: 2006 Mark Wubben.
    Author: Mark Wubben, <http://novemberborn.net/>

  =:history
    * IFR: Shaun Inman
    * sIFR 1: Mike Davidson, Shaun Inman and Tomas Jogin
    * sIFR 2: Mike Davidson, Shaun Inman, Tomas Jogin and Mark Wubben

  =:license
    This software is licensed and provided under the CC-GNU LGPL.
    See <http://creativecommons.org/licenses/LGPL/2.1/>    
*/

var parseSelector=(function(){var _1=/\s*,\s*/;var _2=/\s*([\s>+~(),]|^|$)\s*/g;var _3=/([\s>+~,]|[^(]\+|^)([#.:@])/g;var _4=/^[^\s>+~]/;var _5=/[\s#.:>+~()@]|[^\s#.:>+~()@]+/g;function parseSelector(_6,_7){_7=_7||document.documentElement;var _8=_6.split(_1),_9=[];for(var i=0;i<_8.length;i++){var _b=[_7],_c=toStream(_8[i]);for(var j=0;j<_c.length;){var _e=_c[j++],_f=_c[j++],_10="";if(_c[j]=="("){while(_c[j++]!=")"&&j<_c.length){_10+=_c[j]}_10=_10.slice(0,-1)}_b=select(_b,_e,_f,_10)}_9=_9.concat(_b)}return _9}function toStream(_11){var _12=_11.replace(_2,"$1").replace(_3,"$1*$2");if(_4.test(_12)){_12=" "+_12}return _12.match(_5)||[]}function select(_13,_14,_15,_16){return (_17[_14])?_17[_14](_13,_15,_16):[]}var _18={toArray:function(_19){var a=[];for(var i=0;i<_19.length;i++){a.push(_19[i])}return a}};var dom={isTag:function(_1d,tag){return (tag=="*")||(tag.toLowerCase()==_1d.nodeName.toLowerCase())},previousSiblingElement:function(_1f){do{_1f=_1f.previousSibling}while(_1f&&_1f.nodeType!=1);return _1f},nextSiblingElement:function(_20){do{_20=_20.nextSibling}while(_20&&_20.nodeType!=1);return _20},hasClass:function(_21,_22){return (_22.className||"").match("(^|\\s)"+_21+"(\\s|$)")},getByTag:function(tag,_24){return _24.getElementsByTagName(tag)}};var _17={"#":function(_25,_26){for(var i=0;i<_25.length;i++){if(_25[i].getAttribute("id")==_26){return [_25[i]]}}return []}," ":function(_28,_29){var _2a=[];for(var i=0;i<_28.length;i++){_2a=_2a.concat(_18.toArray(dom.getByTag(_29,_28[i])))}return _2a},">":function(_2c,_2d){var _2e=[];for(var i=0,_30;i<_2c.length;i++){_30=_2c[i];for(var j=0,_32;j<_30.childNodes.length;j++){_32=_30.childNodes[j];if(_32.nodeType==1&&dom.isTag(_32,_2d)){_2e.push(_32)}}}return _2e},".":function(_33,_34){var _35=[];for(var i=0,_37;i<_33.length;i++){_37=_33[i];if(dom.hasClass([_34],_37)){_35.push(_37)}}return _35},":":function(_38,_39,_3a){return (pseudoClasses[_39])?pseudoClasses[_39](_38,_3a):[]}};parseSelector.selectors=_17;parseSelector.pseudoClasses={};parseSelector.util=_18;parseSelector.dom=dom;return parseSelector})();
var sIFR=new function(){var _3b=this;var _3c="sIFR-active";var _3d="sIFR-replaced";var _3e="sIFR-flash";var _3f="sIFR-ignore";var _40="sIFR-alternate";var _41="sIFR-class";var _42="sIFR-layout";var _43="http://www.w3.org/1999/xhtml";var _44=6;var _45=126;var _46=8;var _47="SIFR-PREFETCHED";var _48=" ";this.isActive=false;this.isEnabled=true;this.hideElements=true;this.replaceNonDisplayed=false;this.preserveSingleWhitespace=false;this.fixWrap=true;this.registerEvents=true;this.setPrefetchCookie=true;this.cookiePath="/";this.domains=[];this.fromLocal=true;this.forceClear=false;this.forceWidth=false;this.fitExactly=false;this.forceTextTransform=true;this.useDomContentLoaded=true;this.debugMode=false;this.hasFlashClassSet=false;var _49=0;var _4a=false,_4b=false;var dom=new function(){this.getBody=function(){var _4d=document.getElementsByTagName("body");if(_4d.length==1){return _4d[0]}return null};this.addClass=function(_4e,_4f){if(_4f){_4f.className=((_4f.className||"")==""?"":_4f.className+" ")+_4e}};this.removeClass=function(_50,_51){if(_51){_51.className=_51.className.replace(new RegExp("(^|\\s)"+_50+"(\\s|$)"),"").replace(/^\s+|(\s)\s+/g,"$1")}};this.hasClass=function(_52,_53){return new RegExp("(^|\\s)"+_52+"(\\s|$)").test(_53.className)};this.create=function(_54){if(document.createElementNS){return document.createElementNS(_43,_54)}return document.createElement(_54)};this.setInnerHtml=function(_55,_56){if(ua.innerHtmlSupport){_55.innerHTML=_56}else{if(ua.xhtmlSupport){_56=["<root xmlns=\"",_43,"\">",_56,"</root>"].join("");var xml=(new DOMParser()).parseFromString(_56,"text/xml");xml=document.importNode(xml.documentElement,true);while(_55.firstChild){_55.removeChild(_55.firstChild)}while(xml.firstChild){_55.appendChild(xml.firstChild)}}}};this.getComputedStyle=function(_58,_59){var _5a;if(document.defaultView&&document.defaultView.getComputedStyle){_5a=document.defaultView.getComputedStyle(_58,null)[_59]}else{if(_58.currentStyle){_5a=_58.currentStyle[_59]}}return _5a||""};this.getStyleAsInt=function(_5b,_5c,_5d){var _5e=this.getComputedStyle(_5b,_5c);if(_5d&&!/px$/.test(_5e)){return 0}_5e=parseInt(_5e);return isNaN(_5e)?0:_5e};this.getZoom=function(){return _5f.zoom.getLatest()}};this.dom=dom;var ua=new function(){var ua=navigator.userAgent.toLowerCase();var _62=(navigator.product||"").toLowerCase();this.macintosh=ua.indexOf("mac")>-1;this.windows=ua.indexOf("windows")>-1;this.quicktime=false;this.opera=ua.indexOf("opera")>-1;this.konqueror=_62.indexOf("konqueror")>-1;this.ie=false/*@cc_on || true @*/;this.ieSupported=this.ie&&!/ppc|smartphone|iemobile|msie\s5\.5/.test(ua)/*@cc_on && @_jscript_version >= 5.5 @*/;this.ieWin=this.ie&&this.windows/*@cc_on && @_jscript_version >= 5.1 @*/;this.windows=this.windows&&(!this.ie||this.ieWin);this.ieMac=this.ie&&this.macintosh/*@cc_on && @_jscript_version < 5.1 @*/;this.macintosh=this.macintosh&&(!this.ie||this.ieMac);this.safari=ua.indexOf("safari")>-1;this.webkit=ua.indexOf("applewebkit")>-1&&!this.konqueror;this.khtml=this.webkit||this.konqueror;this.gecko=!this.webkit&&_62=="gecko";this.operaVersion=this.opera&&/.*opera(\s|\/)(\d+\.\d+)/.exec(ua)?parseInt(RegExp.$2):0;this.webkitVersion=this.webkit&&/.*applewebkit\/(\d+).*/.exec(ua)?parseInt(RegExp.$1):0;this.geckoBuildDate=this.gecko&&/.*gecko\/(\d{8}).*/.exec(ua)?parseInt(RegExp.$1):0;this.konquerorVersion=this.konqueror&&/.*konqueror\/(\d\.\d).*/.exec(ua)?parseInt(RegExp.$1):0;this.flashVersion=0;if(this.ieWin){var axo;var _64=false;try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7")}catch(e){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");this.flashVersion=6;axo.AllowScriptAccess="always"}catch(e){_64=this.flashVersion==6}if(!_64){try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash")}catch(e){}}}if(!_64&&axo){this.flashVersion=parseFloat(/([\d,?]+)/.exec(axo.GetVariable("$version"))[1].replace(/,/g,"."))}}else{if(navigator.plugins&&navigator.plugins["Shockwave Flash"]){var _65=navigator.plugins["Shockwave Flash"];this.flashVersion=parseFloat(/(\d+\.?\d*)/.exec(_65.description)[1]);var i=0;while(this.flashVersion>=_46&&i<navigator.mimeTypes.length){var _67=navigator.mimeTypes[i];if(_67.type=="application/x-shockwave-flash"&&_67.enabledPlugin.description.toLowerCase().indexOf("quicktime")>-1){this.flashVersion=0;this.quicktime=true}i++}}}this.flash=this.flashVersion>=_46;this.transparencySupport=this.macintosh||this.windows;this.computedStyleSupport=this.ie||document.defaultView&&document.defaultView.getComputedStyle&&(!this.gecko||this.geckoBuildDate>=20030624);this.css=true;if(this.computedStyleSupport){try{var _68=document.getElementsByTagName("head")[0];_68.style.backgroundColor="#FF0000";var _69=dom.getComputedStyle(_68,"backgroundColor");this.css=!_69||/\#F{2}0{4}|rgb\(255,\s?0,\s?0\)/i.test(_69);_68=null}catch(e){}}this.xhtmlSupport=!!window.DOMParser&&!!document.importNode;this.innerHtmlSupport;try{var n=dom.create("span");if(!this.ieMac){n.innerHTML="x"}this.innerHtmlSupport=n.innerHTML=="x"}catch(e){this.innerHtmlSupport=false}this.zoomSupport=!!(this.opera&&document.documentElement);this.geckoXml=this.gecko&&(document.contentType||"").indexOf("xml")>-1;this.requiresPrefetch=this.ieWin||this.khtml;this.verifiedKonqueror=false;this.supported=this.flash&&this.css&&(!this.ie||this.ieSupported)&&(!this.opera||this.operaVersion>=8)&&(!this.webkit||this.webkitVersion>=412)&&(!this.konqueror||this.konquerorVersion>3.5)&&this.computedStyleSupport&&(this.innerHtmlSupport||!this.khtml&&this.xhtmlSupport)};this.ua=ua;var _6b=new function(){function capitalize($){return $.toUpperCase()}this.normalize=function(str){if(_3b.preserveSingleWhitespace){return str.replace(/\s/g,_48)}return str.replace(/(\s)\s+/g,"$1")};this.textTransform=function(_6e,str){switch(_6e){case "uppercase":str=str.toUpperCase();break;case "lowercase":str=str.toLowerCase();break;case "capitalize":var _70=str;str=str.replace(/^\w|\s\w/g,capitalize);if(str.indexOf("function capitalize")!=-1){var _71=_70.replace(/(^|\s)(\w)/g,"$1$1$2$2").split(/^\w|\s\w/g);str="";for(var i=0;i<_71.length;i++){str+=_71[i].charAt(0).toUpperCase()+_71[i].substring(1)}}break}return str};this.toHexString=function(str){if(typeof (str)!="string"||!str.charAt(0)=="#"||str.length!=4&&str.length!=7){return str}str=str.replace(/#/,"");if(str.length==3){str=str.replace(/(.)(.)(.)/,"$1$1$2$2$3$3")}return "0x"+str};this.toJson=function(obj){var _75="";switch(typeof (obj)){case "string":_75="\""+obj+"\"";break;case "number":case "boolean":_75=obj.toString();break;case "object":_75=[];for(var _76 in obj){if(obj[_76]==Object.prototype[_76]){continue}_75.push("\""+_76+"\":"+_6b.toJson(obj[_76]))}_75="{"+_75.join(",")+"}";break}return _75};this.convertCssArg=function(arg){if(!arg){return {}}if(typeof (arg)=="object"){if(arg.constructor==Array){arg=arg.join("")}else{return arg}}var obj={};var _79=arg.split("}");for(var i=0;i<_79.length;i++){var $=_79[i].match(/([^\s{]+)\s*\{(.+)\s*;?\s*/);if(!$||$.length!=3){continue}if(!obj[$[1]]){obj[$[1]]={}}var _7c=$[2].split(";");for(var j=0;j<_7c.length;j++){var $2=_7c[j].match(/\s*([^:\s]+)\s*\:\s*([^\s;]+)/);if(!$2||$2.length!=3){continue}obj[$[1]][$2[1]]=$2[2]}}return obj};this.extractFromCss=function(css,_80,_81,_82){var _83=null;if(css&&css[_80]&&css[_80][_81]){_83=css[_80][_81];if(_82){delete css[_80][_81]}}return _83};this.cssToString=function(arg){var css=[];for(var _86 in arg){var _87=arg[_86];if(_87==Object.prototype[_86]){continue}css.push(_86,"{");for(var _88 in _87){if(_87[_88]==Object.prototype[_88]){continue}css.push(_88,":",_87[_88],";")}css.push("}")}return escape(css.join(""))}};this.util=_6b;var _5f={};_5f.fragmentIdentifier=new function(){this.fix=true;var _89;this.cache=function(){_89=document.title};function doFix(){document.title=_89}this.restore=function(){if(this.fix){setTimeout(doFix,0)}}};_5f.synchronizer=new function(){this.isBlocked=false;this.block=function(){this.isBlocked=true};this.unblock=function(){this.isBlocked=false;_8a.replaceAll()}};_5f.zoom=new function(){var _8b=100;this.getLatest=function(){return _8b};if(ua.zoomSupport&&ua.opera){var _8c=document.createElement("div");_8c.style.position="fixed";_8c.style.left="-65536px";_8c.style.top="0";_8c.style.height="100%";_8c.style.width="1px";_8c.style.zIndex="-32";document.documentElement.appendChild(_8c);function updateZoom(){if(!_8c){return}var _8d=window.innerHeight/_8c.offsetHeight;var _8e=Math.round(_8d*100)%10;if(_8e>5){_8d=Math.round(_8d*100)+10-_8e}else{_8d=Math.round(_8d*100)-_8e}_8b=isNaN(_8d)?100:_8d;_5f.synchronizer.unblock();document.documentElement.removeChild(_8c);_8c=null}_5f.synchronizer.block();setTimeout(updateZoom,54)}};this.hacks=_5f;var _8f={kwargs:[],replaceAll:function(){for(var i=0;i<this.kwargs.length;i++){_3b.replace(this.kwargs[i])}this.kwargs=[]}};var _8a={kwargs:[],replaceAll:_8f.replaceAll};function isValidDomain(){if(_3b.domains.length==0){return true}var _91="";try{_91=document.domain}catch(e){}if(_3b.fromLocal&&sIFR.domains[0]!="localhost"){sIFR.domains.unshift("localhost")}for(var i=0;i<_3b.domains.length;i++){if(_3b.domains[i]=="*"||_3b.domains[i]==_91){return true}}return false}this.activate=function(){if(!ua.supported||!this.isEnabled||this.isActive||!isValidDomain()){return}this.isActive=true;if(this.hideElements){this.setFlashClass()}if(ua.ieWin&&_5f.fragmentIdentifier.fix&&window.location.hash!=""){_5f.fragmentIdentifier.cache()}else{_5f.fragmentIdentifier.fix=false}if(!this.registerEvents){return}function handler(evt){_3b.initialize();if(evt&&evt.type=="load"){if(document.removeEventListener){document.removeEventListener("DOMContentLoaded",handler,false);document.removeEventListener("load",handler,false)}if(window.removeEventListener){window.removeEventListener("load",handler,false)}}}if(window.addEventListener){if(_3b.useDomContentLoaded&&ua.gecko){document.addEventListener("DOMContentLoaded",handler,false)}window.addEventListener("load",handler,false)}else{if(ua.ieWin){if(_3b.useDomContentLoaded&&!_4a){document.write("<scr"+"ipt id=__sifr_ie_onload defer src=//:></script>");document.getElementById("__sifr_ie_onload").onreadystatechange=function(){if(this.readyState=="complete"){handler();this.removeNode()}}}window.attachEvent("onload",handler)}}};this.setFlashClass=function(){if(this.hasFlashClassSet){return}dom.addClass(_3c,dom.getBody()||document.documentElement);this.hasFlashClassSet=true};this.removeFlashClass=function(){if(!this.hasFlashClassSet){return}dom.removeClass(_3c,dom.getBody());dom.removeClass(_3c,document.documentElement);this.hasFlashClassSet=false};this.initialize=function(){if(_4b||!this.isActive||!this.isEnabled){return}_4b=true;_8f.replaceAll();clearPrefetch()};function getSource(src){if(typeof (src)!="string"){if(src.src){src=src.src}if(typeof (src)!="string"){var _95=[];for(var _96 in src){if(src[_96]!=Object.prototype[_96]){_95.push(_96)}}_95.sort().reverse();var _97="";var i=-1;while(!_97&&++i<_95.length){if(parseFloat(_95[i])<=ua.flashVersion){_97=src[_95[i]]}}src=_97}}if(!src&&_3b.debugMode){throw new Error("sIFR: Could not determine appropriate source")}if(ua.ie&&src.charAt(0)=="/"){src=window.location.toString().replace(/([^:]+)(:\/?\/?)([^\/]+).*/,"$1$2$3")+src}return src}this.prefetch=function(){if(!ua.requiresPrefetch||!ua.supported||!this.isEnabled||!isValidDomain()){return}if(this.setPrefetchCookie&&new RegExp(";?"+_47+"=true;?").test(document.cookie)){return}try{_4a=true;if(ua.ieWin){prefetchIexplore(arguments)}else{prefetchLight(arguments)}if(this.setPrefetchCookie){document.cookie=_47+"=true;path="+this.cookiePath}}catch(e){if(_3b.debugMode){throw e}}};function prefetchIexplore(_99){for(var i=0;i<_99.length;i++){document.write("<embed src=\""+getSource(_99[i])+"\" sIFR-prefetch=\"true\" style=\"display:none;\">")}}function prefetchLight(_9b){for(var i=0;i<_9b.length;i++){new Image().src=getSource(_9b[i])}}function clearPrefetch(){if(!ua.ieWin||!_4a){return}try{var _9d=document.getElementsByTagName("embed");for(var i=_9d.length-1;i>=0;i--){var _9f=_9d[i];if(_9f.getAttribute("sIFR-prefetch")=="true"){_9f.parentNode.removeChild(_9f)}}}catch(e){}}function getRatio(_a0){if(_a0<=10){return 1.55}if(_a0<=19){return 1.45}if(_a0<=32){return 1.35}if(_a0<=71){return 1.3}return 1.25}function getFilters(obj){var _a2=[];for(var _a3 in obj){if(obj[_a3]==Object.prototype[_a3]){continue}var _a4=obj[_a3];_a3=[_a3.replace(/filter/i,"")+"Filter"];for(var _a5 in _a4){if(_a4[_a5]==Object.prototype[_a5]){continue}_a3.push(_a5+":"+escape(_6b.toJson(_6b.toHexString(_a4[_a5]))))}_a2.push(_a3.join(","))}return _a2.join(";")}this.replace=function(_a6,_a7){if(!ua.supported){return}if(_a7){for(var _a8 in _a6){if(typeof (_a7[_a8])=="undefined"){_a7[_a8]=_a6[_a8]}}_a6=_a7}if(!_4b){return _8f.kwargs.push(_a6)}if(_5f.synchronizer.isBlocked){return _8a.kwargs.push(_a6)}var _a9=_a6.elements;if(!_a9&&parseSelector){_a9=parseSelector(_a6.selector)}if(_a9.length==0){return}this.setFlashClass();var src=getSource(_a6.src);var css=_6b.convertCssArg(_a6.css);var _ac=getFilters(_a6.filters);var _ad=(_a6.forceClear==null)?_3b.forceClear:_a6.forceClear;var _ae=(_a6.fitExactly==null)?_3b.fitExactly:_a6.fitExactly;var _af=_ae||(_a6.forceWidth==null?_3b.forceWidth:_a6.forceWidth);var _b0=parseInt(_6b.extractFromCss(css,".sIFR-root","leading"))||0;var _b1=_6b.extractFromCss(css,".sIFR-root","background-color",true)||"#FFFFFF";var _b2=_6b.extractFromCss(css,".sIFR-root","opacity",true)||"100";if(parseFloat(_b2)<1){_b2=100*parseFloat(_b2)}var _b3=_6b.extractFromCss(css,".sIFR-root","kerning",true)||"";var _b4=_a6.gridFitType||_6b.extractFromCss(css,".sIFR-root","text-align")=="right"?"subpixel":"pixel";var _b5=_3b.forceTextTransform?_6b.extractFromCss(css,".sIFR-root","text-transform",true)||"none":"none";var _b6="";if(_ae){_6b.extractFromCss(css,".sIFR-root","text-align",true)}if(!_a6.modifyCss){_b6=_6b.cssToString(css)}var _b7=_a6.wmode||"";if(_b7=="transparent"){if(!ua.transparencySupport){_b7="opaque"}else{_b1="transparent"}}for(var i=0;i<_a9.length;i++){var _b9=_a9[i];if(!ua.verifiedKonqueror){if(dom.getComputedStyle(_b9,"lineHeight").match(/e\+08px/)){ua.supported=_3b.isEnabled=false;this.removeFlashClass();return}ua.verifiedKonqueror=true}if(dom.hasClass(_3d,_b9)||dom.hasClass(_3f,_b9)){continue}var _ba=false;if(!_b9.offsetHeight||!_b9.offsetWidth){if(!_3b.replaceNonDisplayed){continue}_b9.style.display="block";if(!_b9.offsetHeight||!_b9.offsetWidth){_b9.style.display="";continue}_ba=true}if(_ad&&ua.gecko){_b9.style.clear="both"}var _bb=null;if(_3b.fixWrap&&ua.ie&&dom.getComputedStyle(_b9,"display")=="block"){_bb=_b9.innerHTML;dom.setInnerHtml(_b9,"X")}var _bc=dom.getStyleAsInt(_b9,"width",ua.ie);if(ua.ie&&_bc==0){var _bd=dom.getStyleAsInt(_b9,"paddingRight",true);var _be=dom.getStyleAsInt(_b9,"paddingLeft",true);var _bf=dom.getStyleAsInt(_b9,"borderRightWidth",true);var _c0=dom.getStyleAsInt(_b9,"borderLeftWidth",true);_bc=_b9.offsetWidth-_be-_bd-_c0-_bf}if(_bb&&_3b.fixWrap&&ua.ie){dom.setInnerHtml(_b9,_bb)}var _c1,_c2;if(!ua.ie){_c1=dom.getStyleAsInt(_b9,"lineHeight");_c2=Math.floor(dom.getStyleAsInt(_b9,"height")/_c1)}else{if(ua.ie){var _bb=_b9.innerHTML;_b9.style.visibility="visible";_b9.style.overflow="visible";_b9.style.position="static";_b9.style.zoom="normal";_b9.style.writingMode="lr-tb";_b9.style.width=_b9.style.height="auto";_b9.style.maxWidth=_b9.style.maxHeight=_b9.style.styleFloat="none";var _c3=_b9;var _c4=_b9.currentStyle.hasLayout;if(_c4){dom.setInnerHtml(_b9,"<div class=\""+_42+"\">X<br />X<br />X</div>");_c3=_b9.firstChild}else{dom.setInnerHtml(_b9,"X<br />X<br />X")}var _c5=_c3.getClientRects();_c1=_c5[1].bottom-_c5[1].top;_c1=Math.ceil(_c1*0.8);if(_c4){dom.setInnerHtml(_b9,"<div class=\""+_42+"\">"+_bb+"</div>");_c3=_b9.firstChild}else{dom.setInnerHtml(_b9,_bb)}_c5=_c3.getClientRects();_c2=_c5.length;if(_c4){dom.setInnerHtml(_b9,_bb)}_b9.style.visibility=_b9.style.width=_b9.style.height=_b9.style.maxWidth=_b9.style.maxHeight=_b9.style.overflow=_b9.style.styleFloat=_b9.style.position=_b9.style.zoom=_b9.style.writingMode=""}}if(_ba){_b9.style.display=""}if(_ad&&ua.gecko){_b9.style.clear=""}_c1=Math.max(_44,_c1);_c1=Math.min(_45,_c1);if(isNaN(_c2)||!isFinite(_c2)){_c2=1}var _c6=Math.round(_c2*_c1);if(_c2>1&&_b0){_c6+=Math.round((_c2-1)*_b0)}var _c7=dom.create("span");_c7.className=_40;var _c8=_b9.cloneNode(true);for(var j=0,l=_c8.childNodes.length;j<l;j++){_c7.appendChild(_c8.childNodes[j].cloneNode(true))}if(_a6.modifyContent){_a6.modifyContent(_c8,_a6.selector)}if(_a6.modifyCss){_b6=_a6.modifyCss(css,_c8,_a6.selector)}var _cb=handleContent(_c8,_b5);if(_a6.modifyContentString){_cb=_a6.modifyContentString(_cb,_a6.selector)}if(_cb==""){continue}var _cc=["content="+_cb.replace(/\</g,"&lt;").replace(/>/g,"&gt;"),"width="+_bc,"height="+_c6,"fitexactly="+(_ae?"true":""),"tunewidth="+(_a6.tuneWidth||""),"tuneheight="+(_a6.tuneHeight||""),"offsetleft="+(_a6.offsetLeft||""),"offsettop="+(_a6.offsetTop||""),"thickness="+(_a6.thickness||""),"sharpness="+(_a6.sharpness||""),"kerning="+_b3,"gridfittype="+_b4,"zoomsupport="+ua.zoomSupport,"filters="+_ac,"opacity="+_b2,"blendmode="+(_a6.blendMode||""),"size="+_c1,"zoom="+dom.getZoom(),"css="+_b6];_cc=encodeURI(_cc.join("&amp;"));var _cd="sIFR_callback_"+_49++;var _ce={flashNode:null};window[_cd+"_DoFSCommand"]=(function(_cf){return function(_d0,arg){if(/(FSCommand\:)?resize/.test(_d0)){var $=arg.split(":");_cf.flashNode.setAttribute($[0],$[1]);if(ua.khtml){_cf.flashNode.innerHTML+=""}}}})(_ce);_c6=Math.round(_c2*getRatio(_c1)*_c1);var _d3=_af?_bc:"100%";var _d4;if(ua.ie){_d4=["<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" id=\"",_cd,"\" sifr=\"true\" width=\"",_d3,"\" height=\"",_c6,"\" class=\"",_3e,"\">","<param name=\"movie\" value=\"",src,"\"></param>","<param name=\"flashvars\" value=\"",_cc,"\"></param>","<param name=\"allowScriptAccess\" value=\"always\"></param>","<param name=\"quality\" value=\"best\"></param>","<param name=\"wmode\" value=\"",_b7,"\"></param>","<param name=\"bgcolor\" value=\"",_b1,"\"></param>","<param name=\"name\" value=\"",_cd,"\"></param>","</object>","<scr","ipt event=FSCommand(info,args) for=",_cd,">",_cd,"_DoFSCommand(info, args);","</","script>"].join("")}else{_d4=["<embed class=\"",_3e,"\" type=\"application/x-shockwave-flash\" src=\"",src,"\" quality=\"best\" flashvars=\"",_cc,"\" width=\"",_d3,"\" height=\"",_c6,"\" wmode=\"",_b7,"\" bgcolor=\"",_b1,"\" name=\"",_cd,"\" allowScriptAccess=\"always\" sifr=\"true\"></embed>"].join("")}dom.setInnerHtml(_b9,_d4);_ce.flashNode=_b9.firstChild;_b9.appendChild(_c7);dom.addClass(_3d,_b9);if(_a6.onReplacement){_a6.onReplacement(_ce.flashNode)}}_5f.fragmentIdentifier.restore()};function handleContent(_d5,_d6){var _d7=[],_d8=[];var _d9=_d5.childNodes;var i=0;while(i<_d9.length){var _db=_d9[i];if(_db.nodeType==3){var _dc=_6b.normalize(_db.nodeValue);_dc=_6b.textTransform(_d6,_dc);_d8.push(_dc.replace(/\%/g,"%25").replace(/\&/g,"%26").replace(/\,/g,"%2C").replace(/\+/g,"%2B"))}if(_db.nodeType==1){var _dd=[];var _de=_db.nodeName.toLowerCase();var _df=_db.className||"";if(/\s+/.test(_df)){if(_df.indexOf(_41)){_df=_df.match("(\\s|^)"+_41+"-([^\\s$]*)(\\s|$)")[2]}else{_df=_df.match(/^([^\s]+)/)[1]}}if(_df!=""){_dd.push("class=\""+_df+"\"")}if(_de=="a"){var _e0=_db.getAttribute("href")||"";var _e1=_db.getAttribute("target")||"";_dd.push("href=\""+_e0+"\"","target=\""+_e1+"\"")}_d8.push("<"+_de+(_dd.length>0?" ":"")+escape(_dd.join(" "))+">");if(_db.hasChildNodes()){_d7.push(i);i=0;_d9=_db.childNodes;continue}else{if(!/^(br|img)$/i.test(_db.nodeName)){_d8.push("</",_db.nodeName.toLowerCase(),">")}}}if(_d7.length>0&&!_db.nextSibling){do{i=_d7.pop();_d9=_db.parentNode.parentNode.childNodes;_db=_d9[i];if(_db){_d8.push("</",_db.nodeName.toLowerCase(),">")}}while(i<_d9.length&&_d7.length>0)}i++}return _d8.join("").replace(/\n|\r/g,"")}};// LUX WINDOWS APPLICATION JS
// ==========================

var Lux = Class.create();
Lux.prototype = {
	initialize: function() {
		this.embedFlashMasthead();
		//this.embedFlashLogo();
		this.replaceSifrHeadings();
		this.enableNavImageReplacement();
		this.fixIEBGFlicker();
	},
	tokenizeURL: function(){
		var url = location.pathname.toString();
		var url_array = url.split('/');
		this.section = url_array[1] || '';
		this.category = url_array[2] || '';
		this.item = url_array[3] || '';
		//alert(url);
	},
	embedFlashMasthead: function(){
		this.tokenizeURL();

		if($('banner')){
			
			if(this.section == ''){
				var flash = new SWFObject("/flash/homepage_banner.swf", "Lux Banner", "950", "393", "7", "#FFF");
			}else{
				var flash = new SWFObject("/flash/gallery_banner.swf", "Lux Banner", "950", "337", "7", "#FFF");
			}
			flash.addParam("wmode", "opaque");
			flash.addVariable('xSection', 	this.section);
			if(this.category != ''){flash.addVariable('xCategory', 	this.category);}
			if(this.item != ''){flash.addVariable('xItem', 	this.item);}
			flash.write("banner");
		}
	},
	
	embedFlashLogo: function(){
		if($('logo')){
			var flash = new SWFObject("/flash/lux_logo.swf", "Lux Windows", "118", "118", "7", "#FFF");
			flash.addParam("wmode", "transparent");
			flash.write("logo");
		}
	},
	
	enableNavImageReplacement: function(){
		var subnavlinks = $$('.sublevel a');
		subnavlinks.each(function(link){
			link.innerHTML = '<span>'+ link.innerHTML +'</span>';
		});
	},
	
	fixIEBGFlicker: function(){
		try {
		  document.execCommand('BackgroundImageCache', false, true);
		} catch(e) {}	
	},
	
	replaceSifrHeadings: function(){

	}


}

var HoverBehavior = Class.create();
HoverBehavior.prototype = {
  initialize: function() {
    $A(document.styleSheets).each( function(stylesheet) {
      $A(stylesheet.rules).each( function(rule) {
        if( rule.selectorText.match(/:hover/i) ) {
          stylesheet.addRule( rule.selectorText.replace(/:hover/ig, '.hover'), rule.style.cssText );
        }
      });
    });

    $A(arguments).each( function(arg) {
      $$(arg).each( function(tag) {
        Event.observe(tag, 'mouseover', function() { Element.addClassName(tag, 'hover'); });
        Event.observe(tag, 'mouseout', function() { Element.removeClassName(tag, 'hover'); });
      });
    });
  }
};




var ResizingTextArea = Class.create();
ResizingTextArea.prototype = {
    defaultRows: 1,
    initialize: function(field){
        this.defaultRows = Math.max(field.rows, 1);
        this.resizeNeeded = this.resizeNeeded.bindAsEventListener(this);
        Event.observe(field, "click", this.resizeNeeded);
        Event.observe(field, "keyup", this.resizeNeeded);
    },

    resizeNeeded: function(event){
        var t = Event.element(event);
        var lines = t.value.split('\n');
        var newRows = lines.length + 1;
        var oldRows = t.rows;
        for (var i = 0; i < lines.length; i++){
            var line = lines[i];
            if (line.length >= t.cols) newRows += Math.floor(line.length / t.cols);
        }
        if (newRows > t.rows) t.rows = newRows;
        if (newRows < t.rows) t.rows = Math.max(this.defaultRows, newRows);
    }
}

var EmploymentHistory = Class.create();
EmploymentHistory.prototype = {
	employers: [],
	initialize: function(){
		 if($('add-new-position')){
		 	var self = this;
		 	var link = $('add-new-position');
		 	//Event.observe(link, 'click', this.addEmployer, false);
		 	link.onclick = function(){EmploymentHistory.prototype.addEmployer(); return false;}
		 }
	},
	addEmployer: function(){
			var pos = EmploymentHistory.prototype.employers.length + 2;
			var ajax = new Ajax.Request("/submissions/_prev_position.php?pos="+pos, {
				onSuccess: function(response) {
					EmploymentHistory.prototype.employers[EmploymentHistory.prototype.employers.length] = EmploymentHistory.prototype.employers.length;
					var insert = new Insertion.Bottom($('positions'), response.responseText);
					var id = 'remove'+'_'+pos;
					var remover = $(id);
					remover.onclick = function(){EmploymentHistory.prototype.removeEmployer(pos); return false;}
					var num = $('number_of_previous_positions').value = EmploymentHistory.prototype.employers.length + 1;
					//var eff = new Effect.Highlight($('position_'self.employers.length));

				},
				onFailure: function(response) {
					alert('bad url');
				}
			});
		return false;
	},
	removeEmployer: function(id){
		var employer = $('position_'+id);
		if(employer){var removed = Element.remove(employer);}
		self.employers.pop();
		$('number_of_previous_positions').value = self.employers.length + 1;
		return false;
	}
}


// Global Window Onload
Event.observe(window, 'load',
  function() {
	Lux.prototype.initialize();
	new HoverBehavior('#topmenu li');
	EmploymentHistory.prototype.initialize();
	}
);