//upsize the search textbox for IE4+ and NN5+
function fixtxt(specialCase){
	var d = document;
	var NN4 = (d.layer&& !d.getElementById) ? true:false;
	var IE4 = (d.all) ? true:false;
	var NN5 = (d.getElementById) ? true:false;
	if (NN4){
	  	//do nothing, as browser unable to resize a textbox
	  } else if(IE4 || NN5){
	  	document.seek1.qt.size = (specialCase) ? specialCase:15;
	  } else {
	  	//do nothing, as browser capabilities unknown
	  }
} //end function: fixtxt

///////////BEGIN: SUBNAV IN COLLAGE JS
//the premise is that the sub" pages will be able to
//identify which "parent" button to highlight and where
//to rewrite their collage-generated DHTML sub-nav by referencing
//the containing folder name of the on-screen html document.
//This must always match the 'active' navbar image name
//and the DIV ID where we will rewrite the subnav
//01/20/2003 T.S.

//main function - called onLoad by all subnav masterpages
function fixnav()  {
	var strTopNavName = findparentname();
	
	imgSrc(strTopNavName);
	MoveSubNavTo(strTopNavName);
} //end function: fixnav

//dissect the page URL, and return the final folder name
function findparentname()  {
	var foldername = " " + window.location + " ";
	var slash2 = 0;
	var slash1 = 0;
	for (i=0;i<foldername.length-1;i++) {
		if (foldername.substring(i,i+1) == "/" || foldername.substring(i,i+1) == "\\") {
			slash1 = slash2;
			slash2 = i;
		}
	}

	//alert("*"+ foldername.substring(slash1+1,slash2) + "*");
	//FOR DEBUGGING THIS FUNCTION, JUST UNCOMMENT THE LINE ABOVE

	return foldername.substring(slash1+1,slash2);
} //end function: findparentname

//change "_no_" portion to "_hi_"
function replaceImgLabel(src) {
        
	var intReplaceStringStart = src.indexOf("_no_");
	return src.substring(0,intReplaceStringStart) + "_hi_" + src.substring(intReplaceStringStart+4,src.length);
} //end function: replaceImgLabel

function getSubNavId(src) {
// 4/22/05 - Makk - THIS IS A HACK!! for a quick fix to this JavaScript, implemented for Collage v4.6 
// The navigation JavaScript contained here is dependent on what Merant spits out in terms of autogenerated image files, 
// any subtle code changes they make will directly impact our navigation, we need to rewrite the navigation 
// JavaScript to be independent of Merant's codebase or find another method.

//pull the end of the file asset ID for the main file for that group

  var getFileEnd = src.substring(src.lastIndexOf("_")+1,src.length-4);  
  
  //alert(getFileEnd);

  //Need to replace the auto folder section 
  var autoFolderStart = src.lastIndexOf("/");  
  var autoFolderEnd = src.indexOf("auto_");
  var autoFolder = src.substring(autoFolderEnd,autoFolderStart);
  var autoAssetID = src.substring(autoFolderEnd+5,autoFolderStart);

  var newautoFolder = "auto_" + getFileEnd;
  src = src.replace(autoFolder,newautoFolder);
  return src;
  //alert(src);
}


//decrement the 4 digit assetID portion by 1. This
//assumes that the "highlighted" (undecorated) gif button
//was created in Collage immediately before its lighter companion
function replaceImgAssetID(src)  {
	var dash2 = 0;
	var dash1 = 0;
	for (i=0;i<src.length-1;i++) {
		if (src.substring(i,i+1) == "_") {
			dash1 = dash2;
			dash2 = i;
		}
	}
	src = src.substring(0,dash1+1) + (src.substring(dash1+1,dash2)-1) + src.substring(dash2,src.length);
	return src;
} //end function: replaceImgAssetID

//Highlight the rollover image
function imgSrc(img_Name) {
    if (document.images)
    {
	

        var Img = replaceImgLabel(document[img_Name].src);
        Img = replaceImgAssetID(Img);
        Img = getSubNavId(Img);
        //Img = Img.replace(img_Name,"");
        //alert("The image name is : " + Img);
        document[img_Name].src = Img;
    }
} //end function: imgSrc

//Reproduce the subnav code where it 'belongs'
function MoveSubNavTo(div_Name) {
	var appVer = navigator.appVersion;
	appVer = appVer.toLowerCase();
	if (appVer.indexOf("macintosh") != -1) {
		//macintosh ?x  DO NOTHING AS SUBNAV GYNASTICS UNPREDICTABLE...
	}
	else if (!document.all&& document.getElementById) {
		//nn6 plus ie5 and above...
		div1=document.getElementById(div_Name);
		div2=document.getElementById("subnav");
		//'active' section found(reproduce the subnav html code below it)
		div1.innerHTML = div1.innerHTML + div2.innerHTML;
		//hide the original subnav code
		div2.innerHTML = "";
	}
	else if (document.all) {
		//ie4
		for (i=0;i<document.all.length;i++) {
			if (document.all[i].tagName=="DIV"&& document.all[i].id==div_Name) {
				//'active' section found(reproduce the subnav html code below it)
				document.all[i].insertAdjacentHTML('beforeEnd',subnav.innerHTML);
				//hide the original subnav code
				subnav.innerHTML = "";
				break;
			}
		}
	}
} //end function: MoveSubNavTo

//////END: SUBNAV IN COLLAGE JS//////

//added to launch slide shows from collage 5/26/04 Makk/Anne
function launch_slides(goturl, wide, tall)
{
winattributes="'scrollbars=yes,resizable=yes," + "width=" + wide + "," + "height=" + tall + "'";
window.open(goturl,'slide',winattributes);
}

///added to create a print version of content within a div ///

function get_layernostyle(layername){
   if(document.getElementById) 
   {
   //alert("you are using IE 5.5 or higher");
      layerBrowser = "document.getElementById('";
	  styleBrowser = "";
      endlayerBrowser = "')";

   }
   else if(document.all)
   {
   //alert("you are using IE 5.0");
      layerBrowser = "document.all['";
	  styleBrowser = "";
      endlayerBrowser = "']";
   }
   else{
   alert("Sorry your browser is not fully supported by the Intranet, you will be able to use the Intranet, but may not see all the standard features");
   }
   layerID = layerBrowser + layername + endlayerBrowser + styleBrowser;
   return layerID;
}

function printpage() {
layeris=get_layernostyle('content') + ".innerHTML";
//alert(layeris);
var layersend=eval(layeris);
var winprint=window.open("","",'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=600,height=600');
winprint.document.open();
winprint.document.write('<html><head><title>Fletcher Allen Health Care</title>');
winprint.document.write('<link href=/css/alldocs2.css rel=stylesheet>');
winprint.document.write('<link href=/css/print.css rel=stylesheet>');
winprint.document.write('<script language=JavaScript src=/js/mp4_6.js></script>');
winprint.document.write('</head><body><span class=fahcContent>');
winprint.document.write(layersend);
winprint.document.write('</span></body></html>');
winprint.document.close();
winprint.focus();
}

//////////Dreamweaver code to open new window for Flash animations, used in Electrophysiology //
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


/////////Code from intranet for browser-style drop-down menus for GME, using depts

function gothere(gowhere)
{  
 
 if(gowhere=="ql")  {
   document.location.href=document.quicklinks.where.value;}
 
  else if (gowhere=="dest") {
  document.location.href=document.dest.where.value;
  }

  else if (gowhere=="depts") {
  document.location.href=document.depts.where.value;
  }

  else if (gowhere=="apps") {
  document.location.href=document.applist.where.value;
  }
  
}
