/*--------------------------------------------------------------------------  
 *  Axisto Player Loader, version 3.0.0
 *  (c) 2003-2007 Axisto Media Ltd, Andreas Rimbe
 *
 *  Usage:
 *  This javascript file must be embedded in the head, or in the body before the link
 *  described below.
 *
 *  <script src="http://www.axisto.com/apps/pip/1/js/axp-3.0.0.js" type="text/javascript"></script>
 *
 *
 *  href - url with appended parameters
 *         height
 *         resizeToContent - sizes player to the size of the content
 *         width
 *  rel - must be axp for the link to launch Axisto Player
 *
 *  Example:
 *  <a href="someplayer.html?" rel="axp" title="Player 1">Player 1</a>
 *--------------------------------------------------------------------------*/
if(typeof(Axisto) == "undefined")
	Axisto = {
	    appPath: "",
	    modulePath: "",
	    modules: [],
	    parseVersionString: function(versionString){
	        var r = versionString.split('.');
            return parseInt(r[0])*100000 + parseInt(r[1])*1000 + parseInt(r[2]);
	    },
	    includeModule: function(module){
	        Axisto.modules.push(module);
	    },
	    init: function(){
	        //get appPath
	        var scripts = document.getElementsByTagName("script");
	        for(var i=0; i<scripts.length; i++)
	        {
	            var j = scripts[i].src.indexOf("js/axp-");
	            if(j > -1)
	            {
	                Axisto.appPath = (scripts[i].src.indexOf("file://") < 0)?scripts[i].src.substring(0,j):"";
	                break;
	            }
	        }
	        Axisto.loadModules();
	    },
	    loadModule: function(path)
	    {
	        // inserting via DOM fails in Safari 2.0, so brute force approach
            document.write('<script type="text/javascript" src="'+path+'"><\/script>');
	    },
	    loadModules: function()
	    {
	        var module = null;
	        var modules = Axisto.modules;
	        
	        if(Axisto.modulePath == "")
	            Axisto.modulePath = Axisto.appPath + "js/";    
	            
	        for(var i=0; i<modules.length; i++)
	        {
	            module = modules[i];
	            
	            if(typeof(window[module.name]) == 'undefined')
	            {
	                Axisto.loadModule(Axisto.modulePath + module.src); 
	            }
	            else if(typeof(window[module.name].Version) != 'undefined')
	            {
	                var version = Axisto.parseVersionString(window[module.name].Version);
	                if(version < module.version)
	                {
	                    Axisto.loadModule(Axisto.modulePath + module.src);
	                }
	            }
	        }
	    }
	};
	                   
Axisto.includeModule({name: "Prototype", src:"prototype-1.6.0.js", version: "1.6.0"});
Axisto.includeModule({name: "Scriptaculous", src:"scriptaculous/1.8.0/scriptaculous.js", version: "1.8.0"});
Axisto.includeModule({name: "EventDispatcher", src:"event-dispatcher-1.js", version: "1.0.0"});
Axisto.includeModule({name: "Axisto.ModalDialog", src:"modal-dialog-1.0.0.js", version: "2.2.3"});
Axisto.includeModule({name: "Axisto.Player", src:"axp-pip-3.0.0.js", version: "3.0.0"});
Axisto.init();
