// --------------------------------------------------------------------------------------------
// DOM elements
// --------------------------------------------------------------------------------------------
function setElementClass (el, className) {
	if (className !== null) {
		// non-IE - harmless otherwise
		el.setAttribute("class", className);
		// IE - harmless otherwise
		el.setAttribute("className", className);
	}
}
function newElement(name,className) {
	var el=document.createElement(name);
	setElementClass(el,className);
	return el;
}
function newText (txt) {
	return document.createTextNode(txt);
}

function clearElementContent (el) {
	while (el.firstChild !== null) {
		el.removeChild(el.firstChild);
	}
}
function toggleRow(id){
	var e = document.getElementById(id);
   if(e.style.display == 'block'){
      e.style.display = 'none';
   }else{
      e.style.display = 'block';
   }
}
// --------------------------------------------------------------------------------------------
// Getting absolute pos of elements
// --------------------------------------------------------------------------------------------

function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}else if (obj.x){
		curleft += obj.x;
	}
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y){
		curtop += obj.y;
	}
	return curtop;
}
// --------------------------------------------------------------------------------------------
// Help box
// --------------------------------------------------------------------------------------------

var prevHelpObj=null;
function showHelp (obj, str) {
	if(str.length>0){
        var div=newElement("div","helpBox");
        div.id="helpBox";
        div.innerHTML = str;
        div.style.backgroundColor = '#D4FF7F';
        div.style.padding = '10px';
        div.style.border = '1px dotted #89B604';

        div.style.position="absolute";
        //var left=findPosX(obj)+obj.offsetWidth;
        //var top=findPosY(obj)+obj.offsetHeight;;
        div.style.left=(obj.left-100)+'px';
        div.style.top=(obj.top+100)+'px';
        document.body.appendChild(div);
        prevHelpObj=div;
	}
}

function hideHelp () {
	if (prevHelpObj !== null) {
		prevHelpObj.style.display="none";

	}
}

