// JScript source code
var popUpLayerShown = null;

var globalVariable;

var bodyClickedDirectly = true;

document.documentElement.onclick = function()
{
	if(!bodyClickedDirectly)
		bodyClickedDirectly = true;
	else
	{
		//hide all pop up layers
		HidePopUpLayer();
		
		/* Page specific onclick methods, can be overidden on specific pages */
		BodyClicked();
	}
}

function BodyOnLoad()
{
	LinkCSSFiles();
	
	/* Page specific onload methods, can be overidden on specific pages */
	PageOnLoad();
}

function encodeMyHtml(encodedHtml) {
     /*encodedHtml = escape(encodeHtml.htmlToEncode.value);
     encodedHtml = encodedHtml.replace(/\//g,"%2F");
     encodedHtml = encodedHtml.replace(/\?/g,"%3F");
     encodedHtml = encodedHtml.replace(/=/g,"%3D");
     encodedHtml = encodedHtml.replace(/&/g,"%26");
     encodedHtml = encodedHtml.replace(/@/g,"%40");*/
     //encodedHtml = encodedHtml.replace(/\`/g,"%60");
     return encodedHtml;
   }
 
function PageOnLoad()
{
	var s;
	s=document.URL;

	
}

function BodyClicked()
{

}


function LinkCSSFiles()
{
	/*if(browserSniffer(2, 0))
	{	//if Mozilla
		document.getElementById('browserSpecific').href = document.getElementById('browserSpecific').href.replace('browserSpecific', 'ie');
	}
	else */if(browserSniffer(3, 0))
	{	//if safari
		if(document.getElementById('browserSpecific')!= null)
			document.getElementById('browserSpecific').href = document.getElementById('browserSpecific').href.replace('browserSpecific', 'global_safari');
	}
	else if(browserSniffer(1, 6))
	{
		if(document.getElementById('browserSpecific')!= null)
			document.getElementById('browserSpecific').href = document.getElementById('browserSpecific').href.replace('browserSpecific', 'global_IE6');
	}
}

function ShowPrintPage()
{
	//document.getElementById('print').media = "all";
	var objWindow = launchCenter( "/docs/print.html", "Print", 700, 900, "yes", "yes");
	//document.getElementById('print').media = "print";
	//alert();
	//alert(objWindow.document.body.onload);
}

function launchCenter(url, name, height, width, scroll, resize) 
{ 
	var str = "height=" + height + ",innerHeight=" + height; 
	str += ",width=" + width + ",innerWidth=" + width; 
	if (window.screen) 
	{ 
	var ah = screen.availHeight - 30; 
	var aw = screen.availWidth - 10; 
	var xc = (aw - width) / 2; 
	var yc = (ah - height) / 2; 
	str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc;
	}
	str = str + ",scrollbars=" + scroll;
	str = str + ",resizable=" + resize;
	str = str + ",titlebar=yes";
	str = str + ",menubar=yes";
	return window.open(url, name, str); 
	
}

function PopUpClicked()
{
	bodyClickedDirectly = false;
}

function IsBrowser(browserName, version)
{
	alert(navigator.appName);
	alert(navigator.appVersion);
}

function IsLayerShown(obj)
{
	if(obj!=null)
	{
		if(obj.style.visibility=="visible")
			return true;
	}
	return false;
}


var scrollTop, scrollLeft, bodyHeight, bodyWidth, cursorX, cursorY, layerHeight, layerWidth;

function SetAllDimensionData(objEvent, objLayer)
{

	layerHeight = objLayer.clientHeight;
	layerWidth = objLayer.clientWidth;

	scrollTop = document.documentElement.scrollTop;
	if(scrollTop==0)
		scrollTop = document.body.scrollTop;
		
	scrollLeft = document.documentElement.scrollLeft;
	if(scrollLeft==0)
		scrollLeft = document.body.scrollLeft;
	
	bodyHeight, bodyWidth;
	if(self.innerHeight)
	{	//for safari n mozilla
		bodyHeight = self.innerHeight;
		bodyWidth = self.innerWidth;
	}
	else
	{	//for IE 6+
		bodyHeight = document.documentElement.clientHeight;
		if(bodyHeight==0)	//for IE 5.5 -
			bodyHeight = document.body.clientHeight;
			
		bodyWidth = document.documentElement.clientWidth;
		if(bodyWidth==0)
			bodyWidth = document.body.clientWidth;
	}
		
	cursorX = objEvent.clientX;
	cursorY = objEvent.clientY;
	
	if(browserSniffer(3, 0))
	{	//if safari
		cursorX = cursorX - scrollLeft;
		cursorY = cursorY - scrollTop;
	}
}

var lastDoctorIdShown = 0;
// Added by Elma for Doctor details Popup
function ShowPopUpDoctorDetails(currentDoctorDivId, objEvent)
{

	if(IsLayerShown(popUpLayerShown)&&lastDoctorIdShown==currentDoctorDivId)
		return;//if same doctor is shown already, return
	else//else hide the other doctor
		HidePopUpLayer(popUpLayerShown);

	lastDoctorIdShown = currentDoctorDivId;
		
    var layerId = "popUpDoctor"	
    
	var descriptionDiv = document.getElementById("popupDoctorDescription")	
	descriptionDiv.innerHTML = document.getElementById(currentDoctorDivId).innerHTML	
	//descriptionDiv.style.display="";
	
	//the following lines are required to hide/show the healthInfo and education section
	var objUL = GetChildObject(descriptionDiv, "UL", "className", "address");
	var objLi = GetChildObject(objUL, "LI");
	
	// only for the doctor details popup
	GetChildObject(objUL, "LI", "id", "liHealthInfoBullet_" + currentDoctorDivId).style.display="";
	GetChildObject(objUL, "LI", "id", "liHealthInfo_" + currentDoctorDivId).style.display="";
	GetChildObject(objUL, "LI", "id", "liLinkToDetail_" + currentDoctorDivId).style.display="";
	
	GetChildObject(objLi, "A", "id", "aNameLinkPopup_" + currentDoctorDivId).style.display="";
	GetChildObject(objLi, "A", "id", "aNameLink_" + currentDoctorDivId).style.display="none";
	
	ShowPopUpLayer(layerId, objEvent)	
}

//Added By Elma for MoreInformation popup layer

function ShowMoreInfoPopUpLayer(sDescription,objEvent)

{

    var descriptionDiv = document.getElementById("divMoreInfoPopupDescription")     

      descriptionDiv.innerHTML ="<p>" + sDescription + "</p>"

      

      ShowPopUpLayer("moreInfoPopup", objEvent)

}


function ShowPopUpLayer(layerId, objEvent)
{
	var objLayer = document.getElementById(layerId);
	
	//hide previous layer if it is not same and it is shown
	if(IsLayerShown(popUpLayerShown)&&popUpLayerShown!=objLayer)
	{
		HidePopUpLayer(popUpLayerShown);
	}
	
	if(!IsLayerShown(popUpLayerShown)||objEvent.type=="click")
	{//else only if layer is not shown continue
		popUpLayerShown = objLayer;		
		
		var objArrow = GetChildObject(objLayer, "IMG", "className", "directionArrow");
		
		SetAllDimensionData(objEvent, objLayer);
		
		//alert("Layer Height: " + layerHeight + " Layer Width: " + layerWidth);
		//alert("Scroll Top: " + scrollTop + " Scroll Left: " + scrollLeft);
		//alert("Body Height: " + bodyHeight + " Body Width: " + bodyWidth);
		//alert("Cursor Y: " + cursorY + " Cursor X: " + cursorX);
		
		//alert(cursorY);
		//alert(objLayer.clientHeight);
		//show the layer
		objLayer.style.visibility = "visible";
		
		//set the top position of the pop up
		if(cursorY<layerHeight/2)
		{	//space on top is less, show starting from browser top
			objLayer.style.top = scrollTop + 5 + "px";
			objArrow.style.marginTop = cursorY + "px";
		}
		else if((bodyHeight-cursorY)<layerHeight/2)
		{	//space on bottom is less, show ending from browser bottom
			objLayer.style.top = scrollTop + bodyHeight - layerHeight - 5 + "px";
			if(cursorY - (bodyHeight - layerHeight)>layerHeight - 40)
				objArrow.style.marginTop = cursorY - (bodyHeight - layerHeight) - 36 + "px";
			else
				objArrow.style.marginTop = cursorY - (bodyHeight - layerHeight) + "px";
		}
		else
		{	//enough place on both top n bottom, place layer in center
			objLayer.style.top = scrollTop + cursorY - layerHeight/2 + "px";
			objArrow.style.marginTop = (layerHeight-31)/2 + "px";
		}
		
		//set the top position of the pop up
		if(cursorX>bodyWidth/2)
		{	//open box on left
			objLayer.style.left = cursorX + scrollLeft - layerWidth - 20 + "px";		
			objArrow.src = "/css/images/popUpDirectionRight.gif";
			objArrow.style.marginLeft = layerWidth - 5 + "px";
		}
		else
		{	//open box on right
			objLayer.style.left = cursorX + scrollLeft + 20 + "px";
			objArrow.src = "/css/images/popUpDirectionLeft.gif";
			objArrow.style.marginLeft = "-16px";
		}
		
		//Code to fix IE bug by putting IFrame on top of layer so that select box appear behind
		if(browserSniffer( 1, 6.0)||browserSniffer( 1, 5.5))
		{	//if IE 5.5 or 6.0
			var objIframe = document.getElementById('ieFrameContent');
			var objIframeRight = document.getElementById('rightShawdow');
			var objIframeBottom = document.getElementById('bottomShawdow');
			if(objIframe!=null&&objIframeRight!=null&&objIframeBottom!=null)
			{
				objIframe.style.top = objLayer.style.top;
				objIframe.style.left = objLayer.style.left;
				objIframe.style.width = objLayer.clientWidth - 4;
				objIframe.style.height = objLayer.clientHeight - 4;
				
				objIframeRight.style.top = parseInt(objLayer.style.top.replace("px", "")) + 5;
				objIframeRight.style.left = parseInt(objLayer.style.left.replace("px", "")) + objLayer.clientWidth - 4;
				objIframeRight.style.width = 4;
				objIframeRight.style.height = objLayer.clientHeight - 5;
							
				objIframeBottom.style.top = parseInt(objLayer.style.top.replace("px", "")) + objLayer.clientHeight - 4;
				objIframeBottom.style.left = parseInt(objLayer.style.left.replace("px", "")) + 4;
				objIframeBottom.style.width = objLayer.clientWidth - 8;
				objIframeBottom.style.height = 4;
				
				objIframe.style.visibility = objIframeRight.style.visibility  = objIframeBottom.style.visibility = "visible";
			}
		}
		
		//code to set the position of close button
		var objTopClose = GetChildObject(objLayer, "DIV", "className", "closeTop");
		if(objTopClose!=null)
		{
			objTopClose.style.left = layerWidth - 62 + "px";
			objTopClose.style.textDecoration = 'none';
		}
		
		var objBottomClose = GetChildObject(objLayer, "DIV", "className", "closeBottom");
		if(objBottomClose!=null)
		{
			objBottomClose.style.left = layerWidth - 62 + "px";
			objBottomClose.style.top = layerHeight - 33 + "px";
			objBottomClose.style.textDecoration = 'none';
		}
		objLayer.focus();	
	}
}

