/**
 * customadd.js
 * Additional custom code
 * 
 */
// Preload MouseOver Images
if (document.images) {
	imgDefaultLoad = new Image();
	imgDefaultLoad.src = "/images/careers_map_default.png";
	
	imgApLoad = new Image();
	imgApLoad.src = "/images/careers_map_AP.png";

	imgEameLoad = new Image();
	imgEameLoad.src = "/images/careers_map_EAME.png";

	imgLaLoad = new Image();
	imgLaLoad.src = "/images/careers_map_LA.png";

	imgNaUsLoad = new Image();
	imgNaUsLoad.src = "/images/careers_map_NAUS.png";

	imgNaCaLoad = new Image();
	imgNaCaLoad.src = "/images/careers_map_NACA.png";
}
// Change Image Function
function changeMapImage(sImageToUse) {
	if (document.images) {
		if (sImageToUse == "default")
		{
			eval("parent.document['careersmap'].src=imgDefaultLoad.src");
		}
		else if (sImageToUse == "ap")
		{
			eval("parent.document['careersmap'].src=imgApLoad.src");
		}
		else if (sImageToUse == "la")
		{
			eval("parent.document['careersmap'].src=imgLaLoad.src");
		}
		else if (sImageToUse == "naus")
		{
			eval("parent.document['careersmap'].src=imgNaUsLoad.src");
		}
		else if (sImageToUse == "naca")
		{
			eval("parent.document['careersmap'].src=imgNaCaLoad.src");
		}
		else if (sImageToUse == "eame")
		{
			eval("parent.document['careersmap'].src=imgEameLoad.src");
		}		
	}
}

jQuery(document).ready(function () {
	jQuery('#productsAMLink').click(function () {
		jQuery('#productsAMModal').dialog({
			modal: true,
			width: 650,
			title: 'Products A-M'
		});
	});

	jQuery('#productsNZLink').click(function () {
		jQuery('#productsNZModal').dialog({
			modal: true,
			width: 650,
			title: 'Products N-Z'
		});
	});

	$j(".productsNav").children('.AspNet-TreeView').children().each(function (i, element) {
		var $lis = $j(element).children(),
			$ul = $j(element),
			$newUl = $j("<ul class='productsNav' />").css('float', 'left').insertAfter($ul),
			size = $lis.length / 2,
			count = 0;

		$j(element).css('float', 'left')

		$lis.each(function (i, li) {
			if (count < size) {
				count = count + $j(li).find('li').length + 1;
			}
			else {
				$newUl.append($lis.slice(i, $lis.length));
				return false;
			}
		});
	});
});
