//collection of general utility functions  --  utilities.js
// adapted from other sites 4/4/2002

var childWindow = null;
function showWebsite(fn,wn,w,h) {
	if(navigator.appName=='Netscape') properties='directories=yes,screenX=0,screenY=0';
	else if(navigator.appName=='Microsoft Internet Explorer') properties='channelmode=no,top=0,left=0';
	properties+=',resizable=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes';
	properties+=',width=' + w + ',height=' + h;
	windowframe = "/outside.asp?site="+fn+"&back="+document.href+"&new=true"
	childWindow = window.open(windowframe,wn, properties);
	childWindow.focus();
}
function printID(form, research) {
	if(navigator.appName=='Netscape') properties='directories=yes,screenX=0,screenY=0';
	else if(navigator.appName=='Microsoft Internet Explorer') properties='channelmode=no,top=0,left=0';
	properties+=',resizable=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes';
	properties+=',width=' + 300 + ',height=' + 200;
	if(research) fn = "lms/printrsid.asp";
	else fn = "lms/printid.asp";
	windowframe = fn+"?l="+form.login.value+"&p="+form.pass.value+"&q="+form.ques.value+"&a="+form.ans.value
	childWindow = window.open(windowframe,"wn", properties);
	childWindow.focus();
}
function showPopup(fn,wn,w,h) {
	if(navigator.appName=='Netscape') properties='directories=no,screenX=0,screenY=0';
	else if(navigator.appName=='Microsoft Internet Explorer') properties='channelmode=no,top=0,left=0';
	properties+=',resizable=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no';
	properties+=',width=' + w + ',height=' + h;
	childWindow = window.open(fn,wn, properties);
	onunload = autoClosePopup;
	childWindow.focus();
}
function showPopupPositioned(fn,wn,w,h,x,y) {
	if(navigator.appName=='Netscape') properties='directories=no,screenX='+x+',screenY='+y;
	else if(navigator.appName=='Microsoft Internet Explorer') properties='channelmode=no,top='+x+',left='+y;
	properties+=',resizable=no,location=no,menubar=no,scrollbars=yes,status=no,toolbar=no';
	properties+=',width=' + w + ',height=' + h;
	childWindow = window.open(fn,wn, properties);
	onunload = autoClosePopup;
	childWindow.focus();
}

/*
function showPDF(file) {//OBSELETE for 508 reasons - just do an href instead
	document.location='/pdfpop.asp?file='+file;
}
*/
function autoClosePopup() {
	if (childWindow != null) childWindow.close();
}
//begin branding functions
function setVariables(width, height) {
	imgwidth = width;
	imgheight = height;
	if (document.layers) {
		horz=".left";
		vert=".top";
		docStyle="document.";
		styleDoc="";
		innerW="window.innerWidth";
		innerH="window.innerHeight";
		offsetX="window.pageXOffset";
		offsetY="window.pageYOffset";
	} else {
		horz=".pixelLeft";
		vert=".pixelTop";
		docStyle="";
		styleDoc=".style";
		innerW="document.body.clientWidth";
		innerH="document.body.clientHeight";
		offsetX="document.body.scrollLeft";
		offsetY="document.body.scrollTop";
   }
}
function checkLocation() {
	objectXY="branding";
	var availableX=eval(innerW);
	var availableY=eval(innerH);
	var currentX=eval(offsetX);
	var currentY=eval(offsetY);
	x=availableX-(imgwidth+30)+currentX;
	y=availableY-(imgheight+20)+currentY;
	evalMove();
	setTimeout("checkLocation()",5);
}
function evalMove() {
	eval(docStyle + objectXY + styleDoc + horz + "=" + x);
	//eval(docStyle + objectXY + styleDoc + horz + "=10");
	eval(docStyle + objectXY + styleDoc + vert + "=" + y);
}
//end branding functions

// HealthSoft renames of Dreamweaver functions
function reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {
    if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
      document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage;
    }
  }
  else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);
function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function swapImgRestore() { //v3.0
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function swapImage() { //v3.0
  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];}
}
// end Dreamweaver functions
// Healthsoft variants
function HS_imageSwap(daImage, daSrc){
  if ((x=findObj(daImage)) !=null) x.src = daSrc;
}
// Healthsoft General purpose functions
function notNull(str) {
	if(str){
		var tmpStr = new String(str)
		if (tmpStr == "" || tmpStr == " " || tmpStr == null || tmpStr == "null" || tmpStr == "undefined") return false;
		else return true;
	}else return false;
}
function trim(str) {
	var tmpStr = new String(str);
	return tmpStr.replace(/(^\s*)|(\s*$)/g, "");
}

// Dreamweaver functions
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
// end Dreamweaver functions
