function winPopUp(url,w,h) 
{
	win=window.open(url,'dolphinfitness','toolbar=0, location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=yes,top=100,left=100,width='+w+',height='+h);
}

function photoPopUp(src, desc)
{
	ShowLargeProductPicture (src);
}

function infoPopUp(secure, v)
{
	if (secure)
	{
		winPopUp('/fitness/info?' + v, 200, 200);
	}
	else
	{
		winPopUp('/info?' + v, 400, 400);
	}
}

function setCurrency (id, jump)
{
	document.location='/do/set-currency/' + id + '/?jump=' + jump; 
}

function setLanguage (id, jump)
{
	document.location='/do/set-language/' + id + '/?jump=' + jump; 
}

function gotoURL (url)
{
	document.location=url;
}

function ChangeInnerHTML(LayerName, TSV1) 
{
    if (document.layers) 
	{
		TP = document.layers[LayerName].document; TP.open(); TP.write(TSV1); TP.close();
	}
    else if (document.getElementById) 
	{
		document.getElementById(LayerName).innerHTML = TSV1;
	}
	else if (document.all) 
	{
		document.all[LayerName].innerHTML = TSV1;
	}
}


function AppendInnerHTML(LayerName, TSV1) 
{
    if (document.layers) 
	{
		TP = document.layers[LayerName].document; TP.open(); TP.write(TSV1); TP.close();

	}
    else if (document.getElementById) 
	{
		document.getElementById(LayerName).innerHTML += TSV1;
	}
	else if (document.all) 
	{
		document.all[LayerName].innerHTML += TSV1;
	}
}

function ChangeInnerText(LayerName, TSV1) 
{
    if (document.layers) 
	{
		TP = document.layers[LayerName].document; TP.open(); TP.write(TSV1); TP.close();
	}
    else if (document.getElementById) 
	{
		document.getElementById(LayerName).innerText = TSV1;
	}
	else if (document.all) 
	{
		document.all[LayerName].innerText = TSV1;
	}
}



function FocusOnSearch (obj)
{
	obj.innerText = '';
}

function ToggleTextSize ()
{
	var E = GetElement ("enlarge_text");
	var islarge = (E.innerText == "Reduce text size");

	if (islarge)
	{
	    E = GetElement ("content");
		E.style.fontSize = "100%";

		E = GetElement ("contents");
		E.style.fontSize = "100%";

		E = GetElement ("enlarge_text");
		E.innerText = "Enlarge text"; 
	}
	else
	{
	    E = GetElement ("content");
		E.style.fontSize = 10 + "pt";

		E = GetElement ("contents");
		E.style.fontSize = 9 + "pt";

		E = GetElement ("enlarge_text");
		E.innerText = "Reduce text size"; 
	}
}

function tab_menu_on (n)
{ 
	E = GetElement ("tab_menu_" + n);
	F = GetElement ("tab_menu_li_0");

	if ( (E != null) && (F != null) )
	{
		TV1 = F.offsetHeight;

		TV2 = 0;
		for (TV3 = 0 ; TV3 < n ; TV3 ++)
		{
			F = GetElement ("tab_menu_li_" + TV3);

			if ( F != null )
			{
				TV2 += parseInt (F.offsetWidth) + 2;
			}
		}
		E.style.position = "absolute";
		E.style.visibility = "visible"; 
		E.style.left = TV2 + "px";
		E.style.top = TV1 + "px";
	}
}

function setprodphoto (url)
{
	E = GetElement ("prodphoto");
	
	if ( E != null )
	{ 
		E.src = url; 
	}
}

function tab_menu_off (n)
{
	E = GetElement ("tab_menu_" + n);
	
	if ( E != null )
	{
		E.style.visibility = "hidden"; 
	}
}

function AddFavourite ()
{
   if (document.all)
   {
      window.external.AddFavorite ("http://www.dolphinfitness.co.uk","Dolphin Fitness");
   }
 }


function submit_payment (totalprice, deliveryoption)
{
	ChangeInnerText("totalprice", totalprice);
	
    E = GetElement ("delivery_option");
    
	  if ( E != null )
	  {
		 E.value = deliveryoption;  
	  }
	  
 	return true; 
}

function setDeliveryOption (totalprice, deliveryrequest, deliveryband, deliveryrate)
{
	ChangeInnerText("totalprice", totalprice);
	
    E = GetElement ("delivery_option");
    
	  if ( E != null )
	  {
		 E.value = deliveryband;  
	  }
	  
    F = GetElement ("delivery_request");
    
	  if ( F != null )
	  {
		 F.value = deliveryrequest;
	  }

    G = GetElement ("delivery_rate");
    
	  if ( G != null )
	  {
		 G.value = deliveryrate;
	  }

 	return true; 
}

