
;(function(c){var a=c.scrollTo=function(f,e,d){c(window).scrollTo(f,e,d)};a.defaults={axis:"xy",duration:parseFloat(c.fn.jquery)>=1.3?0:1};a.window=function(d){return c(window)._scrollable()};c.fn._scrollable=function(){return this.map(function(){var e=this,d=!e.nodeName||c.inArray(e.nodeName.toLowerCase(),["iframe","#document","html","body"])!=-1;if(!d){return e}var f=(e.contentWindow||e).document||e.ownerDocument||e;return c.browser.safari||f.compatMode=="BackCompat"?f.body:f.documentElement})};c.fn.scrollTo=function(f,e,d){if(typeof e=="object"){d=e;e=0}if(typeof d=="function"){d={onAfter:d}}if(f=="max"){f=9000000000}d=c.extend({},a.defaults,d);e=e||d.speed||d.duration;d.queue=d.queue&&d.axis.length>1;if(d.queue){e/=2}d.offset=b(d.offset);d.over=b(d.over);return this._scrollable().each(function(){var l=this,j=c(l),k=f,i,g={},m=j.is("html,body");switch(typeof k){case"number":case"string":if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(k)){k=b(k);break}k=c(k,this);case"object":if(k.is||k.style){i=(k=c(k)).offset()}}c.each(d.axis.split(""),function(q,r){var s=r=="x"?"Left":"Top",u=s.toLowerCase(),p="scroll"+s,o=l[p],n=a.max(l,r);if(i){g[p]=i[u]+(m?0:o-j.offset()[u]);if(d.margin){g[p]-=parseInt(k.css("margin"+s))||0;g[p]-=parseInt(k.css("border"+s+"Width"))||0}g[p]+=d.offset[u]||0;if(d.over[u]){g[p]+=k[r=="x"?"width":"height"]()*d.over[u]}}else{var t=k[u];g[p]=t.slice&&t.slice(-1)=="%"?parseFloat(t)/100*n:t}if(/^\d+$/.test(g[p])){g[p]=g[p]<=0?0:Math.min(g[p],n)}if(!q&&d.queue){if(o!=g[p]){h(d.onAfterFirst)}delete g[p]}});h(d.onAfter);function h(n){j.animate(g,e,d.easing,n&&function(){n.call(this,f,d)})}}).end()};a.max=function(j,i){var h=i=="x"?"Width":"Height",e="scroll"+h;if(!c(j).is("html,body")){return j[e]-c(j)[h.toLowerCase()]()}var g="client"+h,f=j.ownerDocument.documentElement,d=j.ownerDocument.body;return Math.max(f[e],d[e])-Math.min(f[g],d[g])};function b(d){return typeof d=="object"?d:{top:d,left:d}}})(jQuery);
;(function( $ ){
var $serialScroll = $.serialScroll = function( settings ){
return $(window).serialScroll( settings );
};
$serialScroll.defaults = {// the defaults are public and can be overriden.
duration:1000, // how long to animate.
axis:'x', // which of top and left should be scrolled
event:'click', // on which event to react.
start:0, // first element (zero-based index)
step:1, // how many elements to scroll on each action
lock:true,// ignore events if already animating
cycle:true, // cycle endlessly ( constant velocity )
constant:true // use contant speed ?
};
$.fn.serialScroll = function( options ){
return this.each(function(){
var
settings = $.extend( {}, $serialScroll.defaults, options ),
event = settings.event, // this one is just to get shorter code when compressed
step = settings.step, // ditto
lazy = settings.lazy, // ditto
context = settings.target ? this : document, // if a target is specified, then everything's relative to 'this'.
$pane = $(settings.target || this, context),// the element to be scrolled (will carry all the events)
pane = $pane[0], // will be reused, save it into a variable
items = settings.items, // will hold a lazy list of elements
active = settings.start, // active index
auto = settings.interval, // boolean, do auto or not
nav = settings.navigation, // save it now to make the code shorter
timer; // holds the interval id
if( !lazy )// if not lazy, save the items now
items = getItems();
if( settings.force )
jump( {}, active );// generate an initial call
$(settings.prev||[], context).bind( event, -step, move );
$(settings.next||[], context).bind( event, step, move );
if( !pane.ssbound )// don't bind more than once
$pane
.bind('prev.serialScroll', -step, move ) // you can trigger with just 'prev'
.bind('next.serialScroll', step, move ) // f.e: $(container).trigger('next');
.bind('goto.serialScroll', jump ); // f.e: $(container).trigger('goto', 4 );
if( auto )
$pane
.bind('start.serialScroll', function(e){
if( !auto ){
clear();
auto = true;
next();
}
})
.bind('stop.serialScroll', function(){// stop a current animation
clear();
auto = false;
})
.bind('toggle.serialScroll', function(){ //marcme:added toggle function
clear();
if( auto ) {
auto = false;
} else {
auto = true;
next();
}
});
$pane.bind('notify.serialScroll', function(e, elem){// let serialScroll know that the index changed externally
var i = index(elem);
if( i > -1 )
active = i;
});
pane.ssbound = true;// avoid many bindings
if( settings.jump )// can't use jump if using lazy items and a non-bubbling event
(lazy ? $pane : getItems()).bind( event, function( e ){
jump( e, index(e.target) );
});
if( nav )
nav = $(nav, context).bind(event, function( e ){
e.data = Math.round(getItems().length / nav.length) * nav.index(this);
jump( e, this );
});
function move( e ){
e.data += active;
jump( e, this );
};
function jump( e, button ){
if( !isNaN(button) ){// initial or special call from the outside $(container).trigger('goto',[index]);
e.data = button;
button = pane;
}
var
pos = e.data, n,
real = e.type, // is a real event triggering ?
$items = settings.exclude ? getItems().slice(0,-settings.exclude) : getItems(),// handle a possible exclude
limit = $items.length,
elem = $items[pos],
duration = settings.duration;
if( real )// real event object
e.preventDefault();
if( auto ){
clear();// clear any possible automatic scrolling.
timer = setTimeout( next, settings.interval );
}
if( !elem ){ // exceeded the limits
n = pos < 0 ? 0 : limit - 1;
if( active != n )// we exceeded for the first time
pos = n;
else if( !settings.cycle )// this is a bad case
return;
else
pos = limit - n - 1;// invert, go to the other side
elem = $items[pos];
}
if( !elem || settings.lock && $pane.is(':animated') || // no animations while busy
real && settings.onBefore &&
settings.onBefore(e, elem, $pane, getItems(), pos) === false ) return;
if( settings.stop )
$pane.queue('fx',[]).stop();// remove all its animations
if( settings.constant )
duration = Math.abs(duration/step * (active - pos ));// keep constant velocity
$pane
.scrollTo( elem, duration, settings )// do scroll
.trigger('notify.serialScroll',[pos]);// in case serialScroll was called on this elem more than once.
};
function next(){// I'll use the namespace to avoid conflicts
$pane.trigger('next.serialScroll');
};
function clear(){
clearTimeout(timer);
};
function getItems(){
return $( items, pane );
};
function index( elem ){
if( !isNaN(elem) ) return elem;// number
var $items = getItems(), i;
while(( i = $items.index(elem)) == -1 && elem != pane )// see if it matches or one of its ancestors
elem = elem.parentNode;
return i;
};
});
};
})( jQuery );
$(document).ready(function(){
initFrontpageTeaser();
initTicker();
});
function initTicker()
{
$("#ticker-mask").serialScroll({
items:'li',
duration:1000,
force:true,
axis:'y',
interval:6000
});
}
function initFrontpageTeaser()
{
var objTeaserList = $("#frontpage-teaser-list");
var iListHeight = 300;
var iTop = objTeaserList.position().top;
var duration = 500;
var arrPageSizes = getPageSize();
$("body").append('<div id="frontpage-teaser-overlay"></div>');
$("#frontpage-teaser-overlay").css({
display : "none",
position: "absolute",
width   : arrPageSizes[0],
height  : arrPageSizes[1],
top     : 0,
left    : 0,
height	: 0,
zIndex  : 6
});
$("#frontpage-teaser-overlay").click(function(event){
$("#frontpage-teaser-starter span").removeClass("open");
$("#ticker-mask").trigger("start");
objTeaserList.stop().animate({top:iTop}, duration);
$(this).hide();
event.preventDefault();
});
$("#frontpage-teaser-starter span").click(function(event){
var iEndPosition = iTop - iListHeight;
$(this).toggleClass("open");
$("#ticker-mask").trigger("toggle");
if(objTeaserList.position().top == iTop) {
objTeaserList.stop().animate({top:iEndPosition}, duration);
} else {
objTeaserList.stop().animate({top:iTop}, duration);
}
$("#frontpage-teaser-overlay").toggle();
event.preventDefault();
});
}

