function MoaRouter(){
	var base = "http://labmoa.pl";
	
	this.prepare = function(){	
		this.parsePath();		
		$(document).ready( function(){
			//alert("Moa router is running: "+document.location);
			//log("Try to parse data");			
			
		});		
	}
	
	/*
	 * Parse path on the first run
	 */
	this.parsePath = function(){
		var lLocation = document.location.href;
		lLocation = lLocation.replace("http://", "");
		var lTemp = lLocation.split("/");
		if( lTemp[1] == "#" || lTemp[1] == ""){
			this.showFlash();
		}else{
			var lOut = "";
			for( var i = 0; i < lTemp.length; i++){
				var lItem = lTemp[i];
				if( i == 0 ){
					lOut += lTemp[i] + "/#";
				}else{
					lOut += "/"+lTemp[i];
				}
			}
			
			this.redirectToFlash(lOut);
		}		
	}
	
	
	this.redirectToFlash = function( pPath ){
		document.location.href = "http://"+pPath;
	}
	
	this.showFlash = function(){
		var flashvars = {
                    swfUrl: "/lab/html/moa2.swf"
		};
		var params = {
			menu: "false",
			scale: "noScale",
			allowFullscreen: "true",
			allowScriptAccess: "always",
			bgcolor: "#313040",
			wmode: "window"
		};
		var attributes = {
			id:"MoaApp",
			name: "MoaApp"
		};
		swfobject.embedSWF("/lab/html/loader.swf", "altContent", "100%", "100%", "10.0.0", "expressInstall.swf", flashvars, params, attributes);	
	}
	
}

var moaRouter = new MoaRouter();
moaRouter.prepare();