function ALTsetDeliveryOption (totalprice, deliveryrequest, deliveryband, deliveryrate)
{
	ALTChangeInnerText("totalprice", totalprice);
	
    E = GetElement ("delivery_option");
    
	  if ( E != null )
	  {
		 E.value = deliveryband;  
	  }
	  
    F = GetElement ("delivery_request");
    
	  if ( F != null )
	  {
		 F.value = deliveryrequest;
	  }

    G = GetElement ("delivery_rate");
    
	  if ( G != null )
	  {
		 G.value = deliveryrate;
	  }

 	return true; 
}

function ALTChangeInnerText(LayerName, TSV1) 
{
    if (document.layers) 
	{
		TP = document.layers[LayerName].document; TP.open(); TP.write(TSV1); TP.close();
	}
    else if (document.getElementById) 
	{
		document.getElementById(LayerName).innerText = TSV1;
	}
	else if (document.all) 
	{
		document.all[LayerName].innerText = TSV1;
	}
}


function update_basket (e)
{
   if ( e == null ) return true;
	
   ids = e.split(",");
   x = ids.length;
   y = 0;

   for (i=0; i <= x; i++)
   {	  
	  E = GetElement ("update_qty[" + ids[i] + "]");
	  F = GetElement ("v[update_new_qty_" + ids[i] + "]");
	
	  if ( (E != null) && (F != null) )
	  {
		 if ( F.value != E.value )
		 {
		 	F.value = E.value; 
		 	
		 	y ++;
		 }
	  }
   }
   
  if (y == 0) 
  {
  	alert ("Click 'checkout' to proceed");
  	
  	return false;
  }

  G = GetElement ("basket_update_submit");
  
  if (G != null)
  {
  	G.style.visibility = "hidden";
  	ChangeInnerHTML ("basket_update_loading", "Please Wait ...");
  }

   return true;
}

function submit_package (n)
{

	add_gift_pid (1);
	
   A = GetElement ("buyoptions");
   if (A == null) return false;

   B = GetElement ("package_id");
   if (B == null) return false;
   
   B.value = n;
   
   return A.submit();
}

function submit_order (a, b, c, d)
{
	add_so_buys(a);
	add_also_pids(b);
	add_gift_pid(c);

	add_multi_buys(d);
	
	return true;
}

function add_also_pids (n)
{
   A = GetElement ("also_pids");
   if (A == null) return true;
 
   v = "";
	
   for (i=1; i<=n; i++)
   {	  
	  E = GetElement ("also_pid[" + i + "]");
	  if ( (E != null) && (E.checked) )
	  {
		 v += E.value + ",";  
	  }
   }
   A.value = v;

   return true;
}

function add_multi_buys (n)
{
   A = GetElement ("multi_pids");
   if (A == null) return true;
   
 
   v = "";
   
   ids = n.split(",");
   x = ids.length;
 	
   for (i=0; i <= x; i++)
   {	  
	  E = GetElement ("multibuy_pid[" + ids[i] + "]");
	
	  if ( (E != null) )
	  {
		 v += ids[i] + "[" + E.value + "]";  
	  }
   }
   A.value = v;
   

   return true;
}

function add_so_buys (n)
{
   A = GetElement ("so_buys");
   if (A == null) return true;
 
   v = "";
	
   for (i=1; i<=n; i++)
   {	  
	  E = GetElement ("so_buy[" + i + "]");
	  if ( (E != null) && (E.checked) )
	  {
		 v += E.value + ",";  
	  }
   }
   A.value = v;

   return true;
}

function add_gift_pid (n)
{
   A = GetElement ("gift_pid");
   if (A == null) return true;

   B = GetElement ("select_gift_pid");
   if (B == null) return true;


   A.value = B.value;

   return true;
}


EnquiryHandler = '/do/register-enquiry';
ReviewHandler = '/do/register-review';

function CreateMenu (TP1, TSV1) {
 var TV1, TV2, TP2, TP3, TSV2;

 TV1 = TSV1.split('_').length;
 TV2 = 0;

 for (TP2 in TP1) {

  TV2++;
  TSV2 = TSV1 + '_' + TV2;

  if ((typeof TP1[TP2]) == 'object') {

   document.write("<DIV id='Menu_" + TSV2 + "' class='MenuLevel" + TV1 + "' onmouseover='HandleOnMouseOver(\"" + TSV2 + "\", " + TV1 + ", true)' onmouseout='HandleOnMouseOut(\"" + TSV2 + "\", " + TV1 + ", true)'>");
    document.write(TP2);
    document.write("<DIV id='Menu_" + TSV2 + "L' style='VISIBILITY:hidden; POSITION:fixed; Z-INDEX:" + (TV1 * 10) + "'>");
     CreateMenu(TP1[TP2], TSV2);
    document.write("</DIV>");
   document.write("</DIV>");

  } else if (TP1[TP2] == '') {

   document.write(
    "<DIV id='Menu_" + TSV2 + "' class='MenuHeaderLevel" + TV1 + "'>"
   + TP2
  + "</DIV>"
   );

  } else {

   document.write(
    "<A href='" + TP1[TP2] + "' class='MenuLinkLevel" + TV1 + "'>"
   + "<DIV id='Menu_" + TSV2 + "' class='LinkMenuLevel" + TV1 + "' style='CURSOR:pointer' onmouseover='HandleOnMouseOver(\"" + TSV2 + "\", " + TV1 + ", false)' onmouseout='HandleOnMouseOut(\"" + TSV2 + "\", " + TV1 + ", false)'>"
    + TP2
   + "</DIV>"
  + "</A>"
   );

  }
 }
}


