/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net)
 * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
 * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
 *
 * $LastChangedDate: 2007-08-17 13:14:11 -0500 (Fri, 17 Aug 2007) $
 * $Rev: 2759 $
 *
 * Version: 1.1.2
 *
 * Requires: jQuery 1.1.3+
 */
(function($){var height=$.fn.height,width=$.fn.width;$.fn.extend({height:function(){if(!this[0])error();if(this[0]==window)if($.browser.opera||($.browser.safari&&parseInt($.browser.version)>520))return self.innerHeight-(($(document).height()>self.innerHeight)?getScrollbarWidth():0);else if($.browser.safari)return self.innerHeight;else
return $.boxModel&&document.documentElement.clientHeight||document.body.clientHeight;if(this[0]==document)return Math.max(($.boxModel&&document.documentElement.scrollHeight||document.body.scrollHeight),document.body.offsetHeight);return height.apply(this,arguments);},width:function(){if(!this[0])error();if(this[0]==window)if($.browser.opera||($.browser.safari&&parseInt($.browser.version)>520))return self.innerWidth-(($(document).width()>self.innerWidth)?getScrollbarWidth():0);else if($.browser.safari)return self.innerWidth;else
return $.boxModel&&document.documentElement.clientWidth||document.body.clientWidth;if(this[0]==document)if($.browser.mozilla){var scrollLeft=self.pageXOffset;self.scrollTo(99999999,self.pageYOffset);var scrollWidth=self.pageXOffset;self.scrollTo(scrollLeft,self.pageYOffset);return document.body.offsetWidth+scrollWidth;}else
return Math.max((($.boxModel&&!$.browser.safari)&&document.documentElement.scrollWidth||document.body.scrollWidth),document.body.offsetWidth);return width.apply(this,arguments);},innerHeight:function(){if(!this[0])error();return this[0]==window||this[0]==document?this.height():this.is(':visible')?this[0].offsetHeight-num(this,'borderTopWidth')-num(this,'borderBottomWidth'):this.height()+num(this,'paddingTop')+num(this,'paddingBottom');},innerWidth:function(){if(!this[0])error();return this[0]==window||this[0]==document?this.width():this.is(':visible')?this[0].offsetWidth-num(this,'borderLeftWidth')-num(this,'borderRightWidth'):this.width()+num(this,'paddingLeft')+num(this,'paddingRight');},outerHeight:function(options){if(!this[0])error();options=$.extend({margin:false},options||{});return this[0]==window||this[0]==document?this.height():this.is(':visible')?this[0].offsetHeight+(options.margin?(num(this,'marginTop')+num(this,'marginBottom')):0):this.height()+num(this,'borderTopWidth')+num(this,'borderBottomWidth')+num(this,'paddingTop')+num(this,'paddingBottom')+(options.margin?(num(this,'marginTop')+num(this,'marginBottom')):0);},outerWidth:function(options){if(!this[0])error();options=$.extend({margin:false},options||{});return this[0]==window||this[0]==document?this.width():this.is(':visible')?this[0].offsetWidth+(options.margin?(num(this,'marginLeft')+num(this,'marginRight')):0):this.width()+num(this,'borderLeftWidth')+num(this,'borderRightWidth')+num(this,'paddingLeft')+num(this,'paddingRight')+(options.margin?(num(this,'marginLeft')+num(this,'marginRight')):0);},scrollLeft:function(val){if(!this[0])error();if(val!=undefined)return this.each(function(){if(this==window||this==document)window.scrollTo(val,$(window).scrollTop());else
this.scrollLeft=val;});if(this[0]==window||this[0]==document)return self.pageXOffset||$.boxModel&&document.documentElement.scrollLeft||document.body.scrollLeft;return this[0].scrollLeft;},scrollTop:function(val){if(!this[0])error();if(val!=undefined)return this.each(function(){if(this==window||this==document)window.scrollTo($(window).scrollLeft(),val);else
this.scrollTop=val;});if(this[0]==window||this[0]==document)return self.pageYOffset||$.boxModel&&document.documentElement.scrollTop||document.body.scrollTop;return this[0].scrollTop;},position:function(returnObject){return this.offset({margin:false,scroll:false,relativeTo:this.offsetParent()},returnObject);},offset:function(options,returnObject){if(!this[0])error();var x=0,y=0,sl=0,st=0,elem=this[0],parent=this[0],op,parPos,elemPos=$.css(elem,'position'),mo=$.browser.mozilla,ie=$.browser.msie,oa=$.browser.opera,sf=$.browser.safari,sf3=$.browser.safari&&parseInt($.browser.version)>520,absparent=false,relparent=false,options=$.extend({margin:true,border:false,padding:false,scroll:true,lite:false,relativeTo:document.body},options||{});if(options.lite)return this.offsetLite(options,returnObject);if(options.relativeTo.jquery)options.relativeTo=options.relativeTo[0];if(elem.tagName=='BODY'){x=elem.offsetLeft;y=elem.offsetTop;if(mo){x+=num(elem,'marginLeft')+(num(elem,'borderLeftWidth')*2);y+=num(elem,'marginTop')+(num(elem,'borderTopWidth')*2);}else
if(oa){x+=num(elem,'marginLeft');y+=num(elem,'marginTop');}else
if((ie&&jQuery.boxModel)){x+=num(elem,'borderLeftWidth');y+=num(elem,'borderTopWidth');}else
if(sf3){x+=num(elem,'marginLeft')+num(elem,'borderLeftWidth');y+=num(elem,'marginTop')+num(elem,'borderTopWidth');}}else{do{parPos=$.css(parent,'position');x+=parent.offsetLeft;y+=parent.offsetTop;if((mo&&!parent.tagName.match(/^t[d|h]$/i))||ie||sf3){x+=num(parent,'borderLeftWidth');y+=num(parent,'borderTopWidth');if(mo&&parPos=='absolute')absparent=true;if(ie&&parPos=='relative')relparent=true;}op=parent.offsetParent||document.body;if(options.scroll||mo){do{if(options.scroll){sl+=parent.scrollLeft;st+=parent.scrollTop;}if(oa&&($.css(parent,'display')||'').match(/table-row|inline/)){sl=sl-((parent.scrollLeft==parent.offsetLeft)?parent.scrollLeft:0);st=st-((parent.scrollTop==parent.offsetTop)?parent.scrollTop:0);}if(mo&&parent!=elem&&$.css(parent,'overflow')!='visible'){x+=num(parent,'borderLeftWidth');y+=num(parent,'borderTopWidth');}parent=parent.parentNode;}while(parent!=op);}parent=op;if(parent==options.relativeTo&&!(parent.tagName=='BODY'||parent.tagName=='HTML')){if(mo&&parent!=elem&&$.css(parent,'overflow')!='visible'){x+=num(parent,'borderLeftWidth');y+=num(parent,'borderTopWidth');}if(((sf&&!sf3)||oa)&&parPos!='static'){x-=num(op,'borderLeftWidth');y-=num(op,'borderTopWidth');}break;}if(parent.tagName=='BODY'||parent.tagName=='HTML'){if(((sf&&!sf3)||(ie&&$.boxModel))&&elemPos!='absolute'&&elemPos!='fixed'){x+=num(parent,'marginLeft');y+=num(parent,'marginTop');}if(sf3||(mo&&!absparent&&elemPos!='fixed')||(ie&&elemPos=='static'&&!relparent)){x+=num(parent,'borderLeftWidth');y+=num(parent,'borderTopWidth');}break;}}while(parent);}var returnValue=handleOffsetReturn(elem,options,x,y,sl,st);if(returnObject){$.extend(returnObject,returnValue);return this;}else{return returnValue;}},offsetLite:function(options,returnObject){if(!this[0])error();var x=0,y=0,sl=0,st=0,parent=this[0],offsetParent,options=$.extend({margin:true,border:false,padding:false,scroll:true,relativeTo:document.body},options||{});if(options.relativeTo.jquery)options.relativeTo=options.relativeTo[0];do{x+=parent.offsetLeft;y+=parent.offsetTop;offsetParent=parent.offsetParent||document.body;if(options.scroll){do{sl+=parent.scrollLeft;st+=parent.scrollTop;parent=parent.parentNode;}while(parent!=offsetParent);}parent=offsetParent;}while(parent&&parent.tagName!='BODY'&&parent.tagName!='HTML'&&parent!=options.relativeTo);var returnValue=handleOffsetReturn(this[0],options,x,y,sl,st);if(returnObject){$.extend(returnObject,returnValue);return this;}else{return returnValue;}},offsetParent:function(){if(!this[0])error();var offsetParent=this[0].offsetParent;while(offsetParent&&(offsetParent.tagName!='BODY'&&$.css(offsetParent,'position')=='static'))offsetParent=offsetParent.offsetParent;return $(offsetParent);}});var error=function(){throw"Dimensions: jQuery collection is empty";};var num=function(el,prop){return parseInt($.css(el.jquery?el[0]:el,prop))||0;};var handleOffsetReturn=function(elem,options,x,y,sl,st){if(!options.margin){x-=num(elem,'marginLeft');y-=num(elem,'marginTop');}if(options.border&&(($.browser.safari&&parseInt($.browser.version)<520)||$.browser.opera)){x+=num(elem,'borderLeftWidth');y+=num(elem,'borderTopWidth');}else if(!options.border&&!(($.browser.safari&&parseInt($.browser.version)<520)||$.browser.opera)){x-=num(elem,'borderLeftWidth');y-=num(elem,'borderTopWidth');}if(options.padding){x+=num(elem,'paddingLeft');y+=num(elem,'paddingTop');}if(options.scroll&&(!$.browser.opera||elem.offsetLeft!=elem.scrollLeft&&elem.offsetTop!=elem.scrollLeft)){sl-=elem.scrollLeft;st-=elem.scrollTop;}return options.scroll?{top:y-st,left:x-sl,scrollTop:st,scrollLeft:sl}:{top:y,left:x};};var scrollbarWidth=0;var getScrollbarWidth=function(){if(!scrollbarWidth){var testEl=$('<div>').css({width:100,height:100,overflow:'auto',position:'absolute',top:-1000,left:-1000}).appendTo('body');scrollbarWidth=100-testEl.append('<div>').find('div').css({width:'100%',height:200}).width();testEl.remove();}return scrollbarWidth;};})(jQuery);



