/*
 * document ready, init all behaviors
 *
 */
$(function() {
	
	humana.init({
		overlay: $('input[type="text"]').not('.disable_overlay'),
		round: [$('#search input[name="search"]'), $('#tabset_nav a'), $('#search input[name="q"]')],
		equalize: [ //{cols: $('#tab1 > div'),type: 'multi'},
		{
			cols: $('#tab2 > div'), type: 'simple'}, {
			cols: $('#tab3 > div'), type: 'multi'}, {
			cols: $('#tab4 > div'), type: 'simple'}]
	});
	humana.pw_input($('#member_form_password'), $('#member_form_password-actual'));
	humana.pw_input($('#password'), $('#password-actual'));
	humana.nav.init();
	
	/**
	 * Only run the slideshow code if more than one slide is present. This allows us to leave the markup and JavaScript
	 * 	intact and have only one init call.
	 */
	if ($('#slideshow .slide').length > 1) {
		humana.slideshow.init({
			id: '#slideshow',
			controls: true
		});
	}
	
	humana.tabs.init({id: '#tabset'});
	humana.carousel.init([$('#get_coverage_carousel')]);
	humana.mastnav.init([0, 2, 3], {
		0: [],
		2: [{
			'title': '&raquo; for Members &amp; Visitors',
			'url': 'http://www.humana.com/'
		}, {
			'title': '&raquo; for Employers &amp; Administrators',
			'url': 'http://www.humana.com/employers/'
		}, {
			'title': '&raquo; for Providers',
			'url': 'http://www.humana.com/providers/'
		}, {
			'title': '&raquo; for Pharmacists',
			'url': 'http://www.humana.com/pharmacists/'
		}, {
			'title': '&raquo; for Agents &amp; Brokers',
			'url': 'http://www.humana.com/agents/'
		}, {
			'title': '&raquo; for Government &amp; Public Sectors',
			'url': 'http://www.humana.com/resources/about/company_profile/business_units.aspx'
		}, {
			'title': '&raquo; Other Humana Websites',
			'url': 'http://www.humana.com/resources/about/company_profile/business_units.aspx'
		}],
		3: [{
			'title': '&raquo; Humana News',
			'url': 'http://www.humana.com/resources/about/news/'
		}, {
			'title': '&raquo; Company Profile',
			'url': 'http://www.humana.com/resources/about/company_profile/'
		}, {
			'title': '&raquo; Healthcare Innovation',
			'url': 'http://www.humana.com/resources/about/healthcare_innovation/'
		}, {
			'title': '&raquo; Corporate Responsibility',
			'url': 'http://www.humana.com/resources/about/corporate/'
		}, {
			'title': '&raquo; Public Policy',
			'url': 'http://www.humana.com/resources/about/public_policy/'
		}, {
			'title': '&raquo; Careers',
			'url': 'http://www.humana.com/resources/about/careers/'
		}]
	});
	if ($('#player').length > 0) {
		humana.video.init();
	}
	if ($('.pulldown').length > 0) {
		humana.selectify([$('.pulldown')], null, arguments.callee);
		$('select.pulldown').show();
		$('#nav_primary .submenu').bgiframe();
	}
	if ($('.condense').length > 0) {
		humana.selectify([$('.condense')], null, arguments.callee);
	}
	//if($('#page_wrapper.medicare').length > 0){ humana.selectify([$('.condense')], null, arguments.callee); }
	humana.prepare_gmaps();
	
	// Paginate Content
	humana.pagination.article();
	humana.pagination.video_list();
	
	// Core Metrics Opt Out Page
	$('#frmTrackingOptout').show().submit(function() {
		cmloader.optout.optResultWindow(this);
	});
	$('#view_optout_status').css('display', 'inline-block').click(function() {
		cmloader.optout.viewStatusWindow(this);
	});
});

// New global functionality
$(document).ready(function()
{
	$("#other_humana_websites h4").click(function(e)
	{
		$(this).parent().find("ul").slideDown('fast').show();
		
		$(this).parent().hover(function()
		{
		}, function()
		{
			$(this).parent().find("ul").slideUp('fast');
		});
		
	}).hover(function()
	{
		$(this).addClass("subhover");
	}, function()
	{
		$(this).removeClass("subhover");
	});
	
	if ($('.product_gallery').length > 0) {
		var max_height = 0;
		$(".product_gallery ul.items li").each(function(i)
		{
			if ($(this).height() >= max_height) {
				max_height = $(this).height();
			}
		});
		$(".product_gallery ul.items li").css("height", max_height);
		$(".product_gallery ul.items li ul li").css("height", "auto");
	}
});

cmloader.run();

