﻿//Homepage Flash
$(function () {
    $('#flash-home-container').each(function () {        
        
            //				$(this).html('<div id="flash-home-left"></div><div id="flash-home-right"></div>');
            //				swfobject.embedSWF("/Images/Flash/homepage_bottle.swf", "flash-home-left", 248, 581, "8.0.0", "", {}, {"wmode":"transparent"});
            //				swfobject.embedSWF("/Images/Flash/homepage_ufo.swf", "flash-home-right", 250, 411, "8.0.0", "", {}, {"wmode":"transparent"});            
            var syncFlashStart = setInterval(function () {
                try {
                    var fLeft = FlashCow.getFlashMovie("bottle");
                    var fRight = FlashCow.getFlashMovie("spaceship");
                    
                    if (FlashCow.movieIsLoaded(fLeft) && FlashCow.movieIsLoaded(fRight)) {
                        if (FlashCow.sendPlayAnimation(fLeft) && FlashCow.sendPlayAnimation(fRight)) {
                            clearInterval(syncFlashStart);
                        }
                    }
                } catch (e) {  }
            }, 100);
        
    });
});


var FlashCow = {
    getFlashMovie: function (movieName) {
        return (navigator.appName.indexOf("Microsoft") != -1 ? window[movieName] : document[movieName]) || document.getElementById(movieName);
    },
    sendPlayAnimation: function (theMovie) {
        try {
            if (this.movieIsLoaded(theMovie)) {
                theMovie.Play();
                return true;
            } else {
                return false;
            }
        } catch (e) {
            return false;
        }
    },
    sendResetAnimation: function (theMovie) {
        try {
            if (this.movieIsLoaded(theMovie)) {
                theMovie.Rewind();
                return true;
            } else {
                return false;
            }
        } catch (e) {
            return false;
        }
    },
    movieIsLoaded: function (theMovie) {
        if (typeof (theMovie) != "undefined") {
            return theMovie.PercentLoaded() == 100;
        } else {
            return false;
        }
    }
}




