

/** First write the HTML fallback to the page, so it'll be there even for devices that have poor JS support. **/
document.write("<div class='botrplayer' id='botr_salonterre_div'><a href=\"http://siteweb.caplorient.fr/fileadmin/user_upload/Portail_cap/videos/2009/Hulot-2_1.flv\" title=\"Salon terre\" style='display:block; width:400px; height:330px; background: #003300; text-indent:-999px;'>Click to play video</a></div>");



/** Now define the BotR initialization class **/
if (typeof(BotR) == 'undefined') { var BotR = new Object(); }
BotR.swf = function (src,id,width,height,bgcolor,flv) {
    if (!document.getElementById) { return; }
    this.source = src;
    this.id = id;
    this.width = width;
    this.height = height;
    this.params = {
        'bgcolor':bgcolor,
        'allowfullscreen': 'true',
        'allowscriptaccess': 'always'
    };
    this.flv = flv;
    this.flashvars = new Object();
    this.version = this.getVersion();
    if (!window.opera && document.all && parseInt(this.version.split(',')[0]) > 7) {
        // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
        if (!BotR.unloadSet) {
            BotR.prepUnload = function() {
                __flash_unloadHandler = function(){};
                __flash_savedUnloadHandler = function(){};
                window.attachEvent("onunload", BotR.cleanupSWFs);
            }
            window.attachEvent("onbeforeunload", BotR.prepUnload);
            BotR.unloadSet = true;
        }
    }
}
BotR.swf.prototype = {
    /** Overwrite the div contents with the player, if the right Flash version is there.  **/
    loadSWF: function () {
        var major = parseInt(this.version.split(',')[0]);
        var minor = parseInt(this.version.split(',')[2]);
        var divid = this.id + '_div';
        if(major < 9) {
            return;
        } else if (major == 9 && minor < 98) {
            if(this.flv) {
                this.setFlashvar('file',this.flv);
                this.setFlashvar('hd.state','false');
            } else { 
                return;
            }
        } else {
            this.params['wmode'] = 'opaque';
        }
        document.getElementById(divid).innerHTML = this.swfHtml();
    },
    /** Return the Flash plugin version to javascript. **/
    getVersion: function () {
        try {
            try {
                var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6');
                try { axo.AllowScriptAccess = 'always'; }
                catch(e) { return '6,0,0'; }
            } catch(e) {}
            return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1];
        } catch(e) {
            try {
                if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){
                    return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1];
                }
            } catch(e) {}
        }
        return '0,0,0';
    },
    /** Create the HTML string needed for the flash embed. **/
    swfHtml:function() {
        var html = "";
        var fv = this.getFlashvars();
        if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
            html = '<embed type="application/x-shockwave-flash" src="'+ this.source +'" width="'+ this.width +'" height="'+ this.height +'"';
            html += ' id="'+ this.id +'" name="'+ this.id +'" ';
            for(var key in this.params) { 
                html += [key] +'="'+ this.params[key] +'" ';
            }
            html += 'flashvars="'+ fv +'" />';
        } else {
            html = '<object id="'+ this.id +'" name="'+ this.id +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.width +'" height="'+ this.height +'">';
            html += '<param name="movie" value="'+ this.source +'" />';
            for(var key in this.params) { 
                html += '<param name="'+ key +'" value="'+ this.params[key] +'" />';
            }
            html += '<param name="flashvars" value="'+ fv +'" />';
            html += "</object>";
        }
        return html;
    },
    /** Add a flashvar to the list. **/
    setFlashvar: function(name,value) {
        this.flashvars[name] = encodeURIComponent(value);
    },
    /** Return a concatenated string of flashvars. **/
    getFlashvars: function () {
        var pairs = new Array();
        for(var key in this.flashvars) {
            pairs[pairs.length] = key+"="+this.flashvars[key];
        }
        return pairs.join('&');
    },
    /** Fix for IE6/FP9 video streaming unload bug. **/
    cleanupSWFs: function() {
        var objects = document.getElementsByTagName("OBJECT");
        for (var i=objects.length - 1; i >= 0; i--) {
            objects[i].style.display = 'none';
            for (var x in objects[i]) {
                if(typeof objects[i][x] == 'function') {
                    objects[i][x] = function(){};
                }
            }
        }
    }
};



/** Now the class has been set up, initialize the player, inject all flashvars and start. **/
var botr_salonterre = new BotR.swf("http://siteweb.caplorient.fr/fileadmin/template/salon-terre/css/2009/player.swf","botr_salonterre","400","330","#000000","http://siteweb.caplorient.fr/fileadmin/user_upload/Portail_cap/videos/2009/Hulot-2_1.flv");
botr_salonterre.setFlashvar("playlist","none");
botr_salonterre.setFlashvar("repeat","list");
botr_salonterre.setFlashvar("shuffle","true");
botr_salonterre.setFlashvar("displayclick","play");
botr_salonterre.setFlashvar("title","Salon Terre");
botr_salonterre.setFlashvar("frontcolor","ffffff");
botr_salonterre.setFlashvar("image","http://siteweb.caplorient.fr/fileadmin/user_upload/Portail_cap/videos/2009/hulot_2.jpg");

botr_salonterre.setFlashvar("date","2009-05-01 15:00:00");
botr_salonterre.setFlashvar("lightcolor","006600");
botr_salonterre.setFlashvar("controlbar","bottom");
botr_salonterre.setFlashvar("autostart","false");
botr_salonterre.setFlashvar("backcolor","003300");
botr_salonterre.setFlashvar("file","http://siteweb.caplorient.fr/fileadmin/user_upload/Portail_cap/videos/2009/Hulot-2_1.flv");
botr_salonterre.setFlashvar("logo","http://siteweb.caplorient.fr/fileadmin/user_upload/Portail_cap/videos/2009/caplorient.gif");
botr_salonterre.setFlashvar("skin","http://siteweb.caplorient.fr/fileadmin/template/salon-terre/css/2009/modieus.swf");
botr_salonterre.setFlashvar("streamer","lighttpd");
botr_salonterre.loadSWF();

