/**
 * clearFusionCMS script to display a preview mode icon & provide exit option.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS
 * @copyright Copyright (c) 2013 - 2016 fusionLib. All rights reserved.
 * @link http://clearFusionCMS.com
 */

$fl(document).ready(function() {
	// Load the CSS
	var link = document.createElement("link");
	link.rel = "stylesheet";
	link.href = "system/app/js/cfPreview.css";
	document.getElementsByTagName("head")[0].appendChild(link);

	// Add HTML to the page
	$fl('body').append('<div id="cfPreview">Preview</div>');

	// Handle click to exit preview
	$fl('#cfPreview').bind('click', function(evt) {
		window.location.href = window.location.protocol + '//' + window.location.host + window.location.pathname + '?__preview=false';
	});
});
