var bgImg = document.getElementById('bgimg');
bgImg.setAttribute("onload", "resize();");
document.body.setAttribute("onresize", "resize();");
setTimeout(resize, 2500);
var orgW = orgH = 0;
function resize() {
	var h = w = 0;
	if(orgH == 0 || orgW == 0) {
  	var oImg = new Image();
    oImg.src = bgImg.src;
    orgW = oImg.width;
    orgH = oImg.height;
	}
	if(window.innerWidth) {
  	w = window.innerWidth;
  	h = window.innerHeight;
	} else if(document.documentElement && document.documentElement.clientWidth && document.documentElement.clientWidth != 0) {
	  w = document.documentElement.clientWidth;
	  h = document.documentElement.clientHeight;
	} else {
	  w = document.body.clientWidth;
	  h = document.body.clientHeight;
	}
	var ratioW = w / orgW;
	var ratioH = h / orgH;
	if(ratioW > ratioH) {
		bgImg.height = w * orgH / orgW;
		bgImg.width = w;
	} else {
		bgImg.height = h;
		bgImg.width = h * orgW / orgH;
	}
	deployFunctions();
}
resize();
