// JavaScript Document
// Note all urls will have to be changed before going live

var rxhost= new String (window.location.hostname);

if (rxhost=="search.flu.gov")
{
   var rxs_navbase = "http://www.flu.gov";

}

$(document).ready(function(){

	var rxURL= new String (window.location);
						   
	$("#navigation ul li.active").find('img').attr('src',rxs_navbase+'/images/sys_images/btn-down-arrow-w.png');

	$("#navigation ul li").hover(
		function() {
			$(this).children('ul').show();
			if ($(this).hasClass('active') != true) {
 
                            /*
				if (rxURL.indexOf("Rhythmyx")>0)
				{
					$(this).children('a').css({'color': '#FFF', 'border-right-color': '#20687e', 'border-left-color': '#20687e', 'background': 'transparent url(../web_resources/flu/images/sys_images/nav-down-bg.png) repeat-x top left'});
				}
				else
				{
					$(this).children('a').css({'color': '#FFF', 'border-right-color': '#20687e', 'border-left-color': '#20687e', 'background': 'transparent url(/images/sys_images/nav-down-bg.png) repeat-x top left'});
				}
                            */

				$(this).children('a').css({'color': '#FFF', 'border-right-color': '#20687e', 'border-left-color': '#20687e', 'background': "transparent url(" + rxs_navbase + "/images/sys_images/nav-down-bg.png) repeat-x top left"});

				//$(this).children('a').css({'color': '#FFF', 'border-right-color': '#20687e', 'border-left-color': '#20687e', 'background': 'transparent url(/images/sys_images/nav-down-bg.png) repeat-x top left'});
				$(this).find('img').attr('src',rxs_navbase+'/images/sys_images/btn-down-arrow-w.png');
                     }
		},
		function() {
			$(this).children('ul').hide();
			if ($(this).hasClass('navItem1') == true && $(this).hasClass('active') != true) {
				//$(this).children('a').css({'color': '#335761', 'border-right-color': '#FFF', 'border-left-color': '#CCC', 'background': 'transparent url(/images/sys_images/nav-tip.png) no-repeat top right'});

                            /*
				if (rxURL.indexOf("Rhythmyx")>0)
				{
					$(this).children('a').css({'color': '#335761', 'border-right-color': '#FFF', 'border-left-color': '#CCC', 'background': 'transparent url(../web_resources/flu/images/sys_images/nav-tip.png) no-repeat top right'});
				}
				else
				{
					$(this).children('a').css({'color': '#335761', 'border-right-color': '#FFF', 'border-left-color': '#CCC', 'background': 'transparent url(/images/sys_images/nav-tip.png) no-repeat top right'});

				}
                            */
				$(this).children('a').css({'color': '#335761', 'border-right-color': '#FFF', 'border-left-color': '#CCC', 'background': "transparent url(" + rxs_navbase + "/images/sys_images/nav-tip.png) no-repeat top right"});
				$(this).find('img').attr('src',rxs_navbase+'/images/sys_images/btn-down-arrow.png');
			} else if ($(this).hasClass('active') != true) {
				$(this).children('a').css({'color': '#335761', 'border-right-color': '#FFF', 'border-left-color': '#CCC', 'background': 'none'});
				$(this).find('img').attr('src',rxs_navbase+'/images/sys_images/btn-down-arrow.png');
			};
		}
	);
	
	$(".sidebar.button").hover(
		function() {
			$(this).find('h3').css('color','#FFF');
			$(this).find('a').css('color','#FFF');
			$(this).children('div.top').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-orange-top.png)');
			$(this).children('div.mid').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-orange-mid.png)');
			if($(this).parent('div').hasClass('left-sidebar')) {
				$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-orange-bot-l.png)');
			} else {
				$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-orange-bot.png)');
			};
		},
		function() {
			if($(this).hasClass('gray') == true) {
				$(this).find('h3').css('color','#444');
				$(this).find('a').css('color','#444');
				$(this).children('div.top').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-gray-top.png)');
				$(this).children('div.mid').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-gray-mid.png)');
				if($(this).parent('div').hasClass('left-sidebar')) {
					$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-gray-bot-l.png)');
				} else {
					$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-gray-bot.png)');
				};
			};
			if($(this).hasClass('blue') == true) {
				$(this).children('div.top').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-blue-top.png)');
				$(this).children('div.mid').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-blue-mid.png)');
				if($(this).parent('div').hasClass('left-sidebar')) {
					$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-blue-bot-l.png)');
				} else {
					$(this).children('div.bot').css('background-image',rxs_navbase+'url(/images/sys_images/sidebar-blue-bot.png)');
				};
			};
		}
	);
	
	$('.sidebar.button').click(function() {
		var $pageURL = $(this).find('a').attr('href');
		location.replace($pageURL);
	});
	
	$('.sidebar.button').each(function(index) {

		var sidebarItemHeight = $(this).height() - 6;
		var sidebarArrowY = (sidebarItemHeight/2) - 7;
		$(this).children('div.arrow').css('top',sidebarArrowY+'px');
	});	
	
	$('.subnav .subsubnav ul li').last().addClass('last')
	
});
