var ShareController=ShareController?ShareController:(function()
{
	var url="";
	var title="";
	var brief="";
	var commonPopup=function (url,width,height,toolsInd,wname)
	{
		var options = "width=" + width + ",height=" + height + ",top=" + ((screen.height - height) / 4).toString() + ",left=" + ((screen.width - width) / 2).toString();
		switch (toolsInd)
		{
			case 1:
				options += ",toolbar=no,status=no,resizable=no,scrollbars=yes";
				break;
			case 2:
				options += ",menubar=yes,toolbar=yes,status=yes,resizable=yes,location=yes,scrollbars=yes";
				break;
			case 3:
				options += ",top=50,left=50,resizable=yes,scrollbars=yes,status=no,menubar=no,toolbar=no,location=yes";
				break;
			case 4:
				options += ",top=50,left=50,resizable=yes,scrollbars=no,status=no,menubar=no,toolbar=no,location=yes";
				break;
		}
		if(!wname)
			wname = "reutersPopup";
	
		var popupWindow=window.open(url, wname, options);
	
		if(popupWindow)
			popupWindow.focus();
	}
	var shareTarget={
		"bobrdobr":		function (){ commonPopup('http://bobrdobr.ru/addext.html', 900, 600, 2, 'BobrdobrPopup'); },
		"facebook":		function (){ commonPopup('http://www.facebook.com/sharer.php?u='+encodeURIComponent(url)+'&t='+encodeURIComponent(title), 626, 436, 2, 'facebookPopup'); },
		"linkstore":	function (){ commonPopup('http://www.linkstore.ru/servlet/LinkStore?a=add&url='+encodeURIComponent(url), 800, 600, 2, 'Linkstore'); },
		"livejournal":	function (){ commonPopup('http://www.livejournal.ru/', 800, 600, 2, 'LiveJournalPopup'); },
		"memori":		function (){ commonPopup('http://memori.ru/link/', 800, 600, 2, 'Memori'); },
		"moemesto":		function (){ commonPopup('http://moemesto.ru/', 800, 600, 2, 'Moemesto'); },
		"reddit":		function (){ commonPopup('http://reddit.com/submit?url='+encodeURIComponent(url), 626, 436, 2, 'RedditPopup'); },
		"stumbleupon":	function (){ commonPopup('http://www.stumbleupon.com/submit?url='+encodeURIComponent(url), 800, 400, 2, 'StumbleUponPopup'); },
		"twitter":		function (){ commonPopup('http://twitter.com/home?status=Currently reading '+encodeURIComponent(url), 800, 400, 2, 'TwitterPopup'); },
		"blogger":		function (){ commonPopup('http://www.blogger.com/', 800, 600, 2, 'Blogger'); },
		"delicious":	function (){ commonPopup('http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&notes='+encodeURIComponent(brief)+'&tags=news', 540, 500, 2, 'deliciousPopup'); },
		"newsvine":		function (){ commonPopup('http://www.newsvine.com/_wine/save?aff=reuters&h='+encodeURIComponent(title)+'&t=world-news&u='+encodeURIComponent(url)+'&e='+encodeURIComponent(brief), 650, 445, 2, 'newsvinePopup'); },
		"mixx":			function (){ commonPopup('http://www.mixx.com/submit/story?title='+encodeURIComponent(title)+'&page_url='+encodeURIComponent(url+"?rpc=62")+'&description='+encodeURIComponent(brief), 1024, 640, 2, 'mixxPopup'); },
		"digg":			function (){ commonPopup('http://digg.com/remote-submit?phase=2&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&bodytext='+encodeURIComponent(brief)+'&topic=world_news', 540, 500, 2, 'diggPopup'); },
		"linkedin":		function (){ commonPopup('http://www.linkedin.com/shareArticle?mini=true&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&summary='+encodeURIComponent(brief)+'&source=Trend News Agency', 520, 570, 2, 'linkedinPopup');	}
	};
	var fEventHandler=function()
	{
		var sTarget=$(this).attr("xtarget");
		if(shareTarget[sTarget])
			shareTarget[sTarget]();
		return false;
	};
	return {
		"init":function (ArticleUrl,ArticleTitle,ArticleTeaser)
		{
			url=ArticleUrl;
			title=ArticleTitle;
			brief=ArticleTeaser;
			$("a[xtype=share]").click(fEventHandler);
		}
	};
})();