/*
 * Tooltip - jQuery plugin  for styled tooltips
 *
 * Copyright (c) 2006 J???rn Zaefferer, Stefan Petre
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Display a customized tooltip instead of the default one
 * for every selected element. The tooltip behaviour mimics
 * the default one, but lets you style the tooltip and
 * specify the delay before displaying it.
 *
 * In addition, it displays the href value, if it is available.
 *
 * To style the tooltip, use these selectors in your stylesheet:
 *
 * #tooltip - The tooltip container
 *
 * #tooltip h3 - The tooltip title
 *
 * #tooltip p.body - The tooltip body, shown when using showBody
 *
 * #tooltip p.url - The tooltip url, shown when using showURL
 *
 * @example $('a, input, img').Tooltip();
 * @desc Shows tooltips for anchors, inputs and images, if they have a title
 *
 * @example $('label').Tooltip({
 *   delay: 0,
 *   track: true,
 *   event: "click"
 * });
 * @desc Shows tooltips for labels with no delay, tracking mousemovement, displaying the tooltip when the label is clicked.
 *
 * @example // modify global settings
 * $.extend($.fn.Tooltip.defaults, {
 * 	track: true,
 * 	delay: 0,
 * 	showURL: false,
 * 	showBody: " - ",
 *  fixPNG: true
 * });
 * // setup fancy tooltips
 * $('a.pretty').Tooltip({
 * 	 extraClass: "fancy"
 * });
 $('img.pretty').Tooltip({
 * 	 extraClass: "fancy-img",
 * });
 * @desc This example starts with modifying the global settings, applying them to all following Tooltips; Afterwards, Tooltips for anchors with class pretty are created with an extra class for the Tooltip: "fancy" for anchors, "fancy-img" for images
 *
 * @param Object settings (optional) Customize your Tooltips
 * @option Number delay The number of milliseconds before a tooltip is display, default is 250
 * @option String event The event on which the tooltip is displayed, default is "mouseover", "click" works fine, too
 * @option Boolean track If true, let the tooltip track the mousemovement, default is false
 * @option Boolean showURL If true, shows the href or src attribute within p.url, default is true
 * @option String showBody If specified, uses the String to split the title, displaying the first part in the h3 tag, all following in the p.body tag, separated with <br/>s, default is null
 * @option String extraClass If specified, adds the class to the tooltip helper, default is null
 * @option Boolean fixPNG If true, fixes transparent PNGs in IE, default is false
 *
 * @name Tooltip
 * @type jQuery
 * @cat Plugins/Tooltip
 * @author J???rn Zaefferer (http://bassistance.de)
 */
