var WinId = new Array();
CurrentWin = 0;

function openWindow(width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=yes,status=0,menubar=no,menu=no, scrollbars=no');
	return WinId[CurrentWin++];
}

function openWindowNoRes (width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=no,status=0,menubar=no,menu=no, scrollbars=no');
	return WinId[CurrentWin++];
}

function openWindowScroll(width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=yes,status=0,menubar=no,menu=no, scrollbars=yes');
	return WinId[CurrentWin++];
}
function openWindowFixed(event,width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
	var topY = event.screenY +12;
	var leftX = event.screenX -17;	
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+topY+',left='+leftX+',resizable=no,status=0,menubar=no,scrollbars=no, border=no');
}

function openWindowMenu(width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=yes,status=0,menubar=yes,menu=yes,scrollbars=yes');
	return WinId[CurrentWin++];
}

function openWindowFull(width, height, winLocation, winName) {
    x = (640 - width)/2, y = (480 - height)/2;
	if (screen) {
        y = (screen.availHeight - height)/2;
        x = (screen.availWidth - width)/2;
    }
    WinId[CurrentWin++] = window.open (winLocation, winName, 'width='+width+',height='+height+',screenX='+x+',screenY='+y+',top='+y+',left='+x+',resizable=yes, menubar=yes,menu=yes,scrollbars=yes,location=yes,toolbar=yes,status=yes');
	return WinId[CurrentWin++];
}
function closeAll() {
    for (i=0;i<WinId.length;i++) {
   		if (WinId[i] && !WinId[i].closed) WinId[i].close();
    	}
}

function listAll() {
	alert (WinId.length);
    for (i=0;i<WinId.length;i++) {
   		if (WinId[i] && !WinId[i].closed) alert (WinId[i]);
    	}
}

