/*
E-Pulse JavaScript
Matt Pilz
2011
*/

// Define list of URLs to exclude
var excludedURLS = new Array();
excludedURLS[0] = "http://srdweb1/";
excludedURLS[1] = "http://srdwebtest/";
excludedURLS[2] = "http://mclweb/";
excludedURLS[3] = "http://mclwebdev/";
excludedURLS[4] = "http://mcl-sp1/";

// Document load
$(document).ready(function() {

});

// Handle Clean-up
function cleanup() {

	// Remove  non-breaking spaces from main content
	$("#main").html(jQuery.trim($("#main").html().replace(/&nbsp;/g,' ')));

	if($("#sidebox").length > 0)
	{
		$("#sidebox").html(jQuery.trim($("#sidebox").html().replace(/&nbsp;/g,' ')));	
	}

	// Clean-up internal links and text if viewing Pulse externally
	if (host == "e-pulse.info" || host == "www.e-pulse.info"){

		// Remove all internal hyperlinks
		$("a").each(function() {
			linkURL = $(this).attr("href");
			for(var i=0; i<excludedURLS.length; i++)
			{
				intranetCheck = linkURL.indexOf(excludedURLS[i]);
				if(intranetCheck > -1)
				{
					$(this).replaceWith($(this).text());
				}
			}
		});
		
		// Hide all elements that have the class 'extHide'
		$(".extHide").hide();
		
		// Revise DOE Classes announcement text
		$(".extClasses").text(" is available on the intranet.");
		
		// Revise Ask Pulse contact information
		$(".extAskPulseA").text("on the intranet ");
		$(".extAskPulseB").html('<a href="mailto:dorshorst.deb@marshfieldclinic.org?subject=Pulse">e-mail</a>');
		
		// Revise Giveaway link information
		$(".extGiveawayURL").html("<strong><em style='color: #7f1739;'>Please revisit this page on the clinic's intranet to electronically submit your answer.</em></strong>");
	}
}

window.onload = cleanup;

