jQuery.noConflict();

jQuery(document).ready(function()
{
    jQuery.each(jQuery('a'), function ()
    {
		if (this.getAttribute("href") && this.getAttribute("rel") == "external")
		{
			this.target = "_blank";
		}
    });

	jQuery('#dialog-signup').dialog(
	{
		autoOpen: false,
		height: 385,
		width: 500,
		modal: true,
		resizable: false,
		draggable: false,
		buttons: 
		{
			Subscribe: function()
			{
				jQuery('#mc-embedded-subscribe-form').submit();
			},
			Cancel: function() 
			{
				jQuery(this).dialog('close');
				closeSuccessMsg();

				var buttons = J('.ui-dialog-buttonset .ui-button');
				J(buttons[0]).show();
			}
		},
		close: function() 
		{
			jQuery('input.mce_inline_error').removeClass('mce_inline_error');
			
			J('#mc-embedded-subscribe-form').each(function()
			{
				this.reset();
			});
		}
	});
	
	jQuery("#link_NewsletterSignUp").click(function()
	{
		jQuery("#dialog-signup").dialog('open');
	});

	jQuery("#dialog-signup").removeClass('hide');

	jQuery("#contentLinks li a, .link_BackToTop").click(function()
	{
		var idArray = this.id.split('_');

		jQuery(document).scrollTo('#' + idArray[1], 800, {axis:'y'});
	});
	
	// initize the Hero carousel
	jQuery("#arrow_Prev").click(function()
	{
		jQuery('#container_HeroContent').animate(
		{
			scrollLeft: '-=874'
		}, 800, function()
		{
			jQuery("#arrow_Next").removeClass('hidden');

			if (0 == jQuery('#container_HeroContent').scrollLeft())
			{
				jQuery("#arrow_Prev").addClass('hidden');
			}
			else
			{
				jQuery("#arrow_Prev").removeClass('hidden');
			}
		});
	});

	jQuery("#arrow_Next").click(function()
	{
		jQuery('#container_HeroContent').animate(
		{
			scrollLeft: '+=874'
		}, 800, function()
		{
			jQuery("#arrow_Prev").removeClass('hidden');

			if ((jQuery('#container_HeroContent ul.carouselContent').width() - jQuery('#container_HeroContent ul.carouselContent li').width()) == jQuery('#container_HeroContent').scrollLeft())
			{
				jQuery("#arrow_Next").addClass('hidden');
			}
			else
			{
				jQuery("#arrow_Next").removeClass('hidden');
			}
		});
	});

	jQuery('#hero_Featurettes').css('width', ((jQuery('#hero_Featurettes li.heroSlide').length) * 874) + 'px');
	
	if (2 > (jQuery('#hero_Featurettes li.heroSlide').length))
	{
		jQuery("#arrow_Next").addClass('hidden');
	} 

	// initize the Event carousel
	jQuery("#arrow_PrevEvent").click(function()
	{
		jQuery('#container_EventContent').animate(
		{
			scrollLeft: '-=874'
		}, 800, function()
		{
			jQuery("#arrow_NextEvent").removeClass('hidden');

			if (0 == jQuery('#container_EventContent').scrollLeft())
			{
				jQuery("#arrow_PrevEvent").addClass('hidden');
			}
			else
			{
				jQuery("#arrow_PrevEvent").removeClass('hidden');
			}
		});
	});

	jQuery("#arrow_NextEvent").click(function()
	{
		jQuery('#container_EventContent').animate(
		{
			scrollLeft: '+=874'
		}, 800, function()
		{
			jQuery("#arrow_PrevEvent").removeClass('hidden');

			if ((jQuery('#container_EventContent ul.carouselContent').width() - jQuery('#container_EventContent ul.carouselContent li').width()) == jQuery('#container_EventContent').scrollLeft())
			{
				jQuery("#arrow_NextEvent").addClass('hidden');
			}
			else
			{
				jQuery("#arrow_NextEvent").removeClass('hidden');
			}
		});
	});

	jQuery('#event_Featurettes').css('width', ((jQuery('#event_Featurettes li.heroSlide').length) * 874) + 'px');
	
	if (2 > (jQuery('#event_Featurettes li.heroSlide').length))
	{
		jQuery("#arrow_NextEvent").addClass('hidden');
	} 
})

