if(typeof TSCM=="undefined"){
	var TSCM=function(){
		return{
			version:"0.5",
			scriptname:"tscm.js",
			_debug:true,
			sectionSetup:{},
			reporting:{},
			util:{},
			modules:["util", "storyticker"],
			loaded:[]
		};
	}();
	// Public Methods
	TSCM.loadModule=function(name){
		if(name.indexOf("/")!=-1){
			name=(name.indexOf(".js")==-1?name+".js":name);
		}else{
			name=(name.indexOf(".js")==-1?this.scriptpath+name+".js":this.scriptpath+name);
		}
		if(typeof document.createElement!="undefined"){
			var h=document.getElementsByTagName('head').item(0);
			var s=document.createElement('script');
			s.setAttribute("type","text/javascript");
			s.setAttribute("src",name);
			s.setAttribute("defer", true);
			h.appendChild(s);
			this.loaded.push(name);
		}else{
			document.write("<scr" + "ipt type='text/javascript' src='" + mod + "'><" + "/" + "scr" + "ipt>");
			this.loaded.push(name);
		}
	}
	TSCM.loadModules=function(){
		for(var i=0; i<arguments.length;i++) {
			var o=arguments[i];
			if(typeof o=='string'){
				this.loadModule(o);
			}else{
				try{
					for(var x=0;x<o.length;x++){this.loadModule(o[x]);}
				}catch(e){}
			}
		}
	}

	TSCM.loadCSS=function(url){
         var css = document.createElement('link');
			css.rel  = 'stylesheet';
			css.href = url;
         document.getElementsByTagName("head")[0].appendChild(css);
         delete css;
   }

	TSCM.toString=function(){
		return "TSCM javascript Package version " + this.version + " Active Modules: " + this.loaded.toString();
	}
	TSCM.debug=function(msg){
		if(this._debug){
			try{
				document.getElementById("debug").innerHTML += msg + "<br>";
			}catch(e){
				alert(msg);
			}
		}
	}

	TSCM.register=function(ns){
      try{
         var o = eval("TSCM." + ns);
         if(typeof o == "undefined"){
            o = eval("TSCM." + ns + "={};");
         }else{
            // it exists
         }
      } catch(e){
      }
   }

	TSCM.addOnloadEvent=function(func){
		if(window.attachEvent){
			window.attachEvent("onload", func);
		}
		if(window.addEventListener){
			window.addEventListener("load", func, false);
		}
		return this;
	}
	TSCM.init=function(){
		if(typeof Array.prototype.push=="undefined"){
			this.modules[this.modules.length]="Compat";
		}
		this.scripts=document.getElementsByTagName("script");
		for(var i=0;i<this.scripts.length;i++){if(this.scripts[i].src.indexOf(this.scriptname)!=-1){this.root=i;}}
		this.scriptpath=this.scripts[this.root].src.substring(0,this.scripts[this.root].src.indexOf(this.scriptname));
		this.scripts=null;
		this.loadModules(this.modules);
	}
   TSCM.pollcommand=function(func,pollinterval){
      try {
         if(func)this.func = func;
         if(!!pollinterval)this.pollint = pollinterval;
         this.func.apply();
      }catch(e){
         this.pollfunc = func;
         this.pollint  = pollinterval;
         setTimeout(TSCM.pollcommand,this.pollint);
      }

   }
	TSCM.init();
}
