// JavaScript Document

$(document).ready(function() {



 
  fleXenv.initByClass("flexcroll");
  
  
      
    
   
      $(function(){
  
      var $container = $('#content'),
          // object that will keep track of options
          isotopeOptions = {},
          // defaults, used if not explicitly set in hash
          defaultOptions = {
            filter: '.featured',
            layoutMode: 'masonry'
          };
      
      
     
  
      var setupOptions = $.extend( {}, defaultOptions, {
       itemSelector : '.post-single',
        masonry : {
          columnWidth : 8
        }
        
      });
  
      // set up Isotope
      $container.isotope( setupOptions );
  
      var $optionSets = $('#filtersholder').find('.option-set'),
          isOptionLinkClicked = false;
  
      // switches selected class on buttons
      function changeSelectedLink( $elem ) {
        // remove selected class on previous item
        $elem.parents('.option-set').find('.active').removeClass('active');
        // set selected class on new item
        $elem.addClass('active');
      }
  
  
      $optionSets.find('a').click(function(){
        var $this = $(this);
        // don't proceed if already selected
        if ( $this.hasClass('active') ) {
          return;
        }
        changeSelectedLink( $this );
            // get href attr, remove leading #
        var href = $this.attr('href').replace( /^#/, '' ),
            // convert href into object
            // i.e. 'filter=.inner-transition' -> { filter: '.inner-transition' }
            option = $.deparam( href, true );
        // apply new option to previous
        $.extend( isotopeOptions, option );
        // set hash, triggers hashchange on window
        $.bbq.pushState( isotopeOptions );
        isOptionLinkClicked = true;
        return false;
      });

      var hashChanged = false;

      $(window).bind( 'hashchange', function( event ){
        // get options object from hash
        var hashOptions = window.location.hash ? $.deparam.fragment( window.location.hash, true ) : {},
            // do not animate first call
            aniEngine = hashChanged ? 'best-available' : 'none',
            // apply defaults where no option was specified
            options = $.extend( {}, defaultOptions, hashOptions, { animationEngine: aniEngine } );
        // apply options from hash
        $container.isotope( options );
        // save options
        isotopeOptions = hashOptions;
    
        // if option link was not clicked
        // then we'll need to update selected links
        if ( !isOptionLinkClicked ) {
          // iterate over options
          var hrefObj, hrefValue, $selectedLink;
          for ( var key in options ) {
            hrefObj = {};
            hrefObj[ key ] = options[ key ];
            // convert object into parameter string
            // i.e. { filter: '.inner-transition' } -> 'filter=.inner-transition'
            hrefValue = $.param( hrefObj );
            // get matching link
            $selectedLink = $optionSets.find('a[href="#' + hrefValue + '"]');
            changeSelectedLink( $selectedLink );
          }
        }
    
        isOptionLinkClicked = false;
        hashChanged = true;
      })
        // trigger hashchange to capture any hash data on init
        .trigger('hashchange');

    });
	
	
	
	

$(document).ready(function() {
    $(".post-single.link").click(function() {
  window.location = $(this).find("h2:first a:first").attr("href");
});



	
		//select and style first post
		//$('.post-single:first').addClass('big').removeClass('small');
		//$('.post-single:first').find('.news').attr('style' , 'height: 160px;');
		
		//turn home nav item into logo
		//$('#filters li a:first').html('<h1>We<span class="current_page_item">Make</span>Trulia</h1>').css('margin-top', '-27px').css('padding-right', '40px') ;
		
		//
		//$('nav#filters > li > a:last').css('padding-right' , '0px')
		
//------------------ post fades ------------------


//			$('.post-single').hover(function(){
 //           $('img', this).fadeTo("normal", 1)},
//			function() {
//	$('img',this).fadeTo("fast", 1);

			
//  });


		
$('#content').delay(500).fadeTo('slow',1)

	$('.post-single').hover(function(){

            $(".excerpt",this).fadeTo("fast", 1);
			  $(".excerpt p",this).slideDown();
			},
        function(){
             $(".excerpt",this).fadeTo("fast", 0);
			  $(".excerpt p",this).slideUp();
					});
					
					
			
					

//---------- add active class ------------------
 $(document).ready(function(){
	$('.slideshow-content').qtip({
      content: 'Click for Next Image',
      position: {
         my: 'top center',
         target: 'mouse',
         viewport: $(window), // Keep it on-screen at all times if possible
         adjust: {
            x: 10,  y: 10
         }
      },
      hide: {
         fixed: true // Helps to prevent the tooltip from hiding ocassionally when tracking!
      },
      style: 'tooltip'
   });
});


	
	
	
	
    });
    });
	 	
        
        
        
      
