/*
  jQuery Plugin highlightFade (jquery.offput.ca/highlightFade)
  (c) 2006 Blair Mitchelmore (offput.ca) blair@offput.ca
*/
$.fn.highlightFade = function(c,d,o,t) {
  var ts = {
    'linear': function(s,e,t,c) { return parseInt(s+(c/t)*(e-s)); },
    'sinusoidal': function(s,e,t,c) { return parseInt(s+Math.sin(((c/t)*90)*(Math.PI/180))*(e-s)); },
    'exponential': function(s,e,t,c) { return parseInt(s+(Math.pow(c/t,2))*(e-s)); }
  };
  if (t && t.constructor == Function) t = t;
  else if (t && ts[t]) t = ts[t];
  else t = ts['linear'];
  return this.each(function() {
    var i = 20;
    var e = (this.highlighting) ? this.highlighting.end : $.getBGColor(this) || [255,255,255];
    var s = $.speed(d,o);
    var r = $(this).css('backgroundColor');
    if (this.highlighting && this.highlighting.end) r = this.highlighting.end;
    c = $.getRGB(c || [255,255,128]);
    if (this.highlighting && this.highlighting.timer) window.clearInterval(this.highlighting.timer);
    this.highlighting = { steps: ((s.duration) / i), interval: i, currentStep: 0, start: c, end: e, orig: r };
    $.highlightFade(this,s.onComplete,t);
  });
};
$.highlightFade = function(e,o,t) {
  e.highlighting.timer = window.setInterval(function() { 
    var newR = t(e.highlighting.start[0],e.highlighting.end[0],e.highlighting.steps,e.highlighting.currentStep);
    var newG = t(e.highlighting.start[1],e.highlighting.end[1],e.highlighting.steps,e.highlighting.currentStep);
    var newB = t(e.highlighting.start[2],e.highlighting.end[2],e.highlighting.steps,e.highlighting.currentStep);
    $(e).css('backgroundColor',$.asRGBString([newR,newG,newB]));
    if (e.highlighting.currentStep++ >= e.highlighting.steps) {
      $(e).css('backgroundColor',e.highlighting.orig || '');
      if (o && o.constructor == Function) o.call(e);
      window.clearInterval(e.highlighting.timer);
      e.highlighting = null;
    }
  },e.highlighting.interval);
};
$.getRGB = function(c,d) {
  var result;
  if (c && c.constructor == Array && c.length == 3) return c;
  if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c)) {
    return [parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];
  } else if (result = /#([a-fA-F0-9]{1})([a-fA-F0-9]{1})([a-fA-F0-9]{1})/.exec(c)) {
    return [parseInt("0x"+ result[1] + result[1]),parseInt("0x" + result[2] + result[2]),parseInt("0x" + result[3] + result[3])];
  } else if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c)) {
    return [parseInt("0x" + result[1]),parseInt("0x" + result[2]),parseInt("0x" + result[3])];
  } else {
    return $.checkColorName(c) || d || null;
  }
};
$.asRGBString = function(a) {
  return "rgb(" + a.join(",") + ")";
};
$.getBGColor = function(e) {
  var s;
  do if (((s = $.css(e,'backgroundColor')) != '' && s != 'transparent') || (e.tagName.match(/^body$/i))) break; while (e = e.parentNode);
  if (s == undefined || s == '' || s == 'transparent') s = [255,255,255];
  return $.getRGB(s);
};
$.checkColorName = function(c) {
  switch(c.replace(/^\s*|\s*$/g,'').toLowerCase()) {
    case 'aqua': return [0,255,255];
    case 'black': return [0,0,0];
    case 'blue': return [0,0,255];
    case 'fuchsia': return [255,0,255];
    case 'gray': return [128,128,128];
    case 'green': return [0,128,0];
    case 'lime': return [0,255,0];
    case 'maroon': return [128,0,0];
    case 'navy': return [0,0,128];
    case 'olive': return [128,128,0];
    case 'purple': return [128,0,128];
    case 'red': return [255,0,0];
    case 'silver': return [192,192,192];
    case 'teal': return [0,128,128];
    case 'white': return [255,255,255];
    case 'yellow': return [255,255,0];
  }
};

/*
  jQuery Plugin maxHeight
  (by WinstonDesign)
*/
jQuery.fn.maxHeight = function() {
  var options = {min_height:0, base:1, unit:'px', force:false, height_rule:"min-height", exclude:"#non-existant-id72172799"};
  var _options = arguments[0] || {};
  for(property in _options) { options[property] = _options[property]; }
  if (options.height_rule == 'min-height' && navigator.appVersion.match(/\bMSIE\b/)) options.height_rule = 'height';
  var m = options.min_height;
  return this.each(function(){
    h = $(this).css("height");
    if (h=='auto') h = this.clientHeight;
    h = parseInt(h);
    if (h > m && !options.force) m = h;
  }).not(options.exclude).css(options.height_rule, parseInt(m/options.base)+options.unit);
};