var timerbg, opacity, interval;

		function showimage(img) {
			//var maxheight=445;
			//var maxwidth=345;

			var maxheight=640;
			var maxwidth=480;

			var image=new Image();
			image.onload=imageLoaded;
			image.src=img;
			
			function imageLoaded() {
				width=image.width;
				height=image.height;

				document.getElementById('main_image').src=img;
				if (width>height) {
					document.getElementById('main_image').height=(height/width)*maxwidth;
					document.getElementById('main_image').width=maxwidth;
					document.getElementById('mainimage').style.background="#4e4e54";
				} else {
					document.getElementById('main_image').height=maxheight;
					document.getElementById('main_image').width=(width/height)*maxheight;
					document.getElementById('mainimage').style.background="transparent";
				}
				if (document.getElementById('main_image').height>maxheight)
					document.getElementById('main_image').height=maxheight;
				if (document.getElementById('main_image').width>maxwidth)
					document.getElementById('main_image').width=maxwidth;
					
			}
		}
		
		function showimage1(img) {
			var maxheight=445;
			var maxwidth=345;

			var image=new Image();
			image.onload=imageLoaded;
			image.src=img;
			
			function imageLoaded() {
				width=image.width;
				height=image.height;

				document.getElementById('main_image').src=img;
				if (width>height) {
					document.getElementById('main_image').height=(height/width)*maxwidth;
					document.getElementById('main_image').width=maxwidth;
					document.getElementById('mainimage').style.background="#4e4e54";
				} else {
					document.getElementById('main_image').height=maxheight;
					document.getElementById('main_image').width=(width/height)*maxheight;
					document.getElementById('mainimage').style.background="transparent";
				}
				if (document.getElementById('main_image').height>maxheight)
					document.getElementById('main_image').height=maxheight;
				if (document.getElementById('main_image').width>maxwidth)
					document.getElementById('main_image').width=maxwidth;
					
			}
		}
		

	function fadingOut1() {
		var step=0.08;
		var obj=new Array();
		opacity-=step;

		if (opacity<0) {
			clearInterval(interval);
			opacity=0;
			obj[0]=document.getElementById("bg1");
			for (i=0;i<1;i++) {
				obj[i].style.opacity = opacity;
				obj[i].style.filter = 'alpha(opacity=' + opacity*100 + ')';
				obj[i].style.display="none";
				obj[i].style.zIndex=0;
			}
			
			var to=setTimeout("startAnimation2()",1000);			
		} else {
			obj[0]=document.getElementById("bg1");
			for (i=0;i<1;i++) {
				obj[i].style.opacity = opacity;
				obj[i].style.filter = 'alpha(opacity=' + opacity*100 + ')';
			}
		}
}

	function fadingOut2() {
		var step=0.08;
		var obj=new Array();
		opacity-=step;

		if (opacity<0) {
			clearInterval(interval);
			opacity=0;
			obj[0]=document.getElementById("bg2");
			for (i=0;i<1;i++) {
				obj[i].style.opacity = opacity;
				obj[i].style.filter = 'alpha(opacity=' + opacity*100 + ')';
				obj[i].style.display="none";
				obj[i].style.zIndex=0;
			}
						
		} else {
			obj[0]=document.getElementById("bg2");
			for (i=0;i<1;i++) {
				obj[i].style.opacity = opacity;
				obj[i].style.filter = 'alpha(opacity=' + opacity*100 + ')';
			}
		}
}

function startAnimation1 () {
	var elem;
	clearTimeout(timerbg);
	opacity=1;
	interval=setInterval(fadingOut1, 60);
}

function startAnimation2 () {
	var elem;
	clearTimeout(timerbg);
	opacity=1;
	interval=setInterval(fadingOut2, 60);
}