try{document.domain = "scouting.org";}catch(e){} /* Sets document domain as scouting..org for crossdomain purposes */
window.onload = init; /* Runs init after page load */

/* 
Name: 		init
Purpose:	Initalizes after page load
Variables:	None
Returns:	None
*/

function init() 
{
	icon_add(); /* Runs icon_add */	
}
 
/* 
Name: 		browser_get
Purpose:	Checks for IE
Variables:	None
Returns:	if IE returns 0
			else returns 1
*/

function browser_get()
{
	var browser = navigator.userAgent;
	if(browser.indexOf("MSIE") != -1)
	{
		return 0;
	}
	else
	{
		return 1;
	}
}

/* 
Name: 		rss_load
Purpose:	Load RSS Feeds from sitecore
Variables:	rss_url - String - URL of the RSS feed
			rss_format - String - Name of the format that will be passed to rss_parse
			number - Integer - Number of items loaded from the RSS feed
Returns:	None
*/

function rss_load(rss_url,rss_format,number)
{	
	var http_request = false;
	
	if(browser_get()) // Mozilla, Safari,...
	{
		
		http_request = new XMLHttpRequest();
		(http_request.overrideMimeType)
		{
		
			// set type accordingly to anticipated content type
			http_request.overrideMimeType('text/xml');
			//http_request.overrideMimeType('text/html');
		
		}
		
	}
	else // IE
	{

		try
		{
		
			http_request = new ActiveXObject("Msxml2.XMLHTTP");
		
		}
		catch(e)
		{
		
			try
			{
			
				http_request = new ActiveXObject("Microsoft.XMLHTTP");
				
			}
			catch(e)
			{
			
			
			}
		
		}
	
	}
	
	if(!http_request)
	{
	
		alert('Cannot create XMLHTTP instance');
		return false;
	
	}

	http_request.onreadystatechange = function(){rss_parse(http_request,rss_format,number);};
	http_request.open('GET', rss_url, true);
	http_request.send(null);
}

/* 
Name: 		rss_parse
Purpose:	Interprets the RSS Feed into variables and displays HTML in the format provided
Variables:	http_request - Object - The request variable passed by rss_load
			rss_format - String - Name of the format used by the switch
			number - Integer - Number of items loaded from the RSS feed
Returns:	None
*/

