  	function show_hide(to_id){
			
			ten = document.getElementById(to_id);
			if(ten) 
			{
				if ((ten.style.display == "block") || (ten.style.display == "") || (ten.style.display == "inline")){
					ten.style.display = "none";
				}else if(ten.style.display == "none"){ten.style.display = "block";}
			}
		}
	function show_hide_boss_friend(to_id)
	{
			if(to_id=='refer_a_friend')
			{
				refer_a_friend_cont = document.getElementById(to_id);
				if(refer_a_friend_cont) 
				{
					if(refer_a_friend_cont.style.display == "none")
					{
						refer_a_friend_cont.style.display = "block";
						show_div('referafriendcontent'); 
						hide_div('tellyourbosscontent'); 
						hide_div('ref_menutabs1'); 
						show_div('ref_menutabs2');
					}
				}			
			}
			else if(to_id=='tell_your_boss')
			{
				tell_your_boss_cont = document.getElementById('refer_a_friend');
				if(tell_your_boss_cont) 
				{
					if(tell_your_boss_cont.style.display == "none")
					{
						tell_your_boss_cont.style.display = "block";
						hide_div('referafriendcontent'); 
						show_div('tellyourbosscontent'); 
						show_div('ref_menutabs1'); 
						hide_div('ref_menutabs2');
					}
				}
			}
		
		
	}		
    function toggle_bg(to_bg){
			bgc = $(to_bg);
			if ((bgc.style.background == "#FED7B0") || (bgc.style.background == "")){
				  bgc.style.background = "#FEF4E8";
			}else if(bgc.style.background == "#FEF4E8"){
          bgc.style.background = "#FED7B0";}
      }
      
  var last_show_hide_used = false;
	  
  	  function show_hide_hide_last(to_id){
  	  		
  	  		ten = document.getElementById(to_id);  	  		
  	  		if(ten) {	  			
  	  			
	  	  		if((getStyle(ten,"display")=='none')) {
	  	  			if(last_show_hide_used) {	  	  				
		  	  			ten2 = document.getElementById(last_show_hide_used);  	  
		  	  			if(ten2) {
						
							ten2.style.display = "none";	  	  				
						}
	  	  			}				
					ten.style.display = "inline";
	  			
	  	  		} else {
	  	  			ten.style.display = "none;";  	  	  			
	  	  		}
  				last_show_hide_used = to_id;	  	  		
  	  		}
		}	      
    	
		function show_div(div_id){	
		  
		  to = document.getElementById(div_id);
       	  if(to) {
		  	if ((to.style.display == "none") || (to.style.display == "")){
		  		to.style.display = "inline";
        	}
       	  }
		}
			
			
		function hide_div(div_id){	
			 to = document.getElementById(div_id);	
			 if(to) {
				 if (to.style.display != "none"){
          			to.style.display = "none";
        		}
			 }
		}
				
		function show_hide_link(to_id){
		
			ten = document.getElementById(to_id);
			
			if ((ten.style.display == "block") || (ten.style.display == "")){
				ten.style.display = "none";
				document.getElementById('labellink').innerHTML = 'Open';
				document.getElementById('trianglelink').innerHTML = '<img src="html/images/common/orange_triangle_down.gif" alt="" />';
			}else if(ten.style.display == "none"){
				
				ten.style.display = "block";
				document.getElementById('labellink').innerHTML = 'Close';
				document.getElementById('trianglelink').innerHTML = '<img src="html/images/common/orange_triangle_up.gif" alt="" />';
			}
		}
		
		function hide_bottom_after_search(meal)
		{
		    if($('table_add_'+meal+'_btn2'))
		        hide_div('table_add_'+meal+'_btn2');
            if($(meal+'item_amount'))
                hide_div(meal+'item_amount');             
            if($(meal+'add2favch')) 
                hide_div(meal+'add2favch'); 
		}
		
		function cross_change(to_id) {		
      btn = document.getElementById(to_id);
      if (btn.style.backgroundImage == "url(../../images/ff/buttons/cross2.gif)" || btn.style.backgroundImage == "url(/35/images/ff/buttons/cross2.gif)"){
        btn.style.backgroundImage = "url(/35/images/ff/buttons/cross.gif)";
      } else {
        btn.style.backgroundImage = "url(/35/images/ff/buttons/cross2.gif)";
      }
    }

	function nh_area_nav(selected_link){
		var link = document.getElementById(selected_link+"_link");
		var linkArray=document.getElementById('nutrition_help_area_nav').getElementsByTagName('a');                  

		for (var x=0;x<linkArray.length;x++){
				if(linkArray[x].id==(selected_link+"_link")){
					linkArray[x].style.color='#582F8B';
				}
				else{
					linkArray[x].style.color="#FF830F";
				}
				
		}

		var nh_area_inners_array=new Array();
		nh_area_inners_array=ElementsByClass(document.getElementById("inner_areas_holder"), "innerArea", "div", false);
	
		for(var x=0;x<nh_area_inners_array.length;x++){
			
			if(nh_area_inners_array[x].id==selected_link){
				nh_area_inners_array[x].style.display='inline';
			}
			else{
				nh_area_inners_array[x].style.display='none';
			}
			
		}
	}
    function hide_htw_divs (){
      document.getElementById('htw_overview').style.display = 'none';
      document.getElementById('htw_addingfood').style.display = 'none';
      document.getElementById('htw_recipes').style.display = 'none';
      document.getElementById('htw_meals').style.display = 'none';
      document.getElementById('htw_nuthistory').style.display = 'none';
    }
    
    function unColorLink(){
      document.getElementById('htw_overview_link').style.color = '#FF830F';
      document.getElementById('htw_addingfood_link').style.color = '#FF830F';
      document.getElementById('htw_recipes_link').style.color = '#FF830F';
      document.getElementById('htw_meals_link').style.color = '#FF830F';
      document.getElementById('htw_nuthistory_link').style.color = '#FF830F';
    }
    
    
    function hide_htw_divs_act (){
      document.getElementById('htw_overview').style.display = 'none';
      document.getElementById('htw_addingfood').style.display = 'none';
      document.getElementById('htw_recipes').style.display = 'none';
      document.getElementById('htw_meals').style.display = 'none';
      document.getElementById('htw_nuthistory').style.display = 'none';
    }
    
    function unColorLink_act(){
      document.getElementById('htw_overview_link').style.color = '#FF830F';
      document.getElementById('htw_addingfood_link').style.color = '#FF830F';
      document.getElementById('htw_recipes_link').style.color = '#FF830F';
      document.getElementById('htw_meals_link').style.color = '#FF830F';
      document.getElementById('htw_nuthistory_link').style.color = '#FF830F';
    }    
    function colorLink(to_id){
      document.getElementById(to_id).style.color = '#582F8B';
    }

	function colorLinkToOrange(to_id){
      document.getElementById(to_id).style.color = '#FF830F';
    }
    function linkSwitch(to_id) {
      var btn = document.getElementById(to_id);
      if (btn.className=="showSection_btn"){
        btn.className="hideSection_btn";
      }else if(btn.className=="hideSection_btn"){
		btn.className="showSection_btn"
      }
    }
        
    function popupStart(sourceID) {
    	   	
    	if($(sourceID).innerHTML && $('popupContainer')) {
    		
    		$('popupContainer').innerHTML = $(sourceID).innerHTML;
    		$(sourceID).innerHTML = '';
    		
    		if(document.getElementById('graf_small_container')){
           document.getElementById('graf_small_container').style.display = 'none';
        }
    		
    	}
    }
    
    function popupClose(sourceID) {
    	
    	if($(sourceID) && $('popupContainer').innerHTML) {
    		
    		$(sourceID).innerHTML = $('popupContainer').innerHTML;
    		$('popupContainer').innerHTML = '';
    		
    		if(document.getElementById('graf_small_container')){
           document.getElementById('graf_small_container').style.display = 'block';
        }
    		
    	}    	
    }
    
    
    function toggleActivities(dir, togglestart) {
    	
    	var activityToggleStage = 1;	   	
    	if($("all").className == "tab selected") activityToggleStage = 1;
    	if($("walking").className == "tab selected") activityToggleStage = 2;
    	if($("swimming").className == "tab selected") activityToggleStage = 3;
    	if($("cycling").className == "tab selected") activityToggleStage = 4;
    	if($("skiing").className == "tab selected") activityToggleStage = 5;
    	if($("rowing").className == "tab selected") activityToggleStage = 6;
    	if($("skating").className == "tab selected") activityToggleStage = 7;
    	if($("lifting").className == "tab selected") activityToggleStage = 8;
    	if($("powerplate").className == "tab selected") activityToggleStage = 9;

    	activityToggleStage-=dir;	    	
    	if(activityToggleStage>9) {activityToggleStage = 9;return false;}
    	if(activityToggleStage<1) {activityToggleStage = 1;return false;}
    	
    	var act;
    	switch(activityToggleStage) {
    		case 1: act = "all"; break;
			case 2: act = "walking";break;
			case 3: act = "swimming";break;
			case 4: act = "cycling";break;
			case 5: act = "skiing";break;
			case 6: act = "rowing";break;
			case 7: act = "skating";break;
			case 8: act = "lifting";break;
			case 9: act = "powerplate";break;
			break;
    	}
    	if(act) {
    		
			setReqUrl('uk.myfitbug.activity');
			req('setActivity',act,false,false,"class_toggle('" + act + "','tab selected','tab off','" + togglestart + "');");			
    	}     	
    }
    
    function ieSelectBug(){
      hide_div('nutItemslistArea');
      show_div('nutItemslistHiddenArea');
      hide_div('nutSelectArea');
      show_div('nutSelectHiddenArea');
    }
    
    function ieSelectBugOff(){
      show_div('nutItemslistArea');
      hide_div('nutItemslistHiddenArea');
      show_div('nutSelectArea');
      hide_div('nutSelectHiddenArea');
    }

