// AddThis 
  function addAddThis() {
	var urlToUse = (("https:" == document.location.protocol) ? "https://s7.addthis.com/js/250/addthis_widget.js?pub=methodistil" : "http://s7.addthis.com/js/250/addthis_widget.js?pub=methodistil");
	$("div.AddThis").append("<p>" +
				"<!-- AddThis Button BEGIN -->" +
					"<a href=\"http://www.addthis.com/bookmark.php?v=250&pub=methodistil\" onmouseover=\"return addthis_open(this, '', '[URL]', '[TITLE]')\" onmouseout=\"addthis_close()\" onclick=\"return addthis_sendto()\">" +
					"<img src=\"/imgs/lg-share-en.gif\" width=\"125\" height=\"16\" alt=\"Bookmark and Share\" style=\"border:0\"/>" +
					"</a>" +
					"<script type=\"text/javascript\" src='" + urlToUse + "'></script>" +
				"<!-- AddThis Button END -->" +
	"</p>");
	}
$(document).ready(function(){addAddThis();});

// VisitorType
$(document).ready(function(){
	// adding divs to VisitorType for styling
	$('#VisitorType a.Toggle').wrapInner("<span></span>");
	$('#VisitorType .cmspanel ul').wrap("<div id=\"VisitorFlyout\" class=\"Flyout\"><div class=\"Dec\"><div class=\"Dec2\"></div></div></div>");
	// toggle class
	$('#VisitorType').hover(
		function(){
			$('#VisitorType a.Toggle').addClass('Over');
	},
		function() {
			$('#VisitorType a.Toggle').removeClass('Over');
		}
	);
	
	//moving flyout panels to be within the MainNav
    $('#MainNav li:nth-child(2)').addClass('Second');
    $('#MainNav li:nth-child(3)').addClass('Third');
    $('#MainNav li:nth-child(4)').addClass('Fourth');
    $('#MainNav li:nth-child(5)').addClass('Fifth');

    $('#Flyout1').appendTo('#MainNav li.First');
    $('#Flyout2').appendTo('#MainNav li.Second');
    $('#Flyout3').appendTo('#MainNav li.Third');
    $('#Flyout4').appendTo('#MainNav li.Fourth');
    $('#Flyout5').appendTo('#MainNav li.Fifth');

    //remove the main nav drop down if .cmspanel doesn't exist or is empty
    $('.Flyout .FlyoutInner:empty').parent().parent().parent().remove();
    $('.Flyout .FlyoutInner .cmspanel:empty').parent().parent().parent().parent().remove();

    //keeping active class on main nav li when hover on Flyout
    $('#MainNav li.Last a').addClass('Last');
    $('#MainNav li.First a').addClass('First');
    $('#MainNav li').hover(function () {
        $(this).toggleClass('FlyoutActive');
    });

});
// Extras
$(document).ready(function(){
	$('#MainNav').addClass("ClearFix");
});
