window.GotMilk = window.GotMilk || (function(swfobject, $) {

    var flashvars;
    var resizeTimeout

    function init() {
        if(document.location.hostname == "gotmilkdev.com")
        {
            var assetPath = "http://gotmilkdev.com/";
        }else{
            var assetPath = "/";
        }

        var swfURL = assetPath + "swf/shell.swf";
        var swfID = "flashcontent";

        flashvars = {};
        flashvars.assetPath = assetPath;

        var params = {};
        params.scale = "noscale"; 
        params.allowfullscreen = "true";
        params.allowscriptaccess = "always";
        params.wmode = "opaque";

        var attributes = {name:swfID, id:swfID};
        swfobject.embedSWF( swfURL, swfID, "100", "100", "10.0.0", assetPath + "/swf/expressInstall.swf", flashvars, params, attributes, resizeFlash);

        $(window).resize(initResize);
        resizeFlash(null);
    }

    // intermediary cause of chrome resize redraw bug
    function initResize() {
       setTimeout(resizeFlash, 300);
    }

    function resizeFlash(evt) {
        var heightRatio = 765/1280;
        var widthRatio = 1280/765;
        var newWidth =  $(window).width();
        if(newWidth < 980) newWidth = 980;
        var newHeight = heightRatio * newWidth;

        if(newHeight > $(window).height()) {
            $('#flashcontent').attr('height', newHeight);
            $('.container').css('height', newHeight);

        }else{
            $('#flashcontent').attr('height',  $(window).height());
            $('.container').css('height',  $(window).height()-1);
        }
        $('#flashcontent').attr('width', newWidth);
        $('.container').css('width', newWidth-1);
    }

    function getFlashVars(){
        return flashvars;
    }

    return {
        init: init,
        getFlashVars: getFlashVars
    };

}(swfobject, $));

jQuery(document).ready(GotMilk.init);