// png behaviour repeat/position script
  
if (!window.IEPNGFix) {
	window.IEPNGFix = {};
}

IEPNGFix.tileBG = function(elm, pngSrc, ready) {
	// Params: A reference to a DOM element, the PNG src file pathname, and a
	// hidden "ready-to-run" passed when called back after image preloading.

	var data = this.data[elm.uniqueID],
		elmW = Math.max(elm.clientWidth, elm.scrollWidth),
		elmH = Math.max(elm.clientHeight, elm.scrollHeight),
		bgX = elm.currentStyle.backgroundPositionX,
		bgY = elm.currentStyle.backgroundPositionY,
		bgR = elm.currentStyle.backgroundRepeat;

	// Cache of DIVs created per element, and image preloader/data.
	if (!data.tiles) {
		data.tiles = {
			src: '',
			cache: [],
			img: new Image(),
			old: {}
		};
	}
	var tiles = data.tiles,
		pngW = tiles.img.width,
		pngH = tiles.img.height;

	if (pngSrc) {
		if (!ready && pngSrc != tiles.src) {
			// New image? Preload it with a callback to detect dimensions.
			tiles.img.onload = function() {
				this.onload = null;
				IEPNGFix.tileBG(elm, pngSrc, 1);
			};
			return tiles.img.src = pngSrc;
		}
	} else {
		// No image?
		if (tiles.src) ready = 1;
		pngW = pngH = 0;
	}
	tiles.src = pngSrc;

	if (!ready && elmW == tiles.old.w && elmH == tiles.old.h &&
		bgX == tiles.old.x && bgY == tiles.old.y && bgR == tiles.old.r) {
		return;
	}

	// Convert English and percentage positions to pixels.
	var pos = {
			top: '0%',
			left: '0%',
			center: '50%',
			bottom: '100%',
			right: '100%'
		},
		x,
		y,
		pc;
	x = pos[bgX] || bgX;
	y = pos[bgY] || bgY;
	if (pc = x.match(/(\d+)%/)) {
		x = Math.round((elmW - pngW) * (parseInt(pc[1]) / 100));
	}
	if (pc = y.match(/(\d+)%/)) {
		y = Math.round((elmH - pngH) * (parseInt(pc[1]) / 100));
	}
	x = parseInt(x);
	y = parseInt(y);

	// Handle backgroundRepeat.
	var repeatX = { 'repeat': 1, 'repeat-x': 1 }[bgR],
		repeatY = { 'repeat': 1, 'repeat-y': 1 }[bgR];
	if (repeatX) {
		x %= pngW;
		if (x > 0) x -= pngW;
	}
	if (repeatY) {
		y %= pngH;
		if (y > 0) y -= pngH;
	}

	// Go!
	this.hook.enabled = 0;
	if (!({ relative: 1, absolute: 1 }[elm.currentStyle.position])) {
		elm.style.position = 'relative';
	}
	var count = 0,
		xPos,
		maxX = repeatX ? elmW : x + 0.1,
		yPos,
		maxY = repeatY ? elmH : y + 0.1,
		d,
		s,
		isNew;
	if (pngW && pngH) {
		for (xPos = x; xPos < maxX; xPos += pngW) {
			for (yPos = y; yPos < maxY; yPos += pngH) {
				isNew = 0;
				if (!tiles.cache[count]) {
					tiles.cache[count] = document.createElement('div');
					isNew = 1;
				}
				var clipR = (xPos + pngW > elmW ? elmW - xPos : pngW),
					clipB = (yPos + pngH > elmH ? elmH - yPos : pngH);
				d = tiles.cache[count];
				s = d.style;
				s.behavior = 'none';
				s.left = xPos + 'px';
				s.top = yPos + 'px';
				s.width = clipR + 'px';
				s.height = clipB + 'px';
				s.clip = 'rect(' +
					(yPos < 0 ? 0 - yPos : 0) + 'px,' +
					clipR + 'px,' +
					clipB + 'px,' +
					(xPos < 0 ? 0 - xPos : 0) + 'px)';
				s.display = 'block';
				if (isNew) {
					s.position = 'absolute';
					s.zIndex = -999;
					if (elm.firstChild) {
						elm.insertBefore(d, elm.firstChild);
					} else {
						elm.appendChild(d);
					}
				}
				this.fix(d, pngSrc, 0);
				count++;
			}
		}
	}
	while (count < tiles.cache.length) {
		this.fix(tiles.cache[count], '', 0);
		tiles.cache[count++].style.display = 'none';
	}

	this.hook.enabled = 1;

	// Cache so updates are infrequent.
	tiles.old = {
		w: elmW,
		h: elmH,
		x: bgX,
		y: bgY,
		r: bgR
	};
};

//registration - new tools
var strideConverterMetricOutput = true;

  function newBugStepsStart(){
  	  	   	 
  	 if (document.getElementById('measUnitText1')){document.getElementById('measUnitText1').innerHTML = 'inches'}; 
  	 if (document.getElementById('measUnitText2')) {document.getElementById('measUnitText2').innerHTML = 'cm (stride)'};  	 
  	 strideConverterMetricOutput = false;
     hide_div('tot_step_0');
     show_div('new_tot_step_1');
     show_div('topTitleBar');
  };
  
  function oldBugStepsStart(){
  	  	 
  	 if(document.getElementById('measUnitText1')) {document.getElementById('measUnitText1').innerHTML = 'cm (stride)'};	
  	 if (document.getElementById('measUnitText2')) {document.getElementById('measUnitText2').innerHTML = 'cm (stride)'};	
  	 strideConverterMetricOutput = true;
     hide_div('tot_step_0');
     hide_div('new_steps_container');
     show_div('steps_container');
     show_div('topTitleBar');
     show_div('oldContinueBtn');
     totPages(0,'fwd');
  };
  
  function newBugStep01(){
     hide_div('new_tot_step_1');
     show_div('new_tot_step_2');
  };
  
  function newBugNext(nr){
     actual = nr;
     next = nr+1;
     hide_div('new_tot_step_'+actual+'');
     show_div('new_tot_step_'+next+'');       
  };
  
  function newBugBack(nr){     
     actual = nr;
     back = nr-1;
     hide_div('new_tot_step_'+actual+'');
     show_div('new_tot_step_'+back+'');
  };
  
  
  function hoverActionContinueA(){
     for (x=1;x<10;x++){
        if(document.getElementById('toolsContinueBtn0'+ x +'a')) {document.getElementById('toolsContinueBtn0'+ x +'a').style.display = 'none'};
        if(document.getElementById('toolsContinueBtn0'+ x +'b')) {document.getElementById('toolsContinueBtn0'+ x +'b').style.display = 'block'};
     };
  };
  
  function hoverActionContinueB(){
     for (x=1;x<10;x++){
        if(document.getElementById('toolsContinueBtn0'+ x +'a')) {document.getElementById('toolsContinueBtn0'+ x +'a').style.display = 'block'};
        if(document.getElementById('toolsContinueBtn0'+ x +'b')) {document.getElementById('toolsContinueBtn0'+ x +'b').style.display = 'none'};
     };
  };
  
    function hoverActionPreviousA(){
     for (x=1;x<10;x++){
        if(document.getElementById('toolsPreviousBtn0'+ x +'a')) {document.getElementById('toolsPreviousBtn0'+ x +'a').style.display = 'none'};
        if(document.getElementById('toolsPreviousBtn0'+ x +'b')) {document.getElementById('toolsPreviousBtn0'+ x +'b').style.display = 'block'};
     };
  };
  
  function hoverActionPreviousB(){
     for (x=1;x<10;x++){
        if(document.getElementById('toolsPreviousBtn0'+ x +'a')) {document.getElementById('toolsPreviousBtn0'+ x +'a').style.display = 'block'};
        if(document.getElementById('toolsPreviousBtn0'+ x +'b')) {document.getElementById('toolsPreviousBtn0'+ x +'b').style.display = 'none'};
     };
  };
  
 function hoverActionConvertA(){
    if(document.getElementById('toolsConvertBtnA')) {document.getElementById('toolsConvertBtnA').style.display = 'none'};
    if(document.getElementById('toolsConvertBtnB')) {document.getElementById('toolsConvertBtnB').style.display = 'block'};
  };
  
  function hoverActionConvertB(){
    if(document.getElementById('toolsConvertBtnA')) {document.getElementById('toolsConvertBtnA').style.display = 'block'};
    if(document.getElementById('toolsConvertBtnB')) {document.getElementById('toolsConvertBtnB').style.display = 'none'};
  };
  
 function hoverActionClearA(){
    if(document.getElementById('toolsClearBtnA')) {document.getElementById('toolsClearBtnA').style.display = 'none'};
    if(document.getElementById('toolsClearBtnB')) {document.getElementById('toolsClearBtnB').style.display = 'block'};
  };
  
  function hoverActionClearB(){
    if(document.getElementById('toolsClearBtnA')) {document.getElementById('toolsClearBtnA').style.display = 'block'};
    if(document.getElementById('toolsClearBtnB')) {document.getElementById('toolsClearBtnB').style.display = 'none'};
  };
  
   function hoverActionConvertA2(){
    if(document.getElementById('toolsConvertBtnA2')) {document.getElementById('toolsConvertBtnA2').style.display = 'none'};
    if(document.getElementById('toolsConvertBtnB2')) {document.getElementById('toolsConvertBtnB2').style.display = 'block'};
  };
  
  function hoverActionConvertB2(){
    if(document.getElementById('toolsConvertBtnA2')) {document.getElementById('toolsConvertBtnA2').style.display = 'block'};
    if(document.getElementById('toolsConvertBtnB2')) {document.getElementById('toolsConvertBtnB2').style.display = 'none'};
  };
  
 function hoverActionClearA2(){
    if(document.getElementById('toolsClearBtnA2')) {document.getElementById('toolsClearBtnA2').style.display = 'none'};
    if(document.getElementById('toolsClearBtnB2')) {document.getElementById('toolsClearBtnB2').style.display = 'block'};
  };
  
  function hoverActionClearB2(){
    if(document.getElementById('toolsClearBtnA2')) {document.getElementById('toolsClearBtnA2').style.display = 'block'};
    if(document.getElementById('toolsClearBtnB2')) {document.getElementById('toolsClearBtnB2').style.display = 'none'};
  };
  
  bugVersion = '';
  
  function setBugVersion(bugVersion){  
     if(bugVersion == 'new'){
           $('strideConv02').innerHTML='';
        }else if(bugVersion == 'old'){

           $('strideConv01').innerHTML='';
        };
  }
  
  function nectarPointsLinkChange(link_id){
     if(document.getElementById(link_id).style.backgroundImage == 'url(/35/images/icons/purple_arrow_d.gif)'){
        document.getElementById(link_id).style.backgroundImage = 'url(/35/images/icons/purple_arrow_r.gif)';
     }else{
        document.getElementById(link_id).style.backgroundImage = 'url(/35/images/icons/purple_arrow_d.gif)';
     };
  }