// $Id: at.js,v 1.1.2.3 2010/12/01 13:48:24 jmburnz Exp $
(function ($) {
  /**
   * Insert WAI-ARIA Landmark Roles (Roles for Accessible Rich Internet Applications)
   * http://www.w3.org/TR/2006/WD-aria-role-20060926/
   */
  Drupal.behaviors.adaptivetheme = {
    attach: function(context) {

      // Set role="banner" on the header element.
      $("#page > header").attr("role", "banner");

      // Set role="main" on #main-content div.
      $("#main-content").attr("role", "main");

      // Set role="search" on search forms.
      $("#search-theme-form").attr("role", "search");

      // Set role="contentinfo" on the page footer.
      $("footer").attr("role", "contentinfo");

      // Set role=article on nodes.
      $(".article").attr("role", "article");

      // Set role="nav" on navigation-like blocks.
      $("nav, .admin-panel, #breadcrumb").attr("role", "navigation");
      
      // Set role="complementary" on navigation-like blocks.
      $("aside").attr("role", "complementary");

      // Set role="region" on section elements.
      $("section").attr("role", "region");

      // Set role="region" on section elements.
      $("#search-block-form, #search-form").attr("role", "search");

    }
  };

  /**
   * In most instances this will be called using the built in theme settings.
   * However, if you want to use this manually you can call this file
   * in the info file and user the ready function e.g.:
   * 
   * This will set sidebars and the main content column all to equal height:
   *  (function ($) {
   *    Drupal.behaviors.adaptivetheme = {
   *      attach: function(context) {
   *        $('#content-column, .sidebar').equalHeight();
   *      }
   *    };
   *  })(jQuery);
   */
  jQuery.fn.equalHeight = function () {
    var height = 0;
    var maxHeight = 0;

    // Store the tallest element's height
    this.each(function () {
      height = jQuery(this).outerHeight();
      maxHeight = (height > maxHeight) ? height : maxHeight;
    });

    // Set element's min-height to tallest element's height
    return this.each(function () {
      var t = jQuery(this);
      var minHeight = maxHeight - (t.outerHeight() - t.height());
      var property = jQuery.browser.msie && jQuery.browser.version < 7 ? 'height' : 'min-height';

      t.css(property, minHeight + 'px');
   });
  };

})(jQuery);;

(function ($) {
  $(document).ready(function() {
	$("#front-page-social-twitter").click(function() {
		$(".pane-block-14, .pane-block-13, .pane-block-15, .pane-poll-recent").hide()
		$(".pane-block-14").show()
		
		$("#front-page-social-twitter, #front-page-social-facebook, #front-page-social-youtube, #front-page-social-poll").removeClass("on")
		$(this).addClass("on")
	})
	
	$('#front-page-social-facebook').click(function() {
		$(".pane-block-14, .pane-block-13, .pane-block-15, .pane-poll-recent").hide()
		$(".pane-block-13").show()
		
		$("#front-page-social-twitter, #front-page-social-facebook, #front-page-social-youtube, #front-page-social-poll").removeClass("on")
		$(this).addClass("on")
	})
	
	$('#front-page-social-youtube').click(function() {
		$(".pane-block-14, .pane-block-13, .pane-block-15, .pane-poll-recent").hide()
		$(".pane-block-15").show()
		
		$("#front-page-social-twitter, #front-page-social-facebook, #front-page-social-youtube, #front-page-social-poll").removeClass("on")
		$(this).addClass("on")
	})
	
	$('#front-page-social-poll').click(function() {
		$(".pane-block-14, .pane-block-13, .pane-block-15, .pane-poll-recent").hide()
		$(".pane-poll-recent").show()
		
		$("#front-page-social-twitter, #front-page-social-facebook, #front-page-social-youtube, #front-page-social-poll").removeClass("on")
		$(this).addClass("on")
	})

	$('.event-more').hide();
	$('#view-all-event-datetime').click(function() {
		$('#view-all-event-datetime').hide();
		$('.event-more').show();
	});
	
	if($("#page-contact-us").length) {
		$("#header-contact").addClass("on")
	}
	if($("#page-about-us").length) {
		$("#header-about").addClass("on")
	}
	
	
	if($(".container-expandable").length) {
		$(".container-expandable H4").click(function() {
			if(!$(this).hasClass('on')) {
				$(this).addClass('on');
			} else {
				$(this).removeClass('on');
			}
			$(this).next('.inner').slideToggle('fast');
		})
	}
	
	if($("#view-job-opportunities").length) {
		$(".view-content > H3").click(function() {
			if(!$(this).hasClass('on')) {
				$(this).addClass('on');
			} else {
				$(this).removeClass('on');
                        }
			$(this).nextUntil('h3').slideToggle('fast');			
		})
		
		$("#jobsection-2 .views-field-title").click(function() {
			if(!$(this).hasClass('on')) {
				$(this).addClass('on');	
				$(this).nextAll('.views-field-body').slideToggle('fast');
                                $(this).next('.views-field-field-redirect').show();
			} else {
                                $(this).removeClass('on');
			        $(this).nextAll('.views-field-body').slideToggle('fast');
				$(this).next('.views-field-field-redirect').hide();
                        }
		});
		
		$("#jobsection-3 .views-field-title").click(function() {
			if(!$(this).hasClass('on')) {
                                $(this).addClass('on'); 
                                $(this).nextAll('.views-field-body').slideToggle('fast');
                                $(this).next('.views-field-field-redirect').show();
                        } else {
                                $(this).removeClass('on');
                                $(this).nextAll('.views-field-body').slideToggle('fast');
                                $(this).next('.views-field-field-redirect').hide();
                        }	
		});
	}
	
	if($(".job-opportunities-tabs").length) {
		$(".job-opportunities-tabs .tab-1 A").addClass("on");
		
		$(".job-opportunities-tabs A").click(function() {
			if(!$(this).hasClass('on')) {
				$(".job-opportunities-tabs A").removeClass("on");
				$(this).addClass("on");
				$(".pane-job").hide();
				
				var section = "#" + $(this).attr('rel');
				$(section).show();
			}
			
			return false;
		})
	}
		
/*
	if($("#edit-date-value-datepicker-popup-0").length) {
		$(".calendar-calendar .inline .calendar-day A").css('background-position', 'bottom left')
	}	
*/
	
	if($(".page-entertainment").length) {
		if($(".month-view").length) {
		$(".calendar-calendar .inline .calendar-month A").css('background-position', 'bottom right')
		} else if($(".day-view").length) { 
		$(".calendar-calendar .inline .calendar-day A").css('background-position', 'bottom left')
		}
	}
		
		
	
	if($("#media-landing-template").length) {
		$("#media-landing-template .center-wrapper:first").addClass("media-landing-template-bg");
	}

	if($(".views-widget-filter-date_filter") && $("#views-exposed-form-calendar-calendar-1").attr("action")) {
		var formAction = $("#views-exposed-form-calendar-calendar-1").attr("action");
		if (formAction.match(/^\/entertainment\/\d\d\d\d-\d\d-\d\d$/))
			$(".views-widget-filter-date_filter").show();
		else
			$(".views-widget-filter-date_filter").hide();
	}

	$("#edit-date-value-datepicker-popup-0").change(function() {
		if(this.value.match(/^\d\d\d\d-\d\d-\d\d$/)) {
			window.location.href = '/entertainment/' + $("#edit-date-value-datepicker-popup-0").val();
		}
        });

  });
  
  

})(jQuery);
;

