// oddLoadEven made by Jeremy Keith - book DOM Scripting [2005]function addLoadEvent(func){	var oldonload = window.onload;	if(typeof window.onload != 'function'){		window.onload = func;	} else {		window.onload = function() {			oldonload();			func();		}	}}// =============================================================================================================	   // List of functions which should be executed  after the document is loaded addLoadEvent(createReadibilityDivision);addLoadEvent(changeFontSize);addLoadEvent(setCookie);// =============================================================================================================//Lewro's function - creates Readibility Division and contentfunction createReadibilityDivision(){// Test if the browser underestands the DOM	if(!document.getElementsByTagName || !document.getElementById || !document.createElement || !document.createTextNode ) return false;																							// Create DIV element	var readDivision = document.createElement("div");// Set ID atribute for DIV	readDivision.setAttribute("id","readibility");					    // Create H2 element	var readh2 = document.createElement("h2");// Insert H2 element inside of DIV element		readDivision.appendChild(readh2);// Create text element		var texth2 = document.createTextNode("Readibility");// Insert text element iside of H2 element		readh2.appendChild(texth2);// Create UL element 	var readUl = document.createElement("ul")// Insert UL element inside of DIV element		readDivision.appendChild(readUl)// Create LI element 	var readList1 = document.createElement("li");						// Insert LI element inside of DIV element	readUl.appendChild(readList1);										// Set ID for LI element	readList1.setAttribute("id","size1");								// Set TITLE for LI element	readList1.setAttribute("title","Small font size");								// Create text element	var textList1 = document.createTextNode("Font size small");			// Insert text element iside of LI element	readList1.appendChild(textList1);											var readList2 = document.createElement("li");	readUl.appendChild(readList2);	readList2.setAttribute("id","size2");									readList2.setAttribute("title","Medium font size");									var textList2 = document.createTextNode("Font size medium");					readList2.appendChild(textList2);											var readList3 = document.createElement("li");	readUl.appendChild(readList3);	readList3.setAttribute("id","size3");									var textList3 = document.createTextNode("Font size big");					readList3.setAttribute("title","Big font size");									readList3.appendChild(textList3);										// Define the element which will be used in insertBefore function	var existingDiv = document.getElementById ("header");				// Define parent node of element defined in the line above	var parent = existingDiv.parentNode;								// insertBefore function has 2 parameters (what, where)	var newChild = parent.insertBefore(readDivision, existingDiv);		}// =============================================================================================================// Lewro's function Change Font Size (TODO: There must be simplier way to do it)function changeFontSize(){	if(!document.getElementsByTagName || !document.getElementById) return false;	// Define readList1 again for this function.// Is there a way how to get it from function above?	var readList1 = document.getElementById("size1");						readList1.onclick = FontSize1;												var readList2 = document.getElementById("size2")	readList2.onclick = FontSize2;												var readList3 = document.getElementById("size3")	readList3.onclick = FontSize3;											}// TODO: This 3 functions should be sumarized into single function.function FontSize1(){	if(!document.getElementsByTagName || !document.getElementById) return false;		var articleParagraph = document.getElementById("postsWrap");	articleParagraph.style.fontSize = "1em";	whatIsTheFontSize();}function FontSize2(){	if(!document.getElementsByTagName || !document.getElementById) return false;		var articleParagraph = document.getElementById("postsWrap");	articleParagraph.style.fontSize = "1.1em";	whatIsTheFontSize();}function FontSize3(){	if(!document.getElementsByTagName || !document.getElementById) return false;		var articleParagraph = document.getElementById("postsWrap");	articleParagraph.style.fontSize = "1.3em";	whatIsTheFontSize();}function whatIsTheFontSize(){	if(!document.getElementsByTagName || !document.getElementById) return false;	var articleParagraph = document.getElementById("postsWrap");	var definedFontSize = articleParagraph.style.fontSize;// =============================================================================================================// Create Cookie	var cookieName = "fontSize";		var cookieValue = definedFontSize;	var date = new Date("January 1, 2020");	var cookieDate = date.toGMTString();	var theCookie = cookieName + "=" + cookieValue;	theCookie += ";expires=" + cookieDate;	document.cookie = theCookie;//	theCookie += ";domain=localhost"; //	document.cookie = theCookie;	theCookie += ";path=/"	document.cookie = theCookie;//	alert(theCookie);}// =============================================================================================================//  Function Get Cookie made by Jeremy Keith - book DOM Scripting [2005]function getCookie(searchName){	var cookies = document.cookie.split(";");		for (var i = 0; i < cookies.length; i++)	{		var cookieCrumbs = cookies[i].split("=");		var cookieName = cookieCrumbs[0];		var cookieValue = cookieCrumbs[1];				if(cookieName == searchName);		{			return cookieValue;		}	}	return false;}// =============================================================================================================// Lewro's function Set Cookiefunction setCookie()	{		var fontCookie = getCookie("fontSize")		var articleParagraph = document.getElementById("postsWrap");		articleParagraph.style.fontSize = fontCookie;	}
