var agt = navigator.userAgent.toLowerCase();
var isIE = (agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1);
var isIE6up = isIE && (agt.indexOf("msie 6.") != -1);
var isEffectsSupported = isIE6up || !isIE; // IE 6+ or anything else
var isSafari = (agt.indexOf('safari') + 1)>0 ? true : false;

/* EFFECTS SUCK AT CROSS BROWSERNESS, KILL THEM */
isEffectsSupported = false;

/* this shouldn't be necessary but what the heck...
   IE5.01 isn't doing what it's supposed to, according
   to the internet.  :( */
function getZeEl(name) {
  if (document.all) {
    return document.all[name];    
  }
  else {
    return $(name);
  }
}

function setSections() {
  if (getZeEl('huntersFavoritesMainBody')) {
    getZeEl('hunters-favorites-tab1-div').style.top = getZeEl('huntersFavoritesMainBody').style.top;
    getZeEl('hunters-favorites-tab2-div').style.top = getZeEl('huntersFavoritesMainBody').style.top;
    getZeEl('hunters-favorites-tab3-div').style.top = getZeEl('huntersFavoritesMainBody').style.top;
  }
  
  if (getZeEl('huntersLicenseMainBody')) {
    getZeEl('hunters-license-tab1-div').style.top = getZeEl('huntersLicenseMainBody').style.top;
    getZeEl('hunters-license-tab2-div').style.top = getZeEl('huntersLicenseMainBody').style.top;
  }
  
  if (getZeEl('friendsListMainBody')) {
    getZeEl('friends-list-tab1-div').style.top = getZeEl('friendsListMainBody').style.top;
    getZeEl('friends-list-tab2-div').style.top = getZeEl('friendsListMainBody').style.top;
  }
  
  if (getZeEl('hunterLeaderMainBody')) {
    getZeEl('hunters-leaders-tab1-div').style.top = getZeEl('hunterLeaderMainBody').style.top;
    getZeEl('hunters-leaders-tab2-div').style.top = getZeEl('hunterLeaderMainBody').style.top;
  }
  
  if (getZeEl('huntersFriendsMainBody')) {
    getZeEl('hunters-friends-tab1-div').style.top = getZeEl('huntersFriendsMainBody').style.top;
    getZeEl('hunters-friends-tab2-div').style.top = getZeEl('huntersFriendsMainBody').style.top;
  }
}

/* start navigation tab rollovers */
selected = new Array();
function setRollovers() {
  /* These are the tabs that are selected by default */
  selected["featured-hunter"] = "featured-hunter-tab1";
  selected["hunters-favorites"] = "hunters-favorites-tab1";
  selected["hunters-license"] = "hunters-license-tab1";
  selected["friends-list"] = "friends-list-tab2";
  selected["hunters-leaders"] = "hunters-leaders-tab1";
  selected["hunters-friends"] = "hunters-friends-tab1";
}
function tabOver(name, lang) {
	if (document.images) {
		document[name].src = '../images/MetroidHunters/' + lang + '/' + name + '-on.gif';
	}
}
function tabOut(name, lang) {
  if (document.images) {
    for (x in selected) {
      if (selected[x] == name) {
        return;
      }
    }
  	document[name].src = '../images/MetroidHunters/' + lang + '/' + name + '-off.gif';
  }
}
/* end navigation tab rollovers */

/* start tab navigation stuff */
function tabClick(section, name, lang) {
  var lastTabName = selected[section];
  if (lastTabName == name) return;
  selected[section] = name;
  
  tabOut(lastTabName, lang);
  
  /* Do cool fades on the tab contents if effects are supported */
	if (isEffectsSupported) {
	  setTimeout("Effect.Fade('"+lastTabName+"-div')", 0);
	  setTimeout("Effect.Appear('"+name+"-div')", 1000);
	}
	else {
    getZeEl(lastTabName+'-div').style.display = 'none';
    getZeEl(name+'-div').style.display = 'inline';
	}
}
/* end tab navigation stuff */

function onfocusDynamicClear(elem, defaultText) {
	if (elem.value==defaultText) {
		elem.value=""; //clear value
	}
}

function onblurDynamicClear(elem, defaultText) {
	if (elem.value=="") {
		elem.value=defaultText;
	}
}

function onfocusPassword(elem, prefix) {
	if (elem.value == "Password") {
		getZeEl(prefix + "password").style.display = "block";
		getZeEl(prefix + "fakepassword").style.display = "none";
		getZeEl(prefix + "password").select();
	}
}

function onblurPassword(elem, prefix) {
	if (elem.value == "") {
		getZeEl(prefix + "password").style.display = "none";
		getZeEl(prefix + "fakepassword").style.display = "block";
	}
}
