$(document).ready(function() {

// For Mobile Template: if any div.cmspage is empty, let's remove it -- avoids padding on empty pages.			
	$("#Mobile div").each(function(i, el) {
    // Remove white space
    var html = $(el).html().replace(/\s+/, "");
    // Check if element is :empty or length of html is zero
    if ($(el).is(":empty") || html.length == 0)
        $(el).remove();
	});


$('body#Mobile .ERWTRow span a')
   .each(function()
   { 
      this.href = this.href.replace(/mymethodist.net/, document.domain);
      this.href = this.href.replace(/www./, '');
      this.href = this.href.replace(/services.urgent-care/, 'mobile/UrgentCare');
   });

});  //END DOC READY

//client stuff
function addTextSizer()
{
	var imgPath = '/imgs/icons/';
	var theHref = 'href="#"';
	$("#Col1 #PageToolsWrapper").after("<div id=\"TextSizer\" class=\"ClearFix\"><div>" +
			"<h2>Text Size</h2>" +
			"<ul>" +
				"<li>" +
					"<a class=\"Normal\"" + theHref + "><img src=\"" + imgPath + "small_font.gif\" alt=\"Small Font Size\" /></a>" +
				"</li>" +
				"<li>" +
					"<a class=\"Large\"" + theHref + "><img src=\"" + imgPath + "medium_font.gif\" alt=\"Medium Font Size\" /></a>" +
				"</li>" +
				"<li>" +
					"<a class=\"X-Large\"" + theHref + "><img src=\"" + imgPath + "large_font.gif\" alt=\"Large Font Size\" /></a>" +
				"</li>" +
			"</ul>" +
		"</div></div>");
	$("a.Normal").click(function() { setFontSize('normal'); return false; });
	$("a.Large").click(function() { setFontSize('large'); return false; });
	$("a.X-Large").click(function() { setFontSize('x-large'); return false; });
}
function addPageTools()
{
	$("#PageToolsWrapper").append("<div id=\"PageTools\">" +
		"<h2 class=\"Hide\">Page Tools</h2>" +
		"<ul>" +
			"<li class=\"Print\">" +
				"<a href=\"#\">Printer Friendly</a>" +
			"<li class=\"Email\">" +
				"<a href=\"#\">Email Page</a>" +
			"</li>" +
			"</li>" +
		"</ul>" +
	"</div>");
	var clientDomainName = 'MyMethodist.net';
	var clientSiteName = 'MMCI';
	var titleEl = document.getElementsByTagName('title')[0];
	var currentPageTitle = "";
	if (titleEl.text)
	{
		currentPageTitle = escape(titleEl.text);
	}
	else
	{
		currentPageTitle = escape(title.data);
	}
	var currentPageUrl = document.location;
	var emailSubject = clientDomainName + ": " + currentPageTitle;
	var emailHref = "mailto:?subject=" + emailSubject + "&body=I thought you would be interested in a page on the " + clientSiteName + " Web site: " + currentPageTitle + " - " + currentPageUrl;
	$("li.Email a").attr({ href: emailHref});
	$("li.Print a").click(function() { print(); return false; });
}
$(document).ready(function(){addPageTools();});
$(document).ready(function(){addTextSizer();});

// extras
$(document).ready(function(){
						   
	$('body.Home #Col2 #Content .cmspanel').wrapInner('<div class="Dec1"><div class="Dec2"></div></div>');
	$('#Col3 .GreenBack').wrap('<div class="GreenBack2"></div>');
	$('#Col3 #FlashVideo').parent('.cmspanel').addClass("FlashPanel");
	$('#Col3 .cmspanel').addClass("ClearFix");
	$('body.mcon div.Right').appendTo("#MainNav");
	$('.Tab').addClass("ClearFix");
});