/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	*/
/*	File: 				main.js
/*	Description:		Contains all master javascript code.
/*	Target browsers:	IE6+, Mozilla/Firefox, Safari, Opera
/*	Author(s):			J. Jackson | jjackson@jplcreative.com
/*	Created: 			04.21.2010
/* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++	*/

/* +++++ custom scripts +++++ */
/* +++++ require jquery 1.4.2 +++++++++++++++++++++++++++++++++++++++++ */
$(function(){
	// bind click events to accordians
	$('#ajax-nav li').click(function() { accordian(this) });
	// assign flash replacement content from xml document
	$.ajax({
		type: "GET",
		url: "/lib/xml/portal.xml",
		dataType: "xml",
		success: function(xml) { 
			$(xml).find('item').each(function(index) {
				$('#ajax-nav li:eq(' + index + ') img').attr('src', $(xml).find('item:eq(' + index + ')').attr('src'));
				$('#ajax-nav li:eq(' + index + ') img').attr('alt', $(xml).find('item:eq(' + index + ')').attr('title'));
				$('#ajax-nav li:eq(' + index + ') a').attr('href', 'http://' + $(xml).find('item:eq(' + index + ')').attr('url'));
				$('#ajax-nav li:eq(' + index + ') a').attr('title', $(xml).find('item:eq(' + index + ')').attr('title'));
				$('#ajax-nav li:eq(' + index + ') a').text($(xml).find('item:eq(' + index + ')').attr('title'));
			});
		}
	});
});
function accordian(e) {
	if ( $(e).hasClass('active') != true ) {
		$('#ajax-nav li').unbind('click');
		$('.active').attr('href','#').animate({ width: '-=300' }, 750);
		$(e).siblings('li').removeClass('active');
		$(e).animate({
				width: '+=300'
			}, 750, function() {
				$(e).addClass('active');
				$('#ajax-nav li').click(function() { accordian(this) });
		});
	}
}
