var IE4 = document.all;
var NN7 = (!IE4 && document.getElementById);
var NN4 = document.layers;
if (!(NN7 || IE4) && location.href.indexOf("nonstandard.htm") == -1) location.replace("nonstandard.htm");
if (IE4 && navigator.userAgent.indexOf("Opera") != -1) {
	NN7 = true;
	IE4 = false;
}

var lebsearch = {};
if (location.search) {
	var tmp = location.search.substring(1);
	tmp = tmp.split("&");
	for (var i = 0; i < tmp.length; i++ ) {
		lebsearch[tmp[i].substring(0,tmp[i].indexOf("="))] = tmp[i].substring(tmp[i].indexOf("=") + 1);
	}
}

function getStyleObject(obj) {
	var theObj = (IE4?document.all[obj]:document.getElementById(obj));
	return (theObj?theObj.style:null);
}

function getObject(obj) {
	return (IE4?document.all[obj]:document.getElementById(obj));
}

var copyright = 2006;

function getPath() {
	var str = location.href;
	if (str.indexOf("/site") != -1)
		str = str.substring(str.indexOf("/site") + 6);
	var tmparr = str.split("/");
	str = "";
	for (var i = 1; i < tmparr.length; i++) {
		str += "../";
	}
	return str;
}

var tabs = ["bras","briefs","gear","swim","maternity"];
var tabimg = [];
var tabimgon = [];
for (var i = 0; i < tabs.length; i++) {
	tabimg[i] = new Image();
	tabimg[i].src = getPath() + "images/images_t/bb_lb_tab_" + tabs[i] + ".gif";
	tabimgon[i] = new Image();
	tabimgon[i].src = getPath() + "images/images_t/bb_lb_tab_" + tabs[i] + "_on.gif";
}

function imageOver(obj,img) {
	obj.src = img.src;
}

function openNewWindow(URL,id,attribs) {
  window.open(URL,id,attribs);
}

function stripUnderscores(txt) {
	txt = txt.replace(/_/g, " ");
	return txt;
}

function getResults(f) {
	var results = "";
	var obj;
	if (!f.mychoice.selectedIndex || !f.mysize.selectedIndex)
		alert("Please choose from both drop down menus before searching.");
	else {
		results = doSearch(f.mychoice.options[f.mychoice.selectedIndex].value,f.mysize.options[f.mysize.selectedIndex].value);
		getObject("resultsinfo").innerHTML = results;
	}
	return false;
}

function getQueryResults() {
	getObject("resultsinfo").innerHTML = doSearch(lebsearch.mychoice,lebsearch.mysize);
}

function doSearch(choice,size) {
	var results = "";
	OUTER:
	for (var prop in searchitems) {
		if (choice == prop) {
			for (var sizeprop in searchitems[prop]) {
				if ("X" + size == sizeprop && searchitems[prop][sizeprop][0]["name"].indexOf("none available") == -1) {
					obj = searchitems[prop][sizeprop];
					if (obj.length) {
						results += "<p>You asked for a size " + size + " bra that " + (choice == "most_support"?"offers ":(choice == "non_wired" || choice == "underwired" || choice == "most_comfy" || choice == "front_fastening"?"is ":"is a ")) + stripUnderscores(choice) + ". The bra lady recommends the following bras as best suiting your needs...</p>\n<ul>\n";
						for (var i = 0; i < obj.length; i++) {
							if (typeof obj[i] != "undefined")
								results += "<li class=\"lssearchresults\"><a href=\"" + obj[i].url + "\">" + obj[i].name + "</a></li>\n";
						}
						results += "</ul>";
					} else {
						results += "<div class=\"lssearchresults\">There are no recommended bras available for this combination of size and choice.</div>";
					}
					break OUTER;
				}
			}
		}
	}
	if (!results)
		results += "<div class=\"lssearchresults\">There are no recommended bras available for this combination of size and choice.</div>";
	return results;
}

function startSearch(f) {
	if (!f.mychoice.selectedIndex || !f.mysize.selectedIndex) {
		alert("Please choose from both drop down menues before searching.");
		return false;
	}
	return true;
}