function ShowMenu (TSV1) {
	
	var TSV2, TV1, TV2, TV3, TV4, TA1, TA2, TA3, TP1, TP2, TP3;
	
	TA2 = TSV1.split('_');
	TSV2 = 'Menu_' + TA2[0] + '_' + TA2[1];
	TP2 = GetElement(TSV2);
	
	TA1 = FindPosition(TP2);

	TV3 = TA1['Left'] + TP2.offsetWidth;
	TV4 = TA1['Top'];

	TV1 = TA2.length;
	for (TV2 = 2; TV2 <= TV1 - 1; TV2++) {
	
		TSV2 += '_' + TA2[TV2];
		TP3 = GetElement(TSV2);
		TV3 += TP3.offsetWidth;
	
		TV4 += (parseInt(TA2[TV2]) - 1) * (TP3.offsetHeight - Menu_ReverseMargin);
 	}
 	
 	TP1 = GetElement('Menu_' + TSV1 + 'L');
 	TP1.style.visibility = 'visible';
 	
 	TA3 = GetScrollXY()
 	TP1.style.left = (TV3 - TA3[0] - ((TV1 - 1) * Menu_ReverseOffset)) + 'px';
 	TP1.style.top = (TV4 - TA3[1]) + 'px';
 	
 	return;
}

function HideMenu (TSV1) {
 GetElement('Menu_' + TSV1 + 'L').style.visibility = 'hidden';
}

function HandleOnMouseOut (TSV1, TV1, TBV1) {
 if (TBV1) {
  HideMenu(TSV1);
 }
 GetElement('Menu_' + TSV1).className = (TBV1 ? '' : 'Link') + 'MenuLevel' + TV1;
}

function HandleOnMouseOver (TSV1, TV1, TBV1) {
 if (TBV1) {
  ShowMenu(TSV1);
 }
 GetElement('Menu_' + TSV1).className = (TBV1 ? '' : 'Link') + 'MenuLevel' + TV1 + 'Over';
}

function ReplaceAll (TSV1, TSV2, TSV3) {
 if (TSV2 != TSV3) {
  while (TSV1.indexOf(TSV2) != -1) {
   TSV1 = TSV1.replace(TSV2, TSV3);
  }
 }
 return TSV1;
}

function FindPosition (TP1) {
 var TA1 = {
  'Left':0,
  'Top':0
 };

 if (TP1.offsetParent) {
  do {
   TA1['Left'] += TP1.offsetLeft;
   TA1['Top'] += TP1.offsetTop;

  } while ((TP1.style.position != 'fixed') && (TP1 = TP1.offsetParent));
 }

 return TA1;
}

function GetScrollXY () {
 var scrOfX = 0, scrOfY = 0;

 if (typeof(window.pageYOffset) == 'number') {
  scrOfY = window.pageYOffset;
  scrOfX = window.pageXOffset;
 } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
  scrOfY = document.body.scrollTop;
  scrOfX = document.body.scrollLeft;
 } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
  scrOfY = document.documentElement.scrollTop;
  scrOfX = document.documentElement.scrollLeft;
 }

 return [scrOfX, scrOfY];
}

function GetElement (TSV1) 
{
  if (document.getElementById) 
  {
    if (document.getElementById(TSV1) != null) 
    {
   	   return document.getElementById(TSV1);
    }
  }
  
  if (document.all)
  {
  	return document.all[TSV1];
  }
  return null;
}

function ReplaceAll (TSV1, TSV2, TSV3) {
 if (TSV2 != TSV3) {
  while (TSV1.indexOf(TSV2) != -1) {
   TSV1 = TSV1.replace(TSV2, TSV3);
  }
 }
 return TSV1;
}

function win_center(e)
{
  var box = GetElement(e);
  
  boxw = 1000;

  var TA1 = GetWindowDimensions ();

  var x = (TA1[0] / 2) - (boxw / 2) - 10;
  

  box.style.left = x + "px";
  box.style.display = "block";
 }
 
