var _B10_wndChild;
var _B10_boolOldBrowser = parseInt(navigator.appversion) < 3;

// B10_spawnWindow() -- spawn a child browser window
function B10_spawnWindow(name, content, width, height, scrollbars) {
  _B10_wndChild = B10_spawnWindowAndReturn(name, content, width, height, scrollbars);
}

// B10_spawnWindowAndReturn() -- spawn a child browser window and return a reference to the new window
function B10_spawnWindowAndReturn(name, content, width, height, scrollbars) {
	var strAttribs = 'toolbar=no,width=' + width + ',height=' + height + ',directories=no,status=no,scrollbars=' + ((scrollbars)?'yes':'no') + ',resizeable=yes,menubar=no,location=no,screeny=50,screenx=50,alwaysRaised';
  var objWindow = window.open(content, name, strAttribs);
	if (!objWindow.opener) { objWindow.opener = window; }
	if (!_B10_boolOldBrowser)  { objWindow.focus();         }
  return objWindow;
}

// B10_spawnWindowAndWrite() -- spawn a child browser window and write the given contents to it
function B10_spawnWindowAndWrite(name, content, width, height, scrollbars) {
	var objWindow = B10_spawnWindowAndReturn(name, '', width, height, scrollbars);
	with (objWindow.document) {
	  open("text/html", "replace");
	  write(content)
	  close();
	}
}

// B10_spawnPrintWindow() -- spawn a child browser window and return a reference to the new window
function B10_spawnPrintWindow(name, content, width, height, scrollbars) {
	var strAttribs = 'toolbar=no,width=' + width + ',height=' + height + ',directories=no,status=no,scrollbars=' + ((scrollbars)?'yes':'no') + ',resizeable=yes,menubar=yes,location=no,screeny=50,screenx=50,alwaysRaised';
  var objWindow = window.open(content, name, strAttribs);
	if (!objWindow.opener) { objWindow.opener = window; }
	if (!_B10_boolOldBrowser)  { objWindow.focus();         }
  
}



/*
 * The following are standard MarcoMedia functions
 */

// Open a new page in the current browser window
function MM_goToURL() { //v2.0
  for (var i=0; i< (MM_goToURL.arguments.length - 1); i+=2) //with arg pairs
    eval(MM_goToURL.arguments[i]+".location='"+MM_goToURL.arguments[i+1]+"'");
  document.MM_returnValue = false;
}

// Open a new window.
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_popupMsg(theMsg) { //v2.0
  alert(theMsg);
}


// ---------------------------------------------------------------------------
// Functions used for nMatrix Wizard...
// ---------------------------------------------------------------------------

function B10_nmatrixwizardBegin(intCategory,strProxyStub) {

  location.href = strProxyStub + "\/user\/matrix_nmatrix.cfm?stage=1&catindex=" + intCategory;
}

function B10_nmatrixwizardNext() {
  document.frmNMatrix.hdnStage.value = parseInt(getURLParameter('stage')) + 1;
  document.frmNMatrix.submit();
}

function B10_nmatrixwizardBack() {

  document.frmNMatrix.hdnStage.value = parseInt(getURLParameter('stage')) - 1;
  document.frmNMatrix.submit();
}

function B10_nmatrixwizardReturn() {
  document.frmNMatrix.submit();
}
// ---------------------------------------------------------------------------
// End of nMatrix Wizard functions...
// ---------------------------------------------------------------------------

// ---------------------------------------------------------------------------
// Functions used for Registration Wizard...
// ---------------------------------------------------------------------------

function B10_registerwizardBegin() {
  location.href = "register.cfm?step=1"
}

function B10_registerwizardNext() {
  document.frmRegister.hdnStep.value = parseInt(getURLParameter('step')) + 1;
  document.frmRegister.submit();
}

function B10_registerwizardBack() {
  document.frmRegister.hdnStep.value = parseInt(getURLParameter('step')) - 1;
  location.href = "register.cfm?step=" + document.frmRegister.hdnStep.value;
}