function getHomepageImage() {
	var homepage = [

		{
			name:"1777",
			intro:"<strong>Jenny</strong>, black belt Tae Kwondo modelling the ",
			text:"Sportjock ActionSport Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Sportjock_Action_Sport_Bra_Supplex.html"
		},
		{
			name:"1779",
			intro:"<strong>Kirsty</strong>, keen runner, modelling the limited edition,   ",
			text:"Minimal Bounce Pink Aerobics Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/copy_of_Minimal_Bounce_Bra.html"
		},
		{
			name:"1841",
			intro:"<strong>Jenny</strong>, black belt Tae Kwondo in the  ",
			text:"Z-Runline Heart Rate Monitor Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Z-Runline_Heart_Rate_Monitor_Bra.html"
		},
			{
			name:"1864",
			intro:"<strong>Jenny</strong>, black belt Tae Kwondo in the  ",
			text:"Z-Runline Heart Rate Monitor Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Z-Runline_Heart_Rate_Monitor_Bra.html"
		},
		{
			name:"1960",
			intro:"<strong>Zoe</strong>, personal trainer, in the  ",
			text:"Shock Absorber B4490 Max Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/B4490_-_level_4.html#aBE4490"
		},
		{
			name:"1979",
			intro:"<strong>Amber</strong>, enjoys gym, cycling and running in the ",
			text:"Pure Lime Classic Tank",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Fitness_Wear.html"
		},
		{
			name:"2004",
			intro:"<strong>Amber</strong>, enjoys gym, cycling and in the ",
			text:"limited edition, Minimal Bounce Pink Aerobics Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/copy_of_Minimal_Bounce_Bra.html"
		},
		{
			name:"2042",
			intro:"<strong>Fiona</strong>, keen runner, in the ",
			text:"Freya Soft Cup Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Freya_Soft_Cup_Sports_Bra.html"
		},
		{
			name:"2054",
			intro:"<strong>Maureen</strong>, keen runner, in the  ",
			text:"Freya Underwire Sports Bra",
			endtext:" Pure Lime Running Jacket.",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Freya_Underwire_Sports_Bra.html"
		},
		{
			name:"2106",
			intro:"<strong>Fiona</strong>, keen runner, in the ",
			text:"Pure Lime 098 Compression Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Pure_Lime_Compression_Bra_098.html"
		},
		{
			name:"2111",
			intro:"<strong>Fiona</strong>, keen runner, in the  ",
			text:"Pure Lime 098 Compression Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Pure_Lime_High_Impact_Bra_091.html"
		},
				{
			name:"2149",
			intro:"<strong>Beth</strong>, GB Endurance Rider, in the  ",
			text:"Pure Lime 091 High Impact Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Pure_Lime_High_Impact_Bra_091.html"
		},
		{
			name:"2162",
			intro:"<strong>Beth</strong>, GB Endurance Rider, in the  ",
			text:"Pure Lime 091 High Impact Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Pure_Lime_High_Impact_Bra_091.html"
		},
		{
			name:"2197",
			intro:"<strong>Beth</strong>, GB Endurance Rider, in the  ",
			text:"Triumph Extreme ",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Tri-Action_Extreme.html"
		},
		{
			name:"2373",
			intro:"<strong>Laura</strong>, from the LessBounce office in the  ",
			text:"Moving Comfort Helena Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Helena.html"
		},
		{
			name:"2238",
			intro:"<strong>Beth</strong>, GB Endurance Rider, in the ",
			text:"Shock Absorber N4246 Pump Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Shock_Absorber_N4246_Pump_Sports_Bra_-_NEW_.html"
		},
		{
			name:"2283",
			intro:"<strong>Rachael</strong>, International Endurance Rider, in the ",
			text:"Freya Underwire Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Freya_Underwire_Sports_Bra.html"
		},
		{
			name:"2290",
			intro:"<strong>Beth</strong>, GB Endurance Rider, in the Shock Absorber N4246 Pump Sports Bra ",
			text:"Shock Absorber N4246 Pump Sports Bra",
			endtext:".",
			credit:"",
			url:"http://www.lessbounce.com/acatalog/Shock_Absorber_N4246_Pump_Sports_Bra_-_NEW_.html"
		},
	]
	
	var n = Math.floor(Math.random() * homepage.length);
	getStyleObject("home").backgroundImage = "url(images/homepage2010/bb_lb_m_" + homepage[n].name + ".jpg)";
	getStyleObject("searchbox").backgroundImage = "url(images/homepage2010/bb_lb_b_" + homepage[n].name + ".jpg)";
	getObject("homelogo").src = "images/homepage2010/bb_lb_l_" + homepage[n].name + ".jpg";
//	setTimeout("lala()",1000);
	getObject("homepictext").innerHTML = (typeof homepage[n].intro != "undefined"?homepage[n].intro:"") + "<a href=\"" + homepage[n].url + "\"><b>" + homepage[n].text + "</b></a>" + homepage[n].endtext + "<br>" + homepage[n].credit;
}

function lala() {
	var homepage = [
			{
			name:"dee",
			intro:"<b>Dee Caffari</b><br>round the world yachtswoman wearing the ",
			text:"Shock Absorber B518",
			endtext:".",
			credit:"Photography by Tim Walton",
			url:"http://www.lessbounce.com/acatalog/Online_Catalogue_Sportjock_Bras_5.html"
		}

];
		getObject("homelogo").src = "images/bb_lb_hp_logo_" + homepage[0].name + ".jpg";

}
