/*
 * positionBy 1.0.7 (2008-01-29)
 *
 * Copyright (c) 2006,2007 Jonathan Sharp (http://jdsharp.us)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://jdsharp.us/
 *
 * Built upon jQuery 1.2.2 (http://jquery.com)
 * This also requires the jQuery dimensions plugin
 */
(function($){
 /**
 * This function centers an absolutely positioned element
 */
 /*
 $.fn.positionCenter = function(offsetLeft, offsetTop) {
 var offsetLeft = offsetLeft || 1;
 var offsetTop = offsetTop || 1;

 var ww = $(window).width();
 var wh = $(window).height();
 var sl = $(window).scrollLeft();
 var st = $(window).scrollTop();

 return this.each(function() {
 var $t = $(this);
 
 // If we are not visible we have to display our element (with a negative position offscreen)

 var left = Math.round( ( ww - $t.outerWidth() ) / 2 );
 if ( left < 0 ) {
 left = 0;
 } else {
 left *= offsetLeft;
 }
 left += sl;
 var top = Math.round( ( wh - $t.outerHeight() ) / 2 );
 if ( top < 0 ) {
 top = 0;
 } else {
 top *= offsetTop;
 }
 top += st;

 $(this).parents().each(function() {
 var $this = $(this);
 if ( $this.css('position') != 'static' ) {
 var o = $this.offset();
 left += -o.left;
 top += -o.top;
 return false;
 }
 });

 $t.css({left: left, top: top});
 });
 };
 */
 
 // Our range object is used in calculating positions
 var Range = function(x1, y1, x2, y2) {
 this.x1 = x1; this.x2 = x2;
 this.y1 = y1; this.y2 = y2;
 };
 Range.prototype.contains = function(range) {
 return (this.x1 <= range.x1 && range.x2 <= this.x2) 
 && 
 (this.y1 <= range.y1 && range.y2 <= this.y2);
 };
 Range.prototype.transform = function(x, y) {
 return new Range(this.x1 + x, this.y1 + y, this.x2 + x, this.y2 + y);
 };

 $.fn.positionBy = function(args) {
 var date1 = new Date();
 if ( this.length == 0 ) {
 return this;
 }
 
 var args = $.extend({ // The target element to position us relative to
 target: null,
 // The target's corner, possible values 0-3
 targetPos: null,
 // The element's corner, possible values 0-3
 elementPos: null,
 
 // A raw x,y coordinate
 x: null,
 y: null,

 // Pass in an array of positions that are valid 0-15
 positions: null,

 // Add the final position class to the element (eg. positionBy0 through positionBy3, positionBy15)
 addClass: false,
 
 // Force our element to be at the location we specified (don't try to auto position it)
 force: false,
 
 // The element that we will make sure our element doesn't go outside of
 container: window,

 // Should the element be hidden after positioning?
 hideAfterPosition: false
 }, args);

 if ( args.x != null ) {
 var tLeft = args.x;
 var tTop = args.y;
 var tWidth = 0;
 var tHeight = 0;
 
 // Position in relation to an element
 } else {
 var $target = $( $( args.target )[0] );
 var tWidth = $target.outerWidth();
 var tHeight = $target.outerHeight();
 var tOffset = $target.offset();
 var tLeft = tOffset.left;
 var tTop = tOffset.top;
 }

 // Our target right, bottom coord
 var tRight = tLeft + tWidth;
 var tBottom = tTop + tHeight;

 return this.each(function() {
 var $element = $( this );

 // Position our element in the top left so we can grab its width without triggering scrollbars
 if ( !$element.is(':visible') ) {
 $element.css({ left: -3000, 
 top: -3000
 })
 .show();
 }

 var eWidth = $element.outerWidth();
 var eHeight = $element.outerHeight();
 
 // Holds x1,y1,x2,y2 coordinates for a position in relation to our target element
 var position = [];
 // Holds a list of alternate positions to try if this one is not in the browser viewport
 var next = [];
 
 // Our Positions via ASCII ART
 /*
 8 9 10 11
 +------------+
 7 | 15 12 | 0
 | |
 6 | 14 13 | 1
 +------------+ 
 5 4 3 2
 
 */

 position[0] = new Range(tRight, tTop, tRight + eWidth, tTop + eHeight);
 next[0] = [1,7,4];
 
 position[1] = new Range(tRight, tBottom - eHeight, tRight + eWidth, tBottom);
 next[1] = [0,6,4];
 
 position[2] = new Range(tRight, tBottom, tRight + eWidth, tBottom + eHeight);
 next[2] = [1,3,10];
 
 position[3] = new Range(tRight - eWidth, tBottom, tRight, tBottom + eHeight);
 next[3] = [1,6,10];
 
 position[4] = new Range(tLeft, tBottom, tLeft + eWidth, tBottom + eHeight);
 next[4] = [1,6,9];
 
 position[5] = new Range(tLeft - eWidth, tBottom, tLeft, tBottom + eHeight);
 next[5] = [6,4,9];
 
 position[6] = new Range(tLeft - eWidth, tBottom - eHeight, tLeft, tBottom);
 next[6] = [7,1,4];
 
 position[7] = new Range(tLeft - eWidth, tTop, tLeft, tTop + eHeight);
 next[7] = [6,0,4];
 
 position[8] = new Range(tLeft - eWidth, tTop - eHeight, tLeft, tTop);
 next[8] = [7,9,4];
 
 position[9] = new Range(tLeft, tTop - eHeight, tLeft + eWidth, tTop);
 next[9] = [0,7,4];
 
 position[10]= new Range(tRight - eWidth, tTop - eHeight, tRight, tTop);
 next[10] = [0,7,3];
 
 position[11]= new Range(tRight, tTop - eHeight, tRight + eWidth, tTop);
 next[11] = [0,10,3];
 
 position[12]= new Range(tRight - eWidth, tTop, tRight, tTop + eHeight);
 next[12] = [13,7,10];
 
 position[13]= new Range(tRight - eWidth, tBottom - eHeight, tRight, tBottom);
 next[13] = [12,6,3];
 
 position[14]= new Range(tLeft, tBottom - eHeight, tLeft + eWidth, tBottom);
 next[14] = [15,1,4];
 
 position[15]= new Range(tLeft, tTop, tLeft + eWidth, tTop + eHeight);
 next[15] = [14,0,9];
 
 if ( args.positions !== null ) {
 var pos = args.positions[0];
 } else if ( args.targetPos != null && args.elementPos != null ) {
 var pos = [];
 pos[0] = [];
 pos[0][0] = 15;
 pos[0][1] = 7;
 pos[0][2] = 8;
 pos[0][3] = 9;
 pos[1] = [];
 pos[1][0] = 0;
 pos[1][1] = 12;
 pos[1][2] = 10;
 pos[1][3] = 11;
 pos[2] = [];
 pos[2][0] = 2;
 pos[2][1] = 3;
 pos[2][2] = 13;
 pos[2][3] = 1;
 pos[3] = [];
 pos[3][0] = 4;
 pos[3][1] = 5;
 pos[3][2] = 6;
 pos[3][3] = 14;

 var pos = pos[args.targetPos][args.elementPos];
 }
 var ePos = position[pos];
 var fPos = pos;

 if ( !args.force ) {
 // TODO: Do the args.container
 // window width & scroll offset
 $window = $( window );
 var sx = $window.scrollLeft();
 var sy = $window.scrollTop();
 
 // TODO: Look at innerWidth & innerHeight
 var container = new Range( sx, sy, sx + $window.width(), sy + $window.height() );
 
 // If we are outside of our viewport, see if we are outside vertically or horizontally and push onto the stack
 var stack;
 if ( args.positions ) {
 stack = args.positions;
 } else {
 stack = [pos];
 }
 var test = []; // Keeps track of our positions we already tried
 
 while ( stack.length > 0 ) {
 var p = stack.shift();
 if ( test[p] ) {
 continue;
 }
 test[p] = true;
 
 // If our current position is not within the viewport (eg. window) 
 // add the next suggested position
 if ( !container.contains(position[p]) ) {
 if ( args.positions === null ) {
 stack = jQuery.merge( stack, next[p] );
 }
 } else {
 ePos = position[p];
 break;
 }
 }
 }

 // + TODO: Determine if we are going to use absolute left, top, bottom, right 
 // positions relative to our target
 
 // Take into account any absolute or fixed positioning
 // to 'normalize' our coordinates
 $element.parents().each(function() {
 var $this = $(this);
 if ( $this.css('position') != 'static' ) {
 var abs = $this.offset();
 ePos = ePos.transform( -abs.left, -abs.top );
 return false;
 }
 });
 
 // Finally position our element
 var css = { left: ePos.x1, top: ePos.y1 };
 if ( args.hideAfterPosition ) {
 css['display'] = 'none';
 }
 $element.css( css );

 if ( args.addClass ) {
 $element.removeClass( 'positionBy0 positionBy1 positionBy2 positionBy3 positionBy4 positionBy5 '
 + 'positionBy6 positionBy7 positionBy8 positionBy9 positionBy10 positionBy11 '
 + 'positionBy12 positionBy13 positionBy14 positionBy15')
 .addClass('positionBy' + p);
 }
 });
 };
})(jQuery);

