//Define PopupWindow process
function winopen(filenamewtoken,winWidth,winHeight,whichwindow) {
	closechild(); 
 	if (document.all) {	var xMax = screen.width, yMax = screen.height;
    } else {
		if (document.layers) { var xMax = window.outerWidth, yMax = window.outerHeight;
        } else { var xMax = 640, yMax=480; }
	}
	var xOffset = (xMax - winWidth)/2, yOffset = ((yMax - winHeight)/2) - 30;
	//Whichwindow == 1 -- No Scrolls, no Menu
	//Whichwindow == 2 -- Scrolls, no Menu
	//Whichwindow == 3 -- Scrolls, Menu
	//Whichwindow == 4 -- Custom: for shopping cart popup window
	if (whichwindow == 1) { PopupWindow = window.open(filenamewtoken,'PopupWindow', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else if (whichwindow == 2) { PopupWindow = window.open(filenamewtoken,'PopupWindow', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else if (whichwindow == 4) { PopupWindow = window.open(filenamewtoken,'PopupWindow', 'screenX='+1+',screenY='+yOffset+',top='+yOffset+',left='+1+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else { PopupWindow = window.open(filenamewtoken,'PopupWindow', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,hotkeys=no,resizable=yes,width='+winWidth+',height='+winHeight+'');
	}
	if (!PopupWindow.opener) { PopupWindow.opener = self; }
	PopupWindow.focus();
	if (PopupWindow && PopupWindow.open && !PopupWindow.closed) {
	 	if (document.all && PopupWindow.document && PopupWindow.document.body && PopupWindow.document.body.clientWidth) {	
			if (Math.abs(winWidth-PopupWindow.document.body.clientWidth) > 30) { winopen(filenamewtoken,winWidth,winHeight,whichwindow); }
	    } else if (PopupWindow.innerWidth) {
			if (Math.abs(winWidth-PopupWindow.window.innerWidth) > 30) { winopen(filenamewtoken,winWidth,winHeight,whichwindow); }
		}
	}
}

//This function closes the PopupWindow if it is open when the main page is redirected
var PopupWindow = '';
function closechild() { if (PopupWindow && PopupWindow.open && !PopupWindow.closed) { PopupWindow.close(); } }

//Define secondary PopupWindowAdmin process
function winopenadmin(filenamewtoken,winWidth,winHeight,whichwindow) {
	closechildadmin(); 
 	if (document.all) {	
		var xMax = screen.width, yMax = screen.height;
    } else {
		if (document.layers) {
			var xMax = window.outerWidth, yMax = window.outerHeight;
        } else { var xMax = 640, yMax=480; }
	}
	var xOffset = (xMax - winWidth)/2, yOffset = ((yMax - winHeight)/2) - 30;
	//Whichwindow == 1 -- No Scrolls, no Menu
	//Whichwindow == 2 -- Scrolls, no Menu
	//Whichwindow == 3 -- Scrolls, Menu
	//Whichwindow == 4 -- Custom: for shopping cart popup window
	if (whichwindow == 1) { PopupWindowAdmin = window.open(filenamewtoken,'PopupWindowAdmin', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else if (whichwindow == 2) { PopupWindowAdmin = window.open(filenamewtoken,'PopupWindowAdmin', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else if (whichwindow == 4) { PopupWindowAdmin = window.open(filenamewtoken,'PopupWindowAdmin', 'screenX='+185+',screenY='+yOffset+',top='+yOffset+',left='+185+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,hotkeys=no,resizable=no,width='+winWidth+',height='+winHeight+'');
	} else { PopupWindowAdmin = window.open(filenamewtoken,'PopupWindowAdmin', 'screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+',toolbar=no,location=yes,directories=no,status=no,menubar=yes,scrollbars=yes,hotkeys=no,resizable=yes,width='+winWidth+',height='+winHeight+'');
	}
	if (!PopupWindowAdmin.opener) { PopupWindowAdmin.opener = self; }
	PopupWindowAdmin.focus();
	if (PopupWindowAdmin && PopupWindowAdmin.open && !PopupWindowAdmin.closed) {
	 	if (document.all && PopupWindowAdmin.document && PopupWindowAdmin.document.body && PopupWindowAdmin.document.body.clientWidth) {	
			if (Math.abs(winWidth-PopupWindowAdmin.document.body.clientWidth) > 30) { winopenadmin(filenamewtoken,winWidth,winHeight,whichwindow); }
	    } else if (PopupWindowAdmin.innerWidth) {
			if (Math.abs(winWidth-PopupWindowAdmin.window.innerWidth) > 30) { winopenadmin(filenamewtoken,winWidth,winHeight,whichwindow); }
		}
	}
}

var PopupWindowAdmin = '';
function closechildadmin() {
	if (PopupWindowAdmin && PopupWindowAdmin.open && !PopupWindowAdmin.closed) { PopupWindowAdmin.close(); }
}

