	var MIN_FONT_CHG_SIZE = -2;
	var MAX_FONT_CHG_SIZE = 8;
	
	var FONT_CHG_SIZE_STEP = 2;

	function setCookie (name, value, expires) {
		var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "");
		document.cookie = curCookie;
	}

	function setCookie (name, value, expires, path, domain, secure) {
		var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
		document.cookie = curCookie;
	}

	function chgPictures(howManyPixelLessOrMore) {
		var allImagesNodeList = document.getElementsByTagName("IMG");
		for(var i=0; i < allImagesNodeList.length; i++) {				
			if (allImagesNodeList[i].name != null && allImagesNodeList[i].name != "" ) {
				var rFind, sReplace;
				var sPrefix = "";
				if (allImagesNodeList[i].name.indexOf("HNAPPUR") > -1) {
					sPrefix = "hn_";
				} else if (allImagesNodeList[i].name.indexOf("LAYOUT_IM") > -1) {
					sPrefix = "im_";
				}
				if (sPrefix != "") {
					if (howManyPixelLessOrMore == 0) {
						rFind = new RegExp(sPrefix + "[-]*[0-9]*[_]*");
						sReplace = sPrefix;
					} else {
						rFind = new RegExp(sPrefix + "[-]*[0-9]*[_]*");
						sReplace = sPrefix + howManyPixelLessOrMore + "_";
					}						
				}
				allImagesNodeList[i].src = allImagesNodeList[i].src.replace(rFind, sReplace);
			}
		}
	}

	function getFontChgSizeCookie (fontSize) {
		var prefix = 'fontChgSize=';
		var c = document.cookie;
		var cookieStartIndex = c.indexOf(prefix);
		if (cookieStartIndex == -1)
			return fontSize;
		var cookieEndIndex = c.indexOf(";", cookieStartIndex + prefix.length);
		if (cookieEndIndex == -1)
			cookieEndIndex = c.length;
		return unescape(c.substring(cookieStartIndex + prefix.length, cookieEndIndex));
	}

	function setFontChgSizeCookie(newSize) {
		var now = new Date();
		var base = new Date(0);
		var skew = base.getTime();
		if (skew > 0) { now.setTime(now.getTime() - skew); }
		now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
		setCookie('fontChgSize', newSize, now);
	}

	function getCurrentFontChgSizeAsInt() {
		var sFontSize = getFontChgSizeCookie('0');
		var iFontSize = parseInt(sFontSize);
		return iFontSize;
	}
	
	function defaultFontSize() {
		var lastFontSize = getCurrentFontChgSizeAsInt();
		setFontChgSizeCookie(0);		
		window.location.reload(true);
	}
	
	function enlargeFont() {
		var iFontChgSize = getCurrentFontChgSizeAsInt();
		if (iFontChgSize < MAX_FONT_CHG_SIZE) {
			setFontChgSizeCookie((iFontChgSize+FONT_CHG_SIZE_STEP));			
			window.location.reload(true);
		} else {
			alert("Það er ekki hægt að stækka letrið meira");
		}
	}
	
	function shrinkFont() {
		var iFontChgSize = getCurrentFontChgSizeAsInt();
		if (iFontChgSize > MIN_FONT_CHG_SIZE) {
			setFontChgSizeCookie((iFontChgSize-FONT_CHG_SIZE_STEP));			
			window.location.reload(true);
		} else {
			alert("Það er ekki hægt að minnka letrið meira");
		}
	}
	
	function chgSize(newSize) {
		chgPictures(newSize);	
	}
	
	var currentFontSize = getFontChgSizeCookie(0);