/*
http://isohunt.com Interface Javascript
by Gary Fung - email: gary{REPLACE_WITH_THE_AT_SIGN}isohunt.com

Feel free to use / mod this to your heart's content,
but keep these lines to acknowledge where this code originated.
Comments, mods or additions you'd like add to this script can be posted here:
http://isohunt.com/forum/viewforum.php?f=1

Tip popup functions adapted from AWStats: http://awstats.sourceforge.net/
*/

var smooth_timer;

function smoothHeight(id, curH, targetH, stepH, mode) {
  diff = targetH - curH;
  if (diff != 0) {
    newH = (diff > 0) ? curH + stepH : curH - stepH;
    ((document.getElementById) ? document.getElementById(id) : eval("document.all['" + id + "']")).style.height = newH + "px";
    if (smooth_timer) window.clearTimeout(smooth_timer);
    smooth_timer = window.setTimeout( "smoothHeight('" + id + "'," + newH + "," + targetH + "," + stepH + ",'" + mode + "')", 16 );
  }
  else if (mode != "o") ((document.getElementById) ? document.getElementById(mode) : eval("document.all['" + mode + "']")).style.display="none";
}

function rowOver1(i, nColor) {
  if (!nColor) nColor = "#ECECD9";
  var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
  if (nameObj != null) nameObj.style.background=nColor;
}

function rowOut1(i, nColor) {
  var trObj = (document.getElementById) ? document.getElementById('ihtr' + i) : eval("document.all['ihtr" + i + "']");
  var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
  if (trObj == null || trObj.style.display=="none") nameObj.style.background=nColor;
}

function showAddCat() {
  var rowObj = document.getElementById('new_cat_row');
  if (rowObj.style.display == "none") {
    rowObj.style.display = "";
  }
}

function servOC(i, chgWhat, href, nColor) {
	if (chgWhat == 'read') {
		 var nameObj = (document.getElementById) ? document.getElementById('name' + i) : eval("document.all['name" + i + "']");
		 var arrObj = (document.getElementById) ? document.getElementById('arrow' + i) : eval("document.all['arrow" + i + "']");
	}
	else if (chgWhat == 'post') {
		 var nameObj = (document.getElementById) ? document.getElementById('name_' + i) : eval("document.all['name_" + i + "']");
		 var arrObj = (document.getElementById) ? document.getElementById('arrow_' + i) : eval("document.all['arrow_" + i + "']");		
	}
  var trObj = (document.getElementById) ? document.getElementById('ihtr' + i) : eval("document.all['ihtr" + i + "']");
  var ifObj = (document.getElementById) ? document.getElementById('ihif' + i) : eval("document.all['ihif" + i + "']");
	var dmObj = (document.getElementById) ? document.getElementById('dm' + i) : eval("document.all['dm" + i + "']");
  if (trObj != null) {
    if (trObj.style.display=="none") {
      ifObj.style.height = "0px";
      trObj.style.display="";
      nameObj.style.backgroundColor="#E9D2B5";
			nameObj.style.fontWeight="bold";
			nameObj.style.border = "1px solid #7B0600";
			dmObj.style.backgroundColor="#E9D2B5";
			dmObj.style.display = "block";
			arrObj.src = "assets/arrow_up.png";
      if (!ifObj.src) ifObj.src = href;
      smoothHeight('ihif' + i, 0, 210, 42, 'o');
    }
    else {
      nameObj.style.backgroundColor="";
			nameObj.style.fontWeight="normal";
			nameObj.style.border = "none";
			dmObj.style.backgroundColor="";
			dmObj.style.display = "none";
			arrObj.src = "assets/arrow_down.png";
      smoothHeight('ihif' + i, 210, 0, 42, 'ihtr' + i);
    }
  }
}

function SubmitForm() {
  var form = document.forms[0];
  var bRequired = true;
  if ( (form.fname.value.length < 1) ||
  (form.lname.value.length < 1) ||
  (form.email_addr.value.length < 1) ||
  (form.subject.value.length < 1) ||
  (form.msg.value.length < 1) ||
  (form.user_code.value.length <1) ) {
    alert("Please fill out all the fields.");
    bRequired = false;
  }
  
  if (!bRequired) return false;
  
  form.submit();
}