function HidePopUpLayer()
{
	if(popUpLayerShown!=null)
	{
		popUpLayerShown.style.visibility = "hidden";
		popUpLayerShown.style.top = "0px";
		popUpLayerShown.style.left = "0px";
		
		if(browserSniffer( 1, 6.0)||browserSniffer( 1, 5.5))
		{	//if IE 5.5 or 6.0
			var objIframe = document.getElementById('ieFrameContent');
			var objIframeRight = document.getElementById('rightShawdow');
			var objIframeBottom = document.getElementById('bottomShawdow');
			if(objIframe!=null&&objIframeRight!=null&&objIframeBottom!=null)
			{
				objIframe.style.visibility = objIframeRight.style.visibility  = objIframeBottom.style.visibility = "hidden";
				objIframe.style.top = objIframeRight.style.top = objIframeBottom.style.top = 0;
				objIframe.style.left = objIframeRight.style.left = objIframeBottom.style.left = 0;
			}
		}
	}
}

/*
Browser Sniffer Script-
*/

function browserSniffer(browserCode, browserVersion) 
{
	var agt1 = navigator.userAgent.toLowerCase();
	var agt2 = navigator.appVersion.toLowerCase();
	if(browserCode==1)
	{	//check for IE
		if(browserVersion == 0)
		{
			if(agt2.indexOf("msie")!=-1)
				return true;
		}
		else
		{
			if(agt2.indexOf("msie " + browserVersion)!=-1)
				return true;
		}
	}
	else if(browserCode==2)
	{	//check for mozilla
		if(agt1.indexOf("firefox")!=-1)
			return true;
	}
	else if(browserCode==3)
	{	//check for safari
		if(agt2.indexOf("safari")!=-1)
			return true;
	}
	return false;    
}

function UnderLine(obj)
{
	obj.style.textDecoration = 'underline';
	if(browserSniffer(1, 5.5))
		obj.style.cursor = 'hand';
	else
		obj.style.cursor = 'pointer';
	
	obj.onmouseout = function()
	{
		RemoveUnderLine(obj);
	}
}

function RemoveUnderLine(obj)
{
	obj.style.textDecoration = 'none';
	obj.style.cursor = '';
}

function GetChildObject(obj, tagName, attribute, value)
{
	var i;
	
	for(i=0; i<obj.childNodes.length; i++)
	{
		
		if(obj.childNodes[i].nodeName == tagName)
		{
			if(attribute!=null && attribute!="")
			{
				if(obj.childNodes[i][attribute].indexOf(value)!=-1)
					return obj.childNodes[i];
			}
			else
			{
				return obj.childNodes[i];
			}
		}
	}
	return null;
}

function GetAllRecursiveChildObjects(obj, tagName, attribute, value, childObjects)
{
	var i;
	
	for(i=0; i<obj.childNodes.length; i++)
	{
		//alert(i + " : " + obj.nodeName + " : " + obj.childNodes[i].nodeName);
		if(obj.childNodes[i].nodeName == tagName)
		{
			if(attribute!=null && attribute!="")
			{
				if(obj.childNodes[i][attribute].indexOf(value)!=-1)
				{
					childObjects[childObjects.length] = obj.childNodes[i];
					return childObjects;
				}
			}
			else
			{
				childObjects[childObjects.length] = obj.childNodes[i];
				return childObjects;
			}
		}
		
		GetAllRecursiveChildObjects(obj.childNodes[i], tagName, attribute, value, childObjects);
	}
	return childObjects;
}

function GetParentObject(obj, tagName, attribute, value)
{
	var i;
	
	while(obj.parentNode.nodeName!="BODY"&&obj.parentNode.nodeName!="HTML")
	{
		if(obj.parentNode.nodeName == tagName)
		{
			if(attribute!=null && attribute!="")
			{
				if(obj.parentNode[attribute].indexOf(value)!=-1)
					return obj.parentNode;
			}
			else
			{
				return obj.parentNode;
			}
		}
		
		obj = obj.parentNode;
	}
	
	return null;
}


