function homeAccordion() 
{
	var defaultPic = "http://www.clarkconstruction.com/images/sections/home/default.jpg";
	/*set each of the accordion sections to display (they are set to display:none so the page does not expand and then contract on document.load)*/
	$$('.story_content p').each(function(item, index) {
		item.setStyle('display', 'block');
	});
	/*set up the mootools accordion*/
	var acc = new Accordion( $$('.story'), $$('.story_content'), 
	{
		duration: 200,
		opacity: (Browser.Engine.trident) ? false : true,
		height: (Browser.Engine.trident) ? false : true,
		onActive: function (toggler, element) 
		{
			if (Browser.Engine.trident)
			{
				element.setStyle('display', 'block');
			}
			
			
			/*set the active css*/
			toggler.addClass('story_active');
			/*element.addClass('content_active');*/
			
			/*set the image*/
			var newsElement = element.getElement('img');
			if (newsElement)
			{
				var newsSrc = newsElement.getProperty("src");	
			}
			
			/*link the image*/
			var newsLink = element.getElement('a');
			if (newsLink)
			{
				newsLink = newsLink.getProperty('href');
			}
			
			if (newsSrc) /*the story has a pic*/
			{
				(newsLink) ? $('story_pic').set('html', '<a href="' + newsLink +'"><img src="' + newsSrc + '" alt="" /></a>'): $('story_pic').set('html', '<img src="' + newsSrc + '" alt="" />');
			}
			else /*the story does not have a pic*/
			{
				/*if there is an image and it is the default pic, leave it*/
				if ($('story_pic').getElement('img'))
				{
					if ( $('story_pic').getElement('img').getProperty('src') != defaultPic)
					{
						(newsLink) ? $('story_pic').set('html', '<a href="' + newsLink +'"><img src="' + defaultPic + '" alt="" /></a>'): $('story_pic').set('html', '<img src="' + defaultPic + '" alt="" />');
					}
				}
				else /*if there is no pic, than create the default pic*/
				{
					(newsLink) ? $('story_pic').set('html', '<a href="' + newsLink +'"><img src="' + defaultPic + '" alt="" /></a>'): $('story_pic').set('html', '<img src="' + defaultPic + '" alt="" />');
				}
			}
		},
		onBackground: function(toggler, element) {
			/*remove the active css*/
			toggler.removeClass('story_active');
			/*element.removeClass('content_active');*/
			if (Browser.Engine.trident)
			{
				element.setStyle('display', 'none');
			}
		}
	});	
}

window.addEvent('domready', function() {homeAccordion();});
