	function setAppletCookie(c_name,c_val)
	{	
		var date = new Date();
		date.setFullYear(date.getFullYear() + 20);
		var expires = ";expires=" + date.toGMTString();			
		document.cookie = c_name + "=" + c_val + ";" + expires + ";";
	}
	
	function getAppletCookie(c_name)
	{
		var val = null;
	
		if (document.cookie.length > 0)
		{
	  		c_start = document.cookie.indexOf(c_name + "=")
			if (c_start!=-1)
		    { 
    			c_start = c_start + c_name.length+1 
    			c_end = document.cookie.indexOf(";",c_start)
    		
				if (c_end==-1){ c_end = document.cookie.length }
    		
				val = unescape(document.cookie.substring(c_start,c_end))
	    	} 
		}
		return val;
	}
	
	//this method is called after the color picker has been closed and the user has chosen a color
	function updateAppletColor(name)
	{
		//alert("value of field: " + name);
		//add 0x before the value of the color
		hexColorValue = "0x" + document.getElementById(name).value;
		
		//alert("hex value of field: " + hexColorValue);
		setAppletCookie(name + "Cookie", hexColorValue);
		
		//alert("hex value from cookie: " + name + "Cookie" + " is: " + getAppletCookie(name + "Cookie"));
		
		window.location.reload();		
	}
	
	function getCookieColor(cookieColorName, defaultColorValue)
	{
		var cookieColorValue = getAppletCookie(cookieColorName);
		if(cookieColorValue!=null && cookieColorValue!='' && cookieColorValue!="")
		{
			return cookieColorValue;
		}
		else
		{
			return defaultColorValue;
		}
	}
	
	function getAppletCookieData()
	{
		var UIBGColor = getAppletCookie("UIBGColorCookie");
		if(UIBGColor != null){
			document.getElementById('UIBGColorJS').value = UIBGColor;
		}
	}
	
	function movePosition()
	{	
		document.body.scrollTop-=200;
	}
	
	function removeCookies()
	{
		
		setAppletCookie("UIBGColorJSCookie", "");
		setAppletCookie("ImageButtonBgColorJSCookie", "");
		setAppletCookie("ChartBgColorJSCookie", "");
		setAppletCookie("ChartFgColorJSCookie", "");
		window.location.reload();
	}
	