		function CheckCookie()
		{
			var colorCode = getCookie('Color');
			var fontSize = getCookie('Font');	
			
			if(document.cookie && colorCode!=null)
			{
				ChangeColor(colorCode);
			}
			
			if(document.cookie && fontSize!=null)
			{
				setFont(fontSize);
			}
			
			window.scroll(0,0);
		}	
				
		function ChangeColor(color)
		{		
			//mainPage
			if(document.getElementById('main_place_holder') != null){
				document.getElementById('main_place_holder').style.backgroundColor=color;}
			if(document.getElementById('site_action_left') != null){
				document.getElementById('site_action_left').style.backgroundColor=color;}
			if(document.getElementById('site_action_right') != null){
				document.getElementById('site_action_right').style.backgroundColor=color;}
				
			var govDirTbl = document.getElementById('GovDirTbl');
	        if (govDirTbl != null) 
	        {						
				var p = govDirTbl.getElementsByTagName('td');
				for (i = 0; i < p.length; i++) {
					p[i].style.backgroundColor = color;
				}	
	        }
	          
	        var myBayar = document.getElementById('myBayarTbl');
	        if (myBayar != null)
	        {				
				var p = myBayar.getElementsByTagName('td');
				for (i = 0; i < p.length; i++) {
					p[i].style.backgroundColor = color;
				}	
	        }
	        
	        var voteSummary = document.getElementById('WebPartWPQ5');
	        if (voteSummary != null)
	        {	
				var p = voteSummary.getElementsByTagName('td');
				for (i = 0; i < p.length; i++) {
					p[i].style.backgroundColor = color;
				}	
	        }

			if(color == '#eae985')
			{									
					var body = document.getElementById('main_place_holder');
					var p = body.getElementsByTagName('font');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}
					var p = body.getElementsByTagName('a');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}
					var p = body.getElementsByTagName('p');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}
					// JSN - Change font colour for span and label elements
					var p = body.getElementsByTagName('span');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}						
					var p = body.getElementsByTagName('label');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}						
					var p = body.getElementsByTagName('td');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'black';
					}	
					var p = body.getElementsByTagName('tr');
					for (i = 0; i < p.length; i++) {    
						if (p[i].className == 'psp3-alternating')
						{
						    p[i].style.backgroundColor = 'white';
						}
					}						
			}
			else if (color == '#337598' || color =='#873946')
			{
					var body = document.getElementById('main_place_holder');
					var p = body.getElementsByTagName('font');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
					}
					var p = body.getElementsByTagName('a');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
					}
					var p = body.getElementsByTagName('p');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
					}	
					
					// JSN - Updated to fix bugs
					var p = body.getElementsByTagName('b');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
					}	

					var p = body.getElementsByTagName('div');
					for (i = 0; i < p.length; i++) {
						if (p[i].className == 'srch-Page srch-Page-bg')
						{
							p[i].style.color = 'black';
						            var elements = p[i].getElementsByTagName('a');
						            for( k=0; k < elements.length; k++)
							            elements[k].style.color = 'black';
						}
						else if ((p[i].className != 'srch-stats')&&(p[i].className != 'srch-sort-right'))
						{
							p[i].style.color = 'white';
						}
					}						

					var p = body.getElementsByTagName('span');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
						if (p[i].className == 'srch-URL')
							p[i].className = 'psp3-search-results-link';
					}						

					var p = body.getElementsByTagName('label');
					for (i = 0; i < p.length; i++) {
						p[i].style.color = 'white';
					}						

					var p = body.getElementsByTagName('td');
					for (i = 0; i < p.length; i++) {
						if ((p[i].className == 'ms-formlabel')||(p[i].className == 'PSP3_FactFigures_Bottom'))
							p[i].style.color = 'white';
						else if ((p[i].className == 'ms-toolbar')||(p[i].className == 'psp3-recent-update-title-bar')||(p[i].className == 'ms-formbody'))
						{
							p[i].style.color = 'black';
							var elements = p[i].getElementsByTagName('a');
							for( k=0; k < elements.length; k++)
							    elements[k].style.color = 'black';

						}
					}
					
					var p = body.getElementsByTagName('tr');
					for (i = 0; i < p.length; i++) {    
					    if (p[i].className == 'psp3-alternating')
					    {
					    	p[i].style.color = 'black';
						            var elements = p[i].getElementsByTagName('a');
						            for( k=0; k < elements.length; k++)
							            elements[k].style.color = 'black';
						}
						else if (p[i].className == 'ms-srchresultstop')
						{
					        var cells = p[i].cells;
					        for (j=0; j < cells.length; j++) {
					        		cells[j].style.color = 'black';
						            var elements = cells[j].getElementsByTagName('b');
						            for( k=0; k < elements.length; k++)
							            elements[k].style.color = 'black';
						            var elements = cells[j].getElementsByTagName('a');
						            for( k=0; k < elements.length; k++)
							            elements[k].style.color = 'black';
					        }													
						}
						else
					    {
					        var cells = p[i].cells;
					        for (j=0; j < cells.length; j++) {
					        	if ((cells[j].className == 'ms-vb')||(cells[j].className == 'ms-vb2'))
					        	{
					        		cells[j].style.color = 'white';
						            var elements = cells[j].getElementsByTagName('a');
						            for( k=0; k < elements.length; k++)
							            elements[k].style.color = 'white';
							    }
					        }						
						}
					}				
					
					//custom WPs
					var surveyWP = document.getElementById('MSOZoneCell_WebPartctl00_ctl09_g_e387a5d1_70aa_4578_8990_cc1947b0a561');
					if (surveyWP != null)
					{
						var p = surveyWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
								p[i].style.color = 'white';
						}
					}
					
					var FactFiguresWP = document.getElementById('WebPartctl00_ctl09_g_9362e42f_8b00_413f_8403_cf4556e1b58f');
					if (FactFiguresWP != null)
					{
						var p = FactFiguresWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
					}
					
					var FactFiguresWPTitle = document.getElementById('factFiguresTitle');
					if (FactFiguresWPTitle != null)
					{
						var p = FactFiguresWPTitle.getElementsByTagName('span');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'black';
						}
					}
					
					var myServicesWP = document.getElementById('WebPartctl00_ctl09_g_2e0c2702_0063_448c_8569_16b44f85a52a');
					if (myServicesWP != null)
					{
						var p = myServicesWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
					}
					
					var myFormsWP = document.getElementById('WebPartctl00_ctl09_g_152dbc21_4c81_4ee3_b1a5_c5478c05c3fd');
					if (myFormsWP != null)
					{
						var p = myFormsWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
					}
					
					var myBayarWP = document.getElementById('WebPartctl00_ctl09_g_b89b9a51_24fe_43c0_ae3c_5036539ea1a5');
					if (myBayarWP != null)
					{
						var p = myBayarWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
					}

					var myNewsWP = document.getElementById('WebPartWPQ12');
					if (myNewsWP != null)
					{
						var p = myNewsWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							if (p[i].className != 'psp3-recent-update-title-bar')
							{
								p[i].style.color = 'white';
							}
						}
					}						
					
					// JSN - Upcoming Services WP	
					var upcomingServicesWP = document.getElementById('WebPartWPQ8');
					if (upcomingServicesWP != null)
					{
						var p = upcomingServicesWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							if ((p[i].className != 'psp3-recent-update-title-bar')&&(p[i].className != 'ms-toolbar')&&(p[i].className != 'ms-vb'))
							{
								p[i].style.color = 'white';
							}
						}
					}						

					// JSN - Latest Services WP	
					var latestServicesWP = document.getElementById('WebPartWPQ9');
					if (latestServicesWP != null)
					{
						var p = latestServicesWP.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							if ((p[i].className != 'psp3-recent-update-title-bar')&&(p[i].className != 'ms-toolbar')&&(p[i].className != 'ms-vb')&&(p[i].className != 'style1'))
							{
								p[i].style.color = 'white';
							}
						}
					}						

					//siteActionBar	
					var siteActionBar = document.getElementById('site_action_bar');
					if (siteActionBar != null)
					{
						//window.alert("found...");
						var p = siteActionBar.getElementsByTagName('td');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
						
						var p = siteActionBar.getElementsByTagName('font');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
						var p = siteActionBar.getElementsByTagName('a');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
						var p = siteActionBar.getElementsByTagName('p');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
						var p = siteActionBar.getElementsByTagName('span');
						for (i = 0; i < p.length; i++) {
							p[i].style.color = 'white';
						}
					}			
			}	
		}

	function initCookie(color)
	{
		if(color == 'white')
		{
			if(document.cookie.indexOf("Color"))
			{
				var today = new Date();
				var lastYear = new Date(today.getYear()-1, today.getMonth(), today.getDate());
				setCookie("Color", color, lastYear);
			}
		}
		else
		{
			var today = new Date();
			var nextMonth = new Date(today.getYear(), today.getMonth()+1, today.getDate());
			setCookie("Color", color, nextMonth);
		}
		
		window.location.reload(true);
	}
	
	function setCookie(name, value, time)
	{
	 	var strCookie = 	   name + '=' + value;
		strCookie +=	 	   '; EXPIRES=' + time.toGMTString() + '; path=/';

		document.cookie = strCookie;
	}
	
	function getCookie(name)
	{
		if(document.cookie) 
		{
		    index = document.cookie.indexOf(name);
		    if (index != -1) 
		    {
		      countbegin = (document.cookie.indexOf("=", index) + 1);
		      countend = document.cookie.indexOf(";", index);
		      if (countend == -1) 
		      {
		        countend = document.cookie.length;
		      }
		      var value = document.cookie.substring(countbegin, countend);
	      	}
    	}
    	//window.alert(value +" "+ name);
		return value;
		
	}
	
		var min = 9;
		var max = 14;
		var today = new Date();
   		var nextMonth = new Date(today.getYear(), today.getMonth()+1, today.getDate());

		function setFont(size)
		{
			//alert("Read from Cookie: setFont");
			var p = document.getElementsByTagName('p');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
		
			var p = document.getElementsByTagName('span');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
		
			var p = document.getElementsByTagName('input');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
		
			var p = document.getElementsByTagName('a');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
		
			var p = document.getElementsByTagName('font');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
			
			var p = document.getElementsByTagName('div');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}

			// JSN - Increase font size for labels and table cells
			var p = document.getElementsByTagName('label');
			for (i = 0; i < p.length; i++) {
				if ((p[i].id != 'fntSizeDec') && (p[i].id != 'fntSizeReset') && (p[i].id != 'fntSizeInc'))
				{
					p[i].style.fontSize = size + "px"
				}
			}
			var p = document.getElementsByTagName('td');
			for (i = 0; i < p.length; i++) {
				p[i].style.fontSize = size + "px"
			}
		}
		
		function increaseFontSize() 
		{
			setCookie("Font", 14, nextMonth)
			window.location.reload(true);
		}
		
		function decreaseFontSize() 
		{		
			setCookie("Font", 9, nextMonth)
			window.location.reload(true);
		}
		
		function resetFontSize() 
		{
			if(document.cookie.indexOf("Font"))
			{
				var lastYear = new Date(today.getYear()-1, today.getMonth(), today.getDate());			
				setCookie("Font", 11, lastYear)
				window.location.reload(true);
			}
		}

