/*!
 * jCarousel - Riding carousels with jQuery
 *   http://sorgalla.com/jcarousel/
 *
 * Copyright (c) 2006 Jan Sorgalla (http://sorgalla.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.
 *
 * Built on top of the jQuery library
 *   http://jquery.com
 *
 * Inspired by the "Carousel Component" by Bill Scott
 *   http://billwscott.com/carousel/
 */

(function(i){var q={vertical:false,rtl:false,start:1,offset:1,size:null,scroll:3,visible:null,animation:"normal",easing:"swing",auto:0,wrap:null,initCallback:null,reloadCallback:null,itemLoadCallback:null,itemFirstInCallback:null,itemFirstOutCallback:null,itemLastInCallback:null,itemLastOutCallback:null,itemVisibleInCallback:null,itemVisibleOutCallback:null,buttonNextHTML:"<div></div>",buttonPrevHTML:"<div></div>",buttonNextEvent:"click",buttonPrevEvent:"click",buttonNextCallback:null,buttonPrevCallback:null, itemFallbackDimension:null},r=false;i(window).bind("load.jcarousel",function(){r=true});i.jcarousel=function(a,c){this.options=i.extend({},q,c||{});this.autoStopped=this.locked=false;this.buttonPrevState=this.buttonNextState=this.buttonPrev=this.buttonNext=this.list=this.clip=this.container=null;if(!c||c.rtl===undefined)this.options.rtl=(i(a).attr("dir")||i("html").attr("dir")||"").toLowerCase()=="rtl";this.wh=!this.options.vertical?"width":"height";this.lt=!this.options.vertical?this.options.rtl? "right":"left":"top";for(var b="",d=a.className.split(" "),f=0;f<d.length;f++)if(d[f].indexOf("jcarousel-skin")!=-1){i(a).removeClass(d[f]);b=d[f];break}if(a.nodeName.toUpperCase()=="UL"||a.nodeName.toUpperCase()=="OL"){this.list=i(a);this.container=this.list.parent();if(this.container.hasClass("jcarousel-clip")){if(!this.container.parent().hasClass("jcarousel-container"))this.container=this.container.wrap("<div></div>");this.container=this.container.parent()}else if(!this.container.hasClass("jcarousel-container"))this.container= this.list.wrap("<div></div>").parent()}else{this.container=i(a);this.list=this.container.find("ul,ol").eq(0)}b!==""&&this.container.parent()[0].className.indexOf("jcarousel-skin")==-1&&this.container.wrap('<div class=" '+b+'"></div>');this.clip=this.list.parent();if(!this.clip.length||!this.clip.hasClass("jcarousel-clip"))this.clip=this.list.wrap("<div></div>").parent();this.buttonNext=i(".jcarousel-next",this.container);if(this.buttonNext.size()===0&&this.options.buttonNextHTML!==null)this.buttonNext= this.clip.after(this.options.buttonNextHTML).next();this.buttonNext.addClass(this.className("jcarousel-next"));this.buttonPrev=i(".jcarousel-prev",this.container);if(this.buttonPrev.size()===0&&this.options.buttonPrevHTML!==null)this.buttonPrev=this.clip.after(this.options.buttonPrevHTML).next();this.buttonPrev.addClass(this.className("jcarousel-prev"));this.clip.addClass(this.className("jcarousel-clip")).css({overflow:"hidden",position:"relative"});this.list.addClass(this.className("jcarousel-list")).css({overflow:"hidden", position:"relative",top:0,margin:0,padding:0}).css(this.options.rtl?"right":"left",0);this.container.addClass(this.className("jcarousel-container")).css({position:"relative"});!this.options.vertical&&this.options.rtl&&this.container.addClass("jcarousel-direction-rtl").attr("dir","rtl");var j=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;b=this.list.children("li");var e=this;if(b.size()>0){var g=0,k=this.options.offset;b.each(function(){e.format(this,k++);g+=e.dimension(this, j)});this.list.css(this.wh,g+100+"px");if(!c||c.size===undefined)this.options.size=b.size()}this.container.css("display","block");this.buttonNext.css("display","block");this.buttonPrev.css("display","block");this.funcNext=function(){e.next()};this.funcPrev=function(){e.prev()};this.funcResize=function(){e.reload()};this.options.initCallback!==null&&this.options.initCallback(this,"init");if(!r&&i.browser.safari){this.buttons(false,false);i(window).bind("load.jcarousel",function(){e.setup()})}else this.setup()}; var h=i.jcarousel;h.fn=h.prototype={jcarousel:"0.2.7"};h.fn.extend=h.extend=i.extend;h.fn.extend({setup:function(){this.prevLast=this.prevFirst=this.last=this.first=null;this.animating=false;this.tail=this.timer=null;this.inTail=false;if(!this.locked){this.list.css(this.lt,this.pos(this.options.offset)+"px");var a=this.pos(this.options.start,true);this.prevFirst=this.prevLast=null;this.animate(a,false);i(window).unbind("resize.jcarousel",this.funcResize).bind("resize.jcarousel",this.funcResize)}}, reset:function(){this.list.empty();this.list.css(this.lt,"0px");this.list.css(this.wh,"10px");this.options.initCallback!==null&&this.options.initCallback(this,"reset");this.setup()},reload:function(){this.tail!==null&&this.inTail&&this.list.css(this.lt,h.intval(this.list.css(this.lt))+this.tail);this.tail=null;this.inTail=false;this.options.reloadCallback!==null&&this.options.reloadCallback(this);if(this.options.visible!==null){var a=this,c=Math.ceil(this.clipping()/this.options.visible),b=0,d=0; this.list.children("li").each(function(f){b+=a.dimension(this,c);if(f+1<a.first)d=b});this.list.css(this.wh,b+"px");this.list.css(this.lt,-d+"px")}this.scroll(this.first,false)},lock:function(){this.locked=true;this.buttons()},unlock:function(){this.locked=false;this.buttons()},size:function(a){if(a!==undefined){this.options.size=a;this.locked||this.buttons()}return this.options.size},has:function(a,c){if(c===undefined||!c)c=a;if(this.options.size!==null&&c>this.options.size)c=this.options.size;for(var b= a;b<=c;b++){var d=this.get(b);if(!d.length||d.hasClass("jcarousel-item-placeholder"))return false}return true},get:function(a){return i(".jcarousel-item-"+a,this.list)},add:function(a,c){var b=this.get(a),d=0,f=i(c);if(b.length===0){var j,e=h.intval(a);for(b=this.create(a);;){j=this.get(--e);if(e<=0||j.length){e<=0?this.list.prepend(b):j.after(b);break}}}else d=this.dimension(b);if(f.get(0).nodeName.toUpperCase()=="LI"){b.replaceWith(f);b=f}else b.empty().append(c);this.format(b.removeClass(this.className("jcarousel-item-placeholder")), a);f=this.options.visible!==null?Math.ceil(this.clipping()/this.options.visible):null;d=this.dimension(b,f)-d;a>0&&a<this.first&&this.list.css(this.lt,h.intval(this.list.css(this.lt))-d+"px");this.list.css(this.wh,h.intval(this.list.css(this.wh))+d+"px");return b},remove:function(a){var c=this.get(a);if(!(!c.length||a>=this.first&&a<=this.last)){var b=this.dimension(c);a<this.first&&this.list.css(this.lt,h.intval(this.list.css(this.lt))+b+"px");c.remove();this.list.css(this.wh,h.intval(this.list.css(this.wh))- b+"px")}},next:function(){this.tail!==null&&!this.inTail?this.scrollTail(false):this.scroll((this.options.wrap=="both"||this.options.wrap=="last")&&this.options.size!==null&&this.last==this.options.size?1:this.first+this.options.scroll)},prev:function(){this.tail!==null&&this.inTail?this.scrollTail(true):this.scroll((this.options.wrap=="both"||this.options.wrap=="first")&&this.options.size!==null&&this.first==1?this.options.size:this.first-this.options.scroll)},scrollTail:function(a){if(!(this.locked|| this.animating||!this.tail)){this.pauseAuto();var c=h.intval(this.list.css(this.lt));c=!a?c-this.tail:c+this.tail;this.inTail=!a;this.prevFirst=this.first;this.prevLast=this.last;this.animate(c)}},scroll:function(a,c){if(!(this.locked||this.animating)){this.pauseAuto();this.animate(this.pos(a),c)}},pos:function(a,c){var b=h.intval(this.list.css(this.lt));if(this.locked||this.animating)return b;if(this.options.wrap!="circular")a=a<1?1:this.options.size&&a>this.options.size?this.options.size:a;for(var d= this.first>a,f=this.options.wrap!="circular"&&this.first<=1?1:this.first,j=d?this.get(f):this.get(this.last),e=d?f:f-1,g=null,k=0,l=false,m=0;d?--e>=a:++e<a;){g=this.get(e);l=!g.length;if(g.length===0){g=this.create(e).addClass(this.className("jcarousel-item-placeholder"));j[d?"before":"after"](g);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size)){j=this.get(this.index(e));if(j.length)g=this.add(e,j.clone(true))}}j=g;m=this.dimension(g);if(l)k+= m;if(this.first!==null&&(this.options.wrap=="circular"||e>=1&&(this.options.size===null||e<=this.options.size)))b=d?b+m:b-m}f=this.clipping();var p=[],o=0,n=0;j=this.get(a-1);for(e=a;++o;){g=this.get(e);l=!g.length;if(g.length===0){g=this.create(e).addClass(this.className("jcarousel-item-placeholder"));j.length===0?this.list.prepend(g):j[d?"before":"after"](g);if(this.first!==null&&this.options.wrap=="circular"&&this.options.size!==null&&(e<=0||e>this.options.size)){j=this.get(this.index(e));if(j.length)g= this.add(e,j.clone(true))}}j=g;m=this.dimension(g);if(m===0)throw Error("jCarousel: No width/height set for items. This will cause an infinite loop. Aborting...");if(this.options.wrap!="circular"&&this.options.size!==null&&e>this.options.size)p.push(g);else if(l)k+=m;n+=m;if(n>=f)break;e++}for(g=0;g<p.length;g++)p[g].remove();if(k>0){this.list.css(this.wh,this.dimension(this.list)+k+"px");if(d){b-=k;this.list.css(this.lt,h.intval(this.list.css(this.lt))-k+"px")}}k=a+o-1;if(this.options.wrap!="circular"&& this.options.size&&k>this.options.size)k=this.options.size;if(e>k){o=0;e=k;for(n=0;++o;){g=this.get(e--);if(!g.length)break;n+=this.dimension(g);if(n>=f)break}}e=k-o+1;if(this.options.wrap!="circular"&&e<1)e=1;if(this.inTail&&d){b+=this.tail;this.inTail=false}this.tail=null;if(this.options.wrap!="circular"&&k==this.options.size&&k-o+1>=1){d=h.margin(this.get(k),!this.options.vertical?"marginRight":"marginBottom");if(n-d>f)this.tail=n-f-d}if(c&&a===this.options.size&&this.tail){b-=this.tail;this.inTail= true}for(;a-- >e;)b+=this.dimension(this.get(a));this.prevFirst=this.first;this.prevLast=this.last;this.first=e;this.last=k;return b},animate:function(a,c){if(!(this.locked||this.animating)){this.animating=true;var b=this,d=function(){b.animating=false;a===0&&b.list.css(b.lt,0);if(!b.autoStopped&&(b.options.wrap=="circular"||b.options.wrap=="both"||b.options.wrap=="last"||b.options.size===null||b.last<b.options.size||b.last==b.options.size&&b.tail!==null&&!b.inTail))b.startAuto();b.buttons();b.notify("onAfterAnimation"); if(b.options.wrap=="circular"&&b.options.size!==null)for(var f=b.prevFirst;f<=b.prevLast;f++)if(f!==null&&!(f>=b.first&&f<=b.last)&&(f<1||f>b.options.size))b.remove(f)};this.notify("onBeforeAnimation");if(!this.options.animation||c===false){this.list.css(this.lt,a+"px");d()}else this.list.animate(!this.options.vertical?this.options.rtl?{right:a}:{left:a}:{top:a},this.options.animation,this.options.easing,d)}},startAuto:function(a){if(a!==undefined)this.options.auto=a;if(this.options.auto===0)return this.stopAuto(); if(this.timer===null){this.autoStopped=false;var c=this;this.timer=window.setTimeout(function(){c.next()},this.options.auto*1E3)}},stopAuto:function(){this.pauseAuto();this.autoStopped=true},pauseAuto:function(){if(this.timer!==null){window.clearTimeout(this.timer);this.timer=null}},buttons:function(a,c){if(a==null){a=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="first"||this.options.size===null||this.last<this.options.size);if(!this.locked&&(!this.options.wrap||this.options.wrap== "first")&&this.options.size!==null&&this.last>=this.options.size)a=this.tail!==null&&!this.inTail}if(c==null){c=!this.locked&&this.options.size!==0&&(this.options.wrap&&this.options.wrap!="last"||this.first>1);if(!this.locked&&(!this.options.wrap||this.options.wrap=="last")&&this.options.size!==null&&this.first==1)c=this.tail!==null&&this.inTail}var b=this;if(this.buttonNext.size()>0){this.buttonNext.unbind(this.options.buttonNextEvent+".jcarousel",this.funcNext);a&&this.buttonNext.bind(this.options.buttonNextEvent+ ".jcarousel",this.funcNext);this.buttonNext[a?"removeClass":"addClass"](this.className("jcarousel-next-disabled")).attr("disabled",a?false:true);this.options.buttonNextCallback!==null&&this.buttonNext.data("jcarouselstate")!=a&&this.buttonNext.each(function(){b.options.buttonNextCallback(b,this,a)}).data("jcarouselstate",a)}else this.options.buttonNextCallback!==null&&this.buttonNextState!=a&&this.options.buttonNextCallback(b,null,a);if(this.buttonPrev.size()>0){this.buttonPrev.unbind(this.options.buttonPrevEvent+ ".jcarousel",this.funcPrev);c&&this.buttonPrev.bind(this.options.buttonPrevEvent+".jcarousel",this.funcPrev);this.buttonPrev[c?"removeClass":"addClass"](this.className("jcarousel-prev-disabled")).attr("disabled",c?false:true);this.options.buttonPrevCallback!==null&&this.buttonPrev.data("jcarouselstate")!=c&&this.buttonPrev.each(function(){b.options.buttonPrevCallback(b,this,c)}).data("jcarouselstate",c)}else this.options.buttonPrevCallback!==null&&this.buttonPrevState!=c&&this.options.buttonPrevCallback(b, null,c);this.buttonNextState=a;this.buttonPrevState=c},notify:function(a){var c=this.prevFirst===null?"init":this.prevFirst<this.first?"next":"prev";this.callback("itemLoadCallback",a,c);if(this.prevFirst!==this.first){this.callback("itemFirstInCallback",a,c,this.first);this.callback("itemFirstOutCallback",a,c,this.prevFirst)}if(this.prevLast!==this.last){this.callback("itemLastInCallback",a,c,this.last);this.callback("itemLastOutCallback",a,c,this.prevLast)}this.callback("itemVisibleInCallback", a,c,this.first,this.last,this.prevFirst,this.prevLast);this.callback("itemVisibleOutCallback",a,c,this.prevFirst,this.prevLast,this.first,this.last)},callback:function(a,c,b,d,f,j,e){if(!(this.options[a]==null||typeof this.options[a]!="object"&&c!="onAfterAnimation")){var g=typeof this.options[a]=="object"?this.options[a][c]:this.options[a];if(i.isFunction(g)){var k=this;if(d===undefined)g(k,b,c);else if(f===undefined)this.get(d).each(function(){g(k,this,d,b,c)});else{a=function(m){k.get(m).each(function(){g(k, this,m,b,c)})};for(var l=d;l<=f;l++)l!==null&&!(l>=j&&l<=e)&&a(l)}}}},create:function(a){return this.format("<li></li>",a)},format:function(a,c){a=i(a);for(var b=a.get(0).className.split(" "),d=0;d<b.length;d++)b[d].indexOf("jcarousel-")!=-1&&a.removeClass(b[d]);a.addClass(this.className("jcarousel-item")).addClass(this.className("jcarousel-item-"+c)).css({"float":this.options.rtl?"right":"left","list-style":"none"}).attr("jcarouselindex",c);return a},className:function(a){return a+" "+a+(!this.options.vertical? "-horizontal":"-vertical")},dimension:function(a,c){var b=a.jquery!==undefined?a[0]:a,d=!this.options.vertical?(b.offsetWidth||h.intval(this.options.itemFallbackDimension))+h.margin(b,"marginLeft")+h.margin(b,"marginRight"):(b.offsetHeight||h.intval(this.options.itemFallbackDimension))+h.margin(b,"marginTop")+h.margin(b,"marginBottom");if(c==null||d==c)return d;d=!this.options.vertical?c-h.margin(b,"marginLeft")-h.margin(b,"marginRight"):c-h.margin(b,"marginTop")-h.margin(b,"marginBottom");i(b).css(this.wh, d+"px");return this.dimension(b)},clipping:function(){return!this.options.vertical?this.clip[0].offsetWidth-h.intval(this.clip.css("borderLeftWidth"))-h.intval(this.clip.css("borderRightWidth")):this.clip[0].offsetHeight-h.intval(this.clip.css("borderTopWidth"))-h.intval(this.clip.css("borderBottomWidth"))},index:function(a,c){if(c==null)c=this.options.size;return Math.round(((a-1)/c-Math.floor((a-1)/c))*c)+1}});h.extend({defaults:function(a){return i.extend(q,a||{})},margin:function(a,c){if(!a)return 0; var b=a.jquery!==undefined?a[0]:a;if(c=="marginRight"&&i.browser.safari){var d={display:"block","float":"none",width:"auto"},f,j;i.swap(b,d,function(){f=b.offsetWidth});d.marginRight=0;i.swap(b,d,function(){j=b.offsetWidth});return j-f}return h.intval(i.css(b,c))},intval:function(a){a=parseInt(a,10);return isNaN(a)?0:a}});i.fn.jcarousel=function(a){if(typeof a=="string"){var c=i(this).data("jcarousel"),b=Array.prototype.slice.call(arguments,1);return c[a].apply(c,b)}else return this.each(function(){i(this).data("jcarousel", new h(this,a))})}})(jQuery);