function B10_registerwizardBackToStart() {
  document.frmRegister.hdnStep.value = 1;
  document.frmRegister.submit();
}

function B10_registerwizardContinue(iLocation) {
  location.replace(iLocation);
}

// ---------------------------------------------------------------------------
// End of Registration Wizard functions...
// ---------------------------------------------------------------------------


// The following function is used to close the wizard window and load the login 
// screen into the main window, when the users session times out.
function B10_wizardLogin() {
  window.opener.location.href = "/audit/login.cfm";
  self.close();
}

function getURLParameter(strParameterName) {

  var intStartIndex, intEndIndex;  //starting and ending of substrings of the location string to examine

  // mark first url parameter
  intStartIndex = location.href.indexOf("?") + 1;
  
  // for all url parameters
  while(intStartIndex != 0) {
  
    // mark between ?/& and = to get name of url parameter
    intEndIndex = location.href.indexOf("=", intStartIndex);
    if(intEndIndex == -1) intEndIndex = location.href.length; 
    
    // compare name with passed parameter
    if(location.href.substring(intStartIndex, intEndIndex) == strParameterName) {

      // mark between = and & to get value of url parameter
      intStartIndex = intEndIndex + 1;
      intEndIndex = location.href.indexOf("&", intStartIndex);
      if(intEndIndex == -1) intEndIndex = location.href.length;
      
      // return value
      return (intStartIndex == intEndIndex) ? null : location.href.substring(intStartIndex,intEndIndex);
    }
    
    // move onto next url parameter
    intStartIndex = location.href.indexOf("&", intEndIndex) + 1;          
  }
    
  // no match so return null
  return null;
}

function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if (imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}

function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
  for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr = 'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null || oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore
}


//Functions used to show/hide the progress bar image

function showinfo(category,records)
{
//hide all others

//info1.style.visibility = "hidden";
//info2.style.visibility = "hidden";
//info3.style.visibility = "hidden";
//info4.style.visibility = "hidden";
//info5.style.visibility = "hidden";
  eval(category).style.visibility = "visible";

}

function hideinfo(category,records)
{
  eval(category).style.visibility = "hidden";

}


function hideinfoall()
{
//info1.style.visibility = "hidden";
//info2.style.visibility = "hidden";
//info3.style.visibility = "hidden";
//info4.style.visibility = "hidden";
//info5.style.visibility = "hidden";

}

function togglecontent(id) {
	//show content  
	if (eval(id).style.display == "block") {
		hidecontent(id); 
	} else {
		showcontent(id);
	}
}

function showcontent(id) {
	//show content  
	eval(id).style.display = "block";
}


function hidecontent(id) {
	eval(id).style.display = "none";
}

<!--//hide from old browsers

var counter = 0;

// call Update function in 1 second after first load
ID=window.setTimeout("Update();",1000);
function Update() {
   counter ++;
//Alert after specified number of seconds (15 minutes = 900 seconds.)
if (counter==900) {
	//updateSession();
	deadline = new Date();
	deadline.setMinutes(deadline.getMinutes() + 15)
	showWarning(deadline.toLocaleString());
	// B10_spawnWindow('Timeout','/user/timeout.html','500','400','true');   
//	window.status='';
//	txtTimer.value="Stopped"
} else {
	//Display time in status window
	   //window.status="Elapsed time = " + counter  + " seconds";
	//Display time in text box
	//txtTimer.value="There has been no activity for " + counter + " seconds";
	// set another timeout for the next count
	   ID=window.setTimeout("Update();",1000);
}
}
//-->

