// JavaScript Document
var myWin; 
function popup(url,name,windowWidth,windowHeight){
	myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",top="+mytop+",left="+myleft+	
			  "location=0,titlebar=0,toolbar=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0";
	
	if (!myWin || myWin.closed){
		myWin = window.open(url,name,properties);
	}else{
		myWin.close();
		myWin = window.open(url,name,properties)

	};
	void(0);
}

function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}


function showChildDiv(elemName, display, parentElem, shiftX, shiftY){

	divToDisplay = document.getElementById(elemName);
	
	if (display) {
	
		parentDiv = document.getElementById(parentElem);
	
		var x = findPosX(parentDiv) + parentDiv.offsetWidth;
		var y = findPosY(parentDiv) + parentDiv.offsetHeight;
		//alert("(x,y) = " + "(" + x + "," + y + ")");
		showDiv(elemName, true);
		
		divToDisplay.style.left = x - divToDisplay.offsetWidth + shiftX;
		divToDisplay.style.top = y + shiftY;
		
	} else {
		showDiv(elemName, false);
	}

}

function showDiv(elemName, display)
{
  if (display){
    document.getElementById(elemName).style.display = "block";
  }
  else {
    document.getElementById(elemName).style.display = "none";
  }
}
//document.onmousedown  = mouseSelect;
//document.oncontextmenu  = ItemSelMenu;

function toggleChild(elemName) {
	var target = document.getElementById(elemName);
	
	if (target.style.display == "none") {
		target.style.display = "block";	
	} else {
		target.style.display = "none";	
	}	
}
