
var Site = {
  submitVacancyInterval:600,
  submitVacancyAnimate:1,

  load: function()
  {
    if($("ul#jobsOfTheWeekTicker"))
    {
      $("ul#jobsOfTheWeekTicker").liScroll({travelocity: 0.03}); 
    }
    
    this.observeLoginBar();
    this.observeMenu();
    this.panels();
    this.signObserve();
    this.animateSignLink();
    this.rememberMe();
    this.infoPops();
    
    //this.flyin();
  },
  
  
  observeLoginBar: function()
  {
    var userLoginInput = $('form#UserLoginBar div.input.username input');
  
    userLoginInput.bind("focus", function(e){
      if(userLoginInput[0].value == 'Username')
      {
        userLoginInput[0].value = '';
      }
    });
  },
  
  
  observeMenu: function()
  {
    $('#menu li').bind("mouseenter mouseleave", function(e){
      $(this).toggleClass("over");
    });
  },
  
  
  flyinToggle: function()
  {
    $('#first').fadeOut();
    $('#second').fadeIn();
  },
  
  
  panels: function()
  {
    $(".panel").each(function(c,el){
      var link = $('a', this).get(0);
      
      $(this).bind("mouseenter mouseleave click", function(e){
        if(e.type == 'click')
        {
          document.location.href = link;
        }
        else
        {
          $(this).toggleClass("over");
        }
      });
    });
  },
  
  
  signObserve: function()
  {
    if(!$("#signLink") || this.submitVacancyAnimate == 0) { return; }
    var self = this;
  
    $("#signLink").bind("mouseenter mouseleave", function(e){
      if(e.type == 'mouseenter')
      {
        self.submitVacancyAnimate = 0;
      }
      else
      {
        self.submitVacancyAnimate = 1;
      }
    });
  },
  
  
  animateSignLink: function()
  {
    if(!$("#signLink")) { return; }
    
    if(this.submitVacancyAnimate == 1)
      $('#signLink').toggleClass("on");
      
    setTimeout("Site.animateSignLink()",this.submitVacancyInterval);
  },
  
  
  rememberMe: function()
  {
    if(!$('#UserRemember')[0]) { return; }
  
    var checkbox = $('#UserRemember')[0];
  
    if(checkbox.checked)
    {
      $('#rememberMe').addClass("on");
    }
  
    $('#rememberMe').bind("click", function(e){
      e.preventDefault();
      
      if(checkbox.checked)
      {
        $('#rememberMe').removeClass("on");
        checkbox.checked = false;
      }
      else
      {
        $('#rememberMe').addClass("on");
        checkbox.checked = true;
      }
    });
  },
  
  
  flyin: function()
  {
    if(!$("#flyinImg")) { return; }
  
    var offset = $("#flyinImg").offset();
    
    $("#flyinImg").attr('style','left:-250px; top:500px')
  
    $("#flyinImg").animate({ 
      left:-42,
      top:120
    },5000);
  },
  
  
  infoPops: function()
  {
    $('.infoPopLnk').bind("mouseover mouseout", function(e){
      var rel = $(this).attr('rel');
      var position = $(this).position();
      
      var top = position.top - 65;
      var left = (position.left + $(this).width());
      
      if(e.type == 'mouseover')
      {
        $('#infoPop'+rel).css('top',top);
        $('#infoPop'+rel).css('left',left);
        $('#infoPop'+rel).show();
      }
      else
      {
        $('#infoPop'+rel).hide();
      }
      
    });
  }

}



$(document).ready(function() {
  Site.load();
});

