var MyWidth = 0, MyHeight = 0;
var LoadWidth = 0, LoadHeight = 0;
function getAvailableWindowSize() {
        if( typeof( window.innerWidth ) == 'number' ) {
                MyWidth = window.innerWidth; MyHeight = window.innerHeight;
        } else if( document.documentElement && ( document.documentElement.clientWidth ||document.documentElement.clientHeight ) ) {
                MyWidth = document.documentElement.clientWidth; MyHeight = document.documentElement.clientHeight;
        } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
                MyWidth = document.body.clientWidth; MyHeight = document.body.clientHeight;
        }
}
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;
if (checkIt('konqueror'))
{
        browser = "Konqueror";
        OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
        browser = "Netscape Navigator"
        version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
        if (checkIt('linux')) OS = "Linux";
        else if (checkIt('x11')) OS = "Unix";
        else if (checkIt('mac')) OS = "Mac"
        else if (checkIt('win')) OS = "Windows"
        else OS = "an unknown operating system";
}
//alert(browser);

function checkIt(string)
{	// alert("dans la fonction 'checkIt', la variable 'string' vaut : " + string);
        place = detect.indexOf(string) + 1;
        thestring = string;
        return place;
}




function writeMainSWFCode(PathToFile) {
    // maximiseWin();
     getAvailableWindowSize();
     //If not near maximized, set the values
     if(MyWidth<screen.availWidth-30){
       MyWidth=screen.availWidth;
     }
     if(MyHeight<screen.availHeight*0.7){
       MyHeight=screen.availHeight*0.7;
     }

   if (browser == "Safari" || browser == "Netscape Navigator" ){
     // 5 is good for Netscape. 6 is good for Firefox
     MyWidth=MyWidth-14;
     MyHeight=MyHeight-14;
      // alert(browser);
    }

    // use the height as the basis for calculation, then adapt width...
     LoadWidth =  MyWidth;
     LoadHeight = MyHeight;
 if(LoadWidth > LoadHeight*1.428571429){
 // height is at max - set width according to that
    LoadWidth =  LoadHeight*1.428571429;
 } else if(LoadWidth < LoadHeight*1.428571429){
     ///width is at max - calculkate the height that goes wityh it
     LoadHeight=LoadWidth/1.428571429;
 }

    //  alert("LoadWidth=" + LoadWidth + " LoadHeight=" + LoadHeight);

   writeSWFCode(PathToFile,'','elie', 1000, 560);
}

/*****************************************************************
* Flash Fix script
* Fixes embedded object activation issues in Internet Explorer
*****************************************************************/
function writeSWFCode(movie,var_string , movie_name, width, height, bgcolor,flash_align,flash_menu,flash_scale,flash_wmode,flash_version,flash_hspace,flash_vspace){
   if(bgcolor == '' || bgcolor == undefined){
   //Default color is white... WHen the BG color to a movie is a color, the Background to any print job will be that color too !
    bgcolor = '#ffffff';
   }
   if(flash_version == '' || flash_version == undefined){
    flash_version = '6,0,29,0';
   }
   if(flash_align == '' || flash_align == undefined){
    flash_align = 'middle';
   }
   if(flash_menu == '' || flash_menu == undefined){
    flash_menu = 'false';
   }
   if(flash_hspace == '' || flash_hspace == undefined){
    flash_hspace = '0';
   }
   if(flash_vspace == '' || flash_vspace == undefined){
    flash_vspace = '0';
   }

   if(flash_wmode == '' || flash_wmode == undefined){
    flash_wmode_object='';
    flash_wmode_embed='';
   }else{
    flash_wmode_object='<PARAM NAME="wmode" VALUE="'+flash_wmode+'">';
    flash_wmode_embed=' wmode="'+flash_wmode+'" ';
   }
   if(flash_scale == '' || flash_scale == undefined){
    flash_scale='exactfit';
   }
  if(OS=='Mac' && browser=='Safari'){
  //Safari does not accept Flash Vars.
  //It also bugs when the embed tag is there. After 10 reloads...
  //The javascript is activated but the flash does not display
    //If show only object tag, it seems to work 100%
   flash_code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flash_version+'" name="'+movie_name+'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" id="'+movie_name+'" align="'+flash_align+'"><param name="movie" value="'+movie+'?'+ var_string +'"><param name="quality" value="high"><param name="SCALE" value="'+flash_scale+'"><param name="BGCOLOR" value="'+bgcolor+'"><PARAM NAME="menu" VALUE="'+flash_menu+'">'+flash_wmode_object+'</object>';
  }else{
   flash_code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+flash_version+'" name="'+movie_name+'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" id="'+movie_name+'" align="'+flash_align+'"><param name="movie" value="'+movie+'"><PARAM NAME=FlashVars VALUE="'+ var_string +'"><param name="quality" value="high"><param name="SCALE" value="'+flash_scale+'"><param name="BGCOLOR" value="'+bgcolor+'"><PARAM NAME="menu" VALUE="'+flash_menu+'">'+flash_wmode_object+'<embed src="'+movie+'"  FlashVars="'+ var_string +'" width="'+width+'" height="'+height+'" hspace="'+flash_hspace+'" vspace="'+flash_vspace+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="'+flash_scale+'" menu='+flash_menu+' name="'+movie_name+'" bgcolor="'+bgcolor+'" '+flash_wmode_embed+' align="'+flash_align+'"></embed></object>';
   }
   document.write(flash_code);
  // alert(flash_code);
}