/* Copyright (c) 2006 Brandon Aaron (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$
 * $Rev$
 *
 * Version 2.1.1
 */

(function($){

/**
 * The bgiframe is chainable and applies the iframe hack to get 
 * around zIndex issues in IE6. It will only apply itself in IE6 
 * and adds a class to the iframe called 'bgiframe'. The iframe
 * is appeneded as the first child of the matched element(s) 
 * with a tabIndex and zIndex of -1.
 * 
 * By default the plugin will take borders, sized with pixel units,
 * into account. If a different unit is used for the border's width,
 * then you will need to use the top and left settings as explained below.
 *
 * NOTICE: This plugin has been reported to cause perfromance problems
 * when used on elements that change properties (like width, height and
 * opacity) a lot in IE6. Most of these problems have been caused by 
 * the expressions used to calculate the elements width, height and 
 * borders. Some have reported it is due to the opacity filter. All 
 * these settings can be changed if needed as explained below.
 *
 * @example $('div').bgiframe();
 * @before <div><p>Paragraph</p></div>
 * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div>
 *
 * @param Map settings Optional settings to configure the iframe.
 * @option String|Number top The iframe must be offset to the top
 * by the width of the top border. This should be a negative 
 * number representing the border-top-width. If a number is 
 * is used here, pixels will be assumed. Otherwise, be sure
 * to specify a unit. An expression could also be used. 
 * By default the value is "auto" which will use an expression 
 * to get the border-top-width if it is in pixels.
 * @option String|Number left The iframe must be offset to the left
 * by the width of the left border. This should be a negative 
 * number representing the border-left-width. If a number is 
 * is used here, pixels will be assumed. Otherwise, be sure
 * to specify a unit. An expression could also be used. 
 * By default the value is "auto" which will use an expression 
 * to get the border-left-width if it is in pixels.
 * @option String|Number width This is the width of the iframe. If
 * a number is used here, pixels will be assume. Otherwise, be sure
 * to specify a unit. An experssion could also be used.
 * By default the value is "auto" which will use an experssion
 * to get the offsetWidth.
 * @option String|Number height This is the height of the iframe. If
 * a number is used here, pixels will be assume. Otherwise, be sure
 * to specify a unit. An experssion could also be used.
 * By default the value is "auto" which will use an experssion
 * to get the offsetHeight.
 * @option Boolean opacity This is a boolean representing whether or not
 * to use opacity. If set to true, the opacity of 0 is applied. If
 * set to false, the opacity filter is not applied. Default: true.
 * @option String src This setting is provided so that one could change 
 * the src of the iframe to whatever they need.
 * Default: "javascript:false;"
 *
 * @name bgiframe
 * @type jQuery
 * @cat Plugins/bgiframe
 * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 */
$.fn.bgIframe = $.fn.bgiframe = function(s) {
 // This is only for IE6
 if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
 s = $.extend({
 top : 'auto', // auto == .currentStyle.borderTopWidth
 left : 'auto', // auto == .currentStyle.borderLeftWidth
 width : 'auto', // auto == offsetWidth
 height : 'auto', // auto == offsetHeight
 opacity : true,
 src : 'javascript:false;'
 }, s || {});
 var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
 html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
 'style="display:block;position:absolute;z-index:-1;'+
 (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
 'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
 'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
 'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
 'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
 '"/>';
 return this.each(function() {
 if ( $('> iframe.bgiframe', this).length == 0 )
 this.insertBefore( document.createElement(html), this.firstChild );
 });
 }
 return this;
};

})(jQuery);

