/////////////////////////////////////////////////////////////////////////
// Removes the Product from the Customers Shopping Basket ///
////////////////////////////////////////////////////////////////////////
function cancel_item($id,$product,$url,$backlink)
{
	if(confirm("WARNING - Please Confirm:\n\nThis will clear this Item From Your Shopping Basket !\n("+$product+") ....\n\nClick OK to Remove\nClick Cancel to Keep"))
	{
		window.location = ("action_removeproduct.php?action=cancel&url="+$url+"&id="+$id+"&product="+$product+"&backlink="+$backlink+"");
	}
}
/////////////////////////////////////////////////////////////////////////////
// Empties All the Products from the Customers Shopping Basket ///
////////////////////////////////////////////////////////////////////////////
function clear_basket($sessid,$url,$backlink)
{
	if(confirm("WARNING - Please Confirm:\n\nThis will clear All Item's From Your Shopping Basket !\n\nClick \"OK\" to Empty Your Basket\nClick \"Cancel\" to Keep the Contents of Your Basket."))
	{
		window.location = ("action_clearbasket.php?action=clear&url="+$url+"&customer="+$sessid+"&backlink="+$backlink+"");
	}
}
///////////////////////////////////////////////////////////////////////////
// Removes the Products from the Temporary Shopping Basket ///
// and Transfers them to the Transactions Shopping Basket     ///
//////////////////////////////////////////////////////////////////////////
function checkout($fullname,$email,$sessid)
{
	if(confirm("THANKYOU: "+$fullname+" for Your Order.\n\n\Please Check that \""+$email+"\"\nis Your Correct Email Address !\n\nClicking \"OK\" Will Transfer;\n\n>>  Your Order Details, Name, Home and Email Address,\nto the Netbanx SECURE SERVER.\n\nYou will need Your Credit Card Details to Hand."))
	{
		document.printorder.submit();
	}
}
///////////////////////////////////////////////////////////////////////////////////
// Check the Quantity of Products to be Added to the Shopping Basket ///
//////////////////////////////////////////////////////////////////////////////////
function check_quantity()
{
if(document.AddProduct.quantity.value == "")
	{
		alert("WARNING;\n\n\"You Appear to have left the Quantity Field Blank !\"");
		document.AddProduct.quantity.focus();
	}
	else
	{
		if(isNaN(document.AddProduct.quantity.value))
		{
			alert("WARNING;\n\n\"Only Numbers Acceptable !\"");
			document.AddProduct.quantity.focus();
		}
		else
		{
			if((parseInt(document.AddProduct.quantity.value) > 0) && (parseInt(document.AddProduct.quantity.value) < 100))
			{
				document.AddProduct.submit();
			}
			else
			{
				alert('Invalid Number !\nMust be More Than \"0\" and Less Than \"100\".');
				document.AddProduct.quantity.focus();
			}
		}
	}
}
function check_quantity2()
{
if(document.AddProduct2.quantity.value == "")
	{
		alert("WARNING;\n\n\"You Appear to have left the Quantity Field Blank !\"");
		document.AddProduct2.quantity.focus();
	}
	else
	{
		if(isNaN(document.AddProduct2.quantity.value))
		{
			alert("WARNING;\n\n\"Only Numbers Acceptable !\"");
			document.AddProduct2.quantity.focus();
		}
		else
		{
			if((parseInt(document.AddProduct2.quantity.value) > 0) && (parseInt(document.AddProduct2.quantity.value) < 100))
			{
				document.AddProduct2.submit();
			}
			else
			{
				alert('Invalid Number !\nMust be More Than \"0\" and Less Than \"100\".');
				document.AddProduct2.quantity.focus();
			}
		}
	}
}
function check_AddProduct()
{
if(document.AddProduct.pid.value == "")
	{
		alert("WARNING;\n\n\"Please Select a Format for the Manual !\"");
		document.AddProduct.pid.focus();
	}
	else
	{
	if(document.AddProduct.quantity.value == "")
		{
			alert("WARNING;\n\n\"You Appear to have left the Quantity Field Blank !\"");
			document.AddProduct.quantity.focus();
		}
		else
		{
			if(isNaN(document.AddProduct.quantity.value))
			{
				alert("WARNING;\n\n\"Only Numbers Acceptable !\"");
				document.AddProduct.quantity.focus();
			}
			else
			{
				if((parseInt(document.AddProduct.quantity.value) > 0) && (parseInt(document.AddProduct.quantity.value) < 100))
				{
					document.AddProduct.submit();
				}
				else
				{
					alert('Invalid Number !\nMust be More Than \"0\" and Less Than \"100\".');
					document.AddProduct.quantity.focus();
					}
			}
		}
	}
}
//////////////////////////////////////////////////////////////////////
// Check the Customer Name, Address and Delivery Details ///
// This is for Entry into the Transactions Database            ///
/////////////////////////////////////////////////////////////////////
function checkform($backlink)
{
if(document.orderdetails.basket.value == "")
	{
		alert("SORRY;\n\n\"You Cannot Progress With an Empty Shopping Basket !\"");
		document.orderdetails.action="index.php";
		document.orderdetails.submit();
	}
	else
			{
				terms();
			}
}
function terms()
{
if(!document.orderdetails.terms.checked)
	{
		alert("WARNING;\n\n\"You must accept our terms and conditions !\"");
		document.orderdetails.terms.focus();
	}
	else
			{
				ordername();
			}
}
function ordername()
{
if(document.orderdetails.fullname.value == "")
	{
		alert("WARNING;\n\n\"You Appear to have left Your Name Field Blank !\"");
		document.orderdetails.fullname.focus();
	}
	else
			{
				orderaddress();
			}
}
function orderaddress()
{
if(document.orderdetails.address.value == "")
	{
		alert("WARNING;\n\n\"You Must Provide Your Address !\"");
		document.orderdetails.address.focus();
	}
	else
			{
				orderpostcode();
			}
}
function orderpostcode()
{
if(document.orderdetails.postcode.value == "")
	{
		alert("WARNING;\n\n\"Postcode is Required !\"");
		document.orderdetails.postcode.focus();
	}
	else
			{
				ordercountry();
			}
}
function ordercountry()
{
if(document.orderdetails.countrycode.value == "")
	{
		alert("WARNING;\n\n\"Your Country is Required !\"");
		document.orderdetails.countrycode.focus();
	}
	else
			{
				orderemail();
			}
}
function orderemail()
{
if(document.orderdetails.email.value == "")
	{
		alert("WARNING;\n\n\"You MUST Provide Your Email Address !\"\n\nThis is Extremely Important and MUST be Correct\notherwise You May Not Recieve any Products\nOrdered Via Email...!");
		document.orderdetails.email.focus();
	}
	else
	{
	if (document.orderdetails.email.value.indexOf("@") == -1) {
		   alert("Please Enter a Valid Email Address\n(you have not entered an @ sign).");
		   document.orderdetails.email.focus();
		   return false;
		}
    if (document.orderdetails.email.value.indexOf(".") == -1) {
       alert("Please Enter a Valid Email Address\n(you have not entered a full stop anywhere).");
       document.orderdetails.email.focus();
       return false;
    }
	else
		{
			ordercompleted();
		}
	}
}
function ordercompleted()
{
if(confirm("Please Check Your Information:\n\nClick \"OK\" to Continue to Next Page\nClick \"Cancel\" to Double Check the Details."))
	{
		document.orderdetails.submit();
	}
}
/////////////////////////////////////////
// Check the Add My Link Details ///
////////////////////////////////////////
function checklink()
{
if(document.linkentry.contact.value == "")
	{
		alert("SORRY;\n\nYou Appear to have left\nthe Contact Name Field Blank !");
		document.linkentry.contact.focus();
	}
	else
			{
				linkemail();
			}
}
function linkemail()
{
if(document.linkentry.email.value == "")
	{
		alert("SORRY;\n\n\"You MUST Provide Your Email Address !\"\n\nThis is Extremely Important and MUST be Correct\notherwise You Will Not Recieve the Validation Email...!");
		document.linkentry.email.focus();
	}
	else
	{
	if (document.linkentry.email.value.indexOf("@") == -1) {
		   alert("SORRY;\n\nEmail Address is Incorrect.");
		   document.linkentry.email.focus();
		   return false;
		}
    if (document.linkentry.email.value.indexOf(".") == -1) {
		   alert("SORRY;\n\nEmail Address is Incorrect.");
		   document.linkentry.email.focus();
		   return false;
		}
	else
		{
			linkurl();
		}
	}
}
function linkurl()
{
if(document.linkentry.url.value == "")
	{
		alert("SORRY;\n\n\"You MUST Provide the FULL and Correct URL !\"\n\nThis is Should be in the Following Format...\n\nhttp://www.sportsrevent.com\nInclude the HTTP etc....\nOtherwise When we Visit Your Link,\nWe will not be able to Assess the Link Correctly,\nand the Link will be Declined...!");
		document.linkentry.url.focus();
	}
	else
	{
	if (document.linkentry.url.value.indexOf("http://") == -1) {
       alert("SORRY;\n\nPlease Enter a Valid URL\nYou Have Not Entered \"http://\" Anywhere.");
       document.linkentry.url.focus();
       return false;
    }
	if (document.linkentry.url.value.indexOf(".") == -1) {
		   alert("SORRY;\n\nPlease Enter a Valid URL\nYou Must Enter the Full URL.");
		   document.linkentry.url.focus();
		   return false;
		}
	else
		{
			linkcategory();
		}
	}
}
function linkcategory()
{
if(document.linkentry.category.value == "Other" && document.linkentry.altcategory.value == "")
{
		alert("SORRY;\n\nYou Must Type in Your Suggested Category.");
		document.linkentry.altcategory.focus();
		}
		else
			{
				linktitle();
			}
}
function linktitle()
{
if(document.linkentry.sitename.value == "")
	{
		alert("SORRY;\n\nType in a Title for the Link !\n\nSomething Descriptive about Your Site.\nPlease Limit this to Less Than 50 Characters...!");
		document.linkentry.sitename.focus();
	}
	else
			{
				linktext();
			}
}
function linktext()
{
if(document.linkentry.text.value == "")
	{
		alert("SORRY;\n\nType in Text to Display for the Link !\n\nSomething More Descriptive about Your Site.\nPlease Limit this to Less Than 170 Characters...!");
		document.linkentry.text.focus();
	}
	else
	{
		linkcomplete();
	}
}
function linkcomplete()
{
if(confirm("Please Check Your Information:\n\nClick \"OK\" to Submit Your Link Details\nClick \"Cancel\" to Double Check the Details."))
	{
		document.linkentry.submit();
	}
}