
VIEWS.About = {
    
    menu: ['MenuMenu', 'AboutMenu', 'DistributionMenu', 'NewsMenu', 'ContactMenu'],
   // menuPos: 1,
	//googleMenu: 'AboutMenu',
	
    init: function(args) {
        AMOSTV.startLoading();
        this.loadText();
    },

	//function called when the user pressed up or down arrow to scroll text
	updateTextPos: function(direction){
		var textStyle = $('AboutText').getStyle('top');
		var textHeight = $('AboutTextDiv').getHeight() - $('AboutText').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 the textdiv element is bigger than the container + position of the text is greater than the totalt height on text show down arrow
		if(textStyle > textHeight && ($('AboutTextDiv').getHeight() < $('AboutText').getHeight())) {
			$('aboutTextDOWNOSD').show();
		} else {
			$('aboutTextDOWNOSD').hide();
		}
		
		if(textStyle < 0 && ($('AboutTextDiv').getHeight() < $('AboutText').getHeight())){
			$('aboutTextUPOSD').show();
		} else {
			$('aboutTextUPOSD').hide();
		}
		
		if(direction < 0 && textStyle >= (textHeight)) {
			$('AboutText').setStyle({
				top: textStyle + "px"
			});		
		} else if(direction > 0 && textStyle <= 0){
			$('AboutText').setStyle({
				top: textStyle + "px"
			});
		}
	},
	
    show: function() {
        AMOSTV.stopLoading();
		//this.menuPos = 1;
        AMOSTV.showView('About');
		VIEWS.GoogleMenu.show(1);
		VIEWS.GoogleMenu.setFocus();
		this.updateTextPos(1); // try scrolling text to top to make sure the uparrow is gone
		_gaq.push(['_trackPageview', '/amosgtv/about']);
	//	this.updateMenu();

		
    },
    
    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"); // send keyevent "ok" to GoogleMenu.js
			//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) === "Distribution")
				//AMOSTV.loadView(this.menu[this.menuPos].substring(0, this.menu[this.menuPos].length-4));
		}
    },
    
    loadText: function() {
		var abText = "Using only top quality High Definition video footage, AMOS TV takes viewers on a breathtaking, non-verbal journey around the globe. Creating thematically driven videos, from wildlife to city life, paired with soundtracks from the top musical collections in the world, AMOS TV will remind you of the magic of the world around us and keep you captivated. ";

		$('AboutText').innerHTML = abText;
		$('AboutText').setStyle({
			top: "0px"
		});
        var self = this;
        self.show();
		jQuery("#AboutTextDiv").fadeTo(1000,1);
    },
	
	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);
			}
		}
	}
}