(function($) {
	// the tooltip element
	var helper,
		// it's title part
		tTitle,
		// it's body part
		tBody,
		// it's url part
		tUrl,
		// the current tooltipped element
		current,
		// the title of the current element, used for restoring
		oldTitle,
		// timeout id for delayed tooltips
		tID;

	// the public plugin method
	$.fn.Tooltip = function(settings) {
		// setup configuration
		settings = $.extend({}, arguments.callee.defaults, settings);

		// there can be only one tooltip helper
		if( !helper ) {
			// create the helper, h3 for title, div for url
			helper = $('<div id="tooltip"><span><h3></h3><div id="tooltip-icon"></div><p class="body"></p><p class="url"></p></span></div>')
				// hide it at first
				.hide()
				// move to top and position absolute, to let it follow the mouse
				// Temp display: 'block',  
				.css({ display: 'none', position: 'absolute', zIndex: "3000" })
				// add to document
				.appendTo('body');

			// save references to title and url elements
			tTitle = $('h3', helper);
			tBody = $('p.body', helper);
			tUrl = $('p.url', helper);
		}

		// bind events for every selected element with a title attribute
		$(this).filter('[@title]')
			// save settings into each element
			.each(function() {
				this.tSettings = settings;
			})
			// bind events
			.bind("mouseover", save)
            .bind("focus", save)
            .bind("focus", handle)
			.bind(settings.event, handle);
		return this;
	};

	// main event handler to start showing tooltips
	function handle(event) {
		// show helper, either with timeout or on instant
		if( this.tSettings.delay )
			tID = setTimeout(show, this.tSettings.delay);
		else
			show();

		// if selected, update the helper position when the mouse moves
		if(this.tSettings.track)
			$('body').bind('mousemove', update);

		// update at least once
		update(event);

		// hide the helper when the mouse moves out of the element
		$(this).bind('mouseout', hide);
        $(this).bind('blur', hide);
	}

	// save elements title before the tooltip is displayed
	function save() {
		// if this is the current source, or it has no title (occurs with click event), stop
		if(this == current || !this.title)
			return;
		// save current
		current = this;
		var source = $(this),
			settings = this.tSettings;

		// save title, remove from element and set to helper
		var title = oldTitle = source.attr('title');
		source.attr('title','');
		if(settings.showBody) {
			var parts = title.split(settings.showBody);
			tTitle.html(parts.shift());
			tBody.empty();
			for(var i = 0, part; part = parts[i]; i++) {
				if(i > 0)
					tBody.append("<br/>");
				tBody.append(part);
			}
			if(tBody.html())
				tBody.show();
			else
				tBody.hide();
		} else {
			tTitle.html(title);
			tBody.hide();
		}

		// if element has href or src, add and show it, otherwise hide it
		var href = (source.attr('href') || source.attr('src'));
		if( settings.showURL && href )
			tUrl.html(href.replace('http://', '')).show();
		else
			tUrl.hide();

		// add an optional class for this tip
		if( settings.extraClass ) {
			helper.addClass(settings.extraClass);
		}
		// fix PNG background for IE
		if (settings.fixPNG && $.browser.msie ) {
			helper.each(function () {
				if (this.currentStyle.backgroundImage != 'none') {
					var image = this.currentStyle.backgroundImage;
					image = image.substring(5, image.length - 2);
					$(this).css({
						'backgroundImage': 'none',
						'filter': "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=crop, src='" + image + "')"
					});
				}
			});
		}
	}

	// delete timeout and show helper
	function show() {
		tID = null;
		helper.show();
		update();
	}

	/**
	 * callback for mousemove
	 * updates the helper position
	 * removes itself when no current element
	 */
	function update(event)	{
		// if no current element is available, remove this listener
		if( current == null ) {
			$('body').unbind('mousemove', update);
			return;
		}

		var left = helper[0].offsetLeft;
		var top = helper[0].offsetTop;
		if(event) {
			/* start: 3867 */
			var $eTarget = $(event.target);
			var evTarget = $eTarget.get(0);
			if (evTarget) {
				var image = null;
				if (evTarget.nodeName.toLowerCase() == 'a') {
					image = $eTarget.children('img').get(0);
				} else 
				if (evTarget.nodeName.toLowerCase() == 'img') {
					image = evTarget;
				}
				if (image) {
					var regexp = /^.*\/([^/]+)\.[^.]+$/;
					regexp.exec(image.src);
					var className = RegExp.$1;
					if (className) {
						$('#tooltip-icon').attr('class', className);
					}
				}
				/* end: 3867 */
				
				var offset = $(event.target).offset();

				// position the helper to top left of target element
	            left = offset.left - 120;
				
				top  = offset.top - $(helper).height() - 30;
				
				// place the helper to the left if exceeds the viewport
				var vp = viewport();
				if ((left + helper[0].offsetWidth) > (vp.x + vp.cx)) {
					helper.addClass('tooltip-r');
					left -= (helper[0].offsetWidth - 4);
				} else {
					helper.removeClass('tooltip-r');
				}	
				helper.css({
					left: left + 'px',
					top: top + 'px'
				});
			}
		}
	}
	
	function viewport() {
		var e = document.documentElement || {},
			b = document.body || {},
			w = window;
		function min() {
			var v = Infinity;
			for( var i = 0;  i < arguments.length;  i++ ) {
				var n = arguments[i];
				if( n && n < v ) v = n;
			}
			return v;
		}
		return {
			x: w.pageXOffset || e.scrollLeft || b.scrollLeft || 0,
			y: w.pageYOffset || e.scrollTop || b.scrollTop || 0,
			cx: min( e.clientWidth, b.clientWidth, w.innerWidth ),
			cy: min( e.clientHeight, b.clientHeight, w.innerHeight )
		};
	}

	// hide helper and restore added classes and the title
	function hide() {
		// clear timeout if possible
		if(tID)
			clearTimeout(tID);
		// no more current element
		current = null;
		helper.hide();
		// remove optional class
		if( this.tSettings.extraClass ) {
			helper.removeClass( this.tSettings.extraClass);
		}

		// restore title and remove this listener
		$(this)
			.attr('title', oldTitle)
			.unbind('mouseout', hide);

		// remove PNG background fix for IE
		if( this.tSettings.fixPNG && $.browser.msie ) {
			helper.each(function () {
				$(this).css({'filter': '', backgroundImage: ''});
			});
		}
	}

	// define global defaults, editable by client
	$.fn.Tooltip.defaults = {
		delay: 250,
		event: "mouseover",
		track: false,
		showURL: false,
		showBody: null,
		extraClass: null,
		fixPNG: false
	};

})(jQuery);
/**
 * @author alexander.farkas
 */
