var pages;
var pageWidth = 550;

function resizePopup() {
	$('.orangePopup').height( $(window).height() - 50 );
}

function initPopupPages(){
	pages = $('.orangePopupPage');
	
	var xPos = 0;
	pages.each( function( index, page ){
		
		$(page).css( 'left', xPos );
		xPos += pageWidth;
	});
	
	gotoPage( 0 );
	
	addPagination();
	
}

function addPagination(){
	var container = $('<div class="pageButtonContainer"></div>');
	$('.orangePopup').append( container );
	pages.each( function( index, page ){
		
		var pageButton = $('<div class="pageButton"></div>');
		if( index != 0 ){
			pageButton.addClass( 'inactive' );
		}
		pageButton.click( function(){
			gotoPage(index);
			$('.pageButton').addClass('inactive');
			pageButton.removeClass('inactive');
		} );
		container.append( pageButton );
	});
}

function gotoPage( index ) {
	
	var xPos = index * -pageWidth;
	pages.each( function( index, page ){
		 $(page).animate({
			    left: +xPos,
			  }, 1000, function() {} );
		 xPos += pageWidth;
	});
}