var containerLeft;
var containerTop;
function GetObjectPosition(obj)
{
	var objLeft = 0;
	var objTop = 0;	
	var objParent = obj;
	while( objParent.tagName.toUpperCase() != "BODY" && objParent.tagName.toUpperCase() != "HTML" )
	{
		objLeft += objParent.offsetLeft;
		objTop += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	
	containerLeft = objLeft;
	containerTop = objTop;
}

//Maintain Physician Java Script

var editMode = false;
var elipsisMaxWidth = 443;
//method to populate the fields in address pop up
function PopulateAddressPopUp(obj)
{
	editMode = true;
	var objLi = GetParentObject(obj, "LI", null, null);
	
	globalVariable = objLi;
	
	var objAddress = GetChildObject(objLi, "DIV", "className", "dataStorage");
	var objStrretAddress1 = GetChildObject(objAddress, "SPAN", "className", "streetAddress1");
	var objStrretAddress2 = GetChildObject(objAddress, "SPAN", "className", "streetAddress2");
	var objStrretAddress3 = GetChildObject(objAddress, "SPAN", "className", "streetAddress3");
	var city = GetChildObject(objAddress, "SPAN", "className", "city");
	var state = GetChildObject(objAddress, "SPAN", "className", "state");
	var zip = GetChildObject(objAddress, "SPAN", "className", "zip");
	var phone = GetChildObject(objAddress, "SPAN", "className", "phone");
	var centerDepartment = GetChildObject(objAddress, "SPAN", "className", "centerDepartment");
	var groupPractice = GetChildObject(objAddress, "SPAN", "className", "groupPractice");
	var hAccessible = GetChildObject(objAddress, "SPAN", "className", "handicapAccessible");
	
	// Added new dropdown boxes to the layer so need to populate defaults - Elma July 21 2008
	var arrCenterDepartment;
	var centerDepartmentFullList = getElementByPD_Id("centerDepartment");
	
	if(centerDepartment != null)
	{
	    arrCenterDepartment = centerDepartment.innerHTML.split("||");	
	    // set the default value	    
	    if(arrCenterDepartment[0] != "")
	        document.getElementById('selCenter').value = arrCenterDepartment[0];	    	    
	}	
	    
	var arrGroupPractice;
	var groupPracticeFullList = getElementByPD_Id("groupPractice")
	
	if(groupPractice != null)
	{
	    arrGroupPractice= groupPractice.innerHTML.split("||");
	    // populate the Group Practice Dropdown box & set the default value	
	    if(arrGroupPractice[0] !="")
	        document.getElementById('selGroupPractice').value = arrGroupPractice[0];
	    //copyDropdownValues(groupPracticeFullList,document.getElementById('selGroupPractice'),arrGroupPractice[0])
	}	
	
	//populate addresses
	document.getElementById('txtStreetAdd1').value = objStrretAddress1.innerHTML;
	document.getElementById('txtStreetAdd2').value = objStrretAddress2.innerHTML;
	document.getElementById('txtStreetAdd3').value = objStrretAddress3.innerHTML;
	document.getElementById('txtCity').value = city.innerHTML;
	document.getElementById('txtState').value = state.innerHTML;
	document.getElementById('txtZip').value = zip.innerHTML;
	document.getElementById('txtPhone').value = phone.innerHTML;
	
	if(hAccessible.innerHTML=="Yes" || hAccessible.innerHTML=="Y")
		document.getElementById('accessible').checked = true;
	else
		document.getElementById('notAccessible').checked = true;
	
	//document.getElementById('txtCity').value = hAccessible.innerHTML;
}

//method to clear the fields in address pop up
function ClearAddressPopUp()
{
	editMode = false;
	//make fields as blank
	document.getElementById('txtStreetAdd1').value = "";
	document.getElementById('txtStreetAdd2').value = "";
	document.getElementById('txtStreetAdd3').value = "";
	document.getElementById('txtCity').value = "";
	document.getElementById('txtState').value = "";
	document.getElementById('txtZip').value = "";
	document.getElementById('txtPhone').value = "";
	
	document.getElementById('accessible').checked = false;
	document.getElementById('notAccessible').checked = false;
}

//method to remove the li option
function RemoveOption(obj)
{
	var objLi = GetParentObject(obj, "LI", null, null);
	if(objLi!=null)
	{
		var objUl = objLi.parentNode;
		AdjustSortingOrderAfterDelete(objLi, objUl);
		objUl.removeChild(objLi);
		ShowHideNoneListed(objUl);
	}
}

function AdjustSortingOrderAfterDelete(objLi, objUL)
{
	var objTextBox = GetChildObject(objLi, "INPUT", "className", "ordering");
	var totalChild = GetChildCount(objUL, "LI");
	//amke current order same as this
	currentOrder = objTextBox.value;
	//make this the last order and call adjust sorting order method which will adjust other sorting order fields
	objTextBox.value = totalChild - 1;
	AdjustSortingOrder(objTextBox);
}
	
function SaveAddress()
{

	var objLi, displayAddress = "";
	
	if(editMode)
		objLi = globalVariable;
	else
		objLi = CreateLayer(document.getElementById('addresses'), true);
	
	if(objLi != null)
	{
	
		var objAddress = GetChildObject(objLi, "DIV", "className", "dataStorage");
		var objStrretAddress1 = GetChildObject(objAddress, "SPAN", "className", "streetAddress1");
		var objStrretAddress2 = GetChildObject(objAddress, "SPAN", "className", "streetAddress2");
		var objStrretAddress3 = GetChildObject(objAddress, "SPAN", "className", "streetAddress3");
		var city = GetChildObject(objAddress, "SPAN", "className", "city");
		var state = GetChildObject(objAddress, "SPAN", "className", "state");
		var zip = GetChildObject(objAddress, "SPAN", "className", "zip");
		var phone = GetChildObject(objAddress, "SPAN", "className", "phone");
		var centerDepartment = GetChildObject(objAddress, "SPAN", "className", "centerDepartment");
		var groupPractice = GetChildObject(objAddress, "SPAN", "className", "groupPractice");
		var hAccessible = GetChildObject(objAddress, "SPAN", "className", "handicapAccessible");
		var comma = "";
        var arrCenterDepartment;
        var arrGroupPractice;
                
        if(centerDepartment != null)
            arrCenterDepartment = centerDepartment.innerHTML.split("||");
            
        if(groupPractice != null)
            arrGroupPractice = groupPractice.innerHTML.split("||");
               
		objStrretAddress1.innerHTML = document.getElementById('txtStreetAdd1').value;
		
		if(document.getElementById('txtStreetAdd1').value!="")
			displayAddress += document.getElementById('txtStreetAdd1').value;
			
		objStrretAddress2.innerHTML = document.getElementById('txtStreetAdd2').value;
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
		if(document.getElementById('txtStreetAdd2').value!="")
			displayAddress += comma + document.getElementById('txtStreetAdd2').value;
		
		objStrretAddress3.innerHTML = document.getElementById('txtStreetAdd3').value;
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
			
		if(document.getElementById('txtStreetAdd3').value!="")
			displayAddress += comma + document.getElementById('txtStreetAdd3').value;
		
		city.innerHTML = document.getElementById('txtCity').value;
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
		if(document.getElementById('txtCity').value!="")
			displayAddress += comma + document.getElementById('txtCity').value;
			
		state.innerHTML = document.getElementById('txtState').value;
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
		if(document.getElementById('txtState').value!="")
			displayAddress += comma + document.getElementById('txtState').value;
			
		zip.innerHTML = document.getElementById('txtZip').value;
		if(displayAddress=="")
			comma = "";
		else
			comma = " ";
		if(document.getElementById('txtZip').value!="")
			displayAddress += comma + document.getElementById('txtZip').value;
			
			
		phone.innerHTML = document.getElementById('txtPhone').value;
		
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
			
		if(document.getElementById('txtPhone').value!="")
			displayAddress += comma + document.getElementById('txtPhone').value;
		
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
		
    	if(centerDepartment != null)
    	{			
		    centerDepartment.innerHTML = "";
		    // This piece is taking too much time need to refactor it - Elma
		    if(document.getElementById('selCenter').selectedIndex > 0)
		    {
		        centerDepartment.innerHTML = document.getElementById('selCenter').value + "||" + document.getElementById('selCenter').options[document.getElementById('selCenter').selectedIndex].text;			    
		    //	displayAddress += comma + document.getElementById('selCenter').options[document.getElementById('selCenter').selectedIndex].text;
		    }
		}
		
		if(displayAddress=="")
			comma = "";
		else
			comma = ", ";
		
		if(groupPractice != null)
		{
		    groupPractice.innerHTML = "";
		    // This piece is taking too much time need to refactor it - Elma
		    if(document.getElementById('selGroupPractice').selectedIndex > 0)
		    {
		        groupPractice.innerHTML = document.getElementById('selGroupPractice').value + "||" + document.getElementById('selGroupPractice').options[document.getElementById('selGroupPractice').selectedIndex].text;			
		    //	displayAddress += comma + document.getElementById('selGroupPractice').options[document.getElementById('selGroupPractice').selectedIndex].text;
		    }	
		}
		if(document.getElementById('accessible').checked)
			hAccessible.innerHTML = "Yes";
		else
			hAccessible.innerHTML = "No";
			
		AdjustDisplayText(objLi, elipsisMaxWidth, displayAddress);
		
		//ShowHideNoneListed(objLi.parentNode);
	}
	
	HidePopUpLayer();
	
	return false;
}

function FormDisplayText(objLi)
{
	var displayAddress = "";
	var objAddress = GetChildObject(objLi, "DIV", "className", "dataStorage");
	var objStrretAddress1 = GetChildObject(objAddress, "SPAN", "className", "streetAddress1");
	var objStrretAddress2 = GetChildObject(objAddress, "SPAN", "className", "streetAddress2");
	var objStrretAddress3 = GetChildObject(objAddress, "SPAN", "className", "streetAddress3");
	var city = GetChildObject(objAddress, "SPAN", "className", "city");
	var state = GetChildObject(objAddress, "SPAN", "className", "state");
	var zip = GetChildObject(objAddress, "SPAN", "className", "zip");
	var phone = GetChildObject(objAddress, "SPAN", "className", "phone");
	var hAccessible = GetChildObject(objAddress, "SPAN", "className", "handicapAccessible");
	var comma = "";
	
	if(objStrretAddress1.innerHTML!="")
		displayAddress += objStrretAddress1.innerHTML;
	
	if(displayAddress=="")
		comma = "";
	else
		comma = ", ";
	if(objStrretAddress2.innerHTML!="")
		displayAddress += comma + objStrretAddress2.innerHTML;
	
	if(displayAddress=="")
		comma = "";
	else
		comma = ", ";
	if(objStrretAddress3.innerHTML!="")
		displayAddress += comma + objStrretAddress3.innerHTML;
	
	if(displayAddress=="")
		comma = "";
	else
		comma = ", ";
	if(city.innerHTML!="")
		displayAddress += comma + city.innerHTML;
		
	if(displayAddress=="")
		comma = "";
	else
		comma = ", ";
	if(state.innerHTML!="")
		displayAddress += comma + state.innerHTML;
		
	if(displayAddress=="")
		comma = "";
	else
		comma = " ";
	if(zip.innerHTML!="")
		displayAddress += comma + zip.innerHTML;
		
	if(displayAddress=="")
		comma = "";
	else
		comma = ", ";
	if(phone.innerHTML!="")
		displayAddress += comma + phone.innerHTML;
		
	return displayAddress;
}

function ObtainSpecialityDisplayText(objLi)
{
	var objSpeciality = GetChildObject(objLi, "DIV", "className", "dataStorage");
	return objSpeciality.innerHTML;
}

function ShowHideNoneListed(objUL)
{
	var objNoneLi = GetChildObject(objUL, "LI", "className", "noneListed");
	if(objNoneLi!=null)
	{
	
		var display;
		if(GetChildCount(objUL, "LI")>1)
			display = "none";
		else
			display = "block";
		
		objNoneLi.style.display = display;
	}	
}

var currentOrder;

function AdjustSortingOrder(objTextBox)
{
	//verify if only digits r entered
	
	var valueChanged = false;
	
	if(objTextBox.value==""|| !CheckNumber(objTextBox.value, 0, "") ||parseInt(objTextBox.value)<1)
	{
		objTextBox.value = currentOrder;
		return;
	}
	else if(objTextBox.value==currentOrder)
		return;
		
	var objUL = GetParentObject(objTextBox, "UL", null, null);	
	
	var childObjects = new Array();	
	childObjects = GetAllRecursiveChildObjects(objUL, "INPUT", "className", "ordering", childObjects);	
	
	for(i=0; i<childObjects.length; i++)
	{
		if(childObjects[i]!=objTextBox&&childObjects[i].value!="")
		{
			if(parseInt(objTextBox.value)<currentOrder)
			{
				if(parseInt(childObjects[i].value) >= parseInt(objTextBox.value)&&parseInt(childObjects[i].value)<currentOrder)
				{
					childObjects[i].value = parseInt(childObjects[i].value) + 1;
					valueChanged = true;
				}
			}
			else
			{
				if(parseInt(childObjects[i].value) <= parseInt(objTextBox.value)&&parseInt(childObjects[i].value)>currentOrder)
				{
					childObjects[i].value = parseInt(childObjects[i].value) - 1;
					valueChanged = true;
				}
			}
		}
	}
	
	if(!valueChanged||parseInt(objTextBox.value)>childObjects.length-1)
		objTextBox.value = childObjects.length - 1;
}

function StoreCurrentNumber(objTextBox)
{
	currentOrder = objTextBox.value;	
}

function CreateLayer(objUL, isAddress)
{
	var cnt = GetChildCount(objUL, "LI");
	
	if(isAddress)
		return CreateAddressLayer(objUL, cnt);
	else
		return CreateSpecialityLayer(objUL, cnt);
}

function CreateAddressLayer(objUL, cnt)
{
	var objLI = document.createElement("LI");
	
	objLI.innerHTML = ""
	+"	<input type=\"text\" class=\"ordering\" value=\"" + cnt + "\" onfocus=\"StoreCurrentNumber(this);\" onchange=\"AdjustSortingOrder(this);\" />"
	+"	<a onclick=\"populateDropdowns();PopulateAddressPopUp(this);PopUpClicked();ShowPopUpLayer('adressPopUp', event);\" onmouseover=\"UnderLine(this);\"></a>"
	+"	<div class=\"dataStorage\"><span class=\"streetAddress1\"></span><span class=\"streetAddress2\"></span><span class=\"streetAddress3\"></span><span class=\"city\"></span><span class=\"state\"></span><span class=\"zip\"></span><span class=\"phone\"></span><span class=\"centerDepartment\"></span><span class=\"groupPractice\"></span><span class=\"handicapAccessible\"></span></div>"
	+"	<div class=\"adminButtons\"><img src=\"/css/images/adminButtonBorder.gif\" /><span><a onmouseover=\"UnderLine(this);\" onclick=\"populateDropdowns();PopulateAddressPopUp(this);PopUpClicked();ShowPopUpLayer('adressPopUp', event);\">[Edit]</a><a onmouseover=\"UnderLine(this);\" onclick=\"RemoveOption(this);\">[Delete]</a></span><img src=\"/css/images/adminButtonBorder.gif\" /></div>";
	
	objUL.appendChild(objLI);
	
	return objLI;
}

function CreateSpecialityLayer(objUL, cnt)
{
	var objLI = document.createElement("LI");
	
	objLI.innerHTML = ""
	+"	<input type=\"text\" class=\"ordering\" value=\"" + cnt + "\" onfocus=\"StoreCurrentNumber(this);\" onchange=\"AdjustSortingOrder(this);\"/>"
	+"	<a onclick=\"PopulateSpecialityPopUp(this);PopUpClicked();ShowPopUpLayer('specialityPopUp', event);\" onmouseover=\"UnderLine(this);\"></a>"
	+"	<div class=\"dataStorage\"></div>"
	+"	<div class=\"adminButtons\"><img src=\"/css/images/adminButtonBorder.gif\" /><span><a onmouseover=\"UnderLine(this);\" onclick=\"PopulateSpecialityPopUp(this);PopUpClicked();ShowPopUpLayer('specialityPopUp', event);\">[Edit]</a><a onmouseover=\"UnderLine(this);\" onclick=\"RemoveOption(this);\">[Delete]</a></span><img src=\"/css/images/adminButtonBorder.gif\" /></div>";
	
	objUL.appendChild(objLI);
	
	return objLI;
}

function GetChildCount(objParent, childTagName)
{
	var i, cnt = 0;	
	for(i=0; i<objParent.childNodes.length; i++)
	{
		if(objParent.childNodes[i].nodeName==childTagName)
			cnt++;
	}
	return cnt;
}

function AdjustDisplayText(objLI, displayTextMaxWidth, displayText)
{
	var objAnchor = GetChildObject(objLI, "A", "", "");
	if(objAnchor!=null)
	{
		objAnchor.innerHTML = displayText;
		if(objAnchor.clientWidth>displayTextMaxWidth)
		{
			while(objAnchor.clientWidth>displayTextMaxWidth)
				objAnchor.innerHTML = objAnchor.innerHTML.substring(0, objAnchor.innerHTML.length-1);
			
			//add elipsis
			objAnchor.innerHTML = objAnchor.innerHTML.substring(0, objAnchor.innerHTML.length-3);
			objAnchor.innerHTML += "...";			
		}
	}
}

function AdjustDisplayTextInsideUL(objUL, displayTextMaxWidth, isAddress)
{
	var i, displayText;
	for(i=0; i<objUL.childNodes.length;i++)
	{
		if(objUL.childNodes[i].nodeName == "LI")
		{
			if(objUL.childNodes[i].className!="noneListed")
			{
				if(isAddress)
					displayText = FormDisplayText(objUL.childNodes[i]);
				else
					displayText = ObtainSpecialityDisplayText(objUL.childNodes[i]);
					
				AdjustDisplayText(objUL.childNodes[i], displayTextMaxWidth, displayText);
			}
		}
	}
	ShowHideNoneListed(objUL);
}

function SaveSpeciality()
{
	var objLi, speciality;
	
	if(document.getElementById('speciality').value=="")
	{
		alert("Please enter some valid data.");
		document.getElementById('speciality').focus();
		return;	
	}
	
	if(editMode)
		objLi = globalVariable;
	else
		objLi = CreateLayer(globalVariable, false);
	
	if(objLi != null)
	{
		var objAddress = GetChildObject(objLi, "DIV", "className", "dataStorage");
		speciality = objAddress.innerHTML = document.getElementById('speciality').value;
		AdjustDisplayText(objLi, elipsisMaxWidth, speciality);		
		ShowHideNoneListed(objLi.parentNode);
	}
	
	HidePopUpLayer();
	
	return false;
}

function PopulateSpecialityPopUp(obj)
{
	editMode = true;
	
	var objLi = GetParentObject(obj, "LI", "", "");
	globalVariable = objLi;
	
	var specialityLabel = GetSpecialityLabel(objLi);
	
	var objSpeciality = GetChildObject(objLi, "DIV", "className", "dataStorage");
	
	document.getElementById('speciality').value = objSpeciality.innerHTML;
	document.getElementById('specialityLabel').innerHTML = specialityLabel;
}

function GetSpecialityLabel(obj)
{
	var objCont = GetParentObject(obj, "DIV", "className", "addressContainer");
	var objLabel = GetChildObject(objCont, "LABEL", "", "");
	return objLabel.innerHTML;
}

function ClearSpecialityPopUp(obj)
{
	editMode = false;	
	//make fields as blank
	document.getElementById('speciality').value = "";
	
	//put the speciality label
	var objCont = GetParentObject(obj, "DIV", "className", "addressContainer");
	var objLabel = GetChildObject(objCont, "LABEL", "", "");
	var specialityLabel = objLabel.innerHTML;
	
	//get the UL object
	var objUL = GetChildObject(objCont, "UL", "", "");
	globalVariable = objUL;
	document.getElementById('specialityLabel').innerHTML = specialityLabel;
}


function CheckSpecialityPopUp()
{
	
}
/* End of Maintain Phydician Scripting */

/* Start of Scripting of Home Page */

var objMoreLayer;

function ShowMoreMenu(obj, objEvent)
{
	var liObj = GetParentObject(obj, "LI", null, null);
	var childULObj = GetChildObject(liObj, "UL", null, null);
	if(childULObj.style.visibility!="visible")
	{
		HideMoreMenu();
		childULObj.style.visibility = "visible";
		objMoreLayer = childULObj;
		
		//position the top of this layer
		SetAllDimensionData(objEvent, childULObj);
		
		
		if((bodyHeight-cursorY)<layerHeight/2)
		{	//space on bottom is less, show ending from browser bottom
			childULObj.style.top = scrollTop + bodyHeight - layerHeight - 5 + "px";		
		}
		//set the top position of the pop up
		else if(cursorY<layerHeight/2)
		{	//space on top is less, show starting from browser top
			childULObj.style.top = scrollTop + 5 + "px";
		}
		else
		{	//enough place on both top n bottom, place layer in center
			childULObj.style.top = scrollTop + cursorY - layerHeight/2 + "px";
		}
		
		//set the top position of the pop up
		GetObjectPosition(liObj);
		childULObj.style.left = containerLeft + 47 + "px";
	}
}

function HoverMoreMenu(obj)
{
	obj.className = "over " + obj.className;
}

function OutMoreMenu(obj)
{
	obj.className = obj.className.replace("over", "");
}

function HideMoreMenu()
{
	if(objMoreLayer!=null)
		objMoreLayer.style.visibility = "hidden";
}


function AdjustHomePage(objDiv)
{
	var allULElements = new Array();
	allULElements = GetAllRecursiveChildObjects(objDiv, "UL", "", "", allULElements);
	var objUL;
	for(i=0; i<allULElements.length; i++)
	{
		AdjustHomPageLink(allULElements[i]);
		allULElements[i].style.visibility = "visible";
	}
	
	//AdjustHomPageImage(objDiv, allULElements[0], GetChildObject(objDiv, "IMG"));
}

function AdjustHomPageLink(objUL)
{
	var maxAnchorAllowed = 9;
	
	if(GetChildCount(objUL, "LI")>maxAnchorAllowed)
	{
		var i, j, cnt = 0, objMoreLi;
		
		
		
		var extraLinks = new Array();
		
		var objMoreSection = document.createElement("UL");
		
		for(i=0, j=0; i<objUL.childNodes.length; i++)
		{
			//alert(i);
			if(objUL.childNodes[i].nodeName == "LI")
			{
				cnt++;
				if(cnt>=maxAnchorAllowed)
				{
					var objLI = document.createElement("LI");
					var objLIAnchor = document.createElement("A");
					var existingAnchor = GetChildObject(objUL.childNodes[i], "A", null, null);
					//Populate LI with two functions
					objLI.onmouseover = function()
					{
						HoverMoreMenu(this);
					}
					
					objLI.onmouseout = function()
					{
						OutMoreMenu(this);	
					}
					
					//Populate anchor tag
					objLIAnchor.href = existingAnchor.href;
					objLIAnchor.innerHTML = existingAnchor.innerHTML;
					
					//Appending Anchor to LI Object
					objLI.appendChild(objLIAnchor);
					
					//Appending LI to UL Object
					objMoreSection.appendChild(objLI);
					
					if(cnt==maxAnchorAllowed)
					{
						objMoreLi = objUL.childNodes[i];
						
						//Populate Anchor tag of ninth Element
						/*existingAnchor.onmouseover = function()
						{
							UnderLine(this);
						}
						
						existingAnchor.onclick = function()
						{
							PopUpClicked();
							ShowMoreMenu(this, event);
						}
						
						existingAnchor.innerHTML = "More...";
						existingAnchor.removeAttribute("href");*/
						
						/*on click*/
						//objMoreLi.innerHTML = "<a onmouseover=\"UnderLine(this);\" onclick=\"PopUpClicked();ShowMoreMenu(this, event);\">More...</a>";
						/*on hover*/
						objMoreLi.innerHTML = "<a onmouseover=\"UnderLine(this);ShowMoreMenu(this, event);\">More...</a>";
						objMoreLi
						
					}
					else
					{
						objUL.removeChild(objUL.childNodes[i]);
						i--;
					}			
				}
			}
		}
		
	//	objMoreSection.onclick = function()
	//	{
	//		PopUpClicked();
	//	}
		
		objMoreSection.className = "moreSection";
		
		objMoreLi.appendChild(objMoreSection);
		
		//objMoreLi.style.position = "relative";
	}	
}

function AdjustHomPageImage(objDiv, objUL, objImage)
{
	if(objDiv.clientHeight-objUL.clientHeight<objImage.clientHeight + 83)
	{
		objDiv.style.height = objUL.clientHeight + objImage.clientHeight + 83 + "px";
	}
	GetObjectPosition(objDiv);
	objImage.style.top = containerTop + objDiv.clientHeight - objImage.clientHeight - 24  + "px";
	objImage.style.left = containerLeft + 22 + "px";
	objImage.style.visibility = "visible";
}

/* End of Scripting of Home Page */
function NHS_GetTwoColumnLinkLayout()
{
	var htmlContent = ""
	+"<div class=\"fourContentBlock\">"
	+"	<div class=\"leftSection\">"
	+"		<h3>TITLE</h3>"
	+"		<p>This area is for text that describes the content. This area is for text that describes the content. Links may be listed in order:</p>"
	+"		<ul>"
	+"			<li><a href=\"#\">Link 1</a></li>"
	+"			<li><a href=\"#\">Link 2</a></li>"
	+"			<li><a href=\"#\">Link 3</a></li>"
	+"		</ul>"
	+"		<p>This area is for text that describes the content. This area is for text that describes the content. Links may be listed in order:</p>"
	+"	</div>"
	+"	<div class=\"rightSection\">"
	+"		<h3>TITLE</h3>"
	+"		<p>This area is for text that describes the content. This area is for text that describes the content. Links may be listed in order:</p>"
	+"		<ul>"
	+"			<li><a href=\"#\">Link 1</a></li>"
	+"			<li><a href=\"#\">Link 2</a></li>"
	+"			<li><a href=\"#\">Link 3</a></li>"
	+"		</ul>"
	+"		<p>This area is for text that describes the content. This area is for text that describes the content. Links may be listed in order:</p>"
	+"	</div>"
	+"</div>";
	
	return htmlContent;
}
//Quiz Question Onclick Div

function showQuizQuestions(id)
{
	var showDIVLayer;
	showDIVLayer = "quizQuestion" + id;
	document.getElementById(showDIVLayer).style.display = "block";
}


//Quiz Question hide div

function hideQuizQuestions(id)
{
	var showDIVLayer;
	showDIVLayer = "quizQuestion" + id;
	document.getElementById(showDIVLayer).style.display = "none";
}

/* Start of Calcultae BMI page scripting */
function ShowBMIResults()
{
	document.getElementById('resultContent').style.visibility = "visible";
	document.getElementById('bulletBorder').style.visibility = "visible";
	document.getElementById('linksSection').style.visibility = "visible";
	document.getElementById('rightContent').style.display = "block";
}
/* End of Calcultae BMI page scripting */


/* Start of Validation Scripting */
function CheckEmail(email)
{
	var IsTextValidEmail = /^[^ @]+@[^ @.]+\.[^ @.]{2,3}$/;
	return ValidateData(email, "Enter a valid email address.", IsTextValidEmail);
	/*if(!IsTextValidEmail.test(email))
	{
		alert("Enter a valid email address.");
		return false;
	}
	return true;*/
}

function CheckDate(strDate)
{
	var IsTextValidDate = /^(?:0|1)?\d(\.|\||-|\/)(?:[0-3]?\d)\1(?:19|20)?\d{2}$/;
	return ValidateData(strDate, "Enter a valid date in the format (mm/dd/yyyy).", IsTextValidDate);
	/*if(!IsTextValidDate.test(strDate))
	{
		alert("Enter a valid date in the format (mm/dd/yyyy)");
		return false;
	}
	return true;*/
}
function ValidateData(txBoxValue, message, regExp)
{
	var IsNumberValid;
	IsNumberValid = new RegExp(regExp);
	if(!IsNumberValid.test(txBoxValue))
	{
		if(message!="")
			alert(message);
		return false;
	}
	return true;
}
function CheckNumber(number, length, message)
{
	var IsNumberValid;
	if(length!=0)
		IsNumberValid = new RegExp("^[0-9]{" + length + "}$");
	else
		IsNumberValid = new RegExp("^[0-9]+$");
	return ValidateData(number, message, IsNumberValid);
	/*if(!IsNumberValid.test(number))
	{
		alert(message);
		return false;
	}
	return true;*/
}
function CheckFloat(number, message)
{
	var IsFloatNumberValid = new RegExp("^[0-9]+[.][0-9]+$");
	return ValidateData(number, message, IsFloatNumberValid);
	/*if(!IsFloatNumberValid.test(number))
	{
		alert(message);
		return false;
	}
	return true;*/
}

function ValidateDateRange(fld)
{ 
	var msg = "Entered date is not valid. Please enter a valid date!!!";
	var day = new Array(31,28,31,30,31,30,31,31,30,31,30,31); 
	var dd, mm, yy;
	if (fld == '')
	{
		alert(msg);
	 	return false;
	}
	var d1 = fld.split('\/');
	if (d1.length != 3) d1 = fld.split('-');
	if (d1.length != 3) d1 = fld.split('|');
	if (d1.length != 3) d1 = fld.split('.');
	if (d1.length != 3)
	{
		alert(msg);
	 	return false;
	}

	dd = d1[1]; mm = d1[0]; yy = d1[2];
	dd = parseFloat(dd); 
	mm = parseFloat(mm); 
	yy = parseFloat(yy);
	if (mm == 2 && (yy%400 == 0 || (yy%4 == 0 && yy%100 != 0))) 
	day[mm-1]++;
	if (mm < 1 || mm > 12)
	{
		alert(msg);
	 	return false;
	}

	if (dd < 1 || dd > day[mm-1])
	{
		alert(msg);
	 	return false;
	}

	return true;
}
/* End of validation scripting */

/* Content set 3 js */
//}
//Added by thiru on 30/04/2007 to control the online donor type - start
function showForm()
{
	//alert(document.ctl03);
	if(browserSniffer(2, 0))
	{
		ctl03 = document.ctl03;
	}
	var i = 0;
	for(i = 0; i< ctl03.appType.length - 1; i++)
	{
		if(ctl03.appType[0].checked)
		{
			document.getElementById('formDisplay1').style.display = "block";
			document.getElementById('formDisplay2').style.display = "none";
			return true;
		}
		else(ctl03.appType[1].checked)
		{
			document.getElementById('formDisplay2').style.display = "block";
			document.getElementById('formDisplay1').style.display = "none";
			return true;
		}
	}	
}

//for Appoinment requestion
function showFormnew()
{
	var s_url_string;	
	var s;
	s=document.URL;
	if(browserSniffer(2, 0))
	{
		ctl03 = document.ctl03;
	}
	if ((ctl03.appType[0].checked==false) &&(ctl03.appType[1].checked==false))
	{
		alert("Please select Appointment Type");
		return false;
	}
	if (ctl03.appType[0].checked==true)
	{			
		if (s.indexOf("?")>=0)
		{
			s_url_string=s.substring(0,s.indexOf("?"))+"?formTypeid="+ctl03.appType[0].value;
		}
		else
		{
			s_url_string = document.URL+"?formTypeid="+ctl03.appType[0].value;			
		}
		self.location=s_url_string;
	}
	if (ctl03.appType[1].checked==true)
	{								
		if (s.indexOf("?")>=0)
		{
			s_url_string=s.substring(0,s.indexOf("?"))+"?formTypeid="+ctl03.appType[1].value;
		}
		else
		{
			s_url_string = document.URL+"?formTypeid="+ctl03.appType[1].value;			
		}
		self.location=s_url_string;
	}	
	return true;
}


//Added by thiru on 30/04/2007 to control the online donor type - start


function searchOnEnterPress(e){

var characterCode; 

if(e && e.which){ //if which property of event object is supported (NN4)
e = e;
characterCode = e.which ;
}
else{
e = event;
characterCode = e.keyCode;
}

var searchText;
var hiddenSearchText;




if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)



var textList = YAHOO.util.Dom.getElementsByClassName("search");

    for(var i=0;i<textList.length;i++)
    {       
	searchText = textList[i].value;

	}	

var hiddenTextList = document.getElementById("searchText");
 
	hiddenTextList.value = searchText;


var btnGoList = YAHOO.util.Dom.getElementsByClassName("btnGo");

    for(var i=0;i<btnGoList.length;i++)
    {       
//alert(hiddenTextList.value);
		btnGoList[i].click();	
	}	



return false;
}
else{
return true;
}

}


