
// this script fixes reload bug in Netscape
NS4 = document.layers;
if (NS4) {
  origWidth = innerWidth;
  origHeight = innerHeight;
}
function reDo() {
  if (innerWidth != origWidth || innerHeight != origHeight) {
  location.reload();
  }
}
if (NS4 && parseInt(navigator.appVersion) != 5) {
  onresize = reDo;
}
// end reload bug fix

// how many folders down from the root are we?
dotslashes = "";
for (l=0;l<pageLevel;l++) {
dotslashes = dotslashes + "../";
}

if (pageLevel == 0) {
//dotslashes = "http://www.oldmotherhubbard.com/";
dotslashes = "./";
}

// write out stylesheet links
if (navigator.appName == "Netscape" && navigator.appVersion.charAt(0) == ("4")) { 
	document.writeln("<link rel=\"STYLESHEET\" type=\"text/css\" href=\""+dotslashes+"style_ns.css\">");
} 
else { 
	document.writeln("<link rel=\"STYLESHEET\" type=\"text/css\" href=\""+dotslashes+"style_ie.css\">");
}

// preload sublevel l1 images
A0on = new Image();A0off = new Image();
A1on = new Image();A1off = new Image();
A2on = new Image();A2off = new Image();
A3on = new Image();A3off = new Image();
A4on = new Image();A4off = new Image();
A5on = new Image();A5off = new Image();
A6on = new Image();A6off = new Image();

// which set of L1 buttons should we preload ("for retailers" or "regular sublevel")
// retail: for retailers
// homepage: for the homepage
// omh: sublevel with OMH watermarkdesign
// sunrays: sublevel with Wellness sun rays design
// sunface: sublevel with Wellness sun face design
switch (whichInterface) {
case "homepage":
L1imgList = new Array("","dog","cat","abt","buy","tlk");
A1on.src = "img/hmp_l1_btn_dog_r.gif";A1off.src = "img/hmp_img/l1_btn_dog_0.gif";
A2on.src = "img/hmp_l1_btn_cat_r.gif";A2off.src = "img/hmp_img/l1_btn_cat_0.gif";
A3on.src = "img/hmp_l1_btn_abt_r.gif";A3off.src = "img/hmp_img/l1_btn_abt_0.gif";
A4on.src = "img/hmp_l1_btn_buy_r.gif";A4off.src = "img/hmp_img/l1_btn_buy_0.gif";
A5on.src = "img/hmp_l1_btn_tlk_r.gif";A5off.src = "img/hmp_img/l1_btn_tlk_0.gif";
icon1on = new Image(); icon1on.src = "img/hmp_icon_dog.gif";
icon2on = new Image(); icon2on.src = "img/hmp_icon_cat.gif";
icon3on = new Image(); icon3on.src = "img/hmp_icon_abt.gif";
icon4on = new Image(); icon4on.src = "img/hmp_icon_buy.gif";
icon5on = new Image(); icon5on.src = "img/hmp_icon_tlk.gif";
iconoff = new Image(); iconoff.src = "img/bg_trans.gif";
break;
case "retail":
L1imgList = new Array("","myprofile","talktous","logout");
A1on.src = "img/l1_btn_dog_r.gif";A1off.src = dotslashes+"img/l1_btn_dog_0.gif";
A2on.src = "img/l1_btn_cat_r.gif";A2off.src = dotslashes+"img/l1_btn_cat_0.gif";
A3on.src = "img/l1_btn_abt_r.gif";A3off.src = dotslashes+"img/l1_btn_abt_0.gif";
A4on.src = "img/l1_btn_buy_r.gif";A4off.src = dotslashes+"img/l1_btn_buy_0.gif";
A5on.src = "img/l1_btn_tlk_r.gif";A5off.src = dotslashes+"img/l1_btn_tlk_0.gif";
break;
case "omh":
L1imgList = new Array("","dog-o","cat-o","abt-o","buy-o","tlk-o","bre-o");
A1on.src = dotslashes+"img/l1_btn_dog-o_r.gif";A1off.src = dotslashes+"img/l1_btn_dog-o_0.gif";
A2on.src = dotslashes+"img/l1_btn_cat-o_r.gif";A2off.src = dotslashes+"img/l1_btn_cat-o_0.gif";
A3on.src = dotslashes+"img/l1_btn_abt-o_r.gif";A3off.src = dotslashes+"img/l1_btn_abt-o_0.gif";
A4on.src = dotslashes+"img/l1_btn_buy-o_r.gif";A4off.src = dotslashes+"img/l1_btn_buy-o_0.gif";
A5on.src = dotslashes+"img/l1_btn_tlk-o_r.gif";A5off.src = dotslashes+"img/l1_btn_tlk-o_0.gif";
A6on.src = dotslashes+"img/l1_btn_bre-o_r.gif";A6off.src = dotslashes+"img/l1_btn_bre-o_0.gif";
break;
case "sunrays":
L1imgList = new Array("","dog-o","cat","abt","buy","tlk","bre");
A1on.src = dotslashes+"img/l1_btn_dog-o_r.gif";A1off.src = dotslashes+"img/l1_btn_dog-o_0.gif";
A2on.src = dotslashes+"img/l1_btn_cat_r.gif";A2off.src = dotslashes+"img/l1_btn_cat_0.gif";
A3on.src = dotslashes+"img/l1_btn_abt_r.gif";A3off.src = dotslashes+"img/l1_btn_abt_0.gif";
A4on.src = dotslashes+"img/l1_btn_buy_r.gif";A4off.src = dotslashes+"img/l1_btn_buy_0.gif";
A5on.src = dotslashes+"img/l1_btn_tlk_r.gif";A5off.src = dotslashes+"img/l1_btn_tlk_0.gif";
A6on.src = dotslashes+"img/l1_btn_bre_r.gif";A6off.src = dotslashes+"img/l1_btn_bre_0.gif";
break;
case "sunface":
L1imgList = new Array("","dog-w","cat","abt","buy","tlk","bre");
A1on.src = dotslashes+"img/l1_btn_dog-w_r.gif";A1off.src = dotslashes+"img/l1_btn_dog-w_0.gif";
A2on.src = dotslashes+"img/l1_btn_cat_r.gif";A2off.src = dotslashes+"img/l1_btn_cat_0.gif";
A3on.src = dotslashes+"img/l1_btn_abt_r.gif";A3off.src = dotslashes+"img/l1_btn_abt_0.gif";
A4on.src = dotslashes+"img/l1_btn_buy_r.gif";A4off.src = dotslashes+"img/l1_btn_buy_0.gif";
A5on.src = dotslashes+"img/l1_btn_tlk_r.gif";A5off.src = dotslashes+"img/l1_btn_tlk_0.gif";
A6on.src = dotslashes+"img/l1_btn_bre_r.gif";A6off.src = dotslashes+"img/l1_btn_bre_0.gif";
break;
}

