function $(element) {
	return document.getElementById(element);
}

function insertAfter(parent, node, referenceNode) {
  parent.insertBefore(node, referenceNode.nextSibling);
}

function show(id, type){
	if (type)
	{
		$(id).style.display = 'block';
	}
	else
	{
		$(id).style.display = '';
	}
}

function hide(id){
	$(id).style.display = 'none';
}

function toggle(id)
{
	if ($(id).style.display == 'none')
	{
		show(id);
	}
	else
	{
		hide(id);
	}
}

function remove(id){
	id = $(id);
	id.parentNode.removeChild(id);
}

function disable(id) {
    id = $(id);
    id.blur();
    id.disabled = true;
}

function enable(id) {
    id = $(id);
    id.disabled = false;
}

String.prototype.br2nl =
  function() {
    return this.replace(/<br\s*\/?>\r?\n?/img,"\n"); //
  };
  
 String.prototype.nl2br =
  function() {
    return this.replace(/\n/img,"<br/>");
  };

function makeDoubleDelegate(function1, function2) {
    return function() {
        if (function1)
            function1();
        if (function2)
            function2();
    }
}

function opacity(id, opacStart, opacEnd, millisec) { 
	//speed for each frame 
	var speed = Math.round(millisec / 100); 
	var timer = 0; 

	//determine the direction for the blending, if start and end are the same nothing happens 
	if(opacStart > opacEnd) { 
		for(i = opacStart; i >= opacEnd; i--) { 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		} 
	} else if(opacStart < opacEnd) { 
		for(i = opacStart; i <= opacEnd; i++) 
		{ 
			setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
			timer++; 
		}
	}
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
	var object = document.getElementById(id).style; 
	object.opacity = (opacity / 100); 
	object.filter = "alpha(opacity=" + opacity + ")";
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp(strClassName);
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
			arrReturnElements.push(oElement);
		}
	}
	return (arrReturnElements)
}

function html_entity_decode( string ) {
    var ret, tarea = document.createElement('textarea');
    tarea.innerHTML = string;
    ret = tarea.value;
    return ret;
}

function htmlspecialchars(str) {
 if (typeof(str) == "string") {
  str = str.replace(/&/g, "&amp;"); /* must do &amp; first */
  str = str.replace(/"/g, "&quot;");
  str = str.replace(/'/g, "&#039;");
  str = str.replace(/</g, "&lt;");
  str = str.replace(/>/g, "&gt;");
  }
 return str;
 }

/*
		var objects = document.getElementsByTagName('tr');
		for(var no=0;no<objects.length;no++){
			if(objects[no].className=='active_comment_row'){
				hide(objects[no].id);
			}	
		}
					//loader = document.createElement("img");
			//loader.id = 'loader';
			//loader.src = '/img/bigloader.gif';
			//comment_right.appendChild(loader);	
*/
