YOU_GOT_A_NEW_MSG = false;

jQuery(function($) {
	$(".navigation").each(function() {
		$(".navbutton").hide();
	});
	
	$("div.commands span.history a").each(function() {
		$(this).removeAttr('onclick');
	});
	
	$("#message_contacts .contact a, #message_contacts .history a").each(function() {
		var noframes = $(this).attr('href').match(/\?(.+)$/) ? "&noframesjs=1" : "";
		var newUrl = $(this).attr('href') + noframes;
		$(this).removeAttr("onclick");
		$(this).attr("href", newUrl);
	});
	
	if(YOU_GOT_A_NEW_MSG) {
		var $closeLink = $(document.createElement('a'))
							.text('Close this window')
							.css({
								marginTop : "5px"
							})
							.click(function(){
								$helpBox.hide();
							});

		var $helpBox = $(document.createElement('div'))
							.css({
								textAlign : "center"
							});
		
		$helpBox.addClass('msgBox')
				.appendTo(document.body)
				.hvCenter()
				.show();
		
		$helpBox.html('<object type="text/html" data="/message/index.php" style="width:460px; height: 485px; margin:0; padding:0; border:0; overflow: auto; float:auto;"></object>');
		$helpBox.append($closeLink);
	}
	
	$('div.message a, div.block_messages .footer a').each(function() {
		$(this).removeAttr('onclick');
		
		$(this).click(function(e) {
			e.preventDefault();

			var noframes = $(this).attr('href').match(/\?(.+)$/) ? "&noframesjs=1" : "";
			
			var $closeLink = $(document.createElement('a'))
							.text('Close this window')
							.css({
								marginTop : "5px"
							})
							.click(function(){
								$helpBox.hide();
							});
			
			var $helpBox = $(document.createElement('div'))
							.css({
								textAlign : "center"
							});
			
			$helpBox.addClass('msgBox')
			.appendTo(document.body)
			.hvCenter()
			.show();
			
			$helpBox.html('<object type="text/html" data="'+ $(this).attr('href') + noframes + '" style="width:450px; height: 485px; margin:0; padding:0; border:0; overflow: hidden;"></object>');
			$helpBox.append($closeLink);
		});
	});
	
	$(".helplink a").each(function() {
		$(this).removeAttr('onclick');
		
		$(this).click(function(e) {
			e.preventDefault();
			$.get($(this).attr('href'), null, function(data){
				var $helpcontent = $(data).find('#content div.generalboxcontent');
				
				var $helpBox = $(document.createElement('div'));
				
				$helpBox.addClass('helpBox')
						.html($helpcontent)
						.appendTo(document.body)
						.hvCenter()
						.fadeIn('slow');
				
				$(document.body).one('click', function() {
					$helpBox.fadeOut('slow');
				});
				
			});
		});
	});
	
	$("#embeddedhtml").each(function() {
		$(this).css('display', 'none');
		$.get($(this).attr('data'), null, function(data) {
			$(document.createElement("div")).attr("id", "htmlcontainer").html(data).appendTo($("div#content"));
		});
	});
	
	//replace My Courses
	$(".breadcrumb .first a").text('My Courses');
	
	//replace Available Courses
	if($("#middle-column div h2.headingblock").text() == 'Available Courses')
		$("#middle-column div h2.headingblock").text('My Courses');
});