// preload sublevel l1 images
for (i=1;i<L1imgList.length;i++) {
	eval("A"+i+"on = new Image(); A"+i+"on.src = \""+dotslashes+"img/l1_btn_"+L1imgList[i]+"_r.gif\";");
	eval("A"+i+"off = new Image(); A"+i+"off.src = \""+dotslashes+"img/l1_btn_"+L1imgList[i]+"_0.gif\";");
}

// keep selected l1 button lit
if (selectedL1 != 0) {
	eval("A"+selectedL1+"on.src = \""+dotslashes+"img/l1_btn_"+L1imgList[selectedL1]+"_1.gif\";");
	eval("A"+selectedL1+"off.src = A"+selectedL1+"on.src");
}

// preload homepage l1 images
if (whichInterface == "homepage") {

	for (i=1;i<L1imgList.length;i++) {
	eval("A"+i+"on = new Image(); A"+i+"on.src = \"img/hmp_l1_btn_"+L1imgList[i]+"_r.gif\";");
	eval("A"+i+"off = new Image(); A"+i+"off.src = \"img/hmp_l1_btn_"+L1imgList[i]+"_0.gif\";");
	eval("icon"+i+"on = new Image(); icon"+i+"on.src = \"img/hmp_icon_"+L1imgList[i]+".gif\";");
	}
	eval("iconoff = new Image(); iconoff.src = \"img/bg_trans.gif\";");

}

// turn images on
function menuOn(imgName) {
	eval("document.images."+imgName+".src = eval(imgName + \"on.src\");");
}

// turn images off
function menuOff(imgName) {
	eval("document.images."+imgName+".src = eval(imgName + \"off.src\");");
}

// turn icon on (homepage)
function iconOn(imgName) {
	eval("document.images.icon.src = eval(\"icon\" + imgName + \"on.src\");");
}

// turn icon off (homepage)
function iconOff() {
	document.images.icon.src = iconoff.src;
}

// opens ingredient index window
function openIngredientIndex(list) {
	opidgwin = window.open('../'+list+'_index.html','opidgwin','width=400,height=275,scrollbars=yes');
	opidgwin.focus();
}

// opens interactive feeding chart window
function openFeedingChart(animalFile) {
	ofcwin = window.open('../features/'+animalFile,'ofcwin','width=400,height=275,scrollbars=no');
	ofcwin.focus();
}

// opens download instructions
function openDownInstr() {
	odiwin = window.open('download_instructions.html','odiwin','width=400,height=275,scrollbars=yes');
	odiwin.focus();
}

