var lastWidth = 0;
var lastHeight = 0;
var orgImageWidth = 0;
var orgImageHeight = 0;

var alertTimerId = 0;

function resizeReload() {
	if(navigator.appName == "Microsoft Internet Explorer"){
		clearTimeout (alertTimerId);
		alertTimerId = setTimeout(fitImage, 1000);
	} else {
		fitImage();
	}
}

function resizeReload2() {
	if(navigator.appName == "Microsoft Internet Explorer"){
		clearTimeout (alertTimerId);
		alertTimerId = setTimeout(fitImage2, 1000);
	} else {
		fitImage2();
	}
}

function fitImage() {
	var wWidth;
	var wHeight;
	// --
 	if (typeof window.innerWidth != 'undefined') {
		wWidth = window.innerWidth,
		wHeight = window.innerHeight
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		wWidth = document.documentElement.clientWidth,
		wHeight = document.documentElement.clientHeight
	} else {
		wWidth = document.getElementsByTagName('body')[0].clientWidth,
		wHeight = document.getElementsByTagName('body')[0].clientHeight
	}
	wHeight-=220;
	// --
	var iWidth = fotka.width;
	var iHeight = fotka.height;
	// --
	if (orgImageWidth == 0) {
		orgImageWidth = iWidth;
		orgImageHeight = iHeight;
	}
	// --
	var wRatio = wWidth/wHeight;
	var iRatio = orgImageWidth/orgImageHeight;
	// --
	if (wRatio > iRatio) {
		fotka.width = wWidth;
		fotka.height = (orgImageHeight*wWidth)/orgImageWidth;
	} else {
		//fotka.width = wWidth;
		//fotka.height = (orgImageHeight*wWidth)/orgImageWidth;
		fotka.height = wHeight;
		fotka.width = (orgImageWidth*wHeight)/orgImageHeight;
	}
	el = document.getElementById("fitImage");
	el.width = fotka.width;
	el.height = fotka.height;
	el.src = fotka.src;
}

function fitImage2() {
	var wWidth;
	var wHeight;
	// --
 	if (typeof window.innerWidth != 'undefined') {
		wWidth = window.innerWidth,
		wHeight = window.innerHeight
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		wWidth = document.documentElement.clientWidth,
		wHeight = document.documentElement.clientHeight
	} else {
		wWidth = document.getElementsByTagName('body')[0].clientWidth,
		wHeight = document.getElementsByTagName('body')[0].clientHeight
	}
	wHeight-=224;
	// --
	el = document.getElementById("fitImage");
	el.width = wWidth;
	el.height = wHeight;
	el.src = 'pics/transparent.gif';
}