/**

        (c) copyright 2005 Jason Van Anden. Some rights reserved.

        This work is protected under a Creative Commons license.

        Other terms can be found here:
        http://creativecommons.org/licenses/by-nc-sa/2.5/

        ascii chewy lives here: http://www.smileproject.com/chewy

*/

    function sleep (src, pause, speed, count){
        this.setProperties(src, pause, speed, count);
    };

    sleep.prototype.mouse_over = function(){
		sleep.superclass.setProperties.call(this, src, pause, speed, count);

		this.name       = "sleep";
		this.dream_mode = 1;
	}

    sleep.prototype = new BaseSequence();
    sleep.prototype.constructor = new BaseSequence;
    sleep.superclass = BaseSequence.prototype;


    sleep.prototype.mouse_over = function(){

	    this.rent.objArt.className = "normal";
		this.return_mode = MODE_WAKEUP;
		this.stop();

		return this;
	};

    sleep.prototype.setProperties = function(src, pause, speed, count){

		sleep.superclass.setProperties.call(this, src, pause, speed, count);

        this.sleep_counter = 0;

		this.def_prog = "sleeping()";
		this.prog     = this.def_prog;

		return this;
    };

    sleep.prototype.actout = function actout(){

        sleep.superclass.actout.call(this);

        this.sleep_counter += 1;

		// if (this.sleep_counter < 11) return(this.def_prog);


       // these sequences could be loaded into an array at startup
       switch (this.dream_mode){

			case (1):

				switch (this.sleep_counter){
					case 1: this.prog = "sleep_z()";           break;
					case 2: this.prog = "sleep_z_z()";         break;
					case 3: this.prog = "sleep_z_z_z()";       break;
					case 4: this.prog = "sleep_z_z_z_z()";     break;
					case 5: this.prog = "sleep_z_z_z_z_z()";   break;
					case 6: this.prog = "sleep_z_z_z()";       break;
					case 7: this.prog = "sleep_z()";           break;
					default: this.prog = this.def_prog;        break;
				}

				if(this.sleep_counter >= 9) {
					this.dream_mode = 0;
					this.sleep_counter = 0;
				}

				break;

			case (2):

				switch (this.sleep_counter){

					case 1:  this.prog = "sleep_bone_start()";    break;
					case 2:  this.prog = "sleep_bone_middle()";   break;
					case 3:  this.prog = "sleep_bone_left()";     break;
					case 4:  this.prog = "sleep_bone_wayleft()";  break;
					case 5:  this.prog = "sleep_bone_left()";     break;
					case 6:  this.prog = "sleep_bone_middle()";   break;
					case 7:  this.prog = "sleep_bone_right()";    break;
					case 8:  this.prog = "sleep_bone_wayright()"; break;
					case 9:  this.prog = "sleep_bone_right()";    break;
					case 10: this.prog = "sleep_bone_middle()";   break;
					// case 11: this.prog = "sleep_bone_start()";    break;

					default: this.prog = this.def_prog;           break;
				}

				if(this.sleep_counter >= 12){
					this.dream_mode = 0;
					this.sleep_counter = 0;
				}

				break;

			default:

				this.prog = this.def_prog;

				if(this.sleep_counter >= 10) {
					this.dream_mode = this.get_random_number(3);
					this.sleep_counter = 0;
				}

				break;
		}

        // window.defaultStatus = "dream mode: " + this.dream_mode;
        return(this.prog);
    }

