$(document).ready(function(){
	var type = '?type=mini';
	var course_url = 'http://hootcourse.com/course/1928/r72vp/';
	
	// Add the shell style sheet if it hasn't already been added.
	if ($('link[href="http://hootcourse.com/assets/css/hootcourse_miniclient_shell.css"]').length == 0 && location.host != "hootcourse.com") {
		$('head').append('<link rel="stylesheet" href="http://hootcourse.com/assets/css/hootcourse_miniclient_shell.css" type="text/css" />');
	}
	
	// Insert the mini client
	// sanity check - make sure the mini-client isn't already on the page and the browser isn't IE6
	if($('#hootcourse_mini').length == 0 && !($.browser.msie && $.browser.version < 7.0 )) {
		init(course_url, type);
		$('#hootcourse_mini h1 a').click(function() {
		
			if(!$('#hcm_stream').attr('src')) { // Activate the iframe if the tab is opened
				$('#hcm_stream').attr('src', course_url+type);
			}
		
			if($('#hootcourse_mini').css('left') == '-321px') {
				$('#hootcourse_mini').animate({left: '0px'}, 500);
			} else {
				$('#hootcourse_mini').animate({left: '-321px'}, 500);
			}
			return false;
		})
	}
	
});

function init(course_url, type) {
	var markup = '\u003Cdiv id\u003D\u0022hootcourse_mini\u0022\u003E\u000A\u0009\u003Ch1\u003E\u003Ca href\u003D\u0022#\u0022\u003EHootCourse\u003C/a\u003E\u003C/h1\u003E\u0009\u000A\u0009\u003Cdiv id\u003D\u0022hcm_main\u0022\u003E\u0009\u0009\u000A\u0009\u0009\u003Ciframe frameborder\u003D\u00220\u0022 id\u003D\u0022hcm_stream\u0022 allowtransparency\u003D\u0022true\u0022\u003E\u003C/iframe\u003E\u000A\u0009\u003C/div\u003E\u000A\u003C/div\u003E';
	$(markup).appendTo('body');
}
