// remap jQuery to $

	var leadership = {
		'j-scott-schanen': {
			'id' : "j-scott-schanen",
			'name' : "J. Scott Schanen",
			'title' : "Founder and Chief Executive Officer",
			'bio' : "<p>Scott brings strong leadership and proven success to Dominium. With over 20 years of industry experience, he is committed to securing the firm's position as a premiere consultancy by creating value for Dominium's clients, innovating, and practicing principled entrepreneurship. Before leading Dominium, Scott founded Schanen Consulting, an Atlanta-based consultancy that advised Fortune 1000 companies on health and welfare programs. He has served on a number of boards as both an advisor and a director. Scott is a graduate of the University of Texas.</p>"
		},
		'michael-villa': {
			'id' : "michael-villa",
			'name' : "Michael Villa",
			'title' : "Co-Founder and Chief Operating Officer",
			'bio' : "<p>Michael is dedicated to making sure Dominium's clients receive excellent service in every interaction. He has 20 years of experience in health care and financial services, including senior executive leadership, and brings with him an appreciation of the challenges our clients face in managing their workforce. Prior to Dominium's creation, Michael served as COO at MedQuest, Inc., one of the largest operators of outpatient diagnostic facilities in the US with sales in excess of $300 million and a workforce of 2,000. He earned his degree in economics from the University of Washington.</p>"
		},
		'jim-mills': {
			'id' : "jim-mills",
			'name' : "Jim Mills",
			'title' : "Managing Partner",
			'bio' : "<p>Jim brings an exceptional passion for people, personal achievement, and thought development to Dominium, where he develops executive benefit solutions and oversees the high-performance account management teams that support the firm's clients.  Before joining Dominium, Jim was principal of the Mills Group, a privately held firm that provided health and welfare consulting services to large national employers. The Mills Group merged with an international benefits consulting firm in the late 1990's where Jim served as the Disability Income Practice Leader for the Executive Benefits division.  Jim also served as Managing Director for a national executive compensation and benefits firm.   He currently serves as a board member for several nonprofit organizations.</p>"
		},
		'mark-watson': {
			'id' : "mark-watson",
			'name' : "Mark Watson",
			'title' : "Principal",
			'bio' : "<p>Mark uses his 26 years of experience to develop new business and provide ongoing client support. He excels at performing financial benefit program analyses, stop loss analysis and strategic planning. Beginning with understanding his clients' needs and goals, Mark has a hand in everything from design development to employee communications. His background in both the employer and carrier side of the industry as well as his work with large and small businesses contributes to the unique perspective he brings to clients. Mark holds a Bachelor of Business Administration in finance from the University of Georgia.</p>"
		},
		'linda-schulte': {
			'id' : "linda-schulte",
			'name' : "Linda Schulte",
			'title' : "Director of Health and Productivity",
			'bio' : "<p>Linda is dedicated to helping clients improve performance by making their employees healthier and more productive. She has focused intensively on strategy and design throughout her 25 years in the health care industry, resulting in significant cost savings and customer health improvements. Prior to Dominium, she led the National Segment Sales and Sales Effectiveness operations at CIGNA. There, she developed and executed strategies, supported the sales teams, and carried the voice of the marketplace to the company. In addition, her team organized a national health and productivity forum. Linda was also Definity Health's senior vice president and spent 18 years with Aetna Health Plans as national marketing director and national sales vice president, among other roles.</p>"
		},
		'caryn-cook': {
			'id' : "caryn-cook",
			'name' : "Caryn Cook",
			'title' : "Benefits Consultant",
			'bio' : "<p>Caryn brings exceptional energy and passion to her work and draws from her knowledge in both the carrier and consulting fields. A decade of experience in the health care industry enables her to strategically design employee benefit plans, and her loyal customer base appreciates her focus on cost containment. Her experience and Six Sigma training also help her implement and manage employer benefit plans for public and private corporations. Before coming to Dominium, she served as a senior sales executive for SunLife Financial and GE Capital/Genworth Financial. Caryn holds a Bachelor of Business Administration in Risk Management from the University of Georgia. She also holds a Certificate in Business and Economics from Oxford University.</p>"
		},
		'stephen-boyd': {
			'id' : "stephen-boyd",
			'name' : "Stephen Boyd",
			'title' : "Managing Director, HR Practice",
			'bio' : "<p>During his 20-year career in human resources, Stephen has worked in technology development, sales and marketing, finance, and mergers and acquisitions. He's created strong channel partnerships and put global workforce alternatives and corporate and business development plans into action. His experience with HRIS vendors includes Abra, ADP, Lawson, Ceridian, Peoplesoft, UltiPro, Oracle, and SAP. Stephen is a recognized expert in HR systems having been named on numerous occasions as both a top sales partner and leading provider for several of the aforementioned software companies. Stephen received his Bachelor of Business Administration from Vanderbilt University. He serves on the boards of several charitable and community organizations.</p>"
		},
		'susan-harris': {
			'id' : "susan-harris",
			'name' : "Susan Harris",
			'title' : "Benefits Consultant",
			'bio' : "<p>Susan is responsible for ongoing client development and support in all areas of group medical, dental, short and long term disability, life, accidental death and dismemberment, and voluntary benefits. With over 13 years of industry experience, Susan provides support to clients in plan marketing and review, employee communication and enrollment, claims advocacy, employee benefit plan contract review and compliance, and health and productivity strategy. She also offers guidance in benefit strategies and funding decisions. Susan's active in the Atlanta community and holds a Bachelor of Arts from Furman University.</p>"
		},
		'ted-schweers': {
			'id' : "ted-schweers",
			'name' : "Ted Schweers",
			'title' : "Benefits Consultant",
			'bio' : "<p>Ted has over 25 years of experience in the insurance industry. He works with his clients to develop strategies that help control the cost of their benefits programs. His approach includes creative plan design, funding analysis, and ongoing plan performance reviews. Ted works with a team of experienced account managers to attend to all client support services needs including implementation, enrollment and communication strategy, employee claim management, human resources consulting, benchmarking, and carrier contract review and compliance. Ted is an Atlanta native, and he received his Bachelor of Business Administration from the University of Alabama.</p>"
		},
		'cory-hurley': {
			'id' : 'cory-hurley',
			'name' : "Cory Hurley",
			'title' : "Pharmacy Practice Consultant",
			'bio' : "<p>Cory is dedicated to improving the performance of pharmacy benefit programs.  Under his leadership Dominium has developed a pharmacy benefit practice with an impressive track record of delivering successful and innovative solutions for our clients.  His experience includes evaluation, vendor procurement, contracting, strategy and design, implementation assistance, and ongoing vendor management. His passion is creating a pathway to our clients' success. Cory works directly with Dominium's high-performance account management teams to incorporate our proprietary pharmacy strategy into our clients' strategies. He attended Baylor University on a golf scholarship and received a Bachelor of Arts degree.</p>"
		}/*, 
		'jason-dagley': { 
			'id' : 'jason-dagley', 
			'name' : "Jason Dagley", 
			'title' : "Director of Retirement Plan Consulting", 
			'bio' : "<p>Jason has spent over thirteen years assisting employers to build successful retirement plans that offer employees the opportunity to achieve long term financial success, while giving the Plan Sponsor a valuable employee recruitment and retention tool. Jason has a diverse financial services background working with Defined Benefit, Defined Contribution, 401(k), 403(b), 401(a), 457 and non-qualified retirement plans with groups from all types of industries, backgrounds, and sizes. Jason works closely with his clients to find out what their needs are and looks at all possible avenues to ensure a successful retirement for all employees.</p><p>Jason takes a holistic approach in assisting his clients with their retirement plan(s) by looking at the goals of the plan sponsor, the retirement plan design, the quality of the investments, legislative issues, employee demographics, fiduciary protection and costs. By looking at all aspects of the retirement plan, Jason is able to help the plan sponsor to have a successful retirement plan. Jason holds a BS in Marketing from the University of Tennessee and an MBA in Finance from NYIT. Jason is a registered Principal who currently holds his FINRA Series 6, 7, 24, 26, 63, and 65 licenses along with his life, health and variable licenses.</p>" 
		}*/
	};

