if(typeof td == "undefined") { td = {}; }
if(typeof td.pageinfo == 'undefined') { td.pageinfo = {}; }
if(typeof td.pageinfo.subsection == 'undefined') { td.pageinfo.subsection = 'null'; }
if(typeof td.pageinfo.currpage == 'undefined') { td.pageinfo.currpage = 'null'; }
if(typeof td.pageinfo.area == 'undefined') { td.pageinfo.area = 'null'; }
if(typeof td.pageinfo.environment == 'undefined') { td.pageinfo.environment = 0; }

td.htmlSetup = function() {
	
	var HTMLclass = 'js';
	td.pageinfo = {};
	
	var gender = 'f';
	if(document.getElementById('tdmale')) { gender = 'm'; }
	td.pageinfo.gender = gender;
	
	var h = document.getElementsByTagName('html')[0];
	if(h) { 
		addclass(h,HTMLclass); // js styling
		if(h.id) { // page info setup
			var pageinfo = h.id.split('_');
			td.pageinfo.currpage = pageinfo[0].toLowerCase();
			if(pageinfo[1]) { 
				td.pageinfo.subsection = pageinfo[1].toLowerCase();
			}
			if(pageinfo[2]) { 
				td.pageinfo.area = pageinfo[2].toLowerCase();
			}
			if(pageinfo[3]) {
				td.pageinfo.environment = pageinfo[3].replace("_", "", "g");
			} else {
				td.pageinfo.environment = 0;
			}
		}
	}
	
	td.isIE6 = $.browser.msie && (parseInt(jQuery.browser.version) <= 6);
}

$(document).ready(td.htmlSetup);


function getScrollingPosition()
{
  var position = [0, 0];

  if (typeof window.pageYOffset != 'undefined')
  {
    position = [
        window.pageXOffset,
        window.pageYOffset
    ];
  }

  else if (typeof document.documentElement.scrollTop != 'undefined'
      && document.documentElement.scrollTop > 0)
  {
    position = [
        document.documentElement.scrollLeft,
        document.documentElement.scrollTop
    ];
  }

  else if (typeof document.body.scrollTop != 'undefined')
  {
    position = [
        document.body.scrollLeft,
        document.body.scrollTop
    ];
  }

  return position;
}


function getViewportSize()
{
	var size = [0, 0];
	if (typeof window.innerWidth != 'undefined')
	{
		size = [
			window.innerWidth,
			window.innerHeight
		];
		}
		else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 
				 'undefined' && document.documentElement.clientWidth != 0)
		{
			size = [
		document.documentElement.clientWidth,
		document.documentElement.clientHeight
		];
		}
		else
		{
		size = [
		document.getElementsByTagName('body')[0].clientWidth,
		document.getElementsByTagName('body')[0].clientHeight
		];
	}
	return size;
}

function toggleDiv(divID,cssPropsObject) {
	var id = '#' + divID;
	var o = $(id);
	if(o && o.size() > 0) { // already exists
		  $(id).fadeOut("slow", function () {
			$(id).remove();	
		  });
	} else { // doesn't exist yet
		var newDiv = $('<div/>');
		$(newDiv).attr('id', divID);
		if(typeof cssPropsObject != 'undefined') {
			$(newDiv).css(cssPropsObject);		 
		}
		$('body').append(newDiv);
		$(newDiv).fadeIn("slow"); 		
		return $(newDiv);
	}
}

// toggling overlay DIVs (they have to match page size)
function toggleOverlay(overlayID) {
	var cssPropsObject = {
		'width' : $('body').width(), 
		'height': $(document).height() 
	}	
	return toggleDiv(overlayID,cssPropsObject);
}

// position frontdoor layer in the middle of viewport
function position_fd() {	
	var fd =  document.getElementById('frontdoor');
	if(fd) {
		var vs = getViewportSize();
		var width = 1024;
		if(vs[0]) { 
			width = vs[0];
		} 
		var left = (width/2 - (306 / 2));
		fd.style.top =  160 + 'px';
		fd.style.left =  left + 'px';
	}
}