function rss_parse(http_request,rss_format,number)
{
	if(http_request.readyState == 4)
	{
	
		if(http_request.status == 200)
		{
			var result = http_request.responseText;
			
			var xmlDoc;
			var x;
			var i;
			var j;
			var k;
			var node_array = [];
			var output = "";
			var rss_title = "";
			var rss_addtocontent = false;
				
			if(browser_get()) //All Others
			{
				xmlDoc = (new DOMParser()).parseFromString(result, "text/xml");
				
				rss_title = xmlDoc.childNodes[0].childNodes[1].childNodes[1].textContent.toString();
				
				x = xmlDoc.getElementsByTagName("item");
				
				if(x.length < number){number = x.length;}
				
				for(i=0;i<number;i++)
				{
					node_array[i] = {'title':'','link':'','pubDate':'','description':'','subtitle':'','large':'','small':''};
					for(j=1;j<x[i].childNodes.length;j++)
					{
						if(x[i].childNodes[j].tagName == "title"){node_array[i].title = x[i].childNodes[j].textContent;}
						else if(x[i].childNodes[j].tagName == "link"){node_array[i].link = x[i].childNodes[j].textContent;}
						else if(x[i].childNodes[j].tagName == "pubDate"){node_array[i].pubDate = x[i].childNodes[j].textContent;}
						else if(x[i].childNodes[j].tagName == "description"){node_array[i].description = x[i].childNodes[j].textContent;}
						else if(x[i].childNodes[j].tagName == "bsa:multimedia")
						{
							for(k=1;k<x[i].childNodes[j].childNodes.length;k++)
							{
								if(x[i].childNodes[j].childNodes[k].tagName == "bsa:image")
								{
									if(x[i].childNodes[j].childNodes[k].childNodes.length > 1){node_array[i].small = x[i].childNodes[j].childNodes[k].childNodes[1].textContent;}
									if(x[i].childNodes[j].childNodes[k].childNodes.length > 3){node_array[i].large = x[i].childNodes[j].childNodes[k].childNodes[3].textContent;}
								}
								else if(x[i].childNodes[j].childNodes[k].tagName == "bsa:subtitle")
								{
									node_array[i].subtitle = x[i].childNodes[j].childNodes[k].textContent;
								}
								k++;
							}
						}
						j++;
					}
				}
			}
			else //IE
			{
				xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
				xmlDoc.async = "false";
				xmlDoc.loadXML(result);
				
				rss_title = xmlDoc.childNodes[1].childNodes[0].childNodes[0].text;
				
				x = xmlDoc.getElementsByTagName("item");
				
				if(x.length < number){number = x.length;}
				
				for(i=0;i<number;i++)
				{
					node_array[i] = {'title':'','link':'','pubDate':'','description':'','subtitle':'','large':'','small':''};
					for(j=0;j<x[i].childNodes.length;j++)
					{
						if(x[i].childNodes[j].tagName == "title"){node_array[i].title = x[i].childNodes[j].text;}
						else if(x[i].childNodes[j].tagName == "link"){node_array[i].link = x[i].childNodes[j].text;}
						else if(x[i].childNodes[j].tagName == "pubDate"){node_array[i].pubDate = x[i].childNodes[j].text;}
						else if(x[i].childNodes[j].tagName == "description"){node_array[i].description = x[i].childNodes[j].text;}
						else if(x[i].childNodes[j].tagName == "bsa:multimedia")
						{
							for(k=0;k<x[i].childNodes[j].childNodes.length;k++)
							{
								if(x[i].childNodes[j].childNodes[k].tagName == "bsa:image")
								{
									if(x[i].childNodes[j].childNodes[k].childNodes.length > 0){node_array[i].small = x[i].childNodes[j].childNodes[k].childNodes[0].text;}
									if(x[i].childNodes[j].childNodes[k].childNodes.length > 1){node_array[i].large = x[i].childNodes[j].childNodes[k].childNodes[1].text;}
								}
								else if(x[i].childNodes[j].childNodes[k].tagName == "bsa:subtitle")
								{
									node_array[i].subtitle = x[i].childNodes[j].childNodes[k].text;
								}
							}
						}
					}
				}
			}
			
			switch(rss_format)
			{
				case 'scoutsinthenews':				for(i=0;i<node_array.length;i++)
													{
														output += "<h3><a href=\"" + node_array[i].link.toString() + "\" target=\"_blank\">" + node_array[i].title.toString() + "</a></h3>";
														output += "<p>" + date_format(node_array[i].pubDate.toString(),1) + "</p>";
														output += "<p>" + node_array[i].description.toString() + "</p>";
													}
													break;
				case 'scoutsinthenews_widget':		for(i=0;i<node_array.length;i++)
													{
														output += "<p><a href=\"" + node_array[i].link.toString() + "\" target=\"_blank\">" + date_format(node_array[i].pubDate.toString(),1) + " - " + node_array[i].title.toString() + "</a></p>";
													}
													break;
				case 'prospeak_general':			var current_date = "";
													var new_date = 0;
													for(i=0;i<node_array.length;i++)
													{
														if(date_format(node_array[i].pubDate.toString(),2) == current_date) //check for same date
														{
															if(new_date == 1){output += "<div class=\"monthArticles\"><ul>";new_date = 0;}
															output += "<li><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></li>";
														}
														else //first node of next date
														{
															if(i == 0){output += "<div class=\"month\">";}
															else{output += "</ul></div></div><div class=\"month\">";}
															output += "<h2>" + node_array[i].pubDate.toString().substr(8,8) + "</h2>";
															output += "<div class=\"monthFeature\">";
															output += "<img src=\"" + node_array[i].small.toString() + "\" style=\"margin:0; padding:0;\">";
															output += "<div>";
															output += "<h4><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></h4>";
															output += "<p>" + node_array[i].subtitle.toString() + " <a href=\"" + node_array[i].link.toString() + "\">READ MORE</a></p>";
															output += "</div>";
															output += "</div>";
															current_date = date_format(node_array[i].pubDate.toString(),2);
															new_date = 1;
														}
														
														if(i == (node_array.length - 1)){output += "</ul></div></div>";}
													}
													break;
				case 'prospeak_homepage':			for(i=0;i<node_array.length;i++)
													{
														if(i == 0)
														{
															var split_url = node_array[i].link.toString().split("/");
															split_url.pop();
															output += "<h3><a href=\"" + split_url.join("/") + ".aspx\">" + rss_title + " &gt;&gt;</a></h3>";
															output += "<ul>";
														}
														
														output += "<li><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></li>";
														
														if(i == (node_array.length - 1))
														{
															output += "</ul>";
															rss_format = simple_title(rss_title);
														}
													}
													break;
				case 'prospeak_accordion_widget':	rss_addtocontent = true;
													for(i=0;i<node_array.length;i++)
													{
														if(i == 0)
														{
															output += "<h5><a id=\"widget_" + simple_title(rss_title) + "_header\" href=\"#\" onclick=\"accordion_toggle('prospeak_accordion_widget','widget_" + simple_title(rss_title) + "'); return false;\">" + rss_title + "</a></h5>";
															output += "<div id=\"widget_" + simple_title(rss_title) + "\">";
															output += "<ul>";
														}
														
														output += "<li><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></li>";
														
														if(i == (node_array.length - 1))
														{
															output += "</ul>";
															output += "</div>";
															rss_format = "prospeak_accordion_widget";
														}
													}
													break;
				case 'prospeak_editors_corner':		var current_date = "";
													var new_date = 0;
													for(i=0;i<node_array.length;i++)
													{
														output += "<div class=\"month\">";
														output += "<h2>" + node_array[i].pubDate.toString().substr(8,8) + "</h2>";
														output += "<div class=\"monthFeature\" style=\"width:100%;\">";
														output += "<h4>" + node_array[i].title.toString() + "</h4>";
														output += "<p>" + node_array[i].description.toString() + "</p>";
														output += "</div></div>";
														current_date = date_format(node_array[i].pubDate.toString(),2);
														new_date = 1;
													}
													break;
				case 'prospeak_editors_corner_home':	var player_content = node_array[0].description.toString().replace("width=\"290\"","width=\"190\"");
														player_content = player_content.replace("height=\"24\"","height=\"16\"");
														player_content = player_content.replace(/<p>/gi,"");
														player_content = player_content.replace(/<\/p>/gi,"");
														output += "<p>" + node_array[0].title.toString() + "</p>";
														output += "<h6>" + player_content + "</h6>";
													break;
				case 'prospeak_trailblazers':		for(i=0;i<node_array.length;i++)
													{
														output += "<div id=\"prospeak_" + simple_title(node_array[i].title.toString()) + "\"></div>";
														rss_load(node_array[i].link.toString(),'prospeak_trailblazers_2',12);
													}
													break;
				case 'prospeak_trailblazers_2':		for(i=0;i<node_array.length;i++)
													{														
														if(i == 0) //first node of next date
														{
															output += "<div class=\"month\">";
															output += "<h2>" + node_array[i].title.toString() + "</h2>";
															output += "<ul>";
															output += "<li class=\"current\"><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].pubDate.toString().substr(8,8) + "</a></li>";
														}
														else
														{
															if(i%3 == 0){output += "</ul><ul>";}
															output += "<li><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].pubDate.toString().substr(8,8) + "</a></li>";
														}
														
														if(i == (node_array.length - 1)){output += "</ul></div>"; rss_format = "prospeak_" + simple_title(node_array[i].title.toString());}
													}
													break;
				case 'hs_front':					for(i=0;i<node_array.length;i++)
													{
														output += "<h3><a href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></h3>";
														output += node_array[i].description.toString();
														output += "<p><a href=\"" + node_array[i].link.toString() + "\">READ MORE</a></p>";
													}
													break;
				case 'hs_blog':
				case 'museum_curators_corner':		for(i=0;i<node_array.length;i++)
													{
														output += "<div id=\"BlogItem\">";
														output += "<div id=\"blog\">";
														output += "<h1>" + date_format(node_array[i].pubDate.toString(),3) + "</h1>";
														output += "<div id=\"date\">";
														output += "<div id=\"month\"><h2>" + date_format(node_array[i].pubDate.toString(),5).substr(0,3) + "</h2></div>";
														output += "<div id=\"year\"><p>" + date_format(node_array[i].pubDate.toString(),6).substr(0,2) + "<br/>" + date_format(node_array[i].pubDate.toString(),6).substr(2,2) + "</p></div>";
														output += "</div>";
														output += "</div>";
														output += "<div id=\"blogCONTENT\"><h2><a target=\"_self\" href=\"" + node_array[i].link.toString() + "\">" + node_array[i].title.toString() + "</a></h2><p>" + node_array[i].description.toString() + "</p></div>";
														output += "</div>";
													}
													break;
                                                    
                case 'healthandsafety_widget':		for(i=0;i<node_array.length;i++)
													{
														output += "<p><a href=\"" + node_array[i].link.toString() + "\" >" + node_array[i].title.toString() + "</a><br>" + node_array[i].description.toString() + "</p>";
													}
													break;
				case 'rtn_photos':					for(i=0;i<node_array.length;i++)
													{
														var split_link = node_array[i].link.toString().split("/");
														split_link.pop();
														link_url = split_link.join("/");
														link_url += ".aspx";
														output += "<a href=\"" + link_url + "\"><img class=\"daily_photos\" src=\"" + node_array[i].small.toString() + "\"><h4>" + rss_title + "</h4></a>";
													}
													rss_format = "rtn_" + simple_title(rss_title);
													break;
				case 'rtn_delegates':				for(i=0;i<node_array.length;i++)
													{
														output += "<div class=\"RTNthumb\"><a href=\"" + node_array[i].link.toString() + "\"><img class=\"daily_photos\" src=\"" + node_array[i].small.toString() + "\"><h4>" + node_array[i].title.toString() + "</h4></a></div>";
													}
													break;
			}
			if(rss_addtocontent){document.getElementById(rss_format).innerHTML += output;}
			else{document.getElementById(rss_format).innerHTML = output;}
			
		}
		else
		{
		
			//alert('There was a problem with the request.');
			
		}
		
	}
}

