/**
 * Flash (http://jquery.lukelutman.com/plugins/flash)
 * A jQuery plugin for embedding Flash movies.
 * 
 * Version 1.0
 * November 9th, 2006
 *
 * Copyright (c) 2006 Luke Lutman (http://www.lukelutman.com)
 * Dual licensed under the MIT and GPL licenses.
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.opensource.org/licenses/gpl-license.php
 * 
 * Inspired by:
 * SWFObject (http://blog.deconcept.com/swfobject/)
 * UFO (http://www.bobbyvandersluis.com/ufo/)
 * sIFR (http://www.mikeindustries.com/sifr/)
 * 
 * IMPORTANT: 
 * The packed version of jQuery breaks ActiveX control
 * activation in Internet Explorer. Use JSMin to minifiy
 * jQuery (see: http://jquery.lukelutman.com/plugins/flash#activex).
 *
 **/ 
;(function(){
	
var $$;

/**
 * 
 * @desc Replace matching elements with a flash movie.
 * @author Luke Lutman
 * @version 1.0.1
 *
 * @name flash
 * @param Hash htmlOptions Options for the embed/object tag.
 * @param Hash pluginOptions Options for detecting/updating the Flash plugin (optional).
 * @param Function replace Custom block called for each matched element if flash is installed (optional).
 * @param Function update Custom block called for each matched if flash isn't installed (optional).
 * @type jQuery
 *
 * @cat plugins/flash
 * 
 * @example $('#hello').flash({ src: 'hello.swf' });
 * @desc Embed a Flash movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { version: 8 });
 * @desc Embed a Flash 8 movie.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { expressInstall: true });
 * @desc Embed a Flash movie using Express Install if flash isn't installed.
 *
 * @example $('#hello').flash({ src: 'hello.swf' }, { update: false });
 * @desc Embed a Flash movie, don't show an update message if Flash isn't installed.
 *
**/
$$ = jQuery.fn.flash = function(htmlOptions, pluginOptions, replace, update) {
	
	// Set the default block.
	var block = replace || $$.replace;
	
	// Merge the default and passed plugin options.
	pluginOptions = $$.copy($$.pluginOptions, pluginOptions);
	
	// Detect Flash.
	if(!$$.hasFlash(pluginOptions.version)) {
		// Use Express Install (if specified and Flash plugin 6,0,65 or higher is installed).
		if(pluginOptions.expressInstall && $$.hasFlash(6,0,65)) {
			// Add the necessary flashvars (merged later).
			var expressInstallOptions = {
				flashvars: {  	
					MMredirectURL: location,
					MMplayerType: 'PlugIn',
					MMdoctitle: jQuery('title').text() 
				}					
			};
		// Ask the user to update (if specified).
		} else if (pluginOptions.update) {
			// Change the block to insert the update message instead of the flash movie.
			block = update || $$.update;
		// Fail
		} else {
			// The required version of flash isn't installed.
			// Express Install is turned off, or flash 6,0,65 isn't installed.
			// Update is turned off.
			// Return without doing anything.
			return this;
		}
	}
	
	// Merge the default, express install and passed html options.
	htmlOptions = $$.copy($$.htmlOptions, expressInstallOptions, htmlOptions);
	
	// Invoke $block (with a copy of the merged html options) for each element.
	return this.each(function(){
		block.call(this, $$.copy(htmlOptions));
	});
	
};
/**
 *
 * @name flash.copy
 * @desc Copy an arbitrary number of objects into a new object.
 * @type Object
 * 
 * @example $$.copy({ foo: 1 }, { bar: 2 });
 * @result { foo: 1, bar: 2 };
 *
**/
$$.copy = function() {
	var options = {}, flashvars = {};
	for(var i = 0; i < arguments.length; i++) {
		var arg = arguments[i];
		if(arg == undefined) continue;
		jQuery.extend(options, arg);
		// don't clobber one flash vars object with another
		// merge them instead
		if(arg.flashvars == undefined) continue;
		jQuery.extend(flashvars, arg.flashvars);
	}
	options.flashvars = flashvars;
	return options;
};
/*
 * @name flash.hasFlash
 * @desc Check if a specific version of the Flash plugin is installed
 * @type Boolean
 *
**/
$$.hasFlash = function() {
	// look for a flag in the query string to bypass flash detection
	if(/hasFlash\=true/.test(location)) return true;
	if(/hasFlash\=false/.test(location)) return false;
	var pv = $$.hasFlash.playerVersion().match(/\d+/g);
	var rv = String([arguments[0], arguments[1], arguments[2]]).match(/\d+/g) || String($$.pluginOptions.version).match(/\d+/g);
	for(var i = 0; i < 3; i++) {
		pv[i] = parseInt(pv[i] || 0);
		rv[i] = parseInt(rv[i] || 0);
		// player is less than required
		if(pv[i] < rv[i]) return false;
		// player is greater than required
		if(pv[i] > rv[i]) return true;
	}
	// major version, minor version and revision match exactly
	return true;
};
/**
 *
 * @name flash.hasFlash.playerVersion
 * @desc Get the version of the installed Flash plugin.
 * @type String
 *
**/
$$.hasFlash.playerVersion = function() {
	// ie
	try {
		try {
			// avoid fp6 minor version lookup issues
			// see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
			var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
			try { axo.AllowScriptAccess = 'always';	} 
			catch(e) { return '6,0,0'; }				
		} catch(e) {}
		return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
	// other browsers
	} catch(e) {
		try {
			if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
				return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
			}
		} catch(e) {}		
	}
	return '0,0,0';
};
/**
 *
 * @name flash.htmlOptions
 * @desc The default set of options for the object or embed tag.
 *
**/
$$.htmlOptions = {
	height: 240,
	flashvars: {},
	pluginspage: 'http://www.adobe.com/go/getflashplayer',
	src: '#',
	type: 'application/x-shockwave-flash',
	width: 320		
};
/**
 *
 * @name flash.pluginOptions
 * @desc The default set of options for checking/updating the flash Plugin.
 *
**/
$$.pluginOptions = {
	expressInstall: false,
	update: true,
	version: '6.0.65'
};
/**
 *
 * @name flash.replace
 * @desc The default method for replacing an element with a Flash movie.
 *
**/
$$.replace = function(htmlOptions) {
	this.innerHTML = '<div class="alt">'+this.innerHTML+'</div>';
	jQuery(this)
		.addClass('flash-replaced')
		.prepend($$.transform(htmlOptions));
};
/**
 *
 * @name flash.update
 * @desc The default method for replacing an element with an update message.
 *
**/
$$.update = function(htmlOptions) {
	var url = String(location).split('?');
	url.splice(1,0,'?hasFlash=true&');
	url = url.join('');
	var msg = '<p>This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>. Already have Flash Player? <a href="'+url+'">Click here.</a></p>';
	this.innerHTML = '<span class="alt">'+this.innerHTML+'</span>';
	jQuery(this)
		.addClass('flash-update')
		.prepend(msg);
};
/**
 *
 * @desc Convert a hash of html options to a string of attributes, using Function.apply(). 
 * @example toAttributeString.apply(htmlOptions)
 * @result foo="bar" foo="bar"
 *
**/
function toAttributeString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'="'+this[key]+'" ';
	return s;		
};
/**
 *
 * @desc Convert a hash of flashvars to a url-encoded string, using Function.apply(). 
 * @example toFlashvarsString.apply(flashvarsObject)
 * @result foo=bar&foo=bar
 *
**/
function toFlashvarsString() {
	var s = '';
	for(var key in this)
		if(typeof this[key] != 'function')
			s += key+'='+encodeURIComponent(this[key])+'&';
	return s.replace(/&$/, '');		
};
/**
 *
 * @name flash.transform
 * @desc Transform a set of html options into an embed tag.
 * @type String 
 *
 * @example $$.transform(htmlOptions)
 * @result <embed src="foo.swf" ... />
 *
 * Note: The embed tag is NOT standards-compliant, but it 
 * works in all current browsers. flash.transform can be
 * overwritten with a custom function to generate more 
 * standards-compliant markup.
 *
**/
$$.transform = function(htmlOptions) {
	htmlOptions.toString = toAttributeString;
	if(htmlOptions.flashvars) htmlOptions.flashvars.toString = toFlashvarsString;
	return '<embed ' + String(htmlOptions) + '/>';		
};

