/**
 * @param {Object} context the 'this' value to be used.
 * @param {arguments} [1..n] optional arguments that are
 * prepended to returned function's call.
 * @return {Function} a function that applies the original
 * function with 'context' as the thisArg.
 */
Function.prototype.delegate = function(context){
  var fn = this,
      ap, concat, args,
      isPartial = arguments.length > 1;
  // Strategy 1: just bind, not a partialApply
  if(!isPartial) {
    return function() {
        if(arguments.length !== 0) {
          return fn.apply(context, arguments);
        } else {
          return fn.call(context); // faster in Firefox.
        }
      };
    } else {
    // Strategy 2: partialApply
    ap = Array.prototype,
    args = ap.slice.call(arguments, 1);
    concat = ap.concat;
    return function() {
      return fn.apply(context,
        arguments.length === 0 ? args :
        concat.apply(args, arguments));
    };
  }
};

(function() {
	if (typeof console == 'undefined') {
		window['console'] = {};
	}
	;
	if (typeof console.debug == 'undefined') {
		window['console'].debug = function() {
			if (typeof console.log == 'undefined') {
			}
			else console.log(arguments);
		};
	}
	window.fieldsetInitState = {};
}());


//
// create closure
//
(function($) {
	$.extend({
	    keys:    function(obj){
	        var a = [];
	        $.each(obj, function(k){ a.push(k) });
	        return a;
	    }
	})
	var Temp = function(){
		this.add = function(key, value){
			if(typeof this.values == "undefined")
				this.values = {};
			if(typeof this.values[key] == "undefined" || typeof this.values[key] == null)
				this.values[key] = 0;
			this.values[key]+=value;
			return this.values[key];
		};
		this.get = function(key){
			if(typeof this.values == "undefined")
				this.values = {};
			if(typeof this.values[key] == "undefined")
				this.values[key] = null;
			return this.values[key];
		};
		this.set = function(key, value){
			if(typeof this.values == "undefined")
				this.values = {};
			if(typeof this.values[key] == "undefined")
				this.values[key] = value;
			return this.values[key];
		};

	};

	function getToggleText(element){

		var r = {};
		$(element).find('input[name^=toggleText]').each(function(){
			r[this.name.substring(10).toLowerCase()] = this.value;
		});
		return ($.keys(r).length < 1) ? null : r;
	};

	function getButtonSwitch(element){
		var buttonSwitch = $('<p />').addClass('buttonSwitch');
		var link = $('<a />').attr('href', 'javascript:void(0)');
		buttonSwitch.append(link);
		return {
			p: buttonSwitch,
			a: link
		};
	};

	$.getBaseUri = function(){
		var b = $("base").attr("href");
		if(b) return $("base").attr("href");
		else return "";
	};

	$.fn.faq = function() {
		return this.each(function() {
			var $this = $(this);
			var dl = $('dl', $this);
			dl.addClass('inv');
			var ul = $(" <ul />");
			var dd = $('dt', $this);
			dd.each(
				function(){
					var li = $(" <li />").attr("class", "");
					var fakeDt = $(" <div />").attr("class", "dt").html($(this).html());
					var fakeDd = $(" <div />").attr("class", "dd").html($(this).next().html());
					li.append(fakeDt);
					li.append(fakeDd);
					ul.append(li);
				}
			);
			dl.before(ul);
			$('.dt', $this).click(
				function(){
					if($($(this).parent()).hasClass('chosen')){
						$($(this).parent()).removeClass('chosen')
					} else {
						$(this).parent().siblings().each(function(){
							var li = $(this);
							if(li.hasClass('chosen')){
								li.removeClass('chosen');
							}
						});
						$($(this).parent()).addClass('chosen');
					}
				}
			);
		});
	};
	$.fn.expanders = function(options) {
		var defaults = {
			isAccordion: false
		};
		var options = $.extend({}, defaults, options);
		return this.each(function() {
			var $this = $(this);
			var isAccordion = options.isAccordion || $(this).hasClass('accordion');
			var toExpand =$('.toExpand', this);
			if(toExpand.length > 1){
				if(isAccordion){
					function setChosen(index) {
						return $this.attr("chosen", index);
					}
					function getChosen(reJquery){
						if(reJquery)
							return $this.find(".toExpand[index='"+getChosen()+"']");
						else
							return $this.attr("chosen");
					};
					function getChosenHead(reJquery){
						if(reJquery)
							return $this.find(".toExpand[index='"+getChosen()+"'] .expHead");
						else
							return $this.find(".toExpand[index='"+getChosen()+"'] .expHead")[0];
					}
					function getChosenContent(reJquery){
						if(reJquery)
							return $this.find(".toExpand[index='"+getChosen()+"'] .expContent");
						else
							return $this.find(".toExpand[index='"+getChosen()+"'] .expContent")[0];
					}
					$this.setClassAttributs("chosen");
					toExpand.each(function(i){
						$(this).attr("index", i);
						$('.expHead', this)
							.click(function(){
								if(getChosenHead() != this){
									getChosenContent(true).slideToggle('slow');
									$('.expContent', $(this).parent()).slideToggle('slow');
									setChosen($(this).parent().attr("index"));
								} else {
									getChosenContent(true).slideToggle('slow');
									setChosen(-1);
								}
								$(this).parent().toggleClass('notExpanded');
							});
						if(getChosen(true)[0] != this)
							$(this).addClass("notExpanded");
						if(i != getChosen()){
							$('.expContent', this).css('display', 'none');
						}
					}).addClass('hasJS');
				}else {
					toExpand.each(function(){
						$('.expHead', this)
							.click(function(){
								$('.expContent', $(this).parent()).slideToggle('slow');
								$(this).parent().toggleClass('notExpanded');
							});
						$(this).addClass("notExpanded");
						$('.expContent', this).css('display', 'none');
					}).addClass('hasJS');
				}
			}
		});
	};

	$.fn.intrCalc = function() {
		function toggleTrs(trs){
			trs.each(function(){
				$(this).toggleClass('inv');
			});
		}
		return this.each(function() {
			var $this = $(this);
			$this.find('.oTable').each(function(t){
				t=$(this);
				var toggleText = getToggleText($this);
				if(toggleText != null){
					var buttonSwitch = getButtonSwitch($this);
					var trs = t.find('tbody tr');
	//				console.debug(trs);
					$(buttonSwitch.a).text(toggleText.open).click(function(){
						if(!$(this).hasClass('close')){
							$(this).text(toggleText.close);
							$(this).addClass('close');
						} else {
							$(this).text(toggleText.open);
							$(this).removeClass('close');
						}
						toggleTrs(trs);
					});
					t.find('table').before(buttonSwitch.p);
				toggleTrs(trs);
				}
			});

		});
	};

	$.fn.toggleHiddenContent = function(buttonSwitchAfter) {
		return this.each(function() {
			var toggleText = getToggleText(this);
			var hiddenContent = $(this).find('.hiddenContent').addClass('inv');
			var buttonSwitch = getButtonSwitch(this);
			buttonSwitch.a.text(toggleText.open).click(function(){
				if(hiddenContent.hasClass('inv')){
					hiddenContent.removeClass('inv');
					$(this).text(toggleText.close);
					$(this).addClass('close');
				} else {
					hiddenContent.addClass('inv');
					$(this).text(toggleText.open);
					$(this).removeClass('close');
				}
			});
			$(this).find(buttonSwitchAfter).after(buttonSwitch.p);
		});
	};
	$.fn.video = function() {
		var t = new Temp();
		function getId(name, rfunc){
			var newId = name+(t.add('video', 1));
			if($('#' + newId).length > 0)
				getId(name, rfunc);
			else
				rfunc(newId);
		}
		return this.each(function() {
			var $this = $(this);
			var $parent = $this.parent();
			var img = $('img', $this);
			var dimensions = {
				width: img.width(),
				height: img.height()+20
			};
			if(swfobject.getFlashPlayerVersion().major >= 9) {
				$parent.height($parent.height()+20);
				if(!$this.attr('id')) {
					getId('videoPlayer', function(id){
						$this.attr('id', id);
					});
				};
				var flashvars = {file: $this.attr('href'), "image": img.attr('src')};
				var params = {'allowfullscreen':'true'};
				var attributes = {};
				swfobject.embedSWF($.getBaseUri()+"../swf/longtail/player.swf", $this.attr('id'), dimensions.width, dimensions.height, "9.0.0", false, flashvars, params, attributes);
			}
		});
	};
	$.fn.liToSelect = function(headline) {
		var checkHref = function(href){
			if(!/^(https?:\/\/|\/)/.test(href)){
				href = "/" + href;
			}
			return href;
		};
		return this.each(function() {
			var $this = $(this);
			var $div = $("<div />").addClass("selects");
			var $headline = $this.find(headline).addClass("inv");
			$cont = $headline.next().each(function(i){
				var div = $("<div />");
				var select = $("<select />");
				select[0].options[select[0].options.length] = new Option($($headline[i]).text(), '', false, false);
				$(this).find("li a").each(function(){
					select[0].options[select[0].options.length] = new Option(this.firstChild.data, checkHref($(this).attr("href")), false, false);
				});
				div.append(select).append($("<button />")
						.attr({"class":"submit"})
						.click(function(){
							if(select[0].value != '')
								location.href = select[0].value;
						})
						.append($("<span />").append($("<span />").append($("<span />").append($("<span />").text("los"))))));
				$div.append(div);
				$(this).addClass("inv");
			});
			$this.find(":first").after($div);
		});
	};
	$.fn.additionalInput = function() {
		return this.each(function() {
			var $this = $(this);
			function checkState(checked){
				if(checked){
					$this[0].disabled = false;
				} else {
					$this[0].disabled = true;
					if($this[0].nodeName == "SELECT") {
						for(var i=0; i<$this[0].options.length; i++){
							if(i==0)
								$this[0].options[i].selected = true;
							else
								$this[0].options[i].selected = false;
						};
					} else if ($this[0].nodeName == "INPUT"){;
						$this[0].value = "";
					}
				}
				return checked;
			}
			var parentInput = $($this.parents()[1]).find("p:first input");
			checkState(parentInput[0].checked);
			$($this.parents()[2]).find('input[name="'+parentInput[0].name+'"]').change(function(){
				checkState(parentInput[0].checked);
			});
		});
	};
	$.fn.externLinks = function() {
		return this.each(function() {
			var t = $(this).text();
			$(this).text("");
			$(this).append("<span>"+t+"</span>");
			$(this).removeClass("extern");
			$(this).addClass("extern2");
		});
	};
	$.fn.inpPrefilled = function() {
		return this.each(function() {
			$(this).setClassAttributs('dvalue');
			$(this).setClassAttributs('showlabel');
			if($(this).attr('showlabel') != "true"){
				$("label[for='"+this.id+"']").addClass("inv");
			};
			var dv = $(this).attr('dvalue') || $("label[for='"+this.id+"']").text();
			if(this.value == ""){
				this.value = dv;
			}
			$(this).click(function(){
				if(this.value == dv){
					this.value = "";
					$(this).removeClass('preFilled');
				}
			});
			$(this).blur(function(){
				if(this.value == ""){
					this.value = dv;
					$(this).addClass('preFilled');
				}
			});

		});
	};
	$.fn.datepicker = function() {
		return this.each(function() {
//			$(this).addClass("hasJs");
			$(this).find("input").each(function(){
				var labels = $($(this).parents()[1]).find("label.inv[for='"+this.id+"']");
				var labelText = jQuery.trim(labels.text());
				$(this).setClassAttributs("default");
				if(this.value == "") {
					this.value = $(this).attr("default").substring(0, $(this).attr("maxlength"));
				}
			});
//			$(this).click(function(){alert("Function not available!")});
		});
	};
	$.fn.setClassAttributs = function(attributeName) {
		return this.each(function() {
			var $this = $(this);
			var splitting = this.className.split(" ");
			for(var i= 0; i<splitting.length; i++) {
				if(splitting[i].indexOf(attributeName) != -1){
					var value = splitting[i].substring(splitting[i].indexOf("(")+1, splitting[i].indexOf(")"));
					if(value != "") {
						$this.attr(attributeName, value);
					}
					$(this).removeClass(splitting[i]);
				}
			}
		});
	};
	$.fn.textMaxlength = function() {
		return this.each(function() {
			var $this = $(this);
			$this.setClassAttributs("maxlength");
			$this.setClassAttributs("translateFrom");
			$this.setClassAttributs("translateCharacter");
			if($this.attr("maxlength") != undefined) {
				function countCharacters(){
					$this.siblings().text("("+$this[0].value.length+" "+$this.attr("translatefrom")+" "+$this.attr("maxlength")+" "+$this.attr("translatecharacter")+")");
				}
				$this.wrap('<div class="textareaMaxlengthMod" />');
				$($this.parents()[0]).append($("<span />"));
				countCharacters();
				this.onkeyup = function(){
					if(this.value.length > $this.attr("maxlength")) {
						this.value = this.value.substring(0, $this.attr("maxlength"));
					}
					countCharacters();
				};
			}
		});
	};
	$.fn.slideshow = function() {
		var t = new Temp();
		if(typeof window.slideshowFlashloaded == "undefined")
			window.slideshowFlashloaded = function(flashObjId){
				function showImage(image){
					flash.setPause();
					flash.showImage(image);
					return image;
				}
				var flash = $('#'+flashObjId)[0];
				flash.loadJSON(t.get(flashObjId));
				var $p = $('#'+flashObjId).parent();
				var items = 0;
				if($p.attr('enableskip') == "true"){
					var current = showImage(0);
					items = $p.attr("items");
					if($p.find("a").length == 0) {;
						var $next = $('<a href="javascript:void(0)" class="next" />');
						$next.append('<img src="'+$.getBaseUri()+'../img/style/icons/arrow_04204E.gif" />');
						$next.bind('click', function(){
							current++;
							if(current >= items) current = 0;
							current = showImage(current);
						});
						$p.append($next);
						var $prev = $('<a href="javascript:void(0)" class="prev" />');
						$prev.append('<img src="'+$.getBaseUri()+'../img/style/icons/arrow_right_dbe2ec.gif" />');
						$prev.bind('click', function(){
							current--;
							if(current < 0) current = items-1;
							current = showImage(current);
						});
						$p.append($prev);
					}
				}
			};
		function getId(name, rfunc){
			var newId = name+(t.add('idCounter', 1));
			if($('#' + newId).length > 0)
				getId(name, rfunc);
			else
				rfunc(newId);
		}

		return this.each(function() {
			var $this = $(this);
			var images = '{"images":[';
			var dimensions = {};
			$this.wrap('<div class="'+ this.className +'" />');
			var $p = $this.parent();
			$p.setClassAttributs("enableSkip");
			$p.setClassAttributs("dimW");
			$p.setClassAttributs("dimH");
			dimensions.width = $p.attr('dimw');
			dimensions.height = $p.attr('dimh');
			var l = $("img", this).each(function(i){
				images+= ((i==0) ? '' : ',') + '{';
				if(i==0){
					if(!dimensions.height) dimensions.height = $(this).height();
					if(!dimensions.width) dimensions.width = $(this).width();
				};
				var a = $(this).parent();
				images+='"image":"'+this.src+'"';
				images+=',"url":"'+a.attr('href')+'"';
				if(a.attr('target') != "")
					images+=',"target":"'+a.attr('target')+'"';

				images+='}';
			}).length;
			$p.attr("items", l);
			images+=']}';
			$this.height(dimensions.height);
			$this.width(dimensions.width);
			$this.css("overflow", "hidden");
			if(!$this.attr('id')) {
				getId('slideshow', function(id){
					$this.attr('id', id);
				});
			};
			t.set($this.attr('id'), images);
			var attributes = {
			  id: $this.attr('id'),
			  name: $this.attr('id')
			};
			var flashvars = {
				isLoaded:"slideshowFlashloaded",
				id:$this.attr('id'),
				delayTime:"0",
				intervalTime: "3000",
				autoStart: ($p.attr("autostart") != "true") ? "true" : "false"
			};
			var params = {
				wmode:"transparent",
				scalemode:"noscale"
			};
			swfobject.embedSWF("../swf/slideshow.swf", $this.attr('id'), dimensions.width, dimensions.height, "9.0.0", "expressInstall.swf", flashvars, params, attributes);
		});
	};
	$.fn.compass = function() {
		function resetBlocks(){
			this.find('ol .requestBlock').hide()
			setHeight.delegate(this)(this.find('.requestBlock').height());
		}
		function setHeight(height){
			this.find('.requestBlocks').height(height);
		}
		function responseBlock(answer){
			var response = $(this).find('.responseBlock')[0];
			if(!answer){
				$($(response).parents().find('.roundedBlock')[0]).remove();
				return null;
			}
			if(!response) {
				response = $('<div />').addClass('responseBlock').append($('<h3 />').text('Ihre Antworten')).append($('<div />').append($('<ul />').addClass('responses')).addClass('richTextMod'));
			} else {
				response = this;
			}
			response.find('.responses').append($('<li />').text(answer));
			return response;
		}
		function parseAnswer(){
			return this.each(function(){
				var $this = $(this);
				$this.data('answer', ($this.find('span.inv span').text() || $this.text()));
			});
		}
		function roundedBorderWrap(block){
			return block
					.wrap($('<div />').addClass('roundedBlock'))
					.wrap($('<div />').addClass('rb2'))
					.addClass('rbEnd');
		}

		return this.each(function(){
			var $this = $(this);
			var $response = null;
			var $requestBlocks = $('<div />').addClass('requestBlocks');
			var $reset = $('<p />').append($('<a />').text($this.find('input[name=buttonResetText]').val()).attr({'href': 'javascript:void(0)'}).click(function(){
				resetBlocks.delegate($this)();
				$response = responseBlock.delegate($this)();
			})).appendTo('ol .endBlock').addClass('reset');
			roundedBorderWrap($($($this.find('div.requestBlock')[0]).wrap($requestBlocks).parents()[0]));
			$this.find('ol .requestBlock').hide();
			parseAnswer.delegate($this.find('p.answer'))().wrapInner($('<span />')).wrapInner($('<span />')).wrapInner($('<span />')).wrapInner($('<span />')).wrapInner($('<a />').addClass('ctaBig').attr({'href': 'javascript:void(0)'}));
			$this.find('p.answer a').click(function(event){
				var block = $($($(this).parents()[0]).siblings()[0]).show();
				if(block[0] != document){
					setHeight.delegate($this)(block.height());
					if(!$response){
						$response = responseBlock.delegate($this)($(this).text());
						$($this.find('div.roundedBlock')[0]).before($response);
						roundedBorderWrap($response);
					} else {
						responseBlock.delegate($this)($($(this).parents()[0]).data('answer'));
					}
				}
			});
			$this.find('li:first-child>p').addClass('leftAnswer');
			$this.find('li:not(:first-child)>p').addClass('rightAnswer');
			resetBlocks.delegate($this)();
		});
	};

})(jQuery);

