//Adam's 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 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'))+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'))+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 Huddersfield Fri Jan 15th');}
if (clinicloc == 1) {return ('SS Clinic Windsor Fri Jan 8th');}
if (clinicloc == 2) {return ('SS Clinic Windsor Sat Jan 9th');}
if (clinicloc == 3) {return ('SS Clinic Windsor Sun Jan 10th');}
}

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();}
}

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)');}
  }
  //training plans
  else if (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 ('GB &pound;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 6) {return ('US $' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 7) {return ('AUS $' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 8) {return ('Euro &euro;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 9) {return ('Yen &yen;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 10) {return ('GB &pound;' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 11) {return ('US $' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 12) {return ('AUS $' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 13) {return ('Euro &euro;' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 14) {return ('Yen &yen;' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
  }
    else if (productnumber == '3') {
	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 ('GB &pound;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 6) {return ('US $' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 7) {return ('AUS $' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 8) {return ('Euro &euro;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 9) {return ('Yen &yen;' + productprice(productnumber, currencycode-5) + ' (Level 2)');}
	if (currencycode == 10) {return ('GB &pound;' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 11) {return ('US $' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 12) {return ('AUS $' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 13) {return ('Euro &euro;' + productprice(productnumber, currencycode-10) + ' (Level 3)');}
	if (currencycode == 14) {return ('Yen &yen;' + productprice(productnumber, currencycode-10) + ' (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 ('GB &pound;' + productprice(productnumber, currencycode-5) + ' (Mac Version)');}
	if (currencycode == 6) {return ('US $' + productprice(productnumber, currencycode-5) + ' (Mac Version)');}
	if (currencycode == 7) {return ('AUS $' + productprice(productnumber, currencycode-5) + ' (Mac Version)');}
	if (currencycode == 8) {return ('Euro &euro;' + productprice(productnumber, currencycode-5) + ' (Mac Version)');}
	if (currencycode == 9) {return ('Yen &yen;' + productprice(productnumber, currencycode-5) + ' (Mac Version');}*/
  }
  //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 ('GB &pound;' + productprice(productnumber, currencycode-5) + ' (Pink Cap)');}
	if (currencycode == 6) {return ('US $' + productprice(productnumber, currencycode-5) + ' (Pink Cap)');}
	if (currencycode == 7) {return ('AUS $' + productprice(productnumber, currencycode-5) + ' (Pink Cap)');}
	if (currencycode == 8) {return ('Euro &euro;' + productprice(productnumber, currencycode-5) + ' (Pink Cap)');}
	if (currencycode == 9) {return ('Yen &yen;' + productprice(productnumber, currencycode-5) + ' (Pink Cap)');}
  }
  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));}
  }
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') {productnamebuild = productnamebuild + ' Level 1';} 
	  if (currencycode == '5' || currencycode == '6' || currencycode == '7' || currencycode == '8' || currencycode == '9') {productnamebuild = productnamebuild + ' Level 2';}
	  if (currencycode == '10' || currencycode == '11' || currencycode == '12' || currencycode == '13' || currencycode == '14') {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%2C17'); }
		if (currencycode == '6') { return ('pp%2C1%2C22'); }
		if (currencycode == '7') { return ('pp%2C1%2C23'); }
		if (currencycode == '8') { return ('pp%2C1%2C24'); }
		if (currencycode == '9') { return ('pp%2C1%2C25'); }*/
		}
	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%2C31'); }
		if (currencycode == '6') { return ('pp%2C1%2C32'); }
		if (currencycode == '7') { return ('pp%2C1%2C33'); }
		if (currencycode == '8') { return ('pp%2C1%2C34'); }
		if (currencycode == '9') { return ('pp%2C1%2C35'); }*/
		}
	//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 (productnumber == '12') { return ('Freestyler Paddles'); }
	if (productnumber == '13') { return ('Freestyler Paddles *Junior Version*'); }
	if (productnumber == '14') { return ('Finis Tec 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') {productnamebuild = productnamebuild + ' (Blue)';} 
	  if (currencycode == '5' || currencycode == '6' || currencycode == '7' || currencycode == '8' || currencycode == '9') {productnamebuild = productnamebuild + ' (Pink)';}
	  return (productnamebuild);
	}
	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)');}
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></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></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></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></SELECT>');
}
//product number 5 is clinics - set this up for January 2010 UK clinics
else if ( productnumber == 5 )
{
  /*return ('<SELECT name="currency" onChange="selectpriceandsubmitclinics(this,' + productnumber + ')"><OPTION value="default">Buy Now: </OPTION><OPTION value="1">' + 'Windsor Fri Jan 8th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="2">' + 'Windsor Sat Jan 9th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="3">' + 'Windsor Sun Jan 10th:  ' + productpriceandsymbol(productnumber,0) + '</OPTION><OPTION value="0">' + 'Huddersfield Fri 15th:  ' + 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></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 { currencycodetotext="unknown"; }
}

//filter down currency codes on training plans
function filtercurrency(currencycode)
{
	currencycode = parseInt(currencycode);
	if (currencycode >= 5) { currencycode = currencycode - 5;}
	if (currencycode >= 5) { currencycode = currencycode - 5;}
	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));
		var expires = "; expires="+date.toGMTString();
	}
	else var 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 (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 (productnumber == 5) {
	  return '0'; //Clinic £
  }
	  if (productnumber == 6)	{
		  //no product 6 currently
  }
	  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 (productnumber == 8)	{
	  if (currencycode == 0) {return '1.543';} //PT Paddles £
	  if (currencycode == 1) {return '3';} //PT Paddles US$
	  if (currencycode == 2) {return '4.4';} //PT Paddles Aus$
	  if (currencycode == 3) {return '1.931';} //PT Paddles Euros
	  if (currencycode == 4) {return '414';} //PT Paddles Yen
  }
	  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 (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 (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 (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 (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 (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 (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
  }
  
return null;
	
}

//return price by currency
function productprice(productnumber, currencycode) {
  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 == 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 (productnumber == 3 | productnumber == 4 )	{
	  if (currencycode == 0) {return '25';} //Training Plan £
	  if (currencycode == 1) {return '45';} //Training Plan US$
	  if (currencycode == 2) {return '60';} //Training Plan Aus$
	  if (currencycode == 3) {return '35';} //8Training Plan Euros
	  if (currencycode == 4) {return '5000';} //Training Plan Yen
  }
	  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 (productnumber == 6)	{
//no product 6 currently
  }
	  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 (productnumber == 8)	{
	  if (currencycode == 0) {return '20';} //PT Paddles £
	  if (currencycode == 1) {return '35';} //PT Paddles US$
	  if (currencycode == 2) {return '50';} //PT Paddles Aus$
	  if (currencycode == 3) {return '30';} //PT Paddles Euros
	  if (currencycode == 4) {return '4000';} //PT Paddles Yen
  }
  //these prices are just labels, transaction prices are set within our secure download software.
	  if (productnumber == 9)	{
	  if (currencycode == 0) {return '20';} //Mr Smooth Pro Enthusiasts Console £
	  if (currencycode == 1) {return '35';} //Mr Smooth Pro Enthusiasts Console US$
	  if (currencycode == 2) {return '50';} //Mr Smooth Pro Enthusiasts Console Aus$
	  if (currencycode == 3) {return '30';} //Mr Smooth Pro Enthusiasts Console Euros
	  if (currencycode == 4) {return '4000';} //Mr Smooth Pro Enthusiasts Console Yen
  }
	  if (productnumber == 10)	{
	  if (currencycode == 0) {return '100';} //Mr Smooth Pro Com Console £
	  if (currencycode == 1) {return '175';} //Mr Smooth Pro Com Console US$
	  if (currencycode == 2) {return '240';} //Mr Smooth Pro Com Console Aus$
	  if (currencycode == 3) {return '140';} //Mr Smooth Pro Com Console Euros
	  if (currencycode == 4) {return '20000';} //Mr Smooth Pro Com Console Yen
  }
	  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 (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 (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 (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 (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 (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 (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 (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 (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
  }
  
return null;
}