/* 
Name: 		date_format
Purpose:	Changes the publish date of an RSS feed into a specified format
Variables:	old_date - String - Date read from RSS feed
			format - String - Name of the format that is used by the switch
Returns:	return_date - String - The new formatted Date
*/

function date_format(old_date,format)
{
	var new_date = new Date(old_date);
	var return_date = "";
	var month_array = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	
	switch(format)
	{
		case 1:		return_date = (new_date.getMonth() + 1) + "/" + new_date.getDate() + "/" + new_date.getFullYear(); //MM/DD/YYYY string
					break;
		case 2:		return_date = (new_date.getMonth() + 1) + " " + new_date.getFullYear(); //MM YYYY string
					break;
		case 3:		if(new_date.getDate() < 10){return_date = "0" + new_date.getDate();}
					else{return_date = "" + new_date.getDate();} //DD number
					break;
		case 4:		if(new_date.getMonth() + 1 < 10){return_date = "0" + new_date.getMonth() + 1;}
					else{return_date = "" + new_date.getMonth() + 1;} //MM number
					break;
		case 5:		return_date = "" + month_array[new_date.getMonth()]; //MMM string
					break;
		case 6:		return_date = "" + new_date.getFullYear(); //YYYY
					break;
	}
	
	return return_date;
	
}

