// Tab Module
var tabModule = function() {
	return {
		init : function() {
			tabModule.render();
		},
		render : function(  ) {			
			var tabButtons			= $$( '#tabModule .tabs div' );
			tabButtons.each( function( tabButton ){
				
				tabButton.addEvent( 'click', tabModule.onClickEvent );
				
			} );
			
			var calcSubmit			= $( 'calculator_submit' );
			
			if( calcSubmit ) {
				calcSubmit.addEvent( 'mouseenter', tabModule.calcSubmitMouseEnterEvent );
				calcSubmit.addEvent( 'mouseleave', tabModule.calcSubmitMouseLeaveEvent );
			}
			
			var applyNowSubmit			= $( 'apply_submit' );
			
			if( applyNowSubmit ) {
				applyNowSubmit.addEvent( 'mouseenter', tabModule.applyNowSubmitMouseEnterEvent );
				applyNowSubmit.addEvent( 'mouseleave', tabModule.applyNowSubmitMouseLeaveEvent );
			}
		},
		calcSubmitMouseEnterEvent : function( e ) {
			
			this.setProperty( 'src', '_assets/images/getStarted/tabModule/cashCalculator_submit_hover.gif');
			
		},
		calcSubmitMouseLeaveEvent : function( e ) {
			
			this.setProperty( 'src', '_assets/images/getStarted/tabModule/cashCalculator_submit.gif');
			
		},
		applyNowSubmitMouseEnterEvent : function( e ) {
			
			this.setProperty( 'src', '_assets/images/getStarted/tabModule/apply_submit_hover.gif');
			
		},
		applyNowSubmitMouseLeaveEvent : function( e ) {
			
			this.setProperty( 'src', '_assets/images/getStarted/tabModule/apply_submit.gif');
			
		},
		onClickEvent : function( e ) {
			
			var target			= this;
			
			switch( target.getProperty( 'class' ) ) {
				
				case 'applyNowTab':
					tabModule.showTab( 'applyNow' );
					break;
				case 'calculatorTab':
					tabModule.showTab( 'calculator' );
					break;
				
			}
			
		},
		showTab : function( id ) {
			
			var tabContentContainers = $$( '#tabModule .tabContent' );
			
			tabContentContainers.each( function( tabContent ) {
				
				if( tabContent.getProperty( 'id' ) == id ) {
					
					tabContent.setStyle( 'display', 'block' );
					
				}
				else {
					
					tabContent.setStyle( 'display', 'none' );
					
				}
				
			} );
		}
	}
}();