﻿/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-12-20 08:43:48 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4257 $
 *
 * Version: 1.2
 *
 * Requires: jQuery 1.2+
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.19={P:\'1.2\'};$.u([\'j\',\'w\'],5(i,d){$.q[\'O\'+d]=5(){p(!3[0])6;g a=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';6 3.B(\':y\')?3[0][\'L\'+d]:4(3,d.x())+4(3,\'n\'+a)+4(3,\'n\'+e)};$.q[\'I\'+d]=5(b){p(!3[0])6;g c=d==\'j\'?\'s\':\'m\',e=d==\'j\'?\'D\':\'C\';b=$.F({t:Z},b||{});g a=3.B(\':y\')?3[0][\'8\'+d]:4(3,d.x())+4(3,\'E\'+c+\'w\')+4(3,\'E\'+e+\'w\')+4(3,\'n\'+c)+4(3,\'n\'+e);6 a+(b.t?(4(3,\'t\'+c)+4(3,\'t\'+e)):0)}});$.u([\'m\',\'s\'],5(i,b){$.q[\'l\'+b]=5(a){p(!3[0])6;6 a!=W?3.u(5(){3==h||3==r?h.V(b==\'m\'?a:$(h)[\'U\'](),b==\'s\'?a:$(h)[\'T\']()):3[\'l\'+b]=a}):3[0]==h||3[0]==r?S[(b==\'m\'?\'R\':\'Q\')]||$.N&&r.M[\'l\'+b]||r.A[\'l\'+b]:3[0][\'l\'+b]}});$.q.F({z:5(){g a=0,f=0,o=3[0],8,9,7,v;p(o){7=3.7();8=3.8();9=7.8();8.f-=4(o,\'K\');8.k-=4(o,\'J\');9.f+=4(7,\'H\');9.k+=4(7,\'Y\');v={f:8.f-9.f,k:8.k-9.k}}6 v},7:5(){g a=3[0].7;G(a&&(!/^A|10$/i.16(a.15)&&$.14(a,\'z\')==\'13\'))a=a.7;6 $(a)}});5 4(a,b){6 12($.11(a.17?a[0]:a,b,18))||0}})(X);',62,72,'|||this|num|function|return|offsetParent|offset|parentOffset|||||borr|top|var|window||Height|left|scroll|Left|padding|elem|if|fn|document|Top|margin|each|results|Width|toLowerCase|visible|position|body|is|Right|Bottom|border|extend|while|borderTopWidth|outer|marginLeft|marginTop|client|documentElement|boxModel|inner|version|pageYOffset|pageXOffset|self|scrollTop|scrollLeft|scrollTo|undefined|jQuery|borderLeftWidth|false|html|curCSS|parseInt|static|css|tagName|test|jquery|true|dimensions'.split('|'),0,{}))

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 * Date: 2/19/2008
 * @author Ariel Flesler
 * @version 1.3.3
 */
