(function(){
  // if firefox 3.5+, hide content till load (or 3 seconds) to prevent FOUT
  var d = document, e = d.documentElement, s = d.createElement('style');
  if (e.style.MozTransform === ''){ // gecko 1.9.1 inference
    s.textContent = 'body{visibility:hidden}';
    e.firstChild.appendChild(s);
    function f(){ s.parentNode && s.parentNode.removeChild(s); }
    addEventListener('load',f,false);
    setTimeout(f,3000); 
  }
})();

Cufon.replace('#main-nav, #main-content h1, #subnav h2, #main-content h2, #main-content h3, .page-title, .services h3,', {hover: true,  fontFamily: 'FuturaBold'}); // Works without a selector engine
Cufon.replace('.feed h2, #main-content h4, #main-content h5, .intro, #content blockquote, #sidebar ul li, .related h2, #contact h2 span strong, .learn-more', {hover: true,  fontFamily: 'Eau'});

$(document).ready(function(){
	$('.bio').truncate({ max_length: 170, more: ' Read More &#187 ', less: ' Collapse ' });
	$('#main-nav li').hover(function(){	
		$(this).addClass('hover');
	}, function() {
		$(this).removeClass('hover');
	});
	$('#slideshow .container').cycle({pager:'#slide-nav', pause: 1, timeout: 6000}); 
	$('#services-slider .container').cycle({ timeout: 0, pager: '#services-nav',
			pagerAnchorBuilder: function(idx, slide) { return '<a href="#" class="slide-' + idx + '">' + idx + '</a>';}
	}); 
	$('#contact .expand').click(function() {
 		 $('#contact-form').slideToggle('slow');
 		 $('#contact h2 span strong').toggle('slow'); 		 
 		 $('#contact h2 span em.fill').fadeToggle();
 		 return false;
	});
	$(".message #mce-MESSAGE").counter({ goal: 500 });
	$('#careers').click(function() {
		$('.interest-area').fadeOut().delay(250);
		$('.careers-input-group').fadeIn();
		$('#mc-embedded-subscribe-form').attr('action', 'http://solutionsbyapex.us2.list-manage1.com/subscribe/post?u=d78587fd558c7dc0daa404172&id=038264306c');
	});
	$('#services').click(function() {
		$('.interest-area').fadeOut().delay(250);
		$('.services-input-group').fadeIn();
		$('#mc-embedded-subscribe-form').attr('action', 'http://solutionsbyapex.us2.list-manage.com/subscribe/post?u=d78587fd558c7dc0daa404172&id=6439abfb94');
	});
	$(".sitemap li.page-item-688 a").attr({ rel: 'prettyPhoto', title: '' }).attr('href', function() {
 	 return this + '?iframe=true&width=90%&height=90%'
	});
	$(".sitemap li.page-item-685 a").attr({ rel: 'prettyPhoto', title: '' }).attr('href', function() {
 	 return this + '?iframe=true&width=90%&height=90%'
	});  
	$("a[rel^='prettyPhoto']").prettyPhoto({
			show_title: false
	});
});


