var FShareWidget;
if (!FShareWidget){
	FShareWidget = {
		getFShareStyleButtonCode: function(permalink, communityUcid, fshare_style) {
			var imageButtonUrls = {
				'large_size': 'http://static0.fluxstatic.com/-/Clients/Common/Img/widgets/FShare/btns/large_size.gif',
				'regular_size': 'http://static0.fluxstatic.com/-/Clients/Common/Img/widgets/FShare/btns/regular_size.gif',
				'f_large': 'http://static0.fluxstatic.com/-/Clients/Common/Img/widgets/FShare/btns/f_large.gif',
				'f_small': 'http://static0.fluxstatic.com/-/Clients/Common/Img/widgets/FShare/btns/f_small.gif',
				'template':'http://static0.fluxstatic.com/-/Clients/Common/Img/widgets/FShare/btns/_style_/FShare__size_.gif'
				};
				if (fshare_style.indexOf(":") != -1) {
					var styleParameters = fshare_style.split(":");
					var btnUrl = imageButtonUrls["template"].replace("_size_", styleParameters[0]).replace("_style_", styleParameters[1]);
					return this.getFShareImageButtonCode(permalink, communityUcid, btnUrl);
				}
			return this.getFShareImageButtonCode(permalink, communityUcid, imageButtonUrls[fshare_style]);
		},
		getFShareImageButtonCode: function(permalink, communityUcid, imageUrl) {
			var url = "http://www.flux.com/Share/DiscoverContent.aspx?community_ucid=" + communityUcid + "&permalink=" + encodeURIComponent(permalink) ;
			var windowName = null;
			var windowAttributes = "height=449,width=700,status=yes,toolbar=no,menubar=no,location=no";
			return "<img src='" + imageUrl + "' style='border:0;cursor:pointer;' onclick='window.open(&quot;" + url + "&quot;, &quot;" + windowName + "&quot;, &quot;" + windowAttributes + "&quot;)'/>";
		},
		displayFShareButtonCode: function(fshareButtonParameters) {
			var permalink = fshareButtonParameters["fshare_permalink"];
			if (typeof(permalink) == "undefined" || permalink == "{PERMALINK}")
				permalink = location.href;
			var communityUcid = fshareButtonParameters["fshare_id"];
			var fshare_style = fshareButtonParameters["fshare_style"];
			var fshare_image = fshareButtonParameters["fshare_image"];
			
			if (typeof(communityUcid) == "undefined" || (typeof(fshare_style) == "undefined" && typeof(fshare_image) == "undefined"))
				document.write("fShare widget has invalid arguments");
			else {
				if (typeof(fshare_style) != "undefined")
					document.write(this.getFShareStyleButtonCode(permalink, communityUcid, fshare_style));
				else
					document.write(this.getFShareImageButtonCode(permalink, communityUcid, fshare_image));
			}
		}
	}
}