$(document).ready(function(){
						   
						   
jQuery.easing.def = "easeInQuart";		




function minisite() {
	 var viewportWidth = $(window).width();
	
	if(viewportWidth > 720) {
  
	var altezza = "78px";
	$("div.content").css('padding', '50px 10px 10px 282px' );
}else{

    var altezza = "118px";
	$("div.content").css('padding', '50px 10px 10px 10px' );

    
}

$("#menu_bertoli div.navigazione, #menu_bertoli span").css('height', altezza );

$("#content_menu_izo").css('padding-top', altezza );

}


minisite();



$(window).resize(function() {
 
  minisite();
});
  








// IZOTOPE

 var $container = $('#menu_izo');

    $('#menu_prodotti').find('a').click(function(){
												 
		if( $(this).attr('id') == "cata") { return} else {										 
      // get href attribute, minus the #, plus a . to make it a class
      var filterName = '.' + $(this).attr('href').slice(1);
      filterName = filterName === '.show-all' ? '*' : filterName;
      $container.isotope({ filter: filterName });
	  
	  

		
      return false;}
    });

    
      // sorting
      $('#sort a').click(function(){
        // get href attribute, minus the #
        var $this = $(this),
            sortName = $this.attr('href').slice(1),
            asc = $this.parents('.sort').hasClass('asc');
        $container.isotope({ 
          sortBy : sortName,
          sortAscending : asc
        });
        return false;
      });

    // change size of clicked element
    $container.find('.element').live('click', function(){
      $(this).toggleClass('large');
      $container.isotope('reLayout');
    });

    // toggle variable sizes of all elements
    $('#toggle-sizes').find('a').click(function(){
      $container
        .toggleClass('variable-sizes')
        .isotope('reLayout');
      return false;
    });

    
      // change layout
      var isHorizontal = false;
      $('#layouts a').click(function(){
        var mode = $(this).attr('href').slice(1);
            wasHorizontal = isHorizontal;
        isHorizontal = $(this).hasClass('horizontal');
  
        if ( wasHorizontal !== isHorizontal ) {
          // need to do some clean up for transitions and sizes
          var style = isHorizontal ? 
            { height: '80%', width: $container.width() } : 
            { width: 'auto' };
          // stop any animation on container height / width
          $container.filter(':animated').stop();

          $container.addClass('no-transition').css( style );
          setTimeout(function(){
            $container.removeClass('no-transition').isotope({ layoutMode : mode });
          }, 100 )
        } else {
          // go ahead and apply new layout
          $container.isotope({ layoutMode : mode });
    
        }
  
        return false;
      });

          $('#insert a').click(function(){
        var i = Math.ceil( Math.random()*3 + 1 ),
            newEls = '';
        while ( i-- ) {
          newEls += fakeElement.create();
        }
        var $newEls = $( newEls )
        $container.isotope( 'insert', $newEls );

        return false;
      });

      $('#append a').click(function(){
        var i = Math.ceil( Math.random()*3 + 1 ),
            newEls = '';
        while ( i-- ) {
          newEls += fakeElement.create();
        }
        var $newEls = $( newEls )
        $container.append( $newEls ).isotope( 'appended', $newEls );

        return false;
      });

    $('#shuffle a').click(function(){
      $container.isotope('shuffle');
      return false;
    });

    
      // switches selected class on buttons
      $('#options').find('.option-set a').click(function(){
        var $this = $(this);

        // don't proceed if already selected
        if ( !$this.hasClass('selected') ) {
          $this.parents('.option-set').find('.selected').removeClass('selected');
          $this.addClass('selected');
        }

      });

    

    $(function(){

      // hacky way of adding random size classes
      $container.find('.element').each(function(){
        if ( Math.random() > 0.6 ) {
          $(this).addClass('width2');
        }
        if ( Math.random() > 0.6 ) {
          $(this).addClass('height2');
        }
      });


      $container.isotope({
        itemSelector : '.element',
        // layoutMode : 'fitRows',
        masonry : {
          columnWidth : 136
        },
        masonryHorizontal : {
          rowHeight: 136
        },
        cellsByRow : {
          columnWidth : 240,
          rowHeight : 240
        },
        cellsByColumn : {
          columnWidth : 240,
          rowHeight : 240
        },
        animationEngine : $.browser.opera ? 'jquery' : 'best-available',
        // animationEngine : 'jquery',
        getSortData : {
          symbol : function( $elem ) {
            return $elem.attr('data-symbol');
          },
          category : function( $elem ) {
            return $elem.attr('data-category');
          },
          number : function( $elem ) {
            return parseInt( $elem.find('.number').text(), 10 );
          },
          weight : function( $elem ) {
            return parseFloat( $elem.find('.weight').text().replace( /[\(\)]/g, '') );
          },
          name : function ( $elem ) {
            return $elem.find('.name').text();
          }
        }
      });


    });// JavaScript Document








});




