// open link
(function($){
	$.fn.extend({
		openlink: function() {
			this.each(function () {
				$(this).bind("click", function () {
										
					var destinationURL = "";
					var target = "";
					
					if(this.href) {
						destinationURL = this.href;
						target = this.getAttribute("target");
					}
					else {
						if(this.childNodes) {
							if(this.getElementsByTagName("a")) {
								destinationURL = this.getElementsByTagName("a")[0].href;
								target = this.getElementsByTagName("a")[0].getAttribute("target");
							}
						}
					}
										
					if(destinationURL.length > 0) {
						if(target == "_blank") {
							window.open(destinationURL);
						}
						else {
							location.href = destinationURL;
						}
					}
					return false;
				});
			});
		}
	});
})(jQuery);



/* jQuery CooQuery Plugin v2 (minified) - http://cooquery.lenonmarcel.com.br/
Copyright 2009, 2010 Lenon Marcel
Dual licensed under the MIT and GPL licenses.
http://www.opensource.org/licenses/mit-license.php
http://www.gnu.org/licenses/gpl.html */
(function($){$.setCookie=function(name,value,options){if(typeof name==='undefined'||typeof value==='undefined')
return false;var str=name+'='+encodeURIComponent(value);if(options.domain)str+='; domain='+options.domain;if(options.path)str+='; path='+options.path;if(options.duration){var date=new Date();date.setTime(date.getTime()+options.duration*24*60*60*1000);str+='; expires='+date.toGMTString();}
if(options.secure)str+='; secure';return document.cookie=str;};$.delCookie=function(name){return $.setCookie(name,'',{duration:-1});};$.readCookie=function(name){var value=document.cookie.match('(?:^|;)\\s*'+name.replace(/([-.*+?^${}()|[\]\/\\])/g,'\\$1')+'=([^;]*)');return(value)?decodeURIComponent(value[1]):null;};$.CooQueryVersion='v 2.0';})(jQuery);




/**
 * Liquid Canvas jQuery Plugin 
 * 
 * Version 0.3
 *
 * Steffen Rusitschka  http://www.ruzee.com  MIT licensed
 */