/*-- submenu --

			 * stickyfloat - jQuery plugin for verticaly floating anything in a constrained area
			 * $Version: 05.16.2009 r1
			 * Copyright (c) 2009 Yair Even-Or
			 * vsync.design@gmail.com
*/

			$.fn.stickyfloat = function(options, lockBottom) {
				var $obj 				= this;
				var parentPaddingTop 	= parseInt($obj.parent().css('padding-top'));
				var startOffset 		= $obj.parent().offset().top;
				var opts 				= $.extend({ startOffset: startOffset, offsetY: parentPaddingTop, duration: 200, lockBottom:true }, options);

				$obj.css({ 'position' : 'absolute', 'z-index' : '999999' });

				if(opts.lockBottom){
					var bottomPos = $obj.parent().height() - $obj.height() + parentPaddingTop; //get the maximum scrollTop value
					if( bottomPos < 0 )
						bottomPos = 0;
				}

				$(window).scroll(function () {
					$obj.stop(); // stop all calculations on scroll event

					var pastStartOffset			= $(document).scrollTop() > opts.startOffset;	// check if the window was scrolled down more than the start offset declared.
					var objFartherThanTopPos	= $obj.offset().top > startOffset;	// check if the object is at it's top position (starting point)
					var objBiggerThanWindow 	= $obj.outerHeight() < $(window).height();	// if the window size is smaller than the Obj size, then do not animate.

					// if window scrolled down more than startOffset OR obj position is greater than
					// the top position possible (+ offsetY) AND window size must be bigger than Obj size
					if( (pastStartOffset || objFartherThanTopPos) && objBiggerThanWindow ){
						var newpos = ($(document).scrollTop() -startOffset + opts.offsetY );
						if ( newpos > bottomPos )
							newpos = bottomPos;
						if ( $(document).scrollTop() < opts.startOffset ) // if window scrolled < starting offset, then reset Obj position (opts.offsetY);
							newpos = parentPaddingTop;

						$obj.animate({ top: newpos }, opts.duration );
					}
				});
			};






