//Cart Functions

function initialisecartonpage()
{
  //if qty and/or currency cookies don't exist then initialise
  if (readCookie('cartqty') === null) {createCookie('cartqty',0,0);}
  if (readCookie('cartcurrency') === null) {createCookie('cartcurrency','none',0);}

  //create buy-now pulldowns on page
  if (document.getElementById('buynow1') !== null) {  document.getElementById('buynow1').innerHTML = createform(productnumberfromname('buynow1')); }
  if (document.getElementById('buynow2') !== null) {  document.getElementById('buynow2').innerHTML = createform(productnumberfromname('buynow2')); }
  if (document.getElementById('buynow3') !== null) {  document.getElementById('buynow3').innerHTML = createform(productnumberfromname('buynow3')); }
  if (document.getElementById('buynow4') !== null) {  document.getElementById('buynow4').innerHTML = createform(productnumberfromname('buynow4')); }
  if (document.getElementById('buynow5') !== null) {  document.getElementById('buynow5').innerHTML = createform(productnumberfromname('buynow5')); }
  if (document.getElementById('buynow6') !== null) {  document.getElementById('buynow6').innerHTML = createform(productnumberfromname('buynow6')); }
  if (document.getElementById('buynow7') !== null) {  document.getElementById('buynow7').innerHTML = createform(productnumberfromname('buynow7')); }
  if (document.getElementById('buynow8') !== null) {  document.getElementById('buynow8').innerHTML = createform(productnumberfromname('buynow8')); }
  if (document.getElementById('buynow9') !== null) {  document.getElementById('buynow9').innerHTML = createform(productnumberfromname('buynow9')); }
  if (document.getElementById('buynow10') !== null) {  document.getElementById('buynow10').innerHTML = createform(productnumberfromname('buynow10')); }
  if (document.getElementById('buynow11') !== null) {  document.getElementById('buynow11').innerHTML = createform(productnumberfromname('buynow11')); }
  if (document.getElementById('buynow12') !== null) {  document.getElementById('buynow12').innerHTML = createform(productnumberfromname('buynow12')); }
  if (document.getElementById('buynow13') !== null) {  document.getElementById('buynow13').innerHTML = createform(productnumberfromname('buynow13')); }
  if (document.getElementById('buynow14') !== null) {  document.getElementById('buynow14').innerHTML = createform(productnumberfromname('buynow14')); }
  
  //if something in cart then make 'view carts' visible
  if (document.getElementById('viewcartalwaysvisible') !== null) {
		  document.getElementById('viewcartalwaysvisible').style.display = 'block';
		  document.getElementById('viewcartalwaysvisible').innerHTML = carttext(readCookie('cartqty'));
	  }
  if (readCookie('cartcurrency') != 'none' && readCookie('cartcurrency') !== null)
  {   
	  if (document.getElementById('viewcart1') !== null) {
		  document.getElementById('viewcart1').style.display = 'block';
		  document.getElementById('viewcart1').innerHTML = carttext(readCookie('cartqty'));
	  }
	  if (document.getElementById('viewcart2') !== null) {
		  document.getElementById('viewcart2').style.display = 'block';
		  document.getElementById('viewcart2').innerHTML = carttext(readCookie('cartqty'));
	  }
	  if (document.getElementById('viewcart3') !== null) {
		  document.getElementById('viewcart3').style.display = 'block';
		  document.getElementById('viewcart3').innerHTML = carttext(readCookie('cartqty'));
	  }
	  if (document.getElementById('viewcart4') !== null) {
		  document.getElementById('viewcart4').style.display = 'block';
		  document.getElementById('viewcart4').innerHTML = carttext(readCookie('cartqty'));
	  }	  
  }
}

function selectpriceandsubmit(sel,productcode)
{
  var currencycode = sel.options[sel.selectedIndex].value;
  //if cookie currency is empty or equal to selected currency then process
  if (readCookie('cartcurrency') == 'none' || readCookie('cartcurrency') == filtercurrency(currencycode))
  { //in the event of customer using back button from cart page, the most likely scenario is they haven't changed the cart qtys, so increment the cookie qty. If they return with proper button cookie qty will be updated anyway.
	createCookie('cartqty',parseInt(readCookie('cartqty'),10)+1,0);
	//in case cart currency is none, set it:
	createCookie('cartcurrency',filtercurrency(currencycode),0);
	//reset forms
	resetforms();
	//add selected product to cart
	window.location = 'http://ww12.aitsafe.com/cf/add.cfm?userid=E3240837&product='+productname(productcode,currencycode)+'&units='+productshipping(productcode,filtercurrency(currencycode))+'&price='+productprice(productcode,filtercurrency(currencycode))+'&currency='+filtercurrency(currencycode)+'&return=www.swimsmooth.com/cartpassback.html' + languagepairterm(document.URL);
  }
  else
  { //make sure view carts are visible.
	if (document.getElementById('viewcart1') !== null) { document.getElementById('viewcart1').style.display='block'; }
	if (document.getElementById('viewcart2') !== null) { document.getElementById('viewcart2').style.display='block'; }
	if (document.getElementById('viewcart3') !== null) { document.getElementById('viewcart3').style.display='block'; }
	if (document.getElementById('viewcart4') !== null) { document.getElementById('viewcart4').style.display='block'; }
	//give warning - partially translated	
    alert('The current basket currency is '+currencycodetotext(readCookie('cartcurrency'))+'.\n\nYou are attempting to add an item in '+ currencycodetotext(currencycode)+'.\n\n'+document.getElementById('currencywarning').alt);
	//reset forms back to 'buy now'
	resetforms();
  }
}