function ShowSendEmailPage(toEmail)
{

	var filename = "/send-email.aspx?toEmail="+toEmail;
	
	var objWindow = launchCenter(filename , "Email", 700, 900, "yes", "yes");

}


function openPaypalDonationWindow(formNumber)
{    

   var iFrameDocumentObj;
   var formid;
  
   // Specifically for the 100th Anniversary Gala opening page - Jan 10
   if(formNumber == 6){
	window.open("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=11351562","paypal");
	return false;
   }
   
   // Specifically for the Nordstorm Gala opening page - Jan 09
   if(formNumber == 5){
	window.open("https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2523557","paypal");
	return true;
   }

   
	
   if (document.getElementById('frmPayPal').contentDocument){ 
      //mozilla
      iFrameDocumentObj = document.getElementById('frmPayPal').contentDocument; 
    } else { 
      // IE 
      iFrameDocumentObj = window.frames['frmPayPal'].document;
    } 
	
    formid=iFrameDocumentObj.forms[formNumber-1]
    //alert(formid)
    formid.submit()	
//    self.focus();
    return true; 

}


// This function will copy the options from a dropdown box and set the selected option also
function copyDropdownValues(objFromDropdown,objToDropdown,defaultValue)
{
    // Copy the dropdown options 
    var oOption ;   
    
    // Clear any existing options from objToDropdown
    for(i=0;i<objToDropdown.options.length;)    
    {
        if(browserSniffer(1, 0))         
            objToDropdown.options.remove(i);
        else
            objToDropdown.options[i].remove(i);
    }
    
    for(i=0;i<objFromDropdown.options.length;i++)
    {                
        //For safari only - use new option() method to add option
        if(browserSniffer(3, 0))
        {            
            objToDropdown.options[i] = new Option(objFromDropdown.options[i].value,objFromDropdown.options[i].text);            
            //if(objFromDropdown.options[i].value == defaultValue)
            //    objToDropdown.options[i].selected = true;
        }    
        else
        {    
            oOption = document.createElement("OPTION");                      
            oOption.text = objFromDropdown.options[i].text;
            oOption.value = objFromDropdown.options[i].value;   
            objToDropdown.options.add(oOption,i);
            //if(i==0) // default selected value
            //    oOption.selected =true;            
                
            //if(objFromDropdown.options[i].value == defaultValue)   
            //{
            //    alert("found default value")
            //    oOption.selected =true;                                   
            //} 
        }                    
        oOption = null;        
    }    
    
}

