/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Global variables */
var winW;
var winH;
var popupW;
var popupH;
var MinX = 25;
var MinY = 25;
/* End global variables */

function getposOffset(overlay, offsettype){
	var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
	var parentEl=overlay.offsetParent;
	while (parentEl!=null){
		totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return totaloffset;
}

function getWindowSize(){
	winW = 630;
	winH = 460;

	if (parseInt(navigator.appVersion)>3) {
	 	if (navigator.appName=="Netscape") {
  			winW = window.innerWidth;
  			winH = window.innerHeight;
 		}
 		if (navigator.appName.indexOf("Microsoft")!=-1) {
  			winW = document.body.offsetWidth;
  			winH = document.body.offsetHeight;
		}
	}
}

function overlay(curobj, subobjstr, opt_position){
	getWindowSize();
	if (document.getElementById){
		var subobj=document.getElementById(subobjstr)
		subobj.style.display=(subobj.style.display!="block")? "block" : "none"
		popupW = subobj.clientWidth;
		popupH = subobj.clientHeight;
		var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0)
		var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)

		if ((xpos + popupW) > (winW - MinX)){
			xpos = winW - popupW - MinX;
			if (xpos < MinX){
				xpos = MinX;
			}
		}
		if ((ypos + popupH) > (winH - MinY)){
			ypos = winH - popupH - MinY;
			if (ypos < MinY){	
				ypos = MinY;
			}
		}
		/*window.alert("xpos: " + xpos + " ypos: " + ypos + " popupW: " + popupW + " popupH: " + popupH + " winW: " + winW + " winH: " + winH);*/

		subobj.style.left=xpos+"px"
		subobj.style.top=ypos+"px"
		return false
	} 
	else
		return true
}

function overlayclose(subobj){
	document.getElementById(subobj).style.display="none"
}
