function ISAPIPath()
{
	return 'http://www.mamstore.co.uk/bin/pxisapi1.exe';
}

function capitalise(s)
{
	if (navigator.appVersion.indexOf("Mac_") != -1)
	{
		return s;
	}
	if (navigator.appVersion.indexOf("Safari") != -1)
	{
		return s;
	}
	var str = s;
	str=str.toLowerCase();
	str=str.replace(/\b\w+\b/g, function(word) {
	return word.substring(0,1).toUpperCase()+ word.substring(1); });
	return str;
}

function checkcompetition()
{
	if (getCheckedValue(document.form2.rb_answer) == "")
	{
		alert("Please select answer");
		return false;
	}		

	if ((document.form2.emailcomp.value == "") || (document.form2.emailcomp.value == null))
	{
		alert("Please enter your e-mail address");
		return false;
	}		
	return true;

}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function paypalpayment()
{
	document.form1.action='http://www.mamstore.co.uk/bin/pxisapi1.exe/checkout3';
	document.form1.paymentmethod.value=2;
	document.form1.submit();
}

function GetActiveBand()
{
	var n;
	
	n = Get_Cookie('currentband');
	if (n == null) {n=1};
	ActivateBand(n);	
}

function SetActiveBand(n, URL)
{
	Set_Cookie('currentband', n, 30, '/', '', '' );
	window.location.href = URL;
}

function ActivateBand(n)
{
	document.getElementById('Band1').className ="";
	document.getElementById('Band2').className ="";
	document.getElementById('Band3').className ="";
	document.getElementById('Band4').className ="";
	document.getElementById('Band5').className ="";
	document.getElementById('Band6').className ="";
	document.getElementById('Band7').className ="";
	document.getElementById('Band' + n).className ="active";
	if (n == 1)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('            <ul>');
		document.write('                <li ><a href="http://www.mamstore.co.uk">Home</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600010">Competitions</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600011">Special offers</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600012">Gift Certificates</a> </li>');
		document.write('            </ul>');
		document.write('        </div>');
	}
	if (n == 2)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('            <ul>');
		document.write('                <li ><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600007">About Us</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600005">Size Guide</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600009">Returns</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600013">Delivery</a> </li>');
		document.write('            </ul>');
		document.write('        </div>');
	}
	if (n == 3)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('            <ul>');
		document.write('                <li ><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600004">General Terms and Conditions</a> </li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/info?id=600014">Privacy</a> </li>');
		document.write('            </ul>');
		document.write('        </div>');
	}
	if (n == 4)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('        </div>');
	}
	if (n == 5)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('            <ul>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=415912">0-9</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409071">A</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409112">B</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409113">C</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409114">D</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409115">E</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409116">F</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409092">G</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409117">H</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409118">I</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409119">J</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409120">K</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409121">L</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409122">M</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409123">N</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409060">O</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409125">P</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409126">Q</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409127">R</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409128">S</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409129">T</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409130">U</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409131">V</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409132">W</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409133">X</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409134">Y</a></li>');
		document.write('                <li><a href="http://www.mamstore.co.uk/bin/pxisapi1.exe/catalogue?level=409135">Z</a></li>');
		document.write('            </ul>');
		document.write('        </div>');
	}
	if (n == 6)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('        </div>');
	}
	if (n == 7)
	{
		document.write('		<div id="navigation-secondary">');
		document.write('        </div>');
	}

}