(function($) {
	$.extend({
         getIDformAnker: function($elm){
             var id = $elm.attr('href');
             var fund = id.indexOf('#');
             id = (fund != -1) ? id.substr(fund) : false;
             return id;
         }
    });
    $.fn.extend({
		uaagChange: function(func) {
			function reset(s,val){
				s.activeIndex = val;
			}
			return this.each(function(){
				var s = $(this);
				
				if(!s[0].activeIndex){
					s[0].activeIndex = s[0].selectedIndex;
				}
	            s[0].altPressed = 0;
				s.keydown(function(e){
					var keyCodeTab = "9";
					var keyCodeEnter = "13";
					var keyAlt = "18";
					var keyCodeEsc = "27";
					if(e.keyCode == keyCodeTab || e.keyCode == keyCodeEnter){
	                    func.apply(this,[this.selectedIndex]);
					}else if(e.keyCode == keyCodeEsc && this.altPressed != 1){
						this.selectedIndex = this.activeIndex;
	                    s.altPressed = 0;
					}else if(e.keyCode == keyAlt){
						this.altPressed = 1;
					}	
				});
	            s.change(function(e){
					if(this.altPressed && this.selectedIndex != this.activeIndex){
						func.apply(this,[this.selectedIndex]);
						reset(this,this.selectedIndex);
					}
						
	            });
				s.blur(function(e){
					if(this.selectedIndex != this.activeIndex){
						func.apply(this,[this.selectedIndex]);
						reset(this,this.selectedIndex);
					}
					this.altPressed = 0;
				});
				s.click(function(){
					if(this.selectedIndex != this.activeIndex){
						func.apply(this,[this.selectedIndex]);
						reset(this,this.selectedIndex);
					}
				});
				
			});
			
		},
		clearFillInput: function(s) {
			s = $.extend({
                    focusAttr: {},
    				blurAttr: {}
	            }, s);
			return this.each(function(){
                var $this = $(this);
                $.data(this,'cfiVal',$this.val());
                $this.focus(function(){
                    if($(this).val() == $.data(this,'cfiVal')){
						$(this).val('').attr(s.focusAttr);
					}
						
				}).blur(function(){
					var test = $(this).val();
					if(test == $.data(this,'cfiVal') || test == '')
						$(this).attr(s.blurAttr).val($.data(this,'cfiVal'));
				});
			});
		},
		createLinkButton: function(s) {
			s = $.extend({
                    hiddenClass: 'aural',
    				focusClass: 'focused'
	            }, s);
			return this.each(function(){
                var $this =  $(this);
				var id = $this.attr('id');
				var $label = $('label[for='+id+']:first');
				var labelVal = $label.html();
				var classnames = this.className;
				$label.html('<span><span><span><span>'+labelVal+'</span></span></span></span>');
				if($this.is('[type=radio]')) {
					$this.addClass(s.hiddenClass).focus(function(){
						$label.addClass(s.focusClass);
					}).blur(function(){
						$label.removeClass(s.focusClass);
					});
					$label.click(function(){
                        var $this = $(this);
						var iID = $this.attr('for');
						$('#'+iID).attr({checked: 'checked'});
						$(this).parents('form:first').trigger('submit');
                        return false;
					}).addClass(classnames);
				} else {
					var val = $this.val();
	                var link = $this.after('<a href="#" class="'+classnames+'"><span><span><span><span>'+val+'</span></span></span></span></a>').next('a');
					$this.remove();
					link.click(function(){
                        $(this).parents('form:first').trigger('submit');
                        return false;
					});
				}
                    
			});
		},
        heightOpacToggle: function(s){
            s = s || {};
            return this.each(function(){
                $(this).animate({
                    height: 'toggle',
                    opacity: 'toggle'
                },s)
            });
        },
		tab: function(s) {
			s = $.extend({
		        activeClass: 'on',
				controls: null,
                animationToggle: false
	        }, s);
            
            return this.each(function(){
                 var $this = $(this);
                 var curBlock = $($.getIDformAnker($this));
                 if(!$this.is('.'+s.activeClass)) {
                     curBlock.css({display: 'none'});
                 }
                 curBlock.attr({tabindex: '-1'}).css({outline: 'none'});
                 $this.bind('click.aperto', function(){
                     var curActive = $(s.controls+'.'+s.activeClass).removeClass(s.activeClass);
                     var $this = $(this);
                     
                     $this.addClass(s.activeClass);
                     var curID = $.getIDformAnker(curActive);
                     var newID = $.getIDformAnker($this);
                     if(curID != newID){
                         var curActiveBlock = $(curID);
                         var toActivateBlock = $(newID);
                         if(!s.animationToggle){
                             curActiveBlock.css({display: 'none'});
                             toActivateBlock.css({display: 'block'}).focus();
                         } else {
                             curActiveBlock[s.animationToggle](function(){
								 toActivateBlock[s.animationToggle](function(){
                                      this.focus();
                                 });
                             }); 
                             
                         }
                      }
                     return false;
                 });
			});
		},
        expandClickArea : function(settings) {
		    settings = $.extend({
		        refSource: 'a:first',
				refAttach: false,
				hoverClass:false//notAdded 2DO
		    }, settings || {});
			return this.each(function(){
				var teaseOBJ = (!settings.refAttach)?this:$(this).find(settings.refAttach);
				$(teaseOBJ).css('cursor','pointer').click(function(e){
					var $refSource = $(this).find(settings.refSource);
                    
                    if(e.target != $refSource.get(0) && $(e.target).parents(settings.refSource).get(0) != $refSource.get(0)) {
                        if($refSource.is('a'))
                            window.location = $refSource.attr('href');
                    } 
				});
			});
		},
        carousel : function(s) {
		    s = $.extend({
		        nextB: 'div.next',
                prevB: 'div.prev',
				atomDim: false,
				hoverClass:false//notAdded 2DO
		    }, s);
			return this.each(function(){
				var atom = $('li',this);
                $(this).parents('div.punkte-box-inner').find('ul li:first').addClass('active')
				atom.each(function(i){
                   
				   $(this).click(function(){
                       $(this).parents('div:first').find('li.on').removeClass('on').end().end().addClass('on');
                       var height = ($.browser.msie)? 142 : 140;
                       var top = i * height * -1;
					   var bigCarousel = $(this).parents('div.punkte-box-inner').find('ul:first');
					   bigCarousel.find('li:eq('+i+'),li.active').animate({
                           opacity: 'toggle'
                       },function(){
							$(this).toggleClass('active');
						});
                       
                   }).hover(function(){
                     $(this).addClass('over');
                   },function(){
                     $(this).removeClass('over');
                   });
                });
                var motionArea = $('ul',this);
                var moAWidth = atom.size()* s.atomDim;
               
                
                motionArea.css({width: moAWidth});//
                
                motionArea.clone(true).insertAfter(motionArea).css({left: moAWidth});
                motionArea.clone(true).insertBefore(motionArea).css({left: moAWidth*-1});
                motionArea = $('ul',this);
                
                var speedMode = s.atomDim * 3;
                var mousedown = false;
                var checkedAreas = 0;
                function animCallback(){
                    
                    var $this = $(this);
                    
                    var leftPos = parseInt($.curCSS(this,'left'));
                    if(leftPos < (moAWidth * -1)){
                        var newLeft = (moAWidth * 3) - (leftPos * -1);
                        $this.css({left: newLeft});
                        
                    } else if(leftPos > moAWidth) {
                        var newLeft = leftPos - (moAWidth * 3);
                        $this.css({left: newLeft});
                    }
                    
                    checkedAreas++;
                    if(mousedown && checkedAreas == 3) {
                        checkedAreas = 0;
                        motionArea.animate({
                           left: mousedown+'='+speedMode
                        },animCallback);
                        checkedAreas = 0;
                    }
                }
                $(s.nextB,this).mousedown(function(){
                    mousedown = '-';
                    checkedAreas = 0;                    
                    motionArea.animate({
                       left: '-='+s.atomDim
                    },animCallback);
                }).mouseup(function(){
                    mousedown = false;
                });
                
                $(s.prevB,this).mousedown(function(){
                    mousedown = '+';
                    checkedAreas = 0;
                    motionArea.animate({
                       left: '+='+s.atomDim
                    },animCallback);
                }).mouseup(function(){
                    mousedown = false;
                });
			});
		},
		checkBox: function(s) {
            s = $.extend({
		        checkedClass: 'checked',
				focusClass: 'focused',
				cBubble: true,
                hiddenClass: 'aural'
            }, s);
			return this.each(function(){
                var $this = $(this);
                $this.addClass(s.hiddenClass);
                var id = $this.attr('id');
                var $label = $('label[for='+id+']');
                if($this.is(':checked'))
                    $label.addClass(s.checkedClass);
                $label.bind('click.checkBox', function(){
					var $curLabel = $(this);
                    $curLabel.toggleClass(s.checkedClass);
                    ($curLabel.is('.'+s.checkedClass))?
                        $('#'+id).attr({checked: 'checked'})
                    :
                        $('#'+id).attr({checked:''});
                     return false;
                });
                
                $this.bind('click.checkBox', function(e){
                    
					($this.is(':checked'))? 
                        $('label[for='+id+']').addClass(s.checkedClass)
                    :
                        $('label[for='+id+']').removeClass(s.checkedClass);
                    e.stopPropagation();
					
                }).bind('focus.checkBox', function(){
                    $('label[for='+id+']').addClass(s.focusClass);
                }).bind('blur.checkBox', function(){
                    $('label[for='+id+']').removeClass(s.focusClass);
                });
                
			});
		},
		accordion: function(){
			return this.each(function(){
				var accO = this;
				$(this).children('li').children('ul').hide().end(
				).children('a').addClass('collapsed').click(function(){
					var $this = $(this);
					$this.addClass('tmp-processing');
					
					$('a.faq-section').not('.tmp-processing.collapsed').toggleClass('collapsed').parent('li')
					.children('ul').heightOpacToggle();
					
					
					$this.toggleClass('collapsed').removeClass('tmp-processing').parent('li')
					.children('ul').heightOpacToggle();
                    return false;
                });
			});
		},
		openPopup: function(s){
			s = $.extend(s, {
				winHeight: 500,
				winWidth: 560,
                center: true,
				winOptions: 'scrollbars=1'
			});
			return this.each(function(){
				s.winOptions += 'height='+s.winHeight+',width='+s.winWidth;
				if(s.center){
					var yPos = (screen.availHeight-s.winHeight) / 2;
					var xPos  = (screen.availWidth-s.winWidth) / 2;
					s.winOptions += ', left='+xPos+', top='+yPos;
				}
				var $this = $(this);
				$this.bind('click.openPopup',function(){
					var url = $(this).attr('href');
					var win = window.open(url, "newwindow", s.winOptions);
  					win.focus();
					return false;
				});

			});
		},
		radioActive: function(){
			return this.each(function(){
				var accO = this;
				var $inputs = $('input[type=radio]',accO);

				$inputs.each(function(){

					var divC = $(this).bind('click',function(){
						var $this = $(this);
						var radioName = $this.attr('name');
						$('input[name='+radioName+']',accO).parents('td').children('div').removeClass('odd');

						var divContainer = $this.parents('td:first').children('div:first');

						if($this.is(':checked'))
							divContainer.addClass('odd');
						else
							divContainer.removeClass('odd');
					}).parents('td:first').children('div:first');

					if($(this).is(':checked'))
						divC.addClass('odd');
					else
						divC.removeClass('odd');
				});
			});
		}

	});
    function calcInterimResult(active){
		$(this).siblings('span.interim-result:first').html($(this).val());
	}

    $(function() {
		var b = $('body:first').addClass('js-enabeld');
		if(b.is('.popup')){
			$('#main').prepend('<a id="close-popup" href="#">Fenster Schließen</a>').find('#close-popup').click(
				function(){
					window.close();
					return false;
				}
			);
		}	
		$('a[rel=popup]').openPopup();
		if ($.fn.sifr) {
			$('h1,p.subline').sifr({
				strSWF: 'img/swiss.swf',
				strColor: '#6B196B'
			});
		}
        $('#basket-form').radioActive();
		$('#faq').accordion();
        $('#tabs-select a').tab({controls: '#tabs-select a'});
        $('#punkte-box div.control-carousel').carousel({atomDim: 56});
		$('#pin').clearFillInput({focusAttr: {maxlength: '4'},blurAttr: {maxlength: '999'}});
        $('#member-id,#gb_junior,#gb_senior, #pin1, #member-id1, #tt, #mm, #j').clearFillInput();
        $('ul.box-list li').expandClickArea();
        $('input.button').createLinkButton();
		var helpTip = 
        $('span.help').each(function(){
			var $this = $(this);
			var config = ($this.is('.credit-card'))?{extraClass: 'credit-tip', showBody: ": "}: {showBody: ": "};
			$this.Tooltip(config);
		});
        $('#bonus-search input[type=checkbox], #hood input[type=checkbox]').checkBox();
        $('#basket-summary select').uaagChange(calcInterimResult);
		if($.fn.datepicker)
			$('#point-search input[type=text]').datepicker({closeAtTop: false, firstDay: 1, changeFirstDay: false, changeMonth: false, changeYear: false});
		
		(function(){
			$('#product-views a').bind('click', function(){
				var $this = $(this), $href = $this.attr('href');
				var newPic = new Image();
				newPic.src = $href;
				$('#product-showcase img').animate({opacity: 'hide'},{
					complete: function(){
						$('#product-showcase img').remove();
						$('#product-showcase').append(newPic);
					}
				});
				return false;
			});
		})();
		
		
        if($('#betrag-slide-filler').size() && $('#bonus-slide-filler').size()){
            (function(){
                //wir benutzen intern kein jQuery um so schnell wie m�glich Zugriff auf das Objekt zu haben
                var $slideFillerStyle = $('#betrag-slide-filler').get(0).style;
                var maxInput = $('#max-betrag-input').get(0);
                var maxVal = $('#max-betrag-val');
				var maV = maxInput.value;
				$slideFillerStyle.width = (parseInt(maV)*1.9)+18+'px';
				maxVal.html(parseInt(maV)+' &euro;');
                function onslide(ui,e){
                    maxVal.html(e.value+' &euro;');
                    maxInput.value = e.value;
                    $slideFillerStyle.width = e.pixel+18+'px';
                };
                $('#max-betrag').slider({slide: onslide, stepping: 20, startValue: parseInt(maxInput.value)});
            })();
            (function(){
                var $slideFillerStyle = $('#bonus-slide-filler').get(0).style;
                
                var minPunkte = $('#von-punkte').get(0);
                var maxPunkte = $('#bis-punkte').get(0);
                
                var minVal = $('#min-punkte-val');
                var maxVal = $('#max-punkte-val');
				
				var miV = minPunkte.value || 0;
				var maV = maxPunkte.value || 0;
				
				minVal.html(''+miV);
				maxVal.html(''+maV);
				var cSVal = [parseInt(miV),parseInt(maV)];
				var abstand = (cSVal[1] - cSVal[0])/31.75;
				var pos = cSVal[0]/31.75;
				$slideFillerStyle.width = abstand+10+'px';
				$slideFillerStyle.left = pos+7+'px';
			   
                function onslide(ui,e){
                   var $handle = $(e.handle),curVal = parseInt(e.value),abstand;		
				   if($handle.is('.left-indicator')){
                       minPunkte.value = curVal;
                       minVal.html(''+curVal);
                       abstand = parseFloat($('.right-indicator', this).css('left'))-e.pixel+10;
                       $slideFillerStyle.width = abstand+'px';
                       $slideFillerStyle.left = e.pixel+7+'px';
                   } else {
                       maxPunkte.value = curVal;
                       maxVal.html(''+curVal);
                       var leftVal = parseFloat($('.left-indicator', this).css('left'));
                       abstand = e.pixel+10-leftVal;
                       $slideFillerStyle.width = abstand+'px';
                       $slideFillerStyle.left = leftVal+7+'px';
                   }
                };
				
                $('#bonus-slider').slider({slide: onslide, stepping: 200, maxValue: 6000, startValue: cSVal});
            })();
        }
		
		var $sms = $('#sms');
		var $mobile = $('#mobile-wrapper');
		if($sms.size() && $mobile.size()){
			if(!$(this).is(':checked'))
				$mobile.css({display: 'none'});
			$sms.click(function(){
				$(this).is(':checked')?$mobile.animate({opacity:'show', height: 'show'}):$mobile.animate({opacity:'hide', height: 'hide'});
			});
		}

    });
	
})(jQuery);


