/**
 * SWFBinario v0.9: (SWFObject 2 + Full Browser Flash) functionality all together - http://www.binario.it/
 *
 * SWFBinario is (c) 2009 Luca Iacobini and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * Dependencies: 
 * SWFObject v2.2        <http://code.google.com/p/swfobject/> 
 * 
 */
var swfbinario = function () {
    if (!swfobject) return false;
    swfobject.createCSS("html", "height:100%");
    swfobject.createCSS("body", "height:100%; margin:0; padding:0");
    swfobject.createCSS("object", "display:block; outline:none");
    swfobject.createCSS("#container", "height:100%");
    var UNDEF = "undefined",
        OBJECT = "object",
        NUMBER = "number",
        STRING = "string";
    var swfContent, minWidth, minHeight, minVersion;
    var vars = {};
    var params = {
        menu: 'false',
        allowscriptaccess: 'always'
    };
    var attributes = {};
    var macmousewheel;
    var object;
    var mysheet = document.styleSheets[0];
    var myrules = (mysheet) ? (mysheet.cssRules) ? mysheet.cssRules : mysheet.rules : UNDEF;
    var explorer = (navigator.appName == "Microsoft Internet Explorer") ? true : false;
    for (i = 0; i < myrules.length; ++i) {
        if (myrules[i].selectorText && myrules[i].selectorText.toLowerCase() == "object") {
            object = myrules[i];
            break
        }
    }
    var getViewportSize = function () {
        var size = [0, 0];
        if (typeof window.innerWidth != "undefined") {
            size = [window.innerWidth, window.innerHeight]
        } else if (typeof document.documentElement != "undefined" && typeof document.documentElement.clientWidth != "undefined" && document.documentElement.clientWidth != 0) {
            size = [document.documentElement.clientWidth, document.documentElement.clientHeight]
        } else {
            size = [document.getElementByTagName("body")[0].clientWidth, document.getElementByTagName("body")[0].clientHeight]
        }
        return size
    };
    var createFullBrowserFlash = function () {
        window.onresize = function () {
            if (explorer) object.style.display = "inline";
            var el = document.getElementById("container");
            var size = getViewportSize();
            el.style.width = (size[0] < minWidth) ? (minWidth + "px") : "100%";
            el.style.height = (size[1] < minHeight) ? (minHeight + "px") : "100%";
            if (explorer) object.style.display = "block"
        };
        window.onresize()
    };
    return {
        createSWF: function (swfContent_, minWidth_, minHeight_, minVersion_, vars_, params_, attributes_,callbackz) {
			if(typeof(callbackz)!='function'){
				callbackz = function(){};
			}
            if (swfContent_ && minWidth_ && minHeight_ && minVersion_) {
                swfContent = swfContent_;
                minWidth = minWidth_;
                minHeight = minHeight_;
                minVersion = minVersion_;
                if (vars_ && typeof vars_ === OBJECT) {
                    for (var i in vars_) {
                        vars[i] = vars_[i]
                    }
                }
                if (params_ && typeof params_ === OBJECT) {
                    for (var j in params_) {
                        params[j] = params_[j]
                    }
                }
                if (attributes_ && typeof attributes_ === OBJECT) {
                    for (var k in attributes_) {
                        attributes[k] = attributes_[k]
                    }
                }
                swfobject.embedSWF(swfContent, "content", "100%", "100%", minVersion, "js/expressInstall.swf", vars, params, attributes,callbackz);
                if (swfobject.hasFlashPlayerVersion(minVersion)) {
                    swfobject.addDomLoadEvent(createFullBrowserFlash)
                }
                return true
            } else {
                return false
            }
        },
        getMinViewportSize: function () {
            return {
                width: minWidth,
                height: minHeight
            }
        },
        setMinViewportSize: function (width_, height_) {
            if (width_ && (typeof width_ === NUMBER || typeof width_ === STRING)) {
                minWidth = width_
            }
            if (height_ && (typeof height_ === NUMBER || typeof height_ === STRING)) {
                minHeight = height_
            }
            window.onresize()
        },
        setMinViewportSizeAndScroll: function (width_, height_, posX_) {
            if (width_ && (typeof width_ === NUMBER || typeof width_ === STRING)) {
                minWidth = width_
            }
            if (height_ && (typeof height_ === NUMBER || typeof height_ === STRING)) {
                minHeight = height_
            }
            window.scrollTo(posX_, 0);
            window.onresize()
        }
    }
}();


var flash_callback = function(e){
	if(!e.success){
		document.getElementById(e.id).style.display = 'none';
		document.getElementById('noflash').style.display = 'block';
	}
}
