//*** Class MiniChannelHandler *****************************************************************
// Handles open and close of the mini channel area (#middle in portal.aspx) 
// Function openClose() is called onclick on #closeBtn and #openBtn in portal.aspx
// Function openAndPlay is called by function initPortal if contentId != null;
// When the mini channel is open #banner_3 is invisible and when it's closed #banner_3 is visible
var MiniChannelHandler = Class.create();
MiniChannelHandler.prototype = {       
    initialize: function(){
        this.max = 449; // #bottom style.top when mini channel is open
        this.min = 95; // #bottom style.top when mini channel is closed
        this.yPos; // keeps track of #bottom style.top position
        this.isOpen = false; // mini channel area's open/closed state
        this.isActive = false; // is true if mini channel area is closing or opening
    },
    openAndPlay:function(contentId){
        $("bottom").style.top = this.max+"px";
        $("middle").style.display = "block";
        $("banner_3").style.display = "none";
        $("openBtn").style.display = "none";
        $("closeBtn").style.display = "block";
        this.isOpen = true;
        createClickEvent(contentId);
    },
    openClose:function(){
        this.isActive = true;
        if(this.isOpen){
            this.yPos = this.max;
            $("middle").style.display = "none";
            oPlayer.stop();
            this.startClose();   
        }
        else{
            this.yPos = this.min;
            //$("banner_3").style.display = "none";
            this.startOpen();   
        }
    },
    startClose:function(){
        if(this.yPos > this.min){
            var thisObj = this; 
		    this.to = setTimeout(function() {thisObj.moveUp()}, 15);
        }
        else{
            this.isOpen = false;
            $("closeBtn").style.display = "none";
            $("openBtn").style.display = "block";
            //$("banner_3").style.display = "block";
            this.isActive = false;
        }
    },
    moveUp:function(){
        this.yPos = this.yPos-25;
        if(this.yPos < this.min){
            this.yPos = this.min;
            
        }
        $("bottom").style.top = this.yPos+"px";
        this.startClose();  
    },
    startOpen:function(){
        if(this.yPos < this.max){
            var thisObj = this; 
		    this.to = setTimeout(function() {thisObj.moveDown()}, 15);
        }
        else{
            this.isOpen = true;
            $("openBtn").style.display = "none";
            $("closeBtn").style.display = "block";
            this.isActive = false;
            $("middle").style.display = "block";
            
        }
    },
    moveDown:function(){
        this.yPos = this.yPos+25;
        if(this.yPos > this.max){
            this.yPos = this.max;
        }
        $("bottom").style.top = this.yPos+"px";
        this.startOpen();  
    }
};
oMiniChannelHandler = new MiniChannelHandler();

