$(document).ready(function() {
    $("body").addClass("hasjs");
	showHideSearchLabels();
	Cufon.now();
	$("#most_popular_posts-4 ul li:nth-child(1)").addClass("mpp1");
	$("#most_popular_posts-4 ul li:nth-child(2)").addClass("mpp2");
	$("#most_popular_posts-4 ul li:nth-child(3)").addClass("mpp3");
	$("#most_popular_posts-4 ul li:nth-child(4)").addClass("mpp4");
	$("#most_popular_posts-4 ul li:nth-child(5)").addClass("mpp5");
	$(".home .home-box:even").addClass("clearBox");
	var randHomeImage;
	$('.single').addClass('blog');
	$('.archive').addClass('blog');
	$('#the-teaser') 
	.cycle({ 
		fx:     'fade',
		speed:  500,
		timeout: 7000,
		prev:    '#prev_teaser', 
		next:    '#next_teaser',
		pause: 1 
	});
	$('#client-slides #slides-wrapper') 
	.cycle({ 
		fx:     'fade',
		speed:  500,
		timeout: 3000,
		pause: 1 
	});
	$('#pause-button').click(function() {
		if ($('#pause-button').is('.not-paused')) {
			$('#the-teaser').cycle('pause');
			$('#pause-button').addClass("paused");
			$('#pause-button').removeClass("not-paused");
			return false;
		 } else {
			$('#the-teaser').cycle('resume');
			$('#pause-button').addClass("not-paused");
			$('#pause-button').removeClass("paused");
			return false;
		}
	});
	/* Hide show Toggle */
	$('div#accordion:eq(0)> div').hide();  
	  $('div#accordion:eq(0)> h2').click(function() {
	    $(this).next().slideToggle('fast');
		if($(this).hasClass("ui-state-active")) {
			$(this).removeClass("ui-state-active");
		}
		else {
			$(this).addClass("ui-state-active");
		}
	  });
	$('div#accordion:eq(0)> h2').mouseover(function() {
		$(this).addClass("onHover");
	});
	$('div#accordion:eq(0)> h2').mouseout(function() {
		$(this).removeClass("onHover");
	});
	$("div#accordion").find("div").eq(0).show();
	$("div#accordion").find("h2").eq(0).addClass("ui-state-active");
	$('div#accordion div:eq(0)> div').hide();  
	  $('a.showMore').click(function() {
	    $("div.commentary").slideToggle('fast');
		return false;
	  });
	$("#contactForm").validate();
	$("#styleguideForm").validate();
});

// Search input content show/hide events 
function showHideSearchLabels() {
	$("form input#home-search").focus(function(){
	     if ( $(this).val() == "Search")
	    $(this).val('');
	 });
	 $("form input#home-search").blur(function(){
	     if ( $(this).val() == "")
	     $(this).val('Search');
	 });
	$("form input#search").focus(function(){
	     if ( $(this).val() == "Search")
	    $(this).val('');
	 });
	 $("form input#search").blur(function(){
	     if ( $(this).val() == "")
	     $(this).val('Search');
	 });
	$("form input#search").val('Search');
}

Cufon.replace('#masthead h3, .blockHeading h1, .aside-resources-content h2', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });
Cufon.replace('#footer .footerTagline, .home .home-box blockquote, .home .home-box cite', { fontFamily: 'ITC Avant Garde Gothic Std Extra Light' });
Cufon.replace('.home-masthead h2', { fontFamily: 'ITC Avant Garde Gothic Std Extra Light' });
Cufon.replace('.home-masthead p.strap', { fontFamily: 'ITC Avant Garde Gothic Std Demi' });
Cufon.replace('.home h1', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });
Cufon.replace('.home-box h3, .home-box h2, .home-box a, .aside-box-link', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });
Cufon.replace('.home input.wa-submit', { fontFamily: 'ITC Avant Garde Gothic Std Bold' });