function GetWindowDimensions () {
                var myWidth = 0, myHeight = 0;
 
                if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
                                myWidth = document.body.clientWidth;
                                myHeight = document.body.clientHeight;
                } else if (typeof(window.innerWidth) == 'number') {
                                myWidth = window.innerWidth;
                                myHeight = window.innerHeight;
                } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
                                myWidth = document.documentElement.clientWidth;
                                myHeight = document.documentElement.clientHeight;
                }
 
                return [myWidth, myHeight];
}

function SetElementOpacity (TSV1, TSV2) {
	var TP1;

	TP1 = GetElement(TSV1).style;
	TP1.filter = (TSV2 != '' ? 'alpha(opacity=' + (TSV2 * 100) + ')' : '');
	if (TP1.setProperty) {
		TP1.setProperty('opacity', TSV2, '');
		TP1.setProperty('-moz-opacity', TSV2, '');
		TP1.setProperty('-khtml-opacity', TSV2, '');
	}
}

function MoveLargeProductPictureLayer () {
	var TA1, TA2;

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - GetElement('ProductLargePicture').width) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 60) + "px";

}

function ShowLargeProductPicture (id) {
	var TSV1, TP1;

	TSV1 = "<TABLE cellpadding='1' cellspacing='0' style='BORDER: 1px solid #000'>"
	      + "<TR style='BACKGROUND:#f0f7ff'>"
	       + "<TD style='TEXT-ALIGN:right; PADDING:0;'>"
	        + "<A href='javascript:HideLargeProductPicture()'><IMG src='/u/001-close.gif' alt='Close'></A>"
	       + "</TD>"
	       + "</TR>"
	       + "<TR>"
	        + "<TD style='BACKGROUND:#E0E7F0'>"
	         + "<IMG id='ProductLargePicture' src='/rs/pictures/" + "tn1_" + id + ".jpg' onclick='HideLargeProductPicture()'>"
	        + "</TD>"
	       + "</TR>"
	      + "</TABLE>";
	ChangeInnerHTML('HiddenLayer', TSV1);

	SetElementOpacity('outline', '0.25');

	GetElement('HiddenLayer').style.visibility = 'visible';

	GetElement('ProductLargePicture').onload = MoveLargeProductPictureLayer;
}



function HideLargeProductPicture () {
	var TP1;

	GetElement('HiddenLayer').style.visibility = 'hidden';

	SetElementOpacity('outline', '');
}

function ShowPromoInfo () {
	var TSV1, TP1;

	TSV1 = "<TABLE cellpadding='1' cellspacing='0' style='BORDER: 1px solid #000; width: 300px;'>"
	      + "<TR style='BACKGROUND:#f0f7ff'>"
	       + "<TD style='TEXT-ALIGN:right; PADDING:0;'>"
	        + "<A href='javascript:HideLargeProductPicture()'><IMG src='/u/001-close.gif' alt='Close'></A>"
	       + "</TD>"
	       + "</TR>"
	       + "<TR style='BACKGROUND:#fff;'>"
	        + "<TD style='BACKGROUND:#fff; padding: 10px 10px 20px 10px; text-align: justify'>"
	         + promo
	         + "<br /><br /><a href='/en/promotions'>Click here to see other promotions</a>"
	        + "</TD>"
	       + "</TR>"
	      + "</TABLE>";
	ChangeInnerHTML('HiddenLayer', TSV1);

	SetElementOpacity('outline', '0.25');

	GetElement('HiddenLayer').style.visibility = 'visible';

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 300) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 60) + "px";
}


function doPromotion (x, exec, after) {
	var TSV1, TSV2, TP1;

	if ( exec == 1 )
	{
		TSV2 = "<iframe src='/do/promotion/id/" + x + "' scrolling='no' frameborder='0' width='100%' height='6px'></iframe>"
			 + promoWhatNow;
	}
	else
	{
		TSV2 = promoWhatNow;
	}

	TSV1 = "<TABLE cellpadding='1' cellspacing='0' style='BORDER: 1px solid #000; width: 460px;'>"
	      + "<TR style='BACKGROUND:#f0f7ff'>"
	       + "<TD style='TEXT-ALIGN:right; PADDING:0;'>"
	        + "<A href='javascript:HideLargeProductPicture()'><IMG src='/u/001-close.gif' alt='Close'></A>"
	       + "</TD>"
	       + "</TR>"
	       + "<TR style='BACKGROUND:#fff;'>"
	        + "<TD style='BACKGROUND:#fff; padding: 10px 10px 20px 10px; text-align: justify'>"
	         + "<h3>" + promoArray[x].t + "</h3>"
	         + "<img src='" + promoArray[x].i + "' style='float:right;border:1px solid #c0d0e0;margin: 0 0 10px 10px'>"
	         + promoArray[x].n
	         + "<div style='width:100%;clear:both;border-top:1px solid #c0d0e0;padding:6px 0 6px 0;margin: 6px 0 0 0;'>"
	         + TSV2
	         + "</div>"
	        + "</TD>"
	       + "</TR>"
	      + "</TABLE>";
	ChangeInnerHTML('HiddenLayer', TSV1);

	SetElementOpacity('outline', '0.25');

	GetElement('HiddenLayer').style.visibility = 'visible';

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 460) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 60) + "px";
	
	if (exec == 1) 
	{
		if (after == 0) 
		{
			GetElement('promo_hlink').href = promoArray[x].h;
		}
		else
		{
			GetElement('promo_hlink').href = after;
		}
	}
}

