﻿var currentSection;
var currentSubSection;
var currentSubSubSection;
var textColor; //set in the html file
var headlineWidth;
var bodyWidth;
var currentButtonOver;
var $whatYouGetContent_p;
var currentBtn;
var currentPara;
var $contentContainer;
var $contentBody;
var $contentHeadline;
var $navSecondary;
var $navSecondary2;
var $navBackgroundSecondary;
var $navBackgroundSecondary2;
var $navThird;
var $navBackgroundThird;
var $whatYouGetButtons;
$(function() {
  	currentSubSection = -1;
  	currentSubSubSection = -1;
  	$whatYouGetContent_p = $('#whatYouGetContent').find('p');
  	$whatYouGetButtons = $('#whatYouGetList .whatYouGetButton');
  	$contentContainer = $('#contentContainer');
  	$contentHeadline = $('.contentHeadline');
  	$contentBody = $('.contentBody');
  	$navSecondary = $('.navSecondary');
  	$navSecondary2 = $('.navSecondary2');
  	$navBackgroundSecondary = $('.navBackgroundSecondary');
  	$navBackgroundSecondary2 = $('.navBackgroundSecondary2');
  	$navThird = $('.navThird');
  	$navBackgroundThird = $('.navBackgroundThird');
	begin();
 });
function begin() {
	var sectionManager 	= new SectionManager();
	var navManager 		= new NavManager();
	var bgManager 		= new BGManager();
	$contentContainer.css({color:textColor});
	$contentHeadline.css({width:headlineWidth});
	$contentBody.css({width:bodyWidth});
	individuals();
}
var firstApproach = true;
function hoverApproach(e)
{
	if (firstApproach == true && e.data.btn == '2') {
		$('#approachButton1').css({color:'#8c8d82'});
		$('#approachColumn1').css({display:'none'});
	}
	if (firstApproach == true && e.data.btn == '1') {
		return;
	}
	firstApproach = false;
	var t = e.data.targ;
	$(this).css({color:'#fec14b'});
	t.css({display:'inline', opacity:0});
	t.stop().animate({opacity:1}, 300);
	$('#plusSign').find('img').css('margin-top', '-72px');
}
function outApproach(e)
{
	firstApproach = false;
	var t = e.data.targ;
	$(this).css({color:'#8c8d82'});
	$('#plusSign').find('img').css('margin-top', '0px');
	//t.animate({opacity:0}, 40, function() {
		t.css({display:'none'});
	//});
}
function individuals()
{
	//$('#approachColumn1').css({display:'none', opacity:0});
	$('#approachColumn2').css({display:'none', opacity:0});
	$('#approachButton1').bind('mouseenter', {targ:$('#approachColumn1'), btn:'1'}, hoverApproach);
	$('#approachButton1').bind('mouseleave', {targ:$('#approachColumn1')}, outApproach);
	$('#approachButton2').bind('mouseenter', {targ:$('#approachColumn2'), btn:'2'}, hoverApproach);
	$('#approachButton2').bind('mouseleave', {targ:$('#approachColumn2')}, outApproach);
	
	$('#approachButton1').css({color:'#fec14b'});
	$('#plusSign').find('img').css('margin-top', '-72px');
//	$('#approachButton1').css({display:'inline', opacity:1});
			
	var j = 0;
	$('#whatYouGetList .whatYouGetButton').each(function() {
		$(this).bind("mouseenter", {buttonID:j}, overWhatYouGetButton);
		if (j === 0) {
			currentButtonOver = 0;
			currentBtn = $whatYouGetButtons[0];
			currentPara = $whatYouGetContent_p[0];
			$(currentBtn).css({color:'#FFC222'});
			$(currentPara).css({visibility:'visible'});
		}
		j += 1;
	})
	checkSecNav();
	checkThirdNav();
	
	$('#open-positions-titles').find('span').bind('click', function(e) {
		var num = $(this).index();
		
		$('#open-positions-titles span').removeClass('selected');
		$(this).addClass('selected');
		
		var arr = $('#open-positions-descriptions').find('p');
		arr.css('display', 'none');
		
		$(arr[num]).css('display', 'inline-block');
	});
}
function checkSecNav() 
{	
	var arr = getUrlVars();	
	if ($navSecondary.length > 0 && arr['a'] == 'true') {
		$navSecondary.css({opacity:0});
		$navBackgroundSecondary.css({opacity:0});
		$navSecondary.delay(200).animate({opacity:1}, 500);
		$navBackgroundSecondary.delay(200).animate({opacity:0.8}, 500);
		
		
		$navSecondary2.css({opacity:0});
		$navBackgroundSecondary2.css({opacity:0});
		$navSecondary2.delay(200).animate({opacity:1}, 500);
		$navBackgroundSecondary2.delay(200).animate({opacity:0.8}, 500);
	}
}
function checkThirdNav() 
{	
	var arr = getUrlVars();	
	if ($navThird.length > 0 && arr['b'] == 'true') {
		$navThird.css({opacity:0});
		$navBackgroundThird.css({opacity:0});
		$navThird.delay(200).animate({opacity:1}, 500);
		$navBackgroundThird.delay(200).animate({opacity:0.8}, 500);
	}
}
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;
}
function overWhatYouGetButton(e)
{	
	$(currentBtn).css({color:textColor});
	$(currentPara).css({visibility:'hidden'});	
	currentButtonOver = Number(e.data.buttonID);
	currentBtn = $whatYouGetButtons[currentButtonOver];
	currentPara = $whatYouGetContent_p[currentButtonOver];
	$(currentBtn).css({color:'#FFC222'});
	$(currentPara).css({visibility:'visible'});
}
