// Initialize global variables

var supplement;

function CloseWindows(){
	if (supplement) {
        if (supplement.closed==0) {
            supplement.close();
        }
    }
}

// This function opens a centered popup window.  If a window of the same name is already opened, the function closes the open window before opening a new one.  This ensures the window is always sized correctly.

function CenterWindow(page,w,h) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
	if (xOffset<=20)
	xOffset=0;
	if (yOffset<=40)
	yOffset=0;
	else{
	xOffset=xOffset;
	yOffset=yOffset;}

CloseWindows();
	
supplement = window.open(page,'supplement','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

// This function opens a centered popup window with NO scrollbars.  If a window of the same name is already opened, the function closes the open window before opening a new one.  This ensures the window is always sized correctly.

function CenterWindow2(page,w,h) {
    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
	if (xOffset<=20)
	xOffset=0;
	if (yOffset<=40)
	yOffset=0;
	else{
	xOffset=xOffset;
	yOffset=yOffset;}

CloseWindows();
	
supplement = window.open(page,'supplement','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
}

// This function opens an external Web site in a popup window.  It displays a banner at the top of the popup window, which indicates the learner is viewing a site outside of the learning environment and provides a [Close Window] link to close the popup.

function OutsideWindow(where)
{

    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
	if (xOffset<=10)
	xOffset=0;
	if (yOffset<=55)
	yOffset=0;
	else{
	xOffset=xOffset;
	yOffset=yOffset;}
	
CloseWindows();
	
supplement = window.open('','supplement','toolbar=yes,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=750,height=500,screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
	
	supplement.document.write("<html>");
	supplement.document.write("<head>");
	supplement.document.write("<title>"+where+"<\/title>");
	supplement.document.write("<\/head>");
	supplement.document.write("<frameset rows='50,*' frameborder='no' border='0'>");
    supplement.document.write("<frame name='top' src='../header.htm' marginwidth='0' marginheight='0' scrolling='no' noresize>");
	supplement.document.write("<frame name='bottom' src='"+where+"' marginwidth='0' marginheight='0' scrolling='auto' noresize>");
	supplement.document.write("<\/frameset>");
	supplement.document.write("<\/html>");

	supplement.document.close();
}

// This function opens the supplement Feedback in a popup window.  It displays a banner at the top of the popup window, which indicates the learner is viewing a site outside of the learning environment and provides a [Close Window] link to close the popup.

function FeedbackWindow(where,w,h,title)
{

    if (document.all)
        var xMax = screen.width, yMax = screen.height;
    else
        if (document.layers)
            var xMax = window.outerWidth, yMax = window.outerHeight;
        else
            var xMax = 800, yMax=600;

    var xOffset = (xMax - w)/2, yOffset = (yMax - h)/2;
	if (xOffset<=10)
	xOffset=0;
	if (yOffset<=55)
	yOffset=0;
	else{
	xOffset=xOffset;
	yOffset=yOffset;}
	
CloseWindows();
	
supplement = window.open('','supplement','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width='+w+',height='+h+',screenX='+xOffset+',screenY='+yOffset+',top='+yOffset+',left='+xOffset+'');
	
	supplement.document.write("<html>");
	supplement.document.write("<head>");
	supplement.document.write("<title>"+title+"<\/title>");
	supplement.document.write("<\/head>");
	supplement.document.write("<frameset rows='50,*' frameborder='no' border='0'>");
    supplement.document.write("<frame name='top' src='../header.htm' marginwidth='0' marginheight='0' scrolling='no' noresize>");
	supplement.document.write("<frame name='bottom' src='"+where+"' marginwidth='0' marginheight='0' scrolling='auto' noresize>");
	supplement.document.write("<\/frameset>");
	supplement.document.write("<\/html>");

	supplement.document.close();
}
