var ArticleFontSize =
(
	{
		Size:		2,

		CookieName: 	"JNPCzFontSize=",

		CookieExpire:	120, //days

		ArticleSpot:	"article-font-resizer",

		AnnoSpot:	"annotation-font-resizer",

		LineHeights:	[145, 150, 150],

		SetSize:
			
			function(FontSize)
			{

				if(!document.getElementById(this.ArticleSpot + "-" + this.Size))
				{
					return;
				}

				if(!FontSize)
				{
					var FontSize = this.GetSize();
					if(FontSize==null)
					{
						FontSize = this.Size;
					}
					else
					{
						this.Size = FontSize;
					}
				}
				else
				{
					document.getElementById(this.ArticleSpot + "-" + this.Size).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=/";

				var ArticlePlace = document.getElementById(this.ArticleSpot + "-area");
				if(ArticlePlace)
				{
					ArticlePlace.style.fontSize = ((FontSize-1)*20 + 100) + "%";
					ArticlePlace.style.lineHeight = this.LineHeights[FontSize-1] + "%";
					document.getElementById(this.ArticleSpot + "-" + FontSize).src = "/client.Images/Icons/icon-size-" + FontSize + "-active.gif";
				}
				var AnnoPlace = document.getElementById(this.AnnoSpot + "-area");
				if(AnnoPlace)
				{
					AnnoPlace.style.fontSize = ((FontSize-1)*20 + 100) + "%";
					AnnoPlace.style.lineHeight = this.LineHeights[FontSize-1] + "%";
				}

				//reverse GiGaMaia boxes
				var MainArticlePlace = document.getElementById("article-main-data");
				if(MainArticlePlace)
				{
					var Pars = MainArticlePlace.getElementsByTagName("p");
					for(var i=0; i<Pars.length; i++)
					{
						if(Pars[i].getAttribute("class")=="gm-download-box-clip not4bbtext" || Pars[i].getAttribute("className")=="gm-download-box-clip not4bbtext")
						{
							Pars[i].style.fontSize = parseInt((100 / ((FontSize-1)*20 +100))*100) + "%";
							Pars[i].style.lineHeight = parseInt((this.LineHeights[0] / (this.LineHeights[FontSize-1]))*this.LineHeights[0]) + "%";
						}
					}
				}

			},

		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=/";
			}


	}
)
