var highland = {

	loadSwf:

		[function(filepath,mWidth,mHeight){
			var so = new SWFObject(filepath, "North Highland SWF",mWidth , mHeight, "9");
			so.addParam("scale", "noscale");
			so.addParam("wmode", "transparent");
			so.addParam("AllowScriptAccess", "always");  
			//so.addVariable('foo','bar');   //accessible within flash as loaderInfo.parameters.foo;
			
			if(ie6){//no flash for ie6
				$(this).addClass('secondaryContent').removeAttr('id');
				fadeAccents();
			}
			
			if(!so.write($(this).attr('id'))){//add "flash class to hmtl and body elements if loaded
				$(this).addClass('secondaryContent').removeAttr('id');
				fadeAccents();
			}
			
			return $(this);
		},'addToJquery'],

	expanders :
	
		[function(sel,speed){
			sel.each(function(){
				var btn = $(this);
				var exp  =  $(this).next();
				btn.click(function(){ btn.expandOrContract(speed,exp,btn);});
			});
			return $(this);
		},'addToJquery'],
	
	
	expandOrContract:
	
		[function(speed,exp,btn){
			btn.each(function(){
				exp.stop(false,true).slideToggle(speed,function(){btn.toggleClass('on');});
			});
			return $(this);
		},'addToJquery'],
		
		
	printBio:
		
		function(){
		    try{ 		    	
		    	$('body').append('<iframe src="#" id="printFrame" style="border:0px; width:0px; height:0px;"></iframe>');
		        var oIframe = document.getElementById('printFrame');

		        var oDoc = (oIframe.contentWindow || oIframe.contentDocument);
		        if (oDoc.document) oDoc = oDoc.document;
				oDoc.write('<html><head><title>Executive Bio</title>'+
					'<link rel="stylesheet" type="text/css" href="/css/bio.css" />'+
					'</head><body onload="this.focus(); this.print();">');
				oDoc.write('<div class="activeExec">' + $('.activeExec').html() + '</div>');
				oDoc.write($('.executivebio:visible').html());
				oDoc.write('<img src="/images/logo-print.gif" class="printlogo") />');
				oDoc.write("</body></html>");	    
				oDoc.close(); 	
		    }
		    catch(e){		    	    	
			   self.print();
		    }
		}
		
		
}

function fadeAccents(){	$('#cover code').fadeOut(1000,function(){$('#logo').fadeIn(500);});}

	

//extend jquery with Highland functions:
function extendJQ(source){for (var i in source){if (source[i][1] == 'addToJquery'){	jQuery.fn[i] = source[i][0];}}}
extendJQ(highland);

var ie6 = ($.browser.msie && $.browser.version == "6.0");
var ie7 = ($.browser.msie && $.browser.version == "7.0");

var youAreHere = $('body').attr('id');



function fixBackground(){
	var winWidth = $(window).width();
	if (winWidth < 989) {
		$('body').removeAttr('style').addClass('offset-bg').width(889);
	} 
	else {
		$('body').removeAttr('style').removeClass('offset-bg');
		if (ie7) {	
			var bgWidth = 1426;
			if (winWidth>bgWidth) {$('body').css('background-position','center top'); }
			else {$('body').css('background-position',-((bgWidth-winWidth)/2)+'px top'); $('html').css('overflow-x','hidden');}
		}
	}
}


// {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ global event binding/firing
$(document).ready(function(){	
	
	$(document)
		.expanders($('.expanders>h4'),1000)		
	;	
	$(window).resize(fixBackground);
	
	//alert($.browser);
	
	if (!blackberry) fixBackground();// aligns background for narrow browser window.	
	
	/*
	if(ie6){
		if ($('#homeFlash').appendTo('#pg').addClass('ie6').length > 0 ) $('<div class="ie6Flash"></div>').prependTo('.content');;
	}
	*/
	
	
	//fade in accent if not on flash homepage
	if (accentFade) { setTimeout(fadeAccents,500); }
	
	else{
		$('#homeFlash').loadSwf('flash/homepage_opening_v2.swf',1000,675).css('visibility','visible');
		$('#logo').fadeIn(500);	}
	
	
	if(ie6){$('#nav, #searchForm').css('zoom','1');}//fixes ie6 layout issues
	
	
	if (youAreHere == "page-media-center") {// {{{{{{{{{{{{{{{{{{{{{{{{{{{ media-center page
		var openUp = window.location.hash.replace("#","");
		var controls = $('.expanders h4');
		controls.filter('[rel="'+openUp+'"]').trigger('click');		
		$('.anchor').click(function(){
			openUp = $(this).attr('rel');
			var exp = controls.filter('[rel="'+openUp+'"]');
			if (exp.length > 0 && !exp.hasClass('on')){
				controls.filter('.on').trigger('click');
				exp.trigger('click');
			}
		});
	}
	
	
	
	if (youAreHere == "page-executive-team") {// {{{{{{{{{{{{{{{{{{{{{{{{{{{ executive-team	page
		
		$('.executivebio a').click(function(){			
			highland.printBio();
			return false;
		});
		
		var deviceAgent = navigator.userAgent.toLowerCase();
		var appleDevice = deviceAgent.match(/(iphone|ipod|ipad)/); 		
		section = "story";
		var activeExec = "reardon";		
		function switchBio(BIO){
			$("div.activeExec").removeClass("activeExec");
			$(".executivebio").hide();
			BIO.addClass("activeExec");
			activeExec = BIO.attr("id");
			$("#bio_" + activeExec).show();
		}				
		$(".executive")
			.click(function(){
				switchBio($(this));
				return false;
			})
			.hover(
				function(){
					if (!$(this).hasClass('activeExec')) $('.activeExec').addClass('off');
					$(this).addClass("activeExec");
					if (appleDevice) switchBio($(this));
				},
				function(){	
					if ($(this).attr("id") != activeExec) $(this).removeClass("activeExec");
					$('.off').removeClass('off');
				}		
		);	
	}// end executive-team
	
	
	
	
	if (youAreHere == "page-results") {// {{{{{{{{{{{{{{{{{{{{{{{{{{{ results page
		var activeSlide = 0;	
		var slideCount = $('.widerailslide').size() - 1;
		var slideNum = 0;
		$(".resultsnext").bind("click", function() {
			$(".widerailslide").hide();
			$(".more").hide();
			$(".less").show();
			if (slideNum < slideCount) {
				slideNum++;
				$(".widerailslide").eq(slideNum).show();
			} else {
				if (slideNum == slideCount) {
					slideNum = 0;
					$(".widerailslide").eq(slideNum).show();
				}
			}
		});
		$(".resultsprev").bind("click", function() {
			$(".widerailslide").hide();

			if (slideNum > 0) {
				slideNum--;
				$(".widerailslide").eq(slideNum).show();
			} else {
				if (slideNum == 0) {
					slideNum = slideCount;
					$(".widerailslide").eq(slideNum).show();
				}
			}
		});
		$(".showmore").bind("click", function() {
			$(this).parent("span").hide();
			$(this).parent("span").parent("div").children(".more").show();
		});
		$(".showless").bind("click", function() {
			$(this).parent("span").hide();
			$(this).parent("span").parent("div").children(".less").show();
		});	
	}	
	
});
// {{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ End global binding/firing








