var ArticleFontSize =
(
	{
		Size:		2,

		CookieName: 	"ZiveCzFS2=",

		CookieExpire:	120, //days

		Spot:		".font-resizer-area",

		SetSize:
			
			function(FontSize)
			{

				if(!FontSize)
				{
					var FontSize = this.GetSize();
					if(FontSize==null)
					{
						FontSize = this.Size;
					}
					else
					{
						this.Size = FontSize;
					}
				}
				else
				{
					$(".font-resizer > img:eq(" + (this.Size-1) + ")").attr("src", "/Client.Images/Icons/icon-size-" + this.Size + ".gif");
					this.Size = FontSize;
				}
				var date = new Date();
				date.setTime(date.getTime()+(this.CookieExpire*24*60*60*1000));
				var expires = "; expires=" + date.toGMTString();
				document.cookie = this.CookieName + FontSize + expires + "; path=/";

				$(this.Spot).removeClass("readerSize1 readerSize2 readerSize3").addClass("readerSize" + FontSize);
				$(".font-resizer > img:eq(" + (FontSize-1) + ")").attr("src", "/Client.Images/Icons/icon-size-" + FontSize + "-active.gif");
			},

		GetSize:
			function()
			{
				var ca = document.cookie.split(';');
				for(var i=0;i < ca.length;i++)
				{
					var c = ca[i];
					while (c.charAt(0)==' ') c = c.substring(1,c.length);
					if (c.indexOf(this.CookieName) == 0) return c.substring(this.CookieName.length,c.length);
				}
				return null;
			},

		ClearSize:
			function()
			{
				document.cookie = this.CookieName + "-1" + "; path=/";
			}


	}
);

$(document).ready(function(){
	var oA = $(".font-resizer:last");
	if(oA.length>0)
	{
		$(".font-resizer").bind("click", function(){
			$('#tfujtajblvespolek').hide();
			var date = new Date();
			date.setTime(date.getTime()+(360*24*60*60*1000));
			var expires = "; expires=" + date.toGMTString();
			document.cookie = "SVNZlidi=2" + expires + "; path=/";
		});

		var ca = document.cookie.split(';');
		var vC = 0;

		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf("SVNZlidi=") == 0) {vC = parseInt(c.substring(9,c.length));break;}
		}
		if(isNaN(vC)) {vC=0};
		vC++;
		if(vC<3)
		{
			var oI = $("<div id='tfujtajblvespolek' style='position:absolute;display:block;background:url(/client.images/v4/icons/icon-new-fontsize.png) no-repeat left center;width:218px;height:54px;left:285px;'></div>");
			oA.parent().append(oI);
			oI.css({"top" : (oA.parent().position().top-14)+"px" });

			var date = new Date();
			date.setTime(date.getTime()+(360*24*60*60*1000));
			var expires = "; expires=" + date.toGMTString();
			document.cookie = "SVNZlidi=" + vC + expires + "; path=/";
		}
	}
})
