
var lastLoadedHref="";var lastLoadedHash="";var animationEnded=false;var preloadEnded=false;var selectedImageLoaded=false;$(document).ready(function(){var hash=window.location.hash.substr(1);$.history.init(callback);var hash=window.location.hash.substr(1);var href=$('.ajax').each(function(){var href=$(this).attr('href');if(hash==href.substr(0,href.length-5)){var toLoad=hash+'.html #content';}});ajaxClickInit();$(this).initScroll();});function ajaxClickInit(hash)
{$('.ajax').unbind('click',onAjaxClick);$('.ajax').bind('click',onAjaxClick);}
function callback(hash)
{if(hash&&lastLoadedHash!=hash){animationEnded=true;preloadEnded=true;selectedImageLoaded=true;$('.header-thumbs-inner').fadeTo(100,0,function(){$(".header-thumbs").load(hash+' .header-thumbs-inner','',function(){$('.header-thumbs').fadeIn('slow');})});$('.description-inner').fadeTo(100,0,function(){$(".description").load(hash+' .description-inner','',function(){$('.description').fadeIn('slow');})});$('#content-inner').fadeTo(100,0,function(){$("#content").load(hash+' #content-inner','',showNewContent(false));});}}
function onAjaxClick(){$.fn.hideAll();$.fn.hideInfos();var linkHref=$(this).attr('href');var linkId=linkHref.substring(linkHref.lastIndexOf("/")+1);var isThumb=$(this).hasClass("thumb");var isArrow=$(this).hasClass("arrow");if(isThumb){clearThumbsOver();$(this,"img").addClass("selected");}else if(isArrow){clearThumbsOver();$(".header-thumbs-inner a[href*='/"+linkId+"']").addClass("selected");}
var contentToLoad2=linkHref+' .header-thumbs-inner';if(!isThumb&&!isArrow)$('.header-thumbs').load(contentToLoad2,'',function(){$('.header-thumbs').fadeIn('slow');});var contentToLoad3=linkHref+' .description-inner';$('.description').fadeOut('fast',function(){$('.description').load(contentToLoad3,'',function(){$('.description').fadeIn('slow');})});var contentToLoad=linkHref+' #content-inner';$('#content').hide('fast',function(){$('#content').load(contentToLoad,'',function(){animationEnded=true;showNewContent(isThumb);})});var hash=$(this).attr('href').substr(0,$(this).attr('href').length);window.location.hash=hash;lastLoadedHash=hash;$.history.load(hash);return false;}
function showNewContent(isThumb){$.fn.initSupersize();if(!isThumb)$.fn.initScroll();$('#content').show('slow',function(){ajaxClickInit();});}
$.fn.initSupersize=function(){var topOffset=$(".header-title").height()+$(".header-categories").height();var bottomOffset=$(".footer").height();var mode=$('#supersize img').attr('mode');if(mode=='1'){topOffset+=5;bottomOffset+=5;};if($(".header-thumbs").css('display')!='none')topOffset+=$(".header-thumbs").height()
$.fn.supersized.options={slideshow:0,offset_top:topOffset,offset_bottom:bottomOffset,mode:$('#supersize img').attr('mode'),};$('#supersize').supersized();}
$.fn.initScroll=function(){$.fn.initScroll();}
function clearThumbsOver(){$('.header-thumbs-inner a').each(function(){$(this).removeClass('selected');});};
