// JavaScript Document

var selected = "button1" ;
function showBottom( bottom ) {
	 $('#sms_bottom').hide() ;
	 $('#web20_bottom').hide() ;
	 $('#mobile_bottom').hide() ;
	 $('#header').height( 485 ) ; 
	 $(bottom).slideDown('fast') ;
}
function turnOn( top ) {
	var image ;
	if( top == "button1" ) {
		image = 'images/button1-act.jpg' ;
	} else if( top == "button2" ) {
		image = 'images/button2-act.jpg' ;
	} else if (top == "button3" ) {
		image = 'images/button3-act.jpg' ;
	}
	
	var button = "." + top ;
	
	$( button ).css( {backgroundImage : 'url(' + image + ')' } ) ;
}

function turnOff( top ) {
	var image ;
	if( top == "button1") {
		image = 'images/button1.jpg' ;
	} else if( top == "button2" ) {
		image = 'images/button2.jpg' ;
	} else if (top == "button3" ) {
		image = 'images/button-3.jpg' ;
	}
	
	var button = "." + top ;
	
	$( button ).css( {backgroundImage : 'url(' + image + ')' } ) ;
}

$(document).ready(function() {
		setTopNav() ;
	  $('a.button1').hover(
        function () {
			turnOn( 'button1' ) ;
          //$(this).animate({backgroundColor:'Yellow', color:'Red'}, {queue:false,duration:500});
        }, function () {
			if( selected != "button1" )
			turnOff( 'button1' ) ;
          //$(this).animate({backgroundColor:'#ececed', color:'#777777'}, {queue:false,duration:500});
        });
		
		$('a.button1').click(
		  function() {
		  	selected = "button1" ;
			turnOn( 'button1' ) ;
			turnOff( 'button2' ) ;
			turnOff( 'button3' ) ;
		}) ;
		
      $('a.button2').hover(
        function () {
			turnOn( 'button2' ) ;
          //$(this).animate({backgroundColor:'Yellow', color:'Red'}, {queue:false,duration:500});
        }, function () {
			if( selected != "button2" )
			turnOff( 'button2' ) ;
          //$(this).animate({backgroundColor:'#ececed', color:'#777777'}, {queue:false,duration:500});
        });
		
		$('a.button2').click(
		  function() {
		  	selected = "button2" ;
			turnOn( 'button2' ) ;
			turnOff( 'button1' ) ;
			turnOff( 'button3' ) ;
		}) ;
		
	  $('a.button3').hover(
        function () {
			turnOn( 'button3' ) ;
          //$(this).animate({backgroundColor:'Yellow', color:'Red'}, {queue:false,duration:500});
        }, function () {
			if( selected != "button3" )
			turnOff( 'button3' ) ;
          //$(this).animate({backgroundColor:'#ececed', color:'#777777'}, {queue:false,duration:500});
        });
		
		$('a.button3').click(
		  function() {
		  	selected = "button3" ;
			turnOn( 'button3' ) ;
			turnOff( 'button1') ;
			turnOff( 'button2' ) ;
		}) ;
    });