/* 
Name: 		simple_title
Purpose:	Outputs a nicename using the title. i.e. "This is scouting" would be "thisisscouting"
			Removes spaces and lowercases the string
Variables:	str - String - The title read from the RSS feed
Returns:	str - String - The new string
*/

function simple_title(str)
{
	str = str.toLowerCase();
														
	str = str.replace(/\s+/g,'');
	
	return str;
}

/* 
Name: 		pngfix
Purpose:	Fixes IE6 .png transparency issue
Variables:	None
Returns:	None
*/

function pngfix()
{

	if(navigator.appVersion.indexOf("MSIE 6") != -1)
	{
		
		var tag_array = new Array("a","b","br","div","embed","font","form","frame","h","h1","h2","h3","h4","h5","h6","i","img","iframe","li","p","select","span","strong","table","td","textarea","ul");

		var img_array = document.getElementsByTagName("img");
		
		var bg_array = new Array();
		var bg_path;
		var temp_path;
		
		var i = 0;
		var j = 0;
		
		var img_width = 0;
		var img_height = 0;
		
		for(i=0;i<img_array.length;i++) //Test for images
		{
		
			if(img_array[i].src.indexOf(".png") != -1)
			{
			
				img_width = img_array[i].offsetWidth;
				img_height = img_array[i].offsetHeight;
				
				img_array[i].style.width = img_width + "px";
				img_array[i].style.height = img_height + "px";
				
				img_array[i].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod='none',src=\'" + img_array[i].src + "\')";
				
				img_array[i].src = "/filestore/global/spacer.png";
			
			}
		
		}
		
		for(i=0;i<tag_array.length;i++) //Test for background images
		{
			
			bg_array = document.getElementsByTagName(tag_array[i]);
			
			for(j=0;j<bg_array.length;j++)
			{
				
				if(bg_array[j].style.backgroundImage.indexOf(".png") != -1)
				{
					
					bg_path = bg_array[j].style.backgroundImage;
					
					temp_path = bg_path.substr(4,bg_path.length - 2);
					
					bg_array[j].style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,sizingMethod='none',src=\'" + temp_path + "\')";
					bg_array[j].style.backgroundImage = "";
					
				}
				
			}
			
		}
	
	}

}

