//if you want to use jquery to initialise anything on every page

$(document).ready( function () {

	setExternalLinks();

	globalNavSetup();

});



/* used to get rid of _blank so your code validates w3c stylee */

function setExternalLinks() {

  var el_list = document.getElementsByTagName('A');

  for (i=0; i<el_list.length; i++) {

    if (el_list[i].getAttribute('rel') == 'external') {

      el_list[i].setAttribute('target', '_blank');

    }

  }

}



/* Check's users version of Flash */

function checkFlash (version) {

	return DetectFlashVer(version, 0, 0);

}





function globalNavSetup() {

	$globalNav = $('#globalNav');

	//set to height of topmost level of nav only

	$globalNav.height('48px');

	navOpen = false;

	var currentSubMenu;

	

	//if we've got active children, let's show them

	$('ul.mainLinks').children('.active').find('ul li.active').each(function() {

		$(this).parents('ul').css('display', 'block');	

		$globalNav.height('68px');

		navOpen = true;

	});

	

	$('#globalNav ul').find('li').not('ul ul li').hover(

		//hover on

		function () {

			if ($(this).children('ul').length != 0) {

				currentSubMenu = $(this).siblings('li.active').children('ul');

				$(this).children('ul').css('display', 'block').end().siblings('li').children('ul').hide();

				$globalNav.stop().animate({ 'height': '149px' });

			} else {

				$globalNav.stop().animate({ 'height': '149px' });

			}

		},		

		//hover off

		function () {

			if (!navOpen)

				$globalNav.stop().animate({ 'height': '149px' }, function () { $(this).find('ul ul').css('display', 'none') });

			$(this).not('.active').children('ul').hide();

			currentSubMenu.show();

		});

}



// Clears input box onFocus, and adds back in if empty onBlur

// takes the ID of the input box and the default text value

function inputClear(inputID, inputText) {

	$('#'+inputID).focus(function() {

		if ($(this).attr('value').toLowerCase() == inputText.toLowerCase())

			$(this).attr('value', '');

	});

	$('#'+inputID).blur(function() {

		if ($(this).attr('value') == '')

			$(this).attr('value', inputText);

	});

}


