var cobrand_v = "";
var sPageNum = "";
var curPageNum =  "";
var bsQuery = "";
var hat = new Object();
hat = {
	init: function (cobrand,usrAgent,tthat,bbhat,portalhat,clienthat,header) {
		this.d = document;
		this.cobrand = cobrand;
		this.usrAgent = usrAgent;
		this.tthat = tthat;
		this.bbhat = bbhat;
		this.portalhat = portalhat;
		this.clienthat = clienthat;
		this.header = header;
		this.showHat();
	},
	showHat: function() {
			if((this.cobrand == "talktalk" || this.cobrand == "aolbb" || this.cobrand == "aoluk") && (this.usrAgent == 1)) {
				this.d.getElementById(this.clienthat).style.display = "block";
				this.d.getElementById(this.tthat).style.display = "none";
				this.d.getElementById(this.bbhat).style.display = "none";
				this.d.getElementById(this.portalhat).style.display = "none";
				this.d.getElementById(this.header).style.height = "122px";			
			}
			else if((this.cobrand == "talktalk") && (this.usrAgent != 1)) {
				this.d.getElementById(this.clienthat).style.display = "none";
				this.d.getElementById(this.tthat).style.display = "block";
				this.d.getElementById(this.bbhat).style.display = "none";
				this.d.getElementById(this.portalhat).style.display = "none";
			}
			else if((this.cobrand == "aolbb") && (this.usrAgent != 1))  {
				this.d.getElementById(this.clienthat).style.display = "none";
				this.d.getElementById(this.tthat).style.display = "none";
				this.d.getElementById(this.bbhat).style.display = "block";
				this.d.getElementById(this.portalhat).style.display = "none";
			}
			else if((this.cobrand == "aoluk") && (this.usrAgent != 1))  {
				this.d.getElementById(this.clienthat).style.display = "none";
				this.d.getElementById(this.tthat).style.display = "none";
				this.d.getElementById(this.bbhat).style.display = "none";
				this.d.getElementById(this.portalhat).style.display = "block";
			}
			else {
				this.d.getElementById(this.clienthat).style.display = "none";
				this.d.getElementById(this.tthat).style.display = "none";
				this.d.getElementById(this.bbhat).style.display = "none";
				this.d.getElementById(this.portalhat).style.display = "block";
			}
		}
},
legalftr = {
	init: function (cobrand,usrAgent,portallegal,ttlegal) {
		this.d = document;
		this.cobrand = cobrand;
		this.usrAgent = usrAgent;
		this.portallegal = portallegal;
		this.ttlegal = ttlegal;
		this.showLegalftr();
	},
	showLegalftr: function() {
			if((this.cobrand == "talktalk" || this.cobrand == "aolbb" || this.cobrand == "aoluk") && (this.usrAgent == 1)) {
				this.d.getElementById(this.portallegal).style.display = "block";
				this.d.getElementById(this.ttlegal).style.display = "none";
			}
			else if((this.cobrand == "talktalk") && (this.usrAgent != 1)) {
				this.d.getElementById(this.portallegal).style.display = "none";
				this.d.getElementById(this.ttlegal).style.display = "block";
			}
			else if((this.cobrand == "aolbb") && (this.usrAgent != 1))  {
				this.d.getElementById(this.portallegal).style.display = "none";
				this.d.getElementById(this.ttlegal).style.display = "none";
			}
			else if((this.cobrand == "aoluk") && (this.usrAgent != 1))  {
				this.d.getElementById(this.portallegal).style.display = "block";
				this.d.getElementById(this.ttlegal).style.display = "none";
			}
			else {
				this.d.getElementById(this.portallegal).style.display = "block";
				this.d.getElementById(this.ttlegal).style.display = "none";
			}
		}
} // @end obj
var thatsfitUK = new Object();
thatsfitUK={

		calcBMI : function() {
			var wwft = parseInt(document.getElementById('wwft').value);
			var wwin = parseInt(document.getElementById('wwin').value);
			var wwst = parseInt(document.getElementById('wwst').value);
			var wwlb = parseInt(document.getElementById('wwlb').value);
			var wwcm = 0;
			var wwkg = 0;
			var bmi = 0;
			
			if(wwft == ""){wwft = 0;}
			if(wwin == ""){wwin = 0;}
			if(wwst == ""){wwst = 0;}
			if(wwlb == ""){wwlb = 0;}
			
			wwcm = (wwft * 12) + wwin;
			wwcm = Math.round(wwcm * 2.54);
			wwcm = wwcm / 100;
			wwkg = (wwst * 14) + wwlb;
			wwkg = Math.round(wwkg * 0.45);
			bmi = Math.round(wwkg / (wwcm * wwcm));
			window.location.href='http://wwo.plan-net.de/aol-uk/bmi.php?wert=' + bmi;
		},
		googleAFS : function(cb,spno,cspno,q) {
			cobrand_v = cb;
			sPageNum = spno;
			curPageNum = cspno;
			bsQuery = q;
			bsQuery = bsQuery.replace(/%5C/g, "");
			bsQuery = unescape(bsQuery);
		}

}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

/* Search text */
function effects() {
	var defaultKeyWord="Enter search keywords";
	$("#mkmhptip").hide();
	$("#queryname").click(function () { if ($("#queryname").val() == defaultKeyWord) { $("#queryname").val(""); }});
	$("#queryname").blur(function () { if ($("#queryname").val() == "") { $("#queryname").val(defaultKeyWord);}});
	$("#queryname2").focus(function () { if ($("#queryname2").val() == defaultKeyWord) { $("#queryname2").val("");}});
	$("#queryname2").click(function () { if ($("#queryname2").val() == defaultKeyWord) { $("#queryname2").val("");}});	
	$("#queryname2").blur(function () { if ($("#queryname2").val() == "") { $("#queryname2").val(defaultKeyWord);} });
	$("#s_form").submit(function() { if ($("#queryname").val() == defaultKeyWord || $("#queryname").val()=="") { return false; } else { return true; }});
	$("#s_form2").submit(function() { if ($("#queryname2").val() == defaultKeyWord || $("#queryname2").val()=="") { return false; } else { return true; }});	
	$("#wwbtn").click(function () { thatsfitUK.calcBMI(); });	
	$('#mkmhp,#mkmhpbb').bind('click', function(e) {
		if (document.all) {
			this.style.behavior='url(#default#homepage)';
			this.setHomePage('http://www.thatsfit.co.uk/');
		}
		else {
			$('#mkmhptip').fadeIn(1000);
		}
		e.preventDefault();
	});
	$('#mkmhptip').bind('blur', function(){
		$('#mkmhptip').fadeOut(1500);
	});
	$('#mkmhpclose').bind('click', function(){
		$('#mkmhptip').fadeOut(1000);
	});
}

function navtab() {
// adds selected tag for navigation
var pageURL = new String(document.location);
var pageContext = pageURL.split("http://www.thatsfit.co.uk");
$("#headerBottom .chNav li a").each(function(){
if (pageContext[1] == $(this).attr("href")){
	$(this).addClass("selected");
}});
$("#sidebar .categories li a").each(function(){
if (pageContext[1] == $(this).attr("href")){
	$(this).addClass("selected");
	return false;
}});
}