
function setPic(picName)
{
	document.getElementById('displayPic').src = picName;
}

function deleteSelected()
{
	if (confirm('Are you sure you wish to delete the selected pictures'))
	{
		document.forms[1].submit();
	}
}

function updatePhotoInfo(picId)
{
	
	document.forms[1].elements['action'].value = "update";
	document.forms[1].elements['pic_id'].value = picId;
	document.forms[1].submit();
}



function showCart()
{
	window.open ('pg_view_cart.php', 'ShoppingCart', 'location=0,status=0,scrollbars=1,resizable=1,width=820 height=850');
}

function checkout(dbLink)
{
	window.open ('pg_checkout.php', 'ShoppingCart', 'location=0,status=0,scrollbars=1,resizable=1,width=820 height=850');
}

function email(picId)
{
	window.open('pg_email.php?pic_id=' + picId, 'EmailPhoto', 'location=0,status=0,scrollbars=1, resizable=1, width=620 height=800');
}

function addToCart(picId)
{
	var curCookie = Get_Cookie("pics");
	var inCart = false;
	if (curCookie)
	{
		//Check to make sure the pic is not alread in the cart
		curCookieArray = curCookie.split(":");
		
		for (a=0; a<curCookieArray.length; a++)
		{
			//alert(curCookieArray[a] + " -- " + picId);
			if (curCookieArray[a] == picId)
			{
				inCart = true;
			}
		}
		
		if (inCart == false)
		{ curCookie = curCookie + ":" + picId; }
		
	}
	else
	{ curCookie = picId; }
	
	Set_Cookie("pics", curCookie, 7, "/", "", "");
	
	alert("The picture was successfully added to your cart.");
	
	window.location.href=window.location.href;
}

function removeFromCart(picId)
{
	if (confirm("Are you sure you wish to remove the picture from your cart?"))
	{
		//Grab the current listing of pictureIds, if any
		var curCookie = Get_Cookie("pics");
		var newCookie = new Array();
		var c = 0;
		curCookie = curCookie.split(":");
		
		for (a=0; a<curCookie.length; a++)
		{
			if (curCookie[a] != picId)
			{
				newCookie[c] = curCookie[a];
				c++;
			}
		}
		newCookie = newCookie.join(":");
		Set_Cookie("pics", newCookie, 7, "/", "", "");
		alert("The picture was successfully removed from your cart.");
		window.location.href=window.location.href;	
	}
}
