﻿// JScript File

/***********************************************
* 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
***********************************************/

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 overlay(curobj, subobjstr, opt_position,ovrd_x,ovrd_y){
    if (document.getElementById){
        var subobj=document.getElementById(subobjstr)
        if (subobj) {
            subobj.style.display=(subobj.style.display!="block")? "block" : "none"
        }
        var xScroll, yScroll;
	
	    if (window.innerHeight && window.scrollMaxY) {	
		    xScroll = document.body.scrollWidth;
		    yScroll = window.innerHeight + window.scrollMaxY;
	    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		    xScroll = document.body.scrollWidth;
		    yScroll = document.body.scrollHeight;
	    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		    xScroll = document.body.offsetWidth;
		    yScroll = document.body.offsetHeight;
	    }
        
        var windowWidth, windowHeight;
	    if (self.innerHeight) {	// all except Explorer
		    windowWidth = self.innerWidth;
		    windowHeight = self.innerHeight;
	    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		    windowWidth = document.documentElement.clientWidth;
		    windowHeight = document.documentElement.clientHeight;
	    } else if (document.body) { // other Explorers
		    windowWidth = document.body.clientWidth;
		    windowHeight = document.body.clientHeight;
	    }	
        
        if (ovrd_x>0) {
            subobj.style.left=ovrd_x+"px"
        } else {
            var xpos
            if (ovrd_x==0) {
                xpos=(xScroll/2)+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0)                 
            } else { // where ovrd_x='' or -1
                xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0)                 
            }
            subobj.style.left=xpos+"px"
        }
        
        
        if (ovrd_y>0) {
            //alert('overriding to: '+ovrd_y+'px');
            subobj.style.top=ovrd_y+"px"
            return false
        } else {
            var ypos
            //alert('a');
            if (ovrd_y==0) {
                //alert('b');
                ypos=(yScroll/2)+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
            } else {  // where ovrd_y='' or -1
                ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
                //alert('c');
            }                
            subobj.style.top=ypos+"px"
            return false
            
        }
    }
    else {
        return true
    }
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}