var isIE = (document.getElementById && document.all)?true:false;
var isNS4 = (document.layers)?true:false;
var isNS6 = (document.getElementById && !document.all)?true:false;
function myGetElementById(id) {
	if ( isIE ) {
		var str = "document.all('" + id + "')";
		var o = eval(str);
		return o;
	}
	return document.getElementById(id);
}

var pageWidth;
var pageHeight;

function findDimensions() { 
try{ 
    
	var frameWidth;
    var frameHeight;
    var obj;
	
    if (document.documentElement && document.documentElement.clientWidth && !(navigator.appVersion.indexOf('Safari') != -1) ) {
		frameWidth = document.documentElement.clientWidth;
		frameHeight = document.documentElement.clientHeight;
	} else if (self.innerWidth) {
		frameWidth = self.innerWidth;
		frameHeight = self.innerHeight;
    } else if (document.body) {
		frameWidth = document.body.clientWidth;
		frameHeight = document.body.clientHeight;
    } else
		return;


    pageWidth = frameWidth;
    pageHeight = frameHeight;
	
    if ( (obj = myGetElementById('background')) ) {
		obj.style.width = frameWidth+'px';
		obj.style.height = frameHeight+'px';
    }

    if ( (obj = myGetElementById('background_image')) ) {
		Img = new Image();
		if(obj.src.indexOf('pix.gif') >= -1 && Home){

			Img.src = g_ImageTable[0][0];

		} else {
			Img.src = obj.src;
		}
		
		Img.onload = function(){
			fixImage(obj, Img, frameWidth, frameHeight);
		}
		
		fixImage(obj, Img, frameWidth, frameHeight);
    }
	setTimeout("findDimensions()",5000);
  
  } catch(err){ 
	    var text= document.createTextNode('<!--  Erreur js (resize.js)'+err+'  -->');
	    document.body.appendChild(text);
  }
}

function fixImage(obj, Img, frameWidth, frameHeight){

	
	var iWidth = Img.width;
	var iHeight = Img.height;
	var iRatio = iWidth / iHeight;
	var fRatio = frameWidth / frameHeight;
	
	obj.style.top = obj.style.left = 0;

	if (Math.round(iRatio) >= Math.round('16/9')) {
		if ( iRatio < fRatio ) {
			obj.style.height = frameHeight+'px';
			obj.style.width = (frameHeight * iRatio)+'px';
		} else {
			obj.style.width = frameWidth+'px';
			obj.style.height = (frameWidth / iRatio)+'px';
		}
	} else {
		if ( iRatio < fRatio ) {
			obj.style.width = frameWidth+'px';
			obj.style.height = (frameWidth / iRatio)+'px';
		} else {
			obj.style.height = frameHeight+'px';
			obj.style.width = (frameHeight * iRatio)+'px';
		}
	}
}
addLoadEvent(findDimensions);
addResizeEvent(findDimensions);

