/**
 * Front Page Tabs
 * This allows the page tabs to display each tab separately
 */
if (Drupal.jsEnabled) {
	
	$(document).ready( function() {
		
		//Drupal.trace( BrowserDetect.browser );
    
    if ( $("#front-page-menu-tabs ul.menu").length > 0 ) { //If this is on the page, run it
    
      $("div#front-page-menu-tabs ul.menu li.leaf a").bind( 'click', function () {
        
        if ( $(this).parent().hasClass('first') ) {
                    
          //Lodging & Deals
          $("#front-page-menu-tabs").removeClass( 'local-spotlight' ).removeClass( 'breck-this-week' );
          $("#view-id-nodequeue_3-page, .panels-flexible-row-6-3-inside").css( "display", "none" );
          $(".panels-flexible-row-6-1").css( "display", "block" );
          
        } else if ( $(this).parent().hasClass('last') ) {
          
          //Breck this Week -> Trumba Widgets
          $("#front-page-menu-tabs").addClass( 'breck-this-week' ).removeClass( 'local-spotlight' );
          $("#view-id-nodequeue_3-page, .panels-flexible-row-6-1").css( "display", "none" );
          $(".panels-flexible-row-6-3-inside").css( "display", "block" );
          
          if ( BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Explorer' ) {
            //reload trumba widgets in firefox!
            window.frames["trumba-spud-date-finder.iframe"].location.reload();
            window.frames["trumba-spud-upcoming-crawler.iframe"].location.reload();
          }
          
        } else {
          
          //Local Spotlight
          $("#front-page-menu-tabs").addClass( 'local-spotlight' ).removeClass( 'breck-this-week' );
          $(".panels-flexible-row-6-3-inside, .panels-flexible-row-6-1").css( "display", "none" );
          $("#view-id-nodequeue_3-page").css( "display", "block" );
          
        }
        
        return false; //This needs to return false, so it does not redirect
      
      } );
    
    }
    
    //I had to add this here, so I could just add some blank targets to these images
    $("a.imagecache-imagelink").attr( "target", "_blank");
    
    //Photo Gallery Rolloevers & Image Swap
    $("a.imagecache-photogallery_thumbnails").bind( 'mouseover', function() {
      
      $(this).children("img.imagecache-photogallery_thumbnails").addClass("opacity");
      
      return false;
    
    } ).bind( 'mouseout', function() {
      
      $(this).children("img.imagecache-photogallery_thumbnails").removeClass("opacity");
      
      return false;
    
    } ).bind( 'click', function() {
      
      Drupal.trace( $(this).parent().attr("class").replace("field-item ", "") );
      var item = $(this).parent().attr("class").replace("field-item ", "");
      $(".photo-gallery-image-full div.field-item").hide();
      $("." + item ).show();
      
      return false;
    
    } );
    
    //Select list form submit
    $("#edit-field-gallery-category-value-many-to-one").bind( 'change', function() {
      
      Drupal.trace( "This is changing" );
      
      $("form#views-exposed-form-photo-gallery-gallery-page-1").submit();
      
    } );
	
	} );

}