/*
 * jdMenu 1.4.1 (2008-03-31)
 *
 * Copyright (c) 2006,2007 Jonathan Sharp (http://jdsharp.us)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * http://jdsharp.us/
 *
 * Built upon jQuery 1.2.1 (http://jquery.com)
 * This also requires the jQuery dimensions >= 1.2 plugin
 */

// This initializes the menu
$(function() {
 $('ul.jd_menu').jdMenu();
});

(function($){
 function addEvents(ul) {
 var settings = $.data( $(ul).parents().andSelf().filter('ul.jd_menu')[0], 'jdMenuSettings' );
 $('> li', ul)
 .bind('mouseenter.jdmenu mouseleave.jdmenu', function(evt) {
 $(this).toggleClass('jdm_hover');
 var ul = $('> ul', this);
 if ( ul.length == 1 ) {
 clearTimeout( this.$jdTimer );
 var enter = ( evt.type == 'mouseenter' );
 var fn = ( enter ? showMenu : hideMenu );
 this.$jdTimer = setTimeout(function() {
 fn( ul[0], settings.onAnimate, settings.isVertical );
 }, enter ? settings.showDelay : settings.hideDelay );
 }
 })
 .bind('click.jdmenu', function(evt) {
 var ul = $('> ul', this);
 if ( ul.length == 1 && 
 ( settings.disableLinks == true || $(this).hasClass('accessible') ) ) {
 showMenu( ul, settings.onAnimate, settings.isVertical );
 return false;
 }
 
 // The user clicked the li and we need to trigger a click for the a
 if ( evt.target == this ) {
 var link = $('> a', evt.target).not('.accessible');
 if ( link.length > 0 ) {
 var a = link[0];
 if ( !a.onclick ) {
 window.open( a.href, a.target || '_self' );
 } else {
 $(a).trigger('click');
 }
 }
 }
 if ( settings.disableLinks || 
 ( !settings.disableLinks && !$(this).parent().hasClass('jd_menu') ) ) {
 $(this).parent().jdMenuHide();
 evt.stopPropagation();
 }
 })
 .find('> a')
 .bind('focus.jdmenu blur.jdmenu', function(evt) {
 var p = $(this).parents('li:eq(0)');
 if ( evt.type == 'focus' ) {
 p.addClass('jdm_hover');
 } else { 
 p.removeClass('jdm_hover');
 }
 })
 .filter('.accessible')
 .bind('click.jdmenu', function(evt) {
 evt.preventDefault();
 });
 }

 function showMenu(ul, animate, vertical) {
 var ul = $(ul);
 if ( ul.is(':visible') ) {
 return;
 }
 ul.bgiframe();
 var li = ul.parent();
 ul .trigger('jdMenuShow')
 .positionBy({ target: li[0], 
 targetPos: ( vertical === true || !li.parent().hasClass('jd_menu') ? 1 : 3 ), 
 elementPos: 0,
 hideAfterPosition: true
 });
 if ( !ul.hasClass('jdm_events') ) {
 ul.addClass('jdm_events');
 addEvents(ul);
 }
 li .addClass('jdm_active')
 // Hide any adjacent menus
 .siblings('li').find('> ul:eq(0):visible')
 .each(function(){
 hideMenu( this ); 
 });
 if ( animate === undefined ) {
 ul.show();
 } else {
 animate.apply( ul[0], [true] );
 }
 }
 
 function hideMenu(ul, animate) {
 var ul = $(ul);
 $('.bgiframe', ul).remove();
 ul .filter(':not(.jd_menu)')
 .find('> li > ul:eq(0):visible')
 .each(function() {
 hideMenu( this );
 })
 .end();
 if ( animate === undefined ) {
 ul.hide()
 } else {
 animate.apply( ul[0], [false] );
 }

 ul .trigger('jdMenuHide')
 .parents('li:eq(0)')
 .removeClass('jdm_active jdm_hover')
 .end()
 .find('> li')
 .removeClass('jdm_active jdm_hover');
 }
 
 // Public methods
 $.fn.jdMenu = function(settings) {
 // Future settings: activateDelay
 var settings = $.extend({ // Time in ms before menu shows
 showDelay: 10,
 // Time in ms before menu hides
 hideDelay: 400,
 // Should items that contain submenus not 
 // respond to clicks
 disableLinks: false
 // This callback allows for you to animate menus
 //onAnimate: null
 }, settings);
 if ( !$.isFunction( settings.onAnimate ) ) {
 settings.onAnimate = undefined;
 }
 return this.filter('ul.jd_menu').each(function() {
 $.data( this, 
 'jdMenuSettings', 
 $.extend({ isVertical: $(this).hasClass('jd_menu_vertical') }, settings) 
 );
 addEvents(this);
 });
 };
 
 $.fn.jdMenuUnbind = function() {
 $('ul.jdm_events', this)
 .unbind('.jdmenu')
 .find('> a').unbind('.jdmenu');
 };
 /*$.fn.jdMenuHide = function() {
 return this.filter('ul').each(function(){ 
 hideMenu( this );
 });
 };

 // Private methods and logic
 $(window)
 // Bind a click event to hide all visible menus when the document is clicked
 .bind('click.jdmenu', function(){
 $('ul.jd_menu ul:visible').jdMenuHide();
 });*/
})(jQuery);

