					// ########### change text size javascript ###########
					var DEFAULT_SIZE = "70%";
					var LARGER_SIZE = "80%";
					
					function toggle_text_size(text_link) {
						if (document.documentElement.style.fontSize == LARGER_SIZE) decrease_text(text_link);
						else increase_text(text_link);
						
					}
					
					function increase_text(text_link) {
					
							var text_node = document.createTextNode("Increase/Decrease Text Size");
							document.documentElement.style.fontSize = LARGER_SIZE;
							text_link.className = "decrease";
							text_link.setAttribute("title", "Decrease Text Size");
							text_link.removeChild(text_link.firstChild);
							text_link.appendChild(text_node);
					
					}
					
					function change_link_text() {
					
							var text_link = document.getElementById("page_toolbar_text").getElementsByTagName("a")[0];
							var text_node = document.createTextNode("Increase/Decrease Text Size");
							text_link.className = "decrease";
							text_link.setAttribute("title", "Decrease Text Size");
							text_link.removeChild(text_link.firstChild);
							text_link.appendChild(text_node);
							
					
					}
					
					function decrease_text(text_link) {
					
							var text_node = document.createTextNode("Increase/Decrease Text Size");
							document.documentElement.style.fontSize = DEFAULT_SIZE;
							text_link.className = "increase";
							text_link.setAttribute("title", "Increase Text Size");
							text_link.removeChild(text_link.firstChild);
							text_link.appendChild(text_node);
					
						
					}
					function check_text_size() {
						var cookie = get_cookie("text_size");
						var current_text_size = cookie ? cookie : get_default_text_size();
						return set_current_text_size(current_text_size);
					}
					
					
					function text_size_unload() {
						var current_text_size = get_current_text_size();
						make_cookie("text_size", current_text_size);
					}

					addUnloadEvent(text_size_unload);
					
					function set_current_text_size(current_text_size) {
						if (current_text_size == LARGER_SIZE) {
							document.documentElement.style.fontSize = LARGER_SIZE;
							return true;
						}
						return false;
					}
					
					function get_default_text_size() { return DEFAULT_SIZE; }
					
					function get_current_text_size() {
					
						if (document.documentElement.style.fontSize == LARGER_SIZE) return LARGER_SIZE;
						else return DEFAULT_SIZE;
						
					}
					
					function make_cookie(name, val) {
  						var expires = "";
  						document.cookie = name+"="+val+expires+"; path=/";
					}
					
					function get_cookie(name) {
					
						var n = name + "=";
						var cookieArray = document.cookie.split(';');
					
						for( var h = 0; h < cookieArray.length; h++ ) {
					
							var c = cookieArray[h];
					
							while (c.charAt(0)==' ') c = c.substring(1,c.length);
					
							if (c.indexOf(n) == 0) return c.substring(n.length,c.length);
					
						}
					
						return null;

					}


					// ##### END CHANGE TEXT SIZE JAVASCRIPT ##########################

					// ##### FUNCTION: addUnloadEvent
					// #####  PURPOSE: appends a function to the window.unonload event handler 
					function addUnloadEvent(func) {
						var oldonunload = window.onunload;
						if (typeof window.onunload != 'function') {
							window.onunload = func;
						} else {
							window.onunload = function() {
								if (oldonunload) {
									oldonunload();
								}
								func();
							}
						}
					}

					// ##### FUNCTION: addLoadEvent
					// #####  PURPOSE: appends a function to the window.onload event handler 
					function addLoadEvent(func) {
						var oldonload = window.onload;
						if (typeof window.onload != 'function') {
							window.onload = func;
						} else {
							window.onload = function() {
								if (oldonload) {
									oldonload();
								}
								func();
							}
						}
					}
			
			
					// ######################################################################
					// ##### SMART NAVIGATION VARIABLE DECLARATIONS
			
					// ##### ALLOW_REFRESH: set to true for back-button compatibility.  set to false for fastest response time. ##### 
					var ALLOW_REFRESH = true;
			
					// ##### VISIBILITY_CLASS_NAME: the class for the list items that will be shown by default.  This class is
					// ##### predefined by smart_navigation.  It is also used within the css.
					var VISIBILITY_CLASS_NAME = "show";
			
					// ##### MORE_LINK_LASS_NAME: the class of the list item which the user clicks on to show all the links.
					var MORE_LINK_CLASS_NAME = "more";
			
					// ##### MORE_LINK_TEXT: the text displayed for the "more" links.
					var MORE_LINK_TEXT = "More ...";
			
					// ##### BACK_LINK_CLASS_NAME: the class of the anchor tag which the user click on to return back to the main content.
					var BACK_LINK_CLASS_NAME = "back";
			
					// ##### BACK_LINK_TEXT: the text displayed for the "back" link.
					var BACK_LINK_TEXT = "Back";
			
					// ##### CONTENT_MAIN_ID: the ID of the parent node to the content body.
					var CONTENT_MAIN_ID = "content_main";
			
					// ##### CONTENT_BODY_ID: the ID of the actual content which is displayed on the page.
					var CONTENT_BODY_ID = "content_body";
			
					// ##### SMART_NAVIGATION_ID: the ID of the smart_navigation element.
					var SMART_NAVIGATION_ID = "smart_navigation";
					var STAYWELL_NAVIGATION_ID = "staywell_navigation";
			
					// ##### SUBLIST_CLASS_NAME: the class name of the sublists inside each list-item of the main smart_navigation list.
					var SUBLIST_CLASS_NAME= "sub";
			
					// ##### VISIBLE_SMART_CLASS_NAME: the class name of the element which holds the visible smart nav links for the current "more" section.
					var VISIBLE_SMART_CLASS_NAME = "visible_smart";
			
			
					// ######################################################################
					// ##### SMART NAVIGATION FUNCTION DECLARATIONS
			
					// ##### show_content_body: displays the content body area of the page.
					function show_content_body() { 
						document.getElementById(CONTENT_BODY_ID).style.display = "block"; 
						var graph_wrapper = document.getElementById('content_graph_wrapper');
						if (graph_wrapper != null) {
							graph_wrapper.style.display = "block"; 
						}
					}
			
					// ##### hide_content_body: hides the content body area of the page.
					function hide_content_body() { 
						document.getElementById(CONTENT_BODY_ID).style.display = "none"; 
						var graph_wrapper = document.getElementById('content_graph_wrapper');
						if (graph_wrapper != null) {
							graph_wrapper.style.display = "none"; 
						}
					}
			
					// ##### check_smart_navigation: checks to see if any "more" links need to be created for the smart navigation lists.
					function check_smart_navigation() {
			
						var list = document.getElementById(SMART_NAVIGATION_ID).getElementsByTagName("ul");
						for (var i = 0; i < list.length; i++) if (list[i].className == SUBLIST_CLASS_NAME) create_more_link(list[i], list[i].parentNode.getAttribute("id"));
						if($(STAYWELL_NAVIGATION_ID)){
							list = document.getElementById(STAYWELL_NAVIGATION_ID).getElementsByTagName("ul");
							for (i = 0; i < list.length; i++) if (list[i].className == SUBLIST_CLASS_NAME) create_more_link(list[i], list[i].parentNode.getAttribute("id"));
						}

					}
			
					// ##### remove_visible_links: deletes any elements within the main content area that were created by a "more" link.
					function remove_visible_links() { 
			
						var divs = document.getElementById(CONTENT_MAIN_ID).getElementsByTagName("div");
						for (var i = 0; i < divs.length; i++) if (divs[i].className == VISIBLE_SMART_CLASS_NAME) document.getElementById(CONTENT_MAIN_ID).removeChild(divs[i]); 
					
					}
			
					// ##### create_more_link: checks for hidden links in a list, creates the a more link at the end of a list of hidden links.
					function create_more_link(sublist, category_id) {
			
						var has_hidden_links = false;
						var items = sublist.getElementsByTagName("li");
			
						// ##### Assume that any links without the VISIBILITY_CLASS_NAME are hidden.
						// ##### if any links without the visibility class name are found, then assume
						// ##### that a more link is required.
						for (var i = 0; i < items.length; i++) {
							if (items[i].className != VISIBILITY_CLASS_NAME) {
								has_hidden_links = true;
							}
						}
			
						// ##### if there are any hidden links,
						// ##### create a new list-item for the more link.
						if (has_hidden_links) {
			
							var more_link = document.createElement("a");
							var more_text = document.createTextNode(MORE_LINK_TEXT);
			
							// ##### create the URL for the more link
							var more_link_href = build_more_link(category_id);
							more_link.setAttribute("href", more_link_href);
			
							// ##### GLOBAL BEHAVIOR SWITCH #####
							// ##### if ALLOW_REFRESH is false, NO back-button functionality
							if (ALLOW_REFRESH == false) more_link.onclick = function() {
									hide_content_body();
									remove_visible_links();
									show_more(category_id);
									return false;
							}
			
							// ##### Add the text inside the anchor tag.
							more_link.appendChild(more_text);
			
							// ##### create the list item parent for the anchor tag.
							var more_list_item = document.createElement("li");
							more_list_item.appendChild(more_link);
							more_list_item.className = MORE_LINK_CLASS_NAME;
			
							// ##### attach the more link list item to the end of the list.
							sublist.appendChild(more_list_item);
						}
			
					}
			
					// ##### show_more: displays a duplicate list of links in the main content area
					// ##### includes creation of the back anchor tag which is used to revert back to the original document state.
					function show_more(category_id) {
			
						// ##### create dynamic visible id
						var visible_id = category_id + "_visible";
			
						// ##### create a duplicate set of related links.
						var links = document.getElementById(category_id).getElementsByTagName("ul")[0].cloneNode(true);
			
						// ##### remove the existing "more" link from the clone.
						links.removeChild(links.lastChild);
			
						// ##### create the division which will be used to house the duplicate list.
						var visible_smart = document.createElement("div");
						visible_smart.setAttribute("id", visible_id);
						visible_smart.appendChild(links);
						visible_smart.className = VISIBLE_SMART_CLASS_NAME;
			
						// ##### create the back link
						var back_link = document.createElement("a");
						var back_text = document.createTextNode(BACK_LINK_TEXT);
						back_link.appendChild(back_text);
						back_link.className = BACK_LINK_CLASS_NAME;
						var back_link_href = build_back_link(category_id);
						back_link.setAttribute("href", back_link_href);
			
						// ##### GLOBAL BEHAVIOR SWITCH #####
						// ##### if ALLOW_REFRESH is false, NO back-button functionality
						if (ALLOW_REFRESH == false) back_link.onclick = function() {
								remove_visible_links();
								show_content_body();
								return false;
						}
			
						// ##### attach the back link just below the duplicate list inside the housing division.
						visible_smart.appendChild(back_link);
			
						// ##### attach the housing division to the bottom of the main content area.
						document.getElementById(CONTENT_MAIN_ID).appendChild(visible_smart);

						var content_divisions = document.getElementById(CONTENT_MAIN_ID).getElementsByTagName("div");

						for (var i = 0; i < content_divisions.length; i++) {
							if (content_divisions[i].className == "content_sub") {
								document.getElementById(CONTENT_MAIN_ID).appendChild(visible_smart);
								document.getElementById(CONTENT_MAIN_ID).appendChild(content_divisions[i]);
								i = content_divisions.length;
							}
						}

						
					}
			
					// ##### check_query: parse the current query string and search for the "more" parameter.
					// ##### if found, perform basic functions for displaying the more links.
					function check_query() {
			
						// ##### grab the query string (everything from "?...." in the URL)
						var searchString = document.location.search;
			
						// ##### strip off the leading '?'
						searchString = searchString.substring(1);
						var nvPairs = searchString.split("&");
			
						// ##### Loop through all name=value pairs
						for (i = 0; i < nvPairs.length; i++) {
			
							// ##### split up the pairs and assign variables
							var nvPair = nvPairs[i].split("=");
							var name = nvPair[0];
							var value = nvPair[1];
			
							// ##### look for the pair with the name == "more"
							if (name == "more") {
			
								// ##### perform basic functions for displaying the
								// ##### more links.
								hide_content_body();
								remove_visible_links();
								show_more(value);
								
								// ##### end the loop
								i = nvPairs.length;
							}
						}
					}
			
					// ##### rebuild_original_query: takes in a query string
					// ##### returns query string without: "more=...."
					// ##### WORKS FOR BOTH STATIC AND DYNAMIC PUBLISHING
					function rebuild_original_query(existingQuery) {
			
						// ##### initialize original query place holder.
						var original_query = "";
			
						if (existingQuery == "") return original_query;
						else {
			
							// ##### remove question mark.
							existingQuery = existingQuery.substring(1);
			
							// ##### split up query string into name=value pairs
							var nvPairs = existingQuery.split("&");
			
							// ##### Rebuild the query string WITHOUT more parameter.
							for (i = 0; i < nvPairs.length; i++) {
			
								// ##### split the pair and assign the variables.
								var nvPair = nvPairs[i].split("=");
								var name = nvPair[0];
								var value = nvPair[1];
			
								// ##### exclude "more" parameter in the rebuild.
								if (name != "more") {
									original_query += name+"="+value+"&";
								}
							}
						
							// ##### return original query without trailing ampersand.
							if (original_query != "") return "?" + original_query.substring(0, original_query.length-1);
							else return "";
			
						}
			
					}
			
					// ##### build_back_link: returns the original link to the document without "more" query string parameters.
					// ##### WORKS FOR BOTH STATIC AND DYNAMIC PUBLISHING
					function build_back_link() {
			
						// ##### create place holder for final url
						var myURL = "";
			
						// ##### split the URL in half at the question mark
						var splitURL = document.URL.split("?");
			
						// ##### if no question mark, this means there's no query string to worry about.
						// ##### so, set the final url to the current url.
						if (splitURL.length == 1) myURL = document.URL;
						else {
			
							// ##### grab the original query, minus any pre-existing "more" parameters.
							var myQuery = rebuild_original_query(document.location.search);
							
							// ##### set up the rest of the URL including the any sort of original query string.
							myURL = splitURL[0] + myQuery;
			
						}
			
						return myURL;
					}
			
					// ##### build_more_link: returns the more link including dynamic query string with "more" parameter.
					// ##### WORKS FOR BOTH STATIC AND DYNAMIC PUBLISHING
					function build_more_link(more) {
			
						// ##### create place holder for final url
						var myURL = "";
			
						// ##### split the URL in half at the question mark
						var splitURL = document.URL.split("?");
			
						// ##### if no question mark, the length of the split array will be one.
						// ##### this means there's no query string to worry about.
						// ##### so, set the final url to the current url and append a small query string to invoke the more link.
						if (splitURL.length == 1) myURL = document.URL+"?more="+more;
						else {
			
							// ##### grab the original query, minus any pre-existing "more" parameters.
							var myQuery = rebuild_original_query(document.location.search);
			
							// ##### set up the rest of the URL.
							myURL = splitURL[0];
			
							// ##### If there still isn't any query string, append the single parameter
							// ##### (The only time this would happen is if the original URL ended in only a question mark.)
							if (myQuery == "") myURL += "?more="+more;
			
							// ##### append the query string to the url, including the additional parameter
							else myURL += myQuery+"&more="+more;
			
						}
			
						// ##### return the final url
						return myURL;
					}
			

					function popupEmailWindow(pagename, pageurl, sitename) {
    						top.thisWin= window.open("/EmailPage/email_this_page.jsp?siteName=" + escape(sitename) + "&pageDisplayName=" + pagename + "&pageURL=" + escape(pageurl),"thisPage","scrollbars=1,resizable=1,menubar=0,toolbar=0,width=640,height=500");
    						if(!top.thisWin.closed) top.thisWin.focus();
					}

					function popUp(URL, x, y) {
						day = new Date();
						id = day.getTime();
						options = "toolbar=no, scrollbars=no, location=no, statusbar=no, menubar=no, resizable=no, width=" + x + ", height=" + y + ", left=570, top=150";
						window.open(URL, id, options);
					}

					function eHA_escapeSingleQuote(strVal) {
						sRetVal = new String(strVal);
						sRetVal = sRetVal.replace(/'/g,"\\'");
						return sRetVal;
					}

					function eHA_escapeDoubleQuote(strVal) {
						sRetVal = new String(strVal);
						sRetVal = sRetVal.replace(/\"/g,/\\"/);
						return sRetVal;
					}

					function clearField(theField, defaultText) {
						if (theField.value == defaultText) {
							theField.value = "";
						}
					}

					function revertField(theField, defaultText) {
						if (theField.value == "") {
							theField.value = defaultText;
						}
					}

					function returnPageURL() {
						// alert(document.location.href);
						return document.location.href
					}

		
					// used with greystone newsletters.
					function rotateNodes() {
		         			var x = document.getElementsByTagName("div");
         					var i;
         					for (i = 0; i < x.length; i++) {
		            			    if (x[i].className == "news_online_section") {
        	      				       var theNodeInQuestion = x[i];
	            				    }
						}
		
	        				if (theNodeInQuestion != null) {
							theNodeInQuestion.parentNode.parentNode.appendChild(theNodeInQuestion);
        					}
						
					}

					function bookmarkPage(bookmarkURL,bookmarkTitle){
						try{
							window.external.AddFavorite(bookmarkURL, bookmarkTitle);
						}catch(e){
							alert("To bookmark this page please type Ctrl+D on your keyboard.");
						}
					}

					
					function page_toolbar() {
						var text_link = document.getElementById("page_toolbar_text").getElementsByTagName("a")[0];
						var print_link = document.getElementById("page_toolbar_print").getElementsByTagName("a")[0];
						
						var bookmark_link = $$("#page_toolbar_bookmark a")[0];
						
						bookmark_link.onclick = function(){
							var thisURL = document.location.href;
							var thisTitle = document.title;
							bookmarkPage(thisURL,thisTitle);
							return false;
						}

						text_link.onclick = function () {
							toggle_text_size(this);
							return false;
						}

						print_link.onclick = function () {
							window.print();
							return false;
						}
					}

/* ##### GLOBAL VARIABLES ##### */
var SPOTLIGHT_RANDOM = false;
var SPOTLIGHT_NEXT_LINK_CLASSNAME = "next";
var SPOTLIGHT_NEXT_LINK_TEXTNODE = "Next";
var SPOTLIGHT_PREV_LINK_CLASSNAME = "previous";
var SPOTLIGHT_PREV_LINK_TEXTNODE = "Previous";
var SPOTLIGHT_VISIBLE_CLASSNAME = "visible_spotlight";
var SPOTLIGHT_HIDDEN_CLASSNAME = "hidden_spotlight";
var SPOTLIGHT_NAV_CLASSNAME = "spotlight_nav";

function hide_node(e) { e.className = SPOTLIGHT_HIDDEN_CLASSNAME; }
function show_node(e) { e.className = SPOTLIGHT_VISIBLE_CLASSNAME; }

// function setup_arrows(spotlight_id) {

// 	var spotlight_nav_id = spotlight_id+"_nav";
// 	var content_spotlight = document.getElementById(spotlight_id);
// 	var content_spotlight_nav = document.createElement("ul");
// 	var next = document.createElement("li");
// 	var prev = document.createElement("li"); 
// 	var next_link = document.createElement("a");
// 	var prev_link = document.createElement("a");
// 	var next_text = document.createTextNode(SPOTLIGHT_NEXT_LINK_TEXTNODE);
// 	var prev_text = document.createTextNode(SPOTLIGHT_PREV_LINK_TEXTNODE);
// 	
// 	prev_link.appendChild(prev_text);
// 	prev.appendChild(prev_link);

// 	next_link.appendChild(next_text);
// 	next.appendChild(next_link);

// 	content_spotlight_nav.appendChild(next);
// 	content_spotlight_nav.appendChild(prev);
// 	content_spotlight_nav.setAttribute("id", spotlight_nav_id);
// 	content_spotlight_nav.className = SPOTLIGHT_NAV_CLASSNAME;

// 	next_link.className = SPOTLIGHT_NEXT_LINK_CLASSNAME;
// 	next_link.setAttribute("href", '#');

// 	prev_link.className = SPOTLIGHT_PREV_LINK_CLASSNAME;
// 	prev_link.setAttribute("href", '#');
// 	
// 	next_link.onclick = function() {
// 		go_forward(spotlight_id);
// 		return false;
// 	}
// 	
// 	prev_link.onclick = function() {
// 		go_backward(spotlight_id);
// 		return false;
// 	}
// 	
// 	hide_spotlights(content_spotlight);
// 	content_spotlight.appendChild(content_spotlight_nav);
// 						
//}


// required prototype
function setup_arrows(spotlight_id){
	var numSpotlights = $$("#"+spotlight_id+" ul li").length;
	
	var ul = new Element('ul', { 'id':spotlight_id+'_nav','class': 'spotlight_nav' });
	
	for(i=0;i<numSpotlights;i++){
		var li = new Element('li',{'id':"spotlight_nav_"+(i+1)});
		var a = new Element('a', { href:'#'}).update(i+1);
		li.appendChild(a);
		ul.appendChild(li);
	}
	
	$$("#"+spotlight_id+" ul li h4 a").each(function(element){
		var moreLink = new Element('a',{ 'class':'spotlight_more_link', href:element.href });
		moreLink.update("more");
		element.up("li").appendChild(moreLink);
	});
	
	
	hide_spotlights($(spotlight_id),false);
	$(spotlight_id).insert({'bottom':ul});
	$("spotlight_nav_1").addClassName("sel");
	$$("#"+spotlight_id+" .spotlight_nav li").each(function(element){
		element.onclick = function(){
			hide_spotlights($(spotlight_id),true);
			show_spotlight(element.id.replace("nav_",""));
			
			clearTimeout(theInterval);
			start_intervals();
			
			return false;
		}
	});
	
}

function show_spotlight(this_spotlight_id){
	show_node($(this_spotlight_id));
	select_button(this_spotlight_id.replace("_","_nav_"));
}

function select_button(button_id){
	var buttons = $(button_id).up("ul").getElementsByTagName("li");
	for(i=0;i<buttons.length;i++){
		buttons[i].removeClassName("sel");
	}
	$(button_id).addClassName("sel");
}


function hide_spotlights(e,no_show) {

	var spotlights = e.down("ul").getElementsByTagName("li");

	if ((spotlights != null) && (spotlights.length > 0)) {

		for (var i = 0; i < spotlights.length; i++){
			spotlights[i].id = "spotlight_"+(i+1);
			hide_node(spotlights[i]);
		}
		if (SPOTLIGHT_RANDOM) var current_spotlight = get_rand_node(spotlights[0]);
		else var current_spotlight = spotlights[0];

		if(no_show==false){
			show_node(current_spotlight);
		}
	
	}

}
	
function get_visible_spotlight(spotlight_id) {

	var result = false;
	var content_spotlight = document.getElementById(spotlight_id);
	var spotlights = content_spotlight.getElementsByTagName("ul")[0].getElementsByTagName("li");

	if ((spotlights != null) && (spotlights.length > 0)) {

		for (var i = 0; i < spotlights.length; i++) {
			var spotlight = spotlights[i];
			if (spotlight.className == "visible_spotlight") {
				var result = spotlight;
				i = spotlights.length+1;
			}
		}

		if (result) return result;
		return spotlights[0];
	
	} 

	return false;

}

function get_next_node(e) {

	if (SPOTLIGHT_RANDOM) return get_rand_node(e);

	var spotlights = e.parentNode.getElementsByTagName("li");

	if ((spotlights != null) && (spotlights.length > 0)){
		for (var i = 0; i < spotlights.length; i++){
			if (spotlights[i] == e) {
				if (i == spotlights.length-1) i = -1;
				var result = spotlights[i+1]; 
				i = spotlights.length+1;
			}
		}
	
	}else{
		var result = e.parentNode.firstChild;
	}
	
	return result;

}

function get_prev_node(e) {

	if (SPOTLIGHT_RANDOM) return get_rand_node(e);

	var spotlights = e.parentNode.getElementsByTagName("li");

	if ((spotlights != null) && (spotlights.length > 0)){
		for (var i = spotlights.length-1; i >= 0; i--){
			if (spotlights[i] == e) { 
				if (i == 0) i = spotlights.length;
				return spotlights[i-1]; 
			}
		}
	}
	return e.parentNode.firstChild;

}

function get_rand_node(e) {

	var result = e;
	var spotlights = e.parentNode.getElementsByTagName("li");

	if ((spotlights != null) && (spotlights.length > 0)) {

		while (result == e) {
			var ran_unrounded = Math.random() * spotlights.length;
			var random_node = Math.floor(ran_unrounded);
			result = spotlights[random_node];
		}

		return result;

	}
						
	return false;

}

function go_forward(spotlight_id) {
	var current_node = get_visible_spotlight(spotlight_id);
	hide_node(current_node);
	show_node(get_next_node(current_node));
	if($(spotlight_id).down(".spotlight_nav .sel").next("li")){
		$(spotlight_id).down(".spotlight_nav .sel").next("li").addClassName("sel");
		$(spotlight_id).down(".spotlight_nav .sel").removeClassName("sel");
	}else{
		$(spotlight_id).down(".spotlight_nav li").addClassName("sel");
		$(spotlight_id).down(".spotlight_nav .sel").next("li.sel").removeClassName("sel");
	}
}

function go_backward(spotlight_id) {
	var current_node = get_visible_spotlight(spotlight_id);
	hide_node(current_node);
	show_node(get_prev_node(current_node));
	if($(spotlight_id).down(".spotlight_nav .sel").previous("li")){
		$(spotlight_id).down(".spotlight_nav .sel").previous("li").addClassName("sel")
		$(spotlight_id).down(".spotlight_nav .sel").next("li").removeClassName("sel");
	}else{
		$(spotlight_id).down(".spotlight_nav li:last-child").addClassName("sel")
		$(spotlight_id).down(".spotlight_nav .sel").removeClassName("sel");
	}
}
var theInterval = '';
var all_interval_expressions = '';
function start_intervals() {
	theInterval = window.setInterval(all_interval_expressions, 10000); 
}
addLoadEvent(start_intervals);



/*##############################################
############ js for dropdown Lists  ############
############ 11/21/2008 (bug 536)   ############
################################################
*/

addLoadEvent(dropdownEvents);

var dropdownHeight = 250;

function dropdownEvents(){
	$$(".dropdown_list_wrapper h4").each(function(element){
		element.onclick = function(){
			dropdownRelease();
			if(element.offsetTop+dropdownHeight-document.viewport.getScrollOffsets().top+220>document.viewport.getDimensions().height){
				element.next("ul").style.top = "auto";
				element.next("ul").style.bottom = "15px";
			}else{
				element.next("ul").style.top = "15px";
				element.next("ul").style.bottom = "auto";
			}
			element.next("ul").addClassName("sel");
			element.up(".dropdown_list_wrapper").style.position = "relative";
			if(element.next("ul").offsetHeight>dropdownHeight){
				element.next("ul").style.height = dropdownHeight+"px";
			}
		}
	});
}

function dropdownRelease(){
	$$(".dropdown_list_wrapper ul").invoke("removeClassName","sel");
	$$(".dropdown_list_wrapper").each(function(element){
		element.style.position = "static";
	});
}

function dropdownClickHandler(e){
	var releaseLists = true;
	if(Event.element(e).up(".dropdown_list_wrapper")){
		releaseLists = false;
	}
	if(releaseLists){
		dropdownRelease();
	}
}


function createNewsButtons(featured_news_id){
	if($(featured_news_id)){
		var newsButtonUL = new Element('ul', { 'class': 'featured_news_nav' });
		var i = 1;
		var newsLIs = $$("#"+featured_news_id+" ul li h3 a").each(function(element){
			element.up("li").id = "featured_news_"+i;
			var thisLI = new Element('li', { 'id':"featured_news_nav_"+i });
			var thisA = new Element('a', { href:'#' });
			thisA.update(element.innerHTML);
			i++;
			thisLI.appendChild(thisA);
			newsButtonUL.appendChild(thisLI);
		});
		
		$$(".featured_news")[0].insertBefore(newsButtonUL,$$(".featured_news ul")[0]);
		
		$$("#"+featured_news_id+" .featured_news_nav a").each(function(element){
			element.onclick = function(){
				clearNewsSelect(featured_news_id);
				this.up("li").addClassName("sel");
				$(this.up("li").id.replace("_nav_","_")).addClassName("sel");
				return false;
			}
		});
		
		var firstLI = $$("#"+featured_news_id+" .featured_news_nav li")[0];
		firstLI.addClassName("sel");
		$(firstLI.id.replace("_nav_","_")).addClassName("sel");
	}
}

function clearNewsSelect(featured_news_id){
	$$("#"+featured_news_id+" ul li").invoke("removeClassName","sel");
}


function Calendar_filter(event_category){
	if(event_category=="null"){
		$$("#calendar table div.event").each(function(element){
			element.show();
		});
	}else{
		$$("#calendar table div.event").each(function(element){
			if(event_category.indexOf(":")!=-1){
				if(element.hasClassName("event_category_"+event_category.replace(/ /g,"_"))){
					element.show();
				}else{
					element.hide();
				}
			}else{
				var showThisEvent = false;
				// this event_category is a "parent" category
				$w(element.className).each(function(thisClass){
					if(thisClass.indexOf(event_category.replace(/ /g,"_"))!=-1){
						showThisEvent = true;
					}
				});
				if(showThisEvent){
					element.show();
				}else{
					element.hide();
				}
			}
		});
	}
}



function Calendar_addCalendarToolsEvents(){
	if($('calendar_tools')){
		$('event_filter').onchange = function(){
			Calendar_filter(this.options[this.options.selectedIndex].value);
			return false;
		}
	}
}







var LandingPageSpotlightLimit = 4;
LandingPageSpotlightLimit--;

var LandingPageSpotlightPosition = 0;

function LandingPageSpotlights_HideAll(elementID){
	$(elementID).down("ul").childElements().invoke("hide");
	//hide navigation
	var elementIDnew = elementID.split("featured_spotlights_")[1];
	var spotlightLIsnew = $('featured_spotlights_'+elementIDnew).down("ul").childElements().length;
	if(LandingPageSpotlightPosition<0){
		 $('featured_spotlights_'+elementIDnew+'spotlight_nav_prev').down("a").className="prev hide";
		 $('featured_spotlights_'+elementIDnew+'spotlight_nav_next').down("a").className="next";
	}
	else $('featured_spotlights_'+elementIDnew+'spotlight_nav_prev').down("a").className="prev";
	
	if(LandingPageSpotlightPosition>(spotlightLIsnew.length-LandingPageSpotlightLimit-1)){
		$('featured_spotlights_'+elementIDnew+'spotlight_nav_next').down("a").className="next hide";
		$('featured_spotlights_'+elementIDnew+'spotlight_nav_prev').down("a").className="prev";
	}
	else $('featured_spotlights_'+elementIDnew+'spotlight_nav_next').down("a").className="next";

}

function LandingPageSpotlights_Previous(el){
	var elementID = el.up("div").id;
	LandingPageSpotlights_HideAll(elementID);
	var spotlightLIs = $(elementID).down("ul").childElements();
	//var spotlightLIs = $$("#"+elementID+" ul li");
	
	LandingPageSpotlightPosition--;
	if(LandingPageSpotlightPosition<0){
		LandingPageSpotlightPosition = 0;
				$(elementID+'spotlight_nav_prev').down("a").className="prev hide";

	}
	
	for(i=LandingPageSpotlightPosition;i<spotlightLIs.length;i++){
		if(i<=(LandingPageSpotlightLimit+LandingPageSpotlightPosition)){
			spotlightLIs[i].show();
		}
	}
}

function LandingPageSpotlights_Next(el){
	var elementID = el.up("div").id;
	LandingPageSpotlights_HideAll(elementID);
	var spotlightLIs = $(elementID).down("ul").childElements();
	
	LandingPageSpotlightPosition++;
	if(LandingPageSpotlightPosition>(spotlightLIs.length-LandingPageSpotlightLimit-1)){
		LandingPageSpotlightPosition = spotlightLIs.length-LandingPageSpotlightLimit-1;
		$(elementID+'spotlight_nav_next').down("a").className="next hide";
	}
	for(i=LandingPageSpotlightPosition;i<spotlightLIs.length;i++){
		if(i<=(LandingPageSpotlightLimit+LandingPageSpotlightPosition)){
			spotlightLIs[i].show();
		}
	}
}

function LandingPageSpotlights_MakeNav(elementID){

	if($(elementID)){
		var spotlightLIs = $$("#"+elementID+" ul li");
		for(i=0;i<spotlightLIs.length;i++){
			if(i>LandingPageSpotlightLimit){
				spotlightLIs[i].hide();
			}
		}
		
		var ul_nav = new Element('ul', { 'id':elementID+'_nav','class': 'spotlight_nav' });
		var li_prev = new Element('li',{'id':elementID+"spotlight_nav_prev",'class':'prev'});
		var a_prev = new Element('a', { href:'#','title':'previous','class':'prev hide'}).update("previous");
		li_prev.appendChild(a_prev);
		ul_nav.appendChild(li_prev);
				
		var li_next = new Element('li',{'id':elementID+"spotlight_nav_next",'class':'next'});
		var a_next = new Element('a', { href:'#','title':'next'}).update("next");
		li_next.appendChild(a_next);
		ul_nav.appendChild(li_next);

			$(elementID).appendChild(ul_nav);
			

		//$(elementID).insert({'bottom':ul_nav});
		$(elementID+'spotlight_nav_prev').down("a").onclick = function(element){
			LandingPageSpotlights_Previous(this);
			return false;
		};
		
		$(elementID+'spotlight_nav_next').down("a").onclick = function(element){
			LandingPageSpotlights_Next(this);
			return false;
		};
		
	}
	return false;
}

/*
function braftonShowHideList(){
	if($$('#content_body #health_discovery_archive.Navigation ul li .see_more a')[0]){
		$$('#content_body #health_discovery_archive.Navigation ul li h3.see_more a').each(function(element){
			element.observe("click", function(){
				if(this.up().hasClassName('hide')){
					this.update('See more');
					this.up().addClassName('see_more');
					this.up().removeClassName('hide');
					this.up().next().setStyle({display:'none'});
				}
				else {
					this.update('See less');
					this.up().addClassName('hide');
					this.up().removeClassName('see_more');
					this.up().next().setStyle({display:'block'});
				}
			});
		});
	}
}


addLoadEvent(braftonShowHideList);
*/




/*
The following addLoadEvent command should be in Common/javascript


*/

/*
addLoadEvent(function(){
	FindADoctor_addSearchPageEvents("includes/typeahead.php");
});
*/

var FindADoctor_loadingImage = $CE("img",{'src':'/eHA_files/images/ajax/big.gif','alt':'Please Wait.'});
FindADoctor_loadingImage.addClassName("ajax_loading");


function FindADoctor_typeAheadJSON(FindADoctor_TypeAheadURL,typeAheadTextID,typeAheadDivID){
	var FindADoctor_dataArray = new Array();
	new Ajax.Request(FindADoctor_TypeAheadURL,
	  {
	    method:'get',
	    parameters: "postName="+typeAheadTextID,
	    onCreate: function(){
			//$(typeAheadDivID).update("<img src='/eHA_files/images/ajax/big.gif' alt='Please Wait.' class='ajax_loading' />");
	    },
	    onSuccess: function(transport){
		    FindADoctor_dataArray = (transport.responseText).evalJSON(true);
	    	// begin local autocomplete
	    	new Autocompleter.Local(typeAheadTextID,typeAheadDivID,FindADoctor_dataArray,{fullSearch:true,partialChars:2});
	    },
	    onFailure: function(){ 
			// alert('Something went wrong...');
		}
	  });
}


function FindADoctor_TypeAheadCallback(autoCompleteInput,element){
	//autoCompleteInput.value = element.innerHTML;
	//console.log(element.innerHTML);
	//console.log(autoCompleteInput.value);
	if(element.id && $("assettype") && $("assetid")){
		var assettype = element.id.split("~")[0];
		var assetid = element.id.split("~")[1];
		
		$("assettype").value = assettype;
		$("assetid").value = assetid;
		
		return true;
	}
}
	
function randomInt(startInt,endInt){
	// startInt can be positive or negative or zero
	// endInt is incremented so that the range is inclusive
	endInt++;
	var result = Math.floor(Math.random()*endInt);
	result = result + startInt;
	return result;
}


function $CE(tagName, attributes, styles){ //short for create element
	var el = document.createElement(tagName);
	if (attributes)
		$H(attributes).each(function(pair){
		      eval("el." + pair.key + "='" + pair.value + "'");
		});
	if (styles)
		$H(styles).each(function(pair){
		      el.style[pair.key] = pair.value;
		});
		
	return $(el);
}
function back_to_results(){
	history.go(-1);
}
function clearBackToResutsLink(){
	$$('.detail_back_link a').each(function(element){element.setAttribute('href','javascript:void(0)');})
	$$('#content_body .back_link a').each(function(element){element.href="javascript:void(0)";element.observe('click',function(event){history.go(-1);})});
	if(SWFAddress.getValue()=='print'){window.print();}
}
addLoadEvent(clearBackToResutsLink);

function FindADoctor_switchToTab(tab_id,link_el){
	if($$("#physician_profile .tab")[0] && $$("#profile_tab_links li")[0]){
		try{
			$$("#physician_profile .tab").invoke("removeClassName","on");
			$$("#physician_profile .tab").invoke("hide");
			$$("#profile_tab_links li").invoke("removeClassName","on");
			$(tab_id).addClassName("on");
			$(tab_id).show();
			$(link_el).up("li").addClassName("on");
		}catch(err){
	//		console.log("ERROR: "+err.description);
		}
	}
	
	return false;
}

function FindADoctor_switchMedia(tab_id,link_el){
	if($$("#physician_profile .media_tab")[0] && $$("#profile_media_tab_links li")[0]){
		try{
			$$("#physician_profile .media_tab").invoke("removeClassName","on");
			$$("#physician_profile .media_tab").invoke("hide");
			$$("#profile_media_tab_links li").invoke("removeClassName","on");
			$(tab_id).addClassName("on");
			$(tab_id).show();
			$(link_el).up("li").addClassName("on");
		}catch(err){
	//		console.log("ERROR: "+err.description);
		}
	}
	
	return false;
}	
function FindADoctor_results(val){
	$('directory_results_per_page').value=val;
	$('startindex').value='1';
	SWFAddress.setValue($$('#content_body form')[0].serialize());
	return false;
}

function FindADoctor_addSearchPageEvents() {
	//if($$('#content_body form')[0]){Physician.init();}
	if($$('body')[0].hasClassName('Find_a_Doctor')==true){
		if($$('#content_body form')[0]){Physician.init();}
	}
}
var Physician = {
	init:function(){
		//document.location.hash=SWFAddress.getValue()+'&physiciansearch';
		this.resultsUI.init();
		this.searchUI.init();
		this.uiController.init(this.resultsUI,this.searchUI);
		this.ajax.controller = this.uiController;
		this.ajax.init(this.uiController);
		this.urlChangeHandler.init();
		if(SWFAddress.getValue().length > 1){this.ajax.loadFromURL()}
	},
	uiController:{
		init:function(passResults,passSearch){
			this.results=passResults;
			this.search=passSearch;
			this.isSearchUI=true;

		},
		setUI:function(isResults){
			if(isResults==true){this.search.hide();this.results.clear();this.isSearchUI=false;}
			else{this.results.clear();this.search.show();this.isSearchUI=true;}
		},
		appendResults:function(htmlText){this.results.appendResults(htmlText);},
		showLoading:function(loadingImage){this.search.clear(loadingImage);}
	},
	searchUI: {
		init:function(){
			this.searchForm = $$('#content_body form')[0];
			this.searchForm.setAttribute('autocomplete','off');
			//this.searchForm.select('input[type=text]').each(function(element){element.setAttribute('autocomplete','false');});
			this.distanceInput=$('distance');
			this.sliderDiv=$('distance_slider');
			this.isSliderActive = false;
			this.directory = $('directory');
			this.searchForm.setAttribute('id', 'search_form_form');
			if($('advanced_search_submit')){
				$('advanced_search_submit').observe('click', function(){SWFAddress.setValue(this.searchForm.serialize());return false;}.bind(this));
			}
			if(FindADoctor_advancedToggle == true){
				$('advanced_more_options').setStyle({display:'none'});
				$('quick_search_submit').observe('click', function(){SWFAddress.setValue(this.searchForm.serialize());return false;}.bind(this));
				$('advanced_more_options_button').observe('click',this.toggleAdvancedSearch.bindAsEventListener(this));
			}
			else{this.startSlider()}
			if($('insurance_name')){
				$('insurance_name').observe('change', function(){UpdateInsurancePlan($('insurance_name').options[$('insurance_name').options.selectedIndex].value);return false;}.bind(this));
			}
		},
		toggleAdvancedSearch:function(){
			if($("advanced_more_options_button").value.indexOf("Less")!=-1){$("advanced_more_options_button").value = "View more search options";}
			else{$("advanced_more_options_button").value = "Less";}
			Effect.toggle('advanced_more_options', 'slide',{duration:0.5,afterFinish:function(){this.startSlider()}.bind(this)});
		},
		startSlider:function(){
			if(!this.isSliderActive){
				new Control.Slider(this.sliderDiv.down('.handle'), this.sliderDiv, {
					range:  $R(1,50),
					values: $R(1,50),
					sliderValue: 10,
					onSlide: function(value) {/*this.distanceInput.value=value+"miles";*/ this.distanceInput.value=value;}.bind(this),
					onChange: function(value) {/*this.distanceInput.value=value+"miles";*/ this.distanceInput.value=value;}.bind(this)
				});
				this.isSliderActive=true;
			}
		},
		show:function(){
			if(this.searchForm){
				if($('results')){
					$('results').remove();
					$('content_workspace').remove();
				}
			}
			$('content_body').insert({'top' : this.directory});
			$('content_body').insert({'top' : this.searchForm});
			//$('attention_physicians').setStyle({display:'block'});
		},
		hide:function(){
			if(this.searchForm){
				if($(this.searchForm.id)){this.searchForm.remove();}
				if($(this.directory.id)){this.directory.remove();}

			}
			//$('attention_physicians').setStyle({display:'none'});
		},
		clear:function(loadingImage){
			
			if($("results")) {$("results").update(loadingImage);}
			else{$("content_body").insert(loadingImage);}
			if($('bread_crumbs')){$('bread_crumbs').remove();}
			}
	},
	resultsUI: {
		init:function(){
		
		},
		show:function(){
		},
		clear:function(){

			//if($('results')){$('results').remove();}
			//if($('content_workspace')){$('content_workspace').remove();}
			if($('bread_crumbs')){$('bread_crumbs').remove();}
		},
		appendResults:function(htmlText){
			this.clear();
			if($$('#content_body .ajax_loading')[0]){$$('#content_body .ajax_loading')[0].remove()}
			if($('search_form_form')){
			} else {
				if($('results') ){$('results').update(htmlText);}
				else{$('content_body').insert({'top':htmlText});}
			}
			$$('#results .result .actions .favorites a').each(function(element){element.observe('click',function(){this.addItemToFavorites(element);}.bind(this));}.bind(this));
			$$('#results .result .secondary a.extra').each(function(element){element.observe('click',function(){this.showExtraDetails(element);}.bind(this));}.bind(this));
			$('filter_reset').observe('click', function(){$('startindex').value='1';SWFAddress.setValue($('filter_form').serialize());return false;});
			$$('.pagination .pagination_inner li a').each(function(element){element.observe('click',function(event){
				var element=event.element();
				element.href="javascript:void(0)";
				var paginationAParentElement = element.up('li');
				if(paginationAParentElement.hasClassName('next')==false&&paginationAParentElement.hasClassName('previous')==false&&paginationAParentElement.hasClassName('page_selected')==false){
					$('startindex').value=element.innerHTML;
					SWFAddress.setValue($('filter_form').serialize());
					//var hashValue=SWFAddress.getValue();
					// check to see if we are not on the first page
					/*if(hashValue.indexOf('startindex=')==-1){SWFAddress.setValue(hashValue+'&startindex='+element.innerHTML)}
					else{
						// This code changes the startindex in the url
						var splitHashForStartIndex=hashValue.split('&startindex=');
						if(splitHashForStartIndex[1].substring(0, 1)!='&'){
							splitHashForStartIndex[1]=splitHashForStartIndex[1].replace(splitHashForStartIndex[1].substring(0, 1),'');
						}
						SWFAddress.setValue(splitHashForStartIndex[0]+'&startindex='+element.innerHTML+splitHashForStartIndex[1]);
					}*/
				}
			});});
			$$('#results .back_link a').each(function(element){element.observe('click',function(event){Event.stop(event);SWFAddress.setValue('/');})});
			$$('.results_per_page .results_inner a').each(function(element){element.href="javascript:void(0)"});
			var sliderDiv=$('distance_slider');
			var distanceInput=$('distance');
			new Control.Slider(sliderDiv.down('.handle'), sliderDiv, {
				range:  $R(1,50),
				values: $R(1,50),
				sliderValue: 10,
				onSlide: function(value) {/*distanceInput.value=value+"miles";*/ distanceInput.value=value;}.bind(this),
				onChange: function(value) {/*distanceInput.value=value+"miles";*/ distanceInput.value=value;}.bind(this)
			});
			$$('#results ul li.result ul li.email a').each(function(element){
				element.href="javascript:void(0)";
				//alert(event);
				stOb = SHARETHIS.addEntry(
					{
						title:element.up("div").previous("h3").down("a").innerHTML.replace(/(<([^>]+)>)/ig,""),
						url:element.up("div").previous("h3").down("a").href
					},{
						button:false,
						embeds:true
					}
				);
				stOb.attachButton(element);})
		},
		showExtraDetails:function(element){
			var result_id = element.id.replace("extraButton","");
			Effect.toggle(result_id+"extra", 'blind', {duration:0.5});
			if($(result_id+"extraButton").innerHTML.indexOf("Details")!=-1){
				$(result_id+"extraButton").update("Less");
			}else{
				$(result_id+"extraButton").update("Details");
			} 
		},
		addItemToFavorites:function(element){
			var resultID=element.getAttribute('id').replace('result_a_','');
			//$("favorites").down("p").hide();
			Effect.Appear('favorites_wrapper');
			if($('result'+resultID)){
				var resultDiv=$('result'+resultID);
				var currentFavoritesCookie = PhysicianCookie.getCookie("eHA_FindADoctor_Favorites");
				if(currentFavoritesCookie){
					if(currentFavoritesCookie.length>0){currentFavoritesCookie = currentFavoritesCookie+"-"+resultID;}
					else{currentFavoritesCookie = resultID;}
					PhysicianCookie.setCookie("eHA_FindADoctor_Favorites",currentFavoritesCookie,365);
				}
				else{PhysicianCookie.setCookie("eHA_FindADoctor_Favorites",resultID,365);}
				if(!$("favorite_"+resultID)){
					resultDiv.addClassName("favorite");
					var newDIV = $CE("div",{id:"favorite_"+resultID},{display:"none"}).addClassName("favorite_item");;
					var newH4 = $CE("h4").appendChild(resultDiv.select("h3 a")[0].cloneNode(true));
					var newUL = $CE("ul");
					if(resultDiv.select(".specialty p").length>0){newUL.appendChild($CE("li",{className:"specialty"}).update(resultDiv.select(".specialty p")[0].innerHTML))}
					if(resultDiv.select(".affiliation p").length>0){newUL.appendChild($CE("li",{className:"affiliation"}).update(resultDiv.select(".affiliation p")[0].innerHTML))}
					if(resultDiv.select(".phone p").length>0){newUL.appendChild($CE("li",{className:"phone"}).update(resultDiv.select(".phone p")[0].innerHTML))}
					newDIV.appendChild(newH4);	
					newDIV.appendChild($CE("a",{href:"javascript:void(0)",className:"delete",title:"Remove this from Favorites"}).update("Remove this from Favorites").observe('click',function(event){this.removeItemFromFavorites(event)}.bind(this)));
					newDIV.appendChild(newUL);
					$('favorites').appendChild(newDIV);
					Effect.Appear("favorite_"+resultID,{duration:0.5});
				}
				else{Effect.Appear("favorite_"+resultID,{duration:0.5});}
			}
		},
		removeItemFromFavorites:function(event){
			var favoriteDiv = Event.element(event).up('.favorite_item');
			Effect.Fade(favoriteDiv.id,{duration:0.2});
			$(favoriteDiv.id.replace("favorite_","result")).removeClassName("favorite");
			var currentFavoritesCookie = PhysicianCookie.getCookie("eHA_FindADoctor_Favorites");
			if(currentFavoritesCookie){
				var resultID = favoriteDiv.id.replace("favorite_","");
				// this string manipulation may leave a trailing hyphen. that is acceptable
				currentFavoritesCookie = currentFavoritesCookie.replace(resultID,"").replace(/--/g,"-");
				PhysicianCookie.setCookie("eHA_FindADoctor_Favorites",currentFavoritesCookie,365);
			}else{
			// an error has occured.  if there is a favorite, there should be a cookie unless user agent will not allow cookies
			}
			return false;
		}
	},
	ajax: {
		init:function(controller){
			this.loadingImage = $CE("img",{'src':'/eHA_files/images/ajax/big.gif','alt':'Please Wait.'});
			this.loadingImage.addClassName("ajax_loading");
			this.uiController=controller;
		},
		loadFromURL:function(){
			if(this.uiController.isSearchUI==true){
				this.serverCall=FindADoctor_FindADoctorSubTemplateURL;
			}
			else{
				this.serverCall=FindADoctor_SearchResultsURL;
						
			}

				if(SWFAddress.getValue().indexOf('=') !=-1){
				this.uiController.setUI(true);
				new Ajax.Request(this.serverCall,{
					asynchronous:true,
					method:'get',
					parameters: SWFAddress.getValue().replace('/',''),
					onCreate: function(){this.uiController.showLoading(this.loadingImage);}.bind(this),
					onSuccess: function(transport){/*this.uiController.appendResults(transport.responseText);*/}.bind(this),
					onComplete: function(transport){this.uiController.appendResults(transport.responseText);}.bind(this),
					onFailure: function(){/*alert('Something went wrong...');*/}
				});
			}
			else{this.uiController.setUI(false);}
		}
	},
	urlChangeHandler: {
		init:function(){
			SWFAddress.addEventListener(SWFAddressEvent.INTERNAL_CHANGE, this.handleChange);
			SWFAddress.addEventListener(SWFAddressEvent.EXTERNAL_CHANGE, this.handleExtChange);},
		handleChange:function(){this.Physician.ajax.loadFromURL();},
		handleExtChange:function(event){this.Physician.ajax.loadFromURL();}
	}
}
var PhysicianCookie = {
	getCookie:function(c_name){
		if(document.cookie.length>0){
			c_start=document.cookie.indexOf(c_name + "=");
			if(c_start!=-1){
				c_start=c_start + c_name.length+1; 
				c_end=document.cookie.indexOf(";",c_start);
				if(c_end==-1){
					c_end=document.cookie.length;
				}
				return unescape(document.cookie.substring(c_start,c_end));
			}
			else{
				return false;
			}
		}
		//no cookies
		return false;
	},
	setCookie:function(c_name,value,expiredays){
		var exdate=new Date();
		exdate.setDate(exdate.getDate()+expiredays);
		document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	}
}

function SwitchToTab(tab_id,link_el){
	if($$("#content .tab")[0] && $$("#tab_links li")[0]){
		try{
			$$("#content .tab").invoke("removeClassName","on");
			$$("#content .tab").invoke("hide");
			$$("#content li a").invoke("removeClassName","on");
			$(tab_id).addClassName("on");
			$(tab_id).show();
			$(link_el).addClassName("on");
		}catch(err){
	//		console.log("ERROR: "+err.description);
		}
	}
	
	return false;
}

function UpdateInsurancePlan(insurance_name){
	new Ajax.Request(FindADoctor_InsuranceAjaxURL,{
		method:'get',
		asynchronous:true,
		parameters: {insurance_name:insurance_name},
		onCreate: function(){
			if($('insurance_plan')){
				$('insurance_plan').update('<option>Loading...</option>');
			}
		},
		onSuccess: function(transport){},
		onComplete: function(transport){
			var newOptionsObj = eval(transport.responseText);
			if($('insurance_plan')){
				$('insurance_plan').update('');
				newOptionsObj.each(function(obj){
					$('insurance_plan').insert(new Element('option',{value:obj.id}).update(obj.name));
				});
			}
		},
		onFailure: function(){/*alert('Something went wrong...');*/}
	});	
}
