<!--
function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
	var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
	var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	 if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

var pod_win = '';
function open_pod_win( url, win_name, w, h ) {
	var my_win;
	wX = screen.width;
	hX = screen.height;
	hpos = ((wX - w)/2);
	vpos = ((hX - h)/2);

	if( pod_win ){
		pod_win.close();
	}

	pod_win = window.open(url, win_name,'width='+w+',height='+h+',top=' + vpos + ',left=' + hpos + ',scrollbars=yes,resizable=yes,status=yes,menubar=no,directories=no,toolbar=no,location=no');
	pod_win.focus();
}

$(document).ready(function(){
	// Show loader indicater on ajaxStart
	$("#ajax_indicator").ajaxStart(function(){
		$(this).show();
	});

	// Hide loader indicater on ajaxStop
	$("#ajax_indicator").ajaxStop(function(){
		$(this).hide();
	});
	
	// add image popup to all bio images after checking colorbox is defined
	/*
	if(typeof colorbox == 'function')
		$(".bio a[rel='bio']").colorbox({transition:"fade"});
	*/
	// for each bio title, create anchor and corresponding link in left side menu
	$(".bio h2 .name").each(function(index) {
			if ($('#bios_left').text().length == 0) {  // add title only once
				$('#bios_left').html('<h2>Executives</h2>');
			}
			current_text = $('#bios_left').html();
			anchor_name = $(this).text().toLowerCase().replace(' ','');
			bio_title = $(this).parent().text();
			$(this).html($(this).text() + '<a name="' + anchor_name + '"></a>');  // add anchor to title
			$('#bios_left').html(current_text + '&nbsp; <a href="#'+anchor_name+'" title="'+bio_title+'">' + $(this).text() + '</a><br />\n');			
	});

	// assign click smooth scroll to left menu bio links
		$("#bios_left a").click(function (event) {
			event.preventDefault();
			anchor = $(this).attr('href').replace('#','').replace('http://'+document.domain+'/bios','');   // remove domain for ie
			anchor_pos =  $("a[name='"+anchor+"']").offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: anchor_pos-15}, 2000, function() {
				// update url after the animation
				window.location.hash = "#"+anchor;
			});
		});

	// change image location for odd numbered bios
		/*
		$('.bio:odd').each(function(index) {
			var img = $(this).find ('img');
			// if image exists, format bio
			if (img.length > 0) {
				$(this).css('text-align', 'justify');
				img.css('float', 'right'); 
				img.css('margin', '0px 20px 10px 15px');
			}
		});
		*/

		// change image location for odd numbered images 
		$('.bio img:odd').each(function(index) {
			var bio = $(this).parent();
			// if image exists, format bio
			bio.css('text-align', 'justify');
			$(this).css('float', 'right'); 
			//$(this).css('margin-right', '20px');
			//$(this).css('margin-left', '15px');
			$(this).css('margin', '-25px 20px 0px 15px');
		});
			
		// setup bios_left menu to always appear on the page
		if ($('#bios_left').length > 0)
			var bio_menu_pos = $('#bios_left').offset().top; // get default position
		
		// check window scroll and adjust menu position
		$(window).scroll(function() {
			win_pos = $(window).scrollTop();
			// switch to fixed position when element begins to leave window
			if (win_pos > bio_menu_pos) { 
				$('#bios_left').css('position','fixed');
				$('#bios_left').css('top',0);
			} else {
				// return div to original position
				$('#bios_left').css('position','');
				$('#bios_left').css('top','');
			}
			
		});

			
});