(function($) {
  var canvasElements = [];
  var pollCounter = 0;
  var plugins = {};

  function Area(canvas) {
    var stack = [];
    
    $.extend(this, {
      width: canvas.width, height: canvas.height, ctx: canvas.getContext("2d"),
      
      save: function() {
        this.ctx.save();
        stack.push({ width: this.width, height: this.height });
      },
      
      restore: function() {
        this.ctx.restore();
        $.extend(this, stack.pop());
      }
    });
  }
  
  var Plugin = (function() {
    var shrink = function(area, steps) {
      area.ctx.translate(steps, steps);
      area.width -= 2 * steps;
      area.height -= 2 * steps;
    };
    return {
      action:{ paint:function(){} },  // provide a NOP "plugin"
      shrink: shrink,
      defaultShrink: shrink,
      setAction: function(action) { this.action = action; }
    };
  })();
  
  function newPlugin(hash, opts) {
    return $.extend({}, Plugin, hash, { opts: opts, savedOpts: opts });
  }
  
  function pluginFromPlugins(plugins) {
    return newPlugin({
      paint: function(area) {
        area.save();
        this.action.opts = $.extend(true, this.action.savedOpts);
        $.each(plugins, function() { this.paint(area); });
        area.restore();
      },
      
      setAction: function(action) {
        this.action = action; // should call super if it existed ...
        $.each(plugins, function() { this.action = action; });
      }
    });
  }
  var pluginFromApplications = pluginFromPlugins; // it just does the same ...
  
  function pluginFromName(name, opts) {
    var plugin = plugins[name];
    if (!plugin) throw "Unknown plugin: " + name;
    opts = $.extend({}, plugin.defaultOpts || {}, opts);
    return newPlugin(plugin, opts);
  }
  
  function parse(s) {
    s += " ";
    var index = 0;
    
    function err(m) { msg = m + " at " + index + ": ..." + s.substring(index) + "\nin " + s; alert(msg); throw msg; }
    function cur() { return s.charAt(index); }
    function next() { if (index > s.length) throw("Unexpected end"); return s.charAt(index + 1) }
    function eat() { return s.charAt(index++); }
    function skipWhite() { while (/\s/.exec(cur())) eat(); }
    function check(c) {
      skipWhite(); 
      for (var i=0; i<c.length; ++i) {
        if (cur() != c.charAt(i)) err("Expected '" + c.charAt(i) + "' found '" + cur() + "'"); 
        eat();
      }
    }

    //var parseApplications; // forward reference
    
    function parseWord() {
      skipWhite();
      for (var word = []; /\w/.exec(cur()); word.push(eat()));
      return word.join("");
    }
    
    function parseNumber() {
      skipWhite();
      for (var n = []; /\d/.exec(cur()); n.push(eat()));
      return parseInt(n.join(""));
    }
    
    function parseString() {
      skipWhite();
      var s = [], start = cur();
      if (/[^\'\"]/.exec(start)) { err("String expected") }
      eat();
      while (cur() != start) { if (cur() == "\\") s.eat(); s.push(eat()); }
      check(start);
      return s.join("");
    }
    
    // Yeah, strange thing - this does the CSS value like parsing
    function parseValue() {
      skipWhite();
      for (var s = []; /[^;}]/.exec(cur()); s.push(eat()));
      return s.join("");
    }
    
    function parseLiteral() {
      skipWhite();
      if (/\d/.exec(cur())) return parseNumber();
      if (/['"]/.exec(cur())) return parseString();
      return parseValue();
    }
    
    function parseOpts() {
      check("{");
      skipWhite();
      var opts = {};
      while (cur() != "}") {
        var key = parseWord();
        check(":");
        opts[key] = parseLiteral();
        skipWhite();
        if (cur() == "}") break;
        check(";");
      }
      check("}");
      return opts;
    }
    
    function parsePlugin() {
      var name = parseWord();


      skipWhite();
      opts = cur() == "{" ? parseOpts() : {};
      return pluginFromName(name, opts);
    }
    
    function parsePlugins() {
      check("[");
      skipWhite();
      var plugins = [];
      while (cur() != "]") {
        plugins.push(parsePlugin());
        skipWhite();
      }
      check("]");
      return pluginFromPlugins(plugins);
    }

    function parseActors() {
      skipWhite();
      return cur() == "[" ? parsePlugins() : parsePlugin();
    }
    
    function parseAction() {
      var action;
      skipWhite();
      if (cur() == "(") {
        eat();
        action = parseApplications();
        check(")");
      } else {
        action = parsePlugin();
      }
      return action;
    }
    
    function parseApplication() {
      var actors = parseActors();
      check("=>");
      var action = parseAction();
      actors.setAction(action);
      return actors;
    }
    
    function parseApplications() {
      var applications = [];
      while (true) {
        applications.push(parseApplication());
        skipWhite();
        if (cur() != ",") break;
        check(",");
      }
      return pluginFromApplications(applications);
    }
    
    return parseApplications();
  }

  function checkResize(container, force) {
    var $container = $(container);
    var data = $container.data('liquid-canvas');
    if (!data) return;
    var canvas = data.canvas;
    var $canvas = $(canvas);
    var w = $container.outerWidth();
    var h = $container.outerHeight();
    
    if (force || 
        canvas.width != w || canvas.height != h ||
        canvas.offsetTop != container.offsetTop || canvas.offsetLeft != container.offsetLeft) {
      pollCounter = 100;
      $canvas.css({ left: container.offsetLeft + "px", top: container.offsetTop + "px" });
      canvas.width = w;
      canvas.height = h;
      var area = new Area(canvas);
      area.save();
      data.paint(area);
      area.restore();
    }
  }

  function checkAllResize(force) {
    $.each(canvasElements, function() { checkResize(this, force); });
  }

  function poll(){
    checkAllResize();
    pollCounter--;
    if (pollCounter < 0) {
      pollCounter = 0;
      setTimeout(poll, 1000);
    } else {
      setTimeout(poll, 1000 / 60);
    }
  }

  jQuery.fn.extend({
    liquidCanvas: function(func) {
      this.each(function() {
        var canvas;
        if (window.G_vmlCanvasManager) {
          $(this).before('<div width="0" height="0" style="position:absolute; top:0px; left:0px;"></div>');
          canvas = G_vmlCanvasManager.initElement($(this).prev("div").get(0));
        } else {
          $(this).before('<canvas width="0" height="0" style="position:absolute; top:0px; left:0px;"></canvas>');
          canvas = $(this).prev("canvas").get(0);
        }
        
        var paint;
        if ($.isFunction(func)) {
          paint = func;
        } else {
          var plugin = parse(func)
          paint = function(area) { plugin.paint(area); };
        }
        
        $(this).data("liquid-canvas", {
          "canvas": canvas,
          "paint": paint
        });
        
        // MOD start: modified by BR elements.at
        var bgImage = $(this).css("background-image");
        if(bgImage) {
        	bgImage = bgImage.replace(/"/g,"").replace(/url\(|\)$/ig, "");
        	this.setAttribute("background-image-url", bgImage);
        }
        // MOD end
        
        $(this).css({ background: "transparent" });
        
        if ($(this).css("position") != "absolute") $(this).css({ position: "relative" });
		
        canvasElements.push(this);
        checkResize(this, true);
      });
    }
  });
  
  jQuery.extend({
    registerLiquidCanvasPlugin: function(plugin) {
      plugins[plugin.name] = $.extend({}, Plugin, plugin);
    }
  });
  
  $(document).ready(checkAllResize);
  
  // MOD start: modified by BR elements.at
  // disabled polling because of memory & cpu issues
  //poll();  
  
})(jQuery);







// Liquid Canvas Plugins
(function($) {

  $.registerLiquidCanvasPlugin({
    name: "rect",
    paint: function(area) {
      area.ctx.beginPath();
      area.ctx.rect(0, 0, area.width, area.height);
      area.ctx.closePath();
      if (this.action) this.action.paint(area);  // for chaining
    }
  });
  
  $.registerLiquidCanvasPlugin({
    name: "roundedRect",
    defaultOpts: { radius:20 },
    paint: function(area) {
      var ctx = area.ctx;
      var opts = this.opts;
      ctx.beginPath();
      ctx.moveTo(0, opts.radius);
      ctx.lineTo(0, area.height - opts.radius);
      ctx.quadraticCurveTo(0, area.height, opts.radius, area.height);
      ctx.lineTo(area.width - opts.radius, area.height);
      ctx.quadraticCurveTo(area.width, area.height, area.width, area.height - opts.radius);
      ctx.lineTo(area.width, opts.radius);
      ctx.quadraticCurveTo(area.width, 0, area.width - opts.radius, 0);
      ctx.lineTo(opts.radius, 0);
      ctx.quadraticCurveTo(0, 0, 0, opts.radius);
      ctx.closePath();
      if (this.action) this.action.paint(area);  // for chaining
    },
    shrink: function(area, steps) {
      this.defaultShrink(area, steps);
      this.opts.radius -= steps;
    }
  });
  
  $.registerLiquidCanvasPlugin({
	name: "roundedRect_customCorners",
	defaultOpts: { tl: 10, tr: 10, bl:0, br:0 },
	paint: function(area) {
		var ctx = area.ctx;
		var opts = this.opts;
		ctx.beginPath();
		ctx.moveTo(0, opts.tl);
		ctx.lineTo(0, area.height - opts.bl);
		ctx.quadraticCurveTo(0, area.height, opts.bl, area.height);
		ctx.lineTo(area.width - opts.br, area.height);
		ctx.quadraticCurveTo(area.width, area.height, area.width, area.height - opts.br);
		ctx.lineTo(area.width, opts.tr);
		ctx.quadraticCurveTo(area.width, 0, area.width - opts.tr, 0);
		ctx.lineTo(opts.tl, 0);
		ctx.quadraticCurveTo(0, 0, 0, opts.tl);
		ctx.closePath();
		if (this.action) this.action.paint(area); // for chaining
	},
	shrink: function(area, steps) {
		this.defaultShrink(area, steps);
		this.opts.radius -= steps;
	}
  });
  
  // This is a Liquid Canvas Plugin
  $.registerLiquidCanvasPlugin({
    name: "fill",
    paint: function(area) {
		
	  if(this.opts.color) {
	      area.ctx.fillStyle = this.opts.color;
	      this.action.paint(area);
	      area.ctx.fill();
	  }
	  else if (this.opts.image) { // mod start: modfied by BR elements.at
		  
		  if(this.opts.image == "background") {
			  var bgImage = area.ctx.canvas.nextSibling.getAttribute("background-image-url");			  
			  if(bgImage) {
				  this.opts.image = bgImage;
			  }
		  }
		  		  
		  var test = this;
		  var img = new Image();
		  
		  img.onload = function() {
			  var pattern = area.ctx.createPattern( img , "repeat");
			  area.ctx.fillStyle = pattern;
			  area.ctx.fill();
			  test.action.paint(area);
		  }
		  
		  img.src = this.opts.image;	
		  
		  this.action.paint(area);
	  } // mod end
    }
  });

  $.registerLiquidCanvasPlugin({  // hmmmmmmm, no rotation? no width??? ah patterns!
    name: "image",
    defaultOpts: { url:"http://www.ruzee.com/files/liquid-canvas-image.png" },
    paint: function(area) {
      var image = new Image();
      image.src = this.opts.url;
      image.onload = function() { 
        area.ctx.drawImage(this, 0, 0); 
      };
    }
  });

  // This is a Liquid Canvas Plugin
  $.registerLiquidCanvasPlugin({
    name: "gradient",
    defaultOpts: { from: "#fff", to:"#666", height:0 },
    paint: function(area) {
	var grad;
	  if(this.opts.height > 0) {
		grad = area.ctx.createLinearGradient(0, 0, 0, this.opts.height);
	  } else {
      	grad = area.ctx.createLinearGradient(0, 0, 0, area.height);
	  }
	  
      grad.addColorStop(0, this.opts.from);
      grad.addColorStop(1, this.opts.to);
	  	  
      area.ctx.fillStyle = grad;
      this.action.paint(area);
      area.ctx.fill();
    }
  });
  // End of Liquid Canvas Plugin
  
  $.registerLiquidCanvasPlugin({
    name: "shadow",
    defaultOpts: { width:3, color:'#000', shift:2, alpha: 1.0},
    paint: function(area) {
      var sw = this.opts.width;
      
      area.ctx.fillStyle = this.opts.color; 
      area.ctx.globalAlpha = this.opts.alpha / sw;
      for (var s = 0; s < sw; ++s) {
        this.action.paint(area);
        area.ctx.fill();
        this.action.shrink(area, 1);
      }
      area.ctx.globalAlpha = 1;
      area.ctx.translate(0, -this.opts.shift);
    }
  });

  $.registerLiquidCanvasPlugin({
    name: "border",
    defaultOpts: { color:'#8f4', width:3 },
    paint: function(area) {
      var bw = this.opts.width;
      area.ctx.strokeStyle = this.opts.color;
      area.ctx.lineWidth = bw;
      this.action.shrink(area, bw / 2);
      this.action.paint(area);
      area.ctx.stroke();
      this.action.shrink(area, bw / 2);
    }
  });

})(jQuery);










// ColorBox v1.3.6 - a full featured, light-weight, customizable lightbox based on jQuery 1.3
// c) 2009 Jack Moore - www.colorpowered.com - jack@colorpowered.com
// Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
(function ($) {	   
	// Shortcuts (to increase compression)
	var colorbox = 'colorbox',
	hover = 'hover',
	TRUE = true,
	FALSE = false,
	cboxPublic,
	isIE = !$.support.opacity,
	isIE6 = isIE && !window.XMLHttpRequest,

	// Event Strings (to increase compression)
	cbox_open = 'cbox_open',
	cbox_load = 'cbox_load',
	cbox_complete = 'cbox_complete',
	cbox_cleanup = 'cbox_cleanup',
	cbox_closed = 'cbox_closed',
	cbox_resize = 'resize.cbox_resize',

	// Cached jQuery Object Variables
	$overlay,
	$cbox,
	$wrap,
	$content,
	$topBorder,
	$leftBorder,
	$rightBorder,
	$bottomBorder,
	$related,
	$window,
	$loaded,
	$loadingBay,
	$loadingOverlay,
	$loadingGraphic,
	$title,
	$current,
	$slideshow,
	$next,
	$prev,
	$close,

	// Variables for cached values or use across multiple functions
	interfaceHeight,
	interfaceWidth,
	loadedHeight,
	loadedWidth,
	element,
	bookmark,
	index,
	settings,
	open,
	active,
	
	// ColorBox Default Settings.	
	// See http://colorpowered.com/colorbox for details.
	defaults = {
		transition: "elastic",
		speed: 350,
		fadeout: TRUE, // added by BK elements.at
		overlay: TRUE, // added by BK elements.at
		width: FALSE,
		height: FALSE,
		innerWidth: FALSE,
		innerHeight: FALSE,
		initialWidth: "400",
		initialHeight: "400",
		maxWidth: FALSE,
		maxHeight: FALSE,
		scalePhotos: TRUE,
		scrolling: TRUE,
		inline: FALSE,
		html: FALSE,
		iframe: FALSE,
		photo: FALSE,
		href: FALSE,
		title: FALSE,
		rel: FALSE,
		opacity: 0.9,
		preloading: TRUE,
		current: "image {current} of {total}",
		previous: "previous",
		next: "next",
		close: "close",
		open: FALSE,
		overlayClose: TRUE,
		
		slideshow: FALSE,
		slideshowAuto: TRUE,
		slideshowSpeed: 2500,
		slideshowStart: "start slideshow",
		slideshowStop: "stop slideshow",
		
		onOpen: FALSE,
		onLoad: FALSE,
		onComplete: FALSE,
		onCleanup: FALSE,
		onClosed: FALSE
	};
	
	// ****************
	// HELPER FUNCTIONS
	// ****************
		
	// Convert % values to pixels
	function setSize(size, dimension) {
		dimension = dimension === 'x' ? $window.width() : $window.height();//document.documentElement.clientWidth : document.documentElement.clientHeight;
		return (typeof size === 'string') ? Math.round((size.match(/%/) ? (dimension / 100) * parseInt(size, 10) : parseInt(size, 10))) : size;
	}

	// Checks an href to see if it is a photo.
	// There is a force photo option (photo: true) for hrefs that cannot be matched by this regex.
	function isImage(url) {
		url = $.isFunction(url) ? url.call(element) : url;
		return settings.photo || url.match(/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i);
	}
	
	// Assigns functions results to their respective settings.  This allows functions to be used to set ColorBox options.
	function process() {
		for (var i in settings) {
			if ($.isFunction(settings[i]) && i.substring(0, 2) !== 'on') { // checks to make sure the function isn't one of the callbacks, they will be handled at the appropriate time.
			    settings[i] = settings[i].call(element);
			}
		}
		settings.rel = settings.rel || element.rel;
		settings.href = settings.href || element.href;
		settings.title = settings.title || element.title;
	}

	function launch(elem) {
		element = elem;
		
		settings = $(element).data(colorbox);
		
		process(); // Convert functions to their returned values.
		
		if (settings.rel && settings.rel !== 'nofollow') {
			$related = $('.cboxElement').filter(function () {
				var relRelated = $(this).data(colorbox).rel || this.rel;
				return (relRelated === settings.rel);
			});
			
			index = $related.index(element);
			
			// Check direct calls to ColorBox.
			if (index < 0) {
				$related = $related.add(element);
				index = $related.length - 1;

			}
		} else {
			$related = $(element);
			index = 0;
		}
		
		if (!open) {
			open = TRUE;
			
			active = TRUE; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
			
			bookmark = element;
			
			bookmark.blur(); // Remove the focus from the calling element.
			
			// Set Navigation Key Bindings
			$(document).bind("keydown.cbox_close", function (e) {
				if (e.keyCode === 27) {
					e.preventDefault();
					cboxPublic.close();
				}
			}).bind("keydown.cbox_arrows", function (e) {
				if ($related.length > 1) {
					if (e.keyCode === 37) {
						e.preventDefault();
						$prev.click();
					} else if (e.keyCode === 39) {
						e.preventDefault();
						$next.click();
					}
				}
			});
			
			if (settings.overlayClose) {
				$overlay.css({"cursor": "pointer"}).one('click', cboxPublic.close);
			}
			
			$.event.trigger(cbox_open);
			if (settings.onOpen) {
				settings.onOpen.call(element);
			}
			
			// modfied by BK elements.at:
			if(settings.overlay) {
				$overlay.css({"opacity": settings.opacity}).show();
			}
			
			// Opens inital empty ColorBox prior to content being loaded.
			settings.w = setSize(settings.initialWidth, 'x');
			settings.h = setSize(settings.initialHeight, 'y');
			cboxPublic.position(0);
			
			if (isIE6) {
				$window.bind('resize.cboxie6 scroll.cboxie6', function () {
					$overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()});
				}).trigger("scroll.cboxie6");
			}
		}
		
		$current.add($prev).add($next).add($slideshow).add($title).hide();
		
		$close.html(settings.close).show();
		
		cboxPublic.slideshow();
		
		cboxPublic.load();
	}

	// ****************
	// PUBLIC FUNCTIONS
	// Usage format: $.fn.colorbox.close();
	// Usage from within an iframe: parent.$.fn.colorbox.close();
	// ****************
	
	cboxPublic = $.fn.colorbox = function (options, callback) {
		var $this = this;
		
		if (!$this.length) {
			if ($this.selector === '') { // empty selector means a direct call, ie: $.fn.colorbox();
				$this = $('<a/>');
				options.open = TRUE;
			} else { // else the selector didn't match anything, and colorbox should go ahead and return.
				return this;
			}
		}
		
		$this.each(function () {
			var data = $.extend({}, $(this).data(colorbox) ? $(this).data(colorbox) : defaults, options);
			
			$(this).data(colorbox, data).addClass("cboxElement");
			
			if (callback) {
				$(this).data(colorbox).onComplete = callback;
			}
		});
		
		if (options && options.open) {
			launch($this);
		}
		
		return this;
	};

	// Initialize ColorBox: store common calculations, preload the interface graphics, append the html.
	// This preps colorbox for a speedy open when clicked, and lightens the burdon on the browser by only
	// having to run once, instead of each time colorbox is opened.
	cboxPublic.init = function () {
		
		// jQuery object generator to save a bit of space
		function $div(id) {
			return $('<div id="cbox' + id + '"/>');
		}
		
		// Create & Append jQuery Objects
		$window = $(window);
		$cbox = $('<div id="colorbox"/>');
		$overlay = $div("Overlay").hide();
		$wrap = $div("Wrapper");
		$content = $div("Content").append(
			$loaded = $div("LoadedContent").css({width: 0, height: 0}),
			$loadingOverlay = $div("LoadingOverlay"),
			$loadingGraphic = $div("LoadingGraphic"),
			$title = $div("Title"),
			$current = $div("Current"),
			$slideshow = $div("Slideshow"),
			$next = $div("Next"),
			$prev = $div("Previous"),
			$close = $div("Close")
		);
		
		$wrap.append( // The 3x3 Grid that makes up ColorBox
			$('<div/>').append(
				$div("TopLeft"),
				$topBorder = $div("TopCenter"),
				$div("TopRight")
			),
			$('<div/>').append(
				$leftBorder = $div("MiddleLeft"),
				$content,
				$rightBorder = $div("MiddleRight")
			),
			$('<div/>').append(
				$div("BottomLeft"),
				$bottomBorder = $div("BottomCenter"),
				$div("BottomRight")
			)
		).children().children().css({'float': 'left'});
		
		$loadingBay = $("<div style='position:absolute; top:0; left:0; width:9999px; height:0;'/>");
		
		$('body').prepend($overlay, $cbox.append($wrap, $loadingBay));
				
		if (isIE) {
			$cbox.addClass('cboxIE');
			if (isIE6) {
				$overlay.css('position', 'absolute');
			}
		}
		
		// Add rollover event to navigation elements
		$content.children()
		.bind('mouseover mouseout', function(){
			$(this).toggleClass(hover);
		}).addClass(hover);
		
		// Cache values needed for size calculations
		interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(TRUE) - $content.height();//Subtraction needed for IE6
		interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(TRUE) - $content.width();
		loadedHeight = $loaded.outerHeight(TRUE);
		loadedWidth = $loaded.outerWidth(TRUE);
		
		// Setting padding to remove the need to do size conversions during the animation step.
		$cbox.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide();
		
		// Setup button & key events.
		$next.click(cboxPublic.next);
		$prev.click(cboxPublic.prev);
		$close.click(cboxPublic.close);
		
		// Adding the 'hover' class allowed the browser to load the hover-state
		// background graphics.  The class can now can be removed.
		$content.children().removeClass(hover);
		
		$('.cboxElement').live('click', function (e) {
			if (e.button !== 0 && typeof e.button !== 'undefined') {// checks to see if it was a non-left mouse-click.
				return TRUE;
			} else {
				launch(this);
				return FALSE;
			}
		});
	};

	cboxPublic.position = function (speed, loadedCallback) {
		var
		animate_speed,
		winHeight = $window.height(),
		// keeps the top and left positions within the browser's viewport.
		posTop = Math.max(winHeight - settings.h - loadedHeight - interfaceHeight,0)/2 + $window.scrollTop(),
		posLeft = Math.max(document.documentElement.clientWidth - settings.w - loadedWidth - interfaceWidth,0)/2 + $window.scrollLeft();
		
		// setting the speed to 0 to reduce the delay between same-sized content.
		animate_speed = ($cbox.width() === settings.w+loadedWidth && $cbox.height() === settings.h+loadedHeight) ? 0 : speed;
		
		// this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
		// but it has to be shrank down around the size of div#colorbox when it's done.  If not,
		// it can invoke an obscure IE bug when using iframes.
		$wrap[0].style.width = $wrap[0].style.height = "9999px";
		
		function modalDimensions (that) {
			// loading overlay size has to be sure that IE6 uses the correct height.
			$topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = that.style.width;
			$loadingGraphic[0].style.height = $loadingOverlay[0].style.height = $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = that.style.height;
		}
		
		$cbox.dequeue().animate({width:settings.w+loadedWidth, height:settings.h+loadedHeight, top:posTop, left:posLeft}, {duration: animate_speed,
			complete: function(){
				modalDimensions(this);




				
				active = FALSE;
				
				// shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
				$wrap[0].style.width = (settings.w+loadedWidth+interfaceWidth) + "px";
				$wrap[0].style.height = (settings.h+loadedHeight+interfaceHeight) + "px";
				
				if (loadedCallback) {loadedCallback();}
			},
			step: function(){
				modalDimensions(this);
			}
		});
	};

	cboxPublic.resize = function (object) {
		if(!open){ return; }
		
		var topMargin,
		prev,
		prevSrc,
		next,
		nextSrc,
		photo,
		timeout,
		speed = settings.transition==="none" ? 0 : settings.speed;
		
		$window.unbind(cbox_resize);
		
		if(!object){
			timeout = setTimeout(function(){ // timer allows IE to render the dimensions before attempting to calculate the height
				var $child = $loaded.wrapInner("<div style='overflow:auto'></div>").children(); // temporary wrapper to get an accurate estimate of just how high the total content should be.
				settings.h = $child.height();
				$loaded.css({height:settings.h});
				$child.replaceWith($child.children()); // ditch the temporary wrapper div used in height calculation
				cboxPublic.position(speed);
			}, 1);
			return;
		}
		
		$loaded.remove();
		
		$loaded = $('<div id="cboxLoadedContent"/>').html(object);
		
		function getWidth(){
			settings.w = settings.w || $loaded.width();
			settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
			return settings.w;
		}
		function getHeight(){
			settings.h = settings.h || $loaded.height();
			settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
			return settings.h;
		}
		
		$loaded.hide()
		.appendTo($loadingBay)// content has to be appended to the DOM for accurate size calculations.  Appended to an absolutely positioned element, rather than BODY, which avoids an extremely brief display of the vertical scrollbar in Firefox that can occur for a small minority of websites.
		.css({width:getWidth(), overflow:settings.scrolling ? 'auto' : 'hidden'})
		.css({height:getHeight()})// sets the height independently from the width in case the new width influences the value of height.
		.prependTo($content);
		
		$('#cboxPhoto').css({cssFloat:'none'});// floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
		
		// Hides SELECT elements in IE6 because they would otherwise sit on top of the overlay.
		if (isIE6) {
			$('select:not(#colorbox select)').filter(function(){
				return this.style.visibility !== 'hidden';
			}).css({'visibility':'hidden'}).one(cbox_cleanup, function(){
				this.style.visibility = 'inherit';
			});
		}
				
		function setPosition (s) {
			cboxPublic.position(s, function(){
				if (!open) { return; }
				
				if (isIE) {
					//This fadeIn helps the bicubic resampling to kick-in.
					if( photo ){$loaded.fadeIn(100);}
					//IE adds a filter when ColorBox fades in and out that can cause problems if the loaded content contains transparent pngs.
					$cbox[0].style.removeAttribute("filter");
				}
				
				//Waited until the iframe is added to the DOM & it is visible before setting the src.
				//This increases compatability with pages using DOM dependent JavaScript.
				if(settings.iframe){
					$loaded.append("<iframe id='cboxIframe'" + (settings.scrolling ? " " : "scrolling='no'") + " name='iframe_"+new Date().getTime()+"' frameborder=0 src='"+settings.href+"' " + (isIE ? "allowtransparency='true'" : '') + " />");
				}
				
				$loaded.show();
				
				$title.show().html(settings.title);
				
				if ($related.length>1) {
					$current.html(settings.current.replace(/\{current\}/, index+1).replace(/\{total\}/, $related.length)).show();
					$next.html(settings.next).show();
					$prev.html(settings.previous).show();
					
					if(settings.slideshow){
						$slideshow.show();
					}
				}
				
				$loadingOverlay.hide();
				$loadingGraphic.hide();
				

				$.event.trigger(cbox_complete);
				if (settings.onComplete) {
					settings.onComplete.call(element);
				}
				
				if (settings.transition === 'fade'){
					$cbox.fadeTo(speed, 1, function(){
						if(isIE){$cbox[0].style.removeAttribute("filter");}
					});
				}
				
				$window.bind(cbox_resize, function(){
					cboxPublic.position(0);
				});
			});
		}
		
		if((settings.transition === 'fade' && $cbox.fadeTo(speed, 0, function(){setPosition(0);})) || setPosition(speed)){}
		
		// Preloads images within a rel group
		if (settings.preloading && $related.length>1) {
			prev = index > 0 ? $related[index-1] : $related[$related.length-1];
			next = index < $related.length-1 ? $related[index+1] : $related[0];
			nextSrc = $(next).data(colorbox).href || next.href;
			prevSrc = $(prev).data(colorbox).href || prev.href;
			
			if(isImage(nextSrc)){
				$('<img />').attr('src', nextSrc);
			}
			
			if(isImage(prevSrc)){
				$('<img />').attr('src', prevSrc);
			}
		}
	};

	cboxPublic.load = function () {
		var href, img, setResize, resize = cboxPublic.resize;
		
		active = TRUE;
		
		/*
		 
		// I decided to comment this out because I can see it causing problems as users
		// really should just set the dimensions on their IMG elements instead,
		// but I'm leaving the code in as it may be useful to someone.
		// To use, uncomment the function and change 'if(textStatus === "success"){ resize(this); }'
		// to 'if(textStatus === "success"){ preload(this); }'
		
		// Preload loops through the HTML to find IMG elements and loads their sources.
		// This allows the resize method to accurately estimate the dimensions of the new content.
		function preload(html){
			var
			$ajax = $(html),
			$imgs = $ajax.find('img'),
			x = $imgs.length;
			
			function loadloop(){
				var img = new Image();
				x = x-1;
				if(x >= 0){
					img.onload = loadloop;
					img.src = $imgs[x].src;
				} else {
					resize($ajax);
				}
			}
			
			loadloop();
		}
		*/
		
		element = $related[index];
		
		settings = $(element).data(colorbox);
		
		//convert functions to static values
		process();
		
		$.event.trigger(cbox_load);
		if (settings.onLoad) {
			settings.onLoad.call(element);
		}
		
		// Evaluate the height based on the optional height and width settings.
		settings.h = settings.height ?
				setSize(settings.height, 'y') - loadedHeight - interfaceHeight :
				settings.innerHeight ?
					setSize(settings.innerHeight, 'y') :
					FALSE;
		settings.w = settings.width ?
				setSize(settings.width, 'x') - loadedWidth - interfaceWidth :
				settings.innerWidth ?
					setSize(settings.innerWidth, 'x') :
					FALSE;
		
		// Sets the minimum dimensions for use in image scaling
		settings.mw = settings.w;
		settings.mh = settings.h;
		
		// Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
		// If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
		if(settings.maxWidth){
			settings.mw = setSize(settings.maxWidth, 'x') - loadedWidth - interfaceWidth;
			settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
		}
		if(settings.maxHeight){
			settings.mh = setSize(settings.maxHeight, 'y') - loadedHeight - interfaceHeight;
			settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
		}
		
		href = settings.href;
		
		$loadingOverlay.show();
		$loadingGraphic.show();
		
		if (settings.inline) {
			// Inserts an empty placeholder where inline content is being pulled from.
			// An event is bound to put inline content back when ColorBox closes or loads new content.
			$('<div id="cboxInlineTemp" />').hide().insertBefore($(href)[0]).bind(cbox_load+' '+cbox_cleanup, function(){
				$(this).replaceWith($loaded.children());
			});
			resize($(href));
		} else if (settings.iframe) {
			// IFrame element won't be added to the DOM until it is ready to be displayed,
			// to avoid problems with DOM-ready JS that might be trying to run in that iframe.
			resize(" ");
		} else if (settings.html) {
			resize(settings.html);
		} else if (isImage(href)){
			img = new Image();
			img.onload = function(){
				var percent;
				
				img.onload = null;
				
				img.id = 'cboxPhoto';
				
				$(img).css({margin:'auto', border:'none', display:'block', cssFloat:'left'});
				
				if(settings.scalePhotos){
					setResize = function(){
						img.height -= img.height * percent;
						img.width -= img.width * percent;	
					};
					if(settings.mw && img.width > settings.mw){
						percent = (img.width - settings.mw) / img.width;
						setResize();
					}
					if(settings.mh && img.height > settings.mh){
						percent = (img.height - settings.mh) / img.height;
						setResize();
					}
				}
				
				if (settings.h) {
					img.style.marginTop = Math.max(settings.h - img.height,0)/2 + 'px';
				}
				
				resize(img);
				
				if($related.length > 1){
					$(img).css({cursor:'pointer'}).click(cboxPublic.next);
				}
				
				if(isIE){
					img.style.msInterpolationMode='bicubic';
				}
			};
			img.src = href;
		} else {
			$('<div />').appendTo($loadingBay).load(href, function(data, textStatus){
				if(textStatus === "success"){
					resize(this);
				} else {
					resize($("<p>Request unsuccessful.</p>"));
				}
			});
		}
	};

	// Navigates to the next page/image in a set.
	cboxPublic.next = function () {
		if(!active){
			index = index < $related.length-1 ? index+1 : 0;
			cboxPublic.load();
		}
	};
	
	cboxPublic.prev = function () {
		if(!active){
			index = index > 0 ? index-1 : $related.length-1;
			cboxPublic.load();
		}
	};

	cboxPublic.slideshow = function () {
		var stop, timeOut, className = 'cboxSlideshow_';
		
		$slideshow.bind(cbox_closed, function(){
			$slideshow.unbind();
			clearTimeout(timeOut);
			$cbox.removeClass(className+"off"+" "+className+"on");
		});
		
		function start(){
			$slideshow
			.text(settings.slideshowStop)
			.bind(cbox_complete, function(){
				timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
			})
			.bind(cbox_load, function(){
				clearTimeout(timeOut);	
			}).one("click", function(){
				stop();
				$(this).removeClass(hover);
			});
			$cbox.removeClass(className+"off").addClass(className+"on");
		}
		
		stop = function(){
			clearTimeout(timeOut);
			$slideshow
			.text(settings.slideshowStart)
			.unbind(cbox_complete+' '+cbox_load)
			.one("click", function(){
				start();
				timeOut = setTimeout(cboxPublic.next, settings.slideshowSpeed);
				$(this).removeClass(hover);
			});
			$cbox.removeClass(className+"on").addClass(className+"off");
		};
		
		if(settings.slideshow && $related.length>1){
			if(settings.slideshowAuto){
				start();
			} else {
				stop();
			}
		}
	};

	// Note: to use this within an iframe use the following format: parent.$.fn.colorbox.close();
	cboxPublic.close = function () {
		
		$.event.trigger(cbox_cleanup);
		if (settings.onCleanup) {
			settings.onCleanup.call(element);
		}
		
		open = FALSE;
		$(document).unbind("keydown.cbox_close keydown.cbox_arrows");
		$window.unbind(cbox_resize+' resize.cboxie6 scroll.cboxie6');
		
		// mod start: modfied by BK elements.at
		if(settings.fadeout) {
			$overlay.css({cursor: 'auto'}).fadeOut('fast');
			
			$cbox
			.stop(TRUE, FALSE)
			.fadeOut('fast', function () {
				$('#colorbox iframe').attr('src', 'about:blank');
				$loaded.remove();
				$cbox.css({'opacity': 1});
				
				try{
					bookmark.focus();
				} catch (er){
					// do nothing
				}
				
				$.event.trigger(cbox_closed);
				if (settings.onClosed) {
					settings.onClosed.call(element);
				}
			});
			
		} else {
			$overlay.css({cursor: 'auto'}).hide();
			
			$cbox
			.stop(TRUE, FALSE)
			.hide(function () {
				$('#colorbox iframe').attr('src', 'about:blank');
				$loaded.remove();
				$cbox.css({'opacity': 1});
				
				try{
					bookmark.focus();
				} catch (er){
					// do nothing

				}
				
				$.event.trigger(cbox_closed);
				if (settings.onClosed) {
					settings.onClosed.call(element);
				}
			});
			
		}
		// mod end
		
		
	};

	// A method for fetching the current element ColorBox is referencing.
	// returns a jQuery object.
	cboxPublic.element = function(){ return $(element); };

	cboxPublic.settings = defaults;

	// Initializes ColorBox when the DOM has loaded
	$(cboxPublic.init);

}(jQuery));




var intersport = {
	
	backgroundImagesInitialized: false,
	sidebarShadowsInitialized: false,
	subnavHoverInitialized: false,
	metaNavigationInitialized: false,
	languageSelectionInitialized: false,
	
	// ------------------------------------------ //
	// BACKGROUND IMAGE OR COLOR:				  //
	// ------------------------------------------ //
	backgroundImages: function () {
		if($("#background_image_container .image") && this.backgroundImagesInitialized == false) {
			var image = $("#background_image_container .image");
			if(image.css("background-image") == "none" && image.css("background-color") != "transparent") {	
				image.liquidCanvas("gradient{from:" + image.css("background-color") + "; to:#fafafa} => rect");
			} else if($("#background_image_container .image .gradient")) {
				$("#background_image_container .image .gradient").liquidCanvas("gradient{from:rgba(250, 250, 250, 0); to:#fafafa} => rect");
			}
			this.backgroundImagesInitialized = true;
		}
	},
	
	// ------------------------------------------ //
	// SIDEBAR SHADOWS:							  //
	// ------------------------------------------ //
	sidebarShadows: function () {
		if($("#sidebar .teaser").length > 0 && this.sidebarShadowsInitialized == false) {
			var sidebarteaser = $("#sidebar .teaser");
			for(var i=0; i<sidebarteaser.length; i++) {
				this.shadow = $(".shadow", sidebarteaser.eq(i));
				if(i == 0) {
					$(this.shadow).addClass("top"); // first teaser gets an other type of shadow
				}
				$(this.shadow).height(sidebarteaser.eq(i).outerHeight()); // set height of the shadow
			}
			this.sidebarShadowsInitialized = true;
		}
	},
	
	// ------------------------------------------ //
	// SUB NAVIGATION - HOVER:					  //
	// ------------------------------------------ //
	subnavHover: function () {
		if($("#subnav li").length > 0 && this.subnavHoverInitialized == false) {
			$("#subnav li").hover(
				function() { $(this).addClass('hover'); },
				function() { $(this).removeClass('hover'); }
			);
			this.subnavHoverInitialized = true;
		}
	},
	
	// ------------------------------------------ //
	// META NAVIGATION:							  //
	// ------------------------------------------ //
	metaNavigation: function () {
		if($("#metanav li.main").length > 0 && this.metaNavigationInitialized == false) {
			var metanaventries = $("#metanav li.main");
			var metanaventries_points = $("div.navlink", metanaventries);
			var metanaventries_pointsactive = $("#metanav li.main.active div.navlink");
			
			var metanavsubboxes = $("#metanav .sub .standard");
			var actualOpen = -1;
			
			// set current active link:
			metanaventries_pointsactive.liquidCanvas("gradient{from:#143ca0; to:#1e46aa} => rect");	
			
			// prevents metanavigaton box from closing if inside there's a select-box:
			$("select", metanavsubboxes).mouseleave(function(event) { event.stopPropagation(); }); 
			
			// hover effects:
			metanaventries.each(function(i) {
				$(this).bind({
					mouseenter: function(event) {
						if(!$(this).hasClass("open")) {
							$(this).addClass("open");
							metanaventries_points.eq(i).liquidCanvas("fill{color:#fff} => roundedRect_customCorners{tl:5; tr:5; bl:0; br:0}"); // create hover effect
							actualOpen = i;
							createMetanavSubbox();
						}
					},
					mouseleave: function(event) {
						if($(this).hasClass("open") && event.target.nodeName != "FORM") { // hack for google chrome
							$(this).removeClass("open");
							metanaventries_points.eq(i).prev().remove(); // remove hover effect
							actualOpen = -1;
						}
					}		 
				});
			});
			
			
			function createMetanavSubbox () {
				var currentbox = $(".sub .standard", metanaventries.eq(actualOpen));
				
				// create rounded box and the containers inside (do all this only if box exists and hovered for the first time):
				if(currentbox.length > 0 && currentbox.prev().length == 0) {
					var containers = $(".container", currentbox);
					
					// add lines between containers and calculate width of the box:
					if(containers.length > 0) {
						$(".container:lt(" + (containers.length-1) + ")", currentbox).addClass("line");
						
						var totalWidth = 0;
						containers.each(function(i) {
							totalWidth += $(this).width();
							if(containers.eq(i).hasClass("brands") && !containers.eq(i).hasClass("line")) {
								totalWidth -= 2;	
							}
						});
						currentbox.width(totalWidth);
					}
					
					// change position of the box, if it's too wide to fit into the 990px page width
					if((metanaventries.eq(actualOpen).position().left + currentbox.width() + 1) > 990) {
						currentbox.css({left: -(metanaventries.eq(actualOpen).position().left + currentbox.width() - 990) + 'px'});
					}
					
					// create rectangle with rounded corners and gradient:
					currentbox.liquidCanvas("[shadow{shift:1; alpha:'0.2'; color:'#000'; width:'1'} gradient{from:#fff; to:#eff0f2}] => roundedRect_customCorners{tl:0; tr:0; bl:5; br:5}");
				
					// check if the images inside the teasers have to be rounded:
					var maxHeight = 0;
					containers.each(function(i) {				 
						if($(".content", $(this)).innerHeight() > maxHeight) {
							maxHeight = $(".content", $(this)).innerHeight();
						}
					});
					
					var roundTeaser = true;
					containers.each(function(i) {
						if ($(".content", $(this)).innerHeight() > 160) {
							roundTeaser = false;							   
						}				 
						if($(this).hasClass("teaser")) {
							if($(".bgimage", $(this)).innerHeight() >= maxHeight) {
								roundTeaser = true;
							}
						}
					});
					
					if(roundTeaser && $(".bottom", currentbox).length == 0 ) {
						if(containers.length == 1 && containers.hasClass("teaser")) {
							var bgimage = $(".bgimage", containers);
							bgimage.liquidCanvas("[shadow{shift:0; alpha:'0.0'; color:'#000'; width:'0.1'} fill{image:'background'}] => roundedRect_customCorners{tl:0; tr:0; bl:5; br:5}");
						} else if (containers.length > 1) {
							if(containers.last().hasClass("teaser")) {
								var bgimage = $(".bgimage", containers.last());
								bgimage.liquidCanvas("[shadow{shift:0; alpha:'0.0'; color:'#000'; width:'0.1'} fill{image:'background'}] => roundedRect_customCorners{tl:0; tr:0; bl:0; br:5}");
							}
							if(containers.first().hasClass("teaser")) {
								var bgimage = $(".bgimage", containers.first());
								bgimage.liquidCanvas("[shadow{shift:0; alpha:'0.0'; color:'#000'; width:'0.1'} fill{image:'background'}] => roundedRect_customCorners{tl:0; tr:0; bl:5; br:0}");
							}
						}
					}
				}	
			}
			
			this.metaNavigationInitialized = true;
		}
		
	},
	
	// ------------------------------------------ //
	// LANGUAGE SELECTION:						  //
	// ------------------------------------------ //
	languageSelection: function () {
		if($("#langselect").length > 0 && this.languageSelectionInitialized == false) {
			
			// widen search and hide language selection on "onclick":
			var searchinput = $("input.query", $("#search"));
			
			$(searchinput).bind({
				focus: function() {
					$("#langsearch").addClass("wide");
				},
				blur: function() {
					if($("#langsearch").hasClass("wide")) {
						$("#langsearch").removeClass("wide");
					}
				}		 
			});
			
			this.languageSelectionInitialized = true;
		}
	}
	
};





// dom is loaded (incl. all scripts, images, css, ...)
$(window).load(function(){
						
	$(".gotolink").openlink();
	
	intersport.backgroundImages();
	intersport.sidebarShadows();
	intersport.subnavHover();
	intersport.metaNavigation();
	intersport.languageSelection();
	
	
	
	// ------------------------------------------ //
	// PORTAL:									  //
	// ------------------------------------------ //
	if($("#sujetpaging .slider").length >= 1) {
		var isIE = !$.support.opacity;
		
		var sujetpagingEntries = $("#sujetpaging .slider");
		var sujetpagingEntriesContainers = $("#sujetpaging .slidercontainer");
		var sujetTeasers = $("#sujetteasers div.teaser");
		var portalTeasers = $("#portalteasers div.teasercontainer");
		
		var currentActive = 0;
		
		if(sujetpagingEntries.length > 1) {
			sujetpagingEntries.show();
			sujetpagingEntries.eq(0).addClass("active");
		}
		
		sujetTeasers.eq(0).show();
		portalTeasers.eq(0).show();

        // create rounded portal teasers:
        $('.teaser:not(.noshadow)', portalTeasers.eq(0)).each(function(i) { //UPDATE WEWO
            if($(this).css("background-image") != "none") {
                $(this).liquidCanvas("[shadow{shift:1; alpha:'0.3'; color:'#000'} fill{image:'background'}] => roundedRect{radius:7}");
            } else if($(this).css("background-color") != "transparent") {
                $(this).liquidCanvas("[shadow{shift:1; alpha:'0.3'; color:'#000'} fill{color:'" + $(this).css("background-color") + "'}] => roundedRect{radius:7}");
            }
        });
		
		// set background images:
		var bgImageContainer = $("#background_image_container .image");
		var bgImagesContainer = $("#background_image_container div.images");
		var bgImages = $("#background_image_container div.images img");
		
		bgImageContainer.append("<div class='fadingimage' style='background-image:url(" + bgImages.first().attr("src") + "); display:block; opacity:0;'></img>");			
		if(sujetpagingEntries.length > 1) {
			sujetpagingEntries.each(function(i) {
				if(i > 0 && portalBackgroundImages[i-1]) {
					bgImageContainer.append("<div class='fadingimage' style='background-image:url(" + portalBackgroundImages[i-1] + "); opacity:0;'></img>");
					bgImagesContainer.append('<img src="' + portalBackgroundImages[i-1] + '" />');
				}
			});
		}
		
		var bgimagesNew = $("#background_image_container .image .fadingimage");
		bgimagesNew.eq(0).fadeTo(400, 1, "easeOutQuad");
		
		// sujetpaging slider - automatic animation:		
		var animateSujetPaging = setTimeout(function(){
			sujetpagingEntriesContainers.each(function(i) {
				var container = $(this);
				setTimeout(function(){ container.animate({"left": "193px"}, {"duration": 400, "easein": "easeInCubic"}); }, 250*i);
			});
		}, 4000);
	
		// sujetpaging slider - hover effects:
		sujetpagingEntriesContainers.hover(
			function(){
				clearTimeout(animateSujetPaging);
				sujetpagingEntriesContainers.stop().animate({"left": "0px"}, {"duration": "slow", "easein": "easeInCubic"});
			},
			function(){
				sujetpagingEntriesContainers.stop().animate({"left": "193px"}, {"duration": "slow", "easein": "easeInCubic"});
			}
		);
		
		// sujetpaging entries - click and hover effects:
		sujetpagingEntries.each(function(i) {
			$(this).bind({
				click: function() {
					if(i != currentActive) {
						switchSujet(i);
					}
					clearInterval(switchInterval);
				},
				mouseenter: function() {
					if(!$(this).hasClass("active")) {
						$(this).addClass('hover');
					}
				},
				mouseleave: function () {
					$(this).removeClass('hover');
				}
			});
		});
		
		function switchSujet (i) {
			// fade background image:
			bgimagesNew.eq(currentActive).fadeTo(800, 0, "easeInQuad");
			bgimagesNew.eq(i).fadeTo(800, 1, "easeInQuad");
			
			// switch sujet teaser:
			sujetTeasers.eq(currentActive).hide();
			setTimeout(function(){ 
				if(isIE) { sujetTeasers.eq(i).show(); } else { sujetTeasers.eq(i).fadeIn(450); } // ie can't fade elements with alpha transparency
			}, 350);
			
			// switch portal teasers:
			portalTeasers.eq(currentActive).hide();
			setTimeout(function(){
				if(isIE) { portalTeasers.eq(i).show(); } else { portalTeasers.eq(i).fadeIn(450); } // ie can't fade elements with alpha transparency

                // create rounded teasers only if displayed for the first time:
                $('.teaser:not(.noshadow)', portalTeasers.eq(i)).each(function(j) { //UPDATE WEWO
                    if($(this).prev().eq(0).length == 0) {
                        if($(this).css("background-image") != "none") {
                            $(this).liquidCanvas("[shadow{shift:1; alpha:'0.3'; color:'#000'} fill{image:'background'}] => roundedRect{radius:7}");
                        } else if($(this).css("background-color") != "transparent") {
                            $(this).liquidCanvas("[shadow{shift:1; alpha:'0.3'; color:'#000'} fill{color:'" + $(this).css("background-color") + "'}] => roundedRect{radius:7}");
                        }
                    }
                });
            }, 350);
			
			// set sujetpaging entry to active:
			sujetpagingEntries.eq(currentActive).removeClass("active");
			sujetpagingEntries.eq(i).removeClass("hover").addClass("active");
			
			currentActive = i;
		}
		
		// automatic animation - switch sujet every 12 seconds:
		if(sujetpagingEntries.length > 1) {
			var switchInterval = setInterval(function(){
				var newActive = currentActive+1;
				if(newActive >= sujetpagingEntries.length) {
					newActive = 0;
				}
				switchSujet(newActive);
			}, 12000);
		}
	}
	
	
	// ------------------------------------------ //
	// HRULE IE:								  //
	// ------------------------------------------ //
	if(!$.support.opacity) {
		var hrules = $("#textarea hr");
		hrules.replaceWith("<div class='hrule'></div>");	
	}
	
	
	// ------------------------------------------ //
	// CONTENT MATRIX:							  //
	// ------------------------------------------ //
	if($("#textarea .matrixblock .matrixbox").length > 0) {
		//full caption sliding to top
		$('#textarea .matrixblock .matrixbox.slideupfull').hover(function(){
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:200});
		}, function() {
			$(".cover", this).stop().animate({top:'160px'},{queue:false,duration:200});
		});	
		
		//half caption sliding to top
		$('#textarea .matrixblock .matrixbox.slideuphalf').hover(function(){
			$(".cover", this).stop().animate({top:'0px'},{queue:false,duration:200});
		}, function() {
			$(".cover", this).stop().animate({top:'110px'},{queue:false,duration:200});
		});	
		
		//full caption sliding to left
		$('#textarea .matrixblock .matrixbox.slideleft').hover(function(){
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:200});
		}, function() {
			$(".cover", this).stop().animate({left:'240px'},{queue:false,duration:200});
		});
		
		//full caption sliding to right
		$('#textarea .matrixblock .matrixbox.slideright').hover(function(){
			$(".cover", this).stop().animate({left:'0px'},{queue:false,duration:200});
		}, function() {
			$(".cover", this).stop().animate({left:'-240px'},{queue:false,duration:200});
		});
	}
	
	
	// ------------------------------------------ //
	// CONTENT GALLERY SLIDER:					  //
	// ------------------------------------------ //
	if($("#textarea .gallery .galleryslider").length > 0) {
		var itemWidth = 175;
		var maxItems = 3;
		if ($("#background_contentborders").hasClass("wide")) {
			maxItems = 4;
		}
		var currentId = 0;
		var sliders = $("#textarea .gallery .galleryslider");
		
		function slide (sliderContainer, targetId) {
			var newSliderPos = targetId * (itemWidth * -1);
			sliderContainer.stop().animate({left:newSliderPos + 'px'},{queue:false,duration:320});
			currentId = targetId;
		}

		sliders.each(function(i) {
			var slideLeft = $(".slideImgleft", $(this));
			var slideRight = $(".slideImgright", $(this));
			
			var sliderContainer = $(".imagecontainer", $(this));
			var images = $(".img_thumb", $(this));
			
			slideLeft.bind({
				click: function() {
					if(currentId > 0) {
						slide(sliderContainer, currentId-1);
					}
				}			 
			});
			slideRight.bind({
				click: function() {
					if(currentId < images.length - maxItems) {
						slide(sliderContainer, currentId+1);
					}
				}			 
			});
		});
	}
	
	
	// ------------------------------------------ //
	// CONTENT HISTORY SLIDER:					  //
	// ------------------------------------------ //
	if($("#historyslider").length > 0) {
		var isIE = !$.support.opacity;
		
		$("#historyslider").mopSlider({'w':565,'h':255,'sldW':490,'btnW':160,'itemMgn':20,'itemWidth':162,'indi':"Click &amp; Move",'auto':'n','move':1000,'interval':2000,'type':'intersport'});
		
		var items = $("#historyslider div.item");
		var yeartexts = $("#textarea div.historytexts div.yeartext");
		
		yeartexts.last().show(); // automatically show text for the last year
		
		var currentShown = 0;
		if(yeartexts.length >= 1) {
			currentShown = yeartexts.length - 1;
		}
		
		items.each(function(i) {
			$(this).bind({
				click: function() {
					yeartexts.eq(currentShown).hide();
					if(isIE) { yeartexts.eq(i).show(); } else { yeartexts.eq(i).fadeIn("normal"); }
					currentShown = i;
				}			 
			});
		});
	}
	
	
	// ------------------------------------------ //
	// COLORBOX (LIGHTBOX):						  //
	// ------------------------------------------ //
	
	// images:
	if($("a[rel='colorbox']").length > 0) {
		$("a[rel='colorbox']").colorbox({transition:"none", overlay:false, maxHeight:"90%"});
	}
	
	// videos:
	if($("#textarea .teaserblock .teaser.video").length > 0) {
		var videoteaser = $("#textarea .teaserblock .teaser.video");
		videoteaser.each(function(i) {
			$(this).bind({
				click: function() {
					$("a[rel='colorbox']", $(this)).colorbox({iframe:true, innerWidth:425, innerHeight:344, transition:"none", overlay:false, open:true, rel:'nofollow'});
				}			 
			});
		});
	}	
	
	// country selection - meta navigation:
	if($("#country a").length > 0) {
		$("#country a").eq(0).colorbox({width:"770px", transition:"none", fadeout:true, scrolling:false, overlay:false});
		var tooltip = $("#country .tooltip");
		if(tooltip.length > 0) {
			$("#country").hover(
				function(){ tooltip.show(); },
				function(){ tooltip.hide(); }
			);
		}
	}
	
	// country selection - content area:
	if($("#textarea .countrylist .country .countrydetail").length > 0) {
		var country = $("#textarea .countrylist .country");
		country.each(function(i) {
			var detail = $(".countrydetail", $(this));
			if(detail.length > 0) {
				$(this).colorbox({width:"630px", transition:"none", fadeout:true, inline:true, scrolling:false, href:detail, overlay:false});
			}
		});
	}
	
	
	
	
	// ------------------------------------------ //
	// PRODUCT DETAIL (CHANGE IMAGE + TABBING):	  //
	// ------------------------------------------ //
	
	if($("#textarea .productdetail .images .thumbnails .thumb").length > 0) {
		
		var thumbs = $("#textarea .productdetail .images .thumbnails .thumb");
		var zoomimages = $("#textarea .productdetail .images .zoomimage img");
		
		var currentShownImage = 0;
		
		thumbs.each(function(i) {
			$(this).bind({
				click: function() {
					if(i != currentShownImage) {
						zoomimages.eq(currentShownImage).hide();
						zoomimages.eq(i).show();
						
						currentShownImage = i;
					}
				}			 
			});
		});
	}
	
	if($("#textarea .productdetail .tabbingcontainer .tabs .tab").length > 0) {
		
		var tabs = $("#textarea .productdetail .tabbingcontainer .tabs .tab");
		var texts = $("#textarea .productdetail .tabbingcontainer .tabbingcontent .text");
		
		var currentShownText = 0;
		
		tabs.each(function(i) {
			$(this).bind({
				click: function() {
					if(i != currentShownText) {
						tabs.eq(currentShownText).removeClass("active");
						tabs.eq(i).addClass("active");
						
						texts.eq(currentShownText).hide();
						texts.eq(i).show();
						
						currentShownText = i;
					}
				}			 
			});
		});
	}
	
	
});

