function ISAPIPath()
{
	return 'http://www.maxgear.co.uk/bin/pxisapi1.exe';
}

function clearMe(formfield)
{
  if (formfield.defaultValue==formfield.value)
   formfield.value = ""
}

function showsignupform()
{
	if (top.location.href.indexOf('https') > -1)
	{
		return true;
	}
	else
	{
	document.write('<!--[if IE]>');
	document.write('<style>');
	document.write('#mc_embed_signup fieldset {');
	document.write('position: relative;');
	document.write('}');
	document.write('#mc_embed_signup legend {');
	document.write('position: absolute;');
	document.write('top: -1em;');
	document.write('left: .2em;');
	document.write('}');
	document.write('</style>');
	document.write('<![endif]--> ');
	document.write('<script type="text/javascript" src="http://maxgear.us1.list-manage.com/js/jquery-1.2.6.min.js"></script>');
	document.write('<script type="text/javascript" src="http://maxgear.us1.list-manage.com/js/jquery.validate.js"></script>');
	document.write('<script type="text/javascript" src="http://maxgear.us1.list-manage.com/js/jquery.form.js"></script>');
	document.write('<script type="text/javascript" src="http://maxgear.us1.list-manage.com/subscribe/xs-js?u=d5560601f43155aa96398b30b&amp;id=34cb7ccd71"></script>');
	document.write('');
	document.write('<!-- Begin MailChimp Signup Form -->');
	document.write('<div id="mc_embed_signup">');
	document.write('<form action="http://maxgear.us1.list-manage.com/subscribe/post?u=d5560601f43155aa96398b30b&amp;id=34cb7ccd71" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" style="font: normal 100% Arial;font-size: 12px;">');
	document.write('<fieldset style="-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;border: 1px outset #000000;padding-top: 1.5em;margin: .5em 0;background-color: #FFFFFF;color: #333333;">');
	document.write('<legend style="text-transform: capitalize;font-weight: bold;color: #666666;background: #000000;padding: .5em 1em;border: 1px solid #000000;-moz-border-radius: 4px;border-radius: 4px;-webkit-border-radius: 4px;font-size: 1.0em;">join our mailing list</legend>');
	document.write('<div class="indicate-required" style="text-align: right;font-style: italic;overflow: hidden;color: #333333;margin: 0 9% 0 0;">* indicates required field</div>');
	document.write('<div class="mc-field-group" style="margin: 1.3em 5%;">');
	document.write('<label for="mce-EMAIL" style="display: block;margin: .3em 0;line-height: 1em;font-weight: bold;">Email Address:<strong class="note-required">*</strong>');
	document.write('</label>');
	document.write('<input type="text" value="" name="EMAIL" class="required email" id="mce-EMAIL" style="margin-right: 1.5em;padding: .2em .3em;width: 95%;position: relative;z-index: 999;">');
	document.write('</div>');
	document.write('<div id="mce-responses" style="position: relative;top: -1.4em;padding: 0em .5em 0em .5em;overflow: hidden;">');
	document.write('<div class="response" id="mce-error-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;position: relative;top: -1.5em;z-index: 1;width: 80%;background: #FFEEEE;color: #FF0000;"></div>');
	document.write('<div class="response" id="mce-success-response" style="display: none;margin: 1em 0;padding: 1em .5em .5em 0;font-weight: bold;position: relative;top: -1.5em;z-index: 1;width: 80%;background: #;color: #529214;"></div>');
	document.write('</div>');
	document.write('<div><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="btn" style="width: auto;margin: .2em 3em;display: block;"></div>');
	document.write('</fieldset>');
	document.write('</form>');
	document.write('</div><!--mc_embed_signup-->');
	}
}

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 paypalpayment()
{
	document.form1.action='https://www.maxgear.co.uk/bin/pxisapi1.exe/checkout3';
	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="/">Home</a> </li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/info?id=600010">Competitions</a> </li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/info?id=600011">Special offers</a> </li>');
		document.write('                <li><a href="/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="/bin/pxisapi1.exe/info?id=600007">About Us</a> </li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/info?id=600005">Size Guide</a> </li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/info?id=600009">Returns</a> </li>');
		document.write('                <li><a href="/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="/bin/pxisapi1.exe/info?id=600004">General Terms and Conditions</a> </li>');
		document.write('                <li><a href="/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="/bin/pxisapi1.exe/catalogue?level=415912">0-9</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409071">A</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409112">B</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409113">C</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409114">D</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409115">E</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409116">F</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409092">G</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409117">H</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409118">I</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409119">J</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409120">K</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409121">L</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409122">M</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409123">N</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409060">O</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409125">P</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409126">Q</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409127">R</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409128">S</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409129">T</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409130">U</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409131">V</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409132">W</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409133">X</a></li>');
		document.write('                <li><a href="/bin/pxisapi1.exe/catalogue?level=409134">Y</a></li>');
		document.write('                <li><a href="/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()
{
	if ((Get_Cookie('LOGINID') == null) ||(Get_Cookie('LOGINID') <= 0))
	{
		location.replace(ISAPIPath() + '/loginpage');
	}
	else
	{
		location.replace(ISAPIPath() + '/user');
	};			 
}

function Logout()
{
	location.replace(ISAPIPath() + '/logout')
}

function EditItem(Item)
{
	location.replace(ISAPIPath() + '/large?cartrow=' + Item)
}


function ResolvePC(postcodefield, addressfield)
{
	var x = new CrossXHR();
	var sURL = "/bin/pxisapi1.exe/postcode?postcode=" + postcodefield.value;
	var i;
	var address;
	
	if (postcodefield.value == "")
	{
		alert("Please specify a postcode");
		return false;
	}
		
	x.open( "GET", sURL, false );
	x.send();
	var addresslines = x.responseText.split("~");
	
    addressfield.options.length=0;
	var opt = document.createElement("option");
    addressfield.options.add(opt);
    opt.text = "Please select address...";
	opt.value = "-1";
	
	for(i = 1; i < addresslines.length; i++)
	{
		var opt = document.createElement("option");
       	addressfield.options.add(opt);
        address = addresslines[i].split(",");
        opt.text = address[2];
		opt.value = address[0];
	}
}

function CrossXHR() {
 var crossxhr = false;
 if(window.XMLHttpRequest) {
  crossxhr = new XMLHttpRequest();
  if(crossxhr.overrideMimeType) {
   crossxhr.overrideMimeType('text/xml');
  }
 } else if(window.ActiveXObject) {
  try {
   crossxhr = new ActiveXObject('Msxml2.XMLHTTP');
  } catch(e) {
   try {
    crossxhr = new ActiveXObject('Microsoft.XMLHTTP');
   } catch(e) {
    crossxhr = false;
   }
  }
 }
 return crossxhr;
}

function GetAddress(id, fieldset)
{
	var x = new CrossXHR();
	var sURL = "/bin/pxisapi1.exe/postcode?id=" + id;
	var i;
	var addressfields;
	var s = "";
	
	x.open( "GET", sURL, false );
	x.send();
	var addresslines = x.responseText.split("~");
	addressfields = addresslines[1].split(",");
	if (fieldset == 1)
	{
		document.form1.Bill_2.value = addressfields[11];
		if (addressfields[2] != "")
		{
			document.form1.Bill_3.value = addressfields[2];
			s = addressfields[4];
			if (addressfields[5] != '')
			{
				s = s + ',' + addressfields[5];
			}
			document.form1.Bill_4.value = s;			
		}
		else
		{
			document.form1.Bill_3.value = addressfields[4];
			document.form1.Bill_4.value = addressfields[5];
		}		
		document.form1.Bill_5.value = addressfields[9];	
		document.form1.Bill_6.value = addressfields[10];	
		document.form1.Bill_7.value = 'United Kingdom';	
	}
	if (fieldset == 2)
	{
		document.form1.Deli_2.value = addressfields[11];
		if (addressfields[2] != "")
		{
			document.form1.Deli_3.value = addressfields[2];
			s = addressfields[4];
			if (addressfields[5] != '')
			{
				s = s + ',' + addressfields[5];
			}
			document.form1.Deli_4.value = s;			
		}
		else
		{
			document.form1.Deli_3.value = addressfields[4];
			document.form1.Deli_4.value = addressfields[5];
		}		
		document.form1.Deli_5.value = addressfields[9];	
		document.form1.Deli_6.value = addressfields[10];	
		document.form1.Deli_7.value = 'United Kingdom';	
	}
}

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.LoginName.value == "")
	{
		b = false;
		alert("Please complete field : E-Mail Address (Login Name)");
		return b;
	}		
	
	if (document.form1.Password.value == "")
	{
		b = false;
		alert("Please complete field : Password");
		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;
	var radiopresent = false;
	var radioselected = false;

	var col = document.forms[formName].elements;
	
	if (col != null)
	{
		for (i=0;i <= col.length - 1;i++)
		{
			//see if radio buttons present
			if (col[i].name.indexOf('r') == 0)
			{
				radiopresent = true;
			}
		}
		if (radiopresent == true)
		{
			for (i=0;i <= col.length - 1;i++)
			{
				if (col[i].checked == true)
				{
					radioselected = true;
					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;
					}
				}
			}
			if (radioselected == false) 
			{
				alert('Please select one of the product options listed above');
				return false;
			}
		}
		else
		{
			//radio buttons not present,so check all elements for 'Out of Stock'
			for (i=0;i <= col.length - 1;i++)
			{
				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;
				}
			}
		}
	}
	return true;
}

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>