var wAbout
var wHelp
var wNews
var wMsg
var wContentInfo

var wPopScale
var wPopSkill

var wPopApprover

var theNews=''
var wPopCal   //handle of the pop-up window
var popCalPtr //textbox pop-up is working with

var fSCOTrace = 0 //content trace
var wSCOTrace
var sCurrCourse;

function doAbout()
	{
	if (!wAbout || wAbout.closed)
		wAbout = window.open('About.htm','AboutStudentCenter','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=600,height=380');
	else 
		wAbout.focus()
	}

function doHelp(eHelpID)
	{
	var sURL = 'Help.htm'
	if ( eHelpID != null )
		sURL += '?helpid=' + eHelpID

	if (!wHelp || wHelp.closed)
		{
		wHelp = window.open(sURL,'Help','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=500,height=400')
		}
		else
		{
		wHelp.location.replace(sURL)
		wHelp.focus()
		}
	}

function doNews() {
	doUserWindow('News.htm', 'News')
}

function doUserWindow(strPage, strWindow) {
  if (theNews != strPage) {
    if (wNews) {
      if (wNews.closed) wNews=0;
      if (wNews) {
        theNews = strPage;
        wNews.focus();
        wNews.location = theNews;
        return;
      }
    }
  }
  theNews = strPage;
  if (!wNews || wNews.closed) {
      wNews = window.open(theNews,strWindow,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=610,height=400');
  } else {
      wNews.focus()
  }
}

function doUnloadCloseWindows()
	{
	if (wPopCal)
		{
		if (wPopCal.closed) wPopCal=0;
		if (wPopCal) wPopCal.close();
		}
	if (wAbout)
		{
		if (wAbout.closed) wAbout=0;
		if (wAbout) wAbout.close();
		}
	if (wHelp)
		{
		if (wHelp.closed) wHelp=0;
		if (wHelp) wHelp.close();
		}
	if (wNews)
		{
		if (wNews.closed) wNews=0;
		if (wNews) wNews.close();
		}
	if (wMsg)
		{
		if (wMsg.closed) wMsg=0;
		if (wMsg) wMsg.close();
		}
	if (wContentInfo)
		{
		if (wContentInfo.closed) wContentInfo=0;
		if (wContentInfo) wContentInfo.close();
		}
	if (wPopScale)
		{
		if (wPopScale.closed) wPopScale=0;
		if (wPopScale) wPopScale.close();
		}
	if (wPopSkill)
		{
		if (wPopSkill.closed) wPopSkill=0;
		if (wPopSkill) wPopSkill.close();
		}
	if (wPopApprover)
		{
		if (wPopApprover.closed) wPopApprover=0;
		if (wPopApprover) wPopApprover.close();
		}
	}
	
function doUnloadTraceWindow()
	{
	if (wSCOTrace)
		{
		if (wSCOTrace.closed) wSCOTrace=0;
		if (wSCOTrace) wSCOTrace.close();
		}	
	}

//open pop-up window if needed, else give it the focus to bring it on top
var POPCAL_WIDTH_IE = 200
var POPCAL_HEIGHT_IE = 260
var POPCAL_WIDTH_IE_LG = 220
var POPCAL_HEIGHT_IE_LG = 340

var POPCAL_WIDTH_NS6 = 180
var POPCAL_HEIGHT_NS6 = 280
var POPCAL_WIDTH_NS6_LG = 220
var POPCAL_HEIGHT_NS6_LG = 350

var POPCAL_WIDTH = 220
var POPCAL_HEIGHT = 300

var popCalWidth = null
var popCalHeight = null
function popCal() {
    if (!wPopCal || wPopCal.closed) {
		if ( popCalWidth == null ) {
			popCalWidth  = POPCAL_WIDTH
			popCalHeight = POPCAL_HEIGHT 
			if ( isIE() ) {
				popCalWidth  = POPCAL_WIDTH_IE
				popCalHeight = POPCAL_HEIGHT_IE 
			}
			else if ( isNetscape6() ) {
				popCalWidth  = POPCAL_WIDTH_NS6
				popCalHeight = POPCAL_HEIGHT_NS6 
			}
		}
        wPopCal=window.open('popcal.htm','PickADate','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,copyhistory=0,width=' + popCalWidth + ',height=' + popCalHeight)
    } else {
        wPopCal.focus();
        wPopCal.document.pickadateform.text.value=popCalPtr.value;
    }
}
//clicked calendar icon of textbox n
function clickPopCal( objTextBox ) {
    popCalPtr=objTextBox;
    popCal();
}
//close pop-up window before this window closes (body onUnload=)
//textbox got focus or changed (onFocus= and onBlur=)
function popCalSetFieldFocus( objTextBox ) {
    if (wPopCal) {
        if (!wPopCal.closed) {
            popCalPtr=objTextBox;
            wPopCal.document.pickadateform.text.value=popCalPtr.value;
        }
    }
}

function closePopCal()
	{
	if (wPopCal)
		{
		if (wPopCal.closed) wPopCal=0;
		if (wPopCal) wPopCal.close();
		}
	}

function printWindow( w ) 
	{
	if (w.print)
		{
		w.print();

		// We pause 2.5 seconds while the Print Dialog is being displayed.
		// In IE if you close the window being printed before the Print Dialog is displayed,
		// then a JavaScript exception is thrown.  The pause here prevents the window from being closed.
		objCore.pause(2500);
		}
    else
		alert('Please press alt-P to print.');
	}

function psMessageBox( msg, isHtml )
	{
	var sURL = 'MsgBox.htm?'
	if ( isHtml == true )
		sURL += 'htm=' + escape(msg)
	else
		sURL += 'text=' + escape(msg)

	if (!wMsg || wMsg.closed)
		{
		wMsg = window.open( sURL, "MessageBox", 
		                         "resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,width=520,height=200")
		}
	else
		{
		wMsg.location.replace( sURL )
		wMsg.focus()
		}
   }

function ShowContentInfo( key )
	{
	if (!wContentInfo || wContentInfo.closed)
		{
		wContentInfo = window.open('', '', 'toolbar=no,resizable,scrollbars=yes,status=yes,width=600,height=400,left=20,top=20')
		}
	else
		{
		wContentInfo.focus()
		}

	objCore.psShowContentInfoPage( wContentInfo, key )
	}

function doPopScale( scalecode )
	{
	var url = InternalURL_GetPopScale(null, null, scalecode)
	if (!wPopScale || wPopScale.closed)
		wPopScale = window.open(url, 'popscale','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=300,height=420')
	else
		{
		wPopScale.location.replace(url)
		wPopScale.focus()
		}
	}

function doPopSkill( skillcode )
	{
	var url = InternalURL_GetPopSkill(null, null, skillcode)
	if (!wPopSkill || wPopSkill.closed)
		wPopSkill = window.open(url, 'popskill','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=300,height=200')
	else
		{
		wPopSkill.location.replace(url)
		wPopSkill.focus()
		}
	}
	
function doPopApprover( locator )
	{
	var url = InternalURL_GetPopApprover(null, null, locator)
	if (!wPopApprover || wPopApprover.closed)
		wPopApprover = window.open(url, 'popapprover','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,width=300,height=200')
	else
		{
		wPopApprover.location.replace(url)
		wPopApprover.focus()
		}
	}

function closeScalePopWindow()
	{
	if (wPopScale)
		{
		if (wPopScale.closed) wPopScale=0;
		if (wPopScale) wPopScale.close();
		}
	}

function closeSkillPopWindow()
	{
	if (wPopSkill)
		{
		if (wPopSkill.closed) wPopSkill=0;
		if (wPopSkill) wPopSkill.close();
		}
	}

function psOpenSCOTrace(sCourseCode)
   {
   if (!wSCOTrace || wSCOTrace.closed)
      {				
	  sCurrCourse = sCourseCode;	
      wSCOTrace = open( templatePath + "/SCOTrace.htm", "SCOTrace",
         "resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,width=790,height=590,screenx=0,screeny=0");
	  }
   else
      {
      wSCOTrace.focus()
      }
   }