//uses modernizr.js
function browserSupports(feature){
	
	if( $('html').hasClass(feature) ){
		return true;
	} 
	return false;
}

function rotate90(rotatable, theTime){
	var time = theTime || 225;
	var dfd = $.Deferred();
	
	if ($.isArray(rotatable)){
		var length = rotatable.length;
		
		$.each(rotatable, function(i, item){

			setTimeout(function(){
				item.addClass('rotate');
				
				if( browserSupports('csstransitions')){
					item.bind('webkitTransitionEnd OTransitionEnd transitionend', function(){
						
						if(i === length -1){ 
							
							dfd.resolve();
						}
					});
					
				}else{
					item.hide().fadeIn(400);
				}

			}, (i + 1) * time); 

		});
	
	} else{
		rotatable.addClass('rotate');
		
		if( browserSupports('csstransitions')){
			
			rotatable.bind('webkitTransitionEnd OTransitionEnd transitionend', function(){
				dfd.resolve();
			});
			
		}else{
			rotatable.hide().fadeIn(600);
		}

	}
	return dfd.promise();
}

function rotate180(rotatable, theTime){
	var time = theTime || 225;
	var dfd = $.Deferred();
		
	if( browserSupports('csstransforms3d') &&  browserSupports('cssanimations')){
				
		rotatable.addClass('rotate');
		
		rotatable.bind('webkitAnimationEnd OanimationEnd animationEnd', function(){
				
			dfd.resolve();
		
		});
		
	}else if( browserSupports('csstransitions') && browserSupports('csstransitions') ){
				
		rotatable.addClass('skewForward');

		rotatable.bind('transitionend', function(){
			rotatable.removeClass('skewForward');
			rotatable.addClass('skewBackward');
			
			rotatable.bind('transitionend', function(){
				dfd.resolve();
			})
		
		});


		
	}else{
		rotatable.addClass('rotate')
		rotatable.hide().fadeIn(200, function(){
			setTimeout(function(){
				rotatable.fadeOut(400, function(){
					rotatable.removeClass('rotate')
					rotatable.show()
					dfd.resolve();
				});
			}, 3000);
		});
	}

	return dfd.promise();
}



