﻿
$(document).ready(function($) {
    $('.btn').mouseover(function() {
        $(this).addClass('hover');
    });
    $('.btn').mouseout(function() {
        $(this).removeClass('hover');
    });

    loadHeaderNav();
    manageCareers();
    manageBios();



    /*$('#moreServices .flyOut').hide();
    $('#moreServices .button').click(function() {
        $('#moreServices .flyOut').toggle('slow');
        $(this).text($(this).text() == 'Less Services' ? 'More Services' : 'Less Services');
        $(this).toggleClass('collapse');
        return false;
    });*/


    target = getUrlVars()['target'];
    if (target)
        $.scrollTo('#' + target, 1000, { offset: -65 });

});

// Scroll Navigation
    function loadHeaderNav() {

        $('#nav ol li a,ul li.scrollTop a, a.scrollLink').click(function() {//$.scrollTo scrolls the whole screen
            $.scrollTo(this.hash, 1000, { offset: -65 });
            $(this.hash).find('span.message').text(this.title);
            return false;
        });

        $('ul li.scrollUp a').click(function() {
            currentScrollUp = $(this).parent().parent().parent().index('div.scrollControl')
            if (currentScrollUp > 0) {
                position = currentScrollUp - 1;
                $.scrollTo('li.scrollUp:eq(' + position + ')', 1000, { offset: -10 });
            }
            else {
                $.scrollTo('#top', 1000, { offset: -10 });
            }

            return false;
        });

        $('ul li.scrollDown a').click(function() {
            currentScrollUp = $(this).parent().parent().parent().index('div.scrollControl')

            position = currentScrollUp + 1;
            $.scrollTo('li.scrollUp:eq(' + position + ')', 1000, { offset: -10 });

            return false;
        });
    }
    
//Manage Bios
    function manageBios() {

        $('#bioList div').hide();

        $('#bioList a.link').click(function() {
            /*--Highlight clicked career in side nav--*/
            $('#bioList div').hide();
            $('#bioList li a.link').removeClass('active');
            $(this).addClass('active');

            $(this).siblings('div').show();
            /*--Hide stuff--*/
            return (false);
        });

    }
	


// Manage Careers
    function manageCareers() {

        hideElements();

        $('#positionDetails div:first').show();

        $('#availPositions li a').click(function() {
            /*--Highlight clicked career in side nav--*/
            $('#availPositions li a').removeClass('active');
            $(this).addClass('active');

            /*--Hide stuff--*/
            hideElements();

            /*--Show selected career details--*/
            clickIndex = $('#availPositions li a').index(this);
            $('#positionDetails div.position:eq(' + clickIndex + ')').show();
            $('#positionDetails div.position .linkMore').show();

            return (false);
        });

        $('.position .linkMore').click(function() {
            /*--Show entire position details--*/
            $('.showMore, #rmBrief').show();
            $(this).hide();
            $('.linkApply').show();
            return (false);
        });
    }

function hideElements() {
    $('#positionDetails div, #rmBrief, .linkApply, #careerForm').hide();
}

function getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}






