// 3D-infoSpace support for Highlightings
// Copyright(C) Sergiy Beloy
// Contact email: creator@3D-infospace.com
// Visit www.3D-infoSpace.com for more details

var PICKS = new Array();	// numbers of selected pages

// [onload]
function ReadPicks() {
    var C = document.cookie;
	if (C!="")
		{
		var firstChar, lastChar;
		firstChar = C.indexOf ("H_3D-INFOSPACE");	
		if(firstChar != -1)
			{			
			firstChar = firstChar + 15;	// skip	"H_3D-INFOSPACE="   
			lastChar = C.indexOf(';', firstChar);	    
			if(lastChar == -1) 
				lastChar = C.length;	
			var content = unescape (C.substring (firstChar,lastChar));
			var IDs = content.split("-");   
			for (var i=0; i < IDs.length; i++) 
				{
				PICKS.unshift (IDs[i]);	// add content
				}
			if (CheckPick(I))
				window.document.getElementById('p').style.backgroundColor="#FF6600";
			}
		}
}

function SavePicks() {

	// Set new cookie:
	var d = new Date("January 1, 2050");
	var DATA = "H_3D-INFOSPACE=";
	if (PICKS.length > 1)
		DATA += PICKS.join("-");
	else if (PICKS.length == 1)
		DATA += PICKS[0];
	else	// empty
		d = new Date("January 1, 2000");	// clear
	var by = d.toGMTString();
	document.cookie = DATA + ";path=/;expires=" + by;
}

function ShowPick() {
	if (CheckPick(i))
		window.document.getElementById('p').style.backgroundColor="#FF6600";
	else
		window.document.getElementById('p').style.backgroundColor="#99CCFF";
}

// Highlight cell (number), if required
function CheckPick (number) {
	var n = 0;	// (counter)
	while (n < PICKS.length)
		{
		if (PICKS[n]==number)
			{
			blank=false;
			return true;
			}
		n++;
		}
	blank=true;	
	return false;
}

// Pick Button
function P() {
	if (blank) 
		{ 
		window.document.getElementById('p').style.backgroundColor="#FF6600";
		if (!CheckPick(i))	// if it's not in PICS already
			{
			PICKS.push(i);	// add content
			}
		blank=false;
		}
	else 
		{ window.document.getElementById('p').style.backgroundColor="#99CCFF";
		var n = 0;	// (counter)
		var m = PICKS.length;
		while (n < m)
			{
			if (PICKS[n]==i)
				{
				PICKS.splice(n,1);		// remove content
				n = m;	// stop cycle
				}
			n++;
			}	
		blank=true;	
		}
}