// requires prototype.js

document.observe('dom:loaded', function() {
    $('signOutButton').onclick=function(){return false;}
    $('signOutButton').observe('click', sign_out);

    $('signInButton').onclick=function(){return false;}
    $('signInButton').observe('mouseover', function(e){
	  
	  menuId='signin_header';

	  offsetTop = $(this).cumulativeOffset()[1]+$(this).getHeight()+10;
	  offsetLeft = $('headerContent').cumulativeOffset()[0]+608;

	  //arrow position 
	  $(menuId).firstDescendant().setStyle({'left': ( $(this).cumulativeOffset()[0]-offsetLeft+$(this).getWidth()/2-3 ) + 'px'});
	  
	  if ($(menuId).popup == undefined) new Popup(menuId, menuId, 
					      {position: offsetLeft+","+offsetTop,
						  autoclose: true
					      });
	  
	  // hide any other open menus 
	  if (menuId == fullEpisodesMenuId && $(showsMenuId).popup != undefined) {
		  $(showsMenuId).popup.hide();
	  } 
	  else if (menuId == showsMenuId && $(fullEpisodesMenuId).popup != undefined) {
		  $(fullEpisodesMenuId).popup.hide();
	  }

	  // show the active menu
	  $(menuId).popup.stop_hide_timer();
	  $(menuId).popup.show()

      });

    $('signInButton').observe('mouseout', function(e) { 
	  doNavMouseOut('signin_header');
      })

    $('registerButton').onclick=function(){return false;}
    $('registerButton').observe('click', function(e){
	open_signup_popup('signup'); 
      });

    $('popupLoginButton').onclick=function(){return false;}
    $('popupLoginButton').observe('click', function(e){
	login($("Username_header").value, $("Password_header").value, "_header");
      });

//    $('popupForgotPasswordButton').onclick=function(){return false;}
 //   $('popupForgotPasswordButton').observe('click', function(e){
	//check_form_forgot_password('Username_header', 'error_signin_header');
    //  });

    $('forgotPasswordSubmitButton').onclick=function(){return false;}
    $('forgotPasswordSubmitButton').observe('click', function(e){
	check_form_forgot_password('UsernameOrEmail', '_header');
      });


  });
