
(function($){var Highlights=function(){var
element,type,elements=[],currentElement=0,timer,duration=800
setType=function(ftype){type=ftype||'toolbar';};return{init:function(){if($('#highlights-toolbar').exists()){setType('toolbar');$('#highlights-box').hover(function(){$('#highlights-toolbar').fadeIn(200);},function(){$('#highlights-toolbar').fadeOut(200);});$('#highlights-pause').click(function(event){event.preventDefault();$(this).HighlightsPause();});$('#highlights-start').click(function(event){event.preventDefault();$(this).HighlightsStart();});$('#highlights-prev').click(function(event){event.preventDefault();$(this).HighlightsPrev();});$('#highlights-next').click(function(event){event.preventDefault();$(this).HighlightsNext();});}else if($('#highlights-titles').exists()){setType('titles');$('#highlights-titles a').click(function(event){$(event.target).addClass('active').closest('li').siblings().find('a').removeClass('active');event.preventDefault();$(this).HighlightsGoTo(event.target.id.split('-')[2]);});}else if($('#highlights-pages').exists()){setType('pages');$('#highlights-pages a').click(function(event){$(event.target).addClass('active').siblings().removeClass('active');event.preventDefault();$(this).HighlightsGoTo(event.target.id.split('-')[2]);});}else if($('#highlights-slideshow').exists()){setType('slideshow');$('#highlights-pause').live('click',function(event){event.preventDefault();$(this).HighlightsPause();});$('#highlights-start').live('click',function(event){event.preventDefault();$(this).HighlightsStart();});$('#highlights-slideshow a[rel*=click]').click(function(event){var current=$(this).attr('class'),prev=$('#highlights-slideshow').find('a.active').attr('class');if($(this).hasClass('active')){return false;}
$(this).addClass('active').parent().siblings().children('a').removeClass('active');$('.'+prev.split(' ')[0]).siblings().remove('#highlights-controll');$(this).after('<div id="highlights-controll"><a href="#" id="highlights-pause"><img src="/gfx/button-stop.png" alt="Stop" /></a><a href="#" id="highlights-start" style="display: none;"><img src="/gfx/button-start.png" alt="Start" /></a></div>');$('#highlights-slideshow li a .timer').css('width','0px');$(this).HighlightsGoTo(current.split('-')[2]);$(this).HighlightsStartTimer();event.preventDefault();});}
elements=$('#highlights-box div.highlights-item');if(elements.length>1){$(this).HighlightsStart();}},start:function(){if(type=='toolbar'){$('#highlights-start').hide();$('#highlights-pause').show();}else if(type=='titles'){$('#highlights-titles li:first-child a').addClass('active');}else if(type=='pages'){$('#highlights-pages a:first-child').addClass('active');}else if(type=='slideshow'&&currentElement==0){$('#highlights-slideshow li:first-child a').addClass('active');$('#highlights-start').hide();$('#highlights-pause').show();if($('#highlights-slideshow li:first-child').find('#highlights-controll').length==0){$('#highlights-slideshow li:first-child a').after('<div id="highlights-controll"><a href="#" id="highlights-pause"><img src="/gfx/button-stop.png" alt="Stop" /></a><a href="#" id="highlights-start" style="display: none;"><img src="/gfx/button-start.png" alt="Start" /></a></div>');}}
if(type=='slideshow'){$(this).HighlightsStartTimer();}else{timer=setInterval(function(){var next=currentElement+1;if(elements[next]==undefined){next=0;}
$(elements[currentElement]).fadeOut(duration);$(elements[next]).fadeIn(duration);currentElement=next;if(type=='titles'){$('#highlights-titles a.active').removeClass('active');$('#highlights-titles li:nth-child('+(next+1)+') a').addClass('active');}else if(type=='pages'){$('#highlights-pages a.active').removeClass('active');$('#highlights-pages a:nth-child('+(next+1)+')').addClass('active');}},7000);}},pause:function(){clearTimeout(timer);$('highlights-slideshow').find('.active').removeClass('active');if(type=='toolbar'){$('#highlights-pause').hide();$('#highlights-start').show();}else if(type=='slideshow'){if($(this).attr('rel')!='click'){$('#highlights-pause').hide();$('#highlights-start').show();}}},showPrevious:function(){clearTimeout(timer);var next=currentElement-1;if(elements[next]==undefined){next=elements.length-1;}
$(elements[currentElement]).fadeOut(duration);$(elements[next]).fadeIn(duration);currentElement=next;$(this).HighlightsStart();},showNext:function(){clearTimeout(timer);var next=currentElement+1;if(elements[next]==undefined){next=0;}
$(elements[currentElement]).fadeOut(duration);$(elements[next]).fadeIn(duration);currentElement=next;$(this).HighlightsStart();},goTo:function(id){$(this).HighlightsPause();if(type=='slideshow'){$(elements[currentElement]).animate({left:'-911px'},1000,"linear",function(){$(this).css({'right':'911px','left':'0px'}).hide();});}else{$(elements[currentElement]).fadeOut(duration);}
$('#highlights-page-'+id).fadeIn(duration,function(){currentElement=$('#highlights-page-'+id).index();});},startTimer:function(){var width=0;timer=setInterval(function(){var next=currentElement+1;if(elements[next]==undefined){next=0;}
$('#highlights-start').hide();$('#highlights-pause').show();width+=1;$('#highlights-slideshow li a.active .timer').css('width',width+'px');if($('#highlights-slideshow li a.active .timer').css('width')==$('#highlights-slideshow li').css('width')){$('#highlights-slideshow li a.active .timer').css('width','0px');width=0;$(elements[currentElement]).animate({left:'-911px'},1000,"linear",function(){$(this).css({'right':'911px','left':'0px'}).hide();});$(elements[next]).fadeIn('slow');currentElement=next;$('#highlights-slideshow a.active').siblings().remove('#highlights-controll');$('#highlights-slideshow a.active').removeClass('active');$('#highlights-slideshow li:nth-child('+(next+1)+') a').addClass('active');$('#highlights-slideshow li:nth-child('+(next+1)+') a').after('<div id="highlights-controll"><a href="#" id="highlights-pause"><img src="/gfx/button-stop.png" alt="Stop" /></a><a href="#" id="highlights-start" style="display: none;"><img src="/gfx/button-start.png" alt="Start" /></a></div>');}},40);}};}();$.fn.extend({Highlights:Highlights.init,HighlightsStart:Highlights.start,HighlightsPause:Highlights.pause,HighlightsPrev:Highlights.showPrevious,HighlightsNext:Highlights.showNext,HighlightsGoTo:Highlights.goTo,HighlightsStartTimer:Highlights.startTimer});})(jQuery);jQuery(document).ready(function($){$('#highlights-box').Highlights();});
