/* Modernizr 2.0.6 (Custom Build) | MIT & BSD
 * Build: http://www.modernizr.com/download/#-fontface-borderradius-iepp-teststyles-testprop-testallprops-domprefixes
 */
;window.Modernizr=function(a,b,c){function A(a,b){var c=a.charAt(0).toUpperCase()+a.substr(1),d=(a+" "+m.join(c+" ")+c).split(" ");return z(d,b)}function z(a,b){for(var d in a)if(j[a[d]]!==c)return b=="pfx"?a[d]:!0;return!1}function y(a,b){return!!~(""+a).indexOf(b)}function x(a,b){return typeof a===b}function w(a,b){return v(prefixes.join(a+";")+(b||""))}function v(a){j.cssText=a}var d="2.0.6",e={},f=b.documentElement,g=b.head||b.getElementsByTagName("head")[0],h="modernizr",i=b.createElement(h),j=i.style,k,l=Object.prototype.toString,m="Webkit Moz O ms Khtml".split(" "),n={},o={},p={},q=[],r=function(a,c,d,e){var g,i,j,k=b.createElement("div");if(parseInt(d,10))while(d--)j=b.createElement("div"),j.id=e?e[d]:h+(d+1),k.appendChild(j);g=["&shy;","<style>",a,"</style>"].join(""),k.id=h,k.innerHTML+=g,f.appendChild(k),i=c(k,a),k.parentNode.removeChild(k);return!!i},s,t={}.hasOwnProperty,u;!x(t,c)&&!x(t.call,c)?u=function(a,b){return t.call(a,b)}:u=function(a,b){return b in a&&x(a.constructor.prototype[b],c)};var B=function(a,c){var d=a.join(""),f=c.length;r(d,function(a,c){var d=b.styleSheets[b.styleSheets.length-1],g=d.cssRules&&d.cssRules[0]?d.cssRules[0].cssText:d.cssText||"",h=a.childNodes,i={};while(f--)i[h[f].id]=h[f];e.fontface=/src/i.test(g)&&g.indexOf(c.split(" ")[0])===0},f,c)}(['@font-face {font-family:"font";src:url("https://")}'],["fontface"]);n.borderradius=function(){return A("borderRadius")},n.fontface=function(){return e.fontface};for(var C in n)u(n,C)&&(s=C.toLowerCase(),e[s]=n[C](),q.push((e[s]?"":"no-")+s));v(""),i=k=null,a.attachEvent&&function(){var a=b.createElement("div");a.innerHTML="<elem></elem>";return a.childNodes.length!==1}()&&function(a,b){function s(a){var b=-1;while(++b<g)a.createElement(f[b])}a.iepp=a.iepp||{};var d=a.iepp,e=d.html5elements||"abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",f=e.split("|"),g=f.length,h=new RegExp("(^|\\s)("+e+")","gi"),i=new RegExp("<(/*)("+e+")","gi"),j=/^\s*[\{\}]\s*$/,k=new RegExp("(^|[^\\n]*?\\s)("+e+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),l=b.createDocumentFragment(),m=b.documentElement,n=m.firstChild,o=b.createElement("body"),p=b.createElement("style"),q=/print|all/,r;d.getCSS=function(a,b){if(a+""===c)return"";var e=-1,f=a.length,g,h=[];while(++e<f){g=a[e];if(g.disabled)continue;b=g.media||b,q.test(b)&&h.push(d.getCSS(g.imports,b),g.cssText),b="all"}return h.join("")},d.parseCSS=function(a){var b=[],c;while((c=k.exec(a))!=null)b.push(((j.exec(c[1])?"\n":c[1])+c[2]+c[3]).replace(h,"$1.iepp_$2")+c[4]);return b.join("\n")},d.writeHTML=function(){var a=-1;r=r||b.body;while(++a<g){var c=b.getElementsByTagName(f[a]),d=c.length,e=-1;while(++e<d)c[e].className.indexOf("iepp_")<0&&(c[e].className+=" iepp_"+f[a])}l.appendChild(r),m.appendChild(o),o.className=r.className,o.id=r.id,o.innerHTML=r.innerHTML.replace(i,"<$1font")},d._beforePrint=function(){p.styleSheet.cssText=d.parseCSS(d.getCSS(b.styleSheets,"all")),d.writeHTML()},d.restoreHTML=function(){o.innerHTML="",m.removeChild(o),m.appendChild(r)},d._afterPrint=function(){d.restoreHTML(),p.styleSheet.cssText=""},s(b),s(l);d.disablePP||(n.insertBefore(p,n.firstChild),p.media="print",p.className="iepp-printshim",a.attachEvent("onbeforeprint",d._beforePrint),a.attachEvent("onafterprint",d._afterPrint))}(a,b),e._version=d,e._domPrefixes=m,e.testProp=function(a){return z([a])},e.testAllProps=A,e.testStyles=r;return e}(this,this.document);;
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
/*! NOTE: If you're already including a window.matchMedia polyfill via Modernizr or otherwise, you don't need this part */
window.matchMedia=window.matchMedia||(function(e,f){var c,a=e.documentElement,b=a.firstElementChild||a.firstChild,d=e.createElement("body"),g=e.createElement("div");g.id="mq-test-1";g.style.cssText="position:absolute;top:-100em";d.appendChild(g);return function(h){g.innerHTML='&shy;<style media="'+h+'"> #mq-test-1 { width: 42px; }</style>';a.insertBefore(d,b);c=g.offsetWidth==42;a.removeChild(d);return{matches:c,media:h}}})(document);

/*! Respond.js v1.0.1: min/max-width media query polyfill. (c) Scott Jehl. MIT/GPLv2 Lic. j.mp/respondjs  */
(function(e){e.respond={};respond.update=function(){};respond.mediaQueriesSupported=e.matchMedia&&e.matchMedia("only all").matches;if(respond.mediaQueriesSupported){return}var t=e.document,q=t.documentElement,h=[],j=[],o=[],n={},g=30,f=t.getElementsByTagName("head")[0]||q,b=f.getElementsByTagName("link"),d=[],a=function(){var A=b,v=A.length,y=0,x,w,z,u;for(;y<v;y++){x=A[y],w=x.href,z=x.media,u=x.rel&&x.rel.toLowerCase()==="stylesheet";if(!!w&&u&&!n[w]){if(x.styleSheet&&x.styleSheet.rawCssText){l(x.styleSheet.rawCssText,w,z);n[w]=true}else{if(!/^([a-zA-Z]+?:(\/\/)?)/.test(w)||w.replace(RegExp.$1,"").split("/")[0]===e.location.host){d.push({href:w,media:z})}}}}s()},s=function(){if(d.length){var u=d.shift();m(u.href,function(v){l(v,u.href,u.media);n[u.href]=true;s()})}},l=function(F,u,w){var D=F.match(/@media[^\{]+\{([^\{\}]+\{[^\}\{]+\})+/gi),G=D&&D.length||0,u=u.substring(0,u.lastIndexOf("/")),v=function(H){return H.replace(/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,"$1"+u+"$2$3")},x=!G&&w,A=0,z,B,C,y,E;if(u.length){u+="/"}if(x){G=1}for(;A<G;A++){z=0;if(x){B=w;j.push(v(F))}else{B=D[A].match(/@media *([^\{]+)\{([\S\s]+?)$/)&&RegExp.$1;j.push(RegExp.$2&&v(RegExp.$2))}y=B.split(",");E=y.length;for(;z<E;z++){C=y[z];h.push({media:C.match(/(only\s+)?([a-zA-Z]+)(\sand)?/)&&RegExp.$2,rules:j.length-1,minw:C.match(/\(min\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1),maxw:C.match(/\(max\-width:[\s]*([\s]*[0-9]+)px[\s]*\)/)&&parseFloat(RegExp.$1)})}}i()},k,p,i=function(C){var u="clientWidth",w=q[u],B=t.compatMode==="CSS1Compat"&&w||t.body[u]||w,x={},A=b[b.length-1],v=(new Date()).getTime();if(C&&k&&v-k<g){clearTimeout(p);p=setTimeout(i,g);return}else{k=v}for(var y in h){var D=h[y];if(!D.minw&&!D.maxw||(!D.minw||D.minw&&B>=D.minw)&&(!D.maxw||D.maxw&&B<=D.maxw)){if(!x[D.media]){x[D.media]=[]}x[D.media].push(j[D.rules])}}for(var y in o){if(o[y]&&o[y].parentNode===f){f.removeChild(o[y])}}for(var y in x){var E=t.createElement("style"),z=x[y].join("\n");E.type="text/css";E.media=y;f.insertBefore(E,A.nextSibling);if(E.styleSheet){E.styleSheet.cssText=z}else{E.appendChild(t.createTextNode(z))}o.push(E)}},m=function(u,w){var v=c();if(!v){return}v.open("GET",u,true);v.onreadystatechange=function(){if(v.readyState!=4||v.status!=200&&v.status!=304){return}w(v.responseText)};if(v.readyState==4){return}v.send(null)},c=(function(){var u=false;try{u=new XMLHttpRequest()}catch(v){u=new ActiveXObject("Microsoft.XMLHTTP")}return function(){return u}})();a();respond.update=a;function r(){i(true)}if(e.addEventListener){e.addEventListener("resize",r,false)}else{if(e.attachEvent){e.attachEvent("onresize",r)}}})(this);;



Drupal.behaviors.stavanger = {
  attach: function(context, settings) {
    (function ($) {


    $(document).keydown(function(e){
        if (e.keyCode == 37) {
            $('.field-slideshow').cycle('prev');
           return false;
        }   
        if (e.keyCode == 39) {
            $('.field-slideshow').cycle('next');
           return false;
        }
    });


    $('.front #logo .anim').addClass("animate").delay(4500).queue(function(next){
        $(this).removeClass("animate");
        next();
    });

    $('.field-slideshow-caption .field-slideshow-caption-text').prepend($('#menu-collections ul.menu li a.active').clone())  

					
    })(jQuery);
  },
  detach: function(context, settings) {}
};

