﻿
		
stdBrowser = (document.getElementById) ? true : false

function toggleMenuOver(currElem,id) {
			
	var mainimage = document.getElementById(id);
			
			var h = mainimage.offsetHeight;
			var w = mainimage.offsetWidth;
			
			var x = getElementLeft(mainimage);
			var y = getElementTop(mainimage);
			
			//alert('x: '+x+' y:'+y);
			
			menuObj = (stdBrowser) ? document.getElementById(currElem).style : eval("document." + currElem)
			menuObj.top = (y + h) - 1 + "px";
			menuObj.left = (x - 1) + "px";
			menuObj.visibility = "visible"
			
			
	}
		
function toggleMenuOut(currElem,topPos,leftPos) {

			menuObj = (stdBrowser) ? document.getElementById(currElem).style : eval("document." + currElem)
			//menuObj.top = (stdBrowser) ? topPos + "px" : topPos
			//menuObj.left = (stdBrowser) ? leftPos + "px" : leftPos
			menuObj.visibility = "hidden"
}
		
		
function getElementLeft(elm) {
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) {
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}

var win = null;

function newWindow(mypage,myname,w,h,scroll){
	
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=yes';
	win = window.open(mypage,myname,settings);
}

// ON SCREEN POP-UP WINDOW
function showPopUp(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)

var divimg = dlg.getElementsByTagName('img')[0];

cvr.style.display = 'block'

dlg.style.top = '0px';
dlg.style.left = '0px';

dlg.style.width = '100%';
dlg.style.height = '100%';

//alert(screen.width + 'px');

dlg.style.display = 'block'
}

function closePopUp(el) {
var cvr = document.getElementById('cover')
var dlg = document.getElementById(el)
cvr.style.display = 'none'
dlg.style.display = 'none'
document.body.style.overflowY = 'scroll'
}

