function get(n, d) {
var p,i,x;  
if(!d){
d=document;
}
if((p=n.indexOf("?"))>0 && parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; 
n=n.substring(0,p);
}
if(!(x=d[n])&&d.all){ 
x=d.all[n]; 
}
for (i=0;!x&&i<d.forms.length;i++){
x=d.forms[i][n];
}
for(i=0;!x&&d.layers&&i<d.layers.length;i++) {
x=get(n,d.layers[i].document);
}
if(!x && d.getElementById) {
x=d.getElementById(n); 
}
return x;
}
// shopping cart command functions
function AddToCart(pid,qty,cid){
var url="cart.php?action=add&pid="+pid + "&qty="+qty + "&cid="+cid;
location=url;
}
function UpdateCart(key,cid){
var qty = get('cartitem' + key).qty.value;
var url="cart.php?action=update&key="+key+"&qty="+qty + "&cid="+cid;
location=url;
}
/*
function UpdateCartDD(key,menu){
var qty = menu.options[menu.selectedIndex].text;
var url="cart.php?action=update&key="+key+"&qty="+qty;
location=url;
}
*/
function RemoveFromCart(pid,cid){
if(confirm("Are you sure you wish to remove this item from your Cart?")){
var url="cart.php?action=remove&pid="+pid + "&cid="+cid;
location=url;
}
}
function custDetail(id) {
	if (id > 0) {
		var url = "customer_details.php?uid=" + id;
		window.open(url, null, 'width=500,height=500,scrollbars,resizeable');
	}
}
function orderDetail(id) {
	if (id > 0) {
		var url = "order_details.php?uid=" + id;
		window.open(url, null, 'width=500,height=500,scrollbars,resizeable');
	}
}
function orderPop(id) {
		if (id > 0) {
		var url = "order_details.php?uid=" + id;
		window.open(url, null, 'width=400,height=500,scrollbars,resizeable');
	}
}
function help(num){
var msg1="In the 'Name' field, enter the description of the option, e.g. Size or Colour\n\nIn the 'Options' field, enter a list of the options separated by a comma, e.g. S,M,L,XL or Black,White,Red. (Do not put a comma after the last option)";
eval("msg=msg"+num+";");
alert(msg);
}

function verify_form_survey() {
var themessage = "You are required to complete the following fields: ";
if (document.form_survey.Name.value=="") {
themessage = themessage + " - Name";
}
if (document.form_survey.Postcode.value=="") {
themessage = themessage + " -  Postcode";
}
if (document.form_survey.Telephone_Number.value=="") {
themessage = themessage + " -  Telephone Number";
}
if (document.form_survey.Email_Address.value=="") {
themessage = themessage + " -  Email Address";
}
if (document.form_survey.Enquiry.value=="") {
themessage = themessage + " -  Enquiry";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form_survey.submit();
}
else {
alert(themessage);
return false;
   }
}

function verify_form_contact() {
var themessage = "You are required to complete the following fields: ";
if (document.form_contact.Name.value=="") {
themessage = themessage + " - Name";
}
if (document.form_contact.Telephone_Number.value=="") {
themessage = themessage + " -  Telephone Number";
}
if (document.form_contact.Email_Address.value=="") {
themessage = themessage + " -  Email Address";
}
if (document.form_contact.Enquiry.value=="") {
themessage = themessage + " -  Enquiry";
}
//alert if fields are empty and cancel form submit
if (themessage == "You are required to complete the following fields: ") {
document.form_contact.submit();
}
else {
alert(themessage);
return false;
   }
}