$(document).ready(function(){
	
	//temp fix for cancer www. subdomain issue
	$('div.press_release_listing a').attr("href", function(i, val){return val.replace("www.cancer.osu", "cancer.osu");});
	
	//Show/hide ribbon in IE7
	//if ($.browser.msie && $.browser.version.substr(0,1)<8) {
	if ($.browser.msie && parseInt($.browser.version) == 7) {
		if($('#s4-ribbonrow').children().length){
			$('#s4-ribbonrow').addClass('show');
		}else{
			$('#s4-ribbonrow').removeClass('show');
		}
	}
	
	//get page and pass it through to the authentication so we end up back on that page
	var getPage = window.location.pathname;
	$('#sign_in').attr('href', 'https://medctrstaging.osumc.edu/_layouts/authenticate.aspx?Source='+getPage);
	
	//Search specific rules
	$('.srch-sort').next('br').remove();
	
	
	// Expandable Video Gallery - as used on CPHC conference page
  	//hide all the content stuff including the target container so it can animate open
  	$('div.evg_summary').hide();
  	$('div.evg_attributes').hide();
	$('div#evg_content_display').hide();
  
  //catch all rollovers on <a> tags with the proper class
  	$("a.evg_link").hover(
	//<!-- set the mouse over behavior -->
	function() {
		//set a variable to the value of the href attribute, which equals the corresponding content
		var vSummary=$(this).attr("title");
		//set a variable to the html value of the specified container
		var vSummaryContent=$('div.'+vSummary+' div.evg_summary').html();
		//write that html into the specified container
		$('div#evg_summary_display').html(vSummaryContent);
		//write in a background to the summary
		$('div#evg_summary_display').css({"background-image":"url(/SiteCollectionImages/images/cphc/evg_summary_text_background.jpg)"});
		},
	//<!-- set the mouse out behavior -->
	function() {
		//replace the target container html with something as the default state
		$('div#evg_summary_display').html('<p></p>');
		//write in the default background to the summary
		$('div#evg_summary_display').css({"background-image":"url(/SiteCollectionImages/images/cphc/evg_summary_background.jpg)","background-color":"#fff"});

	})
	
	// catch all the clicks on links with the proper class
	$('a.evg_link').click(
	function() {
		//set a variable to the value of the href attribute, which equals the corresponding content
		var vSummary=$(this).attr("title");
		//set a variable to the html value of the specified attributes container
		var vAttributesContent=$('div.'+vSummary+' div.evg_attributes').html();
		//set a variable to the value of the video filepath
		var vV=$('div.'+vSummary+' div.evg_video a').attr("href");
		//write the appropriate content html into the specified content container
		$('div#evg_content_display').html(vAttributesContent);
		//swap out the a tag with the correct video html
		$('div#evg_content_display div.evg_video a').replaceWith('<object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="320" height="300"><param name="fileName" value="'+vV+'"><param name="autoStart" value="true"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="320" height="300" src="'+vV+'" autostart="true"></embed></object>');
		//make the generic container visible
		$('div#evg_content_display').show();
	})
	
	// Static video gallery player with links - as used on the CPHC testimonials video page
	// NOTE - targets a single player placeholder sitting on the page.
	// catch all the clicks on links with the proper class
	$('a.cm_video_link').click(
		function() {
			//set a varaible to the value of the video path
			var cmVideo=$(this).attr("href");
			//write the appopriate html into the appropriate container to display whatever video was selected
			$('div.cm_video_player img.cm_video_player_placeholder').replaceWith('<object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="320" height="300"><param name="fileName" value="'+cmVideo+'"><param name="autoStart" value="true"><param name="ShowStatusBar" value="1"><param name="CaptioningID" value="CC"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="320" height="300" src="'+cmVideo+'" autostart="true" showstatusbar="1" CaptioningID="CC"></embed></object>');
		return false;
	})
	
	// Generic Click to Play Video from Thumbnail in a sidebar type box
	// catch all the clicks on links with the proper class
	$('a.cm_video_thumb').click(
		function() {
			//set a varaible to the value of the video path
			var cmVideoThumb=$(this).attr("href");
			//write the appopriate html into the appropriate container to display whatever video was selected
			$('div.highlight_box_video').replaceWith('<object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="320" height="300" style="float:right; margin:0px 0px 10px 10px;"><param name="fileName" value="'+cmVideoThumb+'"><param name="autoStart" value="true"><param name="ShowStatusBar" value="1"><param name="CaptioningID" value="CC"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="320" height="300" src="'+cmVideoThumb+'" autostart="true" showstatusbar="1" CaptioningID="CC"></embed></object>');
			return false;
	})
	
	// Generic Click to Play Video from just any thumbnail(s)
	// set a variable to a default value so it can be incremented
	// to accommodate multiple links on the same page to different videos
	var generateID = 1;
	// catch all the clicks on links with the proper class
	$('a.cm_video_thumb_image').click(
		function() {
			//set a varaible to the value of the video path
			var cmVideoThumbImage=$(this).attr("href");
			//increment the ID of the clicked element so it's unique now
			this.id="video"+generateID++;
			//set a variable to the value of the new ID of the element
			var WhichVideo=$(this).attr('id');
			//write the appopriate html into the appropriate container to display whatever video was selected
			$('#'+WhichVideo).replaceWith('<object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="320" height="300" style="float:right; margin:0px 0px 10px 10px; clear:right;"><param name="fileName" value="'+cmVideoThumbImage+'"><param name="autoStart" value="true"><param name="ShowStatusBar" value="1"><param name="CaptioningID" value="CC"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="320" height="300" src="'+cmVideoThumbImage+'" autostart="true" showstatusbar="1" CaptioningID="CC"></embed></object>');
			return false;
	})

	
	
	// Press Release Media Player
	/*$('div.press_release_listing:first').css({'border-top':'1px dotted #e3dcc0'});
	// Find clicks on the correct element
	$('a.cm_media').click(
		function() {
			var href = $(this).attr("href");
			//check if the href has 
			if(href.match("mp3"))
			{
				var vMediaHeight="100";
			}
			else if(href.match("wmv"))
			{
				var vMediaHeight="300";
			}
			// set a variable to the href value
			var cmVideo=$(this).attr("href");
			// remove the player from all the previous instances of press releases in case another had been played already
			$('.cm_inline_video_container').remove();
			// insert the player wrapper and player code into this press release just before the appropriate p tag
			$(this).siblings("p:first").before('<div class="cm_inline_video_container"><DIV class="generic_rounded_corner_top_video"><IMG style="margin:-7px -7px 0px 0px;" alt="" src="http://medicalcenter.osu.edu/SiteCollectionImages/imgs/rounded_corners_generic.gif"></DIV><object CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" type="application/x-oleobject" width="320" height="'+vMediaHeight+'"><param name="fileName" value="'+cmVideo+'"><param name="autoStart" value="true"><param name="CaptioningID" value="CC"><embed type="application/x-mplayer2" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" width="320" height="'+vMediaHeight+'" src="'+cmVideo+'" autostart="true" CaptioningID="CC"></embed></object><div id="CC"></div><DIV class="generic_rounded_corner_bottom"><IMG style="margin:0px -7px -7px 0px;" alt="" src="http://medicalcenter.osu.edu/SiteCollectionImages/imgs/rounded_corners_generic.gif"></DIV></div>');
			// set the width so it displays correctly now that it has something in it
			$(this).siblings('.cm_inline_video_container').css({'width':'321','text-align':'left','background':'#e3dcc0'});
			$(this).siblings('.cm_inline_video_container').children('.generic_rounded_corner_top_video').css({'width':'321'});
			$(this).siblings('.cm_inline_video_container').children('.generic_rounded_corner_bottom').css({'width':'321'});
			// don't open a new window as long as javascript is enabled
			return false;
	})*/
	
	$("a.cm_media").colorbox({width:"400", height:"470", iframe:true, href:"#cboxLoadedContent"}, function() {
		var re = new RegExp("youtu(?:\.be|be\.com)/(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)");		
		var href = $(this).attr('href');
		var m = re.exec(href);
		if(m == null && (href.indexOf(".wmv") >= 0))
		{
			//is a wmv stream
			$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + href + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="320" height="300" captioningid="CC"></embed>');
			$("#cboxLoadedContent").css({"text-align":"center"});
			$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:320px; margin:0px auto 0px auto;"></div>');
		}
		else if(m.length >= 2)
		{
			$("#cboxLoadedContent").html("<iframe class=\"youtube-player\" type=\"text/html\" width=\"320\" height=\"260\" src=\"http://www.youtube.com/embed/" + m[1] + "\" frameborder=\"0\"></iframe>");
			$("#cboxLoadedContent").css({"text-align":"center"});
			$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:320px; margin:0px auto 0px auto;"></div>');
		}
		return false
	});
	
	$("a.aux_media").colorbox({width:"400", height:"380", iframe:true, href:"#cboxLoadedContent"}, function() {
		var vidID = $(this).attr('href');
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + vidID + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="320" height="300" captioningid="CC"></embed>');
		$("#cboxLoadedContent").css({"text-align":"center"});
		$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:320px; margin:0px auto 0px auto;"></div>');
		return false
	});

	
	$(".wideformat_video").colorbox({width:"710", height:"550", iframe:true, href:"#cboxLoadedContent"}, function() {
		var vidID = $(this).attr('href');
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + vidID + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="640" height="480" captioningid="CC"></embed>');
		$("#cboxLoadedContent").css({"text-align":"center"});
		return false
	});

	
	$("a.cm_maternity").colorbox({width:"500", height:"380", iframe:true, href:"#cboxLoadedContent"}, function() {
		var vidID = $(this).attr('href');
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + vidID + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" ShowStatusBar="1" width="432" height="310" captioningid="CC"></embed>');
		$("#cboxLoadedContent").css({"text-align":"center"});
		$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:320px; margin:0px auto 0px auto;"></div>');
		return false
	});

	
	$("a.colorbox1").colorbox({width:"500", height:"470", iframe:true, href:"#cboxLoadedContent"}, function() {
		var vidID = $(this).attr('href');
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + vidID + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="420" height="330" captioningid="CC"></embed>');
		$("#cboxLoadedContent").css({"text-align":"center"});
		$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:420px; margin:0px auto 0px auto;"></div>');
		return false
	});
	
	$("a.colorbox2").colorbox({width:"500", height:"400", iframe:true, href:"#cboxLoadedContent"}, function() {
		var vidID = $(this).attr('href');
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="' + vidID + '" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="420" height="330" captioningid="CC"></embed>');
		$("#cboxLoadedContent").css({"text-align":"center"});
		$("#cboxLoadedContent").append('<div id="CC" style="color:#000; font-size:12px; position:relative; top:10px; padding:0px; width:420px; margin:0px auto 0px auto;"></div>');
		return false
	});

	
	$(".youtube").colorbox({width:'645', height:'420', inline:true, href:"#cboxLoadedContent"}, function() {
			var vidID = $(this).attr('href');
			var youTubePatt = /watch\?v/;
			var result = youTubePatt.test(vidID);
			if(result == true){
				var vidID = this.href.replace('http://www.youtube.com/watch?v=', "");
				$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');
			}else{
				$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');
			}

			//var vidID = this.href.replace('http://www.youtube.com/watch?v=', "");
			//var vidID = $(this).attr('href');
			//$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');
			//$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');

	});
	
	$("#video_info_buttons li a").colorbox({width:'645', height:'420', iframe:true, href:"#cboxLoadedContent"}, function() {
			var vidID = this.href.replace('http://www.youtube.com/watch?v=', "");
			//var vidID = $(this).attr('href');
			$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');
			//$("#cboxLoadedContent").html('<object width="600" height="344"><param name="movie" value="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + vidID + '&hl=en&fs=1&autoplay=1&rel=0&color1=0x5d1719&color2=0xcd311b" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="600" height="344"></embed></object>');

	});

	
	$('#cboxOverlay, #cboxClose').click(function(){
		if ($.browser.msie) {
		$('#cboxLoadedContent embed').replaceWith('<embed style="margin:0px auto 0px auto;" src="" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" autostart=false allowscriptaccess="always" allowfullscreen="true" width="320" height="300" captioningid="CC"></embed>');
		}
	});
	
	$("img.somc_video_button").css({"cursor":"pointer"});
	$("img.somc_video_button").colorbox({width:"525", height:"520", iframe:true}, function() {
		$("#cboxLoadedContent").html('<embed style="margin:0px auto 0px auto;" src="mms://streaming1.osu.edu/media3/osumc/012610.wmv" pluginspage="http://www.microsoft.com/Windows/MediaPlayer/" type="application/x-mplayer2" allowscriptaccess="always" allowfullscreen="true" width="480" height="450" captioningid="CC"></embed>');
	});
	
	$('#portal_graphic_feature a').click( function() {
		if ($.browser.msie && $.browser.version.substr(0,1)<7) {
			var fU = $(this).attr('href');
			window.location = fU;
		}
	});
	
	//******FADING FEATURE**************
	//******for just photo with no link******
	if ($('span.fading_photos').length) {
		//set the fade time
		var FadeTime = 4000;
		//set the container to a variable for later reference
		var fadeContainer = $('span.fading_photos');
		//find out how many children are in the parent container
		var fadeTotal = $(fadeContainer).children().length;
		//set the starting index
		var fadeStart = 1;
		var fadeOrigin = 1;

		//hide the children
		$('span.fading_photos img:first').siblings().hide();
		//give the children an id equal to the index + 1 so we can target them
		$(fadeContainer).children().each( function(i)
			{
				$(this).attr({id:i+1});
			}
		);

		//run the function that does the fades and the timer
		runFades();
	}
	
	//******for photos with links***********
	if($('.fading_photo_links').length){
		var FadeTime = 6000;
		//see if there is more than one photo link
		var PhotoLinks = $('.fading_photo_links').children().length;
		//if there is, then run the fades
		if(PhotoLinks > 1){
			//set the container to a variable for later reference
			var fadeContainer = $('.fading_photo_links');
			//find out how many children are in the parent container
			var fadeTotal = PhotoLinks;
			//set the starting index
			var fadeStart = 1;
			var fadeOrigin = 1;

			//hide the children
			$('.fading_photo_links a:first').siblings().hide();
			//give the children an id equal to the index + 1 so we can target them
			$(fadeContainer).children().each( function(i)
				{
					$(this).attr({id:i+1});
				}
			);

			//run the function that does the fades and the timer
			runFades();

		}
	}
	
	//******for photos not in the right nav******
	if ($('div.fading_photos').length) {
		//set the fade time
		var FadeTime = 4000;
		//set the container to a variable for later reference
		var fadeContainer = $('div.fading_photos');
		//find out how many children are in the parent container
		var fadeTotal = $(fadeContainer).children().length;
		//set the starting index
		var fadeStart = 1;
		var fadeOrigin = 1;

		//hide the children
		$('div.fading_photos img:first').siblings().hide();
		//give the children an id equal to the index + 1 so we can target them
		$(fadeContainer).children().each( function(i)
			{
				$(this).attr({id:i+1});
			}
		);

		//run the function that does the fades and the timer
		runFades();
	}

	
	function runFades() {
		//check that we haven't incremented past the total number of children
		if (fadeStart < fadeTotal) {

			//run the timer for the fade out
			window.setTimeout(function(){
				$('#'+fadeStart).fadeOut(1000, function() {
					//when the timer is done, increment the id (index) so the next one will fade in/out
					fadeStart++;
					//run this whole function again so we fade them all in sequence
					runFades();
				});
				$('#'+(fadeStart + 1)).fadeIn(1000);

			}, FadeTime);

		}else{
			//run the timer for the fade out
			window.setTimeout(function(){
				$('#'+fadeOrigin).fadeIn(1000);
				$('#'+fadeStart).fadeOut(1000, function() {
					//when the timer is done, increment the id (index) so the next one will fade in/out
					fadeStart = 1;
					//run this whole function again so we fade them all in sequence
					runFades();
				});
			}, FadeTime);

		}
	} 
	
	//*************EXPANDABLE LIST***********
	//THIS ONE IS FOR THE PHYSICIAN REFERRAL GUIDE DISPLAY PAGE
	//make sure we're on the correct page
	if($('ul.dfwp-list').length){
		var thisPage = $('#title h1').text();
		//alert(thisPage);
		var myPatt = /Physician Referral Guide/;
		var result = myPatt.test(thisPage);
		if(result == true){
			$('ul.dfwp-list:first').addClass('expanding_list');
			$('ul.dfwp-list li').removeClass('dfwp-item');
			$('ul.dfwp-list li ul').removeClass('dfwp-list');
			//var pList = $('.expanding_list').children('li').length;
			var pList = 0;
			//alert(pList);
		
			//add a class to the top level list items so they can expand
			$('ul.expanding_list li ul').parent().each(function(){
				$(this).addClass("plus");
				//$(this).children('ul li').removeClass("plus");
			});
			
			$('li.plus div').removeClass('plus').removeClass('groupheader').removeClass('item').removeClass('medium');
		
			//remove the bottom border from the last list item so it's clean
			$('ul.expanding_list li ul:last').parent().css({"border-bottom":"none"});

		
			//hide all the nested lists so they can be expanded by user
			$('ul.expanding_list li ul').hide();
		
			//slide down the nested lists
			$('ul.expanding_list li div').click( function(){
				$(this).sibling('ul').slideToggle();
			});
		
			//once expanded, change plus to minus to indicate it can be collapsed
			$('li.plus').live({
				click: function() {
					$(this).removeClass("plus").addClass("minus").css({"background-color":"#ffffff","color":"#000000"});
					pList++;
					$('.plus').css({"opacity":"0.5"});
					$(this).css({"opacity":"1.0"});
				},
				mouseover: function() {
					$(this).css({"background-color":"#eeeeee", "cursor":"pointer"});
				},
				mouseout: function() {
					$(this).css({"background-color":"#ffffff"});
				}
			});
		
			//once collapsed, change minus to plus to indicate it can be expanded
			$('li.minus').live(
				'click', function() {
					$(this).removeClass("minus").addClass("plus").css({"color":"#990000","opacity":"0.5"});
					pList--;
					if(pList < 1){
						$('.plus').css({"opacity":"1.0"});
					}
				}
			);
		}
	}

	//check if there correct element and url string exists
	//THIS ONE IS FOR THE ONBOARDING RESOURCES LIST
	//in this case it can be one of two pages
	var checkPatt = /(onboarding|spousepartnerconnection)/;
	var getresult = checkPatt.test(getPage);

	if(getresult == true && $('.expanding_list').length){
		var pList = 0;
		
		//add a class to the top level list items so they can expand
		$('.expanding_list li ul').parent().each(function(){
			$(this).addClass("plus");
			//$(this).children('ul li').removeClass("plus");
		});
		
		//remove the bottom border from the last list item so it's clean
		$('.expanding_list li ul:last').parent().css({"border-bottom":"none"});

		
		//hide all the nested lists so they can be expanded by user
		$('.expanding_list li ul').hide();
		
		//slide down the nested lists
		$('.expanding_list li').click( function(){
			$(this).children('ul').slideToggle();
		});
		
		//once expanded, change plus to minus to indicate it can be collapsed
		$('.plus').live({
			click: function() {
				$(this).removeClass("plus").addClass("minus").css({"background-color":"#ffffff","color":"#000000"});
				pList++;
				$('.plus').css({"opacity":"0.5"});
				$(this).css({"opacity":"1.0"});
			},
			mouseover: function() {
				$(this).css({"background-color":"#eeeeee", "cursor":"pointer"});
			},
			mouseout: function() {
				$(this).css({"background-color":"#ffffff"});
			}
		});
		
		//once collapsed, change minus to plus to indicate it can be expanded
		$('.minus').live(
			'click', function() {
				$(this).removeClass("minus").addClass("plus").css({"color":"#990000","opacity":"0.5"});
				pList--;
				if(pList < 1){
					$('.plus').css({"opacity":"1.0"});
				}
			}
		);

	}
	
	//******************RIGHT NAV FORM***********************
	//check if the correct element exists
	if($('#right_nav_form').length) {
		//add a class to the parent container so we can target it and style it
		$('#right_nav_form .ms-toolbar').parent().addClass("submit_button");
		//check if the url has a string containing 'submit'
		//the webpart is redirecting to the same page, and appending the url with a query string
		//that contains 'submit'
		var urlString = window.location.href;
		var backHome = urlString.replace('?state=submit', "");
		//if it does, remove the form since they already submitted
		if(/\bsubmit\b/.test(window.location.href)){
			$('#right_nav_form .ms-formtable').parent().html('<p>Thank you for submitting your question. Someone will follow up as soon as possible.</p><p><a href="'+backHome+'">Ask Another Question</a></p>').css({"font-size":"12px !important"});
		}
	}
	
	//*************RIGHT NAV LARGE BUTTON******************
	$('.right_nav_feature .large_graphic_button img').live({
		mouseover: function(){
			var myHover = $(this).attr('src').replace('_static.', '_active.');
			$(this).attr('src', myHover);
		},
		mouseout: function(){
			var myHover = $(this).attr('src').replace('_active.', '_static.');
			$(this).attr('src', myHover);
		}

	});
	
	//************MEDIA ROOM EMAIL LINKS******************
	if($('.consumer_contact').length) {
		var getConsumer = $('.consumer_contact').attr('href');
		var getJournalist = $('.journalist_contact').attr('href');
		var getRelease = window.location.href
		$('.consumer_contact').attr('href', getConsumer+'&Body='+getRelease);
		$('.journalist_contact').attr('href', getJournalist+'&Body='+getRelease);

	}
	
	//************SITEMAP DISPLAY SETTINGS******************
	var mySitemapPatt = /sitemap/;
	var checkresult = mySitemapPatt.test(getPage);

	if(checkresult == true ){
		//since the sitemap is now using the Table of Contents webpart, 'Lists' and 'Surveys' need to
		//be removed manually when the page renders. Technically they're legit sites, just not to the outside world
		//not ideal, but Google will just throw a 403 error if it spiders those links as they require authentication
		//site users won't see them
		$("a:contains('Lists'), a:contains('Surveys')").parent().parent().parent().parent().remove();
	}
	
	//********MEDIA ROOM ADDITIONAL EXPERTS**********
	//remove <nobr> in content query webpart title being inserted by sharepoint
	if($('#media_rightrail table.s4-wpTopTable table h3').length){
		var mediaV = $('#media_rightrail table.s4-wpTopTable table h3').html().replace(/&nbsp;/, '');
		$('#media_rightrail table.s4-wpTopTable table h3').html(mediaV);
	}
	
	if($('.fsp_banner').length){
		var fspStart = 0;
		
		function fspFade() {
			window.setTimeout(function(){
				if(fspStart < 1){
					$('.fsp_banner img:last').fadeOut(1000, function(){
						fspFade();
					});
					fspStart = 1;
				}else{
					$('.fsp_banner img:last').fadeIn(1000, function(){
						fspFade();
					});
					fspStart = 0;
				}
			}, 6000);
		}
		
		fspFade();
		
		//find the height of the news list
		var getNH = $('.fsp_news_text ul').height();
		//find the height of the news list container
		var getNC = $('.fsp_news_text').height();
		//get the difference as a negative number so we can use it as a target location
		var mDiff = getNC - getNH;
		
		//if the list isnt't longer than the list container, remove the up/down controls
		if (getNH < getNC) {
			$('.fsp_news img.up, .fsp_news img.down').hide();
		}
		
		//get the starting position
		var getNHT = $('.fsp_news_text ul').position().top;
		
		//scroll news down when you hover over the 'up' arrow
		$('img.up').hover( function(){
			//get the current top location of the news list
			var getCurrentT = $('.fsp_news_text ul').position().top;
			//if it's not at the starting point, move the list
			if(getCurrentT < getNHT){
				$('.fsp_news_text ul').stop().animate({top: getNHT}, (0-getCurrentT)*10);
			}
		},function(){
			//when we roll off the arrow, stop where you are
			var getCurrentT = $('.fsp_news_text ul').position().top;
			$('.fsp_news_text ul').stop().animate({top: getCurrentT});
		});
			
		//scroll news down when you hover over the 'down' arrow
		$('img.down').hover( function(){
			//get the current top location of the news list
			var getCurrentT = $('.fsp_news_text ul').position().top;
			//if it's not at the ending target, move the list
			if(getCurrentT > mDiff){
				$('.fsp_news_text ul').stop().animate({top: mDiff}, (getCurrentT-mDiff)*10);
			}
		},function(){
			//when we roll off the arrow, stop where you are
			var getCurrentT = $('.fsp_news_text ul').position().top;
			$('.fsp_news_text ul').stop().animate({top: getCurrentT});
		});
			
	}
	
	//If the 'OSUMC in the News' sidebar is present, add a 'read more' link for the full list 
	if($("tr td table tbody tr td h3:contains('OSUMC in the News')").length){
		var osumcP = $("tr td table tbody tr td h3:contains('OSUMC in the News')");
		var osumcL = $(osumcP).closest('table.s4-wpTopTable');
		$(osumcL).children('tbody').children('tr:last').children('td').children('div').children('ul').after('<p class="news_readmore"><a href="/mediaroom/Pages/OSUMC-in-the-News.aspx">read more >></a></p>');
	}
});
