var origRatio;

function init() {
	var img = document.getElementById("portrait");
	var origWidth = img.width;
	var origHeight = img.height;
	origRatio = origHeight/origWidth;

	var w = window.innerWidth;

fit();
}




function fit() {

	var img = document.getElementById("portrait");
	var w = getWidth();
	
fitInner(w);
	
	/* Safariのフッター位置を制御 */
	if (isSafari()) { 
		document.getElementById("footer").style.position = "static";
	}
	document.body.style.overflowX="hidden";
}

function fitInner(width) {
	var img = document.getElementById("portrait");
	img.width = width;
	img.height = width * origRatio;
}


function isFirefox(){
	var userAgent = navigator.userAgent;
	return (userAgent.indexOf("Firefox")!=-1);
}

function isSafari(){
	var userAgent = navigator.userAgent;
	return (userAgent.indexOf("Safari")!=-1);
}

function getWidth ( ) {  
    if ( window.innerWidth ) {
		return window.innerWidth;
	} else if (document.documentElement && document.documentElement.clientWidth != 0) {
		return document.documentElement.clientWidth;
	}  else if ( document.body ) {
		return document.body.clientWidth;
	}  
    return 0;  
}

function getHeight ( ) {  
    if ( window.innerHeight ) {
		return window.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight != 0) {
		return document.documentElement.clientHeight;
	}  else if ( document.body ) {
		return document.body.clientHeight;
	}  
    return 0;  
}



/* ランダム表示 */
var titleCount ;         //画像の最大枚数
n = Math.floor(Math.random() * titleCount);
imageNumbar = n+1;

document.write('<div ><img src=\"images/background/BackgroundOpening_copyrightmariliadestot.jpg\"id=\"portrait\" /></div>')