/**
 *
 * Flash Player 9 Fix (http://blog.deconcept.com/2006/07/28/swfobject-143-released/)
 *
**/
if (window.attachEvent) {
	window.attachEvent("onbeforeunload", function(){
		__flash_unloadHandler = function() {};
		__flash_savedUnloadHandler = function() {};
	});
}
	
})();








/* Copyright (c) 2006 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.
 * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
 * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
 *
 * $LastChangedDate: 2007-12-20 09:02:08 -0600 (Thu, 20 Dec 2007) $
 * $Rev: 4265 $
 *
 * Version: 3.0
 * 
 * Requires: $ 1.2.2+
 */

(function($) {

$.event.special.mousewheel = {
	setup: function() {
		var handler = $.event.special.mousewheel.handler;
		
		// Fix pageX, pageY, clientX and clientY for mozilla
		if ( $.browser.mozilla )
			$(this).bind('mousemove.mousewheel', function(event) {
				$.data(this, 'mwcursorposdata', {
					pageX: event.pageX,
					pageY: event.pageY,
					clientX: event.clientX,
					clientY: event.clientY
				});
			});
	
		if ( this.addEventListener )
			this.addEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = handler;
	},
	
	teardown: function() {
		var handler = $.event.special.mousewheel.handler;
		
		$(this).unbind('mousemove.mousewheel');
		
		if ( this.removeEventListener )
			this.removeEventListener( ($.browser.mozilla ? 'DOMMouseScroll' : 'mousewheel'), handler, false);
		else
			this.onmousewheel = function(){};
		
		$.removeData(this, 'mwcursorposdata');
	},
	
	handler: function(event) {
		var args = Array.prototype.slice.call( arguments, 1 );
		
		event = $.event.fix(event || window.event);
		// Get correct pageX, pageY, clientX and clientY for mozilla
		$.extend( event, $.data(this, 'mwcursorposdata') || {} );
		var delta = 0, returnValue = true;
		
		if ( event.wheelDelta ) delta = event.wheelDelta/120;
		if ( event.detail     ) delta = -event.detail/3;
//		if ( $.browser.opera  ) delta = -event.wheelDelta;
		
		event.data  = event.data || {};
		event.type  = "mousewheel";
		
		// Add delta to the front of the arguments
		args.unshift(delta);
		// Add event to the front of the arguments
		args.unshift(event);

		return $.event.handle.apply(this, args);
	}
};

$.fn.extend({
	mousewheel: function(fn) {
		return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
	},
	
	unmousewheel: function(fn) {
		return this.unbind("mousewheel", fn);
	}
});

})(jQuery);







/* Copyright (c) 2009 Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.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.
 * 
 * See http://kelvinluck.com/assets/jquery/jScrollPane/
 * $Id: jScrollPane.js 87 2009-10-12 10:44:17Z kelvin.luck $
 */

/**
 * Replace the vertical scroll bars on any matched elements with a fancy
 * styleable (via CSS) version. With JS disabled the elements will
 * gracefully degrade to the browsers own implementation of overflow:auto.
 * If the mousewheel plugin has been included on the page then the scrollable areas will also
 * respond to the mouse wheel.
 *
 * @example jQuery(".scroll-pane").jScrollPane();
 *
 * @name jScrollPane
 * @type jQuery
 * @param Object	settings	hash with options, described below.
 *								scrollbarWidth	-	The width of the generated scrollbar in pixels
 *								scrollbarMargin	-	The amount of space to leave on the side of the scrollbar in pixels
 *								wheelSpeed		-	The speed the pane will scroll in response to the mouse wheel in pixels
 *								showArrows		-	Whether to display arrows for the user to scroll with
 *								arrowSize		-	The height of the arrow buttons if showArrows=true
 *								animateTo		-	Whether to animate when calling scrollTo and scrollBy
 *								dragMinHeight	-	The minimum height to allow the drag bar to be
 *								dragMaxHeight	-	The maximum height to allow the drag bar to be
 *								animateInterval	-	The interval in milliseconds to update an animating scrollPane (default 100)
 *								animateStep		-	The amount to divide the remaining scroll distance by when animating (default 3)
 *								maintainPosition-	Whether you want the contents of the scroll pane to maintain it's position when you re-initialise it - so it doesn't scroll as you add more content (default true)
 *								tabIndex		-	The tabindex for this jScrollPane to control when it is tabbed to when navigating via keyboard (default 0)
 *								enableKeyboardNavigation - Whether to allow keyboard scrolling of this jScrollPane when it is focused (default true)
 *								animateToInternalLinks - Whether the move to an internal link (e.g. when it's focused by tabbing or by a hash change in the URL) should be animated or instant (default false)
 *								scrollbarOnLeft	-	Display the scrollbar on the left side?  (needs stylesheet changes, see examples.html)
 *								reinitialiseOnImageLoad - Whether the jScrollPane should automatically re-initialise itself when any contained images are loaded (default false)
 *								topCapHeight	-	The height of the "cap" area between the top of the jScrollPane and the top of the track/ buttons
 *								bottomCapHeight	-	The height of the "cap" area between the bottom of the jScrollPane and the bottom of the track/ buttons
 * @return jQuery
 * @cat Plugins/jScrollPane
 * @author Kelvin Luck (kelvin AT kelvinluck DOT com || http://www.kelvinluck.com)
 */

