how make a condition with events onclick click on button

how make a condition with events onclick click on button

hello there,
i am  working with  window.pageYOffset. i use to know what is the position on Y to active a class in menu and to do a lot more things.

  1. window.onscroll = function () {

  2.     //null
  3.     if (window.pageYOffset >= 100){
  4.     document.getElementById("menu-Bt1").className = "menu-bt";
  5.     document.getElementById("menu-Bt2").className = "menu-bt";
  6.     document.getElementById("menu-Bt3").className = "menu-bt";
  7.     document.getElementById("menu-Bt4").className = "menu-bt";
  8.     document.getElementById("menu-Bt5").className = "menu-bt";
  9. }  

my big problem for now is how to make a condition.


  1. $('li.fields').filter(':nth-child(n+0)').addClass('hide'); 

  2. $('ul').on('click', 'li.title:nth-child(1)', function() {        
  3.         $(this).next(). slideToggle (200).siblings('li.fields').slideUp(200); 

  4. window.onscroll = function () {

  5.     //null
  6.     if (window.pageYOffset >= 500){
  7.     document.getElementById("menu-Bt1").className = "menu-bt";
  8.     document.getElementById("menu-Bt2").className = "menu-bt";
  9.     document.getElementById("menu-Bt3").className = "menu-bt";
  10.     document.getElementById("menu-Bt4").className = "menu-bt";
  11.     document.getElementById("menu-Bt5").className = "menu-bt";
  12. }  
i have a default  window.pageYOffset = 100 , but when click i am looking for a toogle change . when   $('ul').on('click'  window.pageYOffset = 500 but when click again change the 500 to 100.

sorry for my bad english hope some one help me out.
i can put some example more later in jsfiddle thanks in advance