
function popWin(popPath, popName, w, h, scroll, pos) {
	if (pos == "random") {
		leftPos = (screen.availWidth) ? Math.floor(Math.random()*(screen.availWidth-w)) : 100;
		topPos = (screen.availHeight) ? Math.floor(Math.random()*((screen.availHeight-h)-75)) : 100;
	}
	if (pos == "center") {
		leftPos = (screen.availWidth) ? (screen.availWidth-w)/2 : 100;
		topPos = (screen.availHeight) ? (((screen.availHeight-h)/2) - (screen.height - screen.availHeight)) : 100;
	}
	else if ((pos != "center" && pos != "random") || pos == null) {
		leftPos = 0;
		topPos = 20;
	}
	popParams = 'width=' + w + ', height=' + h + ', top=' + topPos + ', left=' + leftPos + ', scrollbars=' + scroll + ', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=no, fullscreen=no';
	objPopup = window.open(popPath, popName, popParams);
}

function popWinResizeable(popPath, popName, w, h, scroll, pos) {
	if (w > screen.availWidth) {
		w = screen.availWidth;
	}
	if (h > screen.availHeight) {
		h = screen.availHeight;
	}
	if (pos == "random") {
		leftPos = (screen.availWidth) ? Math.floor(Math.random()*(screen.availWidth-w)) : 100;
		topPos = (screen.availHeight) ? Math.floor(Math.random()*((screen.availHeight-h)-75)) : 100;
	}
	if (pos == "center") {
		leftPos = (screen.availWidth) ? (screen.availWidth-w)/2 : 100;
		topPos = (screen.availHeight) ? (((screen.availHeight-h)/2) - (screen.height - screen.availHeight)) : 100;
	}
	else if ((pos != "center" && pos != "random") || pos == null) {
		leftPos = 0;
		topPos = 20;
	}
	popParams = 'width=' + w + ', height=' + h + ', top=' + topPos + ', left=' + leftPos + ', scrollbars=' + scroll + ', location=no, directories=no, status=no, menubar=no, toolbar=no, resizable=yes, fullscreen=no';
	objPopup = window.open(popPath, popName, popParams);
}

function popWinStatusBar(popPath, popName, w, h, scroll, pos) {
	if (pos == "random") {
		leftPos = (screen.availWidth) ? Math.floor(Math.random()*(screen.availWidth-w)) : 100;
		topPos = (screen.availHeight) ? Math.floor(Math.random()*((screen.availHeight-h)-75)) : 100;
	}
	if (pos == "center") {
		leftPos = (screen.availWidth) ? (screen.availWidth-w)/2 : 100;
		topPos = (screen.availHeight) ? (((screen.availHeight-h)/2) - (screen.height - screen.availHeight)) : 100;
	}
	else if ((pos != "center" && pos != "random") || pos == null) {
		leftPos = 0;
		topPos = 20;
	}
	popParams = 'width=' + w + ', height=' + h + ', top=' + topPos + ', left=' + leftPos + ', scrollbars=' + scroll + ', location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=yes, fullscreen=no';
	objPopup = window.open(popPath, popName, popParams);
}

function popWinStatusBarXY(popPath, popName, w, h, scroll, x,y) {
	leftPos = x;
	topPos = y;
	popParams = 'width=' + w + ', height=' + h + ', top=' + topPos + ', left=' + leftPos + ', scrollbars=' + scroll + ', location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=no, fullscreen=no';
	objPopup = window.open(popPath, popName, popParams);
}

function popWinHidden(popPath, popName) {
	leftPos = screen.availWidth+1000;
	topPos = screen.availHeight+1000;
	popParams = 'width = 1, height= 1, top=' + topPos + ', left=' + leftPos + ', scrollbars=yes, location=no, directories=no, status=yes, menubar=no, toolbar=no, resizable=no, fullscreen=no';
	objPopup = window.open(popPath, popName, popParams);
}

function closePopup() {
	if (objPopup && objPopup.open && !objPopup.closed) {
		objPopup.close();
	}
}