/* 
Name: 		icon_add
Purpose:	Adds an icon inside all link text on a page depending on the extension of the link
			Will NOT add an icon to links with the same domain as the current page
Variables:	None
Returns:	None
*/

function icon_add()
{
	
	var current_url = "" + window.location.href;

	var split_url = new Array();
	
	split_url = current_url.split("/");

	var current_domain = split_url[2];

	var i;
	
	var j;
	
	if(document.getElementById("middle-element"))
	{
		var middle_element = document.getElementById("middle-element");
		
		var a_array = middle_element.getElementsByTagName("a");
		
		var temp_href = "";
		
		var temp_extension = "";
		
		var split_href = new Array();
		
		var split_file = new Array();
		
		var split_extension = new Array();
		
		var link_image = "";
		
		for(i=0;i<a_array.length;i++)
		{

			temp_href = "" + a_array[i].href;
			
			if(temp_href != "")
			{
			
				temp_href = temp_href.toLowerCase();
		
				link_image = "html";
							
				split_href = temp_href.split("/");
		
				if(split_href[split_href.length - 1].indexOf(".") != -1 && a_array[i].innerHTML.toLowerCase().indexOf("<img") == -1 && a_array[i].href.toLowerCase().indexOf("javascript") == -1)
				{
				
					split_file = split_href[split_href.length - 1].split(".");
		
					temp_extension = split_file[split_file.length - 1];
		
					if(temp_extension.indexOf("?") != -1){split_extension = temp_extension.split("?"); temp_extension = split_extension[0];}
					if(temp_extension.indexOf("#") != -1){split_extension = temp_extension.split("#"); temp_extension = split_extension[0];}
				
					switch(temp_extension)
					{
					
						case 'doc':		
						case 'docx':		
						case 'rtf':
						case 'txt':		link_image = "word";
										break;
						case 'pdf':		link_image = "PDF";
										break;
						case 'swf':		
						case 'fla':		
						case 'swd':
						case 'flv':		link_image = "flash";
										break;
						case 'xls':		
						case 'xlsx':		
						case 'csv':
						case 'xlt':
						case 'xlw':		link_image = "excel";
										break;
						case 'ppt':		
						case 'pptx':		
						case 'pps':		link_image = "powerpoint";
										break;
						case 'zip':		
						case 'gzip':		
						case 'rar':		link_image = "zip";
										break;
                        case 'mov':		link_image = "mov";
                                        break;
                        case 'mp3':
                        case 'mp4':		link_image = "music";
										break;
                        default:		link_image = "html";
										break;
                                        
					}
					
				}
				
				if(temp_href.indexOf("mailto") != -1 && a_array[i].innerHTML.toLowerCase().indexOf("<img") == -1 && a_array[i].href.toLowerCase().indexOf("javascript") == -1)
				{
					
					link_image = "MailTo";
					
				}
		
				if(temp_href.indexOf(current_domain) == -1 && a_array[i].innerHTML.toLowerCase().indexOf("<img") == -1 && a_array[i].href.toLowerCase().indexOf("javascript") == -1)
				{
		
					a_array[i].innerHTML = a_array[i].innerHTML + " <img src=\"/filestore/global/link-" + link_image + ".gif\" border=\"0\" style=\"padding:0;vertical-align:text-bottom;\">";
					
				}
				else if(link_image != "html" && a_array[i].innerHTML.toLowerCase().indexOf("<img") == -1 && a_array[i].href.toLowerCase().indexOf("javascript") == -1)
				{
					
					a_array[i].innerHTML = a_array[i].innerHTML + " <img src=\"/filestore/global/link-" + link_image + ".gif\" border=\"0\" style=\"padding:0;vertical-align:text-bottom;\">";
					
				}
				
			}
		
		}
		
	}
	
	pngfix();
	
}

