/* CONSTANTS */
var FLASH_VERSION_SUPPORTED = '9';

/* UTILITY VARIABLES */
var isIE = $.browser.msie;
var isIE6 = isIE && parseInt($.browser.version) === 6;

/*
 * ENABLE JS and FLASH FLAGS
 */
$('html').addClass('js-enabled');
if(typeof(swfobject) !== 'undefined' && swfobject.hasFlashPlayerVersion(FLASH_VERSION_SUPPORTED)) {
	$('html').addClass('flash-enabled');
}


/*
* SEARCH
*/
;$(function() {
/* get value from label */
var _searchVal = $('.site-search label').html();
$('.site-search input.text').val(_searchVal).focus(
function() { $(this).val(''); }
).blur(
function() { $(this).val(_searchVal); }
);
});




	

/*
* ONLOAD EVENTS
*/

$(document).ready(function()
{
  //hide the all of the element with class msg_body
  $("ul.opener-secondary").hide();
  $("a.expander").next("ul.nav").hide();
  $("a.current_").next("ul.opener-secondary").show();
  $("a.expanded_").next("ul.nav").show();
  //toggle the componenet with class msg_body
  $("a.expander:not(.current_)").click(function()
  {
    $(this).toggleClass("expanded_");
    $(this).next("ul.opener-secondary").slideToggle(200);
  })
  .attr("href", "javascript:void(0);");
});






/*
* GLOBAL ENHANCEMENTS
*/
$(function() {


	/* open external urls in new window */
	$('a.ext, a.doc, div#footer a').live('click', function() {
		window.open(this.href);
		return false;
	});
	/*For the navigation - clicking on links with the current_ class does nothing. */
	$('#sidebar-content a.current_, a.disabled_, a.expander').click(function() { return false; });

    
	/* adds label text as value of text input  */
	$('input.autolabel').each(function() {
		var $this = $(this);
		$this
			.data('label',$('label[for="' + $this.attr('id') + '"]').html())
			.val($this.data('label'))
			.focus(function() {
				if ($this.val() === $this.data('label')) {
					$this.val('');
				}
			})
			.blur(function() {
				if ($this.val() === '') {
					$this.val($this.data('label'));
				}
			});
	});  


});


/*
* IE FIXES
*/
if(isIE6) {

    /* prevents background-image flicker in IE 6
	(http://support.microsoft.com/?scid=kb;en-us;823727&spid=2073&sid=global) */
	try { document.execCommand("BackgroundImageCache",false,true); } 
	catch(e) { }
    
}

/*
 * tricky nav stuff
 *
 * The nav links in the main site nav need to change, only when javascript
 * is enabled, to point to the home page with an anchor attached. This way
 * from anywhere on the site, clicking a nav link will bring the user to
 * the opener animation on the home page rather than the static pages. The
 * static versions will still be available for scriptless users.
 */
// $(function () {
//   // $("a[href=01_home_opener_breakthrough.html]").attr("href", "01_home.html#a-breakthrough-vision");
//   // $("a[href=01_home_opener_global.html]").attr("href", "01_home.html#a-global-perspective");
//   // $("a[href=01_home_opener_education.html]").attr("href", "01_home.html#an-eye-for-education");
//   // $("a[href=01_home_opener_collaborative.html]").attr("href", "01_home.html#a-collaborative-focus");
// });