function doMyAccount (a, x) {
	var TSV1, TP1, TSV2;

		if (x != null) { TSV2 = x; } else { TSV2 = ""; }

	TSV1 = "<TABLE cellpadding='1' cellspacing='0' style='BORDER: 1px solid #000; width: 600px;'>"
	      + "<TR style='BACKGROUND:#f0f7ff'>"
	       + "<TD style='TEXT-ALIGN:right; PADDING:0;'>"
	        + "<A href='javascript:HideLargeProductPicture()'><IMG src='/u/001-close.gif' alt='Close'></A>"
	       + "</TD>"
	       + "</TR>"
	       + "<TR style='BACKGROUND:#fff;'>"
	        + "<TD style='BACKGROUND:#fff; padding: 10px 10px 20px 10px; text-align: justify'>"
	         + TSV2
	         + myAccountInfo
	        + "</TD>"
	       + "</TR>"
	      + "</TABLE>";
	ChangeInnerHTML('HiddenLayer', TSV1);
	
	if (a != null) GetElement('v_login_after').value = a;

	SetElementOpacity('outline', '0.25');

	GetElement('HiddenLayer').style.visibility = 'visible';

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 600) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 60) + "px";
}

function doMyReviewAccount (a)
{
//	x = "<a href='#'>-</a>";
	doMyAccount (a);
}

function doReviewRating (x,a,exec) {
	var TSV1, TP1;

	if (a == 0)
	{
		doMyAccount();
		return;
	}

	TSV2 = "<iframe src='/do/review-rating/" + x + "/" + exec + "' scrolling='no' frameborder='0' width='100%' height='6px'></iframe>";

	TSV1 = "<TABLE cellpadding='1' cellspacing='0' style='BORDER: 1px solid #000; width: 200px;'>"
	      + "<TR style='BACKGROUND:#f0f7ff'>"
	       + "<TD style='TEXT-ALIGN:right; PADDING:0;'>"
	        + "<A href='javascript:HideLargeProductPicture()'><IMG src='/u/001-close.gif' alt='Close'></A>"
	       + "</TD>"
	       + "</TR>"
	       + "<TR style='BACKGROUND:#fff;'>"
	        + "<TD style='BACKGROUND:#fff; padding: 10px 10px 20px 10px; text-align: center; color: black;'>"
	         + TSV2
	         + "Thank you for your feedback ..."
   	         + "<br /><br /><a href='javascript:HideLargeProductPicture();'><img src='/u/001-continue.gif' style='margin: 0 40px 0 0'></a>"
	        + "</TD>"
	       + "</TR>"
	      + "</TABLE>";
	ChangeInnerHTML('HiddenLayer', TSV1);

	SetElementOpacity('outline', '0.25');

	GetElement('HiddenLayer').style.visibility = 'visible';

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 200) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 200) + "px";
	
}


function doStarRatingOver (x,n,m) 
{
	var TSV1; 

	for (TSV1 = 1 ; TSV1 <= n ; TSV1++)
	{
		GetElement("_star_" + TSV1 + "_" + x).src = "/pic/star1.gif";
	}

	for ( ; TSV1 <= m ; TSV1++)
	{
		GetElement("_star_" + TSV1 + "_" + x).src = "/pic/star0.gif";
	}
}
function doStarRatingOut (x,n,m) 
{
	doStarRatingOver (x, GetElement(x).value, m);
}
function doStarRatingClick (x,n,m) 
{
	GetElement(x).value = n; 
}

function doSliderOver (x,n,m,t,a) 
{
	var TSV1; 

	for (TSV1 = 1 ; TSV1 <= n ; TSV1++)
	{
		if ( (a > 0) && (TSV1 == n) )
		{
			if (TSV1 == 1)
			{
				GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "2f.gif";
			}
			else if (TSV1 == m)
			{
				GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "2l.gif";
			}
			else
			{
				GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "2.gif";
			}
		}
		else if ( (a > 0) && (TSV1 == 1) )
		{
			GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "1f.gif";
		}
		else if ( (a == 0) && (TSV1 == n) )
		{
			GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "2.gif";
		}
		else
		{
			GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "1.gif";
		}
	}
	

	for ( ; TSV1 <= m ; TSV1++)
	{
		if ( TSV1 == m )
		{
			if (a > 0)
			{
				GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "0l.gif";
			}
			else
			{
				GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "0.gif";
			}
		}
		else if ( (TSV1 == 1) && (a > 0) )
		{
			GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "0f.gif";
		}
		else
		{
			GetElement("_slider_" + TSV1 + "_" + x).src = "/u/" + t + "0.gif";
		}
	}
}