function showFlashMovie()
{
	var MM_contentVersion = 6;
	MM_FlashCanPlay = true;

	if ( MM_FlashCanPlay )
	{
	    document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"');
        	document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"');
		document.write(' ID="script" WIDTH="590" HEIGHT="180" ALIGN="">');
		document.write(' <PARAM NAME=movie VALUE="templates/imagedirectory/auto_scroll.swf"> <PARAM NAME=quality VALUE=high> <PARAM NAME=bgcolor VALUE=#FFFFFF>  ');
		document.write(' <EMBED src="/templates/imagedirectory/auto_scroll.swf" quality=high bgcolor=#FFFFFF');
        	document.write(' swLiveConnect=FALSE WIDTH="590" HEIGHT="180" NAME="script" ALIGN=""');
        	document.write(' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
        	document.write(' </EMBED>');
        	document.write(' </OBJECT>');
	} 
	else
	{
		document.write('<IMG SRC="/templates/imagedirectory/kitnoflash.jpg" usemap="#script" BORDER=0>');
	}
}

function showpopup(popupURL, pleft, ptop, pwidth, pheight) 
{
  // open the popup window
  
var popup = window.open(popupURL,"PopUp",'toolbar=0, location=0,directories=0, status=0,menubar=0,scrollbars=1,resizable=1, width=' + (pwidth + 50) + ', height=' + (pheight + 70) + ', left=' + pleft + ', top=' + ptop);
  // set the opener if it's not already set.  it's set automatically
  // in netscape 3.0+ and ie 3.0+.
  
  if (window.focus) {popup.focus()}
  
  popup.window.resizeTo(pwidth + 50, pheight + 130)
  
  if( navigator.appName.substring(0,8) == "Netscape" ) {
    popup.location = popupURL;
  }
}

function ViewLarge(Item)
{
	location.replace(ISAPIPath() + '/large?item=' + Item)
	//window.navigate(ISAPIPath() + '/large?item=' + Item)
}

function ShowCatalogue(Level)
{
	location.replace(ISAPIPath() + '/catalogue?level=' + Level)
	//window.navigate(ISAPIPath() + '/catalogue?level=' + Level)
}

function ShowInfo(Item)
{
	location.replace(ISAPIPath() + '/info?id=' + Item)
}

function YourAccount()
{
	location.replace('https://www.mamstore.co.uk/bin/pxisapi1.exe/user')	
}

function Logout()
{
	location.replace(ISAPIPath() + '/logout')
}

function EditItem(Item)
{
	location.replace(ISAPIPath() + '/large?cartrow=' + Item)
}


function ResolvePC(PC,Caller,Prefix)
{
	if (PC == "")
	{
		alert("Please specify a postcode");
		return false;
	}
		
	
	var oXMLHTTP = new ActiveXObject( "Microsoft.XMLHTTP" );
	var sURL = "/bin/pxisapi1.exe/postcode?postcode=" + PC
	oXMLHTTP.open( "GET", sURL, false );
	try
		{
			oXMLHTTP.send();
			var oXMLDOM = new ActiveXObject ( "Microsoft.XMLDOM" );
		 	oXMLDOM.async = false;
		    	oXMLDOM.loadXML(oXMLHTTP.responseText);
		    	var currNode = oXMLDOM.documentElement.childNodes;
			for (var i=0; i < currNode.length; i++) 
				{
					//alert(currNode.item(i).text);
					document.getElementById(Prefix + currNode.item(i).getAttribute("FIELDNO")).value = currNode.item(i).text;
				}
		}
	catch(e)
		{
			alert('Unable to find address for the post code');
		}
}

function ViewCart()
{
	location.replace(ISAPIPath() + '/cart')
}

function ShowCheckout()
{
	document.form2.action = ISAPIPath() + '/checkout1';
	document.form2.method = 'POST';
	document.form2.submit();
}

function AddDeliAddress(callerpage,id,callerid)
{
	document.form1.action=ISAPIPath() + '/checkout1?id=-1&caller=' + callerid
	document.form1.submit();
}

function EditDeliAddress(callerpage,id,callerid)
{
	document.form1.action=ISAPIPath() + '/checkout1?id=' + document.form1.DeliAdd.value + '&caller=' + callerid
	document.form1.submit();
}

function DeliAddDropDown(caller)
{
	document.form1.onsubmit="return(true)";
	document.form1.action=ISAPIPath() + '/checkout1?deliadd=' + document.form1.DeliAdd.value + '&caller=' + caller;
	document.form1.submit();
}

function checkmandatories()
{
	var i;
	var b;
	var check_delivery;
	b = true;

	if (document.form1.Bill_9.value == "")
	{
		b = false;
		alert("Please complete field : Forename");
		return b;
	}		
	
	if (document.form1.Bill_10.value == "")
	{
		b = false;
		alert("Please complete field : Surname");
		return b;
	}		
	
	if (document.form1.Bill_3.value == "")
	{
		b = false;
		alert("Please complete field : Address 1");
		return b;
	}		

	if (document.form1.Bill_7.value == "")
	{
		b = false;
		alert("Please complete field : Country");
		return b;
	}

	if (document.form1.Bill_2.value == "")
	{
		b = false;
		alert("Please complete field : Postcode");
		return b;
	}
			
	if (document.form1.Bill_11.value == "")
	{
		b = false;
		alert("Please complete field : Telephone");
		return b;
	}

	if (document.form1.Bill_13.value == "")
	{
		b = false;
		alert("Please complete field : E-Mail Address");
		return b;
	}

	//See if any delivery fields are filled in
	//If any are, check them all and warn if any are missing
	check_delivery = false;
	if (document.form1.Deli_8.value != "") {check_delivery = true};
	if (document.form1.Deli_9.value != "") {check_delivery = true};
	if (document.form1.Deli_10.value != "") {check_delivery = true};
	if (document.form1.Deli_3.value != "") {check_delivery = true};
	if (document.form1.Deli_4.value != "") {check_delivery = true};
	if (document.form1.Deli_5.value != "") {check_delivery = true};
	if (document.form1.Deli_6.value != "") {check_delivery = true};
	if (document.form1.Deli_7.value != "") {check_delivery = true};
	if (document.form1.Deli_2.value != "") {check_delivery = true};
	if (document.form1.Deli_11.value != "") {check_delivery = true};
	if (document.form1.Deli_12.value != "") {check_delivery = true};
	if (document.form1.Deli_13.value != "") {check_delivery = true};

	if (check_delivery == true)
	{
		if (document.form1.Deli_9.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Forename");
			return b;
		}		
	
		if (document.form1.Deli_10.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Surname");
			return b;
		}		
	
		if (document.form1.Deli_3.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Address 1");
			return b;
		}		

		if (document.form1.Deli_7.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Country");
			return b;
		}

		if (document.form1.Deli_2.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Postcode");
			return b;
		}
			
		if (document.form1.Deli_11.value == "")
		{
			b = false;
			alert("Please complete field : Delivery Telephone");
			return b;
		}

		if (document.form1.Deli_13.value == "")
		{
			b = false;
			alert("Please complete field : Delivery E-Mail Address");
			return b;
		}
	}
	
	if (document.form1.Campaign.value == -1)
	{
		b = false;
		alert("Please complete field : How did you hear about us");
		return b;
	}	

	return b;
}

function checkmandatories_delivery()
{
	var i;
	var b;
	b = true;

	if (document.form1.Deli_10.value == "")
	{
		b = false;
		alert("Please complete field : Surname");
		return b;
	}		
	
	if (document.form1.Deli_3.value == "")
	{
		b = false;
		alert("Please complete field : Address 1");
		return b;
	}		
	
	if (document.form1.Deli_2.value == "")
	{
		b = false;
		alert("Please complete field : Postcode");
		return b;
	}
			
	return b;
}

function checkuserfields()
{
	var i;
	var b;
	b = true;

	if (document.form1.FullName.value == "")
	{
		b = false;
		alert("Please complete field : Full Name");
		return b;
	}		

	if (document.form1.FullName.value.length < 6)
	{
		b = false;
		alert("E-Mail Address (Full Name) must be at least 6 characters");
		return b;
	}
		
	if (document.form1.LoginName.value == "")
	{
		b = false;
		alert("Please complete field : E-Mail Address (Login Name)");
		return b;
	}		

	if (document.form1.LoginName.value.length < 6)
	{
		b = false;
		alert("E-Mail Address (Login Name) must be at least 6 characters");
		return b;
	}

	if (document.form1.LoginName.value.indexOf("@") < 0)
	{
		b = false;
		alert("E-Mail Address (Login Name) is invalid - Please re-enter");
		return b;
	}
	
	if (document.form1.LoginName.value.indexOf(".") < 0)
	{
		b = false;
		alert("E-Mail Address (Login Name) is invalid - Please re-enter");
		return b;
	}
		
	if (document.form1.Password.value == "")
	{
		b = false;
		alert("Please complete field : Password");
		return b;
	}	
	
	if (document.form1.Password.value.length < 6)
	{
		b = false;
		alert("Password must be at least 6 characters");
		return b;
	}	
	
	if (document.form1.Password2.value == "")
	{
		b = false;
		alert("Please complete field : Verify Password");
		return b;
	}
	
	if (document.form1.Password.value != document.form1.Password2.value)
	{
		b = false;
		alert("Passwords do not match - Please re-enter");
		return b;
	}		
	
	if (document.form1.Bill_3.value == "")
	{
		b = false;
		alert("Please complete field : Address 1");
		return b;
	}		
	
	if (document.form1.Bill_2.value == "")
	{
		b = false;
		alert("Please complete field : Postcode");
		return b;
	}	
	return b;
}

function ConfirmDelete()
{
	return (confirm("Are you sure that you wish to delete this address?"));
}

function CardTypeChange()
{
//	if (document.getElementById("CardType").value == "SW")
//		document.getElementById("IssueNo").mandatory = "true"
//	else
  document.getElementById("IssueNo").mandatory = "false";
}

function ClickSubmit()
{
	if (checkmandatories())
		{
			document.form1.S1.disabled=true;
			document.form1.submit();
		}
}

function CountGroupItems(formName,GroupNo)
{
	var i;
	var iGroup;
	var iCounter = 0;
	var lcol = document.getElementById(formName).all;;
	for (i = 0;i <= lcol.length - 1; i++)
		{
			if ((lcol[i].tagName == 'SELECT') | (lcol[i].tagName == 'INPUT'))
				{
					iGroup = lcol[i].group;
					if (iGroup == GroupNo)
						{
							if (lcol[i].value != '-1')
								if (lcol[i].tagName == 'SELECT')
									iCounter++
								else
									if (lcol[i].checked)
										iCounter++;
						}
				}
		}
	return iCounter;
}

function CheckProductFields(formName)
{
	var iMinFields;
	var i;
	var iGroup;
	var sMandatory;
	var b = false;
	var bFinal = true;
	var iTotalEntered = 0;
	var showalert = false;

	if (navigator.appVersion.indexOf("MSIE") == -1)
	{
		//return true;
	}

	var col = document.forms[formName].elements;
	
	if (col != null)
		{
			for (i=0;i <= col.length - 1;i++)
				if (document.getElementById("option_" + col[i].choiceid) != undefined)
					document.getElementById("option_" + col[i].choiceid).style.color = "black";
//					document.getElementById("option_" + col[i].choiceid).classname = "ClassMandatoryFieldNormal";
			for (i=0;i <= col.length - 1;i++)
				{
					if (col[i].value == '-1')
					{
						alert("Please select an item from the 'please choose one' list");
						return false;
					}
					if ((col[i].value == 'Out of Stock') || (col[i].value == 'Out of stock') || (col[i].value == 'Call Us'))
					{
						alert("Sorry, this item is currently out of stock");
						return false;
					}
					
					iGroup = col[i].group;
					if (iGroup != undefined)
						{
							iMinFields = document.getElementById("group_" + iGroup).value;
							sMandatory = document.getElementById("group_" + iGroup).mandatory;
							iTotalEntered = CountGroupItems(formName,iGroup);
							b = false;
							if (sMandatory == 'true')
								{
									if (iTotalEntered >= iMinFields)
										b = true;
								}
							else
								{
									if ((iTotalEntered >= iMinFields) | (iTotalEntered == 0))
										b = true;
								}
							bFinal = (bFinal && b);
							if (!b)
								{
									if ((col[i].value == '-1') & (document.getElementById("option_" + col[i].choiceid) != undefined))
									{
											showalert = true;
											document.getElementById("option_" + col[i].choiceid).style.color = 'red';
									}
//										document.getElementById("option_" + col[i].choiceid).classname = 'ClassMandatoryFieldMissing';
								}
						}
				}
		}
	if ((!bFinal) & (document.getElementById(formName + 'mandatorywarning') != undefined))
	{
		showalert = true;
		document.getElementById(formName + 'mandatorywarning').style.visibility = 'visible';
	}
	
	if (showalert == true)
	{
				alert("Please select an item from the 'please choose one' list");
	}
	return bFinal;
}

function PaymentSection()
{
	if (document.getElementById("d_paymentmethod").value == '7')
		document.getElementById("divCCPayment").style.visibility = "visible"
	else
		document.getElementById("divCCPayment").style.visibility = "hidden";
}

function checkcarddetails2(form)
{
	var letter = /^[a-zA-Z\s]+$/;
	var today = new Date();
	var start_date = new Date(2000 + parseInt(form.IssueYear.options[form.IssueYear.selectedIndex].value), form.IssueMonth.options[form.IssueMonth.selectedIndex].value-1);
	var expiry_date = new Date(2000 + parseInt(form.ExpYear.options[form.ExpYear.selectedIndex].value), form.ExpMonth.options[form.ExpMonth.selectedIndex].value);
	var ccno = form.CardNumber.value; //Card number
	var ccno = ccno.replace(/ /g, "");
	var msg = 'The credit card number you entered could not be\n validated. Please check the number and try again.';
	var start_date_present = false;
	
	//########## CHECK CARD TYPE ##########
	if (form.CardType.options[0].selected)
	{
		alert('Please select card type');  
		form.CardType.focus();
		return false;
	}

	//########## CHECK CARD DETAILS ##########
	vlengthgood=0;
	ccsum=0;
	cclen=ccno.length;
	if (cclen<13)
	{
		alert("Card number must have at least 13 digits.");
		return false;
	}
	else
	{
		for (i=1; i<cclen; i++)
		{
			ccdig=parseInt(ccno.charAt(cclen-(i+1)));
			if (i%2==1)
			{
				ccdig*=2;
				if (ccdig.toString().length==2)
				{
					ccdig=(parseInt(ccdig.toString().charAt(0))+parseInt(ccdig.toString().charAt(1)));
				} 
			}
			ccsum+=ccdig;
		}
		ccsum+=parseInt(ccno.charAt(cclen-1));
		if (ccsum%10!=0)
		{
			alert('Incorrect Card Number - Please re-enter');
			return false;
		}
	}

	//########## CHECK START DATE PRESENT ##########
	if ((form.IssueMonth.options[0].selected) && (form.IssueYear.options[0].selected == false))
	{
		alert('Please select start month');  
		form.ExpMonth.focus();
		return false;
	}

	if ((form.IssueMonth.options[0].selected == false) && (form.IssueYear.options[0].selected))
	{
		alert('Please select start year');  
		form.ExpMonth.focus();
		return false;
	}

	if ((form.IssueMonth.options[0].selected == false) && (form.IssueYear.options[0].selected == false))
	{
		if(start_date > today)
		{
			alert('Please enter the correct start date for the card');
			form.IssueYear.focus();
			return false;
		}
	}

	//########## CHECK EXPIRY MONTH ENTERED ##########
	if (form.ExpMonth.options[0].selected)
	{
		alert('Please select expiry month');  
		form.ExpMonth.focus();
		return false;
	}

	//########## CHECK EXPIRY YEAR ENTERED ##########
	if (form.ExpYear.options[0].selected)
	{
		alert('Please select expiry year');  
		form.ExpYear.focus();
		return false;
	}
	
	//########## CHECK EXPIRY DATE ##########	
	if(expiry_date < today)
	{
		alert('Please enter the correct expiry date for the card');
		return false;
	}

	if ((form.CardType.value != 'SWITCH') && (form.CardType.value != 'SOLO') && (form.CardType.value != 'DELTA') && (form.IssueNo.value != ''))
	{
		alert('Issue No is not appropriate to this type of card. Please delete the Issue No field');  
		form.IssueNo.focus();
		return false;
	}

	return true;
}

function checkcarddetails2_old(form) {
	var letter = /^[a-zA-Z\s]+$/;
	var today = new Date();
	var start_date = new Date(2000 + parseInt(form.IssueYear.options[form.IssueYear.selectedIndex].value), form.IssueMonth.options[form.IssueMonth.selectedIndex].value-1);
	var expiry_date = new Date(2000 + parseInt(form.ExpYear.options[form.ExpYear.selectedIndex].value), form.ExpMonth.options[form.ExpMonth.selectedIndex].value);
	var ccno = form.CardNumber.value; //Card number
	var ccno = ccno.replace(/ /g, "");
	var msg = 'The credit card number you entered could not be\n validated. Please check the number and try again.';

	//########## Check Card Type ##########
	if (form.CardType.options[0].selected)
	{
		alert('Please select card type');  
		form.CardType.focus();
		return false;
	}

	vlengthgood=0;
	ccsum=0;
	cclen=ccno.length;
	if (cclen<13)
	{
		alert("Card number must have at least 13 digits.");
		return false;
	}
	else
	{
		for (i=1; i<cclen; i++)
		{
			ccdig=parseInt(ccno.charAt(cclen-(i+1)));
			if (i%2==1)
			{
				ccdig*=2;
				if (ccdig.toString().length==2)
				{
					ccdig=(parseInt(ccdig.toString().charAt(0))+parseInt(ccdig.toString().charAt(1)));
				} 
			}
			ccsum+=ccdig;
		}
		ccsum+=parseInt(ccno.charAt(cclen-1));
		if (ccsum%10!=0)
		{
			alert('Incorrect Card Number - Please re-enter');
			return false;
		}
	}	
	return true;
}

function Set_Cookie(name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

// this fixes an issue with the old method, ambiguous values
// with this test document.cookie.indexOf( name + "=" );
function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

//--></SCRIPT>