/**!
 * jQuery Maxlength plugin
 * @version		$Id: jquery_plugins.js 880 2011-02-08 11:35:05Z stefans $
 * @package		jQuery maxlength 1.0.5
 * @copyright	Copyright (C) 2009 Emil Stjerneman / http://www.anon-design.se
 * @license		GNU/GPL, see LICENSE.txt
 */

(function($)
{

	$.fn.maxlength = function(options)
	{
		var settings = jQuery.extend(
		{
			events:				      [], // Array of events to be triggerd
			maxCharacters:		  10, // Characters limit
			status:				      true, // True to show status indicator bewlow the element
			statusClass:		    "status", // The class on the status div
			statusText:			    "character left", // The status text
			notificationClass:	"notification",	// Will be added to the emement when maxlength is reached
			showAlert: 			    false, // True to show a regular alert message
			alertText:			    "You have typed too many characters.", // Text in the alert message
			slider:				      false // Use counter slider
		}, options );

		// Add the default event
		$.merge(settings.events, ['keyup']);

		return this.each(function()
		{
			var item = $(this);
			var charactersLength = $(this).val().length;

      // Update the status text
			function updateStatus()
			{
				var charactersLeft = settings.maxCharacters - charactersLength;

				if(charactersLeft < 0)
				{
					charactersLeft = 0;
				}

				item.next("div").html(charactersLeft + " " + settings.statusText);
			}

			function checkChars()
			{
				var valid = true;

				// Too many chars?
				if(charactersLength >= settings.maxCharacters)
				{
					// Too may chars, set the valid boolean to false
					valid = false;
					// Add the notifycation class when we have too many chars
					item.addClass(settings.notificationClass);
					// Cut down the string
					item.val(item.val().substr(0,settings.maxCharacters));
					// Show the alert dialog box, if its set to true
					showAlert();
				}
				else
				{
					// Remove the notification class
					if(item.hasClass(settings.notificationClass))
					{
						item.removeClass(settings.notificationClass);
					}
				}

				if(settings.status)
				{
					updateStatus();
				}
			}

			// Shows an alert msg
			function showAlert()
			{
				if(settings.showAlert)
				{
					alert(settings.alertText);
				}
			}

			// Check if the element is valid.
			function validateElement()
			{
				var ret = false;

				if(item.is('textarea')) {
					ret = true;
				} else if(item.filter("input[type=text]")) {
					ret = true;
				} else if(item.filter("input[type=password]")) {
					ret = true;
				}

				return ret;
			}

			// Validate
			if(!validateElement())
			{
				return false;
			}

			// Loop through the events and bind them to the element
			$.each(settings.events, function (i, n) {
				item.bind(n, function(e) {
					charactersLength = item.val().length;
					checkChars();
				});
			});

			// Insert the status div
			if(settings.status)
			{
				item.after($("<div/>").addClass(settings.statusClass).html('-'));
				updateStatus();
			}

			// Remove the status div
			if(!settings.status)
			{
				var removeThisDiv = item.next("div."+settings.statusClass);

				if(removeThisDiv) {
					removeThisDiv.remove();
				}

			}

			// Slide counter
			if(settings.slider) {
				item.next().hide();

				item.focus(function(){
					item.next().slideDown('fast');
				});

				item.blur(function(){
					item.next().slideUp('fast');
				});
			}

		});
	};
})(jQuery);