/*-- IE6nomore --*/

    $.IE6nomore = function(){
        if(!$('#ie6nomore').length)
            return;
        $('#ie6nomore').css({
            'left': 0,
            'top': 0,
            'bottom': 0,
            'right': 0,
            'position': 'absolute',
            'z-index': 9999
        });
    };

/*-- Swap image --*/

    function swapImage(element, newimage){
        var oldsrc = element.src;
        element.src = newimage;
        if (!element.onmouseout){
            element.onmouseout = function(){
                swapImage(this, oldsrc);
            }
        }
    }

/*-- Spam protection --*/

    function getAdr(prefix, postfix, text){
        document.write('<a href="mailto:' + prefix + '@' + postfix + '">' + (text ? text.replace(/&quot;/g, '"').replace(/%EMAIL%/, prefix + '@' + postfix) : prefix + '@' + postfix) + '</a>');
    }



/*-- Clickable parent element from a link --*/

    (function($){
        $.fn.clickable = function(){
            return this.each(function(){
                var el = this;
                if(!$('.click', el).length)
                    return;
                $(el).data('clickable_uri', $('.click', el).attr('href'));
                $(el).css('cursor', 'pointer');
                $(el).click(function(){
                    window.location = $(this).data('clickable_uri');
                })
            });
        }
    })(jQuery);


/* Popup plugin
------------------------------------------------------------------------------------------------ */

(function($){
    $.fn.popup = function(settings) {

        if(!this.length)
            return;

        settings = $.extend({
            'margin'    : 20,   // Margin from the iframe popup
            'width'     : 700,  // Default popup width
            'height'    : 500  // Default popup height
        }, settings);

        // No inline popup on smartphones etc.

        if (/android|iphone|ipad|ipod|series60|symbian|windowsce|blackberry/i.test(navigator.userAgent))
            return;

        // Create iframe popup

        createIframePopup();

        // Open iframe popup

        $(this).click(function(){

            // Set hash

            var hash = location.hash;

            if (!hash) {
                location.hash = $(this).attr('id');
            }

            // Hide scrollbar and fadein overlay

            $('body, html').css('overflow', 'hidden');

            if (hash) {
                $(ip_overlay).css({
                    'opacity' : 0.8
                }).show();
            }
            else {
                $(ip_overlay).fadeTo('slow', 0.8);
            }

            // Set tabindex="-1" to content

            $('a, input, textarea, select, button').not('.close').each(function(){
                $(this).addClass('tabindex').attr('tabindex', '-1');
            });

            // Get popup size from rel attribut

            var popupHeight     = this.rel.split(',')[1],
                popupWidth      = this.rel.split(',')[0];

            if (popupWidth == null || popupHeight == null) {
                popupWidth      = settings.width;
                popupHeight     = settings.height;
            }

            // Set popup size

            var NormalCSS = {
                'bottom'        : 'auto',
                'height'        : popupHeight + 'px',
                'left'          : '50%',
                'margin-left'   : Math.floor(-(popupWidth)/2) + 'px',
                'margin-top'    : Math.floor(-(popupHeight)/2) + 'px',
                'max-height'    : popupHeight + 'px',
                'top'           : '50%',
                'width'         : popupWidth + 'px'
            };

            var FlexibleCSS = {
                'bottom'        : settings.margin + 'px',
                'height'        : 'auto',
                'margin-top'    : 0,
                'top'           : settings.margin + 'px'
            };

            // Normal iframe popup size

            $(ip_popup).css(NormalCSS).show();

            // Flexible iframe popup size

            $(window).resize(function(){
                ($(this).height() <= ($(ip_popup).outerHeight()+2*settings.margin)) ? $(ip_popup).css(FlexibleCSS) : $(ip_popup).css(NormalCSS);
            });

            ($(window).height() <= ($(ip_popup).outerHeight()+2*settings.margin)) ? $(ip_popup).css(FlexibleCSS) : $(ip_popup).css(NormalCSS);

            // Insert iframe title

            $(ip_title).html(this.title);

            // Insert iframe content

            $(ip_popup).addClass('ip_loading');
            $(ip_iframe).attr('src', this);

            // Preloader

            $(ip_iframe).css('visibility', 'hidden');

            $(ip_iframe).load(function(){
                $(ip_popup).removeClass('ip_loading');
                $(ip_iframe).css('visibility', 'visible');
            });

            $(document).bind('keydown', keyDown);

            return false;
        });

        // Close popup

        function closeIframePopup(){

            $('body').css('overflow', bodyOverflow);
            $('html').css('overflow', htmlOverflow);
            $(ip_popup).hide();
            $(ip_overlay).fadeOut('slow');
            $(window).unbind('resize');

            // Remove tabindex="-1"

            $('.tabindex').each(function(){
                $(this).removeClass('tabindex').removeAttr('tabindex');
            });

        }

        // Keyboard events

        function keyDown(event){
            var code = event.keyCode;
            return ($.inArray(code, [27,88,67]) >= 0) ? closeIframePopup() : true;
        }

        // Create iframe popup

        function createIframePopup(){
            $('body').append(
                ip_overlay = $('<div>').attr({ 'class': 'ip_overlay' }).hide().click(closeIframePopup),
                ip_popup = $('<div class>').attr({ 'class': 'ip_popup' }).append(
                    ip_close = $('<a>').attr({ 'class': 'close', href: '#', title: close+' [ESC]' }).text(close).click(closeIframePopup),
                    ip_title = $('<h2>').attr({ 'class': 'title' }),
                    $('<div>').attr({ 'class': 'ip_content' }).append(
                        ip_iframe = $('<iframe>').attr({ 'src': '', 'frameborder': '0' })
                    )
                ).hide()
            );
            $([
                bodyOverflow = $('body').css('overflow'),
                htmlOverflow = $('html').css('overflow')
            ])
        }

        // Check hash and open popup

        var hash = location.hash;

        if (hash) {
            $(hash).click();
        }

    };
})(jQuery);