function selectpriceandsubmitproconsole(sel,productcode)
{
   //order is processed by dlguard, not mals so do nothing with cookies
   var currencycode = sel.options[sel.selectedIndex].value;
	if (sel.form.licensecheck.checked === true)
	{
	  resetforms();
	  window.location = 'http://www.swimsmooth.com/dlg/sell.php?prodData=' + productname(productcode,currencycode);
	}
	else
	{   
	  resetforms();
	  alert ('You have not accepted the license terms, this must be done before purchasing the Pro Console.');
	}
}

function selectpriceandsubmitclinics(sel,productcode)
{
  var currencycode = 0;
  var clinicloc = sel.options[sel.selectedIndex].value;
  //if cookie currency is empty or equal to selected currency then process
  if (readCookie('cartcurrency') == 'none' || readCookie('cartcurrency') == filtercurrency(currencycode))
  { //in the event of customer using back button from cart page, the most likely scenario is they haven't changed the cart qtys, so increment the cookie qty. If they return with proper button cookie qty will be updated anyway.
	createCookie('cartqty',parseInt(readCookie('cartqty'),10)+1,0);
	//in case cart currency is none, set it:
	createCookie('cartcurrency',filtercurrency(currencycode),0);
	//reset forms
	resetforms();
	//add selected product to cart
	window.location = 'http://ww12.aitsafe.com/cf/add.cfm?userid=E3240837&product='+cliniclocation(clinicloc)+'&units=0&price='+productprice(productcode,filtercurrency(currencycode))+'&currency='+filtercurrency(currencycode)+'&return=www.swimsmooth.com/cartpassback.html' + languagepairterm(document.URL);
  }
  else
  { //make sure view carts are visible
	if (document.getElementById('viewcart1') !== null) { document.getElementById('viewcart1').style.display='block'; }
	if (document.getElementById('viewcart2') !== null) { document.getElementById('viewcart2').style.display='block'; }
	if (document.getElementById('viewcart3') !== null) { document.getElementById('viewcart3').style.display='block'; }
	if (document.getElementById('viewcart4') !== null) { document.getElementById('viewcart4').style.display='block'; }
	//give warning - partially translated	
    alert('The current basket currency is '+currencycodetotext(readCookie('cartcurrency'))+'.\n\nYou are attempting to add an item in '+ currencycodetotext(currencycode)+'.\n\n'+document.getElementById('currencywarning').alt);
	//reset forms back to 'buy now'
	resetforms();
  }
}

function cliniclocation(clinicloc)
{
if (clinicloc === 0) {return ('SS Clinic Birmingham Sun June 6th 2010');}
if (clinicloc == 1) {return ('SS Clinic Birmingham Mon June 7th 2010');}
if (clinicloc == 2) {return ('SS Clinic York Thurs June 10th 2010');}
if (clinicloc == 3) {return ('SS Clinic Bellshill Sat June 12th 2010');}
if (clinicloc == 4) {return ('SS Clinic Bellshill Sun June 13th 2010');}
if (clinicloc == 5) {return ('SS Clinic Bolton Wed June 16th 2010');}
if (clinicloc == 6) {return ('SS Clinic Bolton Thurs June 17th 2010');}
if (clinicloc == 7) {return ('SS Clinic Maidenhead Sat June 19th 2010');}
if (clinicloc == 8) {return ('SS Clinic Windsor Sun June 20th 2010');}
}

function selectpriceandsubmitmp3(sel,productcode)
{
  //order is processed by dlguard, not mals so do nothing with cookies
  var currencycode = sel.options[sel.selectedIndex].value;
  window.location = 'http://www.swimsmooth.com/dlg/sell.php?prodData=' + productname(productcode,currencycode);
}

function languagepairterm(passedurl)
{
  pairlocation = passedurl.indexOf('langpair=en%7C');
  if (pairlocation == -1) { return(''); }
  else { return('&sd='+passedurl.substring(pairlocation+9, passedurl.length).split("&")[0]); }
}

function carttext(qty)
{
  //basket words won't be translated
  if (qty != 1) {plural="s";} else {plural="";}
  if ( isNaN(qty) | qty === 0 ) {//for always visible cart links
	  return ('<a href="http://ww12.aitsafe.com/cf/review.cfm?userid=E3240837&return=www.swimsmooth.com/cartpassback.html' + languagepairterm(document.URL) + '"><img src="images/cart2mini.png" width="25" height="25" border="0">View Basket</a>');
  }
  else {//for cart links showing qty
	  return ('<a href="http://ww12.aitsafe.com/cf/review.cfm?userid=E3240837&return=www.swimsmooth.com/cartpassback.html' + languagepairterm(document.URL) + '"><img src="images/cart2mini.png" width="25" height="25" border="0">View ' + qty + ' Item'+plural+' in Basket</a>');
  }
}

function resetforms()
{
  if (document.getElementById('buynow1') !== null) {document.getElementById('buynow1').reset();}
  if (document.getElementById('buynow2') !== null) {document.getElementById('buynow2').reset();}
  if (document.getElementById('buynow3') !== null) {document.getElementById('buynow3').reset();}
  if (document.getElementById('buynow4') !== null) {document.getElementById('buynow4').reset();}
  if (document.getElementById('buynow5') !== null) {document.getElementById('buynow5').reset();}
  if (document.getElementById('buynow6') !== null) {document.getElementById('buynow6').reset();}
  if (document.getElementById('buynow7') !== null) {document.getElementById('buynow7').reset();}
  if (document.getElementById('buynow8') !== null) {document.getElementById('buynow8').reset();}
  if (document.getElementById('buynow9') !== null) {document.getElementById('buynow9').reset();}
  if (document.getElementById('buynow10') !== null) {document.getElementById('buynow10').reset();}
  if (document.getElementById('buynow11') !== null) {document.getElementById('buynow11').reset();}
  if (document.getElementById('buynow12') !== null) {document.getElementById('buynow12').reset();}
  if (document.getElementById('buynow13') !== null) {document.getElementById('buynow13').reset();}
  if (document.getElementById('buynow14') !== null) {document.getElementById('buynow14').reset();}
}

