﻿ /* <![CDATA[ */

$.expr[':'].containsIgnoreCase = function(e,i,m){return $(e).attr('href').toLowerCase().indexOf(m[3].toLowerCase())>=0;};
$(document).ready(function(){	

var lastItem = null;
//substring really long breadcrumb names
$("div.breadcrumb a.ms-sitemapdirectional, div.breadcrumb span.breadcrumbCurrent").each(function(i, val) {
	
	if($(this).html() == lastItem) {
		$(this).prev().prev().remove();
		$(this).prev().remove();		
	}
	
	lastItem = $(this).html();
	
	tempString = $(this).html();
	if(tempString.length > 15) {
		tempString = tempString.substring(0, 15) + "...";
		$(this).html(tempString);
	}
 
}); 
// 
 
//remove subnav items greater than 10
$("#topLevelNavList li:gt(10)").remove();
// 
 
//display my siblings only 
var cleanCaseURL = null;
cleanCaseURL = window.location.pathname;
cleanCaseURL = cleanCaseURL.toLowerCase();
 
$("#cambrianLeftContent a").each(function () {
				
				if($(this).attr('href')) {
								if($(this).attr('href').indexOf("/") > -1) {
									$(this).attr('href', $(this).attr('href').toLowerCase());
								}
				}
});
 
 
$("a[href='"+cleanCaseURL+"']").css("font-weight","bold");
 
 
addWhatsHere();
 
if($("a[href='"+window.location.pathname+"']:first").parents("div").html() != null) {
	
	if($("td a[href='"+window.location.pathname+"']:last").parents("div").html() != null) {
					$("#cambrianLeftContent table:first").replaceWith($("td a[href='"+window.location.pathname+"']:last").parents("div").html());
					
					$("#cambrianLeftContent table:first").attr('id', 'zz1_CurrentNav');
					$("#cambrianLeftContent table:first").addClass('leftNav');					
					$("#cambrianLeftContent table:last").addClass('spacerNav'); 
			
	}
	
 
} 
//end of display my siblings only 
 
//add the what's here navigation to landing pages which have children 
//display a default graphic if none is provided
titleSplit = new Array();
titleLocation = window.location.pathname;
titleSplit = titleLocation.split("/"); 
 
if(titleSplit[1] == "Pages" || titleSplit[1] == "Search") {
	$("#cambrianLeftContent").hide();
	$("#cambrianRightContent").css("float","none");
	$("#cambrianRightContent").css("width","916px");
	$("#cambrianStandardStandardColB").css("width","650px");
 
	if(titleSplit[1] == "Search") {
		$("#cambrianRightContent").addClass("cambrianSearchResultsBack");
	}	
} 
 
//clean up links in the sitemap
if(titleSplit[2] == "Sitemap.aspx") {	
	$("#tocwp tbody tr td:first").remove();
	$("span a[href*='/NewsEvents/News/Pages/']").parent("span").parent("div").parent("div").remove();
	$("span a[href*='/Lists/']").parent("span").parent("div").remove(); 
}
 
//for each link in the nav
$("#cambrianLeftContent table tbody td td a").each(
function(intIndex) { 
 
 myTitleLocation = $(this).attr('href');
 myTitleLocation = myTitleLocation.toLowerCase();
 
  if(myTitleLocation.indexOf(titleSplit[1].toLowerCase()) < 1) { 
    
    		$(this).addClass("cambrianOutboundLink");
  } 
 
}) 
 
/********************** vv Magic Text Resizing Code vv **********************/
/********************** vv Magic Text Resizing Code vv **********************/
	var whatToScale = '#content *';
	var MINSIZE = 10;
	var BASSIZE = Array();
	var MAXSIZE = 20;
	var runResize = false;
 
 
	/*********** vv init all font-size vv ****************/
	var initCounter = 0;
	$(whatToScale).each(function(i) {
		var currentSize = $(this).css('font-size');
		// parse the number value out of the font size value, set as a var called 'num'
		var num = parseFloat(currentSize, 10);
		// make sure current size is 2 digit number, save as var called 'unit'
		var unit = currentSize.slice(-2);
		$(this).css('font-size', num + unit);
		BASSIZE[initCounter++] = num;
		
		currentSize = 1;
		num = 1;
		unit = '';
	});
	/*********** ^^ init all font-size ^^ ****************/
// textScaler links when clicked
	$("a.textScaler").click(function(){
		$clickedLink = this;
		var loopCounter = 0;
		var runResize = true;		
	
		/***** vv  Change Text size vv *****/
		if(runResize) {
			$(whatToScale).each(function(i) {
			
				var currentSize = $(this).css('font-size');
				// parse the number value out of the font size value, set as a var called 'num'
				var num = parseFloat(currentSize, 10);
				// make sure current size is 2 digit number, save as var called 'unit'
				var unit = currentSize.slice(-2);
			
				// javascript lets us choose which link was clicked, by ID
				if ($clickedLink.id == 'linkLarge') { 
					num = num + 2; 
				} else if ($clickedLink.id == 'linkSmall' && num > MINSIZE) { 
					num = num - 2; 
				} else if ($clickedLink.id == 'linkNormal') {					
					num = BASSIZE[loopCounter++];
				}
				// jQuery lets us set the font Size value of the mainText div
				$(this).css('font-size', num + unit);
			
				var currentSize = 1;
				var num = 1;
				var unit = '';
			});
			}//if(runResize) {
		/***** ^^ Change Text size ^^ *****/
	
		var loopCounter = 0;
	
		/***** vv Test for limits vv *****/
		if($clickedLink.id != 'linkNormal') {
			$(whatToScale).each(function(i) {
				var currentSize = $(this).css('font-size'); var num = parseFloat(currentSize, 10);			
			
				if ($clickedLink.id == 'linkLarge' && num >= MAXSIZE) { 					
					runResize = false;
					return false;
				} else if ($clickedLink.id == 'linkSmall' && num <= MINSIZE) {					
					runResize = false;
					return false;
				} else { }
			});
		}
		/***** ^^ Test for limits ^^ *****/
	});
/********************** ^^ Magic Text Resizing Code ^^ **********************/
/********************** ^^ Magic Text Resizing Code ^^ **********************/
  
}); 
 
