    $(document).ready(function() {

    if( navigator.userAgent.match(/Android/i) ||
            navigator.userAgent.match(/webOS/i) ||
            navigator.userAgent.match(/iPhone/i) ||
            navigator.userAgent.match(/iPod/i) ||
            navigator.userAgent.match(/BlackBerry/i) ||
            navigator.userAgent.match(/SAMSUNG/i) ||
            navigator.userAgent.match(/SGH/i) ||
            navigator.userAgent.match(/SCH-/i) ||
            navigator.userAgent.match(/SEC-/i) ||
            navigator.userAgent.match(/nokia/i) ||
            navigator.userAgent.match(/HPiPAQ910/i) ||
            navigator.userAgent.match(/Motorola/i) ||
            navigator.userAgent.match(/MOT/i) ||
            navigator.userAgent.match(/Moto/i) ||
            navigator.userAgent.match(/LG/i) ||
            navigator.userAgent.match(/LGE/i) ||
            navigator.userAgent.match(/Palm/i) ||
            navigator.userAgent.match(/Treo/i) ||
            navigator.userAgent.match(/Windows CE/i) ||
            navigator.userAgent.match(/Ericsson/i) ||
            navigator.userAgent.match(/Smartphone/i) ||
            navigator.userAgent.match(/MobilePhone/i) ||
            navigator.userAgent.match(/Blazer/i) ||
            navigator.userAgent.match(/Silk/i) ){

       location.href = "mobile.html";

      }else{
          var first_click = true;
          var scroll_offset = -60;

          var stickyPanelOptions = {
               topPadding: 0,
               savePanelSpace: true
          };
      }

    var stickyPanelOptions_ie8 = {
                topPadding: -20,
                savePanelSpace: false
    };

    $("#nav").stickyPanel(stickyPanelOptions);

    $("#nav #home_nav a").click(function(item){
         $(".stickypanel_wrapper div:first-child").remove();
         $(".stickypanel").css("position", "relative")
         $(".stickypanel").css("left", "10px")
    });

    function toggleNav(item){

        $("#nav li").each(function(){
            if($(this).attr("id") != item){
                 $(this).attr("class", '');
            }else{
                 $(this).attr("class", 'current');
            }

            if(item == "home_nav"){
              console.log(item);

           //     $("#nav").stickyPanel(stickyPanelOptions_home);
            }

        });

    }

    $('.home').waypoint(function(event, direction) {
        toggleNav('home_nav');
    }, {
        offset: 100
    });

    $('.experience').waypoint(function(event, direction) {
        toggleNav('experience_nav');
    }, {
        offset: 150
    });

    $('.skills').waypoint(function(event, direction) {
        toggleNav('skills_nav');
    }, {
        offset: 150
    });

    $('.contact').waypoint(function(event, direction) {
        toggleNav('contact_nav');
    }, {
        offset: 200
    });

    $('#nav a').smoothScroll({
        speed: 800,
        offset: -100,
        beforeScroll: function() {
            this.stop();
        }
    });

    function toggle_scroller2(){
     // console.log(item);
        $(".scroller li").each(function(){
              $(this).attr("class", '');
        });

     }

     function toggle_scroller(item){
       console.log(item);
        $(".scroller li").each(function(){

            if(".scroller li:eq(" + item + ")"){
                console.log(item);
                 $(this).attr("class", 'current');
            }else{
                 $(this).attr("class", 'current');
            }

        });
     }

     function toggle_content(){
        $(".part_wrapper > li").each(function(){
          console.log($(this).index());
            if($(this).index() != item){
                 $(this).attr("class", '');
            }else{
                 $(this).attr("class", 'current');
            }
        });
     }



    $(".scroller_toc a").click(function(item){

        var index = $(".scroller_toc a").index(this);

        $(".scroller_toc li").each(function(){
              $(this).attr("class", '');
        });

        $('.scroller_toc li').eq(index).attr("class", "current");

        $(".experience_list > li").each(function(){
              $(this).attr("class", '');
        });

        $('.experience_list > li').eq(index).attr("class", "current");

    });

   /*
   $.scrollingParallax('images/star_field3.jpg',
   {
     bgWidth : '75%',
     bgHeight : '100%'
    }

   );
   */

});
