/**
 * @author rsweeten
 */
var sPathMGA = window.location.pathname;
var sPageMGA = sPathMGA.substring(sPathMGA.lastIndexOf('/') + 1);

mGA = {
	scrollSpeed: 550,
	speed: 400,
	spEase: 'easeInOutCubic',
	curPage: 0,
	lastInsertedPage: 0, 
	pages: 3,
	pageW: 896, 
	init: $(document).ready(function(e){
		mGA.pages = $('.page').length -1;
		$('#scroller').css('width', (mGA.pages +1) * $('.page').outerWidth());
		
		mGA.inner = $('#scroller');
		$('#leftArrow').click(mGA.cLeft);
		$('#rightArrow').click(mGA.cRight);
	}),
	cLeft: function(e){
		if (mGA.curPage > 0) {
			
			mGA.inner.animate({
				'marginLeft': '+=' + mGA.pageW
			},{'duration':mGA.scrollSpeed, 'easing': mGA.spEase});
			mGA.curPage -= 1;
			mGA.title = $('.page:eq('+mGA.curPage+')').attr('title');
			if(mGA.title != ''){
				$('#interior h1').text(mGA.title);
			}
			if(mGA.curPage == 0)$('#leftArrow').css('visibility', 'hidden');
			if(mGA.curPage != mGA.pages)$('#rightArrow').css('visibility', 'visible');
						
			_gaq.push(['_trackEvent', 'Scrolling', 'Viewed', sPageMGA + '_' + (mGA.curPage + 1)]); 
		}
		e.preventDefault();
	},
	cRight: function(e){
		if (mGA.curPage < mGA.pages) {
			
			mGA.inner.animate({
				'marginLeft': '-=' + mGA.pageW
			},{'duration':mGA.scrollSpeed, 'easing': mGA.spEase});
			mGA.curPage += 1;
			mGA.title = $('.page:eq('+mGA.curPage+')').attr('title');
			if(mGA.title != ''){
				$('#interior h1').text(mGA.title);
			}
			if(mGA.curPage != 0)$('#leftArrow').css('visibility', 'visible');
			if(mGA.curPage == mGA.pages)$('#rightArrow').css('visibility', 'hidden');

			_gaq.push(['_trackEvent', 'Scrolling', 'Viewed', sPageMGA + '_' + (mGA.curPage + 1)]); 
			
		}
		e.preventDefault();
	}
}

