Team:IISER-Kolkata/main.js

$(window).on('resize',function() {

   location.reload();

});

$(window).on("load", function() {

   //navmenubar
   var sticky = $("#menubar").offset().top; 
   $(window).scroll(function() {    
       if ($(window).scrollTop() > sticky) {
           $("#menubar").addClass("stickymenu");
       } else {
           $("#menubar").removeClass("stickymenu");
       } 
   });

var homePos = $("#home").offset().top;

   var aboutUsPos = $("#aboutUs").offset().top;
   var eventsPos = $("#events").offset().top;
   var galleryPos = $("#gallery").offset().top;
   var ourTeamPos = $("#ourTeam").offset().top;
   var sponsorsPos = $("#sponsors").offset().top;
   var reachUsPos = $("#reachUs").offset().top;
   $(document).on("click", "#pagedown", function() {

$("body, html").animate({scrollTop: aboutUsPos+2}, 1000, "swing"); }); $(document).on("click", "#homeMenu", function() {

       $("body, html").animate({scrollTop: 0}, 1000, "swing");
   });
   $(document).on("click", "#aboutUsMenu", function() {
       $("body, html").animate({scrollTop: aboutUsPos+2}, 1000, "swing");
   });
   $(document).on("click", "#eventsMenu", function() {
       $("body, html").animate({scrollTop: eventsPos}, 1000, "swing");
   });
   $(document).on("click", "#galleryMenu", function() {
       $("body, html").animate({scrollTop: galleryPos}, 1000, "swing");
   });
   $(document).on("click", "#ourTeamMenu", function() {
       $("body, html").animate({scrollTop: ourTeamPos}, 1000, "swing");
   });
   $(document).on("click", "#sponsorsMenu", function() {
       $("body, html").animate({scrollTop: sponsorsPos}, 1000, "swing");
   });
   $(document).on("click", "#reachUsMenu", function() {
       $("body, html").animate({scrollTop: reachUsPos}, 1000, "swing");
   });  
   $(".pagelink#registerMenu").click(function() {
       $("#register").css("left","30vw");
       $("#login").css("left","-35vw");
   });
   $(".pagelink#loginMenu").click(function() {
       $("#login").css("left","35vw");
       $("#register").css("left","-45vw");
   });
   $("#register .exit").click(function() {
       $("#register").css("left","-45vw");
   });
   $("#login .exit").click(function() {
       $("#login").css("left","-35vw");
   });
   var halfHeight = window.innerHeight/2;
   $(window).scroll(function(){
       var windowPos = $(window).scrollTop() + 1;
       if (windowPos >= homePos && windowPos < aboutUsPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#homeMenu").css("background-color","#bbbbbb");
           $(".pagelink#homeMenu div p").css("color","black");
       } 
       else if (windowPos >= aboutUsPos - halfHeight && windowPos < eventsPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#aboutUsMenu").css("background-color","#bbbbbb");
           $(".pagelink#aboutUsMenu div p").css("color","black");
       }
       else if (windowPos >= eventsPos - halfHeight && windowPos < galleryPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#eventsMenu").css("background-color","#bbbbbb");
           $(".pagelink#eventsMenu div p").css("color","black");
       }
       else if (windowPos >= galleryPos - halfHeight && windowPos < ourTeamPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#galleryMenu").css("background-color","#bbbbbb");
           $(".pagelink#galleryMenu div p").css("color","black");
       }
       else if (windowPos >= ourTeamPos - halfHeight && windowPos < sponsorsPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#ourTeamMenu").css("background-color","#bbbbbb");
           $(".pagelink#ourTeamMenu div p").css("color","black");
       }
       else if (windowPos >= sponsorsPos - halfHeight && windowPos < reachUsPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#sponsorsMenu").css("background-color","#bbbbbb");
           $(".pagelink#sponsorsMenu div p").css("color","black");
       }
       else if (windowPos >= reachUsPos - halfHeight) {
           $(".pagelink").css("background-color","transparent");
           $(".pagelink").children().children().css("color","#bbbbbb");
           $(".pagelink#reachUsMenu").css("background-color","#bbbbbb");
           $(".pagelink#reachUsMenu div p").css("color","black");
       }
   });
   //events page
   

});