/******************************************************************************
 *	Noop::Forum::Script
 *
 *       Author: svale/andreas@noop.no
 *        $Date: 2008-07-11 11:45:30 $
 *    	  $Revision: 1.1 $
 * 
 ***/
 
$(function(){
	// equal height on articles in main column
	/*$(".m-objs-ng div.l").each(function(i,e) {
		var $l = $(e);
		var $r = $l.next();
		var sel = ["h2", "p:first"];
		for(var s in sel)
		{
			s = sel[s];
			var hl = $l.find(s).height();
			var hr = $r.find(s).height();
			var hm = Math.max(hl,hr);
			if(hl < hm)
				$l.find(s).css("height",hm+"px");
			else if(hr < hm)
				$r.find(s).css("height",hm+"px");
		}			
	});*/
	
	// equal height on articles in main column
	$(".m-objs-ng div.l").each(function(i,e) {
		var tallest = 0;
		var $set = $(e).next().andSelf();
		$set.each(function(i){
//alert("i:"+$(this).height());
			if ($(this).height() > tallest)
				tallest = $(this).height(); 
		});
//		alert(tallest);	
		$set.css({'height' : tallest + "px"});
	});
});


 /**
 * frmValue
 */
function frmValue(oElement, sValue, fClear, oToggleElement)
{
	if(oElement)
	{
		if(!fClear && oElement.value == sValue)
		{
		    if(!oToggleElement)
		        oElement.value = '';
            else
		    {
		        oToggleElement.style.display = "block";
                oElement.style.display = "none";
		    }
        }
		else if(fClear && !oElement.value)
		{
			oElement.value = sValue;
        }
	}
}


/**
 * toggleCalItems
 */
function toggleCalItems(classname,link,showmore,showless) {
	var els = getElementsByClass(classname,null,'div');
	var elsLen = els.length;
	for (i = 0; i < els.length; i++) {
		var el = els[i]
		el.style.display = (el.style.display != 'none') ? 'none' : '';
	}
	link.innerHTML = (link.innerHTML != showless) ? link.innerHTML = showless : link.innerHTML = showmore;
}


/**
 * getElementsByClass
 */
function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	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 (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}
