
/*#######################
//initial values
########################*/
var AMXq = 5;
var debugAMX = false;
var images_basic_path = ""


/*#######################
//initial sprites creation
########################*/

function setSpriteObjects(){
    /*
    create the sprites at initial position, state and scenario
    */

    if (body_height < win_height)
	hh= win_height;
    else
	hh= body_height;
    for (i=0;i<AMXq;i++){
	if (AMXrnd()>0) {
	    //make a gecko
	    if (AMXrnd()>.75)
		AMXs[i]=new sprite('g0', 'waituprightB1',-200 * (1+AMXrnd()),win_height * AMXrnd(),states[ 'g0' ].z , -200, -200,body_width,hh);
	    else
		if (AMXrnd()>.66)
		    AMXs[i]=new sprite('g0', 'waitdownrightA2',body_width * AMXrnd(),-200 * (1+AMXrnd()) , states[ 'g0' ].z ,-200, -200,body_width,hh);
		else
		    if (AMXrnd()>.5)
			AMXs[i]=new sprite('g0', 'waitdownrightA2',-200 * (1+AMXrnd()),win_height * AMXrnd(),states[ 'g0' ].z , -200, -200,body_width,hh);
		    else
			AMXs[i]=new sprite('g0', 'downleftA',body_width * AMXrnd(), -200 * (1+AMXrnd()) , states[ 'g0' ].z , -200, -200,body_width,hh);
	}
    }
}

    
/*#######################
//states & scenarios definition
########################*/
function initStates(){
    /*
    defines the different states and scenarios
    */

    states = new Array;
    
    /*##########
    g0 state - each state has several scenarios
    ###########*/
    /*	g0	*/
    st_n = "g0";
    states[ st_n] = new state;
    states[ st_n].onErrorScenario = "waituprightA1";
    states[ st_n].z = 3;
    
    /*####
    upright scenarios
    #####*/
    //scenario uprightA
    states[ st_n ].scenarios["uprightA"] = new scenario;
    with (states[ st_n ].scenarios["uprightA"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gur2.gif", 19, -35, 2);
	steps[1] = new step( st_n, "gur4.gif", 19, -43, 2);
	steps[2] = new step( st_n, "gur2.gif", 19, -35, 2);
	steps[3] = new step( st_n, "gur4.gif", 19, -43, 2);
	next_scenarios[0] = new next_scenario("uprightA",5);
	next_scenarios[1] = new next_scenario("circle",1);
	next_scenarios[2] = new next_scenario("waituprightA1",4);
	next_scenarios[3] = new next_scenario("waituprightA2",3);
	next_scenarios[4] = new next_scenario("waituprightA3",15);
	next_scenarios[5] = new next_scenario("waituprightA4",4);
	next_scenarios[6] = new next_scenario("uprightB",5);
	next_states[0] = new next_state("g0", "uprightA", 99);
	onright_next_states[0] = new next_state("g0", "upleftA", 49);
	onright_next_states[0].action = "boomright()";
	ontop_next_states[0] = new next_state("g0", "downrightA", 49);
	ontop_next_states[0].action = "boomTop()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }
	
    //scenario waituprightA1
    states[ st_n ].scenarios["waituprightA1"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA1"]) {
	random_delay = 140;
	steps[0] = new step( st_n, "gur2.gif", 0, 0, 2);
	steps[1] = new step( st_n, "gur21.gif", 0, 0, 62);
	steps[2] = new step( st_n, "gur22.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gur21.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gur22.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gur21.gif", 0, 0, 22);
	steps[6] = new step( st_n, "gur2.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gur22.gif", 0, 0, 22);
	steps[8] = new step( st_n, "gur21.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("waituprightA1",10);
	next_scenarios[1] = new next_scenario("waituprightA11",10);
	next_scenarios[2] = new next_scenario("uprightA",3);
	next_states[0] = new next_state("g0", "waituprightA1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "uprightB", 2);
	
    }
    
    //scenario waituprightA2
    states[ st_n ].scenarios["waituprightA2"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA2"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gur4.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gur41.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gur4.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gur41.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gur42.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gur41.gif", 0, 0, 12);
	steps[6] = new step( st_n, "gur42.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gur41.gif", 0, 0, 2);
	steps[8] = new step( st_n, "gur4.gif", 0, 0, 12);
	steps[9] = new step( st_n, "gur42.gif", 0, 0, 122);
	steps[10] = new step( st_n, "gur41.gif", 0, 0, 12);
	steps[11] = new step( st_n, "gur42.gif", 0, 0, 12);
	steps[12] = new step( st_n, "gur41.gif", 0, 0, 2);
	next_scenarios[0] = new next_scenario("waituprightA2",20);
	next_scenarios[1] = new next_scenario("uprightA",5);
	next_states[0] = new next_state("g0", "waituprightA1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "uprightB", 2);
	
    }
    
    //scenario waituprightA11
    states[ st_n ].scenarios["waituprightA11"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA11"]) {
	random_delay = 70;
	steps[0] = new step( st_n, "gur1.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gur11.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gur1.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gur11.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gur1.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gur11.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("waituprightA1",10);
	next_scenarios[1] = new next_scenario("waituprightA11",20);
	next_scenarios[2] = new next_scenario("uprightA",10);
	next_scenarios[3] = new next_scenario("waituprightA3",10);
	next_states[0] = new next_state("g0", "waituprightA1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "uprightB", 2);
	
    }
    
    //scenario waituprightA3
    states[ st_n ].scenarios["waituprightA3"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA3"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gur41.gif", 0, 0, 1);
	steps[1] = new step( st_n, "gur43.gif", 0, 0, 2);
	steps[2] = new step( st_n, "gur44.gif", 0, 0, 122);
	next_scenarios[0] = new next_scenario("waituprightA3out2",4);
	next_scenarios[1] = new next_scenario("uprightA",11);
	next_states[0] = new next_state("g0", "waituprightA3", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

    }
        
    //scenario waituprightA3out2
    states[ st_n ].scenarios["waituprightA3out2"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA3out2"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gur43.gif", 0, 0, 0);
	steps[1] = new step( st_n, "gur42.gif", 0, 0, 2);
	steps[2] = new step( st_n, "gur41.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("uprightA",11);
	next_scenarios[1] = new next_scenario("waituprightA3",4);
	next_states[0] = new next_state("g0", "waituprightA3", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

    }
    
    
    //scenario waituprightA4
    states[ st_n ].scenarios["waituprightA4"] = new scenario;
    with (states[ st_n ].scenarios["waituprightA4"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gur2.gif", 0, 0, 2);
	steps[1] = new step( st_n, "gur49.gif", -14, -11, 215);
	steps[2] = new step( st_n, "gur21.gif", 14, 11, 2);
	steps[3] = new step( st_n, "gur2.gif", 0, 0, 2);
	next_scenarios[0] = new next_scenario("waituprightA1",4);
	next_scenarios[1] = new next_scenario("uprightA",2);
	next_states[0] = new next_state("g0", "waituprightA4", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "uprightB", 2);
	
    }
    
    /*
    B 
    */
    
         
    //scenario uprightB
    states[ st_n ].scenarios["uprightB"] = new scenario;
    with (states[ st_n ].scenarios["uprightB"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gurB2.gif", 35, -19, 2);
	steps[1] = new step( st_n, "gurB4.gif", 43, -19, 2);
	steps[2] = new step( st_n, "gurB2.gif", 35, -19, 2);
	steps[3] = new step( st_n, "gurB4.gif", 43, -19, 2);
	next_scenarios[0] = new next_scenario("uprightB",6);
	next_scenarios[1] = new next_scenario("waituprightB1",6);
	next_scenarios[2] = new next_scenario("downrightB",1);
	next_states[0] = new next_state("g0", "uprightB", 99);
	onright_next_states[0] = new next_state("g0", "upleftB", 49);
	onright_next_states[0].action = "boomright()";
	ontop_next_states[0] = new next_state("g0", "downrightB", 49);
	ontop_next_states[0].action = "boomTop()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }
	
    //scenario waituprightB1
    states[ st_n ].scenarios["waituprightB1"] = new scenario;
    with (states[ st_n ].scenarios["waituprightB1"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gurB2.gif", 0, 0, 2);
	steps[1] = new step( st_n, "gurB21.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gurB22.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gurB21.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gurB22.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gurB21.gif", 0, 0, 12);
	steps[6] = new step( st_n, "gurB22.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gurB21.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("waituprightB1",10);
	next_scenarios[1] = new next_scenario("uprightB",2);
	next_states[0] = new next_state("g0", "waituprightB1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "uprightB", 50);
	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "uprightB", 2);
	
    }
    
    
    /*####
    downright scenarios
    ####*/
    //scenario downrightA
    states[ st_n ].scenarios["downrightA"] = new scenario;
    with (states[ st_n ].scenarios["downrightA"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gdr2.gif", 35, 19, 2);
	steps[1] = new step( st_n, "gdr4.gif", 43, 19, 2);
	steps[2] = new step( st_n, "gdr2.gif", 35, 19, 2);
	steps[3] = new step( st_n, "gdr4.gif", 43, 19, 2);
	next_scenarios[0] = new next_scenario("downrightA",11);
	next_scenarios[1] = new next_scenario("waitdownrightA2",11);
	next_scenarios[2] = new next_scenario("uprightA",4);
	next_scenarios[3] = new next_scenario("circle",3);
	next_scenarios[4] = new next_scenario("downrightB",11);
	next_states[0] = new next_state("g0", "downrightA", 99);
	onright_next_states[0] = new next_state("g0", "downleftA", 49);
	onright_next_states[0].action = "boomright()";
	onbottom_next_states[0] = new next_state("g0", "uprightA", 49);
	onbottom_next_states[0].action = "boomBottom()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "circle", 2);
	
    }
    
    //scenario waitdownrightA2
    states[ st_n ].scenarios["waitdownrightA2"] = new scenario;
    with (states[ st_n ].scenarios["waitdownrightA2"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gdr4.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gdr41.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gdr4.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gdr41.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gdr42.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gdr41.gif", 0, 0, 12);
	steps[6] = new step( st_n, "gdr42.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gdr41.gif", 0, 0, 2);
	steps[8] = new step( st_n, "gdr4.gif", 0, 0, 12);
	steps[9] = new step( st_n, "gdr42.gif", 0, 0, 122);
	steps[10] = new step( st_n, "gdr41.gif", 0, 0, 12);
	steps[11] = new step( st_n, "gdr42.gif", 0, 0, 12);
	steps[12] = new step( st_n, "gdr41.gif", 0, 0, 2);
	next_scenarios[0] = new next_scenario("waitdownrightA2",2);
	next_scenarios[1] = new next_scenario("downrightA",20);
	next_scenarios[2] = new next_scenario("circle",1);
	next_states[0] = new next_state("g0", "waitdownrightA2", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "downrightA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "downrightB", 2);
	
    }
  
    /*
    B
    */  

    //scenario downrightB
    states[ st_n ].scenarios["downrightB"] = new scenario;
    with (states[ st_n ].scenarios["downrightB"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gdrB2.gif", 19, 35, 2);
	steps[1] = new step( st_n, "gdrB4.gif", 19, 43, 2);
	steps[2] = new step( st_n, "gdrB2.gif", 19, 35, 2);
	steps[3] = new step( st_n, "gdrB4.gif", 19, 43, 2);
	next_scenarios[0] = new next_scenario("downrightB",8);
	next_scenarios[1] = new next_scenario("downrightA",2);
	next_states[0] = new next_state("g0", "downrightB", 99);
	next_states[1] = new next_state("g0", "downleftB", 99);
	next_states[2] = new next_state("g0", "uprightB", 99);
	onright_next_states[0] = new next_state("g0", "downleftB", 49);
	onright_next_states[0].action = "boomright()";
	onbottom_next_states[0] = new next_state("g0", "uprightB", 49);
	onbottom_next_states[0].action = "boomBottom()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "circle", 2);
	
    }


/*####
    downleft scenarios
####*/
    
    
    //scenario downleftA
    states[ st_n ].scenarios["downleftA"] = new scenario;
    with (states[ st_n ].scenarios["downleftA"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gdl2.gif", -19, 35, 2);
	steps[1] = new step( st_n, "gdl4.gif", -19, 43, 2);
	steps[2] = new step( st_n, "gdl2.gif", -19, 35, 2);
	steps[3] = new step( st_n, "gdl4.gif", -19, 43, 2);
	next_scenarios[0] = new next_scenario("downleftA",6);
	next_scenarios[1] = new next_scenario("downleftB",1);
	next_states[0] = new next_state("g0", "downleftA", 99);
	onleft_next_states[0] = new next_state("g0", "downrightA", 49);
	onleft_next_states[0].action = "boomleft()";
	onbottom_next_states[0] = new next_state("g0", "upleftA", 49);
	onbottom_next_states[0].action = "boomBottom()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }


/*
    mirror B
*/
        
    //scenario downleftB
    states[ st_n ].scenarios["downleftB"] = new scenario;
    with (states[ st_n ].scenarios["downleftB"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gdlB2.gif", -35, 19, 2);
	steps[1] = new step( st_n, "gdlB4.gif", -43, 19, 2);
	steps[2] = new step( st_n, "gdlB2.gif", -35, 19, 2);
	steps[3] = new step( st_n, "gdlB4.gif", -43, 19, 2);
	next_scenarios[0] = new next_scenario("downleftB",21);
	next_scenarios[1] = new next_scenario("waitdownleftB2",11);
	next_scenarios[2] = new next_scenario("upleftB",4);
	next_scenarios[3] = new next_scenario("circle",3);
	next_scenarios[4] = new next_scenario("downleftA",3);
	next_states[0] = new next_state("g0", "downleftB", 99);
	onleft_next_states[0] = new next_state("g0", "downrightB", 49);
	onleft_next_states[0].action = "boomleft()";
	onbottom_next_states[0] = new next_state("g0", "upleftB", 49);
	onbottom_next_states[0].action = "boomBottom()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }
    
    //scenario waitdownleftB2
    states[ st_n ].scenarios["waitdownleftB2"] = new scenario;
    with (states[ st_n ].scenarios["waitdownleftB2"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gdlB4.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gdlB41.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gdlB4.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gdlB41.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gdlB42.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gdlB41.gif", 0, 0, 12);
	steps[6] = new step( st_n, "gdlB42.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gdlB41.gif", 0, 0, 2);
	steps[8] = new step( st_n, "gdlB4.gif", 0, 0, 12);
	steps[9] = new step( st_n, "gdlB42.gif", 0, 0, 122);
	steps[10] = new step( st_n, "gdlB41.gif", 0, 0, 12);
	steps[11] = new step( st_n, "gdlB42.gif", 0, 0, 12);
	steps[12] = new step( st_n, "gdlB41.gif", 0, 0, 2);
	next_scenarios[0] = new next_scenario("waitdownleftB2",2);
	next_scenarios[1] = new next_scenario("downleftB",20);
	next_scenarios[2] = new next_scenario("circle",1);
	next_states[0] = new next_state("g0", "waitdownleftB2", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "downleftB", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "downleftA", 2);
	
    }


/*####
    upleft scenarios
####*/
         
    //scenario upleftA
    states[ st_n ].scenarios["upleftA"] = new scenario;
    with (states[ st_n ].scenarios["upleftA"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gul2.gif", -35, -19, 2);
	steps[1] = new step( st_n, "gul4.gif", -43, -19, 2);
	steps[2] = new step( st_n, "gul2.gif", -35, -19, 2);
	steps[3] = new step( st_n, "gul4.gif", -43, -19, 2);
	next_scenarios[0] = new next_scenario("upleftA",6);
	next_scenarios[1] = new next_scenario("waitupleftA1",6);
	next_scenarios[2] = new next_scenario("downleftA",1);
	next_states[0] = new next_state("g0", "upleftA", 99);
	onleft_next_states[0] = new next_state("g0", "uprightA", 49);
	onleft_next_states[0].action = "boomleft()";
	ontop_next_states[0] = new next_state("g0", "downleftA", 49);
	ontop_next_states[0].action = "boomTop()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }
	
    //scenario waitupleftA1
    states[ st_n ].scenarios["waitupleftA1"] = new scenario;
    with (states[ st_n ].scenarios["waitupleftA1"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gul2.gif", 0, 0, 2);
	steps[1] = new step( st_n, "gul21.gif", 0, 0, 62);
	steps[2] = new step( st_n, "gul22.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gul21.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gul22.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gul21.gif", 0, 0, 22);
	steps[6] = new step( st_n, "gul22.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gul21.gif", 0, 0, 22);
	next_scenarios[0] = new next_scenario("waitupleftA1",10);
	next_scenarios[1] = new next_scenario("upleftA",2);
	next_states[0] = new next_state("g0", "waitupleftA1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "upleftA", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "upleftB", 2);
	
    }
    
	
	    
/*
    B
*/
    
    //scenario upleftB
    states[ st_n ].scenarios["upleftB"] = new scenario;
    with (states[ st_n ].scenarios["upleftB"]) {
	random_delay = 5;
	steps[0] = new step( st_n, "gulB2.gif", -19, -35, 2);
	steps[1] = new step( st_n, "gulB4.gif", -19, -43, 2);
	steps[2] = new step( st_n, "gulB2.gif", -19, -35, 2);
	steps[3] = new step( st_n, "gulB4.gif", -19, -43, 2);
	next_scenarios[0] = new next_scenario("upleftB",5);
	next_scenarios[1] = new next_scenario("circle",1);
	next_scenarios[2] = new next_scenario("waitupleftB1",4);
	next_scenarios[3] = new next_scenario("waitupleftB2",3);
	next_scenarios[4] = new next_scenario("upleftA",5);
	next_states[0] = new next_state("g0", "uprightA", 99);
	onleft_next_states[0] = new next_state("g0", "uprightB", 49);
	onleft_next_states[0].action = "boomleft()";
	ontop_next_states[0] = new next_state("g0", "downrightB", 49);
	ontop_next_states[0].action = "boomTop()";
	onclick_zones[0] = new on_zone( 0, 0, 115,115 );
	onclick_zones[0].next_states[0] = new next_state("g0", "circle", 10);
	onclick_zones[0].next_states[0].action="shake()";
    }
	
    //scenario waitupleftB1
    states[ st_n ].scenarios["waitupleftB1"] = new scenario;
    with (states[ st_n ].scenarios["waitupleftB1"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gulB2.gif", 0, 0, 2);
	steps[1] = new step( st_n, "gulB21.gif", 0, 0, 62);
	steps[2] = new step( st_n, "gulB22.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gulB21.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gulB22.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gulB21.gif", 0, 0, 22);
	steps[6] = new step( st_n, "gulB2.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gulB22.gif", 0, 0, 22);
	steps[8] = new step( st_n, "gulB21.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("waitupleftB1",10);
	next_scenarios[1] = new next_scenario("waitupleftB11",10);
	next_scenarios[2] = new next_scenario("upleftB",3);
	next_states[0] = new next_state("g0", "waitupleftB1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "upleftB", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "upleftA", 2);
	
    }
    
    //scenario waitupleftB2
    states[ st_n ].scenarios["waitupleftB2"] = new scenario;
    with (states[ st_n ].scenarios["waitupleftB2"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gulB4.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gulB41.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gulB4.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gulB41.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gulB42.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gulB41.gif", 0, 0, 12);
	steps[6] = new step( st_n, "gulB42.gif", 0, 0, 12);
	steps[7] = new step( st_n, "gulB41.gif", 0, 0, 2);
	steps[8] = new step( st_n, "gulB4.gif", 0, 0, 12);
	steps[9] = new step( st_n, "gulB42.gif", 0, 0, 122);
	steps[10] = new step( st_n, "gulB41.gif", 0, 0, 12);
	steps[11] = new step( st_n, "gulB42.gif", 0, 0, 12);
	steps[12] = new step( st_n, "gulB41.gif", 0, 0, 2);
	next_scenarios[0] = new next_scenario("waitupleftB2",20);
	next_scenarios[1] = new next_scenario("upleftB",5);
	next_states[0] = new next_state("g0", "waitupleftB1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "upleftB", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "upleftA", 2);
	
    }
    
    //scenario waitupleftB11
    states[ st_n ].scenarios["waitupleftB11"] = new scenario;
    with (states[ st_n ].scenarios["waitupleftB11"]) {
	random_delay = 40;
	steps[0] = new step( st_n, "gulB1.gif", 0, 0, 12);
	steps[1] = new step( st_n, "gulB11.gif", 0, 0, 12);
	steps[2] = new step( st_n, "gulB1.gif", 0, 0, 12);
	steps[3] = new step( st_n, "gulB11.gif", 0, 0, 12);
	steps[4] = new step( st_n, "gulB1.gif", 0, 0, 12);
	steps[5] = new step( st_n, "gulB11.gif", 0, 0, 12);
	next_scenarios[0] = new next_scenario("waitupleftB1",10);
	next_scenarios[1] = new next_scenario("waitupleftB11",20);
	next_scenarios[2] = new next_scenario("upleftB",10);
	next_states[0] = new next_state("g0", "waitupleftB1", 99);
	onmouseover_zones[0] = new on_zone( 0, 0, 115, 115 );
	onmouseover_zones[0].next_states[0] = new next_state("g0", "upleftB", 50);

	ontouch_next_states["g0"] = new Array;
	ontouch_next_states["g0"][0] = new next_state("g0", "upleftA", 2);
	
    }
     
		    
	
/*####
    circle scenario
####*/
    		
			    
    //scenario circle
    states[ st_n ].scenarios["circle"] = new scenario;
    with (states[ st_n ].scenarios["circle"]) {
	random_delay = 3;
	steps[0] = new step( st_n, "gur21.gif",   0, -14, 2);
	steps[1] = new step( st_n, "gur3.gif",   19, -37, 2);
	steps[2] = new step( st_n, "gdr21.gif",  14,   0, 2);
	steps[3] = new step( st_n, "gdr3.gif",   37,  19, 2);
	steps[4] = new step( st_n, "gdl21.gif",   0,  14, 2);
	steps[5] = new step( st_n, "gdl3.gif",  -19,  37, 2);
	steps[6] = new step( st_n, "gul21.gif", -14,   0, 2);
	steps[7] = new step( st_n, "gdl3.gif",  -37, -19, 2);
	next_scenarios[0] = new next_scenario("circle",1);
	next_scenarios[1] = new next_scenario("upleftA",10);
	next_scenarios[2] = new next_scenario("uprightA",10);
	next_scenarios[3] = new next_scenario("downleftA",10);
	next_scenarios[4] = new next_scenario("downrightA",10);
	next_states[0] = new next_state("g0", "circle", 99);
    }
    
    
    checkStatus("g0","");
    
}


/*#######################
//custom functions
########################*/

function boomleft(n) {
    if (!boom) return; 
    if (n==null) n=11;
    top.resizeBy(n,0);
    top.moveBy(-n,0);
    n--;n--;
    if (n>-11) setTimeout("boomleft(" + n + ")",2)
}
function boomright(n) {
    if (!boom) return; 
    if (n==null) n=11;
    top.resizeBy(n,0);
    n--;n--;
    if (n>-11) setTimeout("boomright(" + n + ")",2)
}
function boomTop(n) { 
    if (!boom) return; 
    if (n==null) n=11;
    top.resizeBy(0,n);
    top.moveBy(0,-n);
    n--;n--;
    if (n>-11) setTimeout("boomTop(" + n + ")",2)
 }
function boomBottom(n) {
    if (!boom) return; 
    if (n==null) n=11;
    top.resizeBy(0,n);
    n--;n--;
    if (n>-11) setTimeout("boomBottom(" + n + ")",2)
 }
var boom=false;
function shake() {
    boom = true;
    setTimeout("boom=false",5000);
    for(t=0;t<10;t++){
	top.moveBy(0,10*AMXrnd());
	top.moveBy(10*AMXrnd(),0);
	top.moveBy(0,-10*AMXrnd());
	top.moveBy(-10*AMXrnd(),0);
    }
    for(t=0;t<AMXq;t++) {
	cStatus = s[t].status;
	cStatus.timeout = 0 ;
	cState = cStatus.current_state_name ;
	cScenario = cStatus.current_scenario_name ;	
	cStatus.step_no = states[ cState ].scenarios[ cScenario ].steps.length -1;
    }
}
