VIEWS.Contact = {
    
    menu: ['MenuMenu', 'AboutMenu', 'StreamMenu', 'DistributionMenu', 'NewsMenu', 'ContactMenu'],
    menuPos: 2,
	//googleMenu: 'DistributionMenu',
	
    init: function(args) {
        AMOSTV.startLoading();
        this.loadText();
        
    },
    	
	updateTextPos: function(direction){
		var textStyle = $('ContactText').getStyle('top');
		var textHeight = $('ContactTextDiv').getHeight()  - $('ContactText').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 && ($('ContactTextDiv').getHeight() < $('ContactText').getHeight())) {
			$('contactTextDOWNOSD').show();
		} else {
			$('contactTextDOWNOSD').hide();
		}
		
		if(textStyle < 0 && ($('DistriTextDiv').getHeight() < $('ContactText').getHeight())){
			$('contactTextUPOSD').show();
		} else {
			$('contactTextUPOSD').hide();
		}
		
		if(direction < 0 && textStyle >= (textHeight-20)) {
			$('ContactText').setStyle({
				top: textStyle + "px"
			});		
		} else if(direction > 0 && textStyle <= 0){
			$('ContactText').setStyle({
				top: textStyle + "px"
			});
		}
	},
	
    show: function() {
        AMOSTV.stopLoading();
        AMOSTV.showView('Contact');
		VIEWS.GoogleMenu.show(5);
		VIEWS.GoogleMenu.setFocus();
		this.updateTextPos(1);
		_gaq.push(['_trackPageview', '/amosgtv/contact']);
    },
    
    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");
		}
    },
    
    loadText: function() {
		$('ContactText').innerHTML = "<p><strong>AMOS TV</strong></p>" +
		"<p>555 Madison Avenue, 20th Floor<br/>" +
		"New York NY 10022<br/>" +
		"T: 212-207-8892<br/>" +
		"F: 212-207-8899<br/>" +
		"<a href='mailto:info@amostv.com'>info@amostv.com</p>";
		
		$('ContactText').setStyle({
			top: "0px"
		});
        var self = this;
		jQuery("#ContactTextDiv").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);
			}
		}
	}
}