function selectRow(frm,rdo,intRow,rowName) {
	for (i = 0; i <= eval("document.forms." + frm + "." + rdo + ".length - 1"); i++) {
		if (i == intRow) {
			eval(rowName + i + ".style.background='#c0d7e3'");
			eval("document.forms." + frm + "." + rdo + "[intRow].checked = true");
		} else {
			eval(rowName + i + ".style.background=''");
		}
	}
}


  function validateDate() {
    if(( document.frmEAP.selDate.value == 0)||( document.frmEAP.selMonth.value == 0)||( document.frmEAP.selYear.value == 0)) {
      if(( document.frmEAP.selDate.value != 0)||( document.frmEAP.selMonth.value != 0)||( document.frmEAP.selYear.value != 0)) {
        alert("Please choose a valid date.")
      } else {
        document.frmEAP.submit();
      }
    } else {
      document.frmEAP.submit();
    }
  }

 function B10_enterSubmit()
 {
	  temp = event.keyCode;
    if (temp == 13)
		{
			//submit the form.
			document.frmLogin.submit();
		}
 }
 
function B10_toggleTOCnode(strNode) {
		//Don't try to toggle if the child wasn't drawn (not yet live)
	 if (document.all['toc_' + strNode] != undefined)
	 {	 
		if (document.all['toc_' + strNode].style.display == 'none') {
			document.all['toc_' + strNode].style.display      = '';
		} else {
			document.all['toc_' + strNode].style.display      = 'none';
		}
	}
}

function B10_toggleTOCnodeNS(strNode) {
			//alert(strNode);
			//alert(document.frmTest['toc_' + strNode].style.display);
		//Don't try to toggle if the child wasn't drawn (not yet live)
	 if (document.frmTree['toc_' + strNode] != undefined)
	 {	 

		if (document.frmTree['toc_' + strNode].style.display == 'none') {
			document.frmTree['toc_' + strNode].style.display  = 'none';
			document.frmTree['toc_' + strNode].style.display  = '';
			document.frmTree['toc_' + strNode].style.display      = '';
		} else {
			document.frmTree['toc_' + strNode].style.display  = '';
			document.frmTree['toc_' + strNode].style.display  = 'none';
			document.frmTree['toc_' + strNode].style.display      = 'none';
		}
	}
}


/* Validation functions 
Set of functions that can be used to tell if an element is an email, a postcode or a date
*/
function isEmail(objElement) {
    if (objElement.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
        return true;
    else
        return false;
}


function isDate(objElement) {
    var pattern = /\d{2}\/\d{2}\/\d{4}/
    if (pattern.test(objElement.value))
        return true;
    else
        return false;
}


function isPostCode(objElement) {
//Very basic postcode checker - checks for correct number of characters.

    if (objElement.value.length > 5 &&  objElement.value.length < 9 )
        return true;
    else
        return false;
}

/* Group Matrix functions. */

/* Function to move the focus from token box 1 to token box 2 on the /user/groupmatrix_entertoken page. */
function shiftFocus(frm,element1,element2) {
	var ctrl1 = eval("document." + frm + "." + element1);
	var ctrl2 = eval("document." + frm + "." + element2);
	if (ctrl1.value.length == 3) { ctrl2.focus(); }
	//alert(window.event.keyCode);
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
}
   function tryRefresh()
	 {

		 trytime = new Date();
		if(deadline.getTime() <= trytime.getTime()) {
			document.getElementById('timeout').style.display = 'none';
			document.getElementById('refreshfail').style.display = '';
		}
		else
		{
			document.getElementById('timeout').style.display = 'none';
			window.counter = 0;
      window.setTimeout("Update();",1000);}
	}

		function getResult(result) {
		document.getElementById('timeout').style.display = 'none';
		window.counter = 0;
        window.setTimeout("Update();",1000);
		if(result == 'false') {
			document.getElementById('refreshfail').style.display = '';
		}
		

	}

		function showWarning(result) {
				alert("Warning: Your data may be lost!");
				document.getElementById('timeout').style.display = '';
				document.getElementById('timeoutclock').innerHTML = result;
				window.clearTimeout(ID);
		}
		
		function timeNow() {
		 today = new Date();
          return today.getHours() + ':' + today.getMinutes() + ':' + today.getSeconds();
		}