/*-- slimbox 2.03 --*/

    (function(w){var E=w(window),u,g,F=-1,o,x,D,v,y,L,s,n=!window.XMLHttpRequest,e=window.opera&&(document.comtextMode=="CSS1Comtext")&&(w.browser.version>=9.3),m=document.documentElement,l={},t=new Image(),J=new Image(),H,a,h,q,I,d,G,c,A,K;w(function(){w("body").append(w([H=w('<div id="lbOverlay" />')[0],a=w('<div id="lbCenter" />')[0],G=w('<div id="lbBottomContainer" />')[0]]).css("display","none"));h=w('<div id="lbImage" />').appendTo(a).append(q=w('<div style="position: relative;" />').append([I=w('<a id="lbPrevLink" href="#" />').click(B)[0],d=w('<a id="lbNextLink" href="#" />').click(f)[0]])[0])[0];c=w('<div id="lbBottom" />').appendTo(G).append([w('<a id="lbCloseLink" href="#" />').add(H).click(C)[0],A=w('<div id="lbCaption" />')[0],K=w('<div id="lbNumber" />')[0],w('<div style="clear: both;" />')[0]])[0]});w.slimbox=function(O,N,M){u=w.extend({loop:false,overlayOpacity:0.8,overlayFadeDuration:400,resizeDuration:400,resizeEasing:"swing",initialWidth:250,initialHeight:250,imageFadeDuration:400,captionAnimationDuration:400,counterText:"Image {x} of {y}",closeKeys:[27,88,67],previousKeys:[37,80],nextKeys:[39,78]},M);if(typeof O=="string"){O=[[O,N]];N=0}y=E.scrollTop()+((e?m.clientHeight:E.height())/2);L=u.initialWidth;s=u.initialHeight;w(a).css({top:Math.max(0,y-(s/2)),width:L,height:s,marginLeft:-L/2}).show();v=n||(H.currentStyle&&(H.currentStyle.position!="fixed"));if(v){H.style.position="absolute"}w(H).css("opacity",u.overlayOpacity).fadeIn(u.overlayFadeDuration);z();k(1);g=O;u.loop=u.loop&&(g.length>1);return b(N)};w.fn.slimbox=function(M,P,O){P=P||function(Q){return[Q.href,Q.title]};O=O||function(){return true};var N=this;return N.unbind("click").click(function(){var S=this,U=0,T,Q=0,R;T=w.grep(N,function(W,V){return O.call(S,W,V)});for(R=T.length;Q<R;++Q){if(T[Q]==S){U=Q}T[Q]=P(T[Q],Q)}return w.slimbox(T,U,M)})};function z(){var N=E.scrollLeft(),M=e?m.clientWidth:E.width();w([a,G]).css("left",N+(M/2));if(v){w(H).css({left:N,top:E.scrollTop(),width:M,height:E.height()})}}function k(M){w("object").add(n?"select":"embed").each(function(O,P){if(M){w.data(P,"slimbox",P.style.visibility)}P.style.visibility=M?"hidden":w.data(P,"slimbox")});var N=M?"bind":"unbind";E[N]("scroll resize",z);w(document)[N]("keydown",p)}function p(O){var N=O.keyCode,M=w.inArray;return(M(N,u.closeKeys)>=0)?C():(M(N,u.nextKeys)>=0)?f():(M(N,u.previousKeys)>=0)?B():true}function B(){return b(x)}function f(){return b(D)}function b(M){if(M>=0){F=M;o=g[F][0];x=(F||(u.loop?g.length:0))-1;D=((F+1)%g.length)||(u.loop?0:-1);r();a.className="lbLoading";l=new Image();l.onload=j;l.src=o}return false}function j(){a.className="";w(h).css({backgroundImage:"url("+o+")",visibility:"hidden",display:""});w(q).width(l.width);w([q,I,d]).height(l.height);w(A).html(g[F][1]||"");w(K).html((((g.length>1)&&u.counterText)||"").replace(/{x}/,F+1).replace(/{y}/,g.length));if(x>=0){t.src=g[x][0]}if(D>=0){J.src=g[D][0]}L=h.offsetWidth;s=h.offsetHeight;var M=Math.max(0,y-(s/2));if(a.offsetHeight!=s){w(a).animate({height:s,top:M},u.resizeDuration,u.resizeEasing)}if(a.offsetWidth!=L){w(a).animate({width:L,marginLeft:-L/2},u.resizeDuration,u.resizeEasing)}w(a).queue(function(){w(G).css({width:L,top:M+s,marginLeft:-L/2,visibility:"hidden",display:""});w(h).css({display:"none",visibility:"",opacity:""}).fadeIn(u.imageFadeDuration,i)})}function i(){if(x>=0){w(I).show()}if(D>=0){w(d).show()}w(c).css("marginTop",-c.offsetHeight).animate({marginTop:0},u.captionAnimationDuration);G.style.visibility=""}function r(){l.onload=null;l.src=t.src=J.src=o;w([a,h,c]).stop(true);w([I,d,h,G]).hide()}function C(){if(F>=0){r();F=x=D=-1;w(a).hide();w(H).stop().fadeOut(u.overlayFadeDuration,k)}return false}})(jQuery);

    if (!/android|iphone|ipod|series60|symbian|windows ce|blackberry/i.test(navigator.userAgent)){
        jQuery(function($){
            $("a[rel^='lightbox']").slimbox({counterText: countertext, easing: "easeOutElastic"}, null, function(el){
                return (this == el) || ((this.rel.length > 8) && (this.rel == el.rel));
            });
        });
    }

/* Forms plugin
------------------------------------------------------------------------------------------------ */

