$(document).ready(function() {

		// NAVIGATION
		$(function($){
			$.fn.superfish = function(op){
				var sf = $.fn.superfish,
					c = sf.c,
					$arrow = $(['<span class="',c.arrowClass,'"></span>'].join('')),
					over = function(){
						var $$ = $(this), menu = getMenu($$);
						clearTimeout(menu.sfTimer);
						$$.showSuperfishUl().siblings().hideSuperfishUl();
					},
					out = function(){
						var $$ = $(this), menu = getMenu($$), o = sf.op;
						clearTimeout(menu.sfTimer);
						menu.sfTimer=setTimeout(function(){
							o.retainPath=($.inArray($$[0],o.$path)>-1);
							$$.hideSuperfishUl();
							if (o.$path.length && $$.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.$path);}
						},o.delay);	
					},
					getMenu = function($menu){
						var menu = $menu.parents(['ul.',c.menuClass,':first'].join(''))[0];
						sf.op = sf.o[menu.serial];
						return menu;
					},
					addArrow = function($a){ $a.addClass(c.anchorClass).append($arrow.clone()); };
					
				return this.each(function() {
					var s = this.serial = sf.o.length;
					var o = $.extend({},sf.defaults,op);
					o.$path = $('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){
						$(this).addClass([o.hoverClass,c.bcClass].join(' '))
							.filter('li:has(ul)').removeClass(o.pathClass);
					});
					sf.o[s] = sf.op = o;
					
					$('li:has(ul)',this)[($.fn.hoverIntent && !o.disableHI) ? 'hoverIntent' : 'hover'](over,out).each(function() {
						if (o.autoArrows) addArrow( $('>a:first-child',this) );
					})
					.not('.'+c.bcClass)
						.hideSuperfishUl();
					
					var $a = $('a',this);
					$a.each(function(i){
						var $li = $a.eq(i).parents('li');
						$a.eq(i).focus(function(){over.call($li);}).blur(function(){out.call($li);});
					});
					o.onInit.call(this);
					
				}).each(function() {
					var menuClasses = [c.menuClass];
					if (sf.op.dropShadows  && !($.browser.msie && $.browser.version < 7)) menuClasses.push(c.shadowClass);
					$(this).addClass(menuClasses.join(' '));
				});
			};
		
			var sf = $.fn.superfish;
			sf.o = [];
			sf.op = {};
			sf.IE7fix = function(){
				var o = sf.op;
				if ($.browser.msie && $.browser.version > 6 && o.dropShadows && o.animation.opacity!=undefined)
					this.toggleClass(sf.c.shadowClass+'-off');
				};
			sf.c = {
				bcClass     : 'sf-breadcrumb',
				menuClass   : 'sf-js-enabled',
				anchorClass : 'sf-with-ul',
				arrowClass  : 'sf-sub-indicator',
				shadowClass : 'sf-shadow'
			};
			sf.defaults = {
				hoverClass	: 'sfHover',
				pathClass	: 'overideThisToUse',
				pathLevels	: 1,
				delay		: 800,
				animation	: {opacity:'show'},
				speed		: 'normal',
				autoArrows	: true,
				dropShadows : true,
				disableHI	: false,		// true disables hoverIntent detection
				onInit		: function(){}, // callback functions
				onBeforeShow: function(){},
				onShow		: function(){},
				onHide		: function(){}
			};
			$.fn.extend({
				hideSuperfishUl : function(){
					var o = sf.op,
						not = (o.retainPath===true) ? o.$path : '';
					o.retainPath = false;
					var $ul = $(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass)
							.find('>ul').hide().css('visibility','hidden');
					o.onHide.call($ul);
					return this;
				},
				showSuperfishUl : function(){
					var o = sf.op,
						sh = sf.c.shadowClass+'-off',
						$ul = this.addClass(o.hoverClass)
							.find('>ul:hidden').css('visibility','visible');
					sf.IE7fix.call($ul);
					o.onBeforeShow.call($ul);
					$ul.animate(o.animation,o.speed,function(){ sf.IE7fix.call($ul); o.onShow.call($ul); });
					return this;
				}
			});
		});
	/* // */
	
	



	// TABBED CONTENT
	//Default Action
	$(".TabContent").hide();
	$("ul.Tabmenu li:first").addClass("active").show();
	$(".TabContent:first").show();

	//On Click Event
	$("ul.Tabmenu li").click(function() {
		$("ul.Tabmenu li").removeClass("active");
		$(this).addClass("active");
		$(".TabContent").hide();
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn();
		return false;
	});
	/* // */
	
	
	


	
	// MODALBOX
	$(function ($) {
		var defaults = {
			selector: '.Modalbox',
			popupId: 'Modalbox',
			preloadText: 'Lade Inhalt...',
			errorText: 'Leider kann der Inhalt nicht geladen werden!',
			closeText: 'Close',
			prevText: '&laquo; zur&uuml;ck',
			nextText: 'vor &raquo;'
		};
		if (typeof options == 'string') defaults.selector = options;
		var options = $.extend(defaults, options);
		return $(options.selector).each(function (i) {
			if ($(this).hasClass('gallery')) {
				var classNames = $(this).attr('class');
				classNames = classNames.split(' ').join('');
				$.data(this, 'gallery', classNames);
				eval('if((typeof ' + classNames + '_arr == "undefined")) ' + classNames + '_arr= new Array()');
				eval(classNames + '_arr').push($(this));
				$.data(this, 'index', eval(classNames + '_arr').length - 1)
			};
			$(this).bind('click', function (e) {
				e.preventDefault();
				if ($.browser.opera) $.support.opacity = true;
				var ie6 = $.browser.msie && $.browser.version.substr(0, 1) < 7;
				var opera95 = $.browser.opera && $.browser.version <= 9.5;
				var w = $(window).width();
				var h = $(document).height();
				var w2 = $(window).width() / 2;
				var h2 = $(window).height() / 2;
				show = function () {
					$('#' + options.popupId + 'preloader').remove();
					if (cw != 0) $('#' + options.popupId + 'content').css('width', cw + 'px');
					if (ch != 0) $('#' + options.popupId + 'content').css('height', ch + 'px');
					set($('#' + options.popupId + 'content'));
					$('img', '#' + options.popupId + 'content').css('visibility', 'visible')
				};
				set = function (obj) {
					$(obj).css({
						'padding': '10px',
						'background': '#fff',
						'color': '#333',
						'text-align': 'left',
						'float': 'left',
						'position': 'fixed',
						'z-index': '10001',
						'visible': 'hidden'
					});
					var left = w2 - $(obj).width() / 2;
					var top = h2 - $(obj).height() / 2;
					$(obj).css({
						'left': left,
						'top': top,
						'display': 'none'
					}).fadeIn('1000');
					if (ie6) $(obj).css({
						'position': 'absolute',
						'top': (top + $(window).scrollTop()) + 'px'
					});
					if (opera95) $(obj).css({
						'position': 'absolute',
						'top': (document.body['clientHeight'] / 2 - $(obj).height() / 2 + $(window).scrollTop()) + 'px'
					});
					$('.caption', obj).css({
						'width': $(obj).width() + 'px',
						'display': 'block'
					})
				};
				if (ie6) $('embed, object, select').css('visibility', 'hidden');
				error = function () {
					$('#' + options.popupId + 'content').text(options.errorText);
					show()
				};
				remove = function () {
					$('#' + options.popupId).remove();
					$('#' + options.popupId + 'content').remove();
					$('#' + options.popupId + 'preloader').remove();
					if (ie6) $('embed, object, select').css('visibility', 'visible')
				};
				if ($('#' + options.popupId).length == 0) {
					$('<div id="' + options.popupId + '"></div>').appendTo('body').css({
						'width': w,
						'height': h,
						'background': '#000',
						'position': 'absolute',
						'top': '0',
						'left': '0',
						'z-index': '10000',
						'opacity': .7
					}).click(function () {
						remove()
					})
				};
				var href = $(this).attr('href');
				var extension = href.substr(href.lastIndexOf('.')).toLowerCase();
				var content;
				var cw = 0;
				var ch = 0;
				var showOk = false;
				$('<div id="' + options.popupId + 'preloader">' + options.preloadText + '</div>').appendTo('body');
				set($('#' + options.popupId + 'preloader'));
				$('<div id="' + options.popupId + 'content"></div>').appendTo('body');
				if ($(this).hasClass('flash')) {
					var flash = '<object width="100%" height="100%"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="' + href + '" /><embed src="' + href + '" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="100%" height="100%"></embed></object>';
					$(flash).appendTo('#' + options.popupId + 'content');
					cw = 600;
					ch = 400;
					showOk = true
				} else {
					if (extension == '.jpg' || extension == '.jpeg' || extension == '.gif' || extension == '.png' || extension == '.bmp') {
						var img = new Image();
						$(img).error(function () {
							error()
						}).css('visibility', 'hidden').appendTo('#' + options.popupId + 'content');
						img.onload = function () {
							show();
							img.onload = function () {}
						};
						img.src = href + '?' + (new Date()).getTime() + ' =' + (new Date()).getTime()
					} else if (href.charAt(0) == '#') {
						$(href).clone().removeClass('hidden').show().appendTo('#' + options.popupId + 'content');
						showOk = true
					} else {
						$('<iframe frameborder="0" scrolling="auto" style="width:100%;height:100%" src="' + href + '" />').appendTo('#' + options.popupId + 'content');
						cw = 900;
						ch = 500;
						showOk = true
					}
				};
				var rel = $(this).attr('rel').split(';');
				$.each(rel, function (i) {
					if (rel[i].indexOf('width') != -1) cw = rel[i].split(':')[1];
					if (rel[i].indexOf('height') != -1) ch = rel[i].split(':')[1]
				});
				if ($(this).attr('title') != '') {
					$('<span class="caption">' + $(this).attr('title') + '</span>').appendTo('#' + options.popupId + 'content').css({
						'display': 'none',
						'padding': '10px 0 0 0'
					})
				};
				if (showOk) show();
				$('<small>' + options.closeText + '</small>').appendTo('#' + options.popupId + 'content').css({
					'position': 'absolute',
					'float': 'left',
					'left': '0',
					'top': '-24px',
					'color': '#fff',
					'cursor': 'pointer'
				}).click(function () {
					remove()
				});
				if ($(this).hasClass('gallery')) {
					var arr = $.data(this, 'gallery');
					arr = eval(arr + '_arr');
					var index = $.data(this, 'index');
					if (arr.length > 1) {
						$('<small>' + (index + 1) + '/' + arr.length + '</small>').appendTo('#' + options.popupId + 'content').css({
							'position': 'absolute',
							'float': 'right',
							'right': '0',
							'bottom': '-24px',
							'color': '#fff',
							'cursor': 'pointer'
						});
						$('<small id="' + options.popupId + 'gallery"></small>').appendTo('#' + options.popupId + 'content').css({
							'position': 'absolute',
							'float': 'left',
							'left': '0',
							'bottom': '-24px',
							'color': '#fff',
							'cursor': 'pointer'
						});
						if (index != 0) {
							$('<span>' + options.prevText + '</span>').css('margin-right', '5px').appendTo('#' + options.popupId + 'gallery').click(function () {
								$('#' + options.popupId + 'content').remove();
								var obj = arr[index - 1];
								$(obj).trigger('click')
							})
						}
						if (index < arr.length - 1) {
							$('<span>' + options.nextText + '</span>').appendTo('#' + options.popupId + 'gallery').click(function () {
								$('#' + options.popupId + 'content').remove();
								var obj = arr[index + 1];
								$(obj).trigger('click')
							})
						}
					}
				}
			})
		})
	});
	/* // */
	

	$(function($){  
		$.fn.tinyTips = function (supCont) {
			var tipFrame = '<div class="Tip"><div class="content"></div><div class="bottom">&nbsp;</div></div>';
			
			// Speed of the animations in milliseconds - 1000 = 1 second.
			var animSpeed = 300;
			
			/***************************************************************************************************/
			/* End of user settings - Do not edit below this line unless you are trying to edit functionality. */
			/***************************************************************************************************/
			
			// Global tinyTip variable;
			var tinyTip;
			var tText;
			
			// When we hover over the element that we want the tooltip applied to
			$(this).hover(function() {
			
				// Inject the markup for the tooltip into the page and
				// set the tooltip global to the current markup and then hide it.
				$('body').append(tipFrame);
				tinyTip = $('div.Tip');
				tinyTip.hide();
				
				// Grab the content for the tooltip from the title attribute (or the supplied content) and
				// inject it into the markup for the current tooltip. NOTE: title attribute is used unless
				// other content is supplied instead.
				if (supCont === 'title') {
					var tipCont = $(this).attr('title');
				} else if (supCont !== 'title') {
					var tipCont = supCont;
				}
				$('.Tip .content').html(tipCont);
				tText = $(this).attr('title');
				$(this).attr('title', '');
				
				// Offsets so that the tooltip is centered over the element it is being applied to but
				// raise it up above the element so it isn't covering it.
				var yOffset = tinyTip.height() + 5;
				var xOffset = (((tinyTip.width() - 1) / 2)) - ($(this).width() / 2);
				
				// Grab the coordinates for the element with the tooltip and make a new copy
				// so that we can keep the original un-touched.
				var pos = $(this).offset();
				var nPos = pos;
				
				// Add the offsets to the tooltip position
				nPos.top = pos.top - yOffset;
				nPos.left = pos.left - xOffset;
				
				// Make sure that the tooltip has absolute positioning and a high z-index, 
				// then place it at the correct spot and fade it in.
				tinyTip.css('position', 'absolute').css('z-index', '1000');
				tinyTip.css(nPos).fadeIn(animSpeed);
				
			}, function() {
				
				$(this).attr('title', tText);
			
				// Fade the tooltip out once the mouse moves away and then remove it from the DOM.
				$('div.Tip').fadeOut(animSpeed, function() {
					$(this).remove();
				});
				
			});
			
		}
	});	



});

