/**
 @author Antidote X, Inc.
**/

function ToggleAccordian()
{
	/**toggle all the divs shut that don't have their actuator link className set to "on"*/


	$('ul.services-expandable div.scItemContent').each(function(e)
	{
		if (typeof (this.ParentLink) == "undefined")
		{
			this.ParentLink = $('a.scItemActuator', this.parentNode);
		}

		if (this.ParentLink)
		{
			if (Contains($(this.ParentLink).attr('class'), ' on'))
			{
				$(this).slideUp('fast');
			}
		}
	});

	/**play with the list item we juct clicked on; open if closed, close if open*/
	var myClass = $(this).attr("class");
	
	if ($(this))
	{
		if (Contains(myClass, 'on'))
		{
			$(this).removeClass('on');
		}
		else
		{
			$('ul.services-expandable> li a.scItemActuator').removeClass('on');
			$(this).addClass('on');

			$('div.scItemContent', this.parentNode).slideToggle('fast');
		}
	}
}

$(document).ready(function()
{
	if (typeof ($.preloadCssImages) == "function")
	{	/*for some reason, this undefined by the time the document loads...*/
		$.preloadCssImages();
	}

	// scroll to top
	$('#backtotop a').click(function()
	{
		$.scrollTo(0, 500);
		return false;
	});

	/* ------------------------------ Drop Down Stuff ------------------------ */
	$('ul#mainNav li#menu1').hover(
			function()
			{
				$('div.subLinks', this).css('display', 'block');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-aboutus-over.jpg' });
			},
			function()
			{
				$('div.subLinks', this).css('display', 'none');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-aboutus.jpg' });
			});

	$('ul#mainNav li#menu2').hover(
			function()
			{
				$('div.subLinks', this).css('display', 'block');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-services-over.jpg' });
			},
			function()
			{
				$('div.subLinks', this).css('display', 'none');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-services.jpg' });
			});

	$('ul#mainNav li#menu3').hover(
			function()
			{
				$('div.subLinks', this).css('display', 'block');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-industries-over.jpg' });
			},
			function()
			{
				$('div.subLinks', this).css('display', 'none');
				$('img.menuBtn', this).attr({ src: '/images/mainNav-industries.jpg' });
			});

	/* ------------------------------ jquery accordian effect ------------------------ */

	$('ul.services-expandable div.scItemContent').each(function(e)
	{
		this.ParentLink = $('a.scItemActuator', this.parentNode);
		$(this).hide();
	});

	$('ul.services-expandable > li a.scItemActuator').click(ToggleAccordian);

	/* ------------------------------ nifty rounded corners effect ------------------------ */
	if ($.browser.msie == true && $.browser.version < 8)
	{
		// don't load the nifty corners. they are broken in old version of IE.
	} else
	{
		Nifty("ul.staffNavMain a", "small transparent");
		Nifty("ul.newsNavMain a", "small transparent");
	}



	/* ----------------------------- End of Document Ready ---------------------------- */
});