/*
 * jquery.tools 1.1.2 - The missing UI library for the Web
 *
 * [tools.tabs-1.0.4, tools.tabs.slideshow-1.0.2, tools.tabs.history-1.0.2, tools.overlay-1.1.2, tools.overlay.gallery-1.0.0, tools.overlay.apple-1.0.1, tools.expose-1.0.5]
 *
 * Copyright (c) 2009 Tero Piirainen
 * http://flowplayer.org/tools/
 *
 * Dual licensed under MIT and GPL 2+ licenses
 * http://www.opensource.org/licenses
 *
 * -----
 *
 * File generated: Mon Mar 22 15:57:38 GMT 2010
 */
(function(d){d.tools=d.tools||{};d.tools.tabs={version:"1.0.4",conf:{tabs:"a",current:"current",onBeforeClick:null,onClick:null,effect:"default",initialIndex:0,event:"click",api:false,rotate:false},addEffect:function(e,f){c[e]=f}};var c={"default":function(f,e){this.getPanes().hide().eq(f).show();e.call()},fade:function(g,e){var f=this.getConf(),j=f.fadeOutSpeed,h=this.getPanes();if(j){h.fadeOut(j)}else{h.hide()}h.eq(g).fadeIn(f.fadeInSpeed,e)},slide:function(f,e){this.getPanes().slideUp(200);this.getPanes().eq(f).slideDown(400,e)},ajax:function(f,e){this.getPanes().eq(0).load(this.getTabs().eq(f).attr("href"),e)}};var b;d.tools.tabs.addEffect("horizontal",function(f,e){if(!b){b=this.getPanes().eq(0).width()}this.getCurrentPane().animate({width:0},function(){d(this).hide()});this.getPanes().eq(f).animate({width:b},function(){d(this).show();e.call()})});function a(g,h,f){var e=this,j=d(this),i;d.each(f,function(k,l){if(d.isFunction(l)){j.bind(k,l)}});d.extend(this,{click:function(k,n){var o=e.getCurrentPane();var l=g.eq(k);if(typeof k=="string"&&k.replace("#","")){l=g.filter("[href*="+k.replace("#","")+"]");k=Math.max(g.index(l),0)}if(f.rotate){var m=g.length-1;if(k<0){return e.click(m,n)}if(k>m){return e.click(0,n)}}if(!l.length){if(i>=0){return e}k=f.initialIndex;l=g.eq(k)}if(k===i){return e}n=n||d.Event();n.type="onBeforeClick";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}c[f.effect].call(e,k,function(){n.type="onClick";j.trigger(n,[k])});n.type="onStart";j.trigger(n,[k]);if(n.isDefaultPrevented()){return}i=k;g.removeClass(f.current);l.addClass(f.current);return e},getConf:function(){return f},getTabs:function(){return g},getPanes:function(){return h},getCurrentPane:function(){return h.eq(i)},getCurrentTab:function(){return g.eq(i)},getIndex:function(){return i},next:function(){return e.click(i+1)},prev:function(){return e.click(i-1)},bind:function(k,l){j.bind(k,l);return e},onBeforeClick:function(k){return this.bind("onBeforeClick",k)},onClick:function(k){return this.bind("onClick",k)},unbind:function(k){j.unbind(k);return e}});g.each(function(k){d(this).bind(f.event,function(l){e.click(k,l);return false})});if(location.hash){e.click(location.hash)}else{if(f.initialIndex===0||f.initialIndex>0){e.click(f.initialIndex)}}h.find("a[href^=#]").click(function(k){e.click(d(this).attr("href"),k)})}d.fn.tabs=function(i,f){var g=this.eq(typeof f=="number"?f:0).data("tabs");if(g){return g}if(d.isFunction(f)){f={onBeforeClick:f}}var h=d.extend({},d.tools.tabs.conf),e=this.length;f=d.extend(h,f);this.each(function(l){var j=d(this);var k=j.find(f.tabs);if(!k.length){k=j.children()}var m=i.jquery?i:j.children(i);if(!m.length){m=e==1?d(i):j.parent().find(i)}g=new a(k,m,f);j.data("tabs",g)});return f.api?g:this}})(jQuery);
(function(b){var a=b.tools.tabs;a.plugins=a.plugins||{};a.plugins.slideshow={version:"1.0.2",conf:{next:".forward",prev:".backward",disabledClass:"disabled",autoplay:false,autopause:true,interval:3000,clickable:true,api:false}};b.prototype.slideshow=function(e){var f=b.extend({},a.plugins.slideshow.conf),c=this.length,d;e=b.extend(f,e);this.each(function(){var p=b(this),m=p.tabs(),i=b(m),o=m;b.each(e,function(t,u){if(b.isFunction(u)){m.bind(t,u)}});function n(t){return c==1?b(t):p.parent().find(t)}var s=n(e.next).click(function(){m.next()});var q=n(e.prev).click(function(){m.prev()});var h,j,l,g=false;b.extend(m,{play:function(){if(h){return}var t=b.Event("onBeforePlay");i.trigger(t);if(t.isDefaultPrevented()){return m}g=false;h=setInterval(m.next,e.interval);i.trigger("onPlay");m.next()},pause:function(){if(!h){return m}var t=b.Event("onBeforePause");i.trigger(t);if(t.isDefaultPrevented()){return m}h=clearInterval(h);l=clearInterval(l);i.trigger("onPause")},stop:function(){m.pause();g=true},onBeforePlay:function(t){return m.bind("onBeforePlay",t)},onPlay:function(t){return m.bind("onPlay",t)},onBeforePause:function(t){return m.bind("onBeforePause",t)},onPause:function(t){return m.bind("onPause",t)}});if(e.autopause){var k=m.getTabs().add(s).add(q).add(m.getPanes());k.hover(function(){m.pause();j=clearInterval(j)},function(){if(!g){j=setTimeout(m.play,e.interval)}})}if(e.autoplay){l=setTimeout(m.play,e.interval)}else{m.stop()}if(e.clickable){m.getPanes().click(function(){m.next()})}if(!m.getConf().rotate){var r=e.disabledClass;if(!m.getIndex()){q.addClass(r)}m.onBeforeClick(function(u,t){if(!t){q.addClass(r)}else{q.removeClass(r);if(t==m.getTabs().length-1){s.addClass(r)}else{s.removeClass(r)}}})}});return e.api?d:this}})(jQuery);
(function(d){var a=d.tools.tabs;a.plugins=a.plugins||{};a.plugins.history={version:"1.0.2",conf:{api:false}};var e,b;function c(f){if(f){var g=b.contentWindow.document;g.open().close();g.location.hash=f}}d.fn.onHash=function(g){var f=this;if(d.browser.msie&&d.browser.version<"8"){if(!b){b=d("<iframe/>").attr("src","javascript:false;").hide().get(0);d("body").append(b);setInterval(function(){var i=b.contentWindow.document,j=i.location.hash;if(e!==j){d.event.trigger("hash",j);e=j}},100);c(location.hash||"#")}f.bind("click.hash",function(h){c(d(this).attr("href"))})}else{setInterval(function(){var j=location.hash;var i=f.filter("[href$="+j+"]");if(!i.length){j=j.replace("#","");i=f.filter("[href$="+j+"]")}if(i.length&&j!==e){e=j;d.event.trigger("hash",j)}},100)}d(window).bind("hash",g);return this};d.fn.history=function(g){var h=d.extend({},a.plugins.history.conf),f;g=d.extend(h,g);this.each(function(){var j=d(this).tabs(),i=j.getTabs();if(j){f=j}i.onHash(function(k,l){if(!l||l=="#"){l=j.getConf().initialIndex}j.click(l)});i.click(function(k){location.hash=d(this).attr("href").replace("#","")})});return g.api?f:this}})(jQuery);
(function(c){c.tools=c.tools||{};c.tools.overlay={version:"1.1.2",addEffect:function(e,f,g){b[e]=[f,g]},conf:{top:"10%",left:"center",absolute:false,speed:"normal",closeSpeed:"fast",effect:"default",close:null,oneInstance:true,closeOnClick:true,closeOnEsc:true,api:false,expose:null,target:null}};var b={};c.tools.overlay.addEffect("default",function(e){this.getOverlay().fadeIn(this.getConf().speed,e)},function(e){this.getOverlay().fadeOut(this.getConf().closeSpeed,e)});var d=[];function a(g,k){var o=this,m=c(this),n=c(window),j,i,h,e=k.expose&&c.tools.expose.version;var f=k.target||g.attr("rel");i=f?c(f):null||g;if(!i.length){throw"Could not find Overlay: "+f}if(g&&g.index(i)==-1){g.click(function(p){o.load(p);return p.preventDefault()})}c.each(k,function(p,q){if(c.isFunction(q)){m.bind(p,q)}});c.extend(o,{load:function(u){if(o.isOpened()){return o}var r=b[k.effect];if(!r){throw'Overlay: cannot find effect : "'+k.effect+'"'}if(k.oneInstance){c.each(d,function(){this.close(u)})}u=u||c.Event();u.type="onBeforeLoad";m.trigger(u);if(u.isDefaultPrevented()){return o}h=true;if(e){i.expose().load(u)}var t=k.top;var s=k.left;var p=i.outerWidth({margin:true});var q=i.outerHeight({margin:true});if(typeof t=="string"){t=t=="center"?Math.max((n.height()-q)/2,0):parseInt(t,10)/100*n.height()}if(s=="center"){s=Math.max((n.width()-p)/2,0)}if(!k.absolute){t+=n.scrollTop();s+=n.scrollLeft()}i.css({top:t,left:s,position:"absolute"});u.type="onStart";m.trigger(u);r[0].call(o,function(){if(h){u.type="onLoad";m.trigger(u)}});if(k.closeOnClick){c(document).bind("click.overlay",function(w){if(!o.isOpened()){return}var v=c(w.target);if(v.parents(i).length>1){return}c.each(d,function(){this.close(w)})})}if(k.closeOnEsc){c(document).unbind("keydown.overlay").bind("keydown.overlay",function(v){if(v.keyCode==27){c.each(d,function(){this.close(v)})}})}return o},close:function(q){if(!o.isOpened()){return o}q=q||c.Event();q.type="onBeforeClose";m.trigger(q);if(q.isDefaultPrevented()){return}h=false;b[k.effect][1].call(o,function(){q.type="onClose";m.trigger(q)});var p=true;c.each(d,function(){if(this.isOpened()){p=false}});if(p){c(document).unbind("click.overlay").unbind("keydown.overlay")}return o},getContent:function(){return i},getOverlay:function(){return i},getTrigger:function(){return g},getClosers:function(){return j},isOpened:function(){return h},getConf:function(){return k},bind:function(p,q){m.bind(p,q);return o},unbind:function(p){m.unbind(p);return o}});c.each("onBeforeLoad,onStart,onLoad,onBeforeClose,onClose".split(","),function(p,q){o[q]=function(r){return o.bind(q,r)}});if(e){if(typeof k.expose=="string"){k.expose={color:k.expose}}c.extend(k.expose,{api:true,closeOnClick:k.closeOnClick,closeOnEsc:false});var l=i.expose(k.expose);l.onBeforeClose(function(p){o.close(p)});o.onClose(function(p){l.close(p)})}j=i.find(k.close||".close");if(!j.length&&!k.close){j=c('<div class="close"></div>');i.prepend(j)}j.click(function(p){o.close(p)})}c.fn.overlay=function(e){var f=this.eq(typeof e=="number"?e:0).data("overlay");if(f){return f}if(c.isFunction(e)){e={onBeforeLoad:e}}var g=c.extend({},c.tools.overlay.conf);e=c.extend(true,g,e);this.each(function(){f=new a(c(this),e);d.push(f);c(this).data("overlay",f)});return e.api?f:this}})(jQuery);
(function(b){var a=b.tools.overlay;a.plugins=a.plugins||{};a.plugins.gallery={version:"1.0.0",conf:{imgId:"img",next:".next",prev:".prev",info:".info",progress:".progress",disabledClass:"disabled",activeClass:"active",opacity:0.8,speed:"slow",template:"<strong>${title}</strong> <span>Image ${index} of ${total}</span>",autohide:true,preload:true,api:false}};b.fn.gallery=function(d){var o=b.extend({},a.plugins.gallery.conf),m;b.extend(o,d);m=this.overlay();var r=this,j=m.getOverlay(),k=j.find(o.next),g=j.find(o.prev),e=j.find(o.info),c=j.find(o.progress),h=g.add(k).add(e).css({opacity:o.opacity}),s=m.getClosers(),l;function p(u){c.fadeIn();h.hide();s.hide();var t=u.attr("href");var v=new Image();v.onload=function(){c.fadeOut();var y=b("#"+o.imgId,j);if(!y.length){y=b("<img/>").attr("id",o.imgId).css("visibility","hidden");j.prepend(y)}y.attr("src",t).css("visibility","hidden");var z=v.width;var A=(b(window).width()-z)/2;l=r.index(r.filter("[href="+t+"]"));r.removeClass(o.activeClass).eq(l).addClass(o.activeClass);var w=o.disabledClass;h.removeClass(w);if(l===0){g.addClass(w)}if(l==r.length-1){k.addClass(w)}var B=o.template.replace("${title}",u.attr("title")||u.data("title")).replace("${index}",l+1).replace("${total}",r.length);var x=parseInt(e.css("paddingLeft"),10)+parseInt(e.css("paddingRight"),10);e.html(B).css({width:z-x});j.animate({width:z,height:v.height,left:A},o.speed,function(){y.hide().css("visibility","visible").fadeIn(function(){if(!o.autohide){h.fadeIn();s.show()}})})};v.onerror=function(){j.fadeIn().html("Cannot find image "+t)};v.src=t;if(o.preload){r.filter(":eq("+(l-1)+"), :eq("+(l+1)+")").each(function(){var w=new Image();w.src=b(this).attr("href")})}}function f(t,u){t.click(function(){if(t.hasClass(o.disabledClass)){return}var v=r.eq(i=l+(u?1:-1));if(v.length){p(v)}})}f(k,true);f(g);b(document).keydown(function(t){if(!j.is(":visible")||t.altKey||t.ctrlKey){return}if(t.keyCode==37||t.keyCode==39){var u=t.keyCode==37?g:k;u.click();return t.preventDefault()}return true});function q(){if(!j.is(":animated")){h.show();s.show()}}if(o.autohide){j.hover(q,function(){h.fadeOut();s.hide()}).mousemove(q)}var n;this.each(function(){var v=b(this),u=b(this).overlay(),t=u;u.onBeforeLoad(function(){p(v)});u.onClose(function(){r.removeClass(o.activeClass)})});return o.api?n:this}})(jQuery);
(function(d){var b=d.tools.overlay;b.effects=b.effects||{};b.effects.apple={version:"1.0.1"};d.extend(b.conf,{start:{absolute:true,top:null,left:null},fadeInSpeed:"fast",zIndex:9999});function c(f){var g=f.offset();return[g.top+f.height()/2,g.left+f.width()/2]}var e=function(n){var k=this.getOverlay(),f=this.getConf(),i=this.getTrigger(),q=this,r=k.outerWidth({margin:true}),m=k.data("img");if(!m){var l=k.css("backgroundImage");if(!l){throw"background-image CSS property not set for overlay"}l=l.substring(l.indexOf("(")+1,l.indexOf(")")).replace(/\"/g,"");k.css("backgroundImage","none");m=d('<img src="'+l+'"/>');m.css({border:0,position:"absolute",display:"none"}).width(r);d("body").append(m);k.data("img",m)}var o=d(window),j=f.start.top||Math.round(o.height()/2),h=f.start.left||Math.round(o.width()/2);if(i){var g=c(i);j=g[0];h=g[1]}if(!f.start.absolute){j+=o.scrollTop();h+=o.scrollLeft()}m.css({top:j,left:h,width:0,zIndex:f.zIndex}).show();m.animate({top:k.css("top"),left:k.css("left"),width:r},f.speed,function(){k.css("zIndex",f.zIndex+1).fadeIn(f.fadeInSpeed,function(){if(q.isOpened()&&!d(this).index(k)){n.call()}else{k.hide()}})})};var a=function(f){var h=this.getOverlay(),i=this.getConf(),g=this.getTrigger(),l=i.start.top,k=i.start.left;h.hide();if(g){var j=c(g);l=j[0];k=j[1]}h.data("img").animate({top:l,left:k,width:0},i.closeSpeed,f)};b.addEffect("apple",e,a)})(jQuery);
(function(b){b.tools=b.tools||{};b.tools.expose={version:"1.0.5",conf:{maskId:null,loadSpeed:"slow",closeSpeed:"fast",closeOnClick:true,closeOnEsc:true,zIndex:9998,opacity:0.8,color:"#456",api:false}};function a(){if(b.browser.msie){var f=b(document).height(),e=b(window).height();return[window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,f-e<20?e:f]}return[b(window).width(),b(document).height()]}function c(h,g){var e=this,j=b(this),d=null,f=false,i=0;b.each(g,function(k,l){if(b.isFunction(l)){j.bind(k,l)}});b(window).resize(function(){e.fit()});b.extend(this,{getMask:function(){return d},getExposed:function(){return h},getConf:function(){return g},isLoaded:function(){return f},load:function(n){if(f){return e}i=h.eq(0).css("zIndex");if(g.maskId){d=b("#"+g.maskId)}if(!d||!d.length){var l=a();d=b("<div/>").css({position:"absolute",top:0,left:0,width:l[0],height:l[1],display:"none",opacity:0,zIndex:g.zIndex});if(g.maskId){d.attr("id",g.maskId)}b("body").append(d);var k=d.css("backgroundColor");if(!k||k=="transparent"||k=="rgba(0, 0, 0, 0)"){d.css("backgroundColor",g.color)}if(g.closeOnEsc){b(document).bind("keydown.unexpose",function(o){if(o.keyCode==27){e.close()}})}if(g.closeOnClick){d.bind("click.unexpose",function(o){e.close(o)})}}n=n||b.Event();n.type="onBeforeLoad";j.trigger(n);if(n.isDefaultPrevented()){return e}b.each(h,function(){var o=b(this);if(!/relative|absolute|fixed/i.test(o.css("position"))){o.css("position","relative")}});h.css({zIndex:Math.max(g.zIndex+1,i=="auto"?0:i)});var m=d.height();if(!this.isLoaded()){d.css({opacity:0,display:"block"}).fadeTo(g.loadSpeed,g.opacity,function(){if(d.height()!=m){d.css("height",m)}n.type="onLoad";j.trigger(n)})}f=true;return e},close:function(k){if(!f){return e}k=k||b.Event();k.type="onBeforeClose";j.trigger(k);if(k.isDefaultPrevented()){return e}d.fadeOut(g.closeSpeed,function(){k.type="onClose";j.trigger(k);h.css({zIndex:b.browser.msie?i:null})});f=false;return e},fit:function(){if(d){var k=a();d.css({width:k[0],height:k[1]})}},bind:function(k,l){j.bind(k,l);return e},unbind:function(k){j.unbind(k);return e}});b.each("onBeforeLoad,onLoad,onBeforeClose,onClose".split(","),function(k,l){e[l]=function(m){return e.bind(l,m)}})}b.fn.expose=function(d){var e=this.eq(typeof d=="number"?d:0).data("expose");if(e){return e}if(typeof d=="string"){d={color:d}}var f=b.extend({},b.tools.expose.conf);d=b.extend(f,d);this.each(function(){e=new c(b(this),d);b(this).data("expose",e)});return d.api?e:this}})(jQuery);
/*
 * jQuery hashchange event - v1.2 - 2/11/2010
 * http://benalman.com/projects/jquery-hashchange-plugin/
 *
 * Copyright (c) 2010 "Cowboy" Ben Alman
 * Dual licensed under the MIT and GPL licenses.
 * http://benalman.com/about/license/
 */
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);

/*jslint browser: true */ /*global jQuery: true */

/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/

// TODO JsDoc

/**
* Create a cookie with the given key and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String key The key of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/

/**
* Get the value of a cookie with the given key.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String key The key of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function (key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};


