// Add site spesific javascript here
var CtFontSize = Class.create( {
	initialize : function() {
		this.c = new CtCookie()
	},
	getAvailableFontSizes : function() {
		return getSiteComponentsConfig("fontsize", "sizes", [ "10pt", "12pt",
				"14pt" ])
	},
	toggle : function() {
		var a = this.getCurrentIndex();
		var c = this.getAvailableFontSizes();
		var b = null;
		if (a + 1 >= c.size()) {
			b = c[0]
		} else {
			if (a < 0) {
				b = c[0]
			} else {
				b = c[a + 1]
			}
		}
		this.set(b)
	},
	getCurrentIndex : function() {
		var b = this.getAvailableFontSizes();
		var a = this.c.get("fontsize");
		return b.indexOf(a)
	},
	set : function(a) {
		this.c.set("fontsize", a);
		$(document.body).setStyle( {
			fontSize :a
		})
	},
	setByIndex : function(a) {
		var b = this.getAvailableFontSizes();
		if (a >= 0 && a < b.size()) {
			this.set(b[a])
		}
	},
	initializeFromCookie : function() {
		var a = this.getCurrentIndex();
		var b = this.getAvailableFontSizes();
		if (a < 0) {
			this.set(b[0])
		} else {
			this.set(b[a])
		}
	}
});

function getSiteComponentsConfig(b, c, a) {
	if (typeof siteComponentsConfig != "undefined"
			&& typeof siteComponentsConfig[b] != "undefined"
			&& siteComponentsConfig[b][c] != "undefined") {
		return siteComponentsConfig[b][c]
	}
	if (typeof a != "undefined") {
		return a
	}
	return null
}
