// array to hold selected ID's before page is refreshed
var tmp = new Array();

function hasCookies()
{
	// set a temporary memory cookie - expires at session end
	document.cookie = "cookieTest=true";

	//Check that worked
	var strCookie = String(document.cookie);
	if (strCookie.indexOf("cookieTest") == -1)
	{
		return false;
	}
	else
	{
		return true;
	}
}

function a(n_Id, s_Type) 
{ 
	if (!hasCookies())
	{
		alert("Sorry, you must have cookies enabled to purchase stamps from this web site");
		return;
	}
	var f = document.getElementById('cart_frame');
	f.src = 'doAddToCart.asp?id=' + n_Id + '&type=' + s_Type + '&q=1'; 
	alert("This Stamp has been added to your basket.\t\nClick View Stamp Basket to check/amend and purchase your selections.\t");
}

function o() 
{ 
	alert("Sorry, we are currently out of stock of this item.");
}

function b() 
{ 
	alert("You have clicked on our BUYING PRICE for this stamp.\t\nIf you wish to purchase this stamp please go to our STAMP PRICE LIST.");
}

function ta(n_Id, n_Price, priceID, interval) 
{ 	
	var b_Sel = false;
	
	// if the temp array already contains the id, set the flag
	for(var x=0; x<tmp.length; x++)
	{
		if(tmp[x] == n_Id)
		{
			b_Sel = true;
			break;
		}
	}
			
	
	if(b_Sel)
	{
		tb(); // item was already selected, show the unavailable message
	}
	else 
	{
		// add it to the cart
		var f = document.getElementById('cart_frame');
		f.src = 'doAddToCart.asp?tid=' + n_Id + '&q=1&pt=1&price=' + n_Price; 
		
		document.getElementById("price_" + priceID).style.color = '#FF0000'; // change the background of the cell
		tmp.push(n_Id); // add the id to the temp array so we can't add it again
	}
}

function tb()
{
	alert("This Stamp/Grade is currently unavailable.");
}