function productpriceandsymbol(productnumber, currencycode)
  {  //if DVD product then add in NTSC/PAL disk name
	if (productnumber == '1' || productnumber == '2') {
	if (currencycode == 0) {return ('GB &pound;' + productprice(productnumber, currencycode) + ' (PAL Format)');}
	if (currencycode == 1) {return ('US $' + productprice(productnumber, currencycode) + ' (NTSC Format)');}
	if (currencycode == 2) {return ('AUS $' + productprice(productnumber, currencycode) + ' (PAL Format)');}
	if (currencycode == 3) {return ('Euro &euro;' + productprice(productnumber, currencycode) + ' (PAL Format)');}
	if (currencycode == 4) {return ('Yen &yen;' + productprice(productnumber, currencycode) + ' (NTSC Format)');}
	if (currencycode == 5) {return ('CAD $' + productprice(productnumber, currencycode) + ' (NTSC Format)');}
  }
  //training plans
  else if (productnumber == '3' || productnumber == '4') {
	if (currencycode == 0) {return ('GB &pound;' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 1) {return ('US $' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 2) {return ('AUS $' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 3) {return ('Euro &euro;' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 4) {return ('Yen &yen;' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 5) {return ('CAD $' + productprice(productnumber, currencycode) + ' (Level 1)');}
	if (currencycode == 6) {return ('GB &pound;' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 7) {return ('US $' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 8) {return ('AUS $' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 9) {return ('Euro &euro;' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 10) {return ('Yen &yen;' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 11) {return ('CAD $' + productprice(productnumber, currencycode-6) + ' (Level 2)');}
	if (currencycode == 12) {return ('GB &pound;' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
	if (currencycode == 13) {return ('US $' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
	if (currencycode == 14) {return ('AUS $' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
	if (currencycode == 15) {return ('Euro &euro;' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
	if (currencycode == 16) {return ('Yen &yen;' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
	if (currencycode == 17) {return ('CAD $' + productprice(productnumber, currencycode-12) + ' (Level 3)');}
  }
  //pro consoles
  else if (productnumber == '9' || productnumber == '10') {
	if (currencycode == 0) {return ('GB &pound;' + productprice(productnumber, currencycode));}
	if (currencycode == 1) {return ('US $' + productprice(productnumber, currencycode));}
	if (currencycode == 2) {return ('AUS $' + productprice(productnumber, currencycode));}
	if (currencycode == 3) {return ('Euro &euro;' + productprice(productnumber, currencycode));}
	if (currencycode == 4) {return ('Yen &yen;' + productprice(productnumber, currencycode));}
	if (currencycode == 5) {return ('CAD $' + productprice(productnumber, currencycode));}
  }
  //swim caps
  else if (productnumber == '19') {
	if (currencycode == 0) {return ('GB &pound;' + productprice(productnumber, currencycode)) + ' (Blue Cap)';}
	if (currencycode == 1) {return ('US $' + productprice(productnumber, currencycode)) + ' (Blue Cap)';}
	if (currencycode == 2) {return ('AUS $' + productprice(productnumber, currencycode) + ' (Blue Cap)');}
	if (currencycode == 3) {return ('Euro &euro;' + productprice(productnumber, currencycode)) + ' (Blue Cap)';}
	if (currencycode == 4) {return ('Yen &yen;' + productprice(productnumber, currencycode)) + ' (Blue Cap)';}
	if (currencycode == 5) {return ('CAD $' + productprice(productnumber, currencycode)) + ' (Blue Cap)';}
	if (currencycode == 6) {return ('GB &pound;' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
	if (currencycode == 7) {return ('US $' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
	if (currencycode == 8) {return ('AUS $' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
	if (currencycode == 9) {return ('Euro &euro;' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
	if (currencycode == 10) {return ('Yen &yen;' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
	if (currencycode == 11) {return ('CAD $' + productprice(productnumber, currencycode-6) + ' (Pink Cap)');}
  }
  //all other products, normal format
  else {
	if (currencycode == 0) {return ('GB &pound;' + productprice(productnumber, currencycode));}
	if (currencycode == 1) {return ('US $' + productprice(productnumber, currencycode));}
	if (currencycode == 2) {return ('AUS $' + productprice(productnumber, currencycode));}
	if (currencycode == 3) {return ('Euro &euro;' + productprice(productnumber, currencycode));}
	if (currencycode == 4) {return ('Yen &yen;' + productprice(productnumber, currencycode));}
	if (currencycode == 5) {return ('CAD $' + productprice(productnumber, currencycode));}
  }
return null;
}

function productname(productnumber, currencycode)
{	
	if (productnumber == '1') { return ('Swim Smooth DVD Boxset (English Language) ') + disktype(currencycode); }
	if (productnumber == '2') { return ('Learn To Swim Freestyle Program (English Language) ') + disktype(currencycode); }
	if (productnumber == '3' || productnumber == '4') { 
	  if (productnumber == '3') { productnamebuild = 'Ironman Training Plan (English Language)';}
	  if (productnumber == '4') { productnamebuild = 'Oly/Half-IM Training Plan (English Language)';}
	  if (currencycode == '0' || currencycode == '1' || currencycode == '2' || currencycode == '3' || currencycode == '4' || currencycode == '5') {productnamebuild = productnamebuild + ' Level 1';} 
	  if (currencycode == '6' || currencycode == '7' || currencycode == '8' || currencycode == '9' || currencycode == '10' || currencycode == '11') {productnamebuild = productnamebuild + ' Level 2';}
	  if (currencycode == '12' || currencycode == '13' || currencycode == '14' || currencycode == '15' || currencycode == '16' || currencycode == '17') {productnamebuild = productnamebuild + ' Level 3';}
	  return (productnamebuild);
	}
	//return ('Ironman Training Plan (English Language) -- Shipping Date 27th August --'); }
	//return ('Oly/Half-IM Training Plan (English Language) -- Shipping Date 27th August --'); }
	if (productnumber == '5') { return ('Swim Smooth Stroke Correction Clinic'); }
	if (productnumber == '6') { return ('No Product'); }
	if (productnumber == '7') { return ('Wetronome Mk 2'); }
	if (productnumber == '8') { return ('PT Paddles'); }
	//for pro consoles, passback DL Guard code
	if (productnumber == '9') {
		if (currencycode == '0') { return ('pp%2C1%2C9'); } 
		if (currencycode == '1') { return ('pp%2C1%2C13'); }
		if (currencycode == '2') { return ('pp%2C1%2C14'); }
		if (currencycode == '3') { return ('pp%2C1%2C15'); }
		if (currencycode == '4') { return ('pp%2C1%2C16'); }
		if (currencycode == '5') { return ('pp%2C1%2C85'); }
		}
	if (productnumber == '10')  {
		if (currencycode == '0') { return ('pp%2C1%2C26'); } 
		if (currencycode == '1') { return ('pp%2C1%2C27'); }
		if (currencycode == '2') { return ('pp%2C1%2C28'); }
		if (currencycode == '3') { return ('pp%2C1%2C29'); }
		if (currencycode == '4') { return ('pp%2C1%2C30'); }
		if (currencycode == '5') { return ('pp%2C1%2C86'); }
		}
	//for mp3 tracks, passback DL Guard code
	if (productnumber == '11')  {
		if (currencycode == '0') { return ('pp%2C1%2C39'); } 
		if (currencycode == '1') { return ('pp%2C1%2C40'); }
		if (currencycode == '2') { return ('pp%2C1%2C41'); }
		if (currencycode == '3') { return ('pp%2C1%2C42'); }
		if (currencycode == '4') { return ('pp%2C1%2C43'); }
		if (currencycode == '5') { return ('pp%2C1%2C87'); }
		}
	if (productnumber == '12') { return ('Freestyler Paddles (Expected Stock: Mid September)'); }
	if (productnumber == '13') { return ('Freestyler Paddles *Junior Version*'); }
	if (productnumber == '14') { return ('Finis Tech Toc'); }
	if (productnumber == '15') { return ('Finis Freestyle Snorkel'); }
	if (productnumber == '16') { return ('Finis Pull Buoy'); }
	if (productnumber == '17') { return ('Finis Fins'); }
	if (productnumber == '18') { return ('Finis SwiMP3.1G (1GB) Waterproof MP3 Player Inc Bonus Tracks CD'); }
	if (productnumber == '19') { productnamebuild = 'Swim Smooth Silicon Swim Cap';
	if (currencycode == '0' || currencycode == '1' || currencycode == '2' || currencycode == '3' || currencycode == '4' || currencycode == '5') {productnamebuild = productnamebuild + ' (Blue)';} 
	if (currencycode == '6' || currencycode == '7' || currencycode == '8' || currencycode == '9' || currencycode == '10' || currencycode == '11') {productnamebuild = productnamebuild + ' (Pink)';}
	  return (productnamebuild);
	}
	if (productnumber == '20') { return ('Finis 3X-100M Stopwatch'); }
	alert('product not found in database ' +productnumber+'/'+currencycode);
return null;
}

function disktype(currencycode)
{
    if (currencycode == 0) {return ('(PAL Format)');}
	if (currencycode == 1) {return ('(NTSC Format)');}
	if (currencycode == 2) {return ('(PAL Format)');}
	if (currencycode == 3) {return ('(PAL Format)');}
	if (currencycode == 4) {return ('(NTSC Format)');}
	if (currencycode == 5) {return ('(NTSC Format)');}
	return null;
}

function createform(productnumber)
{
//products 3 and 4 are training plans, create 3 levels of plan for each
if ( ( productnumber == 3 ) | ( productnumber == 4 ) )
{
  return ('<SELECT name="currency" onChange="selectpriceandsubmit(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + productpriceandsymbol(productnumber,1) + '</OPTION><OPTION value="2">' + productpriceandsymbol(productnumber,2) + '</OPTION><OPTION value="3">' + productpriceandsymbol(productnumber,3) + '</OPTION><OPTION value="4">' + productpriceandsymbol(productnumber,4) + '</OPTION><OPTION value="5">' + productpriceandsymbol(productnumber,5) + '</OPTION><OPTION value="6">' + productpriceandsymbol(productnumber,6) + '</OPTION><OPTION value="7">' + productpriceandsymbol(productnumber,7) + '</OPTION><OPTION value="8">' + productpriceandsymbol(productnumber,8) + '</OPTION><OPTION value="9">' + productpriceandsymbol(productnumber,9) + '</OPTION><OPTION value="10">' + productpriceandsymbol(productnumber,10) + '</OPTION><OPTION value="11">' + productpriceandsymbol(productnumber,11) + '</OPTION><OPTION value="12">' + productpriceandsymbol(productnumber,12) + '</OPTION><OPTION value="13">' + productpriceandsymbol(productnumber,13) + '</OPTION><OPTION value="14">' + productpriceandsymbol(productnumber,14) + '</OPTION><OPTION value="15">' + productpriceandsymbol(productnumber,15) + '</OPTION><OPTION value="16">' + productpriceandsymbol(productnumber,16) + '</OPTION><OPTION value="17">' + productpriceandsymbol(productnumber,17) + '</OPTION></SELECT>');
}
//products 9 and 10 are the pro console digital downloads, create two versions for PC and Mac
else if ( ( productnumber == 9 ) | ( productnumber == 10 ) )
{
  return ('I agree to be bound by the<br><a href="../../license_console.html">Pro Console Software License</a><input type="checkbox" name="licensecheck" onChange=""></input><SELECT name="currency" onChange="selectpriceandsubmitproconsole(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + productpriceandsymbol(productnumber,1) + '</OPTION><OPTION value="2">' + productpriceandsymbol(productnumber,2) + '</OPTION><OPTION value="3">' + productpriceandsymbol(productnumber,3) + '</OPTION><OPTION value="4">' + productpriceandsymbol(productnumber,4) + '</OPTION><OPTION value="5">' + productpriceandsymbol(productnumber,5) + '</OPTION></SELECT>');
}
//product 19 is swim caps, create pink and blue versions
else if ( productnumber == 19 ) 
{
  return ('<SELECT name="currency" onChange="selectpriceandsubmit(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + productpriceandsymbol(productnumber,1) + '</OPTION><OPTION value="2">' + productpriceandsymbol(productnumber,2) + '</OPTION><OPTION value="3">' + productpriceandsymbol(productnumber,3) + '</OPTION><OPTION value="4">' + productpriceandsymbol(productnumber,4) + '</OPTION><OPTION value="5">' + productpriceandsymbol(productnumber,5) + '</OPTION><OPTION value="6">' + productpriceandsymbol(productnumber,6) + '</OPTION><OPTION value="7">' + productpriceandsymbol(productnumber,7) + '</OPTION><OPTION value="8">' + productpriceandsymbol(productnumber,8) + '</OPTION><OPTION value="9">' + productpriceandsymbol(productnumber,9) + '</OPTION><OPTION value="10">' + productpriceandsymbol(productnumber,10) + '</OPTION><OPTION value="11">' + productpriceandsymbol(productnumber,11) + '</OPTION></SELECT>');
}
//product 11 is mp3 tracks
else if ( productnumber == 11 )
{
  return ('<SELECT name="currency" onChange="selectpriceandsubmitmp3(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + productpriceandsymbol(productnumber,1) + '</OPTION><OPTION value="2">' + productpriceandsymbol(productnumber,2) + '</OPTION><OPTION value="3">' + productpriceandsymbol(productnumber,3) + '</OPTION><OPTION value="4">' + productpriceandsymbol(productnumber,4) + '</OPTION><OPTION value="5">' + productpriceandsymbol(productnumber,5) + '</OPTION></SELECT>');
}
//product number 5 is clinics - set this up for June 2010 UK clinics
else if ( productnumber == 5 )
{
  return ('<SELECT name="currency" onChange="selectpriceandsubmitclinics(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="2">' + 'York, Thurs June 10th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="3">' + 'Bellshill, Sat June 12th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="4">' + 'Bellshill, Sun June 13th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION></SELECT>');
  /*<OPTION value="8">' + 'Windsor, Sun 20th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION>*/
  /*return ('<SELECT name="currency" onChange="selectpriceandsubmitclinics(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + 'Birmingham, Sun June 6th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + 'Birmingham, Mon June 7th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="2">' + 'Darlington, Thurs June 10th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="3">' + 'Stirling, Sun 13th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="4">' + 'Stirling, Mon 14th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="5">' + 'Bolton, Wed 16th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="6">' + 'Bolton, Thurs 17th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="7">' + 'Maidenhead, Sat 19th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="8">' + 'Maidenhead, Sun 20th June:  ' + productpriceandsymbol(productnumber,0) + '</OPTION></SELECT>');*/
  
/*  return ('<SELECT name="currency" onChange="selectpriceandsubmitclinics(this,' + productnumber + ')"><OPTION value="default">Sorry, all clinics are full.</OPTION></SELECT>');*/
}
else 
{
  return ('<SELECT name="currency" onChange="selectpriceandsubmit(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="0">' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="1">' + productpriceandsymbol(productnumber,1) + '</OPTION><OPTION value="2">' + productpriceandsymbol(productnumber,2) + '</OPTION><OPTION value="3">' + productpriceandsymbol(productnumber,3) + '</OPTION><OPTION value="4">' + productpriceandsymbol(productnumber,4) + '</OPTION><OPTION value="5">' + productpriceandsymbol(productnumber,5) + '</OPTION></SELECT>');
}
}

function disktypes()
{
	alert(document.getElementById('dvdinfo').alt);
}

function planlevels()
{
	alert(document.getElementById('levelsinfo').alt);
}

function currencycodetotext(currencycode)
{
  currencycode = filtercurrency(currencycode);
  if (currencycode == "0") {return "GB Pounds";}
  else if (currencycode == "1") {return "US Dollars";}
  else if (currencycode == "2") {return "Australian Dollars";}
  else if (currencycode == "3") {return "Euros";}
  else if (currencycode == "4") {return "Yen";}
  else if (currencycode == "5") {return "Canadian Dollars";}
  else { currencycodetotext="unknown"; }
}

//filter down currency codes on training plans
function filtercurrency(currencycode)
{
	currencycode = parseInt(currencycode,10);
	if (currencycode >= 6) { currencycode = currencycode - 6;}
	if (currencycode >= 6) { currencycode = currencycode - 6;}
	return(currencycode);
}

//days is number of days cookie will live. If -1 then cookie immediately dies. If 0 then dies on browser closing.
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		expires = "; expires="+date.toGMTString();
	}
	else { 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); }
	}
	return null;
}

function productnumberfromname(elementid) {
	fullname = document.getElementById(elementid).name;
	return fullname.substring(4,fullname.length);
}

//1.75 2.4 1.4 200

//return shipping price by currency
function productshipping(productnumber,currencycode) {
	  if (productnumber == 1 | productnumber == 2)	{
	  if (currencycode == 0) {return '1';} //Boxset or LTSF £        
	  if (currencycode == 1) {return '2';} //Boxset or LTSF US$
	  if (currencycode == 2) {return '3';} //Boxset or LTSF Aus$
	  if (currencycode == 3) {return '1.4';} //Boxset or LTSF Euros
	  if (currencycode == 4) {return '300';} //Boxset or LTSF Yen       
	  if (currencycode == 5) {return '2.1';} //Boxset or LTSF CAD$
  }
	  if (productnumber == 3 | productnumber == 4)	{
	  if (currencycode == 0) {return '1';} //Training Plan £
	  if (currencycode == 1) {return '2';} //Training Plan US$
	  if (currencycode == 2) {return '3';} //Training Plan Aus$
	  if (currencycode == 3) {return '1.4';} //Training Plan Euros
	  if (currencycode == 4) {return '300';} //Training Plan Yen
	  if (currencycode == 5) {return '2.1';} //Training Plan CAD$
  }
	  if (productnumber == 5) {
	  return '0'; //Clinic £
  }
	  if (productnumber == 6)	{
		  //no product 6
  }
	  if (productnumber == 7)	{
	  if (currencycode == 0) {return '0.847';} //Wetronome Mk 2 £
	  if (currencycode == 1) {return '1.9';} //Wetronome Mk 2 US$
	  if (currencycode == 2) {return '2.8';} //Wetronome Mk 2 Aus$
	  if (currencycode == 3) {return '1.187';} //Wetronome Mk 2 Euros
	  if (currencycode == 4) {return '254';} //Wetronome Mk 2 Yen
	  if (currencycode == 5) {return '2';} //Wetronome Mk 2 CAD$
  }
	  if (productnumber == 8)	{
	  if (currencycode == 0) {return '3.21';} //PT Paddles £
	  if (currencycode == 1) {return '3.54';} //PT Paddles US$
	  if (currencycode == 2) {return '4.4';} //PT Paddles Aus$
	  if (currencycode == 3) {return '2.57';} //PT Paddles Euros
	  if (currencycode == 4) {return '400';} //PT Paddles Yen
	  if (currencycode == 5) {return '3.7';} //PT Paddles CAD$
  }
	  if (productnumber == 9 | productnumber == 10 | productnumber == 11)	{
	  return '0'; //9 = Enth Console, 10 = Pro Console, 11 = MP3 tracks
  }
      if (productnumber == 12 | productnumber == 13)	{
	  if (currencycode == 0) {return '2.28';} //Freestyler +junior Pad £
	  if (currencycode == 1) {return '3.11';} //Freestyler +junior Pad US$
	  if (currencycode == 2) {return '4.64';} //Freestyler +junior Pad Aus$
	  if (currencycode == 3) {return '1.93';} //Freestyler +junior Pad Euros
	  if (currencycode == 4) {return '469';} //Freestyler +junior Pad Yen
	  if (currencycode == 5) {return '3.26';} //Freestyler +junior Pad CAD$
  }	  if (productnumber == 14)	{
	  if (currencycode == 0) {return '3.37';} //tec toc £
	  if (currencycode == 1) {return '5.90';} //tec toc US$
	  if (currencycode == 2) {return '8.46';} //tec toc Aus$
	  if (currencycode == 3) {return '3.24';} //tec toc Euros
	  if (currencycode == 4) {return '788';} //tec toc Yen
	  if (currencycode == 5) {return '6.20';} //tec toc CAD$
  }	  if (productnumber == 15)	{
	  if (currencycode == 0) {return '3.37';} //snorkel £ (guestimate, tbc)
	  if (currencycode == 1) {return '5.90';} //snorkel US$
	  if (currencycode == 2) {return '8.46';} //snorkel Aus$
	  if (currencycode == 3) {return '3.24';} //snorkel Euros
	  if (currencycode == 4) {return '788';} //snorkel Yen
	  if (currencycode == 5) {return '6.2';} //snorkel CAD$
  }	  if (productnumber == 16)	{
	  if (currencycode == 0) {return '2.28';} //Pull Buoy £
	  if (currencycode == 1) {return '2.52';} //Pull Buoy US$
	  if (currencycode == 2) {return '3.82';} //Pull Buoy Aus$
	  if (currencycode == 3) {return '1.64';} //Pull Buoy Euros
	  if (currencycode == 4) {return '401';} //Pull Buoy Yen
	  if (currencycode == 5) {return '2.64';} //Pull Buoy CAD$
  }	  if (productnumber == 17)	{
	  if (currencycode == 0) {return '4';} //fins £ (guestimate, tbc)
	  if (currencycode == 1) {return '8';} //fins US$
	  if (currencycode == 2) {return '12';} //fins Aus$
	  if (currencycode == 3) {return '5.6';} //fins Euros
	  if (currencycode == 4) {return '1200';} //fins Yen
	  if (currencycode == 5) {return '8.4';} //fins CAD$
  }	  if (productnumber == 18)	{
	  if (currencycode == 0) {return '2.83';} //swimp3 £
	  if (currencycode == 1) {return '4.50';} //swimp3 US$
	  if (currencycode == 2) {return '6.54';} //swimp3 Aus$
	  if (currencycode == 3) {return '2.61';} //swimp3 Euros
	  if (currencycode == 4) {return '628';} //swimp3 Yen
	  if (currencycode == 5) {return '4.72';} //swimp3 CAD$
  }	  if (productnumber == 19)	{
	  if (currencycode == 0) {return '0.847';} //swim cap £
	  if (currencycode == 1) {return '1.9';} //swim cap US$
	  if (currencycode == 2) {return '2.8';} //swim cap Aus$
	  if (currencycode == 3) {return '1.187';} //swim cap Euros
	  if (currencycode == 4) {return '254';} //swim cap Yen
	  if (currencycode == 5) {return '1.95';} //swim cap CAD$
  }	  if (productnumber == 20)	{
	  if (currencycode == 0) {return '1';} //swim cap £
	  if (currencycode == 1) {return '2';} //swim cap US$
	  if (currencycode == 2) {return '3';} //swim cap Aus$
	  if (currencycode == 3) {return '1.4';} //swim cap Euros
	  if (currencycode == 4) {return '300';} //swim cap Yen
	  if (currencycode == 5) {return '2.1';} //swim cap CAD$
  }
  
return null;
	
}

//return price by currency
function productprice(productnumber, currencycode) {
  /*
  OLD DVD PRICE:
  if (productnumber == 1)	{
	  if (currencycode == 0) {return '50';} //Boxset £ 
	  if (currencycode == 1) {return '80';} //Boxset US$
	  if (currencycode == 2) {return '90';} //Boxset Aus$
	  if (currencycode == 3) {return '60';} //Boxset Euros
	  if (currencycode == 4) {return '7500';} //Boxset Yen
  }*/
  if (productnumber == 1)	{
	  if (currencycode == 0) {return '39';} //Boxset £ 
	  if (currencycode == 1) {return '60';} //Boxset US$
	  if (currencycode == 2) {return '70';} //Boxset Aus$
	  if (currencycode == 3) {return '50';} //Boxset Euros
	  if (currencycode == 4) {return '5500';} //Boxset Yen
	  if (currencycode == 5) {return '63';} //Boxset US$
  }
	  if (productnumber == 2)	{
	  if (currencycode == 0) {return '25';} //LTSF £
	  if (currencycode == 1) {return '45';} //LTSF US$
	  if (currencycode == 2) {return '60';} //LTSF Aus$
	  if (currencycode == 3) {return '35';} //LTSF Euros
	  if (currencycode == 4) {return '5000';} //LTSF Yen
	  if (currencycode == 5) {return '48';} //LTSF CAD$
  }
	  if (productnumber == 3 | productnumber == 4 )	{
	  if (currencycode == 0) {return '25';} //Training Plan £
	  if (currencycode == 1) {return '45';} //Training Plan US$
	  if (currencycode == 2) {return '50';} //Training Plan Aus$
	  if (currencycode == 3) {return '35';} //Training Plan Euros
	  if (currencycode == 4) {return '5000';} //Training Plan Yen
	  if (currencycode == 5) {return '48';} //Training Plan CAF$
  }
	  if (productnumber == 5) {
	  if (currencycode == 0) {return '175';} //Clinic £
	  if (currencycode == 1) {return '300';} //Clinic US$
	  if (currencycode == 2) {return '350';} //Clinic Aus$
	  if (currencycode == 3) {return '250';} //Clinic Euros
	  if (currencycode == 4) {return '50000';} //Clinic Yen
	  if (currencycode == 5) {return '325';} //Clinic CAF$
  }
	  if (productnumber == 6)	{
//no product 6
  }
	  if (productnumber == 7)	{
	  if (currencycode == 0) {return '49';} //Wetronome Mk 2 £
	  if (currencycode == 1) {return '85';} //Wetronome Mk 2 US$
	  if (currencycode == 2) {return '90';} //Wetronome Mk 2 Aus$
	  if (currencycode == 3) {return '55';} //Wetronome Mk 2 Euros
	  if (currencycode == 4) {return '8000';} //Wetronome Mk 2 Yen
	  if (currencycode == 5) {return '88';} //Wetronome Mk 2 US$
  }
	  if (productnumber == 8)	{
	  if (currencycode == 0) {return '23';} //PT Paddles £
	  if (currencycode == 1) {return '32';} //PT Paddles US$
	  if (currencycode == 2) {return '37';} //PT Paddles Aus$
	  if (currencycode == 3) {return '30';} //PT Paddles Euros
	  if (currencycode == 4) {return '4000';} //PT Paddles Yen
	  if (currencycode == 5) {return '35';} //PT Paddles CAD$
  }
  //these prices are just labels, transaction prices are set within our secure download software.
	  if (productnumber == 9)	{
	  if (currencycode == 0) {return '15';} //Mr Smooth Pro Enthusiasts Console £
	  if (currencycode == 1) {return '23';} //Mr Smooth Pro Enthusiasts Console US$
	  if (currencycode == 2) {return '25';} //Mr Smooth Pro Enthusiasts Console Aus$
	  if (currencycode == 3) {return '19';} //Mr Smooth Pro Enthusiasts Console Euros
	  if (currencycode == 4) {return '2000';} //Mr Smooth Pro Enthusiasts Console Yen
	  if (currencycode == 5) {return '24';} //Mr Smooth Pro Enthusiasts Console CAD$
  }
	  if (productnumber == 10)	{
	  if (currencycode == 0) {return '100';} //Mr Smooth Pro Com Console £
	  if (currencycode == 1) {return '150';} //Mr Smooth Pro Com Console US$
	  if (currencycode == 2) {return '170';} //Mr Smooth Pro Com Console Aus$
	  if (currencycode == 3) {return '125';} //Mr Smooth Pro Com Console Euros
	  if (currencycode == 4) {return '14000';} //Mr Smooth Pro Com Console Yen
	  if (currencycode == 5) {return '160';} //Mr Smooth Pro Com Console US$
  }
	  if (productnumber == 11)	{
	  if (currencycode == 0) {return '10';} //MP3 Tracks £
	  if (currencycode == 1) {return '17';} //MP3 Tracks US$
	  if (currencycode == 2) {return '24';} //MP3 Tracks Aus$
	  if (currencycode == 3) {return '14';} //MP3 Tracks Euros
	  if (currencycode == 4) {return '2000';} //MP3 Tracks Yen
	  if (currencycode == 5) {return '19';} //MP3 Tracks CAD$
  }	  if (productnumber == 12)	{
	  if (currencycode == 0) {return '14';} //Freestyler Pad £
	  if (currencycode == 1) {return '19';} //Freestyler Pad US$
	  if (currencycode == 2) {return '29';} //Freestyler Pad Aus$
	  if (currencycode == 3) {return '16';} //Freestyler Pad Euros
	  if (currencycode == 4) {return '1800';} //Freestyler Pad Yen
	  if (currencycode == 5) {return '21';} //Freestyler Pad CAD$
  }	  if (productnumber == 13)	{
	  if (currencycode == 0) {return '12';} //Freestyler Pad Junior £
	  if (currencycode == 1) {return '17';} //Freestyler Pad Junior US$
	  if (currencycode == 2) {return '27';} //Freestyler Pad Junior Aus$
	  if (currencycode == 3) {return '14';} //Freestyler Pad Junior Euros
	  if (currencycode == 4) {return '1600';} //Freestyler Pad Junior Yen
	  if (currencycode == 5) {return '19';} //Freestyler Pad Junior CAD$
  }	  if (productnumber == 14)	{
	  if (currencycode == 0) {return '38';} //tec toc £
	  if (currencycode == 1) {return '50';} //tec toc US$
	  if (currencycode == 2) {return '70';} //tec toc Aus$
	  if (currencycode == 3) {return '45';} //tec toc Euros
	  if (currencycode == 4) {return '4500';} //tec toc Yen
	  if (currencycode == 5) {return '55';} //tec toc CAD$
  }	  if (productnumber == 15)	{
	  if (currencycode == 0) {return '25';} //snorkel price £
	  if (currencycode == 1) {return '35';} //snorkel US$
	  if (currencycode == 2) {return '49';} //snorkel Aus$
	  if (currencycode == 3) {return '29';} //snorkel Euros
	  if (currencycode == 4) {return '3300';} //snorkel Yen
	  if (currencycode == 5) {return '38';} //snorkel CAD$
  }	  if (productnumber == 16)	{
	  if (currencycode == 0) {return '15';} //Pull Buoy price £
	  if (currencycode == 1) {return '20';} //Pull Buoy US$
	  if (currencycode == 2) {return '26';} //Pull Buoy Aus$
	  if (currencycode == 3) {return '19';} //Pull Buoy Euros
	  if (currencycode == 4) {return '2000';} //Pull Buoy Yen
	  if (currencycode == 5) {return '22';} //Pull Buoy CAD$
  }	  if (productnumber == 17)	{
	  if (currencycode == 0) {return '10';} //fins price £
	  if (currencycode == 1) {return '17';} //fins US$
	  if (currencycode == 2) {return '24';} //fins Aus$
	  if (currencycode == 3) {return '14';} //fins Euros
	  if (currencycode == 4) {return '2000';} //fins Yen
	  if (currencycode == 5) {return '19';} //fins CAD$
  }	  if (productnumber == 18)	{
	  if (currencycode == 0) {return '110';} //swimp3 £
	  if (currencycode == 1) {return '150';} //swimp3 US$
	  if (currencycode == 2) {return '249';} //swimp3 Aus$
	  if (currencycode == 3) {return '149';} //swimp3 Euros
	  if (currencycode == 4) {return '14000';} //swimp3 Yen
	  if (currencycode == 5) {return '165';} //swimp3 CAD$
  }	  if (productnumber == 19)	{
	  if (currencycode == 0) {return '5';} //swim cap £
	  if (currencycode == 1) {return '8';} //swim cap US$
	  if (currencycode == 2) {return '10';} //swim cap Aus$
	  if (currencycode == 3) {return '7';} //swim cap Euros
	  if (currencycode == 4) {return '1000';} //swim cap Yen
	  if (currencycode == 5) {return '9';} //swim cap CAD$
  }	  if (productnumber == 20)	{
	  if (currencycode == 0) {return '30';} //3x-100m £
	  if (currencycode == 1) {return '45';} //3x-100m US$
	  if (currencycode == 2) {return '50';} //3x-100m Aus$
	  if (currencycode == 3) {return '35';} //3x-100m Euros
	  if (currencycode == 4) {return '4500';} //3x-100m Yen
	  if (currencycode == 5) {return '48';} //3x-100m CAD$
  }
  
return null;
}