/* 
Name: 		global_bookmark
Purpose:	Opens bookmark dislog depending on the browser
Variables:	None
Returns:	None
*/

function global_bookmark()
{
	
	var url = "" + window.location.href;
	
	var title = "" + document.title;
	
	if(window.sidebar) // firefox
	{
		window.sidebar.addPanel(title, url, "");
	}
	else if(document.all)// ie
	{
		window.external.AddFavorite(url, title);
	}
	else
	{
		alert("This browser does not support this functionality.\nPlease bookmark this page using \"CTRL+D\" or \"CMD+D\".");	
	}
	
}

/* 
Name: 		widget_video_player
Purpose:	Adds a FLV player to the right column on a sitecore site and auto encodes the url of the video
Variables:	flv_url - String - The path to the .flv
Returns:	None
*/

function widget_video_play(flv_url)
{
	
	var encoded_url = encode_url(flv_url);

	var url = "/filestore/global/swf/video_player.swf?url=" + encoded_url;
	
	flash_obj = "<embed width=\"212\" height=\"131\" src=\"" + url + "\" quality=\"high\" allowScriptAccess=\"always\" allowFullScreen=\"true\" wmode=\"transparent\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed>";

	document.getElementById("widget_video_player").innerHTML = flash_obj;
	
}