// This function will populate the dropdown boxes for CenterDepartment & Group Practice
// Called before showing the address popup
function populateDropdowns()
{
// New Field were added, so populate the default values to the dropdown boxes	
	var centerDepartmentFullList = getElementByPD_Id("centerDepartment");		
	copyDropdownValues(centerDepartmentFullList,document.getElementById('selCenter'),"")
	
	var groupPracticeFullList = getElementByPD_Id("groupPractice")	
	copyDropdownValues(groupPracticeFullList,document.getElementById('selGroupPractice'),"")
}

/* Begin Functions for BHATDanvers Virtual Tour Video -Jan 08 */


function ShowBHATDanversVideoPage()
{	
	var url = "/Videos/BHATDanversVideo/flash.html";
	
	var height = "450";
	var width = "568";
	
	var str = "height=" + height + ",innerHeight=" + height; 
	str += ",width=" + width + ",innerWidth=" + width; 
	if (window.screen) 
	{ 
    	var ah = screen.availHeight - 30; 
	    var aw = screen.availWidth - 10; 
	    var xc = (aw - width) / 2; 
	    var yc = (ah - height) / 2; 
	    str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc;
	}
	str = str + ",scrollbars=1";
	str = str + ",resizable=0";
	str = str + ",titlebar=0";
	str = str + ",menubar=0";
	str = str + ",toolbar=0";
	str = str + ",status=0";
	str = str + ",location=0";	

	window.open(url, "BHATDanvers", str); 	
}
/* End Functions for BHATDanvers Virtual Tour Video -Jan 08 */