function animateLeft(selector){

	var dfd = $.Deferred();
	elm = $(selector);
	elm.addClass('active');
	
	if( browserSupports('cssanimations') && browserSupports('csstransitions')){

		elm.bind('webkitAnimationEnd OAnimationEnd animationend ', function(){
			dfd.resolve();
		});
		
	}else{
	
		elm.animate({"left": "1em"}, 500 , 'easeOutExpo' , function() {
			elm.animate({"left": "8em"}, 2000 , 'linear' , function() {
				elm.animate({"left": "75em"}, 200 , 'easeInCirc', function() {
					dfd.resolve();
				});
			});
		});
	}
	return dfd.promise();
}

function showPrivacy(){
	if( !browserSupports('csstransitions')){
		$('#privacy').animate({"top": "1.75em"}, 500 , 'linear');
	}
	
	$('#privacy').addClass('active');
}
function hidePrivacy(){
	if( !browserSupports('csstransitions')){
		$('#privacy').animate({"top": "75em"}, 800 , 'linear');
	}
	
	$('#privacy').removeClass('active');
}

function goTo(thePage){
	var page = thePage || "difference";
	var right = $('#right-'+ page);
	var left = $('#left-'+ page);
	
	if ($('#privacy').hasClass('active')){ 
		hidePrivacy(); 
	}
	
	$('.rotate').removeClass('rotate');
	$('#navigation li.active').removeClass('active');
	$('.left.active').removeClass('active');
	$('#wrapper').removeClass();
	
	$('#wrapper').addClass(page);
	
	if( right.hasClass('panable') ){
		var panes = [];
	
		$.each(right.find('.pane'), function(i, pane){
			panes.push( $(pane) );
		});

		rotate90(panes);

	} else if( right.hasClass('rotatable') ){
		rotate90(right);
	}

	left.addClass('active');
	
	$('#link-'+ page).addClass('active');

}

function runIntro() { 
	
	$('#wrapper').addClass('intro difference');
	
	setTimeout(function(){

		rotate180($('#intro-1')).then(function(){			
			rotate180($('#intro-2')).then(function(){		
				rotate180($('#intro-3')).then(function(){		
			
					$('#intro').fadeOut(200, function(){
					
						$('#wrapper').removeClass('intro');
						
						// catch nav link clicked during intro
						if( !window.location.hash ){
							goTo('difference');
						}
			
					});	
				});
			});
		});
		
	}, 200);

}

function handleHashChange(){
	var hash = window.location.hash;
	hash = hash.replace(/^#/, '');
	
	if(hash){
		
		switch (hash) {
			case 'difference':
				goTo('difference');
				break;
			case 'services':
			   goTo('services');
			   break;
			case 'results':
			   goTo('results');
			   break;
			case 'leadership':
			   goTo('leadership');
			   break;
			default: 
				goTo('difference');
		}

	}else{
	
		runIntro();

	}

}

function populateLeadership(){

	var list = $('#leadership-list');
	
	$.each(leadership, function(i, person){
		var elm = $('<div class="person" id="'+ person.id +'"></div>');
		elm.append('<a rel="' + person.id + '"><h3>' + person.name + '</h3><small>' + person.title + '</small></a>');
		list.append(elm);
	});
	
	setActiveLeader('j-scott-schanen');
}

function setActiveLeader(name){
	
	var person = leadership[name];
	var bio = $('#bio');
	var jsp = $('#bio').data('jsp');
	
	//clear the contents of the scroll pane
	jsp.getContentPane().hide().html('');
	
	//set the contents of the scroll pane
	jsp.getContentPane().append( person.bio ).fadeIn(100);
	
	jsp.reinitialise();
	
	jsp.scrollToY(0, 100);
	
	$('#leadership-list').find('.active').removeClass('active');
	$('#leadership-list #' + person.id ).addClass('active');

}

// after everthing is loaded
$(window).load(function() {

	$('body').removeClass('loading');
	$('#wrapper').show();

	//add scrollbars
	$('.scrollable-content').jScrollPane({verticalGutter : -16, showArrows: true });
	
	populateLeadership();

	//handle direct links
	handleHashChange()
	
	/*events
	---------------------------------------------*/

	$('#leadership-list a').click(function(){
		setActiveLeader($(this).attr('rel'));
	});
	
	$('.right.panable .pane').hover(function(){
		$(this).toggleClass('active');
	});
	
	$('.highlight').hover(function(){
		$(this).toggleClass('active');
	});
	
	$('#privacy-link a').click(function(){
		showPrivacy();
	});
	
	$('#privacy-close').click(function(){
		hidePrivacy();
	});
	
	$(window).hashchange(function() { 
		handleHashChange()
	});
		
});
