var included = [];
function include_once(script) {
  var append = true;
  for(var i=0; i<included.length; i++) {
    if(included[i] == script) {
      append = false;
    };
  };
  if(append) {
    var doc = document.getElementsByTagName('head').item(0);
    var js = document.createElement('script');
    js.setAttribute('language', 'javascript');
    js.setAttribute('type', 'text/javascript');
    js.setAttribute('src', script);
    doc.appendChild(js);
    included.push(script);
    return false;
  };
};

//isdefined( object, variable )
function isdefined(o,v) {
  return (typeof(eval(o)[v]) != "undefined");
};

//addOnLoad(function name, include filename)
function addOnLoad(func,include) {
  if(include != null) {
    include_once('/js/'+include+'.js');
  };
  if(window.onload) {
    var oldFunc = window.onload;
    window.onload = function() {
      oldFunc();
      eval(func);
    };
  };
};

function showSubNav(subNavID) {
	var children = document.getElementsByTagName('UL');
	for (var x=0; x < children.length; x++) {
		if (children[x].className == 'locationsSubRegion') {
			hideSubNav(children[x].id);
		}
	}
	document.getElementById(subNavID).style.display = "block";
}

function hideSubNav(subNavID) {
	if (document.getElementById(subNavID)) {
		document.getElementById(subNavID).style.display = "none";
	}
}

function doRedirect() {
	document.location = document.repRegions.salesRegion.value;
}