VIEWS.Distribution = {
    
    menu: ['MenuMenu', 'AboutMenu', 'StreamMenu', 'DistributionMenu', 'NewsMenu', 'ContactMenu'],
    menuPos: 2,
	//googleMenu: 'DistributionMenu',
	
    init: function(args) {
        AMOSTV.startLoading();
        this.loadText();
        
    },
    	
	updateTextPos: function(direction){
		var textStyle = $('DistriText').getStyle('top');
		var textHeight = $('DistriTextDiv').getHeight()  - $('DistriText').getHeight();
		var textStyle = (parseInt(textStyle.substring(0, textStyle.length - 2)) + (direction * 40));
		var safeSizeDown = ((textStyle)*(-1));
		
		if((safeSizeDown > textHeight) && (safeSizeDown + textHeight) > 0) {
			textStyle = (textHeight-20);
		} else if(textStyle > 0) {
			textStyle = 0;
		}
	
		if(textStyle > textHeight && ($('DistriTextDiv').getHeight() < $('DistriText').getHeight())) {
			$('distriTextDOWNOSD').show();
		} else {
			$('distriTextDOWNOSD').hide();
		}
		
		if(textStyle < 0 && ($('DistriTextDiv').getHeight() < $('DistriText').getHeight())){
			$('distriTextUPOSD').show();
		} else {
			$('distriTextUPOSD').hide();
		}
		
		if(direction < 0 && textStyle >= (textHeight-20)) {
			$('DistriText').setStyle({
				top: textStyle + "px"
			});		
		} else if(direction > 0 && textStyle <= 0){
			$('DistriText').setStyle({
				top: textStyle + "px"
			});
		}
	},
	
    show: function() {
        AMOSTV.stopLoading();
        AMOSTV.showView('Distribution');
		VIEWS.GoogleMenu.show(3);
		VIEWS.GoogleMenu.setFocus();
		this.updateTextPos(1);
		_gaq.push(['_trackPageview', '/amosgtv/distribution']);
    },
    
    exit: function() {
    },
    
    keyHandler: function(key) {
        if ( key == KEYS.BACK || key == KEYS.ESC ) {
			VIEWS.GoogleMenu.hide();
            AMOSTV.loadPreviousView();
        }
		
		if ( key == KEYS.RIGHT ) {
			VIEWS.GoogleMenu.keyHandler("right");
        }
		
		if ( key == KEYS.LEFT ) {
			VIEWS.GoogleMenu.keyHandler("left");
		}
		
		if ( key == KEYS.UP ) {
				this.updateTextPos(1);
		}
		
		if ( key == KEYS.DOWN ) {
				this.updateTextPos(-1);
		}
		if ( key == KEYS.OK ) {
			VIEWS.GoogleMenu.keyHandler("ok");
			//remove the following if when all pages work
			//if(this.menu[this.menuPos].substring(0, this.menu[this.menuPos].length-4) === "Menu" || this.menu[this.menuPos].substring(0, this.menu[this.menuPos].length-4) === "About")
				//AMOSTV.loadView(this.menu[this.menuPos].substring(0, this.menu[this.menuPos].length-4));
		}
    },
    
    loadText: function() {
		// $('DistriText').innerHTML = " AMOS TV is now available on a variety of platforms:"+
		// "<ul><li>         AMOS TV is available in over 1.8 million hotel rooms in the US, check your hotel's television listings</li>"+
		// "<li>         Purchase the AMOS Blu-ray and DVD collection at your preferred retailer or click here: <a href='http://www.amazon.com/HD-Moods-AMOS-Rise-Blu-ray/dp/B003NFHTM6'>Rise</a> and <a href='http://www.amazon.com/HD-Moods-AMOS-Rebel-Blu-ray/dp/B003NFHTMG/ref=sr_1_1?ie=UTF8&s=dvd&qid=1298473055&sr=8-1'>Rebel</a></li>"+
		// "<li>         Download the AMOS HD App through Samsung Apps, to stream premium HD videos through connected Samsung Smart TVs</li>"+
		// "<li>         Enjoy the AMOS TV website optimized for the Google TV viewing experience and gain access to a wide collection of streaming HD videos</li></ul>"+
		// "More options for viewing AMOS will be available shortly - please be sure to check back soon!";

		var content="";
		content += "<div>";
		content += "    <div class=\"tableLeft\">";
		content += "<a href=\"javascript:\"><img src=\"img\/logos\/amos_nobackground.png\"><\/a>";
		content += "    <\/div>";
		content += "    <div class=\"tableRight\">";
		content += "        Stream AMOS right now";
		content += "    <\/div>";
		content += "    <div class=\"clearFix\"><\/div>";
		content += "<\/div>";
		content += "<div>";
		content += "    <div class=\"tableLeft\">";
		content += "<a href=\"http:\/\/www.amazon.com\/Rest-AMOS-TV-Eytan-Rockaway\/dp/B004YWEULK\/ref=sr_1_1?ie=UTF8&qid=1310739743&sr=8-1\" target=\"_blank\"><img src=\"img/logos/amazon.png\"><\/a>";
		content += "    <\/div>";
		content += "    <div class=\"tableRight\">";
		content += "        Purchase AMOS on DVD and Blu-ray";
		content += "    <\/div>";
		content += "    <div class=\"clearFix\"><\/div>";
		content += "<\/div>";
		content += "<div>";
		content += "    <div class=\"tableLeft\">";
		content += "<a href=\"http:\/\/www.samsung.com\/us\/appstore\/app\/G00000364847\" target=\"_blank\"><img src=\"img\/logos\/samsung.png\"><\/a>";
		content += "    <\/div>";
		content += "    <div class=\"tableRight\">";
		content += "        Purchase the AMOS app";
		content += "    <\/div>";
		content += "    <div class=\"clearFix\"><\/div>";
		content += "<\/div>";
		content += "<div>";
		content += "    <div class=\"tableLeft\">";
		content += "<a href=\"http:\/\/www.google.com\/tv\/spotlight.html\" target=\"_blank\"><img src=\"img\/logos\/google.png\"><\/a>";
		content += "    <\/div>";
		content += "    <div class=\"tableRight\">";
		content += "        View AMOS on Google TV's Spotlight gallery";
		content += "    <\/div>";
		content += "    <div class=\"clearFix\"><\/div>";
		content += "<\/div>";
		content += "<div>";
		content += "    <div class=\"tableLeft\">";
		content += "<a href=\"http:\/\/www.thehotelnetworks.com\/programming\/exclusive_content.php\" target=\"_blank\"><img src=\"img\/logos\/lodgeNet.gif\"><\/a>";
		content += "    <\/div>";
		content += "    <div class=\"tableRight\">";
		content += "        Enjoy AMOS when you travel";
		content += "    <\/div>";
		content += "    <div class=\"clearFix\"><\/div>";
		content += "<\/div>";	

		$('DistriText').innerHTML = content;

		$('DistriText').setStyle({
			top: "0px"
		});
        var self = this;
		jQuery("#DistriTextDiv").fadeTo(1000,1);
        self.show();
    },
	
	mouseClicked: function(buttonClicked){
		
		if(buttonClicked.indexOf('Menu') != -1){
			if(buttonClicked.length > 4){
				VIEWS.GoogleMenu.keyHandler("ok");
			}
		} else if(buttonClicked.indexOf('OSD') != -1 && buttonClicked.indexOf('DOWN') != -1) {
			this.keyHandler(KEYS.DOWN);
		} else if(buttonClicked.indexOf('OSD') != -1 && buttonClicked.indexOf('UP') != -1) {
			this.keyHandler(KEYS.UP);
		}
		
	}, 
	
	mouseOver: function(buttonHovered){

		if(buttonHovered.indexOf('Menu') != -1){ // we hover bottom menu
			if(buttonHovered.length > 4){
				this.menuYPos = 1;
				//this.loadMenu();
				VIEWS.GoogleMenu.focusElement(buttonHovered);
			}
		}
	}
}

