Cufon.replace('body.home h1, .callout h2, h1.summary, .lead-in h1, .feature h2, .post h1, .post h2, .side h3, .article-listing h2, p.line-1, p.line-2, p.line-3, p.line-4, #masthead .description', { hover: true, fontFamily: 'Serif 6 Beta' });

DD_belatedPNG.fix('#masthead .features-nav, #masthead .features-callout, img.icon,#masthead .features .lip, body.landing #masthead .feature .label, a.icon');


jQuery.noConflict();  

jQuery(document).ready(function() {
								  
	// Open External Links in a New Window
	jQuery('a[rel*=external]').click(function() {
		window.open(this.href);
		return false;
	});

	// Launch the Begin Your Journey Assessment
	jQuery('a[rel*=begin]').click(function() {
		jQuery.fn.ceebox.popup("<embed type='application/x-shockwave-flash' id='begin' name='begin' src='/wp-content/themes/pauldyer/begin/begin.swf' width='900' height='600' flashvars='xmlPath=/wp-content/themes/pauldyer/begin/begin.xml' allowscriptaccess='always' allowfullscreen='true'></embed>", { type: 'video', width: 900, height: 600 });
		jQuery('#cee_overlay').click(function() {
			jQuery.fn.ceebox.closebox();
			return false;
		});
		return false;
	});
	
	// Launch the Welcome Video
	jQuery('a[rel*=welcome]').click(function() {
		var vid = this.rel;
		jQuery.fn.ceebox.popup('<embed id="single1" type="application/x-shockwave-flash" width="520" height="318" src="http://tapdyer.s3.amazonaws.com/player-licensed.swf"flashvars="file=' + jQuery( this ).attr( 'href' ) + '&amp;autostart=true" allowscriptaccess="always" allowfullscreen="true" name="single1"></embed>', { type: 'video', width: 520, height: 318 });
		jQuery('#cee_overlay').click(function() {
			jQuery.fn.ceebox.closebox();
			return false;
		});
		return false;

	});
	
	
	jQuery( '#faq-jump' ).click( function() {  
	
		var container = jQuery( '#faq' );
		
		var button = container.find( 'a.collapse-button' );
		
		if ( container.length && !container.hasClass( 'open' ) ) {
			
			button.click();	
			
		}
	
	});
	
	
	jQuery( 'div.collapse' ).each( function() {
				
		var container = jQuery( this );
		
		var button = container.find( 'a.collapse-button' );
		
		var content = container.find( 'div.collapse-content' );
		
		container.append( '<p class="more"><a class="collapse-close" href="#">Close</a></p>' );
		
		var closeButton = container.find( 'a.collapse-close' );
		
		button.click( function() {
			
			if ( container.hasClass( 'open' ) ) 
				{
				
				closeButton.fadeOut();
				
				content.slideUp();
				
				}
			
			else 
				{
					
				content.slideDown();
			
				closeButton.fadeIn();
				
				}
			
			
			container.toggleClass( 'open' );
			
			return false;
			
		});
		
		closeButton.click( function() {
			
			content.slideUp();
			
			closeButton.fadeOut();
			
			container.toggleClass( 'open' );
			
			return false;
			
		});
		
	});
	
	
	
	
	// Home Page Slider
	
	if ( jQuery( 'ul.features-nav' ).length )
		{
	
		var selectedFeature = 0;
		
		var totalFeatures = jQuery( 'ul.features-nav li' ).length;
		
		var duration = 600;
		
		var wait = 6000;
		
		
		jQuery( 'div.features a' ).css( 'display', 'none' );
		
		
		jQuery( 'ul.features-nav li' ).click( function( ev ) {
			
			selectFeature( parseInt( jQuery( this ).attr( 'class' ).replace( ' last', '' ).replace( 'feature-', '' ) ) );
			
			clearInterval( featureInterval );
			
			ev.preventDefault();
			
		});
		
		
		function selectFeature( featureIndex )
			{
			
			if ( featureIndex == selectedFeature ) return;
			
			if ( featureIndex == 0 ) featureIndex = selectedFeature + 1;
			
			featureIndex = featureIndex < 1 ? selectedFeature + 1 : featureIndex > totalFeatures ? 1 : featureIndex;
			
			if ( selectedFeature )
				{
				
				jQuery( 'div.features a.feature-' + selectedFeature ).fadeOut( duration );
				
				jQuery( 'ul.features-nav li.feature-' + selectedFeature + ' a' ).removeClass( 'selected' );
					
				}
				
			jQuery( 'div.features a.feature-' + featureIndex ).fadeIn( duration );
			
			jQuery( 'ul.features-nav li.feature-' + featureIndex + ' a' ).addClass( 'selected' );
			
			selectedFeature = featureIndex;
				
			}

	
		selectFeature( Math.floor( Math.random() * totalFeatures ) + 1 );
	
		var featureInterval = setInterval( function() { selectFeature( 0 ) }, wait );

		}
	
	
	
	
	// Matching Columns
	
	if ( jQuery( '.callout' ).length )
		{
			
		var maxHeight = 0;
		
		jQuery( '.callout  a.article-link' ).each( function() 
			{  
			
			maxHeight = jQuery( this ).outerHeight();
		
			});
			
		jQuery( '.callout a.article-link' ).css( 'height', maxHeight + 20 );
			
		}
		
		
	// DROP DOWN MENU
	
	var timeout = 500;
	
	var closetimer = 0;
	
	var ddmenuitem = 0;
	
	var ddmenulink = 0;
	
	
	function jsddm_open()
		{
		
		jsddm_canceltimer();
		
		jsddm_close();
		
		ddmenuitem = jQuery( this ).find( 'div.dropdown' ).css( 'visibility', 'visible' );
		
		if ( ddmenuitem.length ) ddmenulink = jQuery( this ).find( ' > a' ).addClass( 'dropped' );

		}
	
	
	function jsddm_close()
		{  
		
		if( ddmenuitem.length ) 
			{
				
			ddmenuitem.css( 'visibility', 'hidden' );
		
			ddmenulink.removeClass( 'dropped' );			
			
			}
				
		}
		
	
	function jsddm_timer()
		{  
		
		closetimer = window.setTimeout( jsddm_close, timeout );
		
		}
		
	
	function jsddm_canceltimer()
		{
		
		if( closetimer )
	   		{
			
			window.clearTimeout( closetimer );
		  	
			closetimer = null;
			
			}
		
		}
	
	
	jQuery( document ).ready( function()
		{
		
		jQuery( '#mainnav > ul > li' ).bind( 'mouseover', jsddm_open )
		
		jQuery( '#mainnav > ul > li' ).bind( 'mouseout',  jsddm_timer )
		
		}
	);
	
	
	document.onclick = jsddm_close;
	
	
});