<!--
var FavList = new String(); //  the comma delimited string that holds favourite paintings
var PaintNos=new Array();		// array to store the painting Nos in as strings

LoadFavourites();		// get cookie and put value into string FavList
						//	and load individual painting Ids into the array PropNos


function LoadFavourites() {
	var a;
	var tempstr = new String();
	GetFavourites();	// get cookie and put value into string FavList
	//	split commas separated string of painting numbers into an array of strings of
	//	property Nos.
	PaintNos = FavList.split(',');
	//DisplayPIDs();
}

function GetFavourites() {
	var expdate = new Date();
	//	set this cookie to expire in 180 days so they can come back in and 
	//	resume selection within the 6 mths.
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 180)); 
	if(!(FavList = GetCookie("favourites"))) {
		// 	if no cookie, set empty string and create new cookie
		FavList = "";
		SetCookie("favourites", FavList, expdate, cpath, null, false);
	}
}

function ClearFavouritesList() {
	var expdate = new Date();
	//	set this cookie to expire in 180 days so they can come back in and 
	//	resume selection within the 6 mths.
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 180)); 
	FavList = "";
	SetCookie("favourites", FavList, expdate, cpath, null, false);
	alert("\nYour favourites list has been cleared\n");
}

function ListFavouritePaintings() {
	var hotText="Favourites"
	if (FavList == "") {
		alert("\nYou have no favourite paintings selected\n");
	} else {

		// here we load a page to display the favourites
		
		// Here is the bit you need. The 3rd parameter to the call to Windows.open is
		// just an example. I don't know what it does if you leave out this parameter.
		// Also Im not sure how you get the window to open within the lower frame of the website,
		// I assume this will pop up a new window and then we are out of context of the 
// ##########################################################################################		
// This is the magic bit to load the PropertySearch.asp page!
//	In the HTML code that displays the "List Favourite Properties" button
//	put the clause onClick="ListFavouriteProperties()"
		window.open ('PropertySearch.asp?FL=' + FavList, 'My Favourite Paintings','scrollbars=yes,status=yes,width=300,height=300')
// ###########################################################################################
	}
}

function AddToFavourites(PaintingID) {
  	var a=AddToFavourites.arguments;
	var thisPID;
	// put PID in value list for Number instead of 6 !! ie PaintingID
	thisPID = new Number(PaintingID);
	var f;

	f=false;
	alert("\n Painting with ID " + thisPID + " has been added to your favourites.\n");
	for (var i = 0; i < PaintNos.length; i++) {
		if (thisPID == parseInt(PaintNos[i],10)) {
			f=true;
			break;
		}
	}
	if (f==false) {	//	if the painting is not already there
					//	add it to the array of strings and save the cookie
		PaintNos[PaintNos.length] = thisPID.toString(10);
		SaveFavouritesCookie();
	}
}

function SaveFavouritesCookie() {
	var expdate = new Date();
	//	set this cookie to expire in 180 days so they can come back in and 
	//	resume selection within the 6 mths.
	expdate.setTime(expdate.getTime() +  (24 * 60 * 60 * 1000 * 180)); 
	FavList=PaintNos.join(',');
	SetCookie("favourites", FavList, expdate, cpath, null, false);
}

// just testing stuff!
function DisplayPIDs(){
	alert("\n Length of PaintNos is " + PaintNos.length + "\n");
	for (var i = 0; i < PaintNos.length; i++) {
		alert("\n PID is " + PaintNos[i] + "\n");
	}
}
// -->

