/***********************************************************************************
 * Class: CCommon
 * Description:
 *   Common class
 *
 ***********************************************************************************/

	function CCommon() {};

	// Font sizes (%)
	CCommon.fontSizes = [70, 75, 85];
	CCommon.cookieExpireDays = 30;
	
	CCommon.setFontSize = function(size) {
		try {
			var fontSize;
			
			// Get next size in array
			if(size == "next") {
				size = 0;
				
				fontSize = document.body.style.fontSize;
				if(fontSize != '') {
					var i = 0;
					while(i < CCommon.fontSizes.length && CCommon.fontSizes[i] + '%' != fontSize)
						i++;
					if(i < CCommon.fontSizes.length)
						size = (i + 1) % 3;
				}
				else
					size = 1;
			}
	
			// Get font size from sizes array
			fontSize = CCommon.fontSizes[size];
		
			// 0 is default so remove cookie
			if(size == 0)
				CCookie.remove("fontSize");
			else
				CCookie.set("fontSize", size, CCommon.cookieExpireDays);
			
			document.body.style.fontSize = fontSize + '%';
		}
		catch(e) { 
			alert("Unable to change the font size. Please make sure you have cookies enabled. You can also use your browser to change the font size e.g. 'Menu Bar > View > Text Size' for Internet Explorer or Firefox");
		};
	};

	// Get font size from cookie
	CCommon.getFontSize = function() {
		try {
			var fontSize = CCookie.get("fontSize");
			if(fontSize != null && fontSize != '' && !isNaN(fontSize) && fontSize >= 0 && fontSize < CCommon.fontSizes.length)
				CCommon.setFontSize(fontSize);
		}
		catch(e) { 
			;
		};
	};
	
	CCommon.addOnload = function(func) {
		if(typeof(window.onload) != 'function')
			window.onload = func;
		else {
			var prevOnload = window.onload;
			window.onload = function() {
				prevOnload();
				func();
			};
		}
	};
	
	// Get fontsize onload
	CCommon.addOnload(CCommon.getFontSize);
