var Utils = function(){return {

    TEST_VAR_X: 0,
    TEST_VAR_A: 1,
    TEST_VAR_B: 2,

    TEST_VAR_A_PROB: 0.5,
    
    cookieExpiresShort: 1,
    cookieExpiresLong: 3,

    cookieShort: null,
    cookieLong: null,

    init: function(){
        this.cookieShort = new Cookie();
        this.cookieShort.init({name: 'dpshort', expires: this.cookieExpiresShort } );

        this.cookieLong = new Cookie();
        this.cookieLong.init({name: 'dplong', expires: this.cookieExpiresLong } );
    },

    erase: function(){
        this.cookieShort.erase();
        this.cookieLong.erase();
    },

    resetTestVar: function(){
        this.setTestVar( this.TEST_VAR_X );
    },

    getRandomTestVar: function(){
        var testvar = this.TEST_VAR_A;

        if ( this.TEST_VAR_A_PROB <= 0 ) { testvar = this.TEST_VAR_B; }
        if ( this.TEST_VAR_A_PROB >= 1 ) { testvar = this.TEST_VAR_A; }
        if ( this.TEST_VAR_A_PROB < 1 && this.TEST_VAR_A_PROB > 0 ) {
            testvar = Math.random() > this.TEST_VAR_A_PROB ? this.TEST_VAR_B : this.TEST_VAR_A;
        }
        return( testvar );
    },

    getTestVariant: function(){ 
        var testvar = this.getTestVar();
        testvar = testvar == this.TEST_VAR_X ? this.getRandomTestVar() : testvar;
        this.setTestVar( testvar );
        return( testvar );
    },

    setTestVar: function( value ){
        this.cookieShort.setData('testvar', value );
    },

    getTestVar: function(){
       var testvar = this.cookieShort.getData('testvar');
       testvar = typeof testvar === 'undefined' ? this.TEST_VAR_X : testvar;
       return( testvar );
    },

    setSceneVorteilsmodul:function ( id ){
        this.cookieShort.setData('sceneIdVorteilsmodul', id );
    },

    getSceneVorteilsmodul:function ( ){
        var  nextScene = this.cookieShort.getData('sceneIdVorteilsmodul');
        nextScene = typeof nextScene === 'undefined' ? 1 : nextScene;
        return( nextScene );
    },

    resetSceneVorteilsmodul: function(  ){
        this.cookieShort.setData( 'sceneIdVorteilsmodul', 1 );
    },

    setSceneGuidedTour:function ( id ){
        this.cookieLong.setData('sceneIdGuidedTour', id );
    },

    getSceneGuidedTour:function ( ){
        var  nextScene = this.cookieLong.getData('sceneIdGuidedTour');
        nextScene = typeof nextScene === 'undefined' ? 1 : nextScene;
        return( nextScene );
    },

    resetSceneGuidedTour: function(  ){
        this.cookieLong.setData( 'sceneIdGuidedTour', 1 );
    },
    
    setSceneClickdummy:function ( id ){
        this.cookieLong.setData('sceneIdClickdummy', id );
    },

    getSceneClickdummy:function ( ){
        var  nextScene = this.cookieLong.getData('sceneIdClickdummy');
        nextScene = typeof nextScene === 'undefined' ? 0 : nextScene;
        return( nextScene );
    },

    resetSceneClickdummy: function(  ){
        this.cookieLong.setData( 'sceneIdClickdummy', 0 );
    },
    
    setRepeatValue:function  ( value ){
        this.cookieLong.setData('repeatUser', value );
    },

    getRepeatValue:function ( ){
        var repeat = this.cookieLong.getData('repeatUser');
        repeat = typeof repeat !== 'undefined' ? repeat : 0;
        return( repeat );
    },

    incRepeatValue: function( ){
        var repeat = this.getRepeatValue( );
        repeat++;
        repeat = repeat > 2 ? 2 : repeat;
        this.setRepeatValue( repeat );
    },

    resetRepeat: function( ){
      this.cookieLong.setData('repeatUser', 0 );
    }

};};

Utils.factory = function() {
       var result = new Utils();
       result.init();
       return( result );
};


