var Phaser = Phaser || {};
var Ritual = Ritual || {};

var game = new Phaser.Game(1024, 768, Phaser.CANVAS);
game.state.add("BootState", new Ritual.BootState());
game.state.add("LoadingState", new Ritual.LoadingState());
game.state.add("GameState", new Ritual.RunState());

if(getParamByName('level') == 'water') {
	game.state.start("BootState", true, false, "water", "assets/levels/water.json");
}
else {
	game.state.start("BootState", true, false, "nestinar", "assets/levels/nestinar.json");	
}

function getParamByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}