var contentElementWidth = 950;
var currentIndex = 1;
var elementCount = 0;
var elementOffset = 0;

$(document).ready(function() {
	
	popup();
	gaFile();
	
	elementCount = $('.innerIntro').children('img').length;
	totalElementsWidth = elementCount * contentElementWidth; 
	$('.innerIntro').width(totalElementsWidth);
	$('.innerIntro').css({'position': 'relative'});
	
	$('.leftArrow').click(function(e) {
		e.preventDefault();
		$('.innerIntro').stop(true, true);
		if(currentIndex > 1) {
			currentPosition = elementOffset;
			elementOffset = currentPosition - contentElementWidth;
		    newPosition = elementOffset; 
		    currentIndex = currentIndex-1;
		    $('.innerIntro').animate({right: newPosition+'px'}, 500, "swing");
		}
	});
	
	$('.rightArrow').click(function(e) {
		e.preventDefault();
		$('.innerIntro').stop(true, true);
		if(currentIndex < elementCount) {
			currentPosition = elementOffset;
			elementOffset = currentPosition + contentElementWidth;
		    newPosition = elementOffset; 
		    currentIndex = currentIndex+1;
		    $('.innerIntro').animate({right: newPosition+'px'}, 500, "swing");
		}
	});
		                                            
	
});

function popupWindow(url, name, attributes){
	var newWindow = window.open(url, name, attributes);
	newWindow.focus();
} 


function popup() {
	$('a.popupLink').bind('click', function(e) { popupWindow($(this).attr('href'), $(this).attr('title').replace(/[^A-z]/ig, ''),'width=540, height=540, scrollbars'); e.preventDefault(); });
};

function gaFile() {
	$('a.ga-file-tracker').bind('click', function(e) {
		_gaq.push(['_trackPageview', $(this).attr('href')]);
	});
};
