/*
	HealthPartners 2011
	hp global js
*/

var iframeHeight=function(data) {
	$("iframe.key-survey").height(data);
};

$(document).ready(function() {

		// active navagation
	$("ul#navigation li a[href^='/"+window.location.href.split('/')[3]+'/'+window.location.href.split('/')[4]+"/'"+"]").addClass("active");

		// ie-roundies
	if ($.browser.msie && $.browser.version <= 8 ) {
		DD_roundies.addRule('ul#navigation', '0 0 8px 8px');
		DD_roundies.addRule('#navigation a#home', '0 0 0 8px');
		DD_roundies.addRule('#navigation a#pharmacy', '0 0 8px 0');
		DD_roundies.addRule('.bordered', '8px');
		DD_roundies.addRule('.light-bordered', '8px');
		DD_roundies.addRule('.container-header', '8px 8px 0 0');
		DD_roundies.addRule('.aside-header', '8px 8px 0 0');
		DD_roundies.addRule('.aside-body', '0 0 8px 8px');
		DD_roundies.addRule('#logon-container', '4px');
		DD_roundies.addRule('#more-resources', '8px');
		DD_roundies.addRule('.promo', '8px');
		DD_roundies.addRule('#enrollment-tools', '8px');
  		DD_roundies.addRule('div.sub-nav-header', '8px 8px 0 0');
  		DD_roundies.addRule('div.sub-nav-content', '0 0 8px 8px');
  		DD_roundies.addRule('div.one-hundred-ninety-two', '8px 8px 8px 8px');
		DD_roundies.addRule('.aside-sub-navigation ul', '8px 8px 8px 8px');	
		DD_roundies.addRule('.aside-sub-navigation a#top', '8px 8px 0 0');	
		DD_roundies.addRule('.aside-sub-navigation a#bottom', '0 0 8px 8px');	
	}
		// ie-roundies
	if ($.browser.msie && $.browser.version >= 7 && $.browser.version <= 8 ) {
		DD_roundies.addRule('.container-body', '0 0 8px 8px');
	}	

		// Move the h1 title down when an #banner is present on the page
	if ($("#banner").length > 0 && $("#banner.transactions").length == 0) {
		$("h1").addClass("banner-title");
	}
	
		// Move the h1 title down when an #banner.transactions is present on the page
	if ($("#banner.transactions").length > 0 && $("#banner.transactions").length > 0) {
		$("h1").addClass("transactions-banner-title");
	}

		// YouTube Modal
	if ( !($.client.os == "iPad" || $.client.os == "iPhone") ) {
		$("a.youtube-modal").colorbox({iframe:true, innerWidth:725, innerHeight:445}).attr('href', function(i,h) {
			return h + ("?rel=0&amp;showinfo=0&amp;showsearch=0&amp;autoplay=1");
		});
	}
	
		// YouTube
	$("a.youtube").attr('href', function(i,h) {
		return h + ("?rel=0&amp;showinfo=0&amp;showsearch=0&amp;autoplay=0");
	});

		// Pivotal Redirect
	$("a[rel*=pivotal-redirect]").click( function() {
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "generic_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
		
		// Pivotal Compass Redirect
	$("a[rel*=pivotal-compass-redirect]").click( function() {
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "compass_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
	
		// Pivotal Empower Redirect
	$("a[rel*='pivotal-empower-redirect']").click( function() {	
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "empower_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp?plan_family=0036s|0036scd|0036f|0036fcd", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
	
		// Pivotal Traditional Redirect
	$("a[rel*='pivotal-traditional-redirect']").click( function() {
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "traditional_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp?plan_family=0040|0040cd", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
           
		// Pivotal Short Term Redirect 
	$("a[rel*='pivotal-short-term-redirect']").click( function() {
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "shortterm_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp?plan_family=0032cd", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
	
		// Pivotal Link90 Redirect 
	$("a[rel*='pivotal-link90-redirect']").click( function() {
		s.linkTrackVars = "eVar9,events";
		s.linkTrackEvents = "event5";
		s.events = "event5";
		s.eVar9 = "link90_IndividualQuote";
		s.t();
		_gaq.push(['_trackPageview', '/applications/pricing/']);
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp?plan_family=0042cd", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=860,height=700,resizable=yes,scrollbars=yes,toolbar=no,status=no");
		}
		return false;
	});
	
	
		// Pivotal Continue Redirect 
	$("a[rel*='pivotal-continue-redirect']").click( function() {
		if ($.browser.msie && $.browser.version > 5) {
			window.open("https://sales.healthpartners.com/everticals/entry_eConsumer.asp", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
		}
		else {
			window.location = '/public/plans/individual/apply-now/unsupported-browser-non-ie/';
		}
		return false;
	});
	
	
		// eHealth Continue Redirect 
	$("a[rel*='ehealth-continue-redirect']").click( function() {
		if ($.browser.msie && $.browser.version > 5) {
			window.location = '/public/plans/individual/apply-now/unsupported-browser-ie/';
		}
		else {
			window.open("https://healthpartners.inshealth.com/", "top","width=1024,height=740,resizable=no,scrollbars=yes,toolbar=no,status=no");
			
		}
		return false;
	});
	
	
		// Navigation Button Color Hover
	$("ul#navigation a").hover(function() {
    	$(this).stop().animate({backgroundColor: "#bcbcbc"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#dbdcdd"}, 100);
	});
	
	$("ul#navigation a.active").hover(function() {
    	$(this).stop().animate({backgroundColor: "#bcbcbc"});
	});
	
		// Ledger
	$ ('ul.ledger li:odd, table.ledger tr:odd').addClass("ledger-color");
	
		// Promo hover
	$(".promo.hover").hover(function() {
		$(this).stop().animate({backgroundColor: "#f2f2f2"}, 200);
	}, function() {
		$(this).stop().animate({backgroundColor: "#fff"}, 200);
	});
	
		// Container Hover
	$(".container.hover").hover(function() {
    	$(this).stop().animate({backgroundColor: "#f2f2f2"}, 200);
	}, function() {
		$(this).stop().animate({backgroundColor: "#fff"}, 200);
	});
		
		// Primary Button Color Hover
	$(".button").hover(function() {
		$(this).stop().animate({backgroundColor: "#df9800"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#efa300"}, 100);
	});

		// Secondary Button Color Hover
	$(".button.secondary").hover(function() {
    	$(this).stop().animate({backgroundColor: "#0c708c"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#50b3cf"}, 100);
	});

		// Clear Button Color Hover
	$(".button.clear").hover(function() {
    	$(this).stop().animate({backgroundColor: "#999"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#b3b3b3"}, 100);
	});
	
		// Go Green Color Hover
	$(".button.go-green").hover(function() {
    	$(this).stop().animate({backgroundColor: "#80bd31"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#98cf50"}, 100);
	});
	
		// Log-on Button
	$("#log-on-container input.button.go").hover(function() {
    	$(this).stop().animate({backgroundColor: "#3c9fcf"}, 100);
	}, function() {
		$(this).stop().animate({backgroundColor: "#50B3CF"}, 100);
	});

	
		// Table Data Hover
	$("table.data.hover tbody tr, table.data-results.hover tbody tr, table.data.ledger-hover tbody tr:odd, table.data-results.ledger-hover tbody tr:odd").hover(function() {
    	$(this).stop().animate({backgroundColor: "#eee"}, 200);
	}, function() {
		$(this).stop().animate({backgroundColor: "#fff"}, 300);
	});	
	
	$("table.data.ledger-hover tbody tr:even, table.data-results.ledger-hover tbody tr:even").hover(function() {
    	$(this).stop().animate({backgroundColor: "#eee"}, 200);
	}, function() {
		$(this).stop().animate({backgroundColor: "#f2f2f2"}, 300);
	});
	
		// URL rules
	
		// Font size increase for Medicare contract
	if ("/"+window.location.href.split('/')[3]+"/"+window.location.href.split('/')[4]+"/" == "/public/careers/") {
		$("ul#sub-navigation, div#search-form-container").hide();
	}

		// Font size increase for Medicare contract
	if ("/"+window.location.href.split('/')[3]+"/"+window.location.href.split('/')[4]+"/"+window.location.href.split('/')[5]+"/" == "/public/plans/medicare/") {
		$("ul#footer-fine-print li, ul#footer-fine-print li a").css("font-size","12px");
	}
	
		// URL rules - end
		
		// Urgent Care Wait Times Refresh
	if ($("iframe#urgent-care-wait-times-iframe").length > 0) {
		setInterval(function() {
            $.each($("iframe#urgent-care-wait-times-iframe"), function() {
                $(this).attr({
                    src: $(this).attr("src")
                });
            });
            return false;
		}, 300000);
	}
	
		// Gecko 1.9.0 or less font-face override
	$.each($.browser, function(i, val) {
   		if(i=="mozilla" && $.browser.version.substr(0,5)<="1.9.0") {
	  		$("#home-banner h2").css({'font-size' : '19px'});
	  	}
 	});

});