/* 
Name: 		middle_video_play
Purpose:	Adds a FLV player to the content area on a sitecore site and auto encodes the url of the video
Variables:	flv_url - String - The path to the .flv
Returns:	None
*/

function middle_video_play(flv_url)
{
	
	var encoded_url = encode_url(flv_url);

	var url = "/filestore/global/swf/video_player.swf?url=" + encoded_url;
	
	flash_obj = "<embed width=\"515\" height=\"318\" src=\"" + url + "\" quality=\"high\" allowScriptAccess=\"always\" allowFullScreen=\"true\" wmode=\"transparent\" pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\"></embed>";

	document.getElementById("middle_video_player").innerHTML = flash_obj;
	
}

/* 
Name: 		rss_parse
Purpose:	Interprets the RSS Feed into variables and displays HTML in the format provided
Variables:	http_request - The request variable passed by rss_load
			rss_format - Name of the format used by the switch
			number - Number of items loaded from the RSS feed
Returns:	None
*/

function encode_url(url)
{
	
	url = encodeURIComponent(url);
	url = url.replace(".","%2E");
	url = url.replace("/","%2F");
	
	return url;
	
}

/* 
Name: 		rss_list_load (May no longer be used, cause Safari 3+ to crash)
Purpose:	A Flash object reads an RSS feed and send the output using this function to output HTML
Variables:	list - String - content from an RSS feed
			div_id - id of the target element
Returns:	None
*/

function rss_list_load(list,div_id)
{
	
	if(document.getElementById(div_id))
	{
		
		document.getElementById(div_id).innerHTML = list;
		
	}
	
}

/* 
Name: 		image_swap
Purpose:	Swaps out an image based on the url (used on Museum for the Csatari and Rockwell)
Variables:	filestore_dir - String - variable that is set outside of the file - path to filestore directory
Returns:	None
*/

function image_swap()
{
	var url = "" + window.location.href;
	var i;
	var split_url = new Array();
	split_url = url.split("/");
	var current_page = split_url[split_url.length - 1];
	var current_dir = current_page.replace(/.aspx/,"").toLowerCase();
	
	if(filestore_dir) /* Global that is set outside of the file */
	{
		var filestore_path = filestore_dir + current_dir + "/";
		var alphabet = new Array("a","b","c","d","e","f","g","h","i","j");
		
		for(i=0;i<alphabet.length;i++)
		{
			if(document.getElementById(current_dir + "_" + alphabet[i]))
			{
				document.getElementById(current_dir + "_" + alphabet[i]).src = filestore_path + alphabet[i] + image_index + ".jpg";
			}
		}
		
		if(image_index >= total_images){image_index = 1;}
		else{image_index++;}
		
		setTimeout(image_swap,2000);
	}
	
}

/* 
Name: 		prospeak_months (may no longer be used due to redesign, also crashes Safari 3+)
Purpose:	A Flash object reads an RSS feed and send the output using this function to output HTML
Variables:	content - String - content from a RSS feed
Returns:	None
*/

function prospeak_months(content)
{
    document.getElementById('prospeak_content_div').innerHTML = content;
}

/* Audio Player - DO NOT CHANGE */

/* 
Name: 		Audio Player functions - DO NOT CHANGE
Purpose:	A flash object that plays mp3 files and uses these scripts to load content
Variables:	
Returns:	
*/

var ap_instances = new Array();

function ap_stopAll(playerID)
{
	for(var i = 0;i<ap_instances.length;i++)
	{
		try
		{
			if(ap_instances[i] != playerID)
			{
				document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 1);
				if(((i+1) != playerID))
				{
					if(document.getElementById("audioplayer" + (i+1) + "_image"))
					{
						document.getElementById("audioplayer" + (i+1) + "_image").style.display = "none";
						document.getElementById("audioplayer" + (i+1) + "_image").style.visibility = "hidden";
					}
				}
			}
			else
			{
				document.getElementById("audioplayer" + ap_instances[i].toString()).SetVariable("closePlayer", 0);
				if(document.getElementById("audioplayer" + playerID + "_image"))
				{
					document.getElementById("audioplayer" + playerID + "_image").style.display = "block";
					document.getElementById("audioplayer" + playerID + "_image").style.visibility = "visible";
				}
			}
		}
		catch( errorObject )
		{
			// stop any errors
		}
	}
}

