<html>
<head>
<title>Health e-Learning</title>
<link rel="stylesheet" href="../hexml.pack.css" type="text/css" />
<script type="text/javascript" src="../hexml.pack.js"></script>
<style type="text/css">
	body, html {
		margin: 0px;
		padding: 0px;
	}
	#linkViewer {
		padding: 0;
		border-spacing: 0;
		width: 100%;
		border: 0;
	}

	#viewerHeader {
		height: 80px;
		width: 100%;
		border-bottom: 2px #000080 solid !important;
		background-color:#fff;
	}
	ul#toolsLinks a {
		display: block;
		width: 100%;
		text-align: center;
		vertical-align: bottom;		
	}
	ul#toolsLinks li {
		width: 90px;
		text-align: center;
		float: right;
		padding: 5px !important;
		padding-left: 5px !important;
		background: none;
		margin-left: 0px !important;
		vertical-align: bottom;
	}
	ul#toolsLinks {
		height: 70px;
		margin: 0 !important;
		float: right;
		list-style: none !important;
		padding: 0px !important;
		padding-left: 0px !important; 
	}
	
	ul#toolsLinks img {
		height: 35px;
		margin-bottom: 5px;
	}
</style>
</head>
<body>
	<table id="viewerHeader">
		<tr style="vertical-align: middle">
			<td><img src="../banner_logo.gif" id="logo"/></td>
			<td style="text-align: right; width: 50%">
				<ul id="toolsLinks">
					<li>
					<a id="returnLink" title="Click here to return to your course material" href="#">
						<img src="../close-icon.png"/>
						<br/>Close
					</a>
					</li>
					<li>
					<a id="brokenLink" title="Click here to report a broken link" href="#">
						<img src="../broken-icon.png"/>
						<br/>Broken link ?
					</a>
					</li>
					<li>
					<a id="bookmarkLink" title="Bookmark this article" href="#">
						<img src="../bookmark-icon.png" align="bottom"/>
						<br/>Bookmark
					</a>
					</li>
					<li>
					<a id="printLink" title="Print this article" href="#">
						<img src="../print-icon.png"/>
						<br/>Print
					</a>		
					</li>
				</ul>
			</td>
		</tr>
	</table>
	<script type="text/javascript">
		var linkViewer = window.parent.document.getElementById('mainFrame');
		var temp = window.parent.location.search.substring(1).split("&");
		var params = {};
		for (var i=0; i<temp.length; i++) {
			var temp2 = temp[i].split('=');
			params[decodeURIComponent(temp2[0])] = decodeURIComponent(temp2[1]);
		}
		
		linkViewer.src = params.url;

		//print article
		jQuery("#printLink").click(function(){
			window.parent.mainFrame.focus();
			window.parent.print();			
		});

		//broken link
		jQuery('#brokenLink')
			.click(function() {
				jQuery(this)
					.html("Please wait...")
					.unbind('click')
					.click(function() {
						return false;
					})
				;

				jQuery.ajax({
					url : "http://www.health-e-learning.com/reportLink.php?jsoncallback=?",
					data : params,
					dataType : "jsonp",
					success: function(data, textStatus) {
								if(data.success == true) {
									showAlertBox("Thanks for letting us know. We will fix it as soon as possible.");
								}
								else {
									var subject = encodeURIComponent("Broken link in " + params.course + " (Topic " + params.topic + ")");
									var body = encodeURIComponent(params.course + " Topic " + params.topic + " (" + params.url + ")");
									var mailToURL = "mailto:tech@health-e-learning.com?subject=" + subject + "&body=" + body;
									window.location = mailToURL;

								}
								jQuery("#brokenLink").html("Thank you!");
							}
				});
				return false;
			})
		;

		//close window
		if (window.parent.opener) {
			jQuery('#returnLink')
				.click(function() {
					window.parent.close();
					return false;
				});
		}
		else {
			alert("Please close manually this window !");
		}

		//bookmark	
		jQuery("#bookmarkLink").click(function(event){
			event.preventDefault(); // prevent the anchor tag from sending the user off to the link

			var title = "Health eLearning Article, Course: "+ params.course +" Topic: "+ params.topic;
	
			if (window.sidebar) { // Mozilla Firefox Bookmark
				window.sidebar.addPanel(title, params.url,"");
			} else if( window.external ) { // IE Favorite
				window.external.AddFavorite( params.url, title);
			} else if(window.opera) { // Opera 7+
				return false; // do nothing - the rel="sidebar" should do the trick
			} else { // for Safari, Konq etc - browsers who do not support bookmarking scripts (that i could find anyway)
				 alert('Unfortunately, this browser does not support the requested action,'
				 + ' please bookmark this page manually.');
			}

		});
		
	</script>
</body>
</html>