function doSliderOut (x,n,m,t,a) 
{
	doSliderOver (x, GetElement(x).value, m, t, a);
}
function doSliderClick (x,n,m,t,a) 
{
	GetElement(x).value = n; 
}


var myTabEvent;
var myTabView = 1;

function closeOtherTabs (t)
{
	var TV1;

	for (TV2 = 0 ; TV2 < myTabsCount ; TV2 ++)
	{
		TV1 = myTabsID + "_" + TV2;
		
		if ( TV1 != t ) doTabsMouseOut (TV1, 5);
	}
	
	return;
}

function tryTabsMouseOver (t, e)
{
	closeOtherTabs (t);
	
	if ( GetElement(t+"d").style.visibility == "visible" )
	{
		return;
	}
	
	if ( myTabEvent == null )
	{
		var eventCopy ={};
		for (var i in e) eventCopy[i] = e[i];

		myTabEvent = e;
		setTimeout (function() {tryTabsMouseOver(t, eventCopy)}, 150);
		return;
	}

		myTabEvent = null;

	if ( myTabView == 0 ) 
	{
		myTabView = 1;
		return;
	}

	TVtp = FindPosition(GetElement(t));

 	TVmp = GetScrollXY();

 	TVmpx = parseInt(TVmp[0]) - parseInt(TVtp['Left']) + parseInt(e.clientX);
 	TVmpy = parseInt(TVmp[1]) - parseInt(TVtp['Top']) + parseInt(e.clientY);

	if ( TVmpy < 0 ) return;
	if ( TVmpx < 0 ) return;
	if ( TVmpy > 23 ) return;
	if ( TVmpx > 150 ) return;
	

	doTabsMouseOver (t, e);
}

function doTabsMouseOver (t, e)
{
	closeOtherTabs (t);
	
	myTabEvent = null;

	GetElement(t).style.backgroundPosition = "center bottom";
	GetElement(t+"d").style.visibility = "visible";

	GetElement(myTabsID + "_find_key").style.visibility = "hidden";
}
function tryTabsMouseOut (t, e)
{
	TVtp = FindPosition(GetElement(t + "d"));

 	TVmp = GetScrollXY();

 	TVmpx = parseInt(TVmp[0]) - parseInt(TVtp['Left']) + parseInt(e.clientX);
 	TVmpy = parseInt(TVmp[1]) - parseInt(TVtp['Top']) + parseInt(e.clientY);

	if ( TVmpy < 0 ) doTabsMouseOut (t, 1);
	if ( TVmpx < 0 ) doTabsMouseOut (t, 2);
	if ( TVmpy > 500 ) doTabsMouseOut (t, 3);
	if ( TVmpx > 900 ) doTabsMouseOut (t, 4);
}
function doTabsMouseOut (t, n)
{
	if ( (n == 0) && (myTabEvent != null) )
	{
		myTabView = 0;
	}

	GetElement(t).style.backgroundPosition = "center top";
	GetElement(t+"d").style.visibility = "hidden";
	
	GetElement(myTabsID + "_find_key").style.visibility = "visible";
}
function doTabSearchSubmitOver ()
{
	GetElement(myTabsID + "_inputsearch").style.backgroundPosition = "center bottom";
}
function doTabSearchSubmitOut ()
{
	GetElement(myTabsID + "_inputsearch").style.backgroundPosition = "center top";
}

function doFB_Like (t)
{
	var E = GetElement ("fb_like");

	if ( E != null )
	{ 
		ChangeInnerHTML("fb_like", "<iframe src=\"http://www.facebook.com/plugins/like.php?href=" + t + "&amp;layout=standard&amp;show_faces=false&amp;width=370&amp;action=like&amp;font=tahoma&amp;colorscheme=light&amp;height=35\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:370px; height:35px;\" allowTransparency=\"true\"></iframe>");
	}
}

function doXFB_Like (t)
{
	var E = GetElement ("fb_like");

	if ( E != null )
	{ 
		ChangeInnerHTML("fb_like", "<fb:like href=\"http://www.dolphinfitness.co.uk\" send=\"true\" width=\"370\" show_faces=\"false\"></fb:like>");
	}
}