/*
 * Editable 1.3.3
 *
 * Copyright (c) 2009 Arash Karimzadeh (arashkarimzadeh.com)
 * Licensed under the MIT (MIT-LICENSE.txt)
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Date: Mar 02 2009
 */
(function($){$.fn.editable=function(options){var defaults={onEdit:null,onSubmit:null,onCancel:null,editClass:null,submit:null,cancel:null,type:"text",submitBy:"blur",editBy:"click",options:null};if(options=="disable"){return this.unbind(this.data("editable.options").editBy,this.data("editable.options").toEditable)}if(options=="enable"){return this.bind(this.data("editable.options").editBy,this.data("editable.options").toEditable)}if(options=="destroy"){return this.unbind(this.data("editable.options").editBy,this.data("editable.options").toEditable).data("editable.previous",null).data("editable.current",null).data("editable.options",null)}var options=$.extend(defaults,options);options.toEditable=function(){$this=$(this);$this.data("editable.current",$this.html());opts=$this.data("editable.options");$.editableFactory[opts.type].toEditable($this.empty(),opts);$this.data("editable.previous",$this.data("editable.current")).children().focus().addClass(opts.editClass);if(opts.submit){$("<button/>").appendTo($this).html(opts.submit).one("mouseup",function(){opts.toNonEditable($(this).parent(),true)})}else{$this.one(opts.submitBy,function(){opts.toNonEditable($(this),true)}).children().one(opts.submitBy,function(){opts.toNonEditable($(this).parent(),true)})}if(opts.cancel){$("<button/>").appendTo($this).html(opts.cancel).one("mouseup",function(){opts.toNonEditable($(this).parent(),false)})}if($.isFunction(opts.onEdit)){opts.onEdit.apply($this,[{current:$this.data("editable.current"),previous:$this.data("editable.previous")}])}};options.toNonEditable=function($this,change){opts=$this.data("editable.options");$this.one(opts.editBy,opts.toEditable).data("editable.current",change?$.editableFactory[opts.type].getValue($this,opts):$this.data("editable.current")).html(opts.type=="password"?"*****":$this.data("editable.current"));var func=null;if($.isFunction(opts.onSubmit)&&change==true){func=opts.onSubmit}else{if($.isFunction(opts.onCancel)&&change==false){func=opts.onCancel}}if(func!=null){func.apply($this,[{current:$this.data("editable.current"),previous:$this.data("editable.previous")}])}};this.data("editable.options",options);return this.one(options.editBy,options.toEditable)};$.editableFactory={text:{toEditable:function($this,options){$("<input/>").appendTo($this).val($this.data("editable.current"))},getValue:function($this,options){return $this.children().val()}},password:{toEditable:function($this,options){$this.data("editable.current",$this.data("editable.password"));$this.data("editable.previous",$this.data("editable.password"));$('<input type="password"/>').appendTo($this).val($this.data("editable.current"))},getValue:function($this,options){$this.data("editable.password",$this.children().val());return $this.children().val()}},textarea:{toEditable:function($this,options){$("<textarea/>").appendTo($this).val($this.data("editable.current"))},getValue:function($this,options){return $this.children().val()}},select:{toEditable:function($this,options){$select=$("<select/>").appendTo($this);$.each(options.options,function(key,value){$("<option/>").appendTo($select).html(value).attr("value",key)});$select.children().each(function(){var opt=$(this);if(opt.text()==$this.data("editable.current")){return opt.attr("selected","selected").text()}})},getValue:function($this,options){var item=null;$("select",$this).children().each(function(){if($(this).attr("selected")){return item=$(this).text()}});return item}}}})(jQuery);

/* 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$
 * $Rev$
 *
 * Version: @VERSION
 *
 * Requires: jQuery 1.2+
 */