(function($) {
    $.fn.forms = function(options) {

        if (!this.length) return;

        var settings = $.extend({
            'confirmpage'       : 'html',       // Values: html | ajax | iframe (ajax is broken at the moment!)
            'error_value'       : false,        // Error message as input value
            'infobox'           : '.info',      // Container class for progress steps etc.
            'multipage'         : true,         // Multipage
            'scrolltop'         : '#content',   // Scrolltop ID for next/previous page
            'summarypage'       : true,         // Summarypage (only with active multipage)
            'progress_steps'    : true,         // Progress steps
            'debug'             : false         // Debug mode
        }, options);

        return this.each(function() {

            var form = this;

            // Turn off autocomplete with javascript. It's not a valid HTML attribut!

            if(settings.error_value)
                $(form).attr('autocomplete', 'off');

            // Multiple inputs
            $.fn.forms.multiInput(form);

            // Multipage
            $.fn.forms.multipage(form, settings);

            // Update contactinfo
            $.fn.forms.updateReceiver(form);

            // Error in value
            $.fn.forms.valueErrorMsg(form, settings);

            // Dependence
            $.fn.forms.dependence(form, settings);

            // Live validation on blur
            $.fn.forms.validcheck(form, settings, 'live');

            // Validate on submit

            $(form).submit(function() {

                if (settings.confirmpage == 'iframe') {

                    $('#iframesubmit').remove();

                    $(form).attr({
                        'target'    : 'iframesubmit'
                    });

                    $('body').append(
                        $('<iframe name="iframesubmit">').attr({    // IE Fix: Add the name with attr() don't work -> Iframe open in a new window
                            'class' : 'iframesubmit',
                            'id'    : 'iframesubmit'
                        })
                    );

                    if (!settings.debug) {
                        $('.iframesubmit').addClass('hideme');
                    }

                }

                // Focus first input

                setTimeout(function() {
                    $('.error :input:enabled:first', form).focus();
                }, 300);

                // Validate form

                var valid = $.fn.forms.validcheck(form, settings);
                return valid ? $.fn.forms.confirm(form, settings) : false;
            });
        });
    }

    // Validate form

    $.fn.forms.valid = function (el, settings, check) {

        var valid       = true,
            error_msg   = '';

        switch (el.type) {

            case 'radio':

                // radio validation

                valid       = false;
                error_msg   = 'Treffen Sie mindestens eine Auswahl!';

                $('input[name='+el.name+']').each(function() {
                    if ($(this).is(':checked')) {
                        error_msg   = '';
                        valid       = true;
                    }
                });

                break;

            case 'checkbox':

                // checkbox validation

                var siblings = $(el).siblings('.group').andSelf();

                if (siblings.length > 1) {
                    $(el).parents('.entry').find('.group:last').addClass('last');
                    if (check == 'live' && $(el).hasClass('last') ||
                        check == 'live' && !$(el).hasClass('last') && $(el).parents('.entry').hasClass('error') || 
                        check != 'live') {
                        if(!$(siblings).is(':checked')){
                            error_msg   = error_msg_checkbox;
                            valid       = false;
                        }
                    }
                }
                else {
                    if (!$(el).is(':checked')) {
                        error_msg   = error_msg_checkbox;
                        valid       = false;
                    }
                }
                break;

            default:

                // Normal validation

                if (el.value == '' || el.value == error_msg_default) {

                    error_msg   = error_msg_default;
                    valid       = false;

                }

                // Email validation

                else if ($(el).hasClass('email')) {

                    var regExp = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;

                    if (!el.value.match(regExp)) {

                        error_msg   = error_msg_email;
                        valid       = false;
                    }

                }

                // Numbers validation

                else if ($(el).hasClass('number')) {

                    if (el.value != Math.round(el.value)) {

                        error_msg   = error_msg_number;
                        valid       = false;

                    }

                }

                // Url validation
                
                else if ($(el).hasClass('url')) {

                    var regExp = /(http|https|ftp)?:\/\//;

                    if (el.value.match(regExp)) {

                        error_msg   = 'Links sind nicht erlaubt!';
                        valid       = false;
                    }
                }
        }

        // Error message

        if (valid) {

            // Remove error message

            $('.error_msg', $(el).parents('.entry')).remove();
            
            // Add okay class and remove error class

            $(el).parents('.entry').addClass('okay');
            $(el).parents('.entry').removeClass('error');

        }
        else {

            // custom error message

            if(custom_required_text[el.id])
                error_msg = custom_required_text[el.id];

            // insert error message

            if (!$(el).parents('.entry').hasClass('error')) {

                var error_msg_box = $('<p>').addClass('error_msg').text(error_msg);

                switch (el.type) {

                    case 'radio':

                        error_msg_box.insertBefore($('input[name='+el.name+']:first'));
                        break;

                    case 'checkbox':

                        if ($(el).hasClass('group'))
                            error_msg_box.insertBefore($(el).parents('.entry').find('.group:first'));
                        else
                            error_msg_box.insertBefore($(el));
                        break;

                    default:

                        if (settings.error_value && el.type != 'select-one' && $(el).is(':visible')) {
                            $(el).data('value', $(el).val());
                            $(el).addClass('error_value');
                            $(el).val(error_msg);
                        }
                        else if ($(el).siblings('.datepicker').length)
                            error_msg_box.insertAfter($(el).siblings('.datepicker'));
                        else
                            error_msg_box.insertAfter($(el));
                }
            }
            else {

                // Insert error message

                $('.error_msg .text', $(el).parents('.entry')).text(error_msg);

            }

            // Add error class and remove okay class

            $(el).parents('.entry').addClass('error');
            $(el).parents('.entry').removeClass('okay');
        }
    }

    // Live, multipage or normal validation check

    $.fn.forms.validcheck = function(form, settings, check) {

        var toValidate = new Array();

        switch (check) {

            case 'live':
                $('.required', form).blur(function() {

                    toValidate.push(this);

                    setTimeout(function() {
                        if (toValidate.length > 0) {
                            if ($(toValidate[0]).hasClass('required')) { // Some "required" classes might have been removed in the meantime (see dependencies)
                                $.fn.forms.valid(toValidate[0], settings, 'live');
                            }
                            toValidate.shift();
                        }
                    }, 300);

                });
                break;

            default:
                var required = (check == 'multipage') ? $('.section:visible .required', form) : $('.required', form);
                required.each(function() {
                    $.fn.forms.valid(this, settings);
                });

        }

        return ($('.error', form).length || $('.error_value:visible', form).length) ? false : true;

    }

    // Error in value

    $.fn.forms.valueErrorMsg = function(form, settings) {

        if (!settings.error_value)
            return;

        $('.required', form).focus(function() {
            if ($(this).hasClass('error_value')) {
                $(this).val($(this).data('value')).data('value', '').removeClass('error_value');
                $(this).parents('.error').removeClass('error');
            }
        });
    }

    // Get input value

    $.fn.forms.value = function(el) {

        var value = '';

        if ($(el).is('select')) {
            value = $(':selected', el).text();
        }
        else if ($(el).is('input[type=checkbox]') && $(el).is(':checked')) {
            value = yes;
        }
        else if ($(el).is('input[type=checkbox]') && !$(el).is(':checked')) {
            value = no;
        }
        else {
            value = $(el).val();
        }

        return value;
    }

    // Dependence

    $.fn.forms.dependence = function(form, settings) {

        // Check radio

        $('input[type=radio]', form).click(function() {

            var el = this;

            $('input[name='+el.name+']').each(function() {
                if ($(this).is(':checked') && $(this).hasClass('dependence')) {
                    addRequired(this);
                }
                else if (!$(this).is(':checked') && $(this).hasClass('dependence')) {
                    removeRequired(this);
                }
            });

            $.fn.forms.validcheck(form, settings, 'live');
        });

        // Check checkbox, textarea and input[type=text]

        $('.dependence', form).not('input[type=radio]').blur(function() {

            var el = this;

            switch(el.type) {

                case 'checkbox':
                    alert("not available at the moment");
                    break;

                default:
                    (el.value.length) ? addRequired(el) : removeRequired(el);

            }
            $.fn.forms.validcheck(form, settings, 'live');
        });

        // Add required

        function addRequired(el) {

            $('.depends_on_' + el.id).each(function() {

                $(this).addClass('required');
                var label = 'label[for='+this.id+']';

                if (!$(label).find('em').length) {
                    $(label).append(
                        $('<em>').text(' *')
                    );
                }
            });

        }

        // Remove required

        function removeRequired(el) {

            $('.depends_on_' + el.id).each(function(){
                $(this).removeClass('required');
                $(this).unbind();
                $(this).parents('.entry').removeClass('error');
                $('.error_msg', $(this).parents('.entry')).remove();
                $('label[for='+this.id+'] em').remove();
            });

        }
    }

    // Create multipage, summarypage and progress bar

    $.fn.forms.multipage = function(form, settings) {

        if(!settings.multipage)
            return;

        // Generate the progress bar and steps

        if (settings.progress_steps) {

            var progress_steps = $('<h2>').addClass('progress_steps');
            progress_steps.appendTo($(settings.infobox));

        }

        var progress_bar = $('<ol>').addClass('progress_bar');

        $('.section_title', form).each(function() {
            $('<li>').text($(this).text()).appendTo(progress_bar);
        })

        if (settings.summarypage) {

            $('.section:last', form).after(
                summary_section = $('<div>').addClass('section summary_section')
            );
            $('<li>').text(summary_title).appendTo(progress_bar);

        }

        progress_bar.appendTo($(settings.infobox));

        // Show only first section

        $('.section', form).show().not(':first').hide();

        // Back button

        $('<button type=button>').attr({
            'accesskey'     : 'b',
            'name'          : 'back'
            }).html('<span>' + back + '</span>').click(function() {

                $('.section:visible', form).hide().prev().show();
                $(':input:enabled:first', form).focus();
                $('#errorpage').remove();

                $.fn.forms.multipage.update(form, settings, progress_bar, progress_steps);

                // Jump to top of the form

                $('html, body').scrollTop($(settings.scrolltop).offset().top - 10);

                // Hide required text on summary page

                summary_section.is(':visible') ? $('.required_text', settings.infobox).hide() : $('.required_text', settings.infobox).show();

                return false;

        }).insertBefore('button[name=send]', form).hide();

        // Next button

        $('<button type=button>').attr({
            'accesskey'     : 'n',
            'name'          : 'next'
            }).html('<span>' + next + '</span>').click(function() {

                $.fn.forms.validcheck(form, settings, 'multipage');

                if (!$('.error:visible', form).length &&
                    !$('.error_value:visible', form).length) {

                    $('.section:visible', form).hide().next().show();
                    $('.section:visible :input:enabled:first', form).focus();

                    $.fn.forms.multipage.update(form, settings, progress_bar, progress_steps);

                    // Generate summary

                    $.fn.forms.summarypage(form, settings);

                    // Jump to top of the form

                    $('html, body').scrollTop($(settings.scrolltop).offset().top-10);

                    // Hide required text on summary page

                    summary_section.is(':visible') ? $('.required_text', settings.infobox).hide() : $('.required_text', settings.infobox).show();

                }
                else {

                    if(!settings.error_value)
                        $('.error :input:enabled:first', form).focus();

                }

            return false;

        }).insertBefore('button[name=send]', form).hide();

        $.fn.forms.multipage.update(form, settings, progress_bar, progress_steps);
    }

    // Should be run in each formfield change handles progress bar navigation and buttons

    $.fn.forms.multipage.update = function(form, settings, progress_bar, progress_steps) {

        // Update button next

        var button_back = $('button[name=back]', form);
        $('.section:first:visible', form).is(':visible') ? button_back.hide() : button_back.show();

        // Update button last

        var button_next = $('button[name=next]', form);
        $('.section:last', form).is(':visible') ? button_next.hide() : button_next.show();

        // Update button submit

        var button_submit = $('button[name=send]', form);
        !$('.section:last', form).is(':visible') ? button_submit.attr({ 'disabled': 'true' }).hide() : button_submit.attr({ 'disabled': '' }).show();

        // Update progress bar

        $('li.active', progress_bar).removeClass('active');
        $('li:contains("'+$('.section:visible .section_title', form).text()+'")', progress_bar).addClass('active done');

        $('li', progress_bar).each(function(index) {
            var title = $(this).text();
            if (!$(this).children('a').length &&
                $(this).hasClass('done')) {
                $(this).wrapInner(
                    $('<a>').attr({ 'rel': index, 'href': '#', 'title': title })
                );
            }
        });

        $('a', progress_bar).unbind('click').bind('click', function() {

            $('.section:visible', form).hide();
            $('.section:eq('+this.rel+')', form).show();
            $(':input:visible:enabled:first', form).focus();

            // Hide required text on summary page

            summary_section.is(':visible') ? $('.required_text', settings.infobox).hide() : $('.required_text', settings.infobox).show();

            $.fn.forms.multipage.update(form);
            return false;
        });

        // Update progress steps

        if (settings.progress_steps) {
            $(progress_steps).html(
                progress_step.replace('{x}', $('li.active', progress_bar).prevAll().length + 1).replace('{y}', $('li', progress_bar).length)
            );
        }

    };

    // Generate summary table

    $.fn.forms.summarypage = function(form, settings) {

        if (settings.summarypage &&
            $('.section:last', form).is(':visible')) {

            $('.summary_section', form).empty().append(
                $('<h2>').addClass('section_title').attr('title', 'summary_title').text(summary_title)
            );

            $('.section', form).not(':last').each(function() {

                var section_title = $(this).children('.section_title').text();

                $('<table>').addClass('summary').append(
                    $('<caption>').html(section_title),
                    tbody = $('<tbody>')
                ).appendTo(summary_section);

                $('label', $(this)).each(function() {

                    var me = $(this).parents('.multi_entry');

                    if (me.length) {

                        if ($(this).hasClass('hideme')) {

                            $(tbody).append(
                                $('<tr>').append(
                                    $('<td class="multi_summary" colspan="2">').append(
                                        subtable = $('<table>').append(
                                            $('<thead>').append($('<tr>')),
                                            $('<tbody>')
                                        )
                                    )
                                )
                            );

                            $('.entry:first label', me).each(function() {
                                $('thead tr', subtable).append($('<th>').text($(this).text().replace(' *', '')));
                            });

                            $('.entry', me).each(function() {
                                var row = $('<tr>');
                                $(':input', this).each(function(){
                                    var value = $.fn.forms.value(this);
                                    row.append($('<td>').text(value));
                                });
                                $('tbody', subtable).append(row);
                            });
                        }

                    }
                    else {

                        var value = $.fn.forms.value('#'+$(this).attr('for'));

                        if (value.length) {
                            $(tbody).append(
                                $('<tr>').append(
                                    $('<th>').text($(this).text().replace(' *', '')),
                                    $('<td>').text(value)
                                )
                            );
                        }

                    }
                });
            });
        }
    };

    // Update contactinfos on change email receiver

    $.fn.forms.updateReceiver = function(form) {

        $('#secure_target', form).change(function() {

            var contactID = $(':selected', $(this)).attr('id');

            if (contactID.length) {
                $('.locations_data .' + contactID + ' span', form).each(function() {
                    $('input[name=to_' + $(this).attr('title') + ']').val($(this).text());
                });
            }

        });
    }

    //Multiple Inputs init

    $.fn.forms.multiInput = function(form) {

        $('.multi_entry', form).each(function(i) {

            var me      = this,
                meid    = $('.multi_title', me).attr('id') + '_multi';

            $(me).append(

                $('<p>').html(
                    $('<a>').attr({
                        'href'  : '#'
                    }).text(add_entry).click(function() {

                        count = '_' + $('.entry', me).length;
                        clonekrieger = $('.entry:first', me).clone();
                        clonekrieger.addClass('clone');

                        $('label', clonekrieger).each(function() {
                            $(this).attr({
                                'for'       : $(this).attr('for') + count
                            });
                        });

                        $(':input', clonekrieger).each(function() {
                            $(this).attr({
                                'id'        : $(this).attr('id') + count,
                                'name'      : $(this).attr('name')+count 
                            }).val('');
                        });

                        clonekrieger.insertBefore($(this).parent());
                        $.fn.forms.multiInput.update(me);
                        return false;

                    })
                ).addClass('add'),

                $('<input>').attr({
                    'type'      : 'hidden',
                    'name'      : meid,
                    'id'        : meid
                }),
                $('<label>').attr({
                    'for'       : meid
                }).html($('legend', this).html()).addClass('hideme')

            );
            $.fn.forms.multiInput.update(me);
        });

    }

    //Update on Unfocus

    $.fn.forms.multiInput.update = function(me) {

        $(':input', me).unbind().blur(function() {

            var v = '';

            $('.entry :input', me).each(function() {
                v += $('label[for=' + $(this).attr('id') + ']').text().replace(' *', '') + ': ';
                v += $.fn.forms.value(this) + '\n';
            })

            $('input[name=' + $('legend', me).attr('id') + '_multi]', me).val(v);
        });

    };

    // Send message and load confirm text with ajax

    $.fn.forms.confirm = function(form, settings) {

        // Debug mode
        
        if (settings.debug) {
            console.log('settings.confirmpage: ' + settings.confirmpage);
        }

        // Disable send button

        $('button[name=send] span', form).text(wait).attr('disabled', 'disabled');

        // Send message and load confirmpage with ajax

        if (settings.confirmpage == 'ajax') {

            // Debug mode
            
            if (settings.debug) {
                console.log('Action: ' + $(form).attr('action'));
                console.log('Data: ' + $(form).serialize());
            }

            $.ajax({
                'type'      : 'POST',
                'url'       : $(form).attr('action'),
                'data'      : $(form).serialize(),
                'cache'     : true,
                'complete'  : function(data, textStatus) {

                                // Insert confirmpage

                                $('.required_text').remove();

                                $(form).after(
                                    $('<div>').attr({
                                        'id'    : 'confirmpage'
                                    }).load($('input[name=next]').val() + ' #confirm')
                                );

                                $(form).remove();

                                // Show summary page
    
                                if (settings.summarypage && settings.multipage) {

                                    $('#confirmpage').after(
                                        $('<p>').addClass('print').append(
                                            $('<a>').attr({
                                                'href'      : '#',
                                                'title'     : 'Zusammenfassung drucken'
                                            }).text('Zusammenfassung drucken')
                                        ),
                                        summary_section.clone()
                                    );

                                    $('.print').click(function() {
                                        window.print();
                                        return false;
                                    });

                                }

                                // Scroll to the top

                                $('html, body').scrollTop($(settings.scrolltop).offset().top - 10);

                                // Debug mode

                                if (settings.debug) {
                                    console.log('Ajax complete.');
                                    console.log('Data: '    + data);
                                    console.log('Status: '  + textStatus);
                                }

                                return false;
                            }
            });
        }

        // Send message with hidden iframe

        else if (settings.confirmpage == 'iframe') {

            // Insert confirmpage

            $('#iframesubmit').load(function(responseText, textStatus, XMLHttpRequest) {

                try {

                    var confirm = $('.iframesubmit').contents().find('#confirm').html();

                    // Remove form and insert confirmpage

                    $(form).after(
                        $('<div>').attr({
                            'id'        : 'confirmpage'
                            }).append(confirm)
                    );

                    $('#errorpage').remove();

                }

                catch (e) {

                    if (!$('#errorpage').length) {

                        $(form).before(
                            $('<div>').attr({
                                'id'    : 'errorpage'
                            }).append(
                                $('<h2>').text(errorpage_headline),
                                $('<p>').text(errorpage)
                            )
                        )

                    }

                }

                if (!$('#errorpage').length) {

                    $('.required_text').remove();
                    $(form).remove();

                    // Show summary page

                    if (settings.summarypage &&
                        settings.multipage) {

                        $('#confirmpage').after(
                            $('<p>').addClass('print').append(
                                $('<a>').attr({
                                    'href'      : '#',
                                    'title'     : 'Zusammenfassung drucken'
                                }).text('Zusammenfassung drucken')
                            ),
                            summary_section.clone()
                        );

                        $('.print').click(function() {
                            window.print();
                            return false;
                        });
                    }

                }
                else {
                    $('button[name=send] span', form).text(send).attr('disable', '');
                }

                // Scroll to the top

                $('html, body').scrollTop($(settings.scrolltop).offset().top - 10);

            });
            return true;
        }

        // Normal send

        else if (settings.confirmpage == 'html') {
            return true;
        }
    }
})(jQuery);




