(function($){
	$.fn.frypeSay = function(){
		var jQueryMatchedObj = this;
		
		function _initialize(){
			_start(this);
			return false;
		}
		
		function _start(clicked){
			$('embed, object, select').css({ 'visibility' : 'hidden' });
			_set_interface(clicked);
		}
		
		function _set_interface(clicked){
			var url = clicked.href;
			$('body').append('<div id="screen"></div><div id="popup"><div class="close"><a href="#" title="Close"><span>Close</span></a></div><h1>Ieteikt Draugiem.lv</h1><div class="clr"></div><iframe src="' + url + '" id="InfoBox" name="InfoBox" width="592px" height="500px"></iframe></div>');
			$('.close a').click(function(){
				_finish();
				return false;
			});
			$('#sayFrame').unload(function(){
				_finish();
				return false;
			});
		}
		function _finish() {
			$('#popup').remove();
			$('#screen').fadeOut(function() { $('#screen').remove(); });
			// Show some elements to avoid conflict with overlay in IE. These elements appear above the overlay.
			$('embed, object, select').css({ 'visibility' : 'visible' });
		}
		this.unbind('click').click(_initialize);
	}
})(jQuery);