/*
 * IdeaValley Innovation
 * FlipSite
 * Maio 2006
 * Luiz Paulo dos Prazeres Júnior
 * 
 * flipActions Class
 */
 
var FlipActionsClass       = Class.create();

FlipActionsClass.prototype = {

	initialize: function () {

		this.flipActions = new Array();
		this.flipActions["gotoPage"]     = new ActionsClass();
		this.flipActions["gotoEditoria"] = new ActionsClass();
		this.flipActions["gotoMateria"]  = new ActionsClass();
		this.flipActions["gotoAnuncio"]  = new ActionsClass();
		this.flipActions["gotoZoom"]     = new ActionsClass();
		this.flipActions["openURL"]      = new ActionsClass();
		this.flipActions["openMateria"]  = new ActionsClass();

	}, //method initialize


	register: function (func, action, order) {

		if((order != "before") && (order != "after") && (order != "action")){
			return false;
		}else if(isObject(this.flipActions[action])){
			(order == "action") ? this.flipActions[action].setAction(func) : this.flipActions[action].register(func, order);
		}else{
		       msg = "FUNCAO: "+action+" NAO EXISTE! \n\n";
		       msg += "Verifique a classe que registra: \n_______________________\n"+func+"\n";
		       msg += "_______________________\n\n"+order; 
            alert(msg);
		}

	}, //method register


	gotoPage: function(page){
		FlipAction.flipActions["gotoPage"].run(page);
        return false;
	}, //method gotoPage


	nextPage: function(){
		FlipAction.gotoPage(StateMachine.getPageRight()+1);
        return false;
	}, //method nextPage


	prevPage: function(){
		FlipAction.gotoPage(StateMachine.getPageLeft()-1);
        return false;
	}, //method prevPage


    gotoEditoria: function () {
	    var args = arrayToArgs(arguments, 0);
        eval('FlipAction.flipActions["gotoEditoria"].run('+args+');');
        return false;
    }, //method  gotoEditoria


    gotoMateria: function () {
	    var args = arrayToArgs(arguments, 0);
        eval('FlipAction.flipActions["gotoMateria"].run('+args+');');
        return false;
    }, //method  gotoMateria


    gotoAnuncio: function () {
	    var args = arrayToArgs(arguments, 0);
        eval('FlipAction.flipActions["gotoAnuncio"].run('+args+');');
        return false;
    }, //method  gotoAnuncio


    openMateria: function (nrPage, obj) {
    	var args = new Array();
    	
    	args[0] = obj.idMateria;
    	args[1] = obj.idActionType;
    	args[2] = nrPage;
    	args = arrayToArgs(args, 0);
        eval('FlipAction.flipActions["openMateria"].run('+args+');');
    	return false;
    }, //method  openMateria


    openURL: function (nrPage, obj) {
    	var args = new Array();
    	args[0] = obj.idAnuncio;
    	args[1] = obj.idActionType;
    	args[2] = obj.URL;

	    var args = arrayToArgs(args, 0);
	    eval('FlipAction.flipActions["openURL"].run('+args+');');
        return false;
    }, //method  openURL


    openAudio: function (obj) {
        alert("Funcionalidade Audio Desabilitada!");
    },

    openVideo: function (obj) {
        alert("Funcionalidade Video Desabilitada!");
    },

    openProduto: function (obj) {
        alert("Funcionalidade Desabilitada!");
    },

    gotoZoom: function () {
	    var args = arrayToArgs(arguments, 0);
        eval('FlipAction.flipActions["gotoZoom"].run('+args+');');
        return false;
    }, //method  gotoZoom


     callBack: function (leftPage, rightPage, obj) {
//        StateMachine.setAll(leftPage, rightPage);
	    var args = arrayToArgs(arguments, 0, 1);
        eval('FlipAction.flipActions["gotoPage"].doAfter(FlipAction.flipActions["gotoPage"], '+args+');');
        try{requestStickyPage(rightPage);}catch(e){}
    }, //method callBack

     flipping: function (bolean){
         try{ StateMachine.isFlipping = true; }catch(e){}
     },

	end: function () { Prototype.emptyFunction } //method end
}

FlipAction = new FlipActionsClass();