/*-- display elements --*/

    (function($){
        $.fn.showElement = function(options){
            var SE_Settings = {
                handler: 'toggle',
                destination: '',
                animate: false
            };
            var SE_Settings = $.extend(SE_Settings, options);

            // hide href anchor destination
            if($(this).length){
                if($(this).is('a')){
                    var destination = ($(SE_Settings.destination).length) ? $(SE_Settings.destination) : $('#'+$(this).attr('href').split('#').pop());
                }
                else{
                    $(this).wrapInner('<a href="#" />');
                    var destination = $(SE_Settings.destination);
                }
                destination.hide();
                // show destination
                if(SE_Settings.handler == 'toggle'){
                    // toogle destination
                    $(this).toggle(
                        function(){ (SE_Settings.animate) ? destination.animate(SE_Settings.animate, { duration: 'slow' }) : destination.show(); },
                        function(){ (SE_Settings.animate) ? destination.animate(SE_Settings.animate, { duration: 'slow' }) : destination.hide(); }
                    );
                }
                else if(SE_Settings.handler == 'mouseover'){
                    // show destination on mouseover
                    $(this).bind({
                        click: function(){ return false; },
                        mouseover: function(){ (SE_Settings.animate) ? destination.animate(SE_Settings.animate, { duration: 'slow' }) : destination.show(); },
                        mouseout: function(){ (SE_Settings.animate) ? destination.animate(SE_Settings.animate, { duration: 'slow' }) : destination.hide(); }
                    });
                }
            }
        };
    })(jQuery);

