var newwin
var UniqueWin

function cleanupwin(){
	if (newwin!=null && !newwin.closed){
		newwin.close();
		newwin=null;
	}
}

function popwin(url,winname,width,height) {
  var leftPo = (screen.availWidth-width)/2
  var topPo = (screen.availHeight-height)/2
  if (newwin != null && !newwin.closed) {newwin.close(); newwin=null;} 
  newwin = window.open(url, winname, "scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,height="+height+",width="+width+",left="+leftPo+",top="+topPo)
  newwin.focus();
  return false;
}

function popUniqueWin(url,winname,width,height) { 
  var leftPo = (screen.availWidth-width)/2
  var topPo = (screen.availHeight-height)/2
  if (UniqueWin != null && !UniqueWin.closed) {UniqueWin.close(); UniqueWin=null;} 
  UniqueWin = window.open(url, winname, "scrollbars=yes,toolbar=no,status=no,location=no,menubar=no,resizable=yes,height="+height+",width="+width+",left="+leftPo+",top="+topPo)
  UniqueWin.focus();
  return false;
}

/*
	format:
	return popUniqueWin (win, '', width, height)
*/

function adminwin(win) { // admin panel
	return popUniqueWin(win,'',760,550);
}

function profwin(win) { // show voter stats
	return popUniqueWin(win,'',680,440);
}

function addresswin(win) { // quick Address; PM read status
	if (!document.all){
		return popwin(win,'address',230,465);
	}else{
		return popwin(win,'',230,465);
	}
}

function uplwin(win) { // upload
	if (!document.all){
		return popwin(win,'uplwin',300,170);
	}else{
		return popwin(win,'',300,170);
	}
}

function previewwin(win) { // preview
	if (!document.all){
		return popwin(win,'previewwin',660,510);
	}else{
		return popwin(win,'',660,510);
	}
}

function pgdwin(win) { // pgd code helper window
	if (!document.all){
		return popwin(win,'pgdwin',660,510);
	}else{
		return popwin(win,'',660,510);
	}
}

function powin(win) { // post
	return popwin(win,'',660,510);
}

function fwdwin(win) { // forward
	return popwin(win,'',500,130);
}

function logwin(win) { // login; move post to another forum window
	return popwin(win,'',330,200);
}
