	function MM_openBrWindow(theURL,winName,features) {
		window.open(theURL,winName,features);
	}

	function Validate()
	{
		if (document.email.sendto.value == "")
		{
			alert ("You must select the person or area you wish to send this email.");
			return false;
		}

		// Check for Empty fields
		if (document.email.name.value == ""
			|| document.email.email.value == ""
				|| document.email.subject.value == ""
					|| document.email.message.value == "")
		{
			alert ("You must complete all of the fields in the form.");
			return false;
		}


	}

	function Validate_checkout()
	{
		if (document.checkout.user_title.value == "0")
		{
			alert ("You must select a title.");
			return false;
		}

		if (document.checkout.card_type.value == "0")
		{
			alert ("You must select a credit card type.");
			return false;
		}

		// Check for Empty fields
		if (document.checkout.firstname.value == ""
			|| document.checkout.lastname.value == ""
				|| document.checkout.tel_number.value == ""
					|| document.checkout.baddress.value == ""
						|| document.checkout.daddress.value == ""
							|| document.checkout.cc_uname.value == ""
								|| document.checkout.ccnumber.value == ""
										|| document.checkout.email_address.value == "")
		{
			alert ("You must complete all of the fields in the form.");
			return false;
		}


	}

	function del_item(pid, userid, opts)
	{
		var ans;
		ans=window.confirm('Are you sure you wish to delete this item from your cart?');

		if (ans==false) {
			alert ("No action has been taken");
		} else {
			window.location = "processing/delitem.pro.php?user_id=" + userid + "&pro_id=" + pid + "&opts=" + opts;
		}
	}

	function del_all($page){
		var ans;
		ans=window.confirm('Are you sure you wish to empty your cart?');

		if (ans==false) {
			alert ("No action has been taken");
		} else {
			window.location = $page;
		}
	}

	function update_cart(pid, userid, camount, opts, stock) {
		ans = prompt("Please enter the amount you wish to buy of this item\n"
					 +"Positive and negitive numbers.", "")
		if (ans) {
			x = parseFloat(camount) + parseFloat(ans);

			if (x == 0) {
				alert("After doing the maths it appears that you will have 0 or less units of this item in your cart, if you wish to remove the item please click the delete button.");				
			} else if (x < 0) {
				alert("After doing the maths it appears that you will have 0 or less units of this item in your cart, if you wish to remove the item please click the delete button.");				
			} else if (x > stock) {
				alert("We only have " + stock + " of this item and you are tring to purchase " + x);
			} else {
				window.location = "processing/editcart.pro.php?user_id=" + userid + "&pid=" + pid + "&newamount=" + ans + "&opts=" + opts;
			}
		} else{
			alert("This item has not been updated");
		}
	}

	//*****************
	//Menu System
	//*****************

	if (readCookie('xpresspanel') == null)
	{
		createCookie('xpresspanel','0','1000')
	}

	function menucheck()
	{
		xpresspanel = readCookie('xpresspanel');
		arrayOfStrings = xpresspanel.split(' ')

		for (var i=0; i < arrayOfStrings.length; i++)
		{
			exp_coll(arrayOfStrings[i],1) //expands the menus from cookie
		}
	}

	function menu_add(ind)
	{
		xpresspanelval = readCookie('xpresspanel');
		eraseCookie('xpresspanel')
		createCookie('xpresspanel',xpresspanelval + ' ' + ind,'1000')
	}

	function menu_del(ind)
	{
		xpresspanel = readCookie('xpresspanel');
		eraseCookie('xpresspanel')
		arrayOfStrings = xpresspanel.split(' ')

		for (var i=0; i < arrayOfStrings.length; i++)
		{
			if(arrayOfStrings[i] == ind)
			{
				arrayOfStrings[i] = "";
			}
		}

		for (var i=0; i < arrayOfStrings.length; i++)
		{
			if (arrayOfStrings[i])
			{
				if (i == 0)
				{
					saveString = arrayOfStrings[i];
				}
				else
				{
					saveString = saveString + " " + arrayOfStrings[i];
				}
			}
		}

		createCookie('xpresspanel',saveString,'1000')
	}

	function exp_coll(ind,value,url)
	{
		s = document.getElementById("sp_" + ind);
		i = document.getElementById("im_" + ind);
		if (s)
		{
			if (s.style.display == 'none')
			{
				s.style.display = 'block';
				if (i)
				{
					i.src = url+"/minus.gif";
				}
				if ((ind == 0) || (ind == 1001))
				{
					//Do Nothing!
				}
				else
				{
					if (value != 1) //checks if page loading page or user click
					{
						menu_add(ind);
					}
				}

			}
			else if (s.style.display == 'block')
			{
				s.style.display = 'none';
				if (i)
				{
					i.src = url+"/plus.gif";
				}
				if ((ind == 0) || (ind == 1001))
				{
					//Do Nothing!
				}
				else
				{
					if (value != 1) //checks if page loading page or user click
					{
						menu_del(ind);
					}
				}
			}
		}
	}

	function createCookie(name,value,days)
	{
		if (days)
		{
			var date = new Date();
			date.setTime(date.getTime()+(days*24*60*60*1000));
			var expires = "; expires="+date.toGMTString();
		}
		else var expires = "";
		document.cookie = name+"="+value+expires+"; path=/";
	}

	function readCookie(name)
	{
		var nameEQ = name + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++)
		{
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
	}

	function eraseCookie(name)
	{
		createCookie(name,"",-1);
	}