var newhttp

function getXmlHttpRequestObject() {
        if (window.XMLHttpRequest) {
                return new XMLHttpRequest();
        } else if (window.ActiveXObject) {
                return new ActiveXObject("Microsoft.XMLHTTP");
        } else {
        }
}

function InfoWindow (url, name, height, width) {
	window.open(url, name, "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,height="+height+",width="+width);
	return false;
}

//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//
function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function'){
        window.onload = func;
    } else {
        window.onload = function(){
        oldonload();
        func();
        }
    }

}

function showDiv (showDiv, hideDiv) {
	document.getElementById(showDiv).style.display = 'block';
	document.getElementById(hideDiv).style.display = 'none';
}

var currentSearch = 'search';

function searchTab () {

	if (currentSearch == 'search') {
			document.getElementById('advancedsearch').style.display = 'block';
			document.getElementById('normalsearch').style.display = 'none';
			document.getElementById('search_tab').src = '/_images/buttons/nav_search.gif';
			currentSearch = 'advancedsearch';

	} else {
			document.getElementById('normalsearch').style.display = 'block';
			document.getElementById('advancedsearch').style.display = 'none';
			document.getElementById('search_tab').src = '/_images/buttons/advancedsearch.gif';
			currentSearch = 'search';
	}

}


//
// Functions added by Peter Bell
//

function divvisible(div) {
	document.getElementById(div).style.visibility="visible";
}
function divinvisible(div) {
	document.getElementById(div).style.visibility="hidden";
}

function countrychange(country) {
	var id = country + "img";
	if(country=="none"){document.getElementById("Germanyimg").src = "/_images/header2010/Germany.png";
	document.getElementById("Irelandimg").src = "/_images/header2010/Ireland.png";
	document.getElementById("Greeceimg").src = "/_images/header2010/Greece.png";
	document.getElementById("Spainimg").src = "/_images/header2010/Spain.png";}else{
	document.getElementById(id).src = "/_images/header2010/" + country + "_titled.png";
	if(country!="Germany"){document.getElementById("Germanyimg").src = "/_images/header2010/Germany_white.png";}
	if(country!="Ireland"){document.getElementById("Irelandimg").src = "/_images/header2010/Ireland_white.png";}
	if(country!="Greece"){document.getElementById("Greeceimg").src = "/_images/header2010/Greece_white.png";}
	if(country!="Spain"){document.getElementById("Spainimg").src = "/_images/header2010/Spain_white.png";}
	}
}
function change_img(name,alt,address,holder) {
	var id = 'LF_' + holder + '_img';
	var img = document.getElementById(id);
	img.src = "_images/homepage_0809/LF_" + holder + "_" + name + ".png";
	img.alt = alt;
	var hrefid = id + "_link";
	var hreflink = document.getElementById(hrefid);
	hreflink.href = address;
}
function contact_change_img(name,alt,holder) {
	var id = holder;
	var img = document.getElementById(id);
	img.src = "_images/contact/" + name;
	img.alt = alt;
}

//
// Change Brand For HomePage
//
function changeBrand (location) {
	if(location == "inbody"){
		window.location = "http://www.gymcompany.co.uk/lifestyle/body-analysis/b:biospace/1.html";
		}
	else if(location == "fitflop"){
		window.location = "http://www.gymcompany.co.uk/shoes/fit-flops/1.html";
		}
	else if(location == "power-plate"){
		window.location = "http://www.gymcompany.co.uk/powerplate/1.html";
		}
	else if(location == "life-fitness"){
		window.location = "http://www.gymcompany.co.uk/cardio/b:life-fitness/1.html";
		}else{
			window.location = "br/" + location + "/1.html";
		}
}
//
// AJAXNewsHomePage()
// AJAX to get news to the home page
// Function created by Peter Bell - http://www.peterjkbell.me.uk
//
function AJAXNewsHomePage(){
			$("#index_newsholder").load("/news/ .news h2", "", function () {
				var i=1;
				$("#index_newsholder h2 a").each(function(){
					  if($(this).text().length>50){
						  $(this).text($(this).text().substr(0,50)+"...");
					  }
					});
				$("#index_newsholder h2 a").append('<br /><span class="index_seemore">See More <span style="font-size:13px;">&#8227;</span></span>');
				$("#index_newsholder h2").each(function(){
														   if(i>1){t=i+'" style="display:none;'}else{t="1";}
					  $(this).replaceWith('<div id="index_newspiece_'+t+'" class="index_newspieces">' + $(this).html() + "</div>");
					  i++;
					});
				var current = 1;
				i=i-1;
				function fadeloop(){
					function innerfadeloop(){
						$("#index_newspiece_"+current).fadeTo(5000,1);
						$("#index_newspiece_"+current).fadeOut(1000, function(){
							if(current==i){current=1;}else{current++;}
							$("#index_newspiece_"+current).fadeIn(1000, function(){fader();});
						});
					}
					return innerfadeloop;
				}
				var fader = fadeloop();
				fader();
			  });
}

function index_change_store(type) {
	var id = "index_store_"+type;
	var id_button ="index_store_"+type+"_button";
	document.getElementById("index_store_category").style.display="none";
	document.getElementById("index_store_brands").style.display="none";
	document.getElementById("index_store_news").style.display="none";
	document.getElementById(id).style.display="block";
	document.getElementById("index_store_category_button").src="/_images/homepage2010/shop_by_category.png";
	document.getElementById("index_store_brands_button").src="/_images/homepage2010/shop_by_brands.png";
	document.getElementById("index_store_news_button").src="/_images/homepage2010/shop_by_news.png";
	document.getElementById(id_button).src="/_images/homepage2010/shop_by_"+type+"_ro.png";
}

