﻿// JavaScript Document
(function ($)
{
	$.fn.extend(
	{
		share: function (type)
		{
			var url = escape(window.location);
			var title = escape(document.title);
			var winUrl = null;
			var directUrl = false;
			switch (type)
			{
				case "facebook.com":
					winUrl = "http://www.facebook.com/sharer.php?u=" + url + "&t=" + title;
					break;
				case "twitter.com":
					winUrl = "http://twitter.com/share?url=" + url;
					break;
				default:
					directUrl = true;
					winUrl = type;
					break;
			}
			if (winUrl != null)
			{
				$(this).click(function (e)
				{
					var options = "width=800,height=600,resizable=yes,scrollbars=yes,location=yes";
					if (directUrl == true) options += ",menubar=yes,status=yes";
					window.open(winUrl, "ShareWin", options);
				});
			}
			return false;
		},
		youtube: function (id, width, height)
		{
			if (id != undefined)
			{
				if (width == undefined) width = "100%";
				if (height == undefined) height = "100%";
				var str = "<object width='" + width.toString() + "' height='" + height.toString() + "'>";
				str += "<param name='movie' value='http://www.youtube.com/v/" + id + "?fs=1&amp;hl=en_GB'></param>";
				str += "<param name='allowFullScreen' value='true'></param>";
				str += "<param name='allowscriptaccess' value='always'></param>";
				str += "<param name='wmode' value='opaque'></param>";
				str += "<embed src='http://www.youtube.com/v/" + id + "?fs=1&amp;hl=en_GB' wmode='opaque' type='application/x-shockwave-flash' allowscriptaccess='always' allowfullscreen='true' width='" + width.toString() + "' height='" + height.toString() + "'></embed></object>";
				$(this).html(str);
			}
		}
	});
})(jQuery);
