VIEWS.GoogleCheckoutDone = {

	//currPlayerID: null,
	
	init: function(args)
	{
		this.menuPos = "checkoutDoneWatchNow";
		this.currPlayerID = args.currPlayer;
		this.loadPlayer(this.currPlayerID,args.playList);
	},
	
	hide: function(){
		$('GoogleCheckoutDone').hide();
	},
	
	show: function(menuPos){
		$('GoogleCheckoutDone').show();
	},
		
    exit: function() {
    },
	
    keyHandler: function(key) {
		if( key == KEYS.DOWN ) {
			this.setMenuPos(this.menuPos, "checkoutDoneBack");
		}
		if( key == KEYS.UP ) {
			this.setMenuPos(this.menuPos, "checkoutDoneWatchNow");
		}
		if( key == KEYS.OK ) {
			switch(this.menuPos){
				case "checkoutDoneWatchNow":
					
					AMOSTV.loadView('Play', { playerIndex: this.currPlayerID });
				break;
				
				case "checkoutDoneBack":
					//brightcove.removeExperience("googlePreview");
					$('GoogleCheckoutDone').hide();
					AMOSTV.loadView('Menu');
				break;
				
			}	
		}
		
		if ( key == KEYS.ESC ) {
			$('GoogleCheckoutDone').hide();
			AMOSTV.loadView('Menu');
		}
	},
	
	//function so update which button is highlighted.
	setMenuPos: function(prevPos, previewPos) {
		$(prevPos).removeClassName("focused");
		this.menuPos = previewPos;
		var menuItem = $(previewPos);
		menuItem.addClassName("focused");
	},
	
	//current view mouse click handler.
	mouseClicked: function(buttonClicked){
		switch(buttonClicked){
			case "checkoutDoneWatchNow":
				AMOSTV.loadView('Play', { playerIndex: this.currPlayerID });
			break;
			
			case "checkoutDoneBack":
				$('GoogleCheckoutDone').hide();
				AMOSTV.loadView('Menu');
			break;
		}
		
	}, 
	
	//mouseover event handler
	mouseOver: function(buttonHovered){
		switch(buttonHovered){
			case "checkoutDoneWatchNow":
				this.setMenuPos(this.menuPos, "checkoutDoneWatchNow");
			break;
			
			case "checkoutDoneBack":
				this.setMenuPos(this.menuPos, "checkoutDoneBack");
			break;
						
		}
	},
    // load a player with its playlists (a player represents a category)
    loadPlayer: function(playerIndex,playList) {
        
        // retrieve playlist with only video IDs, not entire video objects
        var self = this;
        Brightcove.getPlaylistsByPlayer(AMOSTV.players[playerIndex].id
        , function(player){
            
            // store player, and also its playlists separately, for convenience
            AMOSTV.players[playerIndex].player = player;
            AMOSTV.players[playerIndex].playlists = player.items;
			AMOSTV.players[playerIndex].positions.curr = playList;
			self.setMenuPos(self.menuPos, "checkoutDoneWatchNow");
			$('GoogleCheckoutDone').show();
			_gaq.push(['_trackPageview', '/amosgtv/CheckoutDone/'+self.currPlayerID+'_'+AMOSTV.players[self.currPlayerID].playlists[AMOSTV.players[self.currPlayerID].positions.curr].name]);
			AMOSTV.showView('GoogleCheckoutDone');
			
        });
    }
	
}
