function SetCFCookie (name, value)
	{
	var name = name.toUpperCase();
	var path = "/";
	document.cookie = name + "=" + escape (value) +"; path=" + path + ";";
	};
function GetCFCookie(name)
	{ 
	var cname = name.toUpperCase() + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length; 
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			} 
		}
	return bl; 
	}
function clicktrack()
	{
	var Click = GetCFCookie("ClickVisit");
	var Click = Click / 1;
	var ClickInc = Click + 1;
	SetCFCookie("ClickVisit",ClickInc);
	};
window.load = clicktrack();
function GetCookie(name)
	{ 
	var cname = name + "="; //the cookie name is given an equal signs after it and assigned as cname
	var dc = document.cookie; //the main document.cookie code that will follow is assigned to dc
	var bl = "";
	if (dc.length > 0)
		{ //here the length of the cookie is checked, if it is above 0 the function continues and if not then it returns null
		begin = dc.indexOf(cname); //here the indexOf() method is used to find the location of the cookie's name and it is assigned to begin
		if (begin != -1)
			{ //if the cookie's name is not found in dc then begin is given a value of -1
			begin += cname.length; //if the name is found begin is increased by the length of the cname
			end = dc.indexOf(";", begin); //the indexOf() method now searches for a semicolon to be given to the variable end
			if (end == -1) end = dc.length; 
			return unescape(dc.substring(begin, end)); //here is where is made sure that the value of the cookie is extracted and returned using the substring() method on dc
			} 
		}
	return bl; 
	}

// Find and replace characters within a string
function Switch(item,OldChar,NewChar)
	{
	var _ONE=0;
	var _ret="";
	var _flag=0;
	var _item=item.split("");
	for(var i=0;i<_item.length;i++)
		{
		if(!_flag&&_item[i]==OldChar)
			{
			_item[i]=NewChar;
			_flag=_ONE;
			}
		_ret+=_item[i];
		}
	return(_ret);
	}

// open a new window
function newwindow(href)
	{
	window.open(href,'newwindow','resizable=yes,toolbar=yes,left=200,top=200,status=yes,location=yes,scrollbars=yes');
	}
	

function getCookieVal (offset)
	{
	var endstr = document.cookie.indexOf (";", offset);
	if (endstr == -1)
	endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
	};


function SetCookie (name, value)
	{
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var path = "/";
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;
	document.cookie = name + "=" + escape (value);
	//((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
	//((path == null) ? "" : ("; path=" + path)) +
	//((domain == null) ? "" : ("; domain=" + domain)) +
	//((secure == true) ? "; secure" : "");
	};
	
	
function ResetCounts()
	{
	var expdate = new Date();
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	visit = 0;
	SetCookie("visit", visit, expdate , "/", null, false);
	history.go(0);
	};

function checkpop(myurl,width,height)
	{
	var pagelisting=GetCookie("poplist").split(",");
	var popwindow = true;
	for(var i=0;i < pagelisting.length;i++)
		{
		var mypage = pagelisting[i];
		if(myurl == mypage)
			{
			var popwindow = false;
			}
		}
	if(popwindow == true)
		{
		if(GetCookie("poplist").length == 0)
			{
			var setit = myurl;	
			}
		else
			{
			var setit = GetCookie("poplist") + "," + myurl;	
			}
		// set the cookie
		SetCookie("poplist",setit);
		// pop the window
		twin=window.open(myurl,'twin','resizable=no,toolbar=no,status=no,location=no,height='+height+',width='+width+',scrollbars=no');
		}
	}


// Show the welcome in the header	
function showWelc()
	{
	var cookieName = 'F_NAME'; //the cookie's name is finally assigned to cookieName
	datetoday = new Date();
	timenow=datetoday.getTime();
	datetoday.setTime(timenow);
	thehour = datetoday.getHours();
	if (thehour > 16)
	{
	var time="Good Evening ";
	}
	else if (thehour > 11)
	{
	var time="Good Afternoon ";
	}
	else
	{
	var time="Good Morning ";
	}
	document.write(time);
	document.write(Switch(GetCookie(cookieName),"+"," "));
	}