;(function($){var o=$.scrollTo=function(a,b,c){o.window().scrollTo(a,b,c)};o.defaults={axis:'y',duration:1};o.window=function(){return $($.browser.safari?'body':'html')};$.fn.scrollTo=function(l,m,n){if(typeof m=='object'){n=m;m=0}n=$.extend({},o.defaults,n);m=m||n.speed||n.duration;n.queue=n.queue&&n.axis.length>1;if(n.queue)m/=2;n.offset=j(n.offset);n.over=j(n.over);return this.each(function(){var a=this,b=$(a),t=l,c,d={},w=b.is('html,body');switch(typeof t){case'number':case'string':if(/^([+-]=)?\d+(px)?$/.test(t)){t=j(t);break}t=$(t,this);case'object':if(t.is||t.style)c=(t=$(t)).offset()}$.each(n.axis.split(''),function(i,f){var P=f=='x'?'Left':'Top',p=P.toLowerCase(),k='scroll'+P,e=a[k],D=f=='x'?'Width':'Height';if(c){d[k]=c[p]+(w?0:e-b.offset()[p]);if(n.margin){d[k]-=parseInt(t.css('margin'+P))||0;d[k]-=parseInt(t.css('border'+P+'Width'))||0}d[k]+=n.offset[p]||0;if(n.over[p])d[k]+=t[D.toLowerCase()]()*n.over[p]}else d[k]=t[p];if(/^\d+$/.test(d[k]))d[k]=d[k]<=0?0:Math.min(d[k],h(D));if(!i&&n.queue){if(e!=d[k])g(n.onAfterFirst);delete d[k]}});g(n.onAfter);function g(a){b.animate(d,m,n.easing,a&&function(){a.call(this,l)})};function h(D){var b=w?$.browser.opera?document.body:document.documentElement:a;return b['scroll'+D]-b['client'+D]}})};function j(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);
/*
 * SimpleModal 1.1.1 - jQuery Plugin
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://plugins.jquery.com/project/SimpleModal
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2007 Eric Martin - http://ericmmartin.com
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Revision: $Id: jquery.simplemodal.js 93 2008-01-15 16:14:20Z emartin24 $
 *
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(5($){$.8=5(a,b){9 $.8.t.B(a,b)};$.8.f=5(){$.8.t.f(J)};$.1E.8=5(a){9 $.8.t.B(1,a)};$.8.T={d:1g,P:\'1d\',1a:{},16:\'15\',12:{},f:J,10:\'1v\',u:\'1r\',H:l,C:o,z:o,L:o};$.8.t={3:o,2:{},B:5(a,b){4(1.2.6){9 l}1.3=$.w({},$.8.T,b);4(v a==\'1H\'){a=a 1F 14?a:$(a);4(a.I().I().1B()>0){1.2.r=a.I();4(!1.3.H){1.2.Y=a.1u(J)}}}c 4(v a==\'1t\'||v a==\'1q\'){a=$(\'<E>\').1o(a)}c{4(13){13.1l(\'1j 1i: 1h 6 1f: \'+v a)}9 l}1.2.6=a.A(\'1e\');a=o;1.Q();1.O();4($.F(1.3.z)){1.3.z.G(1,[1.2])}9 1},Q:5(){1.2.d=$(\'<E>\').N(\'1c\',1.3.P).A(\'1d\').q($.w(1.3.1a,{1b:1.3.d/y,x:\'y%\',n:\'y%\',m:\'19\',18:0,17:0,M:1G})).h().i(\'k\');1.2.j=$(\'<E>\').N(\'1c\',1.3.16).A(\'15\').q($.w(1.3.12,{m:\'19\',M:1C})).11(1.3.f?\'<a 1A="1z \'+1.3.u+\'" 1y="\'+1.3.10+\'"></a>\':\'\').h().i(\'k\');4($.Z.1x&&($.Z.1w<7)){1.X()}1.2.j.11(1.2.6.h())},W:5(){K a=1;$(\'.\'+1.3.u).V(5(e){e.1s();a.f()})},U:5(){$(\'.\'+1.3.u).1p(\'V\')},X:5(){K a=$(S.k).x()+\'R\';K b=$(S.k).n()+\'R\';1.2.d.q({m:\'D\',x:a,n:b});1.2.j.q({m:\'D\'});1.2.g=$(\'<g 1n="1m:l;">\').q($.w(1.3.1D,{1b:0,m:\'D\',x:a,n:b,M:1k,n:\'y%\',17:0,18:0})).h().i(\'k\')},O:5(){4(1.2.g){1.2.g.s()}4($.F(1.3.C)){1.3.C.G(1,[1.2])}c{1.2.d.s();1.2.j.s();1.2.6.s()}1.W()},f:5(a){4(!1.2.6){9 l}4($.F(1.3.L)&&!a){1.3.L.G(1,[1.2])}c{4(1.2.r){4(1.3.H){1.2.6.h().i(1.2.r)}c{1.2.6.p();1.2.Y.i(1.2.r)}}c{1.2.6.p()}1.2.j.p();1.2.d.p();4(1.2.g){1.2.g.p()}1.2={}}1.U()}}})(14);',62,106,'|this|dialog|opts|if|function|data||modal|return|||else|overlay||close|iframe|hide|appendTo|container|body|false|position|width|null|remove|css|parentNode|show|impl|closeClass|typeof|extend|height|100|onShow|addClass|init|onOpen|absolute|div|isFunction|apply|persist|parent|true|var|onClose|zIndex|attr|open|overlayId|create|px|document|defaults|unbindEvents|click|bindEvents|fixIE|original|browser|closeTitle|append|containerCss|console|jQuery|modalContainer|containerId|top|left|fixed|overlayCss|opacity|id|modalOverlay|modalData|type|50|Unsupported|Error|SimpleModal|1000|log|javascript|src|html|unbind|number|modalClose|preventDefault|string|clone|Close|version|msie|title|modalCloseImg|class|size|2000|iframeCss|fn|instanceof|3|object'.split('|'),0,{}))


/**
* EasyDrag 1.4 - Drag & Drop jQuery Plug-in
*
* Thanks for the community that is helping the improvement
* of this little piece of code.
*
* For usage instructions please visit http://fromvega.com
*/

;(function($){

	// to track if the mouse button is pressed
	var isMouseDown    = false;

	// to track the current element being dragged
	var currentElement = null;

	// callback holders
	var dropCallbacks = {};
	var dragCallbacks = {};

	// global position records
	var lastMouseX;
	var lastMouseY;
	var lastElemTop;
	var lastElemLeft;
	
	// track element dragStatus
	var dragStatus = {};	

	// returns the mouse (cursor) current position
	$.getMousePosition = function(e){
		var posx = 0;
		var posy = 0;

		if (!e) var e = window.event;

		if (e.pageX || e.pageY) {
			posx = e.pageX;
			posy = e.pageY;
		}
		else if (e.clientX || e.clientY) {
			posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
			posy = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
		}

		return { 'x': posx, 'y': posy };
	};

	// updates the position of the current element being dragged
	$.updatePosition = function(e) {
		var pos = $.getMousePosition(e);

		var spanX = (pos.x - lastMouseX);
		var spanY = (pos.y - lastMouseY);


    var halfHeight = $(currentElement).parent().height()/2;
    var halfWidth = $(currentElement).parent().width()/2;
    
		$(currentElement).parent().css("top",  (lastElemTop + spanY) + halfHeight);
		$(currentElement).parent().css("left", (lastElemLeft + spanX) + halfWidth);
	};

	// when the mouse is moved while the mouse button is pressed
	$(document).mousemove(function(e){
		if(isMouseDown && dragStatus[currentElement.id] == 'on'){
			// update the position and call the registered function
			$.updatePosition(e);
			if(dragCallbacks[currentElement.id] != undefined){
				dragCallbacks[currentElement.id](e, currentElement);
			}

			return false;
		}
	});

	// when the mouse button is released
	$(document).mouseup(function(e){
		if(isMouseDown && dragStatus[currentElement.id] == 'on'){
			isMouseDown = false;
			if(dropCallbacks[currentElement.id] != undefined){
				dropCallbacks[currentElement.id](e, currentElement);
			}

			return false;
		}
	});

	// register the function to be called while an element is being dragged
	$.fn.ondrag = function(callback){
		return this.each(function(){
			dragCallbacks[this.id] = callback;
		});
	};

	// register the function to be called when an element is dropped
	$.fn.ondrop = function(callback){
		return this.each(function(){
			dropCallbacks[this.id] = callback;
		});
	};
	
	// stop the element dragging feature
	$.fn.dragOff = function(){
		return this.each(function(){
			dragStatus[this.id] = 'off';
		});
	};
	
	
	$.fn.dragOn = function(){
		return this.each(function(){
			dragStatus[this.id] = 'on';
		});
	};

	// set an element as draggable - allowBubbling enables/disables event bubbling
	$.fn.easydrag = function(allowBubbling){

		return this.each(function(){

			// if no id is defined assign a unique one
			if(undefined == this.id || !this.id.length) this.id = "easydrag"+(new Date().getTime());

			// set dragStatus 
			dragStatus[this.id] = "on";
			
			// change the mouse pointer
			$(this).css("cursor", "move");

			// when an element receives a mouse press
			$(this).mousedown(function(e){

				// update track variables
				isMouseDown    = true;
				currentElement = this;

				// retrieve positioning properties
				var pos    = $.getMousePosition(e);
				lastMouseX = pos.x;
				lastMouseY = pos.y;

				lastElemTop  = $(currentElement).parent()[0].offsetTop;
				lastElemLeft = $(currentElement).parent()[0].offsetLeft;
				
				$.updatePosition(e);

				return allowBubbling ? true : false;
			});
		});
	};

})(jQuery);


;(function($){
	
	// Give table advanced select options.
	$.fn.advancedSelect = function(checkboxSelect)
	{
	  if (typeof(checkboxSelect) == 'undefined')
	    checkboxSelect = ':checkbox';
	  
	  // Create a central controller with all the information required.  
	  var selectController = new Object();
	  selectController.selecting = false;
	  selectController.lastClickedRow = null;
	  selectController.multipleMode = false;
	  selectController.oneByOneMode = false;
	  selectController.getMode = function() {
      if (this.multipleMode)
        return 'Multiple';

      if (this.oneByOneMode)
        return 'OneByOne';
        
      return 'One';
	  };
	  selectController.keyDown = function(e) {
      switch (e.which)
      {
        case 16:
          this.multipleMode = true;
          break;
        case 17:
          this.oneByOneMode = true;
          break;
      }
    }
    selectController.keyUp = function(e) {
      switch (e.which)
      {
        case 16:
          this.multipleMode = false;
          break;
        case 17:
          this.oneByOneMode = false;
          break;
      } 
    }

    // Capture the events of the CTRL + SELECT buttons.
    $(document).keydown(selectController.keyDown.bind(selectController));
    $(document).keyup(selectController.keyUp.bind(selectController));
    
    // Bind the event for clicking on the checkbox and stop bubbling so that the row click doesn't fire.
    this.find(checkboxSelect).bind('mousedown', function(e) {
      stopEvent(e);
      
      if (this.checked)
        $(this).unselectRow();
      else
        $(this).selectRow();
      // We have to switch it again because the event fires the switch after our function, which is confusing.
      this.checked = !this.checked;
    });
    
		return this.each(function() {
		  // Disable the text select as that is a bit of an annoyance when selecting multiple rows by holding the mouse down.
		  $(this).disableTextSelect();
		  $(this).find('tbody tr')
		  .each(function(i) {
		    // Setup the settings for each row.
		    this.index = i;
        this.selectController = selectController;
        this.checkboxSelect = checkboxSelect;
        // Make sure that all currently selected checkboxes are working the correct way.
        $(this).find(checkboxSelect).each(function() {
          if (this.checked)
            $(this).selectRow();
          else
            $(this).unselectRow();
        });
		  })
		  .mousedown(function() {
        this.selectController.selecting = true;
        switch (this.selectController.getMode())
        {
          case "One":
            $(this).unselectAll();
            $(this).toggleSelectRow();
            break;
          case "OneByOne":
            $(this).toggleSelectRow();
            break;
          case "Multiple":
            $(this).selectRange(this.selectController.lastClickedRow, this.index);
            break;
        }
        // We have to set this so that the the auto selecting of multiple items works correctly, from the first item clicked.
        this.selectController.lastClickedRow = this.index;
      })
      .mouseup(function() {
        this.selectController.selecting = false;
	      this.selectController.lastClickedRow = this.index;
      })
      .mouseover(function() {
        // If we are still selecting items, select the range between the first item clicked and the current one we are hovering over.
        if (this.selectController.selecting)
        {
          $(this).selectRange(this.selectController.lastClickedRow, this.index)
        }
      })
		});
	};
			
	$.fn.toggleSelectRow = function()
	{
    if (this[0].tagName.toLowerCase() != 'tr')
    {
      // Bubble up to the table element if this isn't a table.
      if ($(this).parent().length > 0)
        $(this).parent().toggleSelectRow();
      return;
    }
    
	  return this.each(function() {
	    $(this).toggleClass('HighlightRow');
      $(this).find(this.checkboxSelect).each(function() {
        this.checked = !this.checked;
      });
	  });
	};
	
	$.fn.selectRow = function()
	{
    if (this[0].tagName.toLowerCase() != 'tr')
    {
      // Bubble up to the table element if this isn't a table row.
      if ($(this).parent().length > 0)
        $(this).parent().selectRow();
      return;
    }
    
	  return this.each(function() {
	    $(this).addClass('HighlightRow');
      $(this).find(this.checkboxSelect).each(function() {
        this.checked = true;
      });
	  });
	};
	
	$.fn.unselectRow = function()
	{
    if (this[0].tagName.toLowerCase() != 'tr')
    {
      // Bubble up to the table element if this isn't a table row.
      if ($(this).parent().length > 0)
        $(this).parent().unselectRow();
      return;
    }
    
	  return this.each(function() {
	    $(this).removeClass('HighlightRow');
      $(this).find(this.checkboxSelect).each(function() {
        this.checked = false;
      });
	  });
	};
	
	$.fn.selectAll = function()
	{
	  return this.selectRange(0,99999);
	}
	
	$.fn.unselectAll = function()
	{
	  return this.selectRange(-1,-1);
	}
	
	$.fn.selectRange = function(from, to)
	{
	  return this.each(function() {
	    if (this.tagName.toLowerCase() != 'table')
	    {
	      // Bubble up to the table element if this isn't a table.
	      if ($(this).parent().length > 0)
	        $(this).parent().selectRange(from, to);
	      return;
	    }
	    
	    $(this).find('tbody tr').each(function() {
	      // Select or unselect the row.
	      if ((this.index >= from && this.index <= to) || (this.index >= to && this.index <= from))
	      {
	        $(this).selectRow();
	      }
	      else
	      {
	        if (!this.selectController.oneByOneMode)
	          $(this).unselectRow();
	      }
	    });
	  });
	};
	
	function stopEvent(e)
  {
   if (typeof e.stopPropagation != "undefined")
   {
     e.stopPropagation();
   }
   else
   {
     e.cancelBubble = true;
   }
  }

})(jQuery);

/**
 * .disableTextSelect - Disable Text Select Plugin
 *
 * Version: 1.1
 * Updated: 2007-11-28
 *
 * Used to stop users from selecting text
 *
 * Copyright (c) 2007 James Dempster (letssurf@gmail.com, http://www.jdempster.com/category/jquery/disabletextselect/)
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/

/**
 * Requirements:
 * - jQuery (John Resig, http://www.jquery.com/)
 **/
;(function($) {
    if ($.browser.mozilla) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : 'none'
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : ''
                });
            });
        };
    } else if ($.browser.msie) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('selectstart.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('selectstart.disableTextSelect');
            });
        };
    } else {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('mousedown.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('mousedown.disableTextSelect');
            });
        };
    }
})(jQuery);

jQuery.preloadImages = function()
{
  for(var i = 0; i<arguments.length; i++)
  {
    jQuery("<img>").attr("src", arguments[i]);
  }
}