popupbar = false;
popupmain = false;

function showwin(uri,x,y,nx,ny) {
	if (!document.createElement) { return; }

	var ua = navigator.userAgent;
	var PageOffset;
	var WindowHeight;
	if (document.all) {
		if (ua.indexOf("Opera",0) != -1) { defaultX = defaultY = 0; PageOffset = pageYOffset; WindowHeight = innerHeight; WindowWidth = innerWidth; }
		else { defaultX = document.documentElement.scrollLeft;	defaultY = document.documentElement.scrollTop; WindowHeight = document.documentElement.clientHeight; WindowWidth = document.documentElement.clientWidth; PageOffset = defaultY; }
		ex = x + defaultX;		ey = y + defaultY;
	} else if (document.layers) {
		defaultX = defaultY = 0;
		ex = x;		ey = y;
		PageOffset = pageYOffset;
		WindowHeight = innerHeight;
		WindowWidth = innerWidth;
	} else if (document.getElementById) {
		defaultX = defaultY = 0;
		ex = nx;		ey = ny;
		PageOffset = pageYOffset;
		WindowHeight = innerHeight;
		WindowWidth = innerWidth;
	}

	if (document.getElementById) {
		var popupmain = document.getElementById('IMGfloat');

		var imgsrc = document.createElement('img');
		imgsrc.setAttribute('src', uri);
		popupmain.appendChild(imgsrc);

		popupmain.style.left = WindowWidth * 0.9 - 300 + 'px'; 
		if ( WindowHeight < 306 ) { popupmain.style.top = PageOffset + 'px'; }
		else { popupmain.style.top = WindowHeight / 2  - 160 + PageOffset + 'px'; }
		popupmain.style.visibility = "visible";
	}
}

function hidewin() {
	if (parent.document.getElementById('IMGfloat')) {
		var closeWin = parent.document.getElementById('IMGfloat');
	} else {
		var closeWin = document.getElementById('IMGfloat');
	}
	closeWin.style.visibility = "hidden";
	closeWin.removeChild(closeWin.lastChild);
	closeWin = false;
}


function aWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}


var nw="";

function loadTosubwin(url){
    if( sbwin_closed(nw) ) {
        nw = window.open(url, 'newwin');
    } else {
        nw.location.href=url;
    }
    nw.focus();
}

function sbwin_closed(winVar) {
    var ua = navigator.userAgent;
    if( !winVar )
        if( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) 
            return winVar.closed
        else return typeof winVar.document != 'object'
    else return true
}