/*-- Default value -- */

    (function($){
        $.fn.defaultValue = function(){
            $(this).focus(function(){
                if(!$(this).data('defaultValue')) $(this).data('defaultValue', $(this).attr('value'));
                if($(this).data('defaultValue') == $(this).attr('value')) $(this).attr('value', '');
            }).blur(function(){
                if(!$(this).attr('value').length) $(this).attr('value', $(this).data('defaultValue'));
            });
        };
    })(jQuery);

/*-- Dropdown menu --*/

    (function($){
        $.fn.DropdownMenu = function(options){
            var defaults = {
                removeTitle: true,
                timeOut: 1000
            };
            var options = $.extend(defaults, options);
            var navInterval;
            var el = $(this);
            if(el.length && options.removeTitle)
                $('a', el).attr('title', '');
            $('li', el).not('li li', el).mouseover(function(){
                if(navInterval)
                    clearInterval(navInterval);
                $('li.hover', el).removeClass('hover');
                $(this).addClass('hover');
            }).mouseout(function(){
                $(this).addClass('delete');
                if($(this).has('ul').length > 0)
                    navInterval = setInterval (function(){ $('li.delete', el).removeClass('hover delete'); }, options.timeOut);
                else
                    $('li.delete', el).removeClass('hover delete');
            });
        };
    })(jQuery);





/*-- Create onchange select --*/

    (function($){
        $.fn.createOnchangeSelect = function(options){
            var settings = $.extend({
                'label': false,
                'group': false,
                'id': 'selection'
            }, options);

            return this.each(function(){
                var el = this;
                if(!$('li a', el).length)
                    return;
                if(settings.group){
                    // Create form and select
                    $(el).append(
                        form = $('<form>').attr('action', '').append(
                            select = $('<select>').attr({
                                'id': settings.id,
                                'name': settings.id
                            }).addClass($(this).attr('class'))
                        )
                    );
                    // Create optgroup
                    $(settings.group, el).each(function(){
                        $(select).append(
                            optgroup = $('<optgroup>').attr('label', $(this).text())
                        );
                        // Fill select with options
                        $.fn.createOnchangeSelect.fillSelect($(this).next('ul'), optgroup);
                    });
                }
                else{
                    $('ul, ol', el).each(function(){
                        // Create form and select
                        $(this).after(
                            form = $('<form>').attr('action', '').append(
                                select = $('<select>').attr({
                                    'id': settings.id,
                                    'name': settings.id
                                }).addClass($(this).attr('class'))
                            )
                        );
                        // Fill select with options
                        $.fn.createOnchangeSelect.fillSelect(el, select);
                    });
                }
                // Onchange
                $(select).change(function(){
                    location.href=this.value;
                });
                // Create label
                if(settings.label){
                    $(form).prepend(
                        label = $('<label>').attr('for', settings.id).text($(settings.label).text())
                    );
                }
                // Remove non javascript html code
                $('ul, ol, '+settings.group, el).remove();
                $(settings.label).remove();
            });
        }

        // Fill select with options
        $.fn.createOnchangeSelect.fillSelect = function(el, select){
            $('li a', el).each(function(){
                $(select).append(
                    option = $('<option>').val(this.href).text($(this).text())
                );
                if($(this).hasClass('active'))
                    $(option).attr('selected', 'selected');
            });
        }
    })(jQuery);

/*-- Add bookmark links --*/

    (function($){
        $.fn.bookmark = function(options){
            // Settings
            var settings = $.extend({
                'appendTo': false
            }, options);

            if($.browser.opera || $.browser.msie || $.browser.mozilla){
                return this.each(function(){
                    var el = this;
                    // Create boommark link
                    var bookmarkLink = $('<a>').attr({
                        'href': el.href,
                        'title': 'Lesezeichen hinzufügen'
                    }).addClass('bookmark click').text('Lesezeichen hinzufügen');
                    // Add bookmark link
                    if(settings.appendTo){
                        $(settings.appendTo).show();
                        $(el).parent().next(settings.appendTo).append(bookmarkLink);
                    }
                    else
                        $(el).after(bookmarkLink);
                    // Click bookmark link
                    $(bookmarkLink).click(function(){
                        var el = this;
                        var bookmarkUrl = el.href;
                        var bookmarkTitle = el.title;
                        if(window.sidebar)
                            window.sidebar.addPanel(bookmarkTitle, bookmarkUrl, ''); // For Mozilla Firefox Bookmark
                        else if(window.external || document.all)
                            window.external.AddFavorite(bookmarkUrl, bookmarkTitle); // For IE Favorite
                        else if(window.opera)
                            $(el).attr('rel', 'sidebar'); // For Opera Browsers
                        return false;
                    });
                });
            }
            else if(settings.addTo){
                $(settings.addTo).remove();
            }
        }
    })(jQuery);

