﻿Type.registerNamespace("DDT");
DDT.Direction = function(){};
DDT.Direction.prototype = {
        Up:0,
        Down:1
    } 
DDT.Direction.registerEnum("DDT.Direction");
DDT.Marqee = function(element) {
    DDT.Marqee.initializeBase(this, [element]);

    this.EnumDirection  = DDT.Direction.Up
    this.Speed = 30;
    this.TimeId = null;
}

DDT.Marqee.prototype = {
    initialize: function() {
        DDT.Marqee.callBaseMethod(this, 'initialize');        
        this.get_element().innerHTML += this.get_element().innerHTML;
        this.get_element().style.overflow = "hidden";
         this._onMouseOverHandlerUp = Function.createDelegate(this,this._onMouseOverUp);
        this._onMouseOutHandlerUp = Function.createDelegate(this,this._onMouseOutUp);
        this._onMouseOverHandlerDown = Function.createDelegate(this,this._onMouseOverDown);
        this._onMouseOutHandlerDown = Function.createDelegate(this,this._onMouseOutDown);
        this._onMarqeeHandler = Function.createDelegate(this,this._onMarqee);
        $addHandler($get("marqueeup"), "mouseover",this._onMouseOverHandlerUp);
        $addHandler($get("marqueeup"), "mouseout",this._onMouseOutHandlerUp);
         $addHandler($get("marqueedown"), "mouseover",this._onMouseOverHandlerDown);
        $addHandler($get("marqueedown"), "mouseout",this._onMouseOutHandlerDown);
       // this.TimeId = setInterval(this._onMarqeeHandler,this.Speed);
        // Add custom initialization here
    },_onMarqee:function(){
        switch(this.EnumDirection)
        {
           
            case DDT.Direction.Up:
                if(this.get_element().scrollTop>=(this.get_element().scrollHeight) /2){            
                    this.get_element().scrollTop = 0;
                }else{
                    this.get_element().scrollTop ++;
                }
            break;
            case DDT.Direction.Down:
                if(this.get_element().scrollTop<=0){                               
                    this.get_element().scrollTop = (this.get_element().scrollHeight) /2;
                }else{
                    this.get_element().scrollTop --;
                }
            break;
            default:
            break;
            
        }
        
    }
    ,_onMouseOutDown:function(){
    this.EnumDirection=DDT.Direction.Down;
        clearInterval(this.TimeId);        
    },_onMouseOverDown:function(){
        this.EnumDirection=DDT.Direction.Down;
        this.TimeId = setInterval(this._onMarqeeHandler,this.Speed);
    },
    
    _onMouseOutUp:function(){
    this.EnumDirection=DDT.Direction.Up;
        clearInterval(this.TimeId);        
    },_onMouseOverUp:function(){
        this.EnumDirection=DDT.Direction.Up;
        this.TimeId = setInterval(this._onMarqeeHandler,this.Speed);
    },
    dispose: function() {        
        //Add custom dispose actions here
        DDT.Marqee.callBaseMethod(this, 'dispose');
    }
}
DDT.Marqee.registerClass('DDT.Marqee', Sys.UI.Behavior);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