function select_gift_change (t)
{
	var E = GetElement ("gift_offer_pic");
	var TV1 = GetElement ("select_gift_pid");
	var TV2 = "";
	var TV3 = "<img src='/u/001-free-gift.png' style='border:0;position:absolute;right:0px;top:0;'>";
	if ( E != null )
	{
		if ( t != "" )
		{
			 TV2 = "<img src='" + t + "' style='float:left;'>" + TV3;
		}
		else if ( (TV1 != null) && (TV1.value != null) && (TV1.value != "") )
		{ 
			if ( TV1.value == 0 ) 
			{
				TV2 = "&nbsp;";
				TV1.style.marginBottom = "14px";
			}
			else
			{
				TV2 = "<img src='" + (select_gift_pic[TV1.value]) + "' style='float:left'>" + TV3;
			}
		}
		
		if ( TV2 != "" ) ChangeInnerHTML ("gift_offer_pic", TV2);
	}
}

function RemoteHTML (Layer, URL, FailJS) {
	var TP1 = null;
	
	if (window.XMLHttpRequest) {
		TP1 = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		TP1 = new ActiveXObject('Microsoft.XMLHTTP');
	}
	if (TP1 != null) {
		TP1.onreadystatechange = function () {
			if (TP1.readyState == 4) {
				if (TP1.status == 200) {
					ChangeInnerHTML(Layer, TP1.responseText);
				} else {
					eval(FailJS);
				}
			}
		};
		TP1.open('GET', URL, true);
		TP1.send(null);
	} else {
		eval(FailJS);
	}
}

function doProductPromotion (x, y) 
{
	SetElementOpacity('outline', '0.80');
	ChangeInnerHTML('HiddenLayer', "<div id='ajax_promo_wrap'><div>Loading ...<br /><br /><img src='/u/001-ajax-icon.gif'></div></div>'");
	GetElement('HiddenLayer').style.visibility = 'visible';

	GetElement('HiddenLayer').style.width = "600px";

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 600) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 120) + "px";

	RemoteHTML('HiddenLayer', '/do/ajax-promotion/' + x + '/' + y, 'return true;');
	
	return false;
}

function doSubmitBuy () 
{
   A = GetElement ("buyoptions");
   
   if (A == null) return false;

   return A.submit();
}

function closeProductPromotion () 
{
	GetElement('HiddenLayer').style.visibility = 'hidden';

	SetElementOpacity('outline', '1');
}

function doProductPromotionToggleSelection (x,y)
{
	var TV1, TV2, TV3, TV4=0, TV5=0, TV6=0, TV7=0, TV8;
	
	TV8 = GetElement('ajax_promo_rrp_span');
	
	for (TV1 = 0 ; TV1 < x ; TV1 ++)
	{
		TV2 = GetElement('ajax_promo_source' + TV1);
		
		if ( (TV2 != null) && (TV2.value != "") )
		{
			TV3 = TV2.value.split("|");
			
			TV4 += parseInt (TV3[5]) ;
			TV5 += parseInt (TV3[6]) ;
			if (TV8 != null) TV6 += parseInt (TV3[7]) ; 
		}
		
	}
	for (TV1 = 0 ; TV1 < y ; TV1 ++)
	{
		TV2 = GetElement('ajax_promo_target' + TV1);

		if ( (TV2 != null) && (TV2.value != "") )
		{
			TV3 = TV2.value.split("|");
			
			TV4 += parseInt (TV3[5]) ;
			TV5 += parseInt (TV3[6]) ;
			if (TV8 != null) TV6 += parseInt (TV3[7]) ; 
		}
	}

	TV7 = (parseInt(TV4)+parseInt(TV5))/100;
	TV4 = parseInt(TV4)/100;
	TV5 = parseInt(TV5)/100;
	
	if (TV8 != null) TV6 = parseInt(TV6)/100;

	ChangeInnerHTML('ajax_promo_price_span', ToDecimal(TV4, 2));
	ChangeInnerHTML('ajax_promo_save_span', ToDecimal(TV5, 2)) ;
//	ChangeInnerHTML('ajax_promo_normal_span', ToDecimal(TV7, 2));
	
	if (TV8 != null) ChangeInnerHTML('ajax_promo_rrp_span', ToDecimal(TV6, 2));
}

function doProductPromotionInfo (x,y)
{
	var TV1, TV2, TV3='', TV4;
	
	for (TV1 = 0 ; TV1 < x ; TV1 ++)
	{
		TV2 = GetElement('ajax_promo_source' + TV1);
		
		if ( (TV2 != null) && (TV2.value != "") )
		{
			TV3 += "s" + TV1 + "[" + TV2.value + "]";
		}
		else return false;
	}
	for (TV1 = 0 ; TV1 < y ; TV1 ++)
	{
		TV2 = GetElement('ajax_promo_target' + TV1);

		if ( (TV2 != null) && (TV2.value != "") )
		{
			TV3 += "t" + TV1 + "[" + TV2.value + "]";
		}
		else return false;
	}

	  TV2 = GetElement ("promo_info");
	  if ( TV2 != null )
	  {
		 TV2.value = TV3;  
	  }
	  else return false;
	
	return true;
}


