//case studies helper functions

function celebrating(){
	$('#emotionally_connect').slideDown('slow', function() {});
	$('#emotionally_connect_header').slideUp('slow', function() {});									
	$('#emotionally_connect_content').slideUp('slow', function() {});	
	$('#branded_space_content').animate({width: '0'}, function() {});
	$('#celebrating_legacy_content').animate({height: 'show'});
	$('#go_viral_content').slideUp('slow', function() {});
	$('.grate').slideUp('slow', function() {});
}

function driving(){
	$('#groundbreaking_products').slideDown('slow', function() {});	
	$('#groundbreaking_products_content').slideUp('slow', function() {});	
	$('#groundbreaking_products_header').slideUp('slow', function() {});	
	$('#driving_innovation_content').animate({width:'600px'}, function() {}); 
	$('#evolving_with_customers_content').slideUp('slow', function() {});
	$('.grate').slideUp('slow', function() {});
}

function evolving(){
	$('#groundbreaking_products').slideDown('slow', function() {});	
	$('#groundbreaking_products_content').slideUp('slow', function() {});	
	$('#groundbreaking_products_header').slideUp('slow', function() {});	
	$('#driving_innovation_content').animate({width: '0'}, function() {});
	$('#evolving_with_customers_content').slideDown('slow', function() {});
	$('.grate').slideUp('slow', function() {});
}

function improving(){
	$('#breaking_bottlenecks').slideDown('slow', function() {});	
	$('#breaking_bottlenecks_header').slideUp('slow', function() {});							   
	$('#breaking_bottlenecks_content').animate({width: '0'}, function() {});									 
	$('#improving_performance_content').animate({width: '600'}, function() {});	
	$('.grate').slideUp('slow', function() {});
}

function closeall(){
	$('#emotionally_connect').slideDown('slow', function() {});	
	$('#emotionally_connect_header').slideUp('slow', function() {});	
	$('#emotionally_connect_content').slideUp('slow', function() {});									 
	$('#branded_space_content').animate({width: '0'}, function() {});
	$('#celebrating_legacy_content').slideUp('slow', function() {});
	$('#go_viral_content').slideUp('slow', function() {});	
	
	$('#groundbreaking_products').slideDown('slow', function() {});	
	$('#groundbreaking_products_content').slideUp('slow', function() {});	
	$('#groundbreaking_products_header').slideUp('slow', function() {});			
	$('#driving_innovation_content').animate({width: '0'}, function() {});
	$('#evolving_with_customers_content').slideUp('slow', function() {});
	
	$('#breaking_bottlenecks').slideDown('slow', function() {});	
	$('#breaking_bottlenecks_header').slideUp('slow', function() {});	
	$('#breaking_bottlenecks_content').animate({width: '0'}, function() {});									 
	$('#improving_performance_content').animate({width: '0'}, function() {});
	
	$('.address').slideUp('slow', function() {});
	$('.grate').slideDown('slow', function() {});
	
	$('#careers_content').slideUp('slow', function() {});
}

$.fn.clearOnFocus = function(){
 
    return this.focus(function(){
        var v = $(this).val();
        $(this).val( v === this.defaultValue ? '' : v );
    }).blur(function(){
        var v = $(this).val();
        $(this).val( v.match(/^\s+$|^$/) ? this.defaultValue : v );
    });
 
};


$(document).ready(function() {

	$('input').clearOnFocus();

//hashtag parsing
	if(self.document.location.hash.substring(1) == "celebrating"){
		celebrating();
	}
	if(self.document.location.hash.substring(1) == "driving"){
		driving();
	}
	if(self.document.location.hash.substring(1) == "evolving"){
		evolving();
	}
	if(self.document.location.hash.substring(1) == "improving"){
		improving();
	}



//address
	$('.address_label').click(function(){
		closeall();
		if(!$(this).siblings('.address').is(':visible')){
   			$(this).siblings('.address').slideToggle('slow');
		}
	});


//case studies code

	$('#case_sl').click(function(){
   		$('#case_sl_d').toggle();

	});

//slidout switching code for 3 main content pages
	$('#emotionally_connect').click(function(){
		closeall();
		if(!$('#emotionally_connect_content').is(':visible')){
			$('#emotionally_connect').slideUp('slow', function() {});	
			$('#emotionally_connect_header').slideDown('slow', function() {});	
			$('#emotionally_connect_content').slideDown('slow', function() {});
		}
  	});
	$('#branded_space').click(function(){
		closeall();
		if($('#branded_space_content').width() == 0){
			$('#branded_space_content').animate({width: '458'}, function() {});		
		}
  	});
	$('#celebrating_legacy').click(function(){
		closeall();
		if(!$('#celebrating_legacy_content').is(':visible')){
			$('.grate').slideUp('slow', function() {});
			$('#celebrating_legacy_content').animate({height: 'show'});
		}
  	});
	$('#go_viral').click(function(){
		closeall();
		if(!$('#go_viral_content').is(':visible')){
			$('#go_viral_content').slideDown('slow', function() {});	
		}
  	});
	
//-------------------------------------
	
	$('#groundbreaking_products').click(function(){	
		closeall();
		if(!$('#groundbreaking_products_content').is(':visible')){	
			$('#groundbreaking_products').slideUp('slow', function() {});	
			$('#groundbreaking_products_content').slideDown('slow', function() {});		
			$('#groundbreaking_products_header').slideDown('slow', function() {});
		}
  	});
	$('#driving_innovation').click(function(){
		closeall();
		if($('#driving_innovation_content').width() == 0){
			$('.grate').slideUp('slow', function() {});
			$('#driving_innovation_content').animate({width:'600px'}, function() {});
		}
  	});
	$('#evolving_with_customers').click(function(){
		closeall();
		if(!$('#evolving_with_customers_content').is(':visible')){
			$('.grate').slideUp('slow', function() {});
			$('#evolving_with_customers_content').slideDown('slow', function() {});
		}
  	});
	
//-----------------------------------------

	$('#breaking_bottlenecks').click(function(){
		closeall();
			
		if($('#breaking_bottlenecks_content').width() == 0){
			$('#breaking_bottlenecks').slideUp('slow', function() {});	
			$('#breaking_bottlenecks_content').animate({width: '500'}, function() {});	
			$('#breaking_bottlenecks_header').slideDown('slow', function() {});	
		}
  	});
	$('#improving_performance').click(function(){
		closeall();
		if($('#improving_performance_content').width() == 0){
			$('#improving_performance_content').animate({width: '600'}, function() {});
			$('.grate').slideUp('slow', function() {});		
		}
  	});
	
//-----------------------------------------

	$('#careers').click(function(){
		closeall();
											   
		if(!$('#careers_content').is(':visible')){
			$('#careers_content').slideDown('slow', function() {});
		}
  	});
	
});


