/**
 * Careers video popup: any link with class="video" 
 */
$(document).ready(function() {					   
	$('a.video').click(function(){
		var href = $(this).attr('href');
		window.open(href, 'secure','width=440,height=350,scrollbars=no,location=no,dependent=yes,resizable=no,top=100,left=100');return false; 
	});			
});



/**
 * Security lock popup in Login box 
 */
$(document).ready(function() {					   
	$('#login a#security').click(function(){
		var href = $(this).attr('href');
		window.open(href, 'secure','width=565,height=450,scrollbars=yes,location=no,dependent=yes,resizable=no,top=25,left=25');return false; 
	});			
	$('#Userid').focus();
});

/**
 * Popup a window that plays a 352 x 240 flash video
 */
function popupVid352by240(vid) {
	var popup = window.open('/global/media/video-players/videopopup-352-240.asp?video='+vid,'video','location=no,menubar=no,toolbar=no,status=no,resizable=no,scrollbars=no,width=352,height=260');
}

/**
  * Put the end quote marks at the end in the Careers banner 
  */
$(document).ready(function() {					   
	$('.black-holder p span').after('<img src="/careers/global/images/cite-end.gif" class="cite-end" />');
});




/*******************************************************************************
=== TABBED INTERFACE ===========================================================
	* The first tab withing <ul id="tabs"> will be selected by default. 
*******************************************************************************/
$(document).ready(function() {					   
	$('#tabs').tabs();
});

$(document).ready(function() {					   
	$('#search-tabs > ul').tabs();
});

/*******************************************************************************
=== INCREASE/DECREASE TEXT======================================================
	* INCREASE/DECREASE TEXT 
*******************************************************************************/
$(document).ready(function() {
// For graceful degredation, this script reveals these tools that the CSS hides by default.
	$('#tools').css('display', 'block');
	
// Read the cookie. Depending on what it is, apply the inline style to the body tag, and the selected class to the link that indicates the size.
	var size = $.cookie('fontSize');
	if (size == 'small') {
	$('body').css('font-size','');
		$('#text-size a').removeClass('selected');
		$('#text-size #small').addClass('selected');
	};
	if (size == 'medium') {
	$('body').css('font-size','140%');
		$('#text-size a').removeClass('selected');
		$('#text-size #medium').addClass('selected');
	};
	if (size == 'large') {
	$('body').css('font-size','160%');
		$('#text-size a').removeClass('selected');
		$('#text-size #large').addClass('selected');
	};
	
// To increase and decrease the text-size, adding inline styles to the body tag.
	$('#text-size a').click(function(event) {
									 
// This nullifies the font-size value by default.
	$('body').css('font-size', '');
	$.cookie('fontSize', 'small', { expires: 365, path: '/' });
	
// This is the "smaller" font-size link.
    if (this.id == 'medium') {
      $('body').css('font-size', '140%');
	  $.cookie('fontSize', 'medium', { expires: 365, path: '/' });
    }
	
// This is the "larger" font-size link.
    else if (this.id == 'large') {
      $('body').css('font-size', '160%');
	  $.cookie('fontSize', 'large', { expires: 365, path: '/' });
    }
	
// Add the selected class to the link, if the user has selected it.
    $('#text-size a').removeClass('selected');
    $(this).addClass('selected');
	event.stopPropagation();
	});  
});

/*******************************************************************************
=== PRINT THIS PAGE ============================================================
	* Initiates a regular browser print job when user clicks.
*******************************************************************************/
$(document).ready(function() {					   
  $('#print-page a').click(function() {
    window.print(); return false;
  });
});

/*******************************************************************************
=== PDF LINKS ==================================================================
	* Makes any link to a .PDF open in a smaller cromeless window, 
	  and displays the PDF icon image after the link.
*******************************************************************************/
$(document).ready(function(){
	$('a[href$=".pdf"]').click(function(){ 
		var href = $(this).attr('href'); 
		window.open(href, 'popup', 'location=no,menubar=no,toolbar=no,status=no,resizable=yes,scrollbars=yes,left=10,top=10,width=750,height=550'); return false; 
	}); 
	$('a[href$=".pdf"]').after(' <img src="../images/pdf-ico.gif" class="pdf-icon" title="This is a PDF document" />');
});

/*******************************************************************************
=== HOMEPAGE BILLBOARD =========================================================
	* Makes the homepage billboard animate.
*******************************************************************************/
$(document).ready(function(){
	var divToShow = $('dl dd a.current').attr('rel');
	$(divToShow).show();
	$('#billboard dl dd a').mouseover(function(){
		var link = $(this);
		$('dl dd a.current').removeClass('current');
		link.addClass('current');
		$('#billboard div').hide();
		rel = link.attr('rel');
		$(rel).show();
		return false;
	});
});

/*******************************************************************************
=== TABLE STRIPING =============================================================
	* Makes the homepage billboard animate.
*******************************************************************************/
$(document).ready(function(){
	$('table.tbl tbody tr:odd').addClass('odd');
	$('table.tbl tbody tr:even').addClass('even');
});



/*******************************************************************************
=== TOP NAVIGATION =============================================================
	* Suckfish method to show the parent tab's sub navigation.
*******************************************************************************/
/*
 * sfDelay - Suckerfish CSS menu with JS delay.
 *
 * Copyright (c) 2008 Peter Ryan (peter-ryan.co.uk)
 * This function is free for anyone to use, modify and redistribute.
 *
 * $Id: sfdelay.js 19 2008-05-19 15:33:48Z pryan $
 */

/* http://simonwillison.net/2004/May/26/addLoadEvent/ */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
};


sfHover = function() {
	var timeout = 600;
	var cssClass = "sfhover";

	var queue = [];
	var reCSS = new RegExp("\\b" + cssClass + "\\b");
	var sfEls = document.getElementById("nav").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
  
		// mouseover and mouseout handlers for regular mouse based interface.
		sfEls[i].onmouseover = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onmouseout = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// focus and blur handlers for keyboard based navigation.
		sfEls[i].onfocus = function() {
			queueFlush();
			this.className += " " + cssClass;
		}
		sfEls[i].onblur = function() {
			queue.push([setTimeout(queueTimeout, timeout), this]);
		}

		// click event handler needed for tablet type interfaces (e.g. Apple iPhone).
		sfEls[i].onclick = function(e) {
			if (this.className.search(reCSS) == -1) {
				// CSS not set, so clear all sibling (and decendants) menus, and then set CSS on this menu...
				var elems = this.parentNode.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className += " " + cssClass;
			} else {
				// CSS already set, so clear all decendant menus and then this menu...
				var elems = this.getElementsByTagName("li");
				for (var i=0; i<elems.length; i++) {
					elems[i].className = elems[i].className.replace(reCSS, "");
				}
				this.className = this.className.replace(reCSS, "");
			}
			if (e && e.stopPropagation)
				e.stopPropagation();
			else
				window.event.cancelBubble = true;
		}
	}

	queueFlush = function () {
		while (queue.length) {
			clearTimeout(queue[0][0]);
			queueTimeout();
		}
	}

	queueTimeout = function() {
		if (queue.length) {
			var el = queue.shift()[1];
			el.className = el.className.replace(reCSS, "");
		}
	}
}
addLoadEvent(sfHover);







