$(document).ready(function(){if(window.location.pathname.indexOf("artworks")==-1&&document.location.pathname!="/"){return}$("#images").css("background",'url("'+basePath+'easycms/img/layout/loader.gif") center center no-repeat');initSubnavi();initHashNavi();gesImages=$(".group_all").length;if(window.location.pathname=="/artworks"||window.location.pathname=="/artworks/random"||document.location.pathname=="/"){linkAnimation()}});$(window).load(function(){if(window.location.pathname.indexOf("artworks")==-1&&document.location.pathname!="/"){return}$("#images").css("background","none");var hash=window.location.hash.substring(1);if(isNaN(parseInt(hash))){if(window.location.pathname.indexOf("random")!=-1||document.location.pathname=="/"){showGroup(hash)}}else{if(window.location.pathname.indexOf("random")!=-1||document.location.pathname=="/"){showGroup("")}$("a#image_"+hash).click()}});function showGroup(id){if(id==undefined||id==""){id="all"}if(activeGroup==id){return}if(anim){return}anim=true;$("#subnavi li").removeClass("liActive");$("#subnavi #artworks-"+id).addClass("liActive");groupImages=$(".group_"+id+":not(.placeholder)").length;setImgCounter(groupImages);if(activeGroup==-1){calcGrid(id);displayImages($(".group_"+id+" img"),true,function(){anim=false})}else{displayImages($(gridID+" img"),false,function(){calcGrid(id);displayImages($(".group_"+id+" img"),true,function(){anim=false})})}activeGroup=id}function initSubnavi(){var obj=$(".liActive ul");obj.empty();obj.attr("id","subnavi");var base="";switch(window.location.pathname){case"/artworks":base="/artworks/random";break;case"/artworks/random":base="";break;case"/artworks/catalogue":base="/artworks/random";break;case"/artworks/year":base="/artworks/random";break;default:base="";break}var currentPage=window.location.pathname.split("/")[2];if(currentPage==undefined){currentPage="random"}var html="";html+='<li id="artworks-all" style="width: 200px;" class="liActive">';html+='  <a href="'+base+'#all" class="subnavi">';html+="    all";html+="  </a>";html+="  <select onChange=\"changePage('/artworks/' + this.value);\">";html+='    <option value="random" '+((currentPage=="random")?"selected":"")+">AT RANDOM</option>";html+='    <option value="catalogue"'+((currentPage=="catalogue")?"selected":"")+">BY CATALOGUE</option>";html+='    <option value="year"'+((currentPage=="year")?"selected":"")+">BY YEAR</option>";html+="  </select>";html+="</li>";html+='<li id="artworks-painting">';html+='  <a href="'+base+'#painting" class="subnavi">';html+="    Painting";html+="  </a>";html+="</li>";html+='<li id="artworks-sculpture">';html+='  <a href="'+base+'#sculpture" class="subnavi">';html+="    Sculpture";html+="  </a>";html+="</li>";html+='<li id="artworks-photography">';html+='  <a href="'+base+'#photography" class="subnavi">';html+="    Photography";html+="  </a>";html+="</li>";html+='<li id="artworks-edition">';html+='  <a href="'+base+'#edition" class="subnavi">';html+="    Edition";html+="  </a>";html+="</li>";html+='<li id="artworks-video">';html+='  <a href="'+base+'#video" class="subnavi">';html+="    Video";html+="  </a>";html+="</li>";obj.html(html)}var hash_history=window.location.hash;function initHashNavi(){if("onhashchange" in window){}else{setInterval("noHashFallback()",50)}window.onhashchange=function(){var hash=window.location.hash;hash=hash.substr(1);if(isNaN(parseInt(hash))){showGroup(hash)}else{$("a#image_"+hash).click()}}}function noHashFallback(){var hash=window.location.hash;if(hash!=hash_history){window.onhashchange();hash=hash_history}}function linkAnimation(){$('a[target!="_blank"]:not(.subnavi):not(.fancyFlipBox)').click(function(){changePage(this.href);return false})}function changePage(url){displayImages($(gridID+" img"),false,function(){window.location.href=url})}var gesImages=0;function setImgCounter(groupImages){if(window.location.pathname.indexOf("catalogue")!=-1){return}if(window.location.pathname.indexOf("year")!=-1){return}$("#navi_artworks > a").html("Artworks<br />("+groupImages+"/"+gesImages+")")};