function ap_registerPlayers()
{
	var objectID;
	var objectTags = document.getElementsByTagName("embed");
	for(var i=0;i<objectTags.length;i++)
	{
		objectID = objectTags[i].id;
		if(objectID.indexOf("audioplayer") == 0)
		{
			ap_instances[i] = objectID.substring(11, objectID.length);
		}
	}
}

var ap_clearID = setInterval( ap_registerPlayers, 100 );

/* END OF Audio Player */

/* 
Name: 		show_hide
Purpose:	Displays or hides an element based on ID. Also, tracks and closes previously displayed element
Variables:	show_hide_current - String - ID of the previously displayed element
			wrapper_id - String - Passed to bg_swap - ID of the wrapper element enclosing all hide/show elements (in case there are same IDs outside of the wrapper)
			div_id - String - ID of the element that will be shown
			buttons_id - String - ID of the buttons that activate the show/hide function
			selected_div - String - Passed to bg_swap - ID of the selected element
Returns:	None
*/

var show_hide_current = "none";

function show_hide(div_id,wrapper_id,buttons_id,selected_div)
{
	if(show_hide_current != "none") //hide previous element
	{
		if(document.getElementById(show_hide_current))
		{
			document.getElementById(show_hide_current).style.display = "none";
			document.getElementById(show_hide_current).style.visibility = "hidden";
		}
	}

	if(document.getElementById(div_id)) //show new element
	{
		document.getElementById(div_id).style.display = "block";
		document.getElementById(div_id).style.visibility = "visible";
		show_hide_current = div_id; //set to previous element
	}
	
	bg_swap(wrapper_id,buttons_id,selected_div,div_id);
}

/* 
Name: 		bg_swap
Purpose:	Changes background color of the selected div
Variables:	wrapper_id - String - ID of the wrapper element enclosing all hide/show elements (in case there are same IDs outside of the wrapper)
			div_id - String - ID of the element that will be shown
			selected_div - String - Passed to bg_swap - ID of the selected element
			color_id - String - ID of the element that contains the CSS background-color
Returns:	None
*/

function bg_swap(wrapper_id,div_id,selected_div,color_id)
{
    var divs = document.getElementById(wrapper_id).getElementsByTagName("div");
    var i;
    var div_array = new Array();
    for(i=0;i<divs.length;i++)
    {
        if(divs[i].id == div_id){div_array.push(divs[i]);}
    }
    
    for(i=0;i<div_array.length;i++)
    {
        div_array[i].style.backgroundColor = "";
    }
    
	div_array[selected_div - 1].style.backgroundColor = get_style_info(color_id,"background-color");
}

/* 
Name: 		get_style_info
Purpose:	Gets the a specific property from CSS of an element
Variables:	div_id - String - ID of the element that contains the CSS property
			style_name - 
			color_id - String - ID of the element that contains the CSS background-color (i.e. background-color NOT backgroundColor)
Returns:	String - CSS Property value
*/

function get_style_info(div_id,style_name)
{
	var x = document.getElementById(div_id);
	if (browser_get())
	{
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(style_name);
	}
	else
	{
		if(style_name.indexOf("-") != -1)
		{
			style_name = style_name.replace("-","_");
			style_name = style_name.replace(style_name.substr((style_name.indexOf("_") + 1),1),style_name.substr((style_name.indexOf("_") + 1),1).toUpperCase());
			style_name = style_name.replace("_","");
		}
		var y = x.currentStyle[style_name];
	}
	return y;
}


