jQuery(document).ready(function($){
	
	$('html').removeClass('no-js');
	
	// REMOVE TILE TAG
	$('.wp-post-image').attr('title','');
	
	// OFFERS SLIDER
	// var t   = $( '.small_carousel' );
	//   	var m   = $( 'li', t ).length;
	//   	var w   = $( 'li:first', t ).outerWidth();
	//   	var i   = 0;
	// 
	//   setInterval( function() {
	// 	if ( i >= m ) {
	// 		i   = 0;
	//   }
	// 	
	// 	$( 'ul', t ).animate({
	//   	'margin-left'   : i * w * -1 + 'px'
	//   }, 1000 );
	// 
	//   i++;
	//   }, 3000 );
	
	// CAREERS SLIDER
	$('.careers-trigger').click( function(){
		
		// recalculate $('#careers-container') height based on .careers-info now showing
		
		$('.careers-trigger').css({'background' : '#FFF', 'width' : '190px'});
		$('#careers .careers-info').hide();
		$(this).css({'background' : '#F1F2F3', 'width' : '191px' }).next().show();
		$('#careers-container').height($(this).next().outerHeight());
	});
	
	
	
	$('.careers-trigger:last').css({
		'background' : '#F1F2F3',
		'width' : '191px'			
	}).click();
	
	

	
	// VERTICALLY CENTER LOGOS
	$('#client-images .client-hover span img').each( function()
	{
		if ( $( this ).outerHeight() > 0 )
		{
			verticallyAlign( this );
		}
		else
		{
			$( this ).load( function()
			{
				verticallyAlign( this );
			})
		}
	});
	
	// ACCORDION
	$('.accordion h3').css({'cursor' : 'pointer'}).next().hide();
	$('.accordion h3:first').addClass('open').next().show();
	$('.accordion h3').click( function(){
		$(this).toggleClass('open').next().slideToggle();
	});
	
	$( 'a' ).each( function()
	{
		if ( $( this ).hasEventListener( 'click' ).length == 0 )
		{
			if ( $( this ).attr( 'href' ).indexOf( 'http' ) == 0 && $( this ).attr( 'href' ).indexOf( document.domain ) == -1 )
			{
				$( this ).click( function()
				{
					if ( $( this ).hasClass( 'newwindow' ) )
					{
						window.open( $( this ).attr( 'href' ), 'newwindow', 'width=700,height=500' );
					}
					else
					{
						window.open( $( this ).attr( 'href' ), '_blank' );
					}
					
					return false;
				});
			}
		}
	});
	
});

function verticallyAlign(t)
{
	t	= $( t );
	
	t.css({
		'position' : 'absolute',
		'top' : ( t.parent().outerHeight() - t.outerHeight() ) / 2,
		'left' : ( t.parent().outerWidth() - t.outerWidth() ) / 2
	});
}
