$(document).ready(function() {
  
  // No keyline on the bottom td of table
  $('.listtable tr:last td').css('borderBottom','0');
  
  
  $('form.nocomplete').each(function() {
    this.setAttribute("autocomplete","off");
  });
  
  $('form.nocomplete input').each(function() {
    this.setAttribute("autocomplete","off");
  });
  
  
  $('.altRows tr:not(.altRows table tr):even').addClass('evenRow');
  
  $('a.checkContinue').each(function() {
    
    $(this).click(function(e) {
      e.preventDefault();
      
      var question='Are you sure?';
      if($(this).attr('rel') != '') question=$(this).attr('rel');
      
      var ans=confirm(question);
      
      if(ans) {
        window.location=$(this).attr('href');
      }else{
        return;
      }
      
    });
    
  });

  $('.jumpMenu').change(function() {
    
    var url=$(this).val();
    
    if(url=='') {
      $(this).find('option:first').attr('selected','selected');
      return false;
    }
    
    window.location=url;
    
  });
  
  $('.modal').facebox();
  
  
  // Account menu
  
  var accountmenuhide;
  
  $('.accountMenuTrigger').hover(function() {
    
    $('#accountmenu').show();
    clearTimeout(accountmenuhide);
    
  }, function() {
    accountmenuhide=setTimeout("hideAccountMenu()", 500);
  });
  
  $('#accountmenu').hover(function() {
    clearTimeout(accountmenuhide);
  }, function() {
    accountmenuhide=setTimeout("hideAccountMenu()", 500);
  });
  
  
  
  // Login menu
  
  var loginmenuhide;
  
  $('.loginMenuTrigger').click(function(e) {
    e.preventDefault();
    $('#loginMenu').toggle();
  });
  
  /*
  $('.loginMenuTrigger').hover(function() {
    
    $('#loginMenu').show();
    clearTimeout(loginmenuhide);
    
  }, function() {
    loginmenuhide=setTimeout("hideLoginMenu()", 500);
  });
  
  $('#loginMenu').hover(function() {
    clearTimeout(loginmenuhide);
  }, function() {
    loginmenuhide=setTimeout("hideLoginMenu()", 500);
  });
  
  */
  
});

function hideAccountMenu() {
  $('#accountmenu').hide();
}

function hideLoginMenu() {
  $('#loginMenu').hide();
}

function openwindow(url,width,height) {
  var blocker=window.open (url,"mywindow","status=no,width=" + width + ",height=" + height + ",location=no,menubar=no,resizable=yes,scrollbars=yes,directories=no,toolbar=no");
  
  if(!blocker) {
    alert('Please turn off your popup blocker');
  }
  
}