(function($){
 
$.dimensions = {
 version: '@VERSION'
};

// Create innerHeight, innerWidth, outerHeight and outerWidth methods
$.each( [ 'Height', 'Width' ], function(i, name){
 
 // innerHeight and innerWidth
 $.fn[ 'inner' + name ] = function() {
 if (!this[0]) return;
 
 var torl = name == 'Height' ? 'Top' : 'Left', // top or left
 borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
 
 return this.is(':visible') ? this[0]['client' + name] : num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr);
 };
 
 // outerHeight and outerWidth
 $.fn[ 'outer' + name ] = function(options) {
 if (!this[0]) return;
 
 var torl = name == 'Height' ? 'Top' : 'Left', // top or left
 borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right
 
 options = $.extend({ margin: false }, options || {});
 
 var val = this.is(':visible') ? 
 this[0]['offset' + name] : 
 num( this, name.toLowerCase() )
 + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width')
 + num(this, 'padding' + torl) + num(this, 'padding' + borr);
 
 return val + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0);
 };
});

// Create scrollLeft and scrollTop methods
$.each( ['Left', 'Top'], function(i, name) {
 $.fn[ 'scroll' + name ] = function(val) {
 if (!this[0]) return;
 
 return val != undefined ?
 
 // Set the scroll offset
 this.each(function() {
 this == window || this == document ?
 window.scrollTo( 
 name == 'Left' ? val : $(window)[ 'scrollLeft' ](),
 name == 'Top' ? val : $(window)[ 'scrollTop' ]()
 ) :
 this[ 'scroll' + name ] = val;
 }) :
 
 // Return the scroll offset
 this[0] == window || this[0] == document ?
 self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] ||
 $.boxModel && document.documentElement[ 'scroll' + name ] ||
 document.body[ 'scroll' + name ] :
 this[0][ 'scroll' + name ];
 };
});

$.fn.extend({
 position: function() {
 var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results;
 
 if (elem) {
 // Get *real* offsetParent
 offsetParent = this.offsetParent();
 
 // Get correct offsets
 offset = this.offset();
 parentOffset = offsetParent.offset();
 
 // Subtract element margins
 offset.top -= num(elem, 'marginTop');
 offset.left -= num(elem, 'marginLeft');
 
 // Add offsetParent borders
 parentOffset.top += num(offsetParent, 'borderTopWidth');
 parentOffset.left += num(offsetParent, 'borderLeftWidth');
 
 // Subtract the two offsets
 results = {
 top: offset.top - parentOffset.top,
 left: offset.left - parentOffset.left
 };
 }
 
 return results;
 },
 
 offsetParent: function() {
 var offsetParent = this[0].offsetParent;
 while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') )
 offsetParent = offsetParent.offsetParent;
 return $(offsetParent);
 }
});

function num(el, prop) {
 return parseInt($.curCSS(el.jquery?el[0]:el,prop,true))||0;
};

})(jQuery);

 /*
 * stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
 * 
 * Example: jQuery('#menu').stickyfloat({duration: 400});
 * parameters:
 * duration - the duration of the animation
 * startOffset - the amount of scroll offset after it the animations kicks in
 * offsetY - the offset from the top when the object is animated
 * lockBottom - 'true' by default, set to false if you don't want your floating box to stop at parent's bottom
 * $Version: 05.16.2009 r1
 * Copyright (c) 2009 Yair Even-Or
 * vsync.design@gmail.com
 */

 $.fn.stickyfloat = function(options, lockBottom) {
 var $obj = this;
 var parentPaddingTop = parseInt($obj.parent().css('padding-top'));
 var startOffset = $obj.parent().offset().top;
 var opts = $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom:true }, options);
 
 $obj.css({ position: 'absolute' });
 
 if(opts.lockBottom){
 var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
 if( bottomPos < 0 )
 bottomPos = 0;
 }
 
 $(window).scroll(function () { 
 $obj.stop(); // stop all calculations on scroll event

 var pastStartOffset = $(document).scrollTop() > opts.startOffset; // check if the window was scrolled down more than the start offset declared.
 var objFartherThanTopPos = $obj.offset().top > startOffset; // check if the object is at it's top position (starting point)
 var objBiggerThanWindow = $obj.outerHeight() < $(window).height(); // if the window size is smaller than the Obj size, then do not animate.
 
 // if window scrolled down more than startOffset OR obj position is greater than
 // the top position possible (+ offsetY) AND window size must be bigger than Obj size
 if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow ){ 
 var newpos = ($(document).scrollTop() -startOffset + opts.offsetY );
 if ( newpos > bottomPos )
 newpos = bottomPos;
 if ( $(document).scrollTop() < opts.startOffset ) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
 newpos = parentPaddingTop;
 
 $obj.animate({ top: newpos }, opts.duration );
 }
 });
 };
 
/* ------------------------------------------------------------------------
 * Class: prettyPhoto
 * Use: Lightbox clone for jQuery
 * Author: Stephane Caron (http://www.no-margin-for-errors.com)
 * Version: 2.5.6
 ------------------------------------------------------------------------- */