// New function to show Annual Day meeting flash vedio
function ShowAnnualDayMeeting()
{
	var url = "/videos/AnnualMeeting/flash.html";
	
	var height = "380";
	var width = "550";
	
	var str = "height=" + height + ",innerHeight=" + height; 
	str += ",width=" + width + ",innerWidth=" + width; 
	if (window.screen) 
	{ 
    	var ah = screen.availHeight - 30; 
	    var aw = screen.availWidth - 10; 
	    var xc = (aw - width) / 2; 
	    var yc = (ah - height) / 2; 
	    str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc;
	}
	str = str + ",scrollbars=0";
	str = str + ",resizable=0";
	str = str + ",titlebar=0";
	str = str + ",menubar=0";
	str = str + ",toolbar=0";
	str = str + ",status=0";
	str = str + ",location=0";	

	window.open(url, "AnnualDayMeeting", str); 
}


 /* Begin function for Event Signup form*/
    function ShowPopupPage(filename)
    {     
	    var objWindow = launchCenter(filename , "popupWindow", 700, 900, "yes", "yes");
    } 
    
    /* End function for Event Signup form*/




// Contact Us - Email with Attachments Updates - 25-FEB-2009

    /* Below Two functions used to set up Parent form field values to Child form fields   -- Start*/
        
    function ShowContactUsEmailPage(toEmail)
    {        
	    var filename = "/contact-us-email.aspx?toEmail="+toEmail;	
	    var objWindow = launchCenter(filename , "Email", 700, 900, "yes", "yes");
    } 
    
    function EmailFormLoad()
    {   
       
        var obj= window.opener;        
        
        if(obj)
        {        
        if(obj.getElementByPD_Id("FirstName") && getElementByPD_Id("FirstName"))
            getElementByPD_Id("FirstName").value = obj.getElementByPD_Id("FirstName").value;
            
        if(obj.getElementByPD_Id("LastName") && getElementByPD_Id("LastName"))
            getElementByPD_Id("LastName").value = obj.getElementByPD_Id("LastName").value;
            
        if(obj.getElementByPD_Id("Inquiry") && getElementByPD_Id("Message"))
            getElementByPD_Id("Message").value = obj.getElementByPD_Id("Inquiry").value;
            
        if(obj.getElementByPD_Id("FromEMail") && getElementByPD_Id("FromEMail"))
            getElementByPD_Id("FromEMail").value = obj.getElementByPD_Id("FromEMail").value;
        
        if(obj.getElementByPD_Id("address1") && getElementByPD_Id("address1"))
            getElementByPD_Id("address1").value = obj.getElementByPD_Id("address1").value;
        
        if(obj.getElementByPD_Id("city") && getElementByPD_Id("city"))
            getElementByPD_Id("city").value = obj.getElementByPD_Id("city").value;
        
        if(obj.getElementByPD_Id("state") && getElementByPD_Id("state"))
            getElementByPD_Id("state").value = obj.getElementByPD_Id("state").value;
        
        if(obj.getElementByPD_Id("country") && getElementByPD_Id("country"))
            getElementByPD_Id("country").value = obj.getElementByPD_Id("country").value;
        }
     
        var pair1;
        var pageURL = location.search;
  		var indexOfQuestionMark = pageURL.indexOf("?");
	    var key="toEmail"; 

		if(indexOfQuestionMark!=-1)
		{
		   var queryString = pageURL.substring(indexOfQuestionMark);
		   var indexOfKey = queryString.indexOf(key);
		   var pair1 ="";		
		
		   if(indexOfKey!=-1)
		    pair1 = queryString.substring(indexOfKey+key.length+1);		        
		}		
		
		if(getElementByPD_Id("EMail"))
		{
		    //getElementByPD_Id("EMail").readOnly = true;
		    getElementByPD_Id("EMail").value =  pair1;		    
		}
		
		
	}

    function EmailFormLoadSimple()
    {   
       
        var obj= window.opener;        
        
             
        var pair1;
        var pageURL = location.search;
  		var indexOfQuestionMark = pageURL.indexOf("?");
	    var key="toEmail"; 

		if(indexOfQuestionMark!=-1)
		{
		   var queryString = pageURL.substring(indexOfQuestionMark);
		   var indexOfKey = queryString.indexOf(key);
		   var pair1 ="";		
		
		   if(indexOfKey!=-1)
		    pair1 = queryString.substring(indexOfKey+key.length+1);		        
		}		
		
		if(getElementByPD_Id("EMail"))
		{
		    //getElementByPD_Id("EMail").readOnly = true;
		    getElementByPD_Id("EMail").value =  pair1;		    
		}
		
		
	}
    
    /* Below Two functions used to set up Parent form field values to Child form fields  -- End*/

