var main_image_original_width = 1920;
var main_image_original_height = 1076;
var pic_width = main_image_original_width;
var pic_height = main_image_original_height;
 
function resize_image() {
	var win_width = $(window).width();
	var win_height = $(window).height();
	var win_aspect_ratio = win_width / win_height;
	
	current_width = $('#img-container img').width();
	if (current_width > 1) {
		pic_width = current_width;
	}	

	current_height = $('#img-container img').height();
	if (current_height > 1) {
		pic_height = current_height;
	}
	
	var pic_aspect_ratio = pic_width / pic_height;
	var new_height = $(window).height();
	var new_width = $(window).width();
	if (win_aspect_ratio > pic_aspect_ratio) {
		// scale pic to fit window width
		var new_height = (win_width / pic_width) * pic_height;
	} else {
		// scale pic to fit window height		
		var new_width = (win_height / pic_height) * pic_width;
	}
	
	// center image
	new_top = 0 - ((new_height - win_height) / 2);
	new_left =  0 - ((new_width - win_width) / 2);

	//alert("win_height: "+win_height+"; win_width: "+win_width+"; pic aspect ratio: "+pic_aspect_ratio+"; win aspect ratio: "+win_aspect_ratio+"; new height: "+new_height+"; new width: "+new_width+"; new top: "+new_top+"; new left: "+new_left);
	$('#img-container img').css({
		'top': new_top, 
		'left': new_left,
		'height': new_height,
		'width': new_width
	});
}

/////////Ostensibly the image swapping functions.
function swapImgTo(nextImgId){
	var next_id = '#'+nextImgId+' img';
	if($(next_id).length != 0)
	{
		$('#img-container img').hide();
		$(next_id).show();
	}
};
function swapImgNext(currID){
	var nextID = currID*1;
	swapImgTo(nextID+1);
};
function swapImgPrev(currID){
	var nextID = currID*1;
	swapImgTo(nextID-1);
};

