// <script language="JavaScript">

// <!-- Begin

// ** HotSpot functions

var sepchar   = "@";	// unique separator character
var BMtotal   = 9;	// max number of HotSpots permitted
var ShowCount = 0;
var expDays   = 360;	// cookie variables - expiry # days

var exp       = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function ListHotSpots()
{
	var NumHotSpots = GetCookie('PT_NumHotSpots');
	var i;
	var HotSpot;

	// alert("ListHotSpots started");
	if (NumHotSpots == null) 
	
	{
		NumHotSpots = 0;
	}
	ShowCount = 0; SwapColour = 0;

	for (i=1; i <= NumHotSpots ; i++)
	{
		HotSpot = GetCookie('PT_HotSpot'+i);
		if (HotSpot != null)
		{
			PrintHotSpot(HotSpot, i);
		}
	}
}

function DeleteHotSpot(Count)
{
	DeleteCookie('PT_HotSpot'+Count);
	window.location = window.location;
}

function PrintHotSpot (HotSpot, Count)
{

	var color = "";
	//alert("hello 6");
	var pairs = HotSpot.split(sepchar);
	// pairs[0]= unescape(pairs[0]);
	//pairs[1]= unescape(pairs[1]);
	// alert(HotSpot+" "+sepchar);
	var BMtitle = pairs[0];
	var BMaddress = pairs[1];
	//alert(BMaddress);

	ShowCount++;
	
	document.write("<img src='http://www.thiswaytothe.net/images/list.gif' border='0' alt='Your Hot Spots'>&nbsp\;<a href='"+BMaddress+"'><font color='#0066FF'>"+BMtitle+"</font></a>");
	//alert("hmmm");

	document.write("&nbsp\;[<a href='javascript:DeleteHotSpot(" + Count + ")'>Delete</a>]<br>");
}

function AddHotSpot(BMtitle, BMaddress)
{

	var NumHotSpots = GetCookie('PT_NumHotSpots');
	var i;
	var ToDoItem;
	var HotSpot;
	var OldestHotSpot = 0;
	var CountHotSpots = 0;

	if (NumHotSpots == null) 
	{	NumHotSpots = 0;	}
	
	// check if already exists, and count HotSpots 
	for (i=1; i <= NumHotSpots ; i++)
	{
		HotSpot = GetCookie('PT_HotSpot'+i);
		if (HotSpot != null) 
		{	CountHotSpots++;			
			if (OldestHotSpot == 0)
			{	OldestHotSpot = i;	}	
		}
	
		if (HotSpot == BMtitle+sepchar+BMaddress)
		{	alert("HotSpot added for "+BMtitle);
			return;			}
	}

	// check if limit reached
	if (CountHotSpots > BMtotal)
	{	DeleteHotSpot(OldestHotSpot);
	}

	// now add it
	NumHotSpots++;
	//alert('PT_HotSpot'+NumHotSpots);
	SetCookie('PT_HotSpot'+NumHotSpots, BMtitle+sepchar+BMaddress, exp);
	SetCookie('PT_NumHotSpots',NumHotSpots, exp);
	alert("HotSpot added for "+BMtitle);
	//window.location = window.location;
}

// cookie functions

function getCookieVal (offset) {  

	var endstr = document.cookie.indexOf (";", offset);  

	if (endstr == -1)    
		endstr = document.cookie.length;  
	return 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 + "=" + 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();
}

	//  End Hotspots


// -->
// </script>
