<!-- Hide script contents from old browsers 
/*****************************************************************************************
*  Project Name:    AIM Online Web Site
*  Project Number:  3318B
*
*  Object Name:     client_lib.js
*  Reference No:    P3318B/T9/JS/2
*
*  Description:     
*    Set of client side javascript functions. Must only be called from client side code.
*
*  Available Methods: 
*    KeepOutOfFrame - If page is in a frame make it the top element
*    CheckSearchForm - Validates user input for keywords in search form
*    GotoHelp - Opens a new Help browser window
*    GotoAIMOnlineSystem - Opens the AIM Online System application in a new browser window.
*    OpenNewFullScreenWindow - Opens a web page in a new fullscreen window
*	 GotoPageID - redirects to the specified page (as defined in redirect.asp)
*
*  Configuration Record
*
*  Review           Version  Author(s)         Date        Change No.
*  P3318B/PM5.7/119 1.0      J.Blazey          23/08/2001  Original
*  P3318B/PM5.7/539 1.1      A Coulter         14/03/2002  P3318B/PM5.9/CCR5
*  P3318B/PM5.7/917 1.2      M Zalio           25/07/2002  PM5.9/CR74
*  ECF7996/PM5.7/16 1.3      R Cook			   17/06/2003  PM5.9/CR106
*  ECF7996/PM5.7/20 1.4      R Cook			   25/06/2003  UAT_IR_295
*
*  Copyright CMG Admiral Australia 2001
*****************************************************************************************
*  Revision History
*
*  Version  Description
*  1.0      Original.
*  1.1      Added script comments to hide from old browsers (Accessibility). Also 
*           modified a validation message to coincide with server-side validation.
*  1.2      PM5.9/CR74:
*           - GotoAIMOnlineSystem: new function to navigate the user into the AIM Online
*           System application
*  1.3		PM5.9/CR106:
*			- OpenNewFullScreenWindow: new function to assist in displaying practice tests
*			- GotoPageID: new function to call redirect.asp with a Page ID.
*  1.4		UAT:IR_295:
*			- OpenNewFullScreenWindow: added "scrollbars=yes,resizeable=yes" to ensure
*			  scrollbars appear when in Visitor Practice mode.
*
****************************************************************************************/
  // Window objects
  var objAIMHelpWindow = null;
  var m_objWin = null;
  
  // 

  // Check if page is in a frame and fix if not
  function KeepOutOfFrame()
  {
    if(top.location != self.location)
    {
      top.location = self.location;
    }
  }
  
  // Checks that the user has entered valid keywords. An empty string is not valid.
  function CheckSearchForm(i_objForm)
  {   // Search keywords
      var strKeywords = i_objForm.txtKeywords.value;
      // No keywords entered
      if (strKeywords == '')
      {
        alert("Keywords must not be blank. Please enter keywords, or a search phrase in double quotes and then press Go.");
        i_objForm.txtKeywords.focus();
        return false;
      }
      // Forbidden keywords entered script or any tags
      //  
      if (strKeywords.toLowerCase().indexOf("<"+"script") != -1)
      {
        alert("Forbidden Keywords. Script tags are not permitted.");
        i_objForm.txtKeywords.focus();
        return false;
      }

      return true;
  }
 
  // Opens a help window and passes in the anchor reference within page.
  // If window exists focus it, if closed open a new one
  function GotoHelp(strWebRoot, strPageAnchor)
  {
      // Set help window focus if it exists
      if(typeof(objAIMHelpWindow) != "undefined" && objAIMHelpWindow != null)
      {
        // If window is closed set to null to avoid errors
        if(objAIMHelpWindow.closed)
        {
          objAIMHelpWindow = null;
          OpenHelpWindow(strWebRoot, strPageAnchor);
        }
        else
        {
          // Assumes objAIMHelpWindow.blur == true
          objAIMHelpWindow.focus();
          objAIMHelpWindow.location = strWebRoot+"/help/help.htm#"+strPageAnchor;
        }
      }
      else
      {
        OpenHelpWindow(strWebRoot, strPageAnchor);
      }
  }

  // Opens a new help Window with Web Root virtual directory 
  // and Page Anchor passed in
  function OpenHelpWindow(strWebRoot, strPageAnchor)
  {
        objAIMHelpWindow = window.open(strWebRoot+"/help/help.htm#"+strPageAnchor,
            "AIMHelp",
            "toolbar=no,width=780,height=500,directories=no,"+
            "menubar=no,scrollbars=yes,resizable=yes,screenX=100,screenY=100");
            
        objAIMHelpWindow.moveTo(30,30);                
  }
  
  /***************************************************************************
  * Item        : GotoAIMOnlineSystem
  * Description : Opens a new window for the AIM Online System application.
  * Inputs      : Nothing
  * Returns     : Nothing
  ***************************************************************************/
  function GotoAIMOnlineSystem()
  {
    var strServer = window.location.hostname;
    var strURL = "https://"+strServer+"/client_controller.asp";
    var strWinStyle = "menubar=yes,toolbar=no,scrollbars=yes," + 
                      "status=yes,resizable=yes," + 
                      "top=0,left=0," + 
                      "height=" + (screen.availHeight - 100) + 
                      ",width=" + (screen.availWidth - 10);  
    
    window.open(strURL,"",strWinStyle);
    return;
  }

  
  
  /***************************************************************************
  * Item        : OpenNewFullScreenWindow
  * Description : Opens a web page in fullscreen mode, similar to how the
  *				  private website displays online tests.
  * Inputs      : i_strURL - full URL of the page to open
  * Returns     : Nothing
  * Assumptions : fullscreen=true is not used in this instance as it makes it
  *				  difficult for visitors to close the window
  ***************************************************************************/
  function OpenNewFullScreenWindow (i_strURL)
  {
	var blnClosed = true;
	var strWinStyle = "menubar=no,hotkeys=no,resizable=yes,titlebar=yes," +
	                  "statusbar=no,scrollbars=yes";
	if (m_objWin != null) blnClosed = m_objWin.closed;
	if (blnClosed)
	{
		m_objWin = window.open(i_strURL,"AIMTest",strWinStyle);
	    m_objWin.resizeTo(screen.availWidth,screen.availHeight);
	    m_objWin.moveTo(0,0);
	  }
	m_objWin.focus();
	return;
  }
  
  /***************************************************************************
  * Item        : GotoPageID
  * Description : Redirects to the specified page ID
  * Inputs      : i_strPageID - Page ID as specified in redirect.asp
  *				: i_strQueryString - Optional query string to pass through
  *				: i_blnFullScreen - set to true to open in fullscreen mode
  * Returns     : Nothing
  * Assumptions : redirect.asp resides in the public website. Page IDs are
  *				  defined in redirect.asp.
  ***************************************************************************/
  function GotoPageID(i_strPageID, i_strQueryString, i_blnFullScreen)
  {
    var strServer = window.location.hostname;
    var strURL = "http://"+strServer+"/redirect.asp?pageid=" + i_strPageID;
    
    if (typeof(i_strQueryString) != "undefined") {
		strURL += "&" + i_strQueryString;
	}
	if ((typeof(i_blnFullScreen) != "undefined") && i_blnFullScreen) {
		OpenNewFullScreenWindow(strURL);
	} else {
		location.href = strURL;
	}
    return;
  }
  
  // end hiding script contents from old browsers -->