//the preload function loads the supplied images into memory
//for the top menu javascript rollover logic 
preload("mainspacerImage","/stvnet/controls/images/spacer.gif")
preload("mainlocations","/stvnet/controls/images/menu_22.gif")
preload("mainservices","/stvnet/controls/images/menu_23.gif")
preload("mainfpnv","/stvnet/controls/images/menu_24.gif") 
preload("mainphysician","/stvnet/controls/images/menu_25.gif")
preload("mainhealthinfo","/stvnet/controls/images/menu_healthinfo.gif")

preload("overspacerImage","/stvnet/controls/images/spacer.gif")
preload("overlocations","/stvnet/controls/images/menu_22_over.gif")
preload("overservices","/stvnet/controls/images/menu_23_over.gif")
preload("overfpnv","/stvnet/controls/images/menu_24_over.gif")
preload("overphysician","/stvnet/controls/images/menu_25_over.gif")
preload("overhealthinfo","/stvnet/controls/images/menu_HealthInfo_over.gif")

preload("onspacerImage","/stvnet/controls/images/spacer.gif")
preload("onlocations","/stvnet/controls/images/menu_22_on.gif")		// _on
preload("onservices","/stvnet/controls/images/menu_23_on.gif")			// _on
preload("onfpnv","/stvnet/controls/images/menu_24_on.gif")				// _on
preload("onphysician","/stvnet/controls/images/menu_25_on.gif")		// _on
preload("onhealthinfo","/stvnet/controls/images/menu_HealthInfo_on.gif")		// _on

preload("textPopupnone","/stvnet/controls/images/menu_19.gif")
preload("textPopuplocations","/stvnet/controls/images/menu_19_1.gif")
preload("textPopupservices","/stvnet/controls/images/menu_19_2.gif")
preload("textPopupfpnv","/stvnet/controls/images/menu_19_3.gif")
preload("textPopupphysician","/stvnet/controls/images/menu_19_4.gif")
preload("textPopuphealthinfo","/stvnet/controls/images/menu_19_5.gif")

//This array is used by the top menu 
//javascript rollover logic
menuTopImagesArray = new Array()
menuTopImagesArray[0] = "locations"
menuTopImagesArray[1] = "services"
menuTopImagesArray[2] = "fpnv"
menuTopImagesArray[3] = "physician"
menuTopImagesArray[4] = "healthinfo"







//Parse the URL of the web page we are on to create the baseHREF variable 
//and capture the contents beyond stvincent.org to a variable 
var thisHREF	= location.href.split("//")
var sStart		= thisHREF[1].search(/.org/) + 4

if (sStart < 4) //The URL indicates we are in WBC Authoring mode or using CMS host header redirect. 
				//Parse URL and add "www.stvincent.org".
{
	var thisURL		= "";
	var sStart		= thisHREF[1].search("/")
	var baseHREF	= thisHREF[0] + "//" + thisHREF[1].substr(0,sStart) + "/www.stvincent.org";
} 
else			//Parse the URL and create variables
{
	var sEnd		= thisHREF[1].length
	var thisURL		= thisHREF[1].substr(sStart,sEnd)
	var baseHREF 	= thisHREF[0] + "//" + thisHREF[1].substr(0,sStart)
}

if(baseHREF.length > 44)	//Account for www.stvincent.org not being listed in URL (for stage website).
							//Can happen when a form switches the postings URL to its address.
{
	sStartNew	= thisHREF[1].search("/")
	baseHREF	= thisHREF[0] + "//" + thisHREF[1].substr(0,sStartNew) + "/www.stvincent.org";
}

//Remove everything after the first / in thisURL
var sStart2		= thisURL.search(/\//) + 1
var sEnd2		= thisURL.length
thisURL			= thisURL.substr(sStart2,sEnd2)
var findDoc1 	= thisURL.substr(9,23) 
var findDoc2	= findDoc1.split("/")

//Par down thisURL to nothing but the 
//2nd level folder name
var sEnd3		= thisURL.search(/\//)
thisURL			= thisURL.substring(0,sEnd3)







//Use thisURL and findDoc2[0] to populate the imgStay and imgStaySRC variables  
//that indicate which menu art should be highlighted (if any)
var imgStay
var imgStaySRC
var a
switch(thisURL) {
	case "ourlocations":
		imgStay 	= 'locations';
		imgStaySRC 	= 'onlocations';
		break;
	case "ourservices":
		imgStay 	= 'services';
		imgStaySRC 	= 'onservices';
		break;
	case "for":
		imgStay 	= 'fpnv';				//for patients & visitors
		imgStaySRC 	= 'onfpnv';
		break;

	default:
		imgStay 	= 'spacerImage';
		imgStaySRC 	= 'onspacerImage';
		break;
}
switch(findDoc2[0]) { 
	case "findaphysician":
		imgStay 	= 'physician';
		imgStaySRC 	= 'onphysician';
		break;	
	case "":
	//	imgStay 	= 'physician';
	//	imgStaySRC 	= 'onphysician';
		break;	
}
a = location.href.search("HealthInformation")
if (a > 0)
{
		imgStay 	= 'healthinfo';				//for patients & visitors
		imgStaySRC 	= 'onhealthinfo';
}





// Using the baseHREF var, determine if the website being viewed 
// is a production or edit website and add functionality as needed. 
switch(baseHREF.toLowerCase()) {
	case "http://www.stvincent.org": 
				window.onresize = function (e) {location.reload();};
				break;
	case "http://cms/www.stvincent.org":
				break;
	case "http://cms-edit/www.stvincent.org":
				break;
	case "http://localhost/www.stvincent.org":
				break;
	default: 
				window.onresize = function (e) {location.reload();};
				break;
}







// DreamWeaver rollover functions 
// Added to support Womens service line rollover art (/ourservices/womens)

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_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_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.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];}
}