/*-- Google Maps --*/

    (function($){
        $.fn.GoogleMaps = function(options){
            // Settings
            var settings = $.extend({
                'id': false,
                'mapdata': false,
                'zoom': 17,
                'min_zoom': 4,
                'max_zoom': 18,
                'map_control': false,
                'hide_description': false,
                'hide_company_name': false
            }, options);

            return this.each(function(){
                var el = this;
                if(!$(el).length || !settings.id || !settings.mapdata)
                    return;
                // Show Map -> hide without javascript
                $(el).show();
                // Remove static map
                $('img', el).remove();
                // Default latlng
                var location = {
                    company_name: settings.mapdata[0].company_name,
                    street: settings.mapdata[0].street,
                    postal_code: settings.mapdata[0].postal_code,
                    city: settings.mapdata[0].city,
                    country: settings.mapdata[0].country,
                    latitude: settings.mapdata[0].latitude,
                    longitude: settings.mapdata[0].longitude
                };
                var address = '';
                if(location.street && location.postal_code && location.city && location.country)
                    address = location.street + ', ' + location.postal_code + ' ' + location.city + ', ' + location.country;
                if(location.latitude && location.longitude){
                    var latlng = new google.maps.LatLng(location.latitude, location.longitude);
                    // Initialize map
                    $.fn.GoogleMaps.init(el, settings, latlng);
                }
                else if(address){
                    // Geocode: convert address to latlng
                    var geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ 'address': address }, function(results, status){
                        if(status == google.maps.GeocoderStatus.OK){
                            var latlng = results[0].geometry.location;
                            // Initialize map
                            $.fn.GoogleMaps.init(el, settings, latlng);
                        }
                    });
                }
            });
        }

        $.fn.GoogleMaps.init = function(el, settings, latlng){
            // Map options
            var MapOptions = {
                zoom: settings.zoom,
                center: latlng,
                scrollwheel: false,
                mapTypeId: google.maps.MapTypeId.TERRAIN,
                mapTypeControl: settings.map_control,
                mapTypeControlOptions:{
                    style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR
                },
                navigationControl: true,
                navigationControlOptions:{
                    style: google.maps.NavigationControlStyle.SMALL
                }
            };
            // Initialize map
            var map = new google.maps.Map(document.getElementById($(el).attr('id')), MapOptions),
                infowindow = new google.maps.InfoWindow(),
                cords = new Array(),
                markers = new Array();
            // min/max zoom
            if(settings.min_zoom <= settings.max_zoom){
                google.maps.event.addListener(map, 'zoom_changed', function() {
                    if (this.getZoom() < settings.min_zoom) this.setZoom(settings.min_zoom);
                    if (this.getZoom() > settings.max_zoom) this.setZoom(settings.max_zoom);
                });
            }
            // Directions panel
            $.fn.GoogleMaps.directions(map, settings, markers, cords, infowindow);
            // Set Markers
            $(settings.mapdata).each(function(){
                var location = {
                    company_name: this.company_name,
                    street: this.street,
                    postal_code: this.postal_code,
                    city: this.city,
                    country: this.country,
                    phone: this.phone,
                    fax: this.fax
                };
                var address = '';
                if(location.street && location.postal_code && location.city && location.country)
                    address = location.street + ', ' + location.postal_code + ' ' + location.city + ', ' + location.country;
                if(this.latitude && this.longitude){
                    latlng = new google.maps.LatLng(this.latitude, this.longitude);
                    cords.push(latlng);
                    markers.push($.fn.GoogleMaps.marker(map, settings, latlng, location, infowindow));
                    $.fn.GoogleMaps.update(map, settings, markers);
                }
                // Geocode: convert address to latlng
                else if(address){
                    var geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ 'address': address }, function(results, status){
                        if(status == google.maps.GeocoderStatus.OK){
                            latlng = results[0].geometry.location;
                            cords.push(latlng);
                            markers.push($.fn.GoogleMaps.marker(map, settings, latlng, location, infowindow));
                            $.fn.GoogleMaps.update(map, settings, markers);
                        }
                    });
                }
            });
        }

        $.fn.GoogleMaps.marker = function(map, settings, latlng, location, infowindow){
            // Create infowindow
            var description = '<div class="google description">';
            if(location.company_name && settings.hide_company_name){
                description += '<h2>' + location.company_name + '</h2>';
            }
            description += '<div class="google address">';
            description += '<p>' + location.street + '<br />' + location.postal_code + ' ' + location.city + '<br />' + location.country + '</p>';
            if(location.phone || location.fax)
                description += '<p>';
            if(location.phone)
                description += '<strong>' + phone + '</strong> ' + location.phone + '<br />';
            if(location.fax)
                description += '<strong>' + fax + '</strong> ' + location.fax + '<br />';
            if(location.phone || location.fax)
                description += '</p>';
            description += '</div>';
            description += '</div>';
            // Set marker
            var marker = new google.maps.Marker({
                position: latlng, 
                map: map,
                title: marker_title,
                description: description,
                clickable: (settings.hide_description)? true : false
            });
            // Set infowindow to marker
            if(settings.hide_description){
                if(description){
                    google.maps.event.addListener(marker, 'click', function(){
                        infowindow.setContent(this.description);
                        infowindow.open(map, this);
                    });
                    if(settings.mapdata.length == 1)
                        google.maps.event.trigger(marker, 'click');
                }
            }
            return marker;
        }

        $.fn.GoogleMaps.update = function(map, settings, markers){
            // Update map
            if($(markers).length > 1){
                // Show all markers on the map
                var bounds = new google.maps.LatLngBounds();
                $(markers).each(function(){
                    bounds.extend(this.getPosition());
                });
                map.fitBounds(bounds);
            }
        }

        // Hide all markers
        $.fn.GoogleMaps.hideAllMarkers = function(map, markers, infowindow){
            $(markers).each(function(){
                this.setVisible(false);
            });
            infowindow.close(map);
        }

        $.fn.GoogleMaps.directions = function(map, settings, markers, cords, infowindow){
            var direction = '#direction_' + settings.id;
            if(!$(direction).length)
                return;
            // Show DIV -> hide without javascript
            $(direction).show();
            // Initialize directions panel
            var directionsService = new google.maps.DirectionsService();
            var directions = new google.maps.DirectionsRenderer({
                map: map,
                panel: document.getElementById('panel_' + settings.id)
            });
            $('form', direction).submit(function(){
                $('#content').scrollTop(0);
                if($('#saddr_' + settings.id).val().length){
                    // Print directions result
                    var panel = '#panel_' + settings.id;
                    $(panel).show();
                    $('.print a', panel).click(function(){
                        window.print();
                        return false; 
                    });
                    // Directions result             
                    var destination_value = $(cords)[$('#daddr_' + settings.id).val()];
                    var request = {
                        origin: $('#saddr_' + settings.id).val(),
                        destination: (destination_value ? destination_value : $(cords)[0]),
                        travelMode: google.maps.DirectionsTravelMode.DRIVING
                    };
                    directionsService.route(request, function(result, status){
                        if(status == google.maps.DirectionsStatus.OK){
                            directions.setDirections(result);
                            $.fn.GoogleMaps.update(map, settings, markers);
                            $.fn.GoogleMaps.hideAllMarkers(map, markers, infowindow);
                        }
                    });
                }
                return false;
            });
        }
    })(jQuery);


/*-- DOM -- */

 $(function(){
            if ( $('#subnav').length > 0 ) {
	    $('#subnav').stickyfloat({ duration: 400, lockBottom:'true', offsetY: -80});
	    }
            
        // IE6nomore
        $.IE6nomore();
        // Forms
        $('form.contact').forms();
        $('form.newsletter').forms({ 'multipage': false });
        // News
        $('#news_selection').createOnchangeSelect({ 'label': '#news_selection h3' });
        // Infolists
        $('.selection').createOnchangeSelect({ 'group': '.group' });
        // Show elements
        $('.show_disclaimer').showElement();
        // Search
        $('#search input[type=text]').defaultValue();
        // Iframe popup
        $('.popup').popup();
        // Links
        $('.link').bookmark({ 'appendTo': '.bookmark' });
        // Table
        $('.downloads td').clickable();
        $('.links_section td').clickable();

      
      
             $('.headlink').hover( 
                function () {
                   oldheadlinkdiv = $('.headlinkdiv.active').attr('id');
                   oldheadlinkli = $('.headlinkli.active').attr('id');
                
                $('#'+oldheadlinkli).removeClass('active');   
                 $('.headlinkdiv').removeClass('active');
                     numb3r ='#headlinkdiv_'+$(this).attr('rel');
               var  numb3rlnk ='#headlink_'+$(this).attr('rel');
                   oldheadlinkli = $('.headlinkli.active').attr('id');
                  $(numb3rlnk).addClass('active');
              
              
              
                  $(numb3r).addClass('active');
                },
                function () {
                    // $('.headlinkdiv').removeClass('active');
                    // $('#'+oldheadlinkdiv).addClass('active');
                    // $('#'+oldheadlinkli).addClass('active');
                }
              );
              
              
        $('.headlink').click(
                function () {
                   oldheadlinkdiv = $('.headlinkdiv.active').attr('id')
                 $('.headlinkli').removeClass('active');
                 var  numb3rlnk ='#headlink_'+$(this).attr('rel');
                   oldheadlinkli = $('.headlinkli.active').attr('id');
                  $(numb3rlnk).addClass('active');
                }
              );
              
              
          $('#circuit').jcarousel({
              scroll:1,
              visible:1,
              animation:'slow',
              wrap: 'circular',
              auto:10
            }); 
              
       
    $('#footercircuit').jcarousel({
              scroll:1,
              visible:1,
              animation:'slow',
              wrap: 'circular',
              auto:15
            }); 

                
    });