(function($) {

$.jScrollPane = {
        active : []
};
$.fn.jScrollPane = function(settings)
{
        settings = $.extend({}, $.fn.jScrollPane.defaults, settings);

        var rf = function() { return false; };
       
        return this.each(
                function()
                {
                        var $this = $(this);
                        var paneEle = this;
                        var currentScrollPosition = 0;
                        var paneWidth;
                        var paneHeight;
                        var trackHeight;
                        var trackOffset = settings.topCapHeight;
                       
                        if ($(this).parent().is('.jScrollPaneContainer')) {
                                currentScrollPosition = settings.maintainPosition ? $this.position().top : 0;
                                var $c = $(this).parent();
                                paneWidth = $c.innerWidth();
                                paneHeight = $c.outerHeight();
                                $('>.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown, >.jScollCap', $c).remove();
                                $this.css({'top':0});
                        } else {
                                $this.data('originalStyleTag', $this.attr('style'));
                                // Switch the element's overflow to hidden to ensure we get the size of the element without the scrollbars [http://plugins.jquery.com/node/1208]
                                $this.css('overflow', 'hidden');
                                this.originalPadding = $this.css('paddingTop') + ' ' + $this.css('paddingRight') + ' ' + $this.css('paddingBottom') + ' ' + $this.css('paddingLeft');
                                this.originalSidePaddingTotal = (parseInt($this.css('paddingLeft')) || 0) + (parseInt($this.css('paddingRight')) || 0);
                                paneWidth = $this.innerWidth();
                                paneHeight = $this.innerHeight();
                                var $container = $('<div></div>')
                                        .attr({'className':'jScrollPaneContainer'})
                                        .css(
                                                {
                                                        'height':paneHeight+'px',
                                                        'width':paneWidth+'px'
                                                }
                                        );
                                if (settings.enableKeyboardNavigation) {
                                        $container.attr(
                                                'tabindex',
                                                settings.tabIndex
                                        );
                                }
                                $this.wrap($container);
                                // deal with text size changes (if the jquery.em plugin is included)
                                // and re-initialise the scrollPane so the track maintains the
                                // correct size
                                $(document).bind(
                                        'emchange',
                                        function(e, cur, prev)
                                        {
                                                $this.jScrollPane(settings);
                                        }
                                );
                               
                        }
                        trackHeight = paneHeight;
                       
                        if (settings.reinitialiseOnImageLoad) {
                                // code inspired by jquery.onImagesLoad: http://plugins.jquery.com/project/onImagesLoad
                                // except we re-initialise the scroll pane when each image loads so that the scroll pane is always up to size...
                                // TODO: Do I even need to store it in $.data? Is a local variable here the same since I don't pass the reinitialiseOnImageLoad when I re-initialise?
                                var $imagesToLoad = $.data(paneEle, 'jScrollPaneImagesToLoad') || $('img', $this);
                                var loadedImages = [];
                               
                                if ($imagesToLoad.length) {
                                        $imagesToLoad.each(function(i, val)     {
                                                $(this).bind('load readystatechange', function() {
                                                        if($.inArray(i, loadedImages) == -1){ //don't double count images
                                                                loadedImages.push(val); //keep a record of images we've seen
                                                                $imagesToLoad = $.grep($imagesToLoad, function(n, i) {
                                                                        return n != val;
                                                                });
                                                                $.data(paneEle, 'jScrollPaneImagesToLoad', $imagesToLoad);
                                                                var s2 = $.extend(settings, {reinitialiseOnImageLoad:false});
                                                                $this.jScrollPane(s2); // re-initialise
                                                        }
                                                }).each(function(i, val) {
                                                        if(this.complete || this.complete===undefined) {
                                                                //needed for potential cached images
                                                                this.src = this.src;
                                                        }
                                                });
                                        });
                                };
                        }

                        var p = this.originalSidePaddingTotal;
                        var realPaneWidth = paneWidth - settings.scrollbarWidth - settings.scrollbarMargin - p; 
                        if(realPaneWidth < 0) realPaneWidth = 0;

                        var cssToApply = {
                                'height':'auto',
                                'width': realPaneWidth + 'px'
                        }

                        if(settings.scrollbarOnLeft) {
                                cssToApply.paddingLeft = settings.scrollbarMargin + settings.scrollbarWidth + 'px';
                        } else {
                                cssToApply.paddingRight = settings.scrollbarMargin + 'px';
                        }

                        $this.css(cssToApply);

                        var contentHeight = $this.outerHeight();
                        var percentInView = paneHeight / contentHeight;

                        if (percentInView < .99) {
                                var $container = $this.parent();
                                $container.append(
                                        $('<div></div>').addClass('jScrollCap jScrollCapTop').css({height:settings.topCapHeight}),
                                        $('<div></div>').attr({'className':'jScrollPaneTrack'}).css({'width':settings.scrollbarWidth+'px'}).append(
                                                $('<div></div>').attr({'className':'jScrollPaneDrag'}).css({'width':settings.scrollbarWidth+'px'}).append(
                                                        $('<div></div>').attr({'className':'jScrollPaneDragTop'}).css({'width':settings.scrollbarWidth+'px'}),
                                                        $('<div></div>').attr({'className':'jScrollPaneDragBottom'}).css({'width':settings.scrollbarWidth+'px'})
                                                )
                                        ),
                                        $('<div></div>').addClass('jScrollCap jScrollCapBottom').css({height:settings.bottomCapHeight})
                                );
                               
                                var $track = $('>.jScrollPaneTrack', $container);
                                var $drag = $('>.jScrollPaneTrack .jScrollPaneDrag', $container);
                               
                               
                                var currentArrowDirection;
                                var currentArrowTimerArr = [];// Array is used to store timers since they can stack up when dealing with keyboard events. This ensures all timers are cleaned up in the end, preventing an acceleration bug.
                                var currentArrowInc;
                                var whileArrowButtonDown = function()
                                {
                                        if (currentArrowInc > 4 || currentArrowInc % 4 == 0) {
                                                positionDrag(dragPosition + currentArrowDirection * mouseWheelMultiplier);
                                        }
                                        currentArrowInc++;
                                };

                                if (settings.enableKeyboardNavigation) {
                                        $container.bind(
                                                'keydown.jscrollpane',
                                                function(e)
                                                {
                                                        switch (e.keyCode) {
                                                                case 38: //up
                                                                        currentArrowDirection = -1;
                                                                        currentArrowInc = 0;
                                                                        whileArrowButtonDown();
                                                                        currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
                                                                        return false;
                                                                case 40: //down
                                                                        currentArrowDirection = 1;
                                                                        currentArrowInc = 0;
                                                                        whileArrowButtonDown();
                                                                        currentArrowTimerArr[currentArrowTimerArr.length] = setInterval(whileArrowButtonDown, 100);
                                                                        return false;
                                                                case 33: // page up
                                                                case 34: // page down
                                                                        // TODO
                                                                        return false;
                                                                default:
                                                        }
                                                }
                                        ).bind(
                                                'keyup.jscrollpane',
                                                function(e)
                                                {
                                                        if (e.keyCode == 38 || e.keyCode == 40) {
                                                                for (var i = 0; i < currentArrowTimerArr.length; i++) {
                                                                        clearInterval(currentArrowTimerArr[i]);
                                                                }
                                                                return false;
                                                        }
                                                }
                                        );
                                }


                                if (settings.showArrows) {
                                       
                                        var currentArrowButton;
                                        var currentArrowInterval;

                                        var onArrowMouseUp = function(event)
                                        {
                                                $('html').unbind('mouseup', onArrowMouseUp);
                                                currentArrowButton.removeClass('jScrollActiveArrowButton');
                                                clearInterval(currentArrowInterval);
                                        };
                                        var onArrowMouseDown = function() {
                                                $('html').bind('mouseup', onArrowMouseUp);
                                                currentArrowButton.addClass('jScrollActiveArrowButton');
                                                currentArrowInc = 0;
                                                whileArrowButtonDown();
                                                currentArrowInterval = setInterval(whileArrowButtonDown, 100);
                                        };
                                        $container
                                                .append(
                                                        $('<a></a>')
                                                                .attr(
                                                                        {
                                                                                'href':'javascript:;',
                                                                                'className':'jScrollArrowUp',
                                                                                'tabindex':-1
                                                                        }
                                                                )
                                                                .css(
                                                                        {
                                                                                'width':settings.scrollbarWidth+'px',
                                                                                'top':settings.topCapHeight + 'px'
                                                                        }
                                                                )
                                                                .html('Scroll up')
                                                                .bind('mousedown', function()
                                                                {
                                                                        currentArrowButton = $(this);
                                                                        currentArrowDirection = -1;
                                                                        onArrowMouseDown();
                                                                        this.blur();
                                                                        return false;
                                                                })
                                                                .bind('click', rf),
                                                        $('<a></a>')
                                                                .attr(
                                                                        {
                                                                                'href':'javascript:;',
                                                                                'className':'jScrollArrowDown',
                                                                                'tabindex':-1
                                                                        }
                                                                )
                                                                .css(
                                                                        {
                                                                                'width':settings.scrollbarWidth+'px',
                                                                                'bottom':settings.bottomCapHeight + 'px'
                                                                        }
                                                                )
                                                                .html('Scroll down')
                                                                .bind('mousedown', function()
                                                                {
                                                                        currentArrowButton = $(this);
                                                                        currentArrowDirection = 1;
                                                                        onArrowMouseDown();
                                                                        this.blur();
                                                                        return false;
                                                                })
                                                                .bind('click', rf)
                                                );
                                        var $upArrow = $('>.jScrollArrowUp', $container);
                                        var $downArrow = $('>.jScrollArrowDown', $container);
                                }
                               
                                if (settings.arrowSize) {
                                        trackHeight = paneHeight - settings.arrowSize - settings.arrowSize;
                                        trackOffset += settings.arrowSize;
                                } else if ($upArrow) {
                                        var topArrowHeight = $upArrow.height();
                                        settings.arrowSize = topArrowHeight;
                                        trackHeight = paneHeight - topArrowHeight - $downArrow.height();
                                        trackOffset += topArrowHeight;
                                }
                                trackHeight -= settings.topCapHeight + settings.bottomCapHeight;
                                $track.css({'height': trackHeight+'px', top:trackOffset+'px'})
                               
                                var $pane = $(this).css({'position':'absolute', 'overflow':'visible'});
                               
                                var currentOffset;
                                var maxY;
                                var mouseWheelMultiplier;
                                // store this in a seperate variable so we can keep track more accurately than just updating the css property..
                                var dragPosition = 0;
                                var dragMiddle = percentInView*paneHeight/2;
                               
                                // pos function borrowed from tooltip plugin and adapted...
                                var getPos = function (event, c) {
                                        var p = c == 'X' ? 'Left' : 'Top';
                                        return event['page' + c] || (event['client' + c] + (document.documentElement['scroll' + p] || document.body['scroll' + p])) || 0;
                                };
                               
                                var ignoreNativeDrag = function() {     return false; };
                               
                                var initDrag = function()
                                {
                                        ceaseAnimation();
                                        currentOffset = $drag.offset(false);
                                        currentOffset.top -= dragPosition;
                                        maxY = trackHeight - $drag[0].offsetHeight;
                                        mouseWheelMultiplier = 2 * settings.wheelSpeed * maxY / contentHeight;
                                };
                               
                                var onStartDrag = function(event)
                                {
                                        initDrag();
                                        dragMiddle = getPos(event, 'Y') - dragPosition - currentOffset.top;
                                        $('html').bind('mouseup', onStopDrag).bind('mousemove', updateScroll);
                                        if ($.browser.msie) {
                                                $('html').bind('dragstart', ignoreNativeDrag).bind('selectstart', ignoreNativeDrag);
                                        }
                                        return false;
                                };
                                var onStopDrag = function()
                                {
                                        $('html').unbind('mouseup', onStopDrag).unbind('mousemove', updateScroll);
                                        dragMiddle = percentInView*paneHeight/2;
                                        if ($.browser.msie) {
                                                $('html').unbind('dragstart', ignoreNativeDrag).unbind('selectstart', ignoreNativeDrag);
                                        }
                                };
                                var positionDrag = function(destY)
                                {
                                        $container.scrollTop(0);
                                        destY = destY < 0 ? 0 : (destY > maxY ? maxY : destY);
                                        dragPosition = destY;
                                        $drag.css({'top':destY+'px'});
                                        var p = destY / maxY;
                                        $this.data('jScrollPanePosition', (paneHeight-contentHeight)*-p);
                                        $pane.css({'top':((paneHeight-contentHeight)*p) + 'px'});
                                        $this.trigger('scroll');
                                        if (settings.showArrows) {
                                                $upArrow[destY == 0 ? 'addClass' : 'removeClass']('disabled');
                                                $downArrow[destY == maxY ? 'addClass' : 'removeClass']('disabled');
                                        }
                                };
                                var updateScroll = function(e)
                                {
                                        positionDrag(getPos(e, 'Y') - currentOffset.top - dragMiddle);
                                };
                               
                                var dragH = Math.max(Math.min(percentInView*(paneHeight-settings.arrowSize*2), settings.dragMaxHeight), settings.dragMinHeight);
                               
                                $drag.css(
                                        {'height':dragH+'px'}
                                ).bind('mousedown', onStartDrag);
                               
                                var trackScrollInterval;
                                var trackScrollInc;
                                var trackScrollMousePos;
                                var doTrackScroll = function()
                                {
                                        if (trackScrollInc > 8 || trackScrollInc%4==0) {
                                                positionDrag((dragPosition - ((dragPosition - trackScrollMousePos) / 2)));
                                        }
                                        trackScrollInc ++;
                                };
                                var onStopTrackClick = function()
                                {
                                        clearInterval(trackScrollInterval);
                                        $('html').unbind('mouseup', onStopTrackClick).unbind('mousemove', onTrackMouseMove);
                                };
                                var onTrackMouseMove = function(event)
                                {
                                        trackScrollMousePos = getPos(event, 'Y') - currentOffset.top - dragMiddle;
                                };
                                var onTrackClick = function(event)
                                {
                                        initDrag();
                                        onTrackMouseMove(event);
                                        trackScrollInc = 0;
                                        $('html').bind('mouseup', onStopTrackClick).bind('mousemove', onTrackMouseMove);
                                        trackScrollInterval = setInterval(doTrackScroll, 100);
                                        doTrackScroll();
                                        return false;
                                };
                               
                                $track.bind('mousedown', onTrackClick);
                               
                                $container.bind(
                                        'mousewheel',
                                        function (event, delta) {
                                                delta = delta || (event.wheelDelta ? event.wheelDelta / 120 : (event.detail) ?
-event.detail/3 : 0);
                                                initDrag();
                                                ceaseAnimation();
                                                var d = dragPosition;
                                                positionDrag(dragPosition - delta * mouseWheelMultiplier);
                                                var dragOccured = d != dragPosition;
                                                return !dragOccured;
                                        }
                                );


                                var _animateToPosition;
                                var _animateToInterval;
                                function animateToPosition()
                                {
                                        var diff = (_animateToPosition - dragPosition) / settings.animateStep;
                                        if (diff > 1 || diff < -1) {
                                                positionDrag(dragPosition + diff);
                                        } else {
                                                positionDrag(_animateToPosition);
                                                ceaseAnimation();
                                        }
                                }
                                var ceaseAnimation = function()
                                {
                                        if (_animateToInterval) {
                                                clearInterval(_animateToInterval);
                                                delete _animateToPosition;
                                        }
                                };
                                var scrollTo = function(pos, preventAni)
                                {
                                        if (typeof pos == "string") {
                                                $e = $(pos, $this);
                                                if (!$e.length) return;
                                                pos = $e.offset().top - $this.offset().top;
                                        }
                                        ceaseAnimation();
                                        var maxScroll = contentHeight - paneHeight;
                                        pos = pos > maxScroll ? maxScroll : pos;
                                        $this.data('jScrollPaneMaxScroll', maxScroll);
                                        var destDragPosition = pos/maxScroll * maxY;
                                        if (preventAni || !settings.animateTo) {
                                                positionDrag(destDragPosition);
                                        } else {
                                                $container.scrollTop(0);
                                                _animateToPosition = destDragPosition;
                                                _animateToInterval = setInterval(animateToPosition, settings.animateInterval);
                                        }
                                };
                                $this[0].scrollTo = scrollTo;
                               
                                $this[0].scrollBy = function(delta)
                                {
                                        var currentPos = -parseInt($pane.css('top')) || 0;
                                        scrollTo(currentPos + delta);
                                };
                               
                                initDrag();
                               
                                scrollTo(-currentScrollPosition, true);
                       
                                // Deal with it when the user tabs to a link or form element within this scrollpane
                                $('*', this).bind(
                                        'focus',
                                        function(event)
                                        {
                                                var $e = $(this);
                                               
                                                // loop through parents adding the offset top of any elements that are relatively positioned between
                                                // the focused element and the jScrollPaneContainer so we can get the true distance from the top
                                                // of the focused element to the top of the scrollpane...
                                                var eleTop = 0;
                                               
                                                while ($e[0] != $this[0]) {
                                                        eleTop += $e.position().top;
                                                        $e = $e.offsetParent();
                                                }
                                               
                                                var viewportTop = -parseInt($pane.css('top')) || 0;
                                                var maxVisibleEleTop = viewportTop + paneHeight;
                                                var eleInView = eleTop > viewportTop && eleTop < maxVisibleEleTop;
                                                if (!eleInView) {
                                                        var destPos = eleTop - settings.scrollbarMargin;
                                                        if (eleTop > viewportTop) { // element is below viewport - scroll so it is at bottom.
                                                                destPos += $(this).height() + 15 + settings.scrollbarMargin - paneHeight;
                                                        }
                                                        scrollTo(destPos);
                                                }
                                        }
                                )
                               
                               
                                if (location.hash && location.hash.length > 1) {
                                        setTimeout(function() {scrollTo(location.hash);}, $.browser.safari ? 100 : 0);
                                }
                               
                                // use event delegation to listen for all clicks on links and hijack them if they are links to
                                // anchors within our content...
                                $(document).bind(
                                        'click',
                                        function(e)
                                        {
                                                $target = $(e.target);
                                                if ($target.is('a')) {
                                                        var h = $target.attr('href');
                                                        if (h && h.substr(0, 1) == '#' && h.length > 1) {
                                                                setTimeout(function() {scrollTo(h, !settings.animateToInternalLinks);}, $.browser.safari ? 100 : 0);
                                                        }
                                                }
                                        }
                                );
                               
                                // Deal with dragging and selecting text to make the scrollpane scroll...
                                function onSelectScrollMouseDown(e)
                                {
                                   $(document).bind('mousemove.jScrollPaneDragging', onTextSelectionScrollMouseMove);
                                   $(document).bind('mouseup.jScrollPaneDragging',   onSelectScrollMouseUp);
                                 
                                }
                               
                                var textDragDistanceAway;
                                var textSelectionInterval;
                               
                                function onTextSelectionInterval()
                                {
                                        direction = textDragDistanceAway < 0 ? -1 : 1;
                                        $this[0].scrollBy(textDragDistanceAway / 2);
                                }

                                function clearTextSelectionInterval()
                                {
                                        if (textSelectionInterval) {
                                                clearInterval(textSelectionInterval);
                                                textSelectionInterval = undefined;
                                        }
                                }
                               
                                function onTextSelectionScrollMouseMove(e)
                                {
                                        var offset = $this.parent().offset().top;
                                        var maxOffset = offset + paneHeight;
                                        var mouseOffset = getPos(e, 'Y');
                                        textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
                                        if (textDragDistanceAway == 0) {
                                                clearTextSelectionInterval();
                                        } else {
                                                if (!textSelectionInterval) {
                                                        textSelectionInterval  = setInterval(onTextSelectionInterval, 100);
                                                }
                                        }
                                }

                                function onSelectScrollMouseUp(e)
                                {
                                   $(document)
                                          .unbind('mousemove.jScrollPaneDragging')
                                          .unbind('mouseup.jScrollPaneDragging');
                                   clearTextSelectionInterval();
                                }

                                $container.bind('mousedown.jScrollPane', onSelectScrollMouseDown);

                               
                                $.jScrollPane.active.push($this[0]);
                               
                        } else {
                                $this.css(
                                        {
                                                'height':paneHeight+'px',
                                                'width':paneWidth-this.originalSidePaddingTotal+'px',
                                                'padding':this.originalPadding
                                        }
                                );
                                $this[0].scrollTo = $this[0].scrollBy = function() {};
                                // clean up listeners
                                $this.parent().unbind('mousewheel').unbind('mousedown.jScrollPane').unbind('keydown.jscrollpane').unbind('keyup.jscrollpane');
                        }
                       
                }
        )
};

$.fn.jScrollPaneRemove = function()
{
        $(this).each(function()
        {
                $this = $(this);
                var $c = $this.parent();
                if ($c.is('.jScrollPaneContainer')) {
                        $this.css(
                                {
                                        'top':'',
                                        'height':'',
                                        'width':'',
                                        'padding':'',
                                        'overflow':'',
                                        'position':''
                                }
                        );
                        $this.attr('style', $this.data('originalStyleTag'));
                        $c.after($this).remove();
                }
        });
}

$.fn.jScrollPane.defaults = {
        scrollbarWidth : 10,
        scrollbarMargin : 5,
        wheelSpeed : 18,
        showArrows : false,
        arrowSize : 0,
        animateTo : false,
        dragMinHeight : 1,
        dragMaxHeight : 99999,
        animateInterval : 100,
        animateStep: 3,
        maintainPosition: true,
        scrollbarOnLeft: false,
        reinitialiseOnImageLoad: false,
        tabIndex : 0,
        enableKeyboardNavigation: true,
        animateToInternalLinks: false,
        topCapHeight: 0,
        bottomCapHeight: 0
};


// clean up the scrollTo expandos
$(window)
        .bind('unload', function() {
                var els = $.jScrollPane.active;
                for (var i=0; i<els.length; i++) {
                        els[i].scrollTo = els[i].scrollBy = null;
                }
        }
);

})(jQuery);



