// Positionne le footer selon la résolution verticale, swfH déclaré dans la <head>
function PosFooter() {
    var dFooter = document.getElementById('footer');
    var wrapBorder = parseInt(getStyle(document.getElementById('wrap'), 'border-top-width'));
    var footerMargin = parseInt(getStyle(dFooter, 'margin-top'));
    var totalH = swfH + wrapBorder + footerMargin;
    //~ alert(swfH+' '+totalH);
    if(winH >= totalH) {
	dFooter.style.position = 'absolute';
	dFooter.style.bottom = '0';
	dFooter.style.left = '0';
    }
}
function getStyle(x, styleProp) {
    //~ var x = document.getElementById(x);
    if(typeof(x) != 'object') return false;
    if (window.getComputedStyle) {
        var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
    }
    else if (x.currentStyle) {
	styleProp = parseSP(styleProp);
        var y = x.currentStyle[styleProp];
    }
    return y;
}
// For IE
function parseSP(str) {
    if(typeof(str) != 'string') return '';
    if(str.indexOf('-') != -1) {
	var tmpStr = str.split('-');
	for(var i = 1; i < tmpStr.length; ++i) {
	    tmpStr[i] = tmpStr[i].charAt(0).toUpperCase() + tmpStr[i].substr(1);
	}
	str = tmpStr.join('');
	//~ alert(str);
    }
    return str;
}

function PosInfos(IE6) {
    var estimH = 700;
    var eInfos = document.getElementById('infos');
    if(IE6 || winH < estimH) eInfos.style.position = 'absolute';
    var infos_x = Math.floor((winW - 980) / 2) - 10;
    eInfos.style.left = infos_x+'px';
    
    if(IE6 && (flashvars['pageToLoad'] == 'news') && winH >= estimH) {
	var infos_y = winH - 280 - 20;
	eInfos.style.top = infos_y+'px';
	window.onscroll = function() {
	    eInfos.style.top = (window.pageYOffset) ? infos_y+window.pageYOffset+'px' : infos_y+document.documentElement.scrollTop+'px';
	}
    }
}

var winW, winOW, winH, winOH = 0;
if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    winW = window.innerWidth;
    winH = window.innerHeight;
    winOW = window.outerWidth;
    winOH = window.outerHeight;
} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    winW = document.documentElement.clientWidth;
    winH = document.documentElement.clientHeight;
    //~ winW = document.body.offsetWidth;
    //~ winH = document.body.offsetHeight;
    winOW = document.documentElement.offsetWidth;
    winOH = document.documentElement.offsetHeight;
}
var scrW = screen.availWidth;
var scrH = screen.availHeight;
//~ alert('this window: '+winOW+' (out) '+winW+' (in) x '+winOH+' (out) '+winH+' (in)\nscreen (avail.): '+scrW+' x '+scrH);

//~ alert('le swf mesure: '+swfW+' x '+swfH);
if((winW - 30) < 980) {
    //on redimensionne la fenetre
    if(scrW >= 1024) {
	self.resizeTo(1024, winOH);
    }
}
if(winH < 700) {
    if(scrH >= 860) {
	self.resizeTo(winOW, 860);
    }
}

window.onload = function() {
    PosFooter();
    PosInfos();
};

