var expDays = 30;
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
var ShowCount = 0;
var SwapColour;

function ListFavItems()
{
	var NumFavItems = GetCookie('PT_NumFavList');
	var i;
	var FavItem;
	var FavImage;
	var FavFolder;

	if (NumFavItems == null) 
	{
		NumFavItems = 0;
	}
	ShowCount = 0; SwapColour = 0;
	
	for (i=1; i <= NumFavItems; i++)
	{
		FavItem = GetCookie('PT_FavItem'+i);
		FavFolder = GetCookie('PT_FavFolder'+i);
		FavImage = GetCookie('PT_FavImage'+i);
		
		if (FavItem != null)
		{
			PrintItem(FavItem, i, FavFolder, FavImage);
		}
	}
}

function DeleteItem(Count)
{
	DeleteCookie('PT_FavItem'+Count);
	window.location = window.location;
}

function PrintItem (FavItem, Count, FavFolder, FavImage)
{
	var color = "";

	document.write("<tr>");
	document.write("<td><font face=\"Helvetica, Verdana, Arial, sans-serif\" color=\"Maroon\" size=2><b><a href=\"/" + FavFolder + "/default.htm\" target=\"_top\">"+FavItem + "</a>");
	document.write("<td><font face=\"Helvetica, Verdana, Arial, sans-serif\" color=\"Black\" size=2>"+"<a href='javascript:DeleteItem(" + Count + ")'>Remove</a>");
	document.write("</tr><tr><td width=20% colspan=2></td><td><img src=\"/" +FavFolder + "/" + FavImage + "\" height=100></td></tr>");	
}

function AddItem(FavItem, FavFolder, FavImage)
{
	var NumFavItems = GetCookie('PT_NumFavList');
	var i;
	var FavItem;

	if (NumFavItems == null) 
	{
		NumFavItems = 0;
	}
	if ((FavItem != null) && (FavItem != "undefined" ))
	{
		NumFavItems++;
		SetCookie('PT_FavItem'+NumFavItems, FavItem, exp,"/");
		SetCookie('PT_FavFolder'+NumFavItems, FavFolder, exp,"/");
		SetCookie('PT_FavImage'+NumFavItems, FavImage, exp,"/");
		SetCookie('PT_NumFavList',NumFavItems, exp,"/");
		window.location = window.location;
		alert(FavItem + " has been added to your favourites!");
	}
}


function set(){
VisitorName = prompt("Who are you?");
SetCookie ('VisitorName', VisitorName, exp);
SetCookie ('WWHCount', 0, exp);
SetCookie ('WWhenH', 0, exp);
}
function getCookieVal (offset) {  
var endstr = document.cookie.indexOf (";", offset);  
if (endstr == -1)    
endstr = document.cookie.length;  
return unescape(document.cookie.substring(offset, endstr));
}
function GetCookie (name) {  
var arg = name + "=";  
var alen = arg.length;  
var clen = document.cookie.length;  
var i = 0;  
while (i < clen) {    
var j = i + alen;    
if (document.cookie.substring(i, j) == arg)      
return getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}
function SetCookie (name, value) {  
var argv = SetCookie.arguments;  
var argc = SetCookie.arguments.length;  
var expires = (argc > 2) ? argv[2] : null;  
var path = (argc > 3) ? argv[3] : null;  
var domain = (argc > 4) ? argv[4] : null;  
var secure = (argc > 5) ? 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 DeleteCookie (name) {  
var exp = new Date();  
exp.setTime (exp.getTime() - 1);  
var cval = GetCookie (name);  
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}