// Contact Us - Email with Attachments Updates - 25-FEB-2009

 /* Begin function for Event Signup form*/
    function ShowPopupPage(filename)
    {     
	    var objWindow = launchCenter(filename , "popupWindow", 700, 900, "yes", "yes");
    } 
    
    /* End function for Event Signup form*/



/*  BEGIN AJAX calls for FAD  group paractices sections */

function showGroupPracticeList(city)
{       
        if(city !="")                    
        {    
            var opt = {
            // Use POST
                method: 'post',
            // Send data
                postBody: "getGroupPractices=" + encodeURIComponent(city),
            // Handle successful response
            onSuccess: function(t) {
                getGroupPracticeList(t);
            },
            // Handle 404
            on404: function(t) {
                alert('Error 404: location "' + t.statusText + '" was not found.');
            },
            // Handle other errors
            onFailure: function(t) {
                alert('Error ' + t.status + ' -- ' + t.statusText);
            }
            }
         
            var filename = "/ajax/AjaxController.ashx"
            new Ajax.Request(filename,opt);        
        }    
    }
    
    //Refresh the Speciality List and select the newly added option
    function getGroupPracticeList(response)
    {    
        var list = eval('(' + response.responseText + ')');
        var htmlString = "<ul>";        
        //var htmlString = "<div class='doctorPractices'><select class='hoverSelect' id='selGroupPractices' onChange='window.location = this.options[this.selectedIndex].value;' >";        
        
        // show the list got from the AJAX Request ,JSON String            
        var oOption ; 
        for(i=0;i<list.GroupPractices.length;i++)                    
        { 
            //htmlString+= "<option value='" + escape(list.GroupPractices[i].url) + "'>" + list.GroupPractices[i].name + "</option>";             
            htmlString+= "<li><a href='" + list.GroupPractices[i].url + "'>" + list.GroupPractices[i].name + "</a></li>";             
        }             
        htmlString += "</ul>"
        //htmlString += "</select></div>"
        

        
        var objContent = document.getElementById("contentColumn");
        objContent.innerHTML = htmlString;
        
    }
    
    //Refresh the Speciality List and select the newly added option
    function getGroupPracticeListOld(response)
    {    
        var list = eval('(' + response.responseText + ')');
        //var htmlString = "<div class='doctorPractices'><ul>";        
        var htmlString = "<div class='doctorPractices'><select class='hoverSelect' id='selGroupPractices' onChange='window.location = this.options[this.selectedIndex].value;' >";        
        
        // show the list got from the AJAX Request ,JSON String            
        var oOption ; 
        for(i=0;i<list.GroupPractices.length;i++)                    
         htmlString+= "<option value='" + escape(list.GroupPractices[i].url) + "'>" + list.GroupPractices[i].name + "</option>";             
           // htmlString+= "<li><a href='" + list.GroupPractices[i].url + "'>" + list.GroupPractices[i].name + "</a></li>";             
                      
        //htmlString += "</ul></div>"
        htmlString += "</select></div>"
        

        
        var objContent = document.getElementById("contentColumn");
        objContent.innerHTML = htmlString;
        
    }
    

/*  END AJAX calls for FAD  group paractices sections */

 /* Begin function for On The air - videos*/  
  

function ShowOnTheAirAudio  (filename)
{
    var url = "/videos/OnTheAirVideos/AllPodcasts/" + filename + ".mp3";	
    window.open(url);
}

function ShowOnTheAirVideo(folderName)
{	
	var url = "/videos/ontheairvideos/flash.html?show="+folderName;	
	ShowVideoPopup(url,"OnTheAir");
}

function ShowVideoPopup(url,title)
{    
	//WIDTH="426" HEIGHT="305"
	var height = "430";
	var width = "550";
	
	var str = "height=" + height + ",innerHeight=" + height; 
	str += ",width=" + width + ",innerWidth=" + width; 
	if (window.screen) 
	{ 
    	var ah = screen.availHeight - 30; 
	    var aw = screen.availWidth - 10; 
	    var xc = (aw - width) / 2; 
	    var yc = (ah - height) / 2; 
	    str += ",left=" + xc + ",screenX=" + xc; str += ",top=" + yc + ",screenY=" + yc;
	}
	str = str + ",scrollbars=0";
	str = str + ",resizable=0";
	str = str + ",titlebar=0";
	str = str + ",menubar=0";
	str = str + ",toolbar=0";
	str = str + ",status=0";
	str = str + ",location=0";	

	window.open(url, title, str); 	
}
 
/* End function for On The air - videos*/ 


/* Start Functions for Font dynamically increasing the font size */
	
	function IncreaseFontSize(val) {
	    $(".mainContainer p, .mainContainer li, .mainContainer td").css("font-size",val + "px");	
	return false;
}

/* End Functions for Font dynamically increasing the font size */


/* Start SWARm Updates */
function highlightBodyPart(objEvent,imageId,bodyPart)
{
        removeHoverEffect();
		var objLink;		
		var offsetX = 0;
        var offsetY = 0;
        var tmpX = 0;
        var tmpY = 0;
        var e = objEvent;
     
        if(e.pageX)
        {
            tmpX = tmpX + window.pageXOffset - 20 + document.documentElement.scrollLeft;
            tmpY = tmpY + window.pageYOffset - 15 - document.documentElement.scrollTop;            
        }
        else if(e.clientX)
        {
            tmpX = e.clientX - 20 + document.documentElement.scrollLeft;
            tmpY = e.clientY - 15 + document.documentElement.scrollTop;
        }
              
        var imagePos = getElementPosition(document.getElementById(imageId));
            
		switch(bodyPart)
        {
            case "aaarepair": 
                        tmpX = imagePos.x + 240;                        
                        tmpY = imagePos.y + 135;                        
                        objLink = document.getElementById("lnkAAARepair");
                        break;
            case "angiography":                        
                        tmpX = imagePos.x + 70;                        
                        tmpY = imagePos.y + 198;                        
                        objLink = document.getElementById("lnkAngiogrpy");
                        break; 
            case "angioplasty": 
                        tmpX = imagePos.x + 50;
                        tmpY = imagePos.y + 250;                       
                        objLink = document.getElementById("lnkAngioPlsty");
                        break;  
            case "aaa": 
                        tmpX = imagePos.x + 190;                        
                        tmpY = imagePos.y + 350;                        
                        objLink = document.getElementById("lnkAAA");
                        break;
            case "heartanat":                        
                        tmpX = imagePos.x + 260;                        
                        tmpY = imagePos.y + 260;                        
                        objLink = document.getElementById("lnkHeartAnat");
                        break; 
            case "athero": 
                        tmpX = imagePos.x + 100;
                        tmpY = imagePos.y + 160;                       
                        objLink = document.getElementById("lnkAthero");
                        break;
            case "stroke":                        
                        tmpX = imagePos.x + 135;                        
                        tmpY = imagePos.y + 60;
                        objLink = document.getElementById("lnkStroke");                        
                        break; 
            case "heartattk": 
                        tmpX = imagePos.x + 300;
                        tmpY = imagePos.y + 205;
                        objLink = document.getElementById("lnkHeartAttk");                       
                        break;
            case "elbow":                        
                        tmpX = imagePos.x + 35;//  tmpX + 100; //688                        
                        tmpY = imagePos.y + 108; //810; // 843-810
                        objLink = document.getElementById("lnkElbow");
                        break;                        
            case "shoulder":                        
                        tmpX = imagePos.x + 105; // 755; // 755 - 590
                        tmpY = imagePos.y + 50 ; //750; //768 - 750
                        objLink = document.getElementById("lnkShoulder");
                        break;                        
            case "spine":                        
                        tmpX = imagePos.x + 75; // 730; //730 - 580
                        tmpY = imagePos.y +105; //809; //809 - 805
                        objLink = document.getElementById("lnkSpine");
                        break;                        
            case "wrist":                        
                        tmpX = imagePos.x + 10;//  tmpX + 100; //688                        
                        tmpY = imagePos.y + 153; //810; // 843-810
                        objLink = document.getElementById("lnkWrist");
                        break;                        
            case "hip": 
                        tmpX = imagePos.x + 100;//  tmpX + 100; //688                        
                        tmpY = imagePos.y + 153; //810; // 843-810
                        objLink = document.getElementById("lnkHip");
                        break;                        
            case "knee":
                        tmpX = imagePos.x + 100;//  tmpX + 100; //688                        
                        tmpY = imagePos.y + 235; //810; // 843-810
                        objLink = document.getElementById("lnkKnee");
                        break;                        
            case "ankle": 
                        tmpX = imagePos.x + 50;//  tmpX + 100; //688                        
                        tmpY = imagePos.y + 305; //810; // 843-810
                        objLink = document.getElementById("lnkAnkle");
                        break;                                    
        }  
    
    
		var spanHover = document.getElementById('spanHover');
        spanHover.innerHTML="<img src=\"/css/images/hoverCircle.gif\" class=\"opaque\" onclick=\"openSwarmUrl('" + bodyPart +"')\" />";
        spanHover.style.visibility="visible";
        spanHover.style.position="absolute";
        	
		spanHover.style.left = (tmpX )+ "px";
        spanHover.style.top = (tmpY ) + "px";
        spanHover.style.display = "block";
        
               
        if(objLink)
            objLink.className= "over" + objLink.className
}

function removeHighlightBodyPart()
{
    var spanHover =document.getElementById("spanHover");
       
    if(spanHover)
        spanHover.style.visibility="hidden";
}

// BEGIN FUnctions related to SWARM HUMAN BODY LINKS
  
   function showHoverEffect(objEvent,bodyPart)
    {
        var objLink;
        switch(bodyPart)
        {
            //case "neck": partCode="cervrad";
            //            break;
            case "elbow":
                        objLink = document.getElementById("lnkElbow");
                        break;                        
            case "shoulder":
                        objLink = document.getElementById("lnkShoulder");
                        break;                        
            case "spine":
                        objLink = document.getElementById("lnkSpine");
                        break;                        
            case "wrist": 
                        objLink = document.getElementById("lnkWrist");
                        break;                        
            case "hip": 
                        objLink = document.getElementById("lnkHip");
                        break;                        
            case "knee": 
                        objLink = document.getElementById("lnkKnee");
                        break;                        
            case "ankle": 
                        objLink = document.getElementById("lnkAnkle");
                        break;                        
        }   
        
        objLink.className = "over" + objLink.className
        
        
    }
    
    function highlightPart(objEvent,bodyPart)
    {   
        highlightBodyPart(objEvent,"imgSkeleton",bodyPart);
        
    }
    
    function removeHoverEffect()
    {       
        var spanHover =document.getElementById("spanHover");
        
        if(spanHover)
            spanHover.style.visibility="hidden";   
           
        if(document.getElementById("lnkShoulder"))
            document.getElementById("lnkShoulder").className = "humanLinks"; 
                  
        if(document.getElementById("lnkSpine"))
            document.getElementById("lnkSpine").className = "humanLinks"; 
                   
        if(document.getElementById("lnkElbow"))
            document.getElementById("lnkElbow").className = "humanLinks"; 
               
        if(document.getElementById("lnkKnee"))
            document.getElementById("lnkKnee").className = "humanLinks"; 
                  
        if(document.getElementById("lnkWrist"))
            document.getElementById("lnkWrist").className = "humanLinks";  
                  
        if(document.getElementById("lnkHip"))
            document.getElementById("lnkHip").className = "humanLinks";  
              
        if(document.getElementById("lnkAnkle"))
            document.getElementById("lnkAnkle").className = "humanLinks";  
            
        if(document.getElementById("lnkAAARepair"))
            document.getElementById("lnkAAARepair").className = "humanLinks"; 
                  
        if(document.getElementById("lnkAngiogrpy"))
            document.getElementById("lnkAngiogrpy").className = "humanLinks"; 
                   
        if(document.getElementById("lnkAngioPlsty"))
            document.getElementById("lnkAngioPlsty").className = "humanLinks"; 
               
        if(document.getElementById("lnkAAA"))
            document.getElementById("lnkAAA").className = "humanLinks"; 
                  
        if(document.getElementById("lnkHeartAnat"))
            document.getElementById("lnkHeartAnat").className = "humanLinks";  
                  
        if(document.getElementById("lnkAthero"))
            document.getElementById("lnkAthero").className = "humanLinks";  
              
        if(document.getElementById("lnkStroke"))
            document.getElementById("lnkStroke").className = "humanLinks"; 
            
        if(document.getElementById("lnkHeartAttk"))
            document.getElementById("lnkHeartAttk").className = "humanLinks";                   
        
    }
               
    function openSwarmUrl(bodyPart)    
    {          
      
       var partCode = "";
        switch(bodyPart)
        {
            //case "neck": partCode="cervrad";
            //            break;
            case "elbow": partCode="1el";
                        break;                        
            case "shoulder": partCode="2sh";
                        break;                        
            case "spine": partCode="2sp";
                        break;                        
            case "wrist": partCode="2ha";
                        break;                        
            case "hip": partCode="2hi";
                        break;                        
            case "knee": partCode="2kn";
                        break;                        
            case "ankle": partCode="2fo";
                        break;
            case "aaarepair": partCode="aaarepair";
                        break; 
            case "angiography": partCode="angiography";
                        break;                        
            case "angioplasty": partCode="angioplasty";
                        break;                        
            case "aaa": partCode="aaa";
                        break;
            case "heartanat": partCode="heartanat";
                        break; 
            case "athero": partCode="athero";
                        break; 
            case "stroke": partCode="stroke";
                        break;    
            case "heartattk": partCode="mi";
                        break;                                                                                                                                             
        }                             
        openSwarmPopupWindow(partCode)        
    }
    
    function openSwarmPopupWindow(partCode)
    {
        var sUrl = "/swarm/swarmMaterial.html?part=" +  partCode ;
        var str = "height=450,innerHeight=450"; 
	    str += ",width=600,innerWidth=600";	     	    
	    str = str + ",scrollbars=no";
	    str = str + ",resizable=no";
	    str = str + ",titlebar=no";
	    str = str + ",menubar=no";
	
        window.open(sUrl,"SwarmInteractivePage",str);                  
    }
    
    
    function getElementPosition(theElement){
      var posX = 0;
      var posY = 0;
                  
      while(theElement != null){
        posX += theElement.offsetLeft;
        posY += theElement.offsetTop;
        theElement = theElement.offsetParent;
      }
                            		      
     return {x:posX,y:posY};

    }
    

/* End Swarm Updated */

/* Begin Share Your Story - Video popup */
function ShowLeadingEdgeOfCareVideo(folderName)
{	
	var url = "/videos/LeadingEdgeOfCare/"+folderName+"/flash.html";	
	ShowVideoPopup(url,"LeadingEdgeOfCare");
}
/* End Share Your Story - Video popup */