var image_height
var image_width

$(document).ready(function () {
	
	image_width = 	$("#border img").width()
	image_height = 	$("#border img").height()
	
	image_ratio = image_width / image_height
	
	min_width = 760
	
	init()
	
});

function init(){
	
	set_values()
	size_border()
	size_image()
	
	set_image_scroller_heights()
	move_mid_screen()
		
}
var currheight;
window.onresize = function(){
	init()
	
}

var border_width = 10;

function size_border(){
	$("#border").css({
		height: winH - (border_width *2)
	})
}
function set_values(){
	if($.browser.msie){
		winW = document.body.offsetWidth
		winH = $(window).height()
	}
	else{
		winW = window.innerWidth;
		winH = Math.max(window.innerHeight, $("#inner_mask").height() + 220)
	}
}
function size_image(){
	
	ratioW = winW / image_width
	ratioH = $('#border').height() / image_height
	
	
	var new_w = image_width * ratioW
		
		
		
	if(ratioW > ratioH){

	//Width is greater than height
		if(new_w > min_width){
			$("#border img").css({
				width: (image_width * ratioW) - (border_width *2),
				height: (image_height * ratioW) - (border_width *2)
			})
		}				
	}				
	else{
		$("#border img").css({
			width: (image_width * ratioH) - (border_width *2),
			height: (image_height * ratioH) - (border_width *2) + 20
		})
	
	}	
	if(new_w > min_width){
		$("#border").css({
			width: winW - (border_width *2),
			height: winH - (border_width *2),
			overflow: "hidden"
		})
	}
	
}


