function swapImgRestore() { 
  var i,x,a=document.sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function doubleRestore() { 
  document.images.tab7.src = '/images/tab_log.gif' 
  document.images.tab8.src = '/images/tab_out.gif'
}

function preloadImages() { 
  if(document.images){ 
	if(!document.p) document.p=new Array();
    var i,j=document.p.length,a=preloadImages.arguments;
	for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0) {
	  document.p[j]=new Image; document.p[j++].src=a[i];
	}
  }
}

function findObj(n, d) { 
  var p,i,x;
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
    document=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);
  }
  if(!(x=document[n])&&document.all) x=document.all[n];
  for (i=0;!x&&i<document.forms.length;i++) x=document.forms[i][n];
  for(i=0;!x&&document.layers&&i<document.layers.length;i++) x=findObj(n,document.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); 
  return x;
}

function swapImage() { 
  var i,j=0,x,a=swapImage.arguments;
  document.sr=new Array;
  for(i=0;i<(a.length-2);i+=3)
  if ((x=findObj(a[i]))!=null){
    document.sr[j++]=x;
    if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
  }
}



function detect() {
	// if the main window contains only this page, go to the frameset for index.cfm
	if (parent.location.href == self.location.href) {

        // Split up the url into two chunks labelled 0,1,
        // It splits after filename and before file extension.
        url = self.location.href.split("_");
	    parent.location.href = url[0] + '.html';
	}
}


// Javascript to open references in a new window and position coordinates relative to users screen size -->
function quesWindow(url) {

	leftPos = 0
	if (screen) {
		leftPos = screen.width-670
	}

	questionWindow = window.open(url, 'formWin', 'width=620,height=380,left='+leftPos+',top=135,toolbar=no,status=no,scrollbars=yes,resizable=yes')
	questionWindow.focus()
	}


function refWindow(url) {

	leftPos = 0
	if (screen) {
		leftPos = screen.width-590
	}

	referenceWindow = window.open(url, 'refWin', 'width=550,height=320,left='+leftPos+',top=210,location=no,toolbar=no,status=no,scrollbars=yes,resizable=yes')
	referenceWindow.focus()
	}


function pdfWindow(url) {

	leftPos = 0
	if (screen) {
		leftPos = 20
		xdimension = screen.width-120
		topPos = 20
		ydimension = screen.height-120
	}

	MakePDFWindow = window.open(url, 'pdfWin', 'width='+xdimension+',height='+ydimension+'left='+leftPos+',top='+topPos+'toolbar=no,status=no,scrollbars=yes,resizable=yes')
	MakePDFWindow.focus()
	}


// a function used in another function
function IsEmpty(MyField)
{
  var ch;

  for (var i = 0; i <= MyField.length - 1; i++)
  {
    ch = MyField.charAt(i);
    if ((ch != ' ') && (ch != '/n') && (ch != '/t'))
    {
      return false;
    }
  }
  return true;
}


// validation needed on some forms copied from those in the https secure area.
// This is what we submitted: onsubmit="return validate('orglist,fullname,role,email',document.contact);"

function validate(AFields, form)
{
  var MyFields = AFields.split(','), 
  	  MyValue, 
	  i;

  for (i = 0; i < MyFields.length - 1; i++)
  {
    MyValue = form.elements[MyFields[i]].value;
    if ((MyValue == null) || (MyValue == "") || (IsEmpty(MyValue)))
    {
      alert('You must complete all required fields.');
      form.elements[MyFields[i]].focus();
      return false;
    }
    //alert (MyValue);
  }
  //alert('true');
  return true;
}