﻿var tempMenuHolder;

$(function() {
				$('td[id*="MSOZoneCell_WebPartWPQ"]').children("table").addClass("StdWebPart");
				$('span.StdForm').parent().parent().parent().parent().addClass("StdForm");
				$('span.StdForm').parent().parent().parent().parent().children().children().children().children().children().children().children().children().addClass("StdForm");
				$('span.TrnsWebPart').parent().parent().parent().parent().parent().addClass("TrnsWebPart");
				$('div.av-NewsScrollerHolder').parent().parent().parent().parent().parent().addClass("TrnsWebPart");
				
				if (!($.browser.msie)) {
					$('div.punchbox').css("width", "250px");
					$('ul').css("margin-left", "-10px");
					$('.sa-LeftSideBar .ms-WPBody').css("margin-top", "-15px");
					$('.sa-LeftSideBar .ms-WPBody').css("width", "190px");
				}
				else
				{
					$('.sa-LeftSideBar .ms-WPBody').css("width", "200px");
					$('ul').css("margin-left", "25px");
					//$('ul').css("margin-right", "-25px");
				}
				
				$('.sa-LeftSideBar .ms-WPBody').css("padding-right", "0px");
				
				$('#ctl00_IdWelcome_ExplicitLogin').hide();
				$('input[type="submit"]').addClass('button');
				$('td.middleDivider').prev().css("padding-right", "20px");
				
				shuffleMenu();
				getSubsite();
});

function shuffleMenu() {
	try {
		if ($.browser.msie) {
			tempMenuHolder = $('.ms-topnav')[0].outerHTML;
			$('.ms-topnav')[0].outerHTML= $('.ms-topnav')[2].outerHTML;
			$('.ms-topnav')[2].outerHTML= tempMenuHolder;
												
			tempMenuHolder = $('.ms-topnav')[4].outerHTML;
			$('.ms-topnav')[4].outerHTML = $('.ms-topnav')[10].outerHTML;
			$('.ms-topnav')[10].outerHTML = tempMenuHolder;
			
			tempMenuHolder = $('.ms-topnav')[4].outerHTML;
			$('.ms-topnav')[4].outerHTML = $('.ms-topnav')[8].outerHTML;
			$('.ms-topnav')[8].outerHTML = tempMenuHolder;
		}
		else {
			tempMenuHolder = $('.ms-topnav')[0].innerHTML;
			$('.ms-topnav')[0].innerHTML = $('.ms-topnav')[2].innerHTML;
			$('.ms-topnav')[2].innerHTML = tempMenuHolder;

			tempMenuHolder = $('.ms-topnav')[4].innerHTML;
			$('.ms-topnav')[4].innerHTML= $('.ms-topnav')[10].innerHTML;
			$('.ms-topnav')[10].innerHTML= tempMenuHolder;
					
			tempMenuHolder = $('.ms-topnav')[4].innerHTML;
			$('.ms-topnav')[4].innerHTML= $('.ms-topnav')[8].innerHTML;
			$('.ms-topnav')[8].innerHTML= tempMenuHolder;
		}
				
		$('#zz1_TopNavigationMenun0Items').attr('id', 'tempDropDownID');
		$('#zz1_TopNavigationMenun1Items').attr('id', 'zz1_TopNavigationMenun0Items');
		$('#tempDropDownID').attr('id', 'zz1_TopNavigationMenun1Items');
				
		$('#zz1_TopNavigationMenun5Items').attr('id', 'zz1_TopNavigationMenun2Items');
				
		$('#zz1_TopNavigationMenun2Items').attr('id', 'tempDropDownID');
		$('#zz1_TopNavigationMenun4Items').attr('id', 'zz1_TopNavigationMenun2Items');
		$('#tempDropDownID').attr('id', 'zz1_TopNavigationMenun4Items');
	}
	catch(e) {}
	
	$('.ms-topNavContainer').css('visibility', 'visible');
}

function getSubsite() {
	var currentSubsite = -1;
	var url = window.location.href;
	var nohttp = url.split('//')[1];
	var subsiteAddress = nohttp.split('/')[1];

	//Press Releases -- special case
	if (nohttp.split('/')[1] == "Pages" && nohttp.split('/')[2] == "PressReleases.aspx")
		subsiteAddress = "about_us";
	
	//Press Releases single item -- special case #2
	if (nohttp.split('/')[1] == "Lists" && (nohttp.split('/')[2] == "Recent News" || nohttp.split('/')[2] == "Recent%20News"))
		subsiteAddress = "about_us";
	
	for (var i = 0; i < $('.ms-topnav a').length; i++) {
		nohttp = $('.ms-topnav a')[i].toString();
		nohttp = nohttp.split('//')[1];
		var menuSubsite = nohttp.split('/')[1];
		if (menuSubsite == subsiteAddress) {
			currentSubsite = i;
		}
	}
	
	if (currentSubsite >= 0) {
		$('table.ms-topnav a')[currentSubsite].style.height = "33px";
		$('table.ms-topnav a')[currentSubsite].style.background = "url('/Style%20Library/Images/topnavbluearrow.gif') no-repeat center";
	}
}