function popWindow(url, width, height)
{
	popWin = window.open(url, 'PopWindow', 'width=' + width + ', height=' + height + ', left = 10, top = 10, resizable=yes, scrollbars=no, toolbar=no, location=center, menubar=no, alwaysRaised=yes','');
}

function popWindow(url, width, height, scrolling)
{
	popWin = window.open(url, 'PopWindow', 'width=' + width + ', height=' + height + ', left = 10, top = 10, resizable=yes, scrollbars=' + scrolling + ', toolbar=no, location=center, menubar=no, alwaysRaised=yes','');
}

function showPopup(url, resizable, windowname) 
{
    if (! resizable) {
        resizable='yes';
    }
    if (! windowname) {
        windowname='dialog_window';
    }

    window.open(url, windowname, 'toolbar=no,location=no,directories=no,status=yes,menubar=no, scrollbars=yes,resizable=' + resizable + ',width=400,height=400,left=0,top=0');
}

function initPopup() {

		window.blur();

        if (!document.all) {
            window.sizeToContent();
            window.sizeToContent(); // for reasons beyond understanding,
                        // only if we call it twice we get the
                        // correct size.
            window.addEventListener("unload", myclose, true);
            // center on parent
            var px1 = opener.screenX;
            var px2 = opener.screenX + opener.outerWidth;
            var py1 = opener.screenY;
            var py2 = opener.screenY + opener.outerHeight;
            //var x = (px2 - px1 - window.outerWidth) / 2;
            //var y = (py2 - py1 - window.outerHeight) / 2;
            var x = 50;
            var y = 50;
            window.moveTo(x, y);
            var body = document.body;
            window.innerHeight = body.offsetHeight;
            window.innerWidth = body.offsetWidth;

        } else {

            var body = document.body;
            var contentblock = document.getElementById('contentblock');

            var winW = body.clientWidth;
            var winH = body.clientHeight;

            var popW = contentblock.clientWidth + 29;
            var popH = contentblock.clientHeight + 38;

            if (popW > window.screen.width) {
                popW = window.screen.width - 75;
            }

            if (popH > window.screen.height) {
                popH = window.screen.height - 75;
            }

            //var leftPos = (window.screen.width - popW) / 2;
            //var topPos = (window.screen.height - popH) / 2;
            var leftPos = 50;
            var topPos = 50;

            window.resizeTo(popW, popH + 25);
            if (window.screenLeft < 10 && window.screenLeft > 0) {
                window.moveTo(leftPos, topPos);
            }

        }

       window.focus();
}

function newPopUp(PopupPage)
{
		var DetailWindow
		DetailWindow = window.open(PopupPage, 'Immunotec', 'width=700, height=400, top=10, left=10, resizable=yes, scrollbars=yes, toolbar=no, location=no, menubar=no,alwaysRaised=yes');
}

function popHelp(helpID)
{
	popWin = window.open('/nonsectionfiles/general/Help.aspx?HID=' + helpID, 'eonlinedata', 'width=400, height=400, left = 650, top = 450, resizable=no, scrollbars=yes, toolbar=no, location=center, menubar=no, alwaysRaised=yes','');
}

function popCalendar(currentDate, controlName)
{
	popWin = window.open('/smallcalendar/?CurrentDate=' + currentDate + '&ParentControl=' + controlName, 'PopWindow', 'width=180, height=180, left = 650, top = 450, resizable=no, scrollbars=no, toolbar=no, location=center, menubar=no, alwaysRaised=yes','');
}

function refreshAndClose()
{
	window.opener.location.reload();
	window.close();
}

function autotab(original,destination)
{
	if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
	{
		destination.focus()
	}
}



