// JavaScript Document

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function moveContainer(obj, top, left) {
    obj.style.top = top+'px'
    obj.style.left = left+'px'
}

function getElement(id) {
    return document.getElementById(id);
}
function createBox(id, bClass) {            
    var hb = document.createElement('div');
    hb.setAttribute('class', bClass);
    hb.setAttribute('id', id);            
    document.getElementsByTagName('div')[0].appendChild(hb);
}
function showHelp(content, btn) {
    if(getElement('helpBox')==null)
        createBox('helpBox', 'helpBox');
      
    getElement('helpBox').innerHTML = content;
    pos = findPos(btn);    
    moveContainer(getElement('helpBox'), pos[1]+20, pos[0]+20);
    show('helpBox');           
}
function hide(id) {
    getElement(id).style.display = 'none';
}
function show(id) {
    getElement(id).style.display = 'block';
}
function moveBy(o1, o2) {
    pos = findPos(getElement(o1));
    moveContainer(getElement(o2), pos[1]+20, pos[0]+20);
}