function ToDecimal (TSV1, TV1) {
                var TV2, TSV2, TA1;
 
                TSV1 = Math.round(TSV1 * Math.pow(10, TV1)) / Math.pow(10, TV1);
 
                TA1 = TSV1.toString().split('.');
                if (TA1.length == 2) {
                                TSV2 = TA1[0] + '.';
                                if (TA1[1].length > TV1) {
                                                TSV2 += TA1[1].substring(0, TV1);
                                } else {
                                                TSV2 += TA1[1];
                                                for (TV2=1; TV2 <= (TV1 - TA1[1].length); TV2++) {
                                                                TSV2 += '0';
                                                }
                                }
                } else {
                                TSV2 = TA1[0] + '.';
                                for (TV2=1; TV2 <= TV1; TV2++) {
                                                TSV2 += '0';
                                }
                }
                return TSV2;
}

function doAutoLoad()
{
	if ( al != null ) 
	{
		for (var i in al)
		{
			E = GetElement ("alw" + i);
	
			if ( E != null )
			{
				RemoteHTML("al" + i, alp[i] + "&h=" + E.offsetHeight, 'return true;');
			}
		}
	}

	if ( alx != null ) 
	{
		for (var i in alx)
		{
			E = GetElement ("alxw" + i);
	
			if ( E != null )
			{
				RemoteHTML("alx" + i, alpx[i] + "&h=" + E.offsetHeight, 'return true;'); 
				
			}
		}
	}

	return true;
}

function doListTools (TSV1, TSV2, TSV3, TSV4)
{
	if ( TSV1 != null )
	{
		ChangeInnerHTML(TSV1, "<center>Loading ...<br /><br /><img src='/u/001-ajax-icon.gif'></center>");

		RemoteHTML(TSV1, "/do/ajax-product-list/" + TSV1 + "/" + TSV2 + "/" + TSV3 + "/" + TSV4, 'return true;'); 
	
	}
	
	return true;
}

function doHelp (TSV1, TSV2, TSV3)
{
	SetElementOpacity('outline', '0.80');
	ChangeInnerHTML('HiddenLayer', "<div id='ajax_help_wrap'><div style='padding:30px 0 0 120px;'><br /><img src='/u/001-ajax-icon.gif'></div></div>");
	GetElement('HiddenLayer').style.visibility = 'visible';

	GetElement('HiddenLayer').style.width = "800px";

	TA1 = GetWindowDimensions();
	TA2 = GetScrollXY();
	GetElement('HiddenLayer').style.left = ((TA1[0] - 810) / 2) + "px";
	GetElement('HiddenLayer').style.top = (TA2[1] + 80) + "px";

	RemoteHTML('HiddenLayer', '/do/ajax-help-' + TSV1 + '/' + TSV2 + '/' + TSV3, 'return true;');

	return false;
}
function doHelpProduct (TSV1)
{
	ChangeInnerHTML('ajax_alternate_product', "<div style='padding:30px 0 0 0;'><br /><img src='/u/001-ajax-icon.gif'></div>");
	GetElement('ajax_alternate_product').style.visibility = 'visible';

	RemoteHTML('ajax_alternate_product', '/do/ajax-help-product' + '/' + TSV1, 'return true;');

	return false;
}
function doCloseHelp ()
{
	GetElement('HiddenLayer').style.visibility = 'hidden';
	GetElement('ajax_alternate_product').style.visibility = 'hidden';

	SetElementOpacity('outline', '1');
}

function doShowDeliveryInfo (TSV1, TSV2)
{
	var TV1;

	TV1 = FindPosition(TSV1);
	
	ChangeInnerHTML('HiddenLayer', "<div class='delivery_matrix_bubbles'>" + TSV2 + "</div>");
	GetElement('HiddenLayer').style.visibility = 'visible';
	GetElement('HiddenLayer').style.width = "90px";

	GetElement('HiddenLayer').style.left = (TV1['Left'] + 35) + "px";
	GetElement('HiddenLayer').style.top = (TV1['Top'] - 40) + "px";
}

function doHideDeliveryInfo () 
{
	GetElement('HiddenLayer').style.visibility = 'hidden';
}

function doOrderAttribued (a, x)
{
	gotoURL('/do/order-stock/' + a + '/' + x); 
}
function doOrderSpecial (a, x)
{
	var TV1, TV2;
	
	TV1 = GetElement ("ajax_alternate_product_op");
	
	if (TV1 != null)
	{
		TV2 = TV1.value;
	}
	else
	{
		TV2 = "";
	}
	
	gotoURL('/do/order-special/' + a + '/' + TV2); 
}