(function($){$.prettyPhoto={version:'2.5.6'};$.fn.prettyPhoto=function(settings){settings=jQuery.extend({animationSpeed:'normal',opacity:0.80,showTitle:true,allowresize:true,default_width:500,default_height:344,counter_separator_label:'/',theme:'light_rounded',hideflash:false,wmode:'opaque',autoplay:true,modal:false,changepicturecallback:function(){},callback:function(){},markup:'<div class="pp_pic_holder"> \
 <div class="pp_top"> \
 <div class="pp_left"></div> \
 <div class="pp_middle"></div> \
 <div class="pp_right"></div> \
 </div> \
 <div class="pp_content_container"> \
 <div class="pp_left"> \
 <div class="pp_right"> \
 <div class="pp_content"> \
 <div class="pp_loaderIcon"></div> \
 <div class="pp_fade"> \
 <a href="#" class="pp_expand" title="Expand the image">Expand</a> \
 <div class="pp_hoverContainer"> \
 <a class="pp_next" href="#">next</a> \
 <a class="pp_previous" href="#">previous</a> \
 </div> \
 <div id="pp_full_res"></div> \
 <div class="pp_details clearfix"> \
 <a class="pp_close" href="#">Close</a> \
 <p class="pp_description"></p> \
 <div class="pp_nav"> \
 <a href="#" class="pp_arrow_previous">Previous</a> \
 <p class="currentTextHolder">0/0</p> \
 <a href="#" class="pp_arrow_next">Next</a> \
 </div> \
 </div> \
 </div> \
 </div> \
 </div> \
 </div> \
 </div> \
 <div class="pp_bottom"> \
 <div class="pp_left"></div> \
 <div class="pp_middle"></div> \
 <div class="pp_right"></div> \
 </div> \
 </div> \
 <div class="pp_overlay"></div> \
 <div class="ppt"></div>',image_markup:'<img id="fullResImage" src="" />',flash_markup:'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="{width}" height="{height}"><param name="wmode" value="{wmode}" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="{path}" /><embed src="{path}" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="{width}" height="{height}" wmode="{wmode}"></embed></object>',quicktime_markup:'<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="{height}" width="{width}"><param name="src" value="{path}"><param name="autoplay" value="{autoplay}"><param name="type" value="video/quicktime"><embed src="{path}" height="{height}" width="{width}" autoplay="{autoplay}" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>',iframe_markup:'<iframe src ="{path}" width="{width}" height="{height}" frameborder="no"></iframe>',inline_markup:'<div class="pp_inline clearfix">{content}</div>'},settings);if($.browser.msie&&parseInt($.browser.version)==6){settings.theme="light_square";}
if($('.pp_overlay').size()==0)_buildOverlay();var doresize=true,percentBased=false,correctSizes,$pp_pic_holder,$ppt,$pp_overlay,pp_contentHeight,pp_contentWidth,pp_containerHeight,pp_containerWidth,windowHeight=$(window).height(),windowWidth=$(window).width(),setPosition=0,scrollPos=_getScroll();$(window).scroll(function(){scrollPos=_getScroll();_centerOverlay();_resizeOverlay();});$(window).resize(function(){_centerOverlay();_resizeOverlay();});$(document).keydown(function(e){if($pp_pic_holder.is(':visible'))
switch(e.keyCode){case 37:$.prettyPhoto.changePage('previous');break;case 39:$.prettyPhoto.changePage('next');break;case 27:if(!settings.modal)
$.prettyPhoto.close();break;};});$(this).each(function(){$(this).bind('click',function(){_self=this;theRel=$(this).attr('rel');galleryRegExp=/\[(?:.*)\]/;theGallery=galleryRegExp.exec(theRel);var images=new Array(),titles=new Array(),descriptions=new Array();if(theGallery){$('a[rel*='+theGallery+']').each(function(i){if($(this)[0]===$(_self)[0])setPosition=i;images.push($(this).attr('href'));titles.push($(this).find('img').attr('alt'));descriptions.push($(this).attr('title'));});}else{images=$(this).attr('href');titles=($(this).find('img').attr('alt'))?$(this).find('img').attr('alt'):'';descriptions=($(this).attr('title'))?$(this).attr('title'):'';}
$.prettyPhoto.open(images,titles,descriptions);return false;});});$.prettyPhoto.open=function(gallery_images,gallery_titles,gallery_descriptions){if($.browser.msie&&$.browser.version==6){$('select').css('visibility','hidden');};if(settings.hideflash)$('object,embed').css('visibility','hidden');images=$.makeArray(gallery_images);titles=$.makeArray(gallery_titles);descriptions=$.makeArray(gallery_descriptions);image_set=($(images).size()>0)?true:false;_checkPosition($(images).size());$('.pp_loaderIcon').show();$pp_overlay.show().fadeTo(settings.animationSpeed,settings.opacity);$pp_pic_holder.find('.currentTextHolder').text((setPosition+1)+settings.counter_separator_label+$(images).size());if(descriptions[setPosition]){$pp_pic_holder.find('.pp_description').show().html(unescape(descriptions[setPosition]));}else{$pp_pic_holder.find('.pp_description').hide().text('');};if(titles[setPosition]&&settings.showTitle){hasTitle=true;$ppt.html(unescape(titles[setPosition]));}else{hasTitle=false;};movie_width=(parseFloat(grab_param('width',images[setPosition])))?grab_param('width',images[setPosition]):settings.default_width.toString();movie_height=(parseFloat(grab_param('height',images[setPosition])))?grab_param('height',images[setPosition]):settings.default_height.toString();if(movie_width.indexOf('%')!=-1||movie_height.indexOf('%')!=-1){movie_height=parseFloat(($(window).height()*parseFloat(movie_height)/100)-100);movie_width=parseFloat(($(window).width()*parseFloat(movie_width)/100)-100);percentBased=true;}
$pp_pic_holder.fadeIn(function(){imgPreloader="";switch(_getFileType(images[setPosition])){case'image':imgPreloader=new Image();nextImage=new Image();if(image_set&&setPosition>$(images).size())nextImage.src=images[setPosition+1];prevImage=new Image();if(image_set&&images[setPosition-1])prevImage.src=images[setPosition-1];$pp_pic_holder.find('#pp_full_res')[0].innerHTML=settings.image_markup;$pp_pic_holder.find('#fullResImage').attr('src',images[setPosition]);imgPreloader.onload=function(){correctSizes=_fitToViewport(imgPreloader.width,imgPreloader.height);_showContent();};imgPreloader.onerror=function(){alert('Image cannot be loaded. Make sure the path is correct and image exist.');$.prettyPhoto.close();};imgPreloader.src=images[setPosition];break;case'youtube':correctSizes=_fitToViewport(movie_width,movie_height);movie='http://www.youtube.com/v/'+grab_param('v',images[setPosition]);if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case'vimeo':correctSizes=_fitToViewport(movie_width,movie_height);movie_id=images[setPosition];movie='http://vimeo.com/moogaloop.swf?clip_id='+movie_id.replace('http://vimeo.com/','');if(settings.autoplay)movie+="&autoplay=1";toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,movie);break;case'quicktime':correctSizes=_fitToViewport(movie_width,movie_height);correctSizes['height']+=15;correctSizes['contentHeight']+=15;correctSizes['containerHeight']+=15;toInject=settings.quicktime_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,images[setPosition]).replace(/{autoplay}/g,settings.autoplay);break;case'flash':correctSizes=_fitToViewport(movie_width,movie_height);flash_vars=images[setPosition];flash_vars=flash_vars.substring(images[setPosition].indexOf('flashvars')+10,images[setPosition].length);filename=images[setPosition];filename=filename.substring(0,filename.indexOf('?'));toInject=settings.flash_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{wmode}/g,settings.wmode).replace(/{path}/g,filename+'?'+flash_vars);break;case'iframe':correctSizes=_fitToViewport(movie_width,movie_height);frame_url=images[setPosition];frame_url=frame_url.substr(0,frame_url.indexOf('iframe')-1);toInject=settings.iframe_markup.replace(/{width}/g,correctSizes['width']).replace(/{height}/g,correctSizes['height']).replace(/{path}/g,frame_url);break;case'inline':myClone=$(images[setPosition]).clone().css({'width':settings.default_width}).wrapInner('<div id="pp_full_res"><div class="pp_inline clearfix"></div></div>').appendTo($('body'));correctSizes=_fitToViewport($(myClone).width(),$(myClone).height());$(myClone).remove();toInject=settings.inline_markup.replace(/{content}/g,$(images[setPosition]).html());break;};if(!imgPreloader){$pp_pic_holder.find('#pp_full_res')[0].innerHTML=toInject;_showContent();};});};$.prettyPhoto.changePage=function(direction){if(direction=='previous'){setPosition--;if(setPosition<0){setPosition=0;return;};}else{if($('.pp_arrow_next').is('.disabled'))return;setPosition++;};if(!doresize)doresize=true;_hideContent(function(){$.prettyPhoto.open(images,titles,descriptions)});$('a.pp_expand,a.pp_contract').fadeOut(settings.animationSpeed);};$.prettyPhoto.close=function(){$pp_pic_holder.find('object,embed').css('visibility','hidden');$('div.pp_pic_holder,div.ppt,.pp_fade').fadeOut(settings.animationSpeed);$pp_overlay.fadeOut(settings.animationSpeed,function(){$('#pp_full_res').html('');$pp_pic_holder.attr('style','').find('div:not(.pp_hoverContainer)').attr('style','');_centerOverlay();if($.browser.msie&&$.browser.version==6){$('select').css('visibility','visible');};if(settings.hideflash)$('object,embed').css('visibility','visible');setPosition=0;settings.callback();});doresize=true;};_showContent=function(){$('.pp_loaderIcon').hide();projectedTop=scrollPos['scrollTop']+((windowHeight/2)-(correctSizes['containerHeight']/2));if(projectedTop<0)projectedTop=0+$ppt.height();$pp_pic_holder.find('.pp_content').animate({'height':correctSizes['contentHeight']},settings.animationSpeed);$pp_pic_holder.animate({'top':projectedTop,'left':(windowWidth/2)-(correctSizes['containerWidth']/2),'width':correctSizes['containerWidth']},settings.animationSpeed,function(){$pp_pic_holder.find('.pp_hoverContainer,#fullResImage').height(correctSizes['height']).width(correctSizes['width']);$pp_pic_holder.find('.pp_fade').fadeIn(settings.animationSpeed);if(image_set&&_getFileType(images[setPosition])=="image"){$pp_pic_holder.find('.pp_hoverContainer').show();}else{$pp_pic_holder.find('.pp_hoverContainer').hide();}
if(settings.showTitle&&hasTitle){$ppt.css({'top':$pp_pic_holder.offset().top-25,'left':$pp_pic_holder.offset().left+20,'display':'none'});$ppt.fadeIn(settings.animationSpeed);};if(correctSizes['resized'])$('a.pp_expand,a.pp_contract').fadeIn(settings.animationSpeed);settings.changepicturecallback();});};function _hideContent(callback){$pp_pic_holder.find('#pp_full_res object,#pp_full_res embed').css('visibility','hidden');$pp_pic_holder.find('.pp_fade').fadeOut(settings.animationSpeed,function(){$('.pp_loaderIcon').show();if(callback)callback();});$ppt.fadeOut(settings.animationSpeed);}
function _checkPosition(setCount){if(setPosition==setCount-1){$pp_pic_holder.find('a.pp_next').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_next').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_next').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_next.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('next');return false;});};if(setPosition==0){$pp_pic_holder.find('a.pp_previous').css('visibility','hidden');$pp_pic_holder.find('a.pp_arrow_previous').addClass('disabled').unbind('click');}else{$pp_pic_holder.find('a.pp_previous').css('visibility','visible');$pp_pic_holder.find('a.pp_arrow_previous.disabled').removeClass('disabled').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});};if(setCount>1){$('.pp_nav').show();}else{$('.pp_nav').hide();}};function _fitToViewport(width,height){hasBeenResized=false;_getDimensions(width,height);imageWidth=width;imageHeight=height;if(((pp_containerWidth>windowWidth)||(pp_containerHeight>windowHeight))&&doresize&&settings.allowresize&&!percentBased){hasBeenResized=true;notFitting=true;while(notFitting){if((pp_containerWidth>windowWidth)){imageWidth=(windowWidth-200);imageHeight=(height/width)*imageWidth;}else if((pp_containerHeight>windowHeight)){imageHeight=(windowHeight-200);imageWidth=(width/height)*imageHeight;}else{notFitting=false;};pp_containerHeight=imageHeight;pp_containerWidth=imageWidth;};_getDimensions(imageWidth,imageHeight);};return{width:Math.floor(imageWidth),height:Math.floor(imageHeight),containerHeight:Math.floor(pp_containerHeight),containerWidth:Math.floor(pp_containerWidth)+40,contentHeight:Math.floor(pp_contentHeight),contentWidth:Math.floor(pp_contentWidth),resized:hasBeenResized};};function _getDimensions(width,height){width=parseFloat(width);height=parseFloat(height);$pp_details=$pp_pic_holder.find('.pp_details');$pp_details.width(width);detailsHeight=parseFloat($pp_details.css('marginTop'))+parseFloat($pp_details.css('marginBottom'));$pp_details=$pp_details.clone().appendTo($('body')).css({'position':'absolute','top':-10000});detailsHeight+=$pp_details.height();detailsHeight=(detailsHeight<=34)?36:detailsHeight;if($.browser.msie&&$.browser.version==7)detailsHeight+=8;$pp_details.remove();pp_contentHeight=height+detailsHeight;pp_contentWidth=width;pp_containerHeight=pp_contentHeight+$ppt.height()+$pp_pic_holder.find('.pp_top').height()+$pp_pic_holder.find('.pp_bottom').height();pp_containerWidth=width;}
function _getFileType(itemSrc){if(itemSrc.match(/youtube\.com\/watch/i)){return'youtube';}else if(itemSrc.match(/vimeo\.com/i)){return'vimeo';}else if(itemSrc.indexOf('.mov')!=-1){return'quicktime';}else if(itemSrc.indexOf('.swf')!=-1){return'flash';}else if(itemSrc.indexOf('iframe')!=-1){return'iframe'}else if(itemSrc.substr(0,1)=='#'){return'inline';}else{return'image';};};function _centerOverlay(){if(doresize){titleHeight=$ppt.height();contentHeight=$pp_pic_holder.height();contentwidth=$pp_pic_holder.width();projectedTop=(windowHeight/2)+scrollPos['scrollTop']-((contentHeight+titleHeight)/2);$pp_pic_holder.css({'top':projectedTop,'left':(windowWidth/2)+scrollPos['scrollLeft']-(contentwidth/2)});$ppt.css({'top':projectedTop-titleHeight,'left':(windowWidth/2)+scrollPos['scrollLeft']-(contentwidth/2)+20});};};function _getScroll(){if(self.pageYOffset){return{scrollTop:self.pageYOffset,scrollLeft:self.pageXOffset};}else if(document.documentElement&&document.documentElement.scrollTop){return{scrollTop:document.documentElement.scrollTop,scrollLeft:document.documentElement.scrollLeft};}else if(document.body){return{scrollTop:document.body.scrollTop,scrollLeft:document.body.scrollLeft};};};function _resizeOverlay(){windowHeight=$(window).height();windowWidth=$(window).width();$pp_overlay.css({'height':$(document).height()});};function _buildOverlay(){$('body').append(settings.markup);$pp_pic_holder=$('.pp_pic_holder');$ppt=$('.ppt');$pp_overlay=$('div.pp_overlay');$pp_pic_holder.attr('class','pp_pic_holder '+settings.theme);$pp_overlay.css({'opacity':0,'height':$(document).height()}).bind('click',function(){if(!settings.modal)
$.prettyPhoto.close();});$('a.pp_close').bind('click',function(){$.prettyPhoto.close();return false;});$('a.pp_expand').bind('click',function(){$this=$(this);if($this.hasClass('pp_expand')){$this.removeClass('pp_expand').addClass('pp_contract');doresize=false;}else{$this.removeClass('pp_contract').addClass('pp_expand');doresize=true;};_hideContent(function(){$.prettyPhoto.open(images,titles,descriptions)});$pp_pic_holder.find('.pp_fade').fadeOut(settings.animationSpeed);return false;});$pp_pic_holder.find('.pp_previous, .pp_arrow_previous').bind('click',function(){$.prettyPhoto.changePage('previous');return false;});$pp_pic_holder.find('.pp_next, .pp_arrow_next').bind('click',function(){$.prettyPhoto.changePage('next');return false;});};_centerOverlay();};function grab_param(name,url){name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(url);if(results==null)
return"";else
return results[1];}})(jQuery);