/**
 * jQuery lightBox plugin
 * This jQuery plugin was inspired and based on Lightbox 2 by Lokesh Dhakar (http://www.huddletogether.com/projects/lightbox2/)
 * and adapted to me for use like a plugin from jQuery.
 * @name jquery-lightbox-0.5.js
 * @author Leandro Vieira Pinho - http://leandrovieira.com
 * @version 0.5
 * @date April 11, 2008
 * @category jQuery plugin
 * @copyright (c) 2008 Leandro Vieira Pinho (leandrovieira.com)
 * @license CC Attribution-No Derivative Works 2.5 Brazil - http://creativecommons.org/licenses/by-nd/2.5/br/deed.en_US
 * @example Visit http://leandrovieira.com/projects/jquery/lightbox/ for more informations about this jQuery plugin
 */



(function($){$.fn.lightBox=function(settings){settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.68,fixedNavigation:false,autoplay:true,autoplayAtStart:true,animationTime:8000,
imageLoading:'fileadmin/template/i/lb_loader.gif',
imageBtnPrev:'fileadmin/template/i/lb_prev.png',
imageBtnNext:'fileadmin/template/i/lb_next.png',
imageBtnClose:'fileadmin/template/i/lb_close.gif',
imageBlank:'fileadmin/template/i/lb_blank.gif',
imageBtnPause:'fileadmin/template/i/lb_pause.gif',
imageBtnPlay:'fileadmin/template/i/lb_play.gif',
containerBorderSize:10,containerResizeSpeed:400,txtImage:'Image',txtOf:'of',keyToClose:'c',keyToPrev:'p',keyToNext:'n',imageArray:[],activeImage:0,interval:false,playMode:false},settings);var jQueryMatchedObj=this;function _initialize(){_start(this,jQueryMatchedObj);return false;}function _do_animation(){settings.activeImage=settings.activeImage+1;if(settings.activeImage==settings.imageArray.length)settings.activeImage=0;_set_image_to_view();return false;}function _start(objClicked,jQueryMatchedObj){$('embed, object, select').css({'visibility':'hidden'});settings.imageArray.length=0;settings.activeImage=0;if(jQueryMatchedObj.length==1){settings.imageArray.push(new Array(objClicked.getAttribute('href'),objClicked.getAttribute('title')));}else{for(var i=0;i<jQueryMatchedObj.length;i++){settings.imageArray.push(new Array(jQueryMatchedObj[i].getAttribute('href'),jQueryMatchedObj[i].getAttribute('title')));}}while(settings.imageArray[settings.activeImage][0]!=objClicked.getAttribute('href')){settings.activeImage++;}_set_interface();_set_image_to_view();}function _set_interface(){autoplayBtn='';if(settings.autoplay&&settings.imageArray.length>1){autoplayBtn='<a href="#" id="lightbox-secNav-btnPlay" title="Play"><img src="'+settings.imageBtnPlay+'"/></a>';autoplayBtn+='<a href="#" id="lightbox-secNav-btnPause" title="Pause"><img src="'+settings.imageBtnPause+'"/></a>';}$('body').append('<div id="jquery-overlay"></div><div id="jquery-lightbox"><div id="lightbox-container-image-box"><div id="lightbox-container-image"><img id="lightbox-image"><div style="" id="lightbox-nav"><a href="#" id="lightbox-nav-btnPrev"></a><a href="#" id="lightbox-nav-btnNext"></a></div><div id="lightbox-loading"><a href="#" id="lightbox-loading-link"></a></div></div></div><div id="lightbox-container-image-data-box"><div id="lightbox-container-image-data"><div id="lightbox-image-details"><span id="lightbox-image-details-caption"></span><span id="lightbox-image-details-currentNumber"></span></div><div id="lightbox-secNav">'+autoplayBtn+'<a href="#" id="lightbox-secNav-btnClose"><img src="'+settings.imageBtnClose+'" /></a></div></div></div></div>');var arrPageSizes=___getPageSize();$('#jquery-overlay').css({backgroundColor:settings.overlayBgColor,opacity:settings.overlayOpacity,width:arrPageSizes[0],height:arrPageSizes[1]}).fadeIn();var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]}).show();$('#jquery-overlay,#jquery-lightbox').click(function(){_finish();});$('#lightbox-loading-linkSSS,#lightbox-secNav-btnClose').click(function(){_finish();return false;});$('#lightbox-secNav-btnPlay').unbind().bind('click',function(e){_do_animation();settings.autoplayAtStart=true;settings.interval=window.setInterval(function(){_do_animation();},settings.animationTime);e.preventDefault();return false;});$('#lightbox-secNav-btnPause').click(function(){settings.autoplayAtStart=false;if(settings.interval)window.clearInterval(settings.interval);return false;});$(window).resize(function(){var arrPageSizes=___getPageSize();$('#jquery-overlay').css({width:arrPageSizes[0],height:arrPageSizes[1]});var arrPageScroll=___getPageScroll();$('#jquery-lightbox').css({top:arrPageScroll[1]+(arrPageSizes[3]/10),left:arrPageScroll[0]});});}function _set_image_to_view(){$('#lightbox-loading').show();if(settings.fixedNavigation){$('#lightbox-image,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}else{$('#lightbox-image,#lightbox-nav,#lightbox-nav-btnPrev,#lightbox-nav-btnNext,#lightbox-container-image-data-box,#lightbox-image-details-currentNumber').hide();}var objImagePreloader=new Image();objImagePreloader.onload=function(){$('#lightbox-image').attr('src',settings.imageArray[settings.activeImage][0]);_resize_container_image_box(objImagePreloader.width,objImagePreloader.height);objImagePreloader.onload=function(){};};objImagePreloader.src=settings.imageArray[settings.activeImage][0];};function _resize_container_image_box(intImageWidth,intImageHeight){var intCurrentWidth=$('#lightbox-container-image-box').width();var intCurrentHeight=$('#lightbox-container-image-box').height();var intWidth=(intImageWidth+(settings.containerBorderSize*2));var intHeight=(intImageHeight+(settings.containerBorderSize*2));var intDiffW=intCurrentWidth-intWidth;var intDiffH=intCurrentHeight-intHeight;$('#lightbox-container-image-box').animate({width:intWidth,height:intHeight},settings.containerResizeSpeed,function(){_show_image();});if((intDiffW==0)&&(intDiffH==0)){if($.browser.msie){___pause(250);}else{___pause(100);}}$('#lightbox-container-image-data-box').css({width:intWidth});$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({height:intImageHeight+(settings.containerBorderSize*2)});};function _show_image(){$('#lightbox-loading').hide();$('#lightbox-image').fadeIn(function(){_show_image_data();_set_navigation();if(settings.autoplayAtStart&&settings.autoplay&&settings.imageArray.length>1){if(settings.interval)window.clearInterval(settings.interval);settings.interval=window.setInterval(function(){_do_animation();},settings.animationTime);}});_preload_neighbor_images();};function _show_image_data(){$('#lightbox-container-image-data-box').slideDown('fast');$('#lightbox-image-details-caption').hide();if(settings.imageArray[settings.activeImage][1]){$('#lightbox-image-details-caption').html(settings.imageArray[settings.activeImage][1]).show();}if(settings.imageArray.length>1){$('#lightbox-image-details-currentNumber').html(settings.txtImage+' '+(settings.activeImage+1)+' '+settings.txtOf+' '+settings.imageArray.length).show();}}function _set_navigation(){$('#lightbox-nav').show();$('#lightbox-nav-btnPrev,#lightbox-nav-btnNext').css({'background-image':'url('+settings.imageBlank+')'});if(settings.activeImage!=0){if(settings.fixedNavigation){$('#lightbox-nav-btnPrev').css({'background-image':'url('+settings.imageBtnPrev+')'}).unbind().bind('click',function(){if(settings.interval)window.clearInterval(settings.interval);settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnPrev').unbind().hover(function(){$(this).css({'background-image':'url('+settings.imageBtnPrev+')'});},function(){$(this).css({'background-image':'url('+settings.imageBlank+')'});}).show().bind('click',function(){if(settings.interval)window.clearInterval(settings.interval);settings.activeImage=settings.activeImage-1;_set_image_to_view();return false;});}}if(settings.activeImage!=(settings.imageArray.length-1)){if(settings.fixedNavigation){$('#lightbox-nav-btnNext').css({'background-image':'url('+settings.imageBtnNext+')'}).unbind().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}else{$('#lightbox-nav-btnNext').unbind().hover(function(){$(this).css({'background-image':'url('+settings.imageBtnNext+')'});},function(){$(this).css({'background-image':'url('+settings.imageBlank+')'});}).show().bind('click',function(){settings.activeImage=settings.activeImage+1;_set_image_to_view();return false;});}}_enable_keyboard_navigation();}function _enable_keyboard_navigation(){$(document).keydown(function(objEvent){_keyboard_action(objEvent);});}function _disable_keyboard_navigation(){$(document).unbind();}function _keyboard_action(objEvent){if(objEvent==null){keycode=event.keyCode;escapeKey=27;}else{keycode=objEvent.keyCode;escapeKey=objEvent.DOM_VK_ESCAPE;}key=String.fromCharCode(keycode).toLowerCase();if((key==settings.keyToClose)||(key=='x')||(keycode==escapeKey)){_finish();}if((key==settings.keyToPrev)||(keycode==37)){if(settings.activeImage!=0){settings.activeImage=settings.activeImage-1;_set_image_to_view();_disable_keyboard_navigation();}}if((key==settings.keyToNext)||(keycode==39)){if(settings.activeImage!=(settings.imageArray.length-1)){settings.activeImage=settings.activeImage+1;_set_image_to_view();_disable_keyboard_navigation();}}}function _preload_neighbor_images(){if((settings.imageArray.length-1)>settings.activeImage){objNext=new Image();objNext.src=settings.imageArray[settings.activeImage+1][0];}if(settings.activeImage>0){objPrev=new Image();objPrev.src=settings.imageArray[settings.activeImage-1][0];}}function _finish(){$('#jquery-lightbox').remove();$('#jquery-overlay').fadeOut(function(){$('#jquery-overlay').remove();});$('embed, object, select').css({'visibility':'visible'});if(settings.interval)window.clearInterval(settings.interval);}function ___getPageSize(){var xScroll,yScroll;if(window.innerHeight&&window.scrollMaxY){xScroll=window.innerWidth+window.scrollMaxX;yScroll=window.innerHeight+window.scrollMaxY;}else if(document.body.scrollHeight>document.body.offsetHeight){xScroll=document.body.scrollWidth;yScroll=document.body.scrollHeight;}else{xScroll=document.body.offsetWidth;yScroll=document.body.offsetHeight;}var windowWidth,windowHeight;if(self.innerHeight){if(document.documentElement.clientWidth){windowWidth=document.documentElement.clientWidth;}else{windowWidth=self.innerWidth;}windowHeight=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){windowWidth=document.documentElement.clientWidth;windowHeight=document.documentElement.clientHeight;}else if(document.body){windowWidth=document.body.clientWidth;windowHeight=document.body.clientHeight;}if(yScroll<windowHeight){pageHeight=windowHeight;}else{pageHeight=yScroll;}if(xScroll<windowWidth){pageWidth=xScroll;}else{pageWidth=windowWidth;}arrayPageSize=new Array(pageWidth,pageHeight,windowWidth,windowHeight);return arrayPageSize;};function ___getPageScroll(){var xScroll,yScroll;if(self.pageYOffset){yScroll=self.pageYOffset;xScroll=self.pageXOffset;}else if(document.documentElement&&document.documentElement.scrollTop){yScroll=document.documentElement.scrollTop;xScroll=document.documentElement.scrollLeft;}else if(document.body){yScroll=document.body.scrollTop;xScroll=document.body.scrollLeft;}arrayPageScroll=new Array(xScroll,yScroll);return arrayPageScroll;};function ___pause(ms){var date=new Date();curDate=null;do{var curDate=new Date();}while(curDate-date<ms);};return this.unbind('click').click(_initialize);};})(jQuery);







var loading_stat = 0;
var xlength = 0;
var loading_finished = 0;
var current = false;


function callback(hash)
{
   /*if(hash && hash != '')
   {
      current = hash;
      if($('#container').attr('class') == 'content')
      {
        $('.mainLogo img').animate({"width":'1000px',"height":'564px'},'600');
        $('div.wrapper:eq(0)').animate({"top":'595px',"left":'1000px'},'600');
      }
   } */
}

$(document).ready(function(){
/**    
    $('#sound').flash(
        { src: 'fileadmin/content/sound.swf',
          width: 74,
          height: 28,
          bgcolor:'#000000' }
    );
   
**/
   
   
   // History
   // $.history.init(callback);
    

    $('.scroll-pane').jScrollPane({showArrows:true,scrollbarWidth:20});
   
    /* ----- Lightbox --------- */
    /* --------------------------*/
    $('.lightboxlink, a[rel*=lightbox]').each(function(){
      $(this).attr('title',$(this).find("img").attr('alt'));
    });
    $('.lightboxlink, a[rel*=lightbox]').lightBox();

   
   
   
    $('area#hightlightInLink').hover(function(){
      if ($('.highlightIn').queue("fx").length>0){return};
      $('.highlightIn').fadeIn("slow");
    },
    function(){
      $('.highlightIn').fadeOut("fast",function(){
        //$('.highlightOut').stop(false);
      });
    });
    $('area#hightlightOutLink').hover(function(){
      if ($('.highlightOut').queue("fx").length>0){return};
      $('.highlightOut').fadeIn("slow");
    },
    function(){
      $('.highlightOut').fadeOut("fast",function(){
        //$('.highlightIn').stop(false);
      });
    });

    
    //Click Links
    $('.home .mainMenu a:gt(0)').bind('click',function(e){
        
        
        
        xId = $(this).attr('id');
        xId = xId.replace('link','');
        $('#container #pagelink').hide().removeClass('home');
        
        $('.mainLogo img').animate({"width":'283px',"height":'150px'},'600');
        $('div#ct'+ xId).animate({"top":'0px',"left":'0px'},'600');
        $('.mainLink').css({"display":"none"}); 
        $('#container .wrapper:eq(0) div.mainMenu').css({"display":"none"});
        current = xId;
        
        e.preventDefault();
        
        //History
        //$.history.load(current.replace(/^.*#/, '#'));
        
        
    });
    
    $('.content .mainMenu a').live('click',function(e){
        
        
        
        //Get the index
        $th = $(this);
        index = ($th.parent().children().index($th))*1 / 2;
        
        
        if($(this).parent().attr('class') !='homeLink')
        {
            $('#container #pagelink').hide().removeClass('home');;
            
            $('#container .wrapper:eq(0) div.mainMenu').css({"display":"none"});
            if(!current) xCurrent = 'div.wrapper:eq(0)'; 
            else xCurrent = 'div#ct'+ current;
            
            xHref = $(this).attr('href');
            
            
            $('.mainLogo img').animate({"width":'1000px',"height":'564px'},'600');
            $(xCurrent).animate({"top":'595px',"left":'1000px'},'600',function(){
              $('div.dynamicContent#ct'+index).animate({"top":'0px',"left":'0px'},'600');
              $('.mainLogo img').animate({"width":'283px',"height":'150px'},'600');
            });

            current = index;
            
            $('.mainLink').css({"display":"none"});
        
        
            //History
            //$.history.load(index);
        }
        
        e.preventDefault();
            
    });
    
    $('.content .mainMenu .homeLink a').live('click',function(e){  
        
        if(current)
        {
          $('div#ct'+ current).animate({"top":'595px',"left":'1000px'},'600');
        }
        $('.mainLogo img').animate({"width":'1000px',"height":'564px'},'600',function(){
          $('#container .wrapper:eq(0) div.mainMenu').css({"display":"block"});
          $('#container #pagelink').show().addClass('home');;
        });
        $('.mainLink').css({"display":"block"}); 
        $('#container .wrapper:eq(0) div:not(div.mainMenu)').css({"display":"none"});
        $('#container .wrapper:eq(0) div.mainMenu').addClass('back2home');
        
        
        


        $('.home .wrapper:eq(0) .mainMenu a').removeClass('menu_selected');
        $('div.wrapper:eq(0)').css({"left":"0px","top":"0px"});
        e.preventDefault();
        
        //History
        //$.history.load('');
        
        current = false;
                 
    });
    
    
    
        
    //Preload Contents
    z=1;
    k=0;
    var xlength = $('.mainMenu a:gt(0)').length;
    $('.mainMenu a:gt(0)').each(function(){
        
        xHref = $(this).attr('href');      
        $(this).attr('id','link' + z);

        $('div#container').append('<div id="ct'+z+'" class="dynamicContent content" alt="'+xHref+'"></div>');
        
        // Preload
        $('.ajax').fadeIn("fast");
        $('div#ct'+z).load(
            xHref + ' #container .wrapper',
            function(){
              k++;
              loading_stat = k;
              if(k==xlength)
              {
                  
                  $('.scroll-pane').jScrollPane({showArrows:true,scrollbarWidth:20});
                  
                  $('.lightboxlink').each(function(){
                    $(this).attr('title',$(this).find("img").attr('alt'));
                  });
                  $('.lightboxlink').lightBox();
                  
                  if(current)
                  {
                        $('div.dynamicContent#ct'+current).animate({"top":'0px',"left":'0px'},'600');
                        $('.mainLogo img').animate({"width":'283px',"height":'150px'},'600');
                        
                  }
                  
                  $('.ajax').fadeOut("fast");
              }
            }
        );
        
        z++;
        
        
    });
});