
var delays = { normal:20, checking: 200 };
delays.current = delays.normal;

function resizeimage(){	
	img = new Image();
	img.src = newImage;
	img.onLoad = LoadMainimage();
}			



function LoadMainimage(){
	var state = img.complete? "normal":"checking";
		if(state =="normal")
			{
			if (img.width > img.height)
				{
					document.getElementById("thephoto").style.width = Imgwdth + "px";
					document.getElementById("thephoto").style.height = Math.ceil((img.height/img.width)*Imgwdth) + "px";
				}else{
				document.getElementById("thephoto").style.height = Imghght + "px";
				document.getElementById("thephoto").style.width = Math.ceil((img.width/img.height)*Imghght) + "px";
				}
				document.getElementById("thephoto").src = newImage;
				initImage()
				}else{
				delays = { normal:20, checking: 200 };
				delays.current = delays.checking;
				setTimeout("LoadMainimage()", delays[state]);
				}

			}





 
function initImage() {
	imageId = "thephoto";
	
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = "visible";
	fadeIn(imageId,0);
}

function fadeIn(objId,opacity) {

	if (document.getElementById) {
		obj = document.getElementById(objId);
		if (opacity <= 100) {
			setOpacity(obj, opacity);
			opacity += 10;
			window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
		}
	}
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;
	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}



