
//addEvent - attach a function to an event
function AddEvent(obj, evType, fn){ 
 if (obj.addEventListener){ 
   obj.addEventListener(evType, fn, false); 
   return true; 
 } else if (obj.attachEvent){ 
   var r = obj.attachEvent("on"+evType, fn); 
   return r; 
 } else { 
   return false; 
 } 
}


function equalHeightInit (){
  var botsl = document.getElementById ('botsl');
  if (!botsl) return;
  var objs = getElementsByClass ('moduletable*', botsl, 'DIV');
  equalHeight (objs, -20);
}

AddEvent (window, 'load', equalHeightInit);

ToolsHover = function() {
	var utw = document.getElementById("usertoolswrap");	
	if (!utw) return;

	utw.onmouseover=function() {
		this.className="toolswraphover";
	}
	utw.onmouseout=function() {
		this.className="";
	}
}







function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	var j = 0;
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\s)'+searchClass+'(\\s|$)');
	for (var i = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	//alert(searchClass + j);
	return classElements;
}


function showtabcontent (obj) {
	var tabdisplay = document.getElementById ('tab-content');
	if (!tabdisplay) return;
	var tabcontents = getElementsByClass ('tab-content', obj, "DIV");
	if (!tabcontents) return;
	tabdisplay.innerHTML = tabcontents[0].innerHTML;
	tabresetclass(obj);
}

function tabresetclass (obj) {
	var tab = document.getElementById ('tabswrap');
  if (tab) {
	  var lis = getElementsByClass ('tab-li', tab, "LI");
    if (!lis) return;
    for (var i=0; i<lis.length; i++) {
      lis[i].className = lis[i].className.replace(new RegExp(" tab-hover\\b"), "");
    }
    obj.className += " tab-hover";
  }
}

function tabinit (){
	var tab = document.getElementById ('tabswrap');
  if (tab) {
	  var tabcontents = getElementsByClass ('tab-content', tab, "DIV");
	  if (tabcontents) {
	   var tabdisplay = document.getElementById ('tab-content');
	   var divobj = document.createElement ("DIV");

	   divobj.style.display = "block";
	   divobj.style.position = "absolute";
	   divobj.style.top = "-1000px";
	   divobj.style.width = tabdisplay.offsetWidth + "px";
	   document.body.appendChild (divobj);
	   var maxh = 0;
      for (var i=0; i<tabcontents.length; i++) {
        divobj.innerHTML = tabcontents[i].innerHTML;
        if (maxh < divobj.offsetHeight) maxh = divobj.offsetHeight;
      }
     tabdisplay.style.height = (maxh - 20) + "px"; 
	   document.body.removeChild (divobj);
    }
	  var lis = getElementsByClass ('tab-li', tab, "LI");
    if (!lis) return;
    showtabcontent (lis[0]);
    
  }
}

AddEvent (window, 'load', tabinit);

function InitHover () {
  addMouseOver ('newsitem-inner');
}
AddEvent (window, 'load', InitHover);