// frontdoor background overlay
$(document).ready(function() {
	var fd = $('#frontdoor');			   
	if(fd.size() > 0) {
		toggleOverlay('overlayBackground');
		if(typeof td.isIE6 != 'undefined' && td.isIE6) {
			$('select').hide();
		}	
	}
});

// accordion
$(document).ready(function(){
	if(typeof jQuery.fn.accordion != "undefined") {
		$("#diets-accordion").accordion( { 
			fillSpace: false,
			autoHeight: false,
			header: "a[href='#']"
		} );
	}
});


// horizontal accordion - active
$(document).ready(function(){
						   
    lastBlock = $("#a1");
    maxWidth = 228;
    minWidth = 25;	

    $("ul#diets-horizontal-accordion li a").hover(
      function(){
        $(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
		$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
		lastBlock = this;
      },
	  function() {}
    );
	
});

$(document).ready(function() {
			
	// default
	var currentSelection = $('#teamdescriptions div:first').attr('id');
	var className = 'active';		
		
	$('#teamContainer a').click(function() {
										 
		var h = this.href;
		var lastHashPos = h.lastIndexOf('#');
		if(lastHashPos != -1) {			
			h = h.substr(lastHashPos);
			if(h != currentSelection) {
				$(this).parents('div:first').addClass(className);
				$('#teamContainer a[href^=' + currentSelection + ']:first').parents('div:first').removeClass(className);		
				currentSelection = h;
				var visibleDivs = $('#teamdescriptions div:visible');
				
				if(visibleDivs.size() > 0) {
					$('#teamdescriptions div:visible').fadeOut('slow', function() {				
						$(h).fadeIn('slow');				
					});
				} else {
					$(h).fadeIn('slow');					
				}
			}
		}
		return false;
	});
	
	$('#teamContainer a:first').click();

});


// video player
/*$(document).ready(function()
{
  //hide the all of the element with class msg_body
  $("#ulList").hide();
  
  $("#slick-show").toggle(
  function() {
  	$("#ulList").slideDown(600);
	$(this).text('Hide dieters');
   },
   function() {
    $("#ulList").slideUp(600);
	$(this).text('Show dieters');
   }
  );
    
});*/

td.showVideoListMenu = function() {
  	$("#slick-show").click();
}

td.hideVideoListMenu = function() {
  	$("#slick-show").click();
}


// tescodiets namespace object
var td = td || {};






function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}










function addLoadListener(fn)
{
  if (typeof window.addEventListener != 'undefined')
  {
    window.addEventListener('load', fn, false);
  }
  else if (typeof document.addEventListener != 'undefined')
  {
    document.addEventListener('load', fn, false);
  }
  else if (typeof window.attachEvent != 'undefined')
  {
    window.attachEvent('onload', fn);
  }
  else
  {
    var oldfn = window.onload;
    if (typeof window.onload != 'function')
    {
      window.onload = fn;
    }
    else
    {
      window.onload = function()
      {
        oldfn();
        fn();
      };
    }
  }
}



function attachEventListener(target, eventType, functionRef, capture)
{
  if (typeof target.addEventListener != "undefined")
  {
      target.addEventListener(eventType, functionRef, capture);
  }
  else if (typeof target.attachEvent != "undefined")
  {
      target.attachEvent("on" + eventType, functionRef);
  }
  else
  {
    eventType = "on" + eventType;

    if (typeof target[eventType] == "function")
    {
      var oldListener = target[eventType];

      target[eventType] = function()
      {
        oldListener();

        return functionRef();
      }
    }
    else
    {
      target[eventType] = functionRef;
    }
  }

  return true;
}


// http://www.dustindiaz.com/getelementsbyclass/
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}


function toggleObj(obj) {
	var el = document.getElementById(obj);
	if ( el.style.display != 'none' ) {
		el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
}


function toggleEl(el) {
	if(el) {
		if ( el.style.display != 'none' ) {
			el.style.display = 'none';
		}
		else {
			el.style.display = '';
		}
	}
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
  
// checks if element has given css class assigned to it
function hasclass(obj,cssc1ass) {
	var found = false;
	var temparray = obj.className.split(' ');
	for(var i=0; i<temparray.length; i++){
		if(temparray[i]==cssc1ass){found=true;}
	}
	return found; 
}

// adds a css class to an element
function addclass(obj,cssc1ass) { 
	if(!hasclass(obj,cssc1ass)) { obj.className += obj.className ? ' '+cssc1ass : cssc1ass; } 	
}
	
// removes a css class	
function removeclass(obj,cssc1ass) {
	var rep=obj.className.match(' '+cssc1ass)?' '+cssc1ass:cssc1ass;
	obj.className=obj.className.replace(rep,'');	
}


function retrieveComputedStyle(element, styleProperty)
{
  var computedStyle = null;

  if (typeof element.currentStyle != "undefined")
  {
    computedStyle = element.currentStyle;
  }
  else
  {
    computedStyle = document.defaultView.getComputedStyle(element, null);
  }

  return computedStyle[styleProperty];
}






// opening windows based on rel attribute, this can be used to replace target="_blank"
// if width & height given, sizes the new window respectively
function popups() {                      
    if(!document.getElementsByTagName) { return; }		
	
	var relValuetoCheck = 'popup';
	var popupClassname = 'popup';
	
	var anchors = document.getElementsByTagName('a'); 
    for (var i = 0; i < anchors.length; i++) {        
         var anchor = anchors[i];   		 
		 
         var relIndex = anchor.rel;                  
		 if (relIndex) { 
		 var relSplit = relIndex.split('|');  	
		 
		 if (relSplit[0] == relValuetoCheck) { 		 	
			if(anchor.className) {  
				anchor.className += ' ' + popupClassname; 
			} else
			{
				anchor.className = popupClassname;
			}
			
			if(relSplit[1]) { anchor.popupHeight = relSplit[1]; }
			if(relSplit[2]) { anchor.popupWidth = relSplit[2]; }        			       
			anchor.onclick = function() {
				if(this.popupHeight && this.popupWidth) { // for links with rel values like rel="popup|471|534"
					var newWin = window.open(this.href, '_blank', "resizable,height="+this.popupHeight+",width="+this.popupWidth); 
				}
				else // for links with rel="popup"
				{
					var newWin = window.open(this.href, '_blank'); 	
				}
				newWin.focus();
				return false;
				};			
		 }
		 }				 
	} 	
	
} 

addLoadEvent(popups);




function initNewsTicker()
{

  var newsScroller = document.getElementById("newsScroller");
  if(!newsScroller) { return; }	

  newsScroller.style.left = 0;

  if (retrieveComputedStyle(newsScroller, "position") == "relative")
  {
    var relativeWidth = newsScroller.offsetWidth;

    newsScroller.style.position = "absolute";
    newsScroller.calculatedWidth = newsScroller.offsetWidth;

    if (relativeWidth > newsScroller.calculatedWidth)
    {
      newsScroller.calculatedWidth = relativeWidth;
    }

    newsScroller.style.position = "relative";
  }
  else
  {
    newsScroller.calculatedWidth = newsScroller.clientWidth;
  }


  moveNewsScroller();

  return true;
}

function moveNewsScroller()
{
  var increment = 5;
  var newsScroller = document.getElementById("newsScroller");
  var currLeft = parseInt(newsScroller.style.left);

  if (currLeft < newsScroller.calculatedWidth * -1)
  {
    newsScroller.style.left = newsScroller.parentNode.offsetWidth + "px";
  }
  else
  {
    newsScroller.style.left = (parseInt(newsScroller.style.left) - increment) + "px";
  }

  newsScroller.timeout = setTimeout("moveNewsScroller()", 85);

  return true;
}


//News scroller
addLoadListener(initNewsTicker);







/*
function resizeNewsBoxes() {
	var boxclass = 'boxNews';
	var newsboxes = getElementsByClass(boxclass);	
	if(newsboxes.length == 0) { return; }
	
	var largestHeight = 114; // fallback
	
	for(i = 0; i < newsboxes.length; i++) {
		if(newsboxes[i].offsetHeight > largestHeight) {
				largestHeight = newsboxes[i].offsetHeight;
		}
	}
	
	for(j = 0; j < newsboxes.length; j++) {
		if(newsboxes[j].offsetHeight < largestHeight) {
				newsboxes[j].style.height = largestHeight - 2 +'px'; // with a fix for borders
		}
	}		
	
}

window.addEvent('domready', function() { resizeNewsBoxes(); });
// addLoadEvent(resizeNewsBoxes);
window.ontextresize = resizeNewsBoxes;
*/






function fivefactors() {
	var s = getElementsByClass('show',document,'li');
	
	if(s) {		
		for(var i = 0; i < s.length; i++) {	
			if(s[i].id) {
				toggleObj('r'+s[i].id.substr(1)); // hiding recipes onload
				s[i].onclick = function() { toggleObj('r'+this.id.substr(1)); return false; }
			}
		}			
	}	
	
	
}

addLoadEvent(fivefactors);
// window.addEvent('domready', fivefactors);


// adds 'js' class to html element allowing to apply 
// different css based on whether js is supported
function htmljs() {
	var HTMLclass = 'js';
	var h = document.getElementsByTagName('html')[0];
	if(h) { addclass(h,HTMLclass); }	
}
// window.addEvent('domready', htmljs);
addLoadEvent(htmljs);



function toggleVisibility() {	
	
	var CSSclass = 'jstoggle';
	var ts = getElementsByClass(CSSclass);	
	
	if(ts) {	
		for(var i = 0; i < ts.length; i++) {	
			
			var n = getNextDiv(ts[i]);
			if(n) {
				toggleEl(n);				
				ts[i].onclick = function() { toggleEl(getNextDiv(this)); return false; }
			}
		}
	}
	
	function getNextDiv(elem) {
		do {
			if(elem.nextSibling) { 
				elem = elem.nextSibling;
			} else {
				elem = elem.parentNode.nextSibling;
			}
		} while (elem.nodeName.toUpperCase() != 'DIV');
		
		return elem;
	}
}

// window.addEvent('domready', toggleVisibility);
addLoadEvent(toggleVisibility);







// Adds a new class to an object, preserving existing classes
function AddClass(obj,cName){ KillClass(obj,cName); return obj && (obj.className+=(obj.className.length>0?' ':'')+cName); }
//***Removes a particular class from an object, preserving other existing classes.
function KillClass(obj,cName){ return obj && (obj.className=obj.className.replace(new RegExp("^"+cName+"\\b\\s*|\\s*\\b"+cName+"\\b",'g'),'')); }
// Returns true if the object has the class assigned, false otherwise.
function HasClass(obj,cName){ return (!obj || !obj.className)?false:(new RegExp("\\b"+cName+"\\b")).test(obj.className) }

//***Cross browser attach event function. For 'evt' pass a string value with the leading "on" omitted
//***e.g. AttachEvent(window,'load',MyFunctionNameWithoutParenthesis,false);
function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 
//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}







function toggleElements(Mid, Iid ) {
			 var e = document.getElementById( Mid );
				var c = document.getElementById( Iid );
		if ( e.style.visibility == 'visible' ||  e.style.display == 'block' ) {
		  e.style.visibility = 'hidden';
		  e.style.display    = 'none';
		  c.style.visibility = 'visible';
		  c.style.display    = 'block';
		} else {
		  e.style.visibility = 'visible';
		  e.style.display    = 'block';
		  c.style.visibility = 'hidden';
		  c.style.display    = 'none';
		}	
		
 }


//*** Tabtastic 1.0.4 -- see http://phrogz.net/JS/Tabstatic/index.html
//*** This code is copyright 2002-2003 by Gavin Kistner and Refinery; www.refinery.com
//*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt
// window.addEvent('domready', tabtastic);


									 
function tabtastic() {	

// AttachEvent(window,'load',function(){
	var tocTag='ul',tocClass='tabset_tabs',tabTag='a',contentClass='tabset_content';

	function FindEl(tagName,evt){
		if (!evt && window.event) evt=event;
		if (!evt) return DebugOut("Can't find an event to handle in DLTabSet::SetTab",0);
		var el=evt.currentTarget || evt.srcElement;
		while (el && (!el.tagName || el.tagName.toLowerCase()!=tagName)) el=el.parentNode;
		return el;
	}

	function SetTabActive(tab){
		if (tab && tab.tabTOC.activeTab){ 
			if (tab.tabTOC.activeTab==tab) return;
			KillClass(tab.tabTOC.activeTab,'active');
			if (tab.tabTOC.activeTab.tabContent) KillClass(tab.tabTOC.activeTab.tabContent,'tabset_content_active');
			if (tab.tabTOC.activeTab.prevTab) KillClass(tab.tabTOC.activeTab.previousTab,'preActive');
			if (tab.tabTOC.activeTab.nextTab) KillClass(tab.tabTOC.activeTab.nextTab,'postActive');
		}
		if(tab) { 
			AddClass(tab.tabTOC.activeTab=tab,'active'); 
			if (tab.tabContent) AddClass(tab.tabContent,'tabset_content_active');	
			if (tab.prevTab) AddClass(tab.prevTab,'preActive');
			if (tab.nextTab) AddClass(tab.nextTab,'postActive');
		}
	}
	function SetTabFromAnchor(evt){
		SetTabActive(FindEl('a',evt).semanticTab);
	}
	
	function Init(){
		
		window.everyTabThereIsById = {};
		
		var anchorMatch = /#d([a-z][\w.:-]*)$/i,match;
		var activeTabs = [];
		
		var tocs = document.getElementsByTagName(tocTag); // ULs
		
		for (var i=0,len=tocs.length;i<len;i++){
			var toc = tocs[i];
			if (!HasClass(toc,tocClass)) continue;  // 'tabset_tabs'

			var lastTab;
			var firstTab;
			
			var tabs = toc.getElementsByTagName(tabTag);  // a
			for (var j=0,len2=tabs.length;j<len2;j++){
				var tab = tabs[j];
				if (!tab.href || !(match=anchorMatch.exec(tab.href))) continue;
				if (lastTab){
					tab.prevTab=lastTab;
					lastTab.nextTab=tab;
				}
				if(!firstTab) {
					firstTab = tab;
				}
				tab.tabTOC=toc; // toc UL
				everyTabThereIsById[tab.tabID=match[1]]=tab; // building array of all anchors
				
				tab.tabContent = document.getElementById(tab.tabID);  // respective content 
				
				if (HasClass(tab,'active')) activeTabs[activeTabs.length]=tab;  // if anchor has 'active' class, push it to the array
				
				lastTab=tab;
			}
			// AddClass(toc.getElementsByTagName('li')[0],'firstchild'); // assign class to the first LI
		}

		// if there are no active links
		if(activeTabs.length == 0) {			
			activeTabs[0] = firstTab;	
		}

		// loop through active links and show respective content
		for (var i=0,len=activeTabs.length;i<len;i++){
			SetTabActive(activeTabs[i]);
		}

		// loop through all the links, anf if link is in the array, assign onclick behaviour to it
		for (var i=0,len=document.links.length;i<len;i++){
			var a = document.links[i];
			if (typeof a.href != 'string' || !(match=anchorMatch.exec(a.href))) continue;
			if (a.semanticTab = everyTabThereIsById[match[1]]) { 
				AttachEvent(a,'mouseover',SetTabFromAnchor,false);
			}
		}
		
		if ((match=anchorMatch.exec(location.href)) && (a=everyTabThereIsById[match[1]])) SetTabActive(a);
		
	}
	Init();
}
// },false);
// });
addLoadEvent(tabtastic);

function promocarousel() {
	var p = getElementsByClass('promocarousel')[0];
	if(!p) { return; }	
	var o = p.getElementsByTagName('ol')[0];
	var allpromos = [];
	
	var links = o.getElementsByTagName('a');
	if(links) {
		for(var i = 0; i < links.length; i++) {
			var d = links[i].getElementsByTagName('div')[0];
			if(d) { 
				allpromos.push(d);
				var flashimg = d.getElementsByTagName('img')[0];
				if(flashimg) {
					var flashsrc = flashimg.src.substr(0,flashimg.src.lastIndexOf('.'))+'.swf';
					var so = new SWFObject(flashsrc, "mymovie", flashimg.width, flashimg.height, "7", "#ffffff");
					if(flashimg.parentNode.id) {
						so.write(flashimg.parentNode.id);
					}
				}
			} else {
				var img = links[i].getElementsByTagName('img')[0];
				if(img) {					
					allpromos.push(img); 
				}
			}			
		}
	}
	if(allpromos.length == 0) { return; }
	
	showPromo(0);
	
	for(var i = 0; i < links.length; i++) {
		// assigning custom attribute to links to use in event handler
		links[i].seq = i; 
		links[i].onmouseover = function() {
			showPromo(this.seq);
		}
	}
	
	function showPromo(imageNo) {
		for(var j = 0; j < allpromos.length; j++) {
			if(j == imageNo) {
				removeclass(allpromos[j],'hidden');
				addclass(allpromos[j].parentNode,'active');
			} else {
				addclass(allpromos[j],'hidden');
				removeclass(allpromos[j].parentNode,'active');
			}
		}
	}
	
	
}
addLoadEvent(promocarousel);
// window.addEvent('domready', promocarousel);




function getCookie(searchName)
{
  var cookies = document.cookie.split(";");

  for (var i = 0; i < cookies.length; i++)
  {
    var cookieCrumbs = cookies[i].split("=");
    var cookieName = cookieCrumbs[0].toLowerCase(); // converting to lowercase
    var cookieValue = cookieCrumbs[1];
	var searchName = searchName.toLowerCase(); // converting to lowercase

    if (cookieName.replace(/^\s+/,'') == searchName) // added trimming with regex
    {
      return cookieValue;
    }
  }
  return false;
}




function DoGenderChanges(gender) {
	
	function getValueOfSelect(form,selectname) {
		var selectRef = form.elements[selectname];
		return selectRef.options[selectRef.selectedIndex].value;
	}
	
	var qsbform = document.getElementById('qsb');
	if(!qsbform) { return; }	
	
	// get gender from select
	var genderSelected = getValueOfSelect(qsbform,'gender');
	if(!genderSelected) { genderSelected = 'female'; }
	genderSelected = genderSelected.toLowerCase();
	genderSelected = genderSelected.substr(0,1);

	// get gender from cookie
	var genderCookie = getCookie('CK_GENDER'); // 'm' or 'f'
	if(!genderCookie) { genderCookie = 'f';  }
	genderCookie = genderCookie.toLowerCase();

	// weight, stones
	var wt_st = getValueOfSelect(qsbform,'wt_st');
	
	// weight, pounds
	var wt_lb = getValueOfSelect(qsbform,'wt_lb');
	
	// height, feet
	var htft = getValueOfSelect(qsbform,'htft');
	
	// height, inches
	var htin = getValueOfSelect(qsbform,'htin');
	
	// age
	var age = qsbform.elements['age'].value;
	
	// if gender in select and cookie not the same, redirect
	if(genderSelected != genderCookie) {
		var currentURL = location.href;
		var regex = new RegExp("&*ck_gender=[mf]", "i"); // remove gender param from URL, if exists
		var currentURLcleaned = currentURL.replace(regex, '');
		var newURL =  currentURLcleaned;
		if(!location.search) { newURL += '?'; } // if no URL params, add question mark
		newURL += '&ck_gender=' + genderSelected;
		newURL += '&wt_st=' + wt_st;
		newURL += '&wt_lb=' + wt_lb;
		newURL += '&htft=' + htft;
		newURL += '&htin=' + htin;
		if(age) { 
			newURL += '&age=' + age;
		}
		location.href = newURL;
	}
}



// fixing CF validation on contact page
var cfform_submit_status = '';


function showEmailFriend(){
	var conf = getElementsByClass('confirmation');
	var err = document.getElementById('errorList');
	
	if(conf.length > 0  || err) { 
	var box = document.getElementById('friendForm');
		if(box){			
			toggleEl(box);
		}
	} 
}
addLoadEvent(showEmailFriend);

function hideanatomyimg() {
      document.getElementById('anatomyimg').style.visibility = 'hidden'; 
}

