// close box of the maternelle games (swf)
var myWidth = 0;
var myHeight = 0;
function setSizes() {
  
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
}
setSizes();

function writeIFrame( w, h, theUrl ){
	var H_SAFE_AREA = 110;
	var W_SAFE_AREA = 100;
    writeSpecificIFrame( w, h, theUrl, H_SAFE_AREA, W_SAFE_AREA );
}

function writeIFrameFullView( w, h, theUrl ){
    var H_SAFE_AREA = 10;
    var W_SAFE_AREA = 60;
    writeSpecificIFrame( w, h, theUrl, H_SAFE_AREA, W_SAFE_AREA );
}

function writeSpecificIFrame( w, h, theUrl, safeAreaH, safeAreaW ){

    var maxHeight = myHeight - safeAreaH;
    var maxWidth = myWidth - safeAreaW;
    
    var widthOnHeightRatio = w / h;
    
    var appWidth;
    var appHeight;
    if( widthOnHeightRatio * maxHeight > maxWidth ){
        // take width as ref
        appWidth = maxWidth;
        appHeight = appWidth * 1 / widthOnHeightRatio;
    }else{
        // take height as ref
        appHeight = maxHeight;
        appWidth = appHeight * widthOnHeightRatio;
    }
    
    var iFrameStr = '<iframe scrolling="No" marginheight="0" marginwidth="0"  frameborder="0" align="top" src ="'+theUrl+'" width="'+appWidth+'px" height="'+appHeight+'px">';
    iFrameStr += '<p>Your browser does not support iframes.</p>';
    iFrameStr += '</iframe>';
    document.write( iFrameStr );
}