/*
	sdFrame version: 1.0 (tested with jQuery v1.2 or later)
	
	Feel free to use it! Credits, comments and suggestions are always welcome.
	
	Contact: nikos@savage-dreams.gr
	
	Files:
	sdFrame-1.0.js
	sdFrame.css
	sdFrame.png
	
	Usage:
	jQuery(document).ready(function($) {
		$("a[target*=sdFrame]").click(function () {
			sdFrame($(this).attr("href"), $(this).attr("title"));
			return false;
		});
	});
	
	<a href="Your link" target="sdFrame" title="Link title">Link text</a>
	
	OR
	
	<a href="javascript:sdFrame('Your link', 'Link title');">Link text</a>
*/

function sdFrame(href, title) {
	$('body').append('<span id="iframe"></span>');
	$('#iframe').append('<div id="iframeContainer"></div>');
	$('#iframeContainer').append('<div id="iframeLabel"><span id="iframeTitle">' + title + '</span><a id="iframeClose">Close this window</a></div>');
	$('#iframeContainer').append('<iframe src="' + href + '" name="sdFrame" id="sdFrame" width="100%" height="650px" marginwidth="0" marginheight="0" scrolling="auto" frameborder="0"></iframe>');
	
	$("#iframe").fadeIn("normal");
	
	/*$("#iframeContainer").draggable({
		handle: '#iframeLabel',
		iframeFix: true
	});*/
	
	$("#iframeClose").click(function () {
		$("#iframe").fadeOut("normal", function () {
			$(this).remove();
		});
	});
	
	$(document).keypress(function(e) {
		if (e.keyCode == 27) {
			$("#iframe").fadeOut("normal", function () {
				$(this).remove();
			});
		}
	});
}