$(document).ready(function() {
$('.contact-us-side label').labelOver('over-apply');
  $('.logo img').click(function() {
    $('.tab_content').hide();
    $('#widget-nav a.selected').removeClass('selected');
    $('#start').show();
  });
  $('.subpages .logo img').click(function() {
    window.location = '/';
  }); 
  $(function() {
    theRotator();
  });
  $(function() {$('.login').toggle(
    function(){ 
    $('.myAquentSection label').labelOver('over-apply');
    $('.myAquentSection').show('slow');
    //prevent click
             event.preventDefault();
    },
    function(){ 
    $('.myAquentSection').hide('slow');
    }
    );
  });
  $(function() {
    $('.custom-select').find('li.option:not(.selected)').hide();
    $('.custom-select').find('.selected').css({'background-color':'transparent', 'border':'none'});
    $('.custom-select').hover(
    function() {
      $(this).find('li').show().css({'border-bottom':'1px solid #ccc','border-left':'1px solid #ccc', 'border-right':'1px solid #ccc', 'background-color':'#fff', 'margin-left':'-1px', 'z-index':'999'});
      $(this).find('li:first').css({'border':'none','border-bottom':'1px solid #ccc','background-color':'transparent', 'margin-left':'0'});
    },
    function() {
    $(this).find('li.option:not(.selected)').hide();
      $(this).find('.selected').css({'background-color':'transparent', 'border':'none'});
    }
    );
    //check for selecting a new option
    $('.custom-select li.option').live('click', function(event) {
              //prevent click
             //event.preventDefault();
              //first traverse up to the parent container of that list.
              //then find all the lis of that list
               $(this).parents('ul').find('li').each(
                    function(){
                    //this is now each LI in the list
                    $(this).removeClass('selected');
                    });
    //last cause of order            
              $(this).addClass('selected');
    //slide up the selected option
    $('li.option:not(.selected)').hide();
            });
  });
  

  function agentContent() {
   var hashname = $(location).attr('hash');   
    if (hashname == "#contactMeAnchor") {      
      $('.agent-copy').hide(); //Hide all content
      $('#agent-nav li:last').addClass('selected').show(); //Activate first tab
      $('.agent-copy:last').show(); //Show first tab content
      $('#agent-content').removeClass('hide-onload');
      $('#agent-nav').removeClass('hide-onload');
    }
    else {
      //When page loads...
      $('.agent-copy').hide(); //Hide all content
      $('#agent-nav li:first').addClass('selected').show(); //Activate first tab
      $('.agent-copy:first').show(); //Show first tab content
      $('#agent-content').removeClass('hide-onload');
      $('#agent-nav').removeClass('hide-onload');
    }


  //On Click Event
    $('#agent-nav li').click(function() {

    $('#agent-nav li').removeClass('selected'); //Remove any 'active' class
    $(this).addClass('selected'); //Add 'active' class to selected tab
    $('.agent-copy').hide(); //Hide all tab content

    var activeTab = $(this).find('a:first').attr('href'); //Find the href attribute value to identify the active tab + content
    $(activeTab).show(); //Fade in the active ID content
    return false;
  });
  }

  //$(function() {
    //$('.custom-select').find('li.option:not(.selected)').hide();
    //$('.custom-select').hover(
    //function() {
    //$(this).find('li').show();
    //},
    //function() {
    //$(this).find('li.option:not(.selected)').hide();
    //}
    //);
    //check for selecting a new option
    //$('.custom-select li.option').live('click', function(event) {
              //prevent click
             //event.preventDefault();
              //first traverse up to the parent container of that list.
              //then find all the lis of that list
               //$(this).parents('ul').find('li').each(
                    //function(){
                    //this is now each LI in the list
                    //$(this).removeClass('selected');
                    //});
    //last cause of order            
              //$(this).addClass('selected');
    //slide up the selected option
    //$('li.option:not(.selected)').hide();
            //});
  //});



  function tabs() {

  //When page loads...
  $('.tab_content').show();
  $('.tab_content').hide(); //Hide all content
  $('#widget-nav li:first a').addClass('selected').show(); //Activate first tab
  $('.tab_content:first').show(); //Show first tab content

  //On Click Event
    $('#widget-nav li a').click(function() {

    $('#widget-nav li a').removeClass('selected'); //Remove any 'active' class
    $(this).addClass('selected'); //Add 'active' class to selected tab
    $('.tab_content').hide(); //Hide all tab content

    var activeTab = $(this).attr('href'); //Find the href attribute value to identify the active tab + content
    $(activeTab).show(); //Fade in the active ID content
    return false;
  });
  }
  $(function() {
  if ( $('#widget-body').is(':hidden') ) {    
    tabs();    
    $('#widget-nav li a').click(function(){
    $('#widget-body').show('slow');
    //prevent click
    event.preventDefault();
    });
  }
  else {
    tabs();
  }
  });
  $(function(){
  $('.close').click(function(){
    $('#widget-body').hide('slow');
    $('#widget-nav a.selected').removeClass('selected');
  });
  });
  $(function(){
  $('#ticker-box ul').show();
  if ($('#ticker li').length > 1){
      $('#ticker').list_ticker({
                speed:5000,
                effect:'fade'
        });
  };
   });
  $(function(){ 
    if ($('.agents').length){ 
      agentContent();
      $( '#jobs32' ).accordion({ active: false, autoHeight: false, header: '.faux-h3', collapsible: true, navigation: true});
      if(location.hash != "") {
      var id = window.location.hash
      $("#jobs32").accordion("activate", id);
      } else {
      agentContent();
      $( '#jobs32' ).accordion({ active: false, autoHeight: false, header: '.faux-h3', collapsible: true, navigation: true});
      };
    };
  });
  $(function() {  
    if($('#find-talent').length){
    $('.hide-onload').show();
    };
  });
  $(function(){
    $('select:not(.formalize)').customStyle();
  });
 });
