var d = document;

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// nav drop down script for IE
// from http://www.htmldog.com/articles/suckerfish/dropdowns/
/*
sfHover = function() {
	var sfEls = d.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);
*/
initProdTable = function() {
  var t = d.getElementById("table-products");
  if(t) {
    alternateRows(t);
    // rewrite URLs for testing
    if(location.href.indexOf("biggs-gilmore") > -1) {
      for(var i=0; a=t.getElementsByTagName("A")[i]; i++) {
        a.href = a.href.replace(/fafh\.biggs-gilmore/, "www.foodawayfromhome");
        a.target = "_blank";
      }
    }
  }
}


alternateRows = function(table) {
	for(var i=0; tr=table.getElementsByTagName("tr")[i]; i++) {
		if(i % 2) tr.className = "even";
	}
}

/*
hideSearchFields = function() {
  var ns = d.getElementById("nav-segments"), i, a;
  if(ns) {
    for(i = 0; a = ns.getElementsByTagName("a")[i]; i++) {
      a.onmouseover = hideSelects;
      a.onmouseout = showSelects;
    }
  }
}



hideSelects = function() {
	if(document.all) {
		for(var i=0; s=document.getElementsByTagName("select")[i]; i++) {
			s.style.visibility = "hidden";
		}
	}
}

showSelects = function() {
	if(document.all) {
		for(var i=0; s=document.getElementsByTagName("select")[i]; i++) {
			s.style.visibility = "visible";
		}
	}
}



parseQuery = function() {
	var returnVals = new Array();
	qString = new String(window.location);
	var queryStart = qString.indexOf('?');
	if (queryStart==-1) {
		return returnVals;
	}
	var query = qString.substring(queryStart + 1, qString.length);
	var parts = query.split("&");
	for (var i=0; i<parts.length; i++) {
		bits = parts[i].split("=");
		if(bits[1]) {
			subbits = bits[1].split("#"); // added by T.D. to handle fragment identifier in URL
			returnVals[bits[0].toLowerCase()] = bits[1]; // query[] indexes are now lowercase!
		}
	}
	return returnVals;
}

var query = parseQuery();

addLoadEvent(hideSearchFields);


*/