//pop out the what's here dialog on pages that have children
function addWhatsHere() {
				var currentChildCurrentNavItem;
				var checkThisUrlOnly = null;
				checkThisUrlOnly = window.location.pathname;
				checkThisUrlOnly = checkThisUrlOnly.toLowerCase();
				
				currentChildCurrentNavItem = $("#cambrianLeftContent a[href='"+checkThisUrlOnly+"']:last").parents("tr:first").parents("tr:first").attr("id") + "Items";
								if($("#" + currentChildCurrentNavItem + ":has(a)").html() != null) { 
								//this has a fly out, that means we need to setup the area for content
																	
										$("#cambrianStandardFullColHeader").prepend("<div id='selfIdentifiedIntroListWrap' class='selfIdentifiedWhatsHere'><ul id='whatsHereFlyOutEdition'></ul></div>");
																	
												$("#" + currentChildCurrentNavItem + " a").each(function() {
													
													$(this).clone().appendTo("#whatsHereFlyOutEdition").wrap("<li></li>");
												
												});											
											
										var selfIdentifiedListwhatsHereFlyOutEdition = Math.ceil($("ul#whatsHereFlyOutEdition").children().size() / 2);
										$("ul#whatsHereFlyOutEdition").wrapList({ itemsPerColumn: selfIdentifiedListwhatsHereFlyOutEdition });
								
				}
				//end of what's here dialog
			} 
 
var today = new Date(); 
var expiry = new Date(today.getTime() + 30 * 86400 * 1000); // plus 30 days  
 
function setCookie(name, value) { 
	document.cookie = name + "=" + escape(value) + "; expires=" + expiry.toGMTString() + "; path=/"; 
}
 
function getCookie (cookie_name) {
	var results = document.cookie.match ('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
	if (results)
		return (unescape(results[2]));
	else
		return null;
}
 
function executeJQueryUp() {
	$('#homepageBanner').animate({height: '75'}, 1000 );
	setCookie("flvHidden","yes")
}
 
function executeJQueryDown() {
	$('#homepageBanner').animate({height: '308'}, 1000 );
	setCookie("flvHidden","null")
}
 
if (getCookie("flvHidden")=="yes") {
	$(document).ready(function() {
	$('#homepageBanner').height(75);
	});
} 
 
 /* ]]> */
