/*
 * IdeaValley Innovation
 * FlipSite
 * Maio 2006
 * Luiz Paulo dos Prazeres Júnior
 * 
 * flipControl Class
 */
 
var stateMachineClass       = Class.create();

stateMachineClass.prototype = {

	initialize: function () {

        this.initVars();

        FlipAction.register(this.onBack, "gotoPage", "before");
        FlipAction.register(this.onFront, "gotoPage", "before");
        FlipAction.register(this.setAll, "gotoPage", "after");

	}, //method initialize


    initVars: function () {

		this.page       = 1;
		this.pageRight  = 1;
		this.pageLeft   = 0;

        this.playerType = typePlayer;//"doubleFlash";

		this.pageMin    = 1;
		this.pageMax    = maxPages;

        // VARS STATE FLIP
        this.isFlipping   = false;
        this.isZoom       = false;
        this.isSearch     = false;
        this.isIndice     = false;
        this.isSendFriend = false;
        // VARS STATE FLIP END

    }, //Method initVars

    getIsFlip:  function (){ return (1 == 1 || 2 == 2) ? true : false; },
    getIsFlip1: function (){ return (1 == 1)           ? true : false; },
    getIsFlip2: function (){ return (1 == 1)           ? true : false; },
    getIsFlip3: function (){ return (1 == 1)           ? true : false; },
    getIsFlip4: function (){ return (1 == 1)           ? true : false; },
    getIsFlip5: function (){ return (1 == 1)           ? true : false; },

    setAll: function (leftPage, rightPage){

        if(StateMachine.playerType == "double"){

            rightPage = (leftPage == maxPages) ? rightPage : parseInt(leftPage)+1;

            StateMachine.setPageRight(rightPage)
            StateMachine.setPageLeft(leftPage);

        }else{
            StateMachine.setPage(leftPage);
        }

    }, //Method setAll


    setPage:      function (page) { this.pageLeft = this.pageRight = this.page = page; }, //Method setPage
    setPageRight: function (page) { this.pageRight = page; this.setPage(page); }, //Method setpageRight
    setPageLeft:  function (page) { this.pageLeft = page; }, //Method setpageLeft

    getPage:      function ()     { return this.page; }, //Method getPage
    getPageRight: function ()     { return this.pageRight; }, //Method getpageRight
    getPageLeft:  function ()     { return this.pageLeft; }, //Method getpageLeft
    

    getPlayerType: function (str){
        return this.playerType;
    }, //Method getPlayerType


	onFront: function () {
		return ((StateMachine.pageLeft == StateMachine.pageMin) || (StateMachine.pageLeft == 0)) ? true : false;
	}, //Method onFront


	onBack: function () {
	    StateMachine.notIsFlipping();
		return (StateMachine.pageRight >= StateMachine.pageMax) ? true : false;
	}, //Method onBack


	notIsFlipping: function () {
		StateMachine.isFlipping = false;
	}, //Method notIsFlipping


	end: function () { Prototype.emptyFunction } //method end

} //Class stateMachineClass

StateMachine = new stateMachineClass();