$(function() {

	// flash
	if($('object').size() > 0) {
		var HIAAFlash = $('object');
		var HIASId = '';
		HIAAFlash.each(function() {
			HIASId = $(this).attr('id');
			swfobject.registerObject(HIASId);
			$(this).css({visibility: 'visible'});
		});
	}

	// email address
	$('a.email').each(function() {
		var HIASIndirizzo = ($(this).attr('href')).replace('.htm?', '@').replace('=', '.').replace('../', '');
		$(this).attr('href', 'mailto:' + HIASIndirizzo);
		$(this).text(HIASIndirizzo);
	});

	// menu
	var $el, leftPos, newWidth;
		$mainNav2 = $("#mainMenu");
	var HIANULHeight = $('li:first', $mainNav2).height();
	
	$mainNav2.append("<li id='magic-line-two'></li>");
	
	var $magicLineTwo = $("#magic-line-two");
	
	$magicLineTwo
		.height(HIANULHeight);
	if($('ul#mainMenu li.selected').size() > 0) {
		$magicLineTwo
			.width($(".selected").width())
			.css("left", $(".selected a").position().left)
			.data("origLeft", $(".selected a").position().left)
			.data("origColor", $(".selected a").attr("rel"));
	}
	else {
		$magicLineTwo
			.width(0)
			.css("left", 0)
			.data("origLeft", 0)
			.data("origColor", '');
	}
	$magicLineTwo
		.data("origWidth", $magicLineTwo.width());
				
	$("#mainMenu a").hover(function() {
		$el = $(this);
		leftPos = $el.position().left;
		newWidth = $el.parent().width();
		$magicLineTwo.stop().animate({
			left: leftPos,
			width: newWidth,
			backgroundColor: $el.attr("rel")
		})
	}, function() {
		$magicLineTwo.stop().animate({
			left: $magicLineTwo.data("origLeft"),
			width: $magicLineTwo.data("origWidth"),
			backgroundColor: $magicLineTwo.data("origColor")
		});
	});
	
	/* Kick IE into gear */
	//$(".selected a").mouseenter();

	// popup
	$("a.popup").each(function() {
		if($(this).attr('href').indexOf('.htm') > -1) {
			$(this).click(function() {
				$.fancybox({
					type:	'iframe',
					href:	$(this).attr('href'),
					width:	'90%',
					height:	'90%'
				});
				return false;
			});
		}
		else {
			$(this).click(function() {
				$.fancybox({
					href:	$(this).attr('href')
				});
				return false;
			});
		}
	});
});

-->
