ctv.ca.WMVVideoWindow = function (parentVideoWindow, wmObj) {
    this.parentVideoWindow = parentVideoWindow;
    this.wmObj = wmObj;
    this.volume = 50;
    this.positionTimer = null;
    this.currentPosition = 0;
}

ctv.ca.WMVVideoWindow.prototype = {
    playUrl : function (url) {
        this.stop();
        this.wmObj.URL = url;
        this.currentPosition = 0;
        this.play();
       
    },
    
    play : function () {
        try
        {
        this.wmObj.controls.play();
        this.getPosition();
        }
        catch (e) {}
    },
    
    stop : function () {
        try
        {
            clearTimeout(this.positionTimer);
            this.wmObj.controls.stop();
        }
        catch (e) {}        
    },
    
    pause : function () {
        clearTimeout(this.positionTimer);
        this.wmObj.controls.pause();
    },
    
    mute : function (goMute) {
        if (goMute)
        {
            this.wmObj.settings.volume = 0;
        }
        else
            this.wmObj.settings.volume = this.volume;
    },
    
    setVolume : function (value) {      
        this.volume = value;
        this.wmObj.settings.volume = value;
    },
    
    gotoPosition : function (pos) {
        this.wmObj.controls.currentPosition = (pos);
    },
    
    getMediaLength: function () {
        return this.wmObj.currentMedia.duration;
    },
    
    getPosition: function () {
        clearTimeout(this.positionTimer);
        try {
            this.currentPosition = this.wmObj.controls.currentPosition;            
	        this.parentVideoWindow.onPosition(this.currentPosition);
	    } catch(e) {
            this.parentVideoWindow.onPosition(0);
	    }
        var thisObj = this;
        this.positionTimer = setTimeout(function() { thisObj.getPosition() },500);
    },
    
    fullScreen : function (gotoFullScreen) {
        if (this.wmObj.fullscreen == gotoFullScreen)
            return;
            
        try {
            if (this.wmObj.playState == 3 && gotoFullScreen) { 
                this.wmObj.fullscreen = true;
            }
            else
                this.wmObj.fullscreen = false;
                
        }
	    catch(e) {
	    }
    },
    
    show : function (visible) {
        if (visible) {
            this.wmObj.uiMode = this.useInternalControl == true?"full":"none";
    	    this.wmObj.style.visibility = "visible"; 
        } else {
            if (this.wmObj.playState==3) return; 
                        		
            if (!this.wmObj.fullScreen)
		    { 
                this.wmObj.style.visibility = "hidden"; 
            }
        }
    },
    
    resize : function(w, h) {

    },
    
    moveTo : function(x, y) {

    },
    
    setCaption : function (text, visible) {

    },
    
    fullScreenChangedEvent : function (sender, eventArgs) {

    },
    
    setOverlay : function (imageUrl, visible) {

    }

}

ctv.ca.WMVVideoWindow.registerClass('ctv.ca.WMVVideoWindow', Sys.Component);
