/*
this script inspired from:

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 you must keep these lines to acknowledge where this code originated.
Comments, mods or additions you'd like add to this script? Post it here:
http://isohunt.com/forum/viewforum.php?f=1

Tip popup functions adapted from AWStats: http://awstats.sourceforge.net/
*/

function init() {
	if(location.href.indexOf('#') < 0) { //not for anchors
		var id = "searchform";
		((document.getElementById) ? document.getElementById(id).MovieName.focus() : eval("document.all['" + id + "']")).MovieName.focus();
	}
}


var smooth_timer;
var dissableRedir = false; 

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 + "')", 20 );
  }
  else if (mode != "o") ((document.getElementById) ? document.getElementById(mode) : eval("document.all['" + mode + "']")).style.display="none";
}

function servOC(i, href, nColor, height) {
	if(dissableRedir) { dissableRedir = false; return; } 
	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 + "']");
	var classObj = (document.getElementById) ? document.getElementById('main' + i) : eval("document.all['main" + i + "']");
	var ifObj = (document.getElementById) ? document.getElementById('ihif' + i) : eval("document.all['ihif" + i + "']");
	if (trObj != null) {
		if(height == null) {
			height = 450;
		} else {
			height = 50 + (height * 40);
			if(height % 50 != 0) { height = (Math.ceil(height/50) * 50); }
			if(height > 600) { height = 600; }
		}
  		if (trObj.style.display=="none") {
    			trObj.style.display="";
    			classObj.className = "sb_close";
    			nameObj.style.background="#FFFFFF";
    			if (!ifObj.src) ifObj.src = href; 
    			smoothHeight('ihif' + i, 0, height, 10, 'o');
  		} else {
  			classObj.className = "sb_ok";
  			nameObj.style.background="#FFFFFF";
			smoothHeight('ihif' + i, height, 0, 50, 'ihtr' + i);
		}
	}
}

function reLink(link) { 
    dissableRedir = true; 
    window.location.href = link; 
    return false; 
} 

function toggleLayer(whichLayer)
{
if (document.getElementById) {
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = style2.display ? "":"block";
} else if (document.all) {
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = style2.display ? "":"block";
} else if (document.layers) {
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = style2.display ? "":"block";
}
}

function hideLayer(whichLayer)
{
if (document.getElementById) {
	// this is the way the standards work
	var style2 = document.getElementById(whichLayer).style;
	style2.display = "";
} else if (document.all) {
	// this is the way old msie versions work
	var style2 = document.all[whichLayer].style;
	style2.display = "";
} else if (document.layers) {
	// this is the way nn4 works
	var style2 = document.layers[whichLayer].style;
	style2.display = "";
}
}