//////////////////////////////////////// // init jQuery( function() { // slide Navigation var birdsite_menu_width = jQuery( '#menu-wrapper' ).width(); jQuery( '#small-menu' ).click(function(){ var left = 0; if( jQuery( 'body' ).hasClass( 'open-menu' ) ){ // colse Navigation left = '-' + birdsite_menu_width + 'px'; } else{ // open Navigation jQuery( 'body' ).addClass( 'open-menu' ); } jQuery('#menu-wrapper').animate( { 'left' : left }, 300, function() { if(0 != left){ // close Navigation jQuery( 'body' ).removeClass( 'open-menu' ); } }); }); jQuery(window).resize(function() { // close Navigation if( jQuery( 'body' ).hasClass( 'open-menu' ) ){ jQuery( 'body' ).removeClass( 'open-menu' ); jQuery('#menu-wrapper').css( { 'left': '-' + birdsite_menu_width + 'px' } ); } }); jQuery( '.overlay' ).click(function(){ // close Navigation jQuery( '#small-menu' ).click(); }); // back to pagetop var totop = jQuery( '#back-top' ); totop.hide(); jQuery( window ).scroll(function(){ if( jQuery( this ).scrollTop() > 800 ) totop.fadeIn(); else totop.fadeOut(); }); totop.click( function () { jQuery( 'body, html' ).animate( { scrollTop: 0 }, 500 ); return false; }); // Center Thumbnail Position jQuery(window).load(function() { centerThumbnail(); }); }); //////////////////////////////////////// // Center Thumbnail Position function centerThumbnail() { jQuery( '.home .thumbnail img' ).each(function( i ){ var wrapperHeight = jQuery( this ).parent().height(); var wrapperWidth = jQuery( this ).parent().width(); var imageHeight = jQuery( this ).height(); var imageWidth = jQuery( this ).width(); if( imageWidth > imageHeight ){ // Horizontal Thumbnail var h = wrapperHeight; var w = ( imageWidth/imageHeight ) * h; } else{ // Vertical Thumbnail var w = wrapperWidth; var h = ( imageHeight/imageWidth ) * w; } // Set Center var y = ( wrapperHeight - h ) / 2; var x = ( wrapperWidth - w ) / 2; jQuery( this ).css( { 'height': h + 'px', 'width': w + 'px', 'top': y + 'px', 'left': x + 'px' } ); }); }