// source --> https://kamphuus-fewo10.de/wp-content/plugins/nextgen-gallery/static/Legacy/ajax.min.js?ver=4.2.3 
// TODO: This file can be removed once the minimum Pro API version is 4.0
EasyCookie=(function(){var EPOCH='Thu, 01-Jan-1970 00:00:01 GMT',RATIO=1000*60*60*24,KEYS=['expires','path','domain'],esc=escape,un=unescape,doc=document,me;var get_now=function(){var r=new Date();r.setTime(r.getTime());return r;}
    var cookify=function(c_key,c_val){var i,key,val,r=[],opt=(arguments.length>2)?arguments[2]:{};r.push(esc(c_key)+'='+esc(c_val));for(i=0;i<KEYS.length;i++){key=KEYS[i];if(val=opt[key])
        r.push(key+'='+val);}
        if(opt.secure)
            r.push('secure');return r.join('; ');}
    var alive=function(){var k='__EC_TEST__',v=new Date();v=v.toGMTString();this.set(k,v);this.enabled=(this.remove(k)==v);return this.enabled;}
    me={set:function(key,val){var opt=(arguments.length>2)?arguments[2]:{},now=get_now(),expire_at,cfg={};if(opt.expires){opt.expires*=RATIO;cfg.expires=new Date(now.getTime()+opt.expires);cfg.expires=cfg.expires.toGMTString();}
        var keys=['path','domain','secure'];for(i=0;i<keys.length;i++)
            if(opt[keys[i]])
                cfg[keys[i]]=opt[keys[i]];var r=cookify(key,val,cfg);doc.cookie=r;return val;},has:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length);return((!ofs&&key!=sub)||ofs<0)?false:true;},get:function(key){key=esc(key);var c=doc.cookie,ofs=c.indexOf(key+'='),len=ofs+key.length+1,sub=c.substring(0,key.length),end;if((!ofs&&key!=sub)||ofs<0)
        return null;end=c.indexOf(';',len);if(end<0)
        end=c.length;return un(c.substring(len,end));},remove:function(k){var r=me.get(k),opt={expires:EPOCH};doc.cookie=cookify(k,'',opt);return r;},keys:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(i=0;i<ps.length;i++){p=ps[i].split('=');r.push(un(p[0]));}
        return r;},all:function(){var c=doc.cookie,ps=c.split('; '),i,p,r=[];for(i=0;i<ps.length;i++){p=ps[i].split('=');r.push([un(p[0]),un(p[1])]);}
        return r;},version:'0.2.1',enabled:false};me.enabled=alive.call(me);return me;}());

window.Ngg_Store = {

    get: function(key){
        return EasyCookie.get(key);
    },

    set: function(key, value){
        if (typeof(value) == 'object') {
            value = JSON.stringify(value);
        }
        return EasyCookie.set(key, value, {
            expires: 10,
            path: '/',
            secure: false
        });
    },

    del: function(key){
        EasyCookie.remove(key);
        return !this.has(key);
    },

    has: function(key){
        var value = this.get(key);
        return typeof(value) != 'undefined' && value != null;
    },

    save: function(){
        return true;
    }
};

jQuery(function($){
    $(window).on('unload', function(){
        Ngg_Store.save();
    })
});
// source --> https://kamphuus-fewo10.de/wp-content/plugins/nextgen-gallery/static/Thumbnails/nextgen_basic_thumbnails.js?ver=4.2.3 
jQuery(function($) {
    var ngg_imagebrowser_init = function() {
        var imagebrowser_links = $('a.use_imagebrowser_effect');
        imagebrowser_links.on('click', function(e) {
            e.preventDefault();
            var success = true;
            var $this   = $(this);
            var image_id   = $this.attr('data-image-id');
            var image_slug = $this.attr('data-image-slug');
            var image_url  = $this.attr('data-imagebrowser-url');

            var url = window.location.toString();
            url = url.split('/' + photocrati_ajax.ngg_param_slug + '/').shift();
            if (url.substr(-1) === '/')
                url = url.substr(0, url.length - 1);

            image_id = image_slug ? image_slug : image_id;
            try {
                if (!image_id)
                    image_id = parseInt($this.parents('.ngg-gallery-thumbnail-box').attr('id').match(/\d+/).join(''));
            } catch (ex) {
                success = false;
            }

            if (success) {

                url = image_url.replace('%STUB%', image_id);

                /* TODO: Remove this entire chunk. It should be unecessary.
                // Custom permalinks are disabled. So we have to redirect to /index.php/nggallery/image/n?qs=1
                if (photocrati_ajax.wp_root_url.indexOf('index.php') >= 0) {
                    url = photocrati_ajax.wp_root_url + "/" + photocrati_ajax.ngg_param_slug + "/image/" + image_id;
                    if (window.location.toString().indexOf('?') >= 0)
                        url += '?'+window.location.toString().split('?').pop();
                } else {
                    // Just append the slug
                    url += "/" + photocrati_ajax.ngg_param_slug + "/image/" + image_id;
                } */

                window.location = url;
            }
        });

        // Unregister any onclick handlers added after the above has executed to avoid conflicts
        if (imagebrowser_links.length > 0) {
            setTimeout(function() {
                imagebrowser_links.each(function() {
                    this.onclick = null;
                });
            }, 200);
        }
    };

    $(this).on('refreshed', ngg_imagebrowser_init);
    ngg_imagebrowser_init();
});
// source --> https://kamphuus-fewo10.de/wp-content/themes/twentytwelve/js/navigation.js?ver=20250303 
/**
 * Handles toggling the navigation menu for small screens and
 * accessibility for submenu items.
 */
( function() {
	var nav = document.getElementById( 'site-navigation' ), button, menu;
	if ( ! nav ) {
		return;
	}

	button = nav.getElementsByTagName( 'button' )[0];
	menu   = nav.getElementsByTagName( 'ul' )[0];
	if ( ! button ) {
		return;
	}

	// Hide button if menu is missing or empty.
	if ( ! menu || ! menu.childNodes.length ) {
		button.style.display = 'none';
		return;
	}

	// Assign an ID for the default page list if no menu is set as Primary.
	if ( ! menu.id ) {
		menu.id = 'twentytwelve-page-list-menu';
	}

	button.setAttribute( 'aria-controls', menu.id );
	button.setAttribute( 'aria-expanded', 'false' );

	button.onclick = function() {
		if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
			menu.className = 'nav-menu';
		}

		if ( -1 !== button.className.indexOf( 'toggled-on' ) ) {
			button.setAttribute( 'aria-expanded', 'false' );
			button.className = button.className.replace( ' toggled-on', '' );
			menu.className = menu.className.replace( ' toggled-on', '' );
		} else {
			button.setAttribute( 'aria-expanded', 'true' );
			button.className += ' toggled-on';
			menu.className += ' toggled-on';
		}
	};
} )();

// Better focus for hidden submenu items for accessibility.
( function( $ ) {
	$( '.main-navigation' ).find( 'a' ).on( 'focus.twentytwelve blur.twentytwelve', function() {
		$( this ).parents( '.menu-item, .page_item' ).toggleClass( 'focus' );
	} );

  if ( 'ontouchstart' in window ) {
    $('body').on( 'touchstart.twentytwelve',  '.menu-item-has-children > a, .page_item_has_children > a', function( e ) {
      var el = $( this ).parent( 'li' );

      if ( ! el.hasClass( 'focus' ) ) {
        e.preventDefault();
        el.toggleClass( 'focus' );
        el.siblings( '.focus').removeClass( 'focus' );
      }
    } );
  }
} )( jQuery );