var flexControl={
    requiredMajorVersion:9,
    requiredMinorVersion:0,
    requiredRevision:28,
        
    loadFlash:function(noflash,params)
    {
        var hasRequestedVersion = false;
        if(!noflash)
        {
            hasRequestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
        }
        
        if(hasRequestedVersion)
        {
            var swf = swfUrl;
            if(dev)
                swf+='dev.swf';
            else
                swf+='FA_mediatisPPC.swf?ver='+version;
            
            this.loadContent(swf,'flexContent-mini',params);
        }
        else
        {
            this.setShowCloseWindowPopUp(false);
            window.open('noFlash.jsp','_self');
        }   
    },
    
    getFlash:function(movieName)
    {
    	if (window.document[movieName])
    		return window.document[movieName];
    	if (navigator.appName.indexOf("Microsoft Internet")==-1)
    		if (document.embeds && document.embeds[movieName])
    			return document.embeds[movieName];
    		else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
    			return document.getElementById(movieName);
    },
    
    loadContent:function(swf,divId)
    {
    	//swf, id, w, h, version, color, useExpressInstall, quality("Autolow"), xiRedirectUrl, redirectUrl, detectKey
    	//var so = new SWFObject(swf, 'FA_MiniSimulateurRAC', '285', '325', 9, "#");
	var so = new SWFObject(swf, 'FA_MiniSimulateurRAC', '286', '325', 9, "#");
    	so.addParam('allowScriptAccess','always');
    	so.addParam('WMODE','transparent');
	so.addVariable('co',co);
/*
    	so.addVariable('allowDomain','*');
    	so.addParam('base','.');
    	so.addVariable('labelsUrl',labelsUrl);
    	so.addVariable('assetsUrl',assetsUrl);
    	so.addVariable('gateway', gatewayUrl);
    	so.addVariable('autoFill',autoFill);
    	so.addVariable('nowTimestamp',nowTimestamp);
    	so.addVariable('browserWindowTitle',document.title);
*/
/*
        var keys = ["co","amountPrjInit","addFinPrjInit","durationPrjInit","mensualityPrjInit"];
        for(var i=0; i!=keys.length; ++i)
        { 
          if(params[keys[i]]!=undefined)
             so.addVariable(keys[i],params[keys[i]]);
        }
*/
        so.write(divId);
    },
    
    getFAMediatis:function(){ return this.getFlash('FA_MiniSimulateurRAC'); },
    
    //to fix bug on loading with preloader (getBodyHeight() is the default flex height value)
    setContentHeight:function(height)
    {
    	document.getElementById("right-block-simu").style.height = height + "px";
    	this.getFAMediatis().height = height+6;
    },
    
    //to center popupFlex in the html page (scrollable)
    getCenterPosition:function()
    {
    	var centerPosition = document.body.scrollTop + this.getBodyHeight()/2;
    //alert('centerPosition:' + centerPosition + ' scrollTop:' + document.body.scrollTop + ' getBodyHeight:' + getBodyHeight())
    	return centerPosition;
    },
    
    getBodyWidth:function()
    {
    	var width;
    	if( typeof( window.innerWidth ) == 'number')
    	{
    	   width = window.innerWidth-18;
    	}
    	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
    	{
    	   width = document.documentElement.clientWidth;
    	}
    	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ))
    	{
    	   width = document.body.clientWidth;
    	}
    	return width;
    },
    
    getBodyHeight:function()
    {
    	var height;
    	if( typeof( window.innerWidth ) == 'number')
    	{
    	   height = window.innerHeight;
    	}
    	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ))
    	{
    	   height = document.documentElement.clientHeight;
    	}
    	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ))
    	{
    	   height = document.body.clientHeight;
    	}
    	return height;
    },
     
    openUrl:function(url,target){ window.open(url,target); }
};
