jQuery(document).ready(function($) {
$('[title]').removeAttr('title');
if($('.cycle').length > 0){
    $('.cycle').cycle({
	    fx: 'fade', 
	    timeout:  10000,
	    pager:  '#feature_nav'
        //before:  onBefore, 
        //after:   onAfter 
    });
}
$('#whats_new a.gold').bigTarget({
	clickZone: 'div:eq(1)'
});
$('#leaders').hrzAccordion({
    handlePosition: "left",
    openOnLoad: 1
    
});
  
$('.bio-more').click(function(){
	t = $(this);
	bio = t.prev('.bio');
	defaultHeight = 80;
	bioHeight = 0;
	bio.children().each(function(){
		bioHeight += $(this).outerHeight(true);
	});
	if(t.hasClass('open')){
		t.removeClass('open');
		t.animate({
			opacity:0
		}, 250, function(){
			t.html('Read More');
			t.animate({
				opacity:1
			}, 500);
		});
		bio.animate({
			height: defaultHeight
		}, 750);
	} else {
		t.addClass('open');
		t.animate({
			opacity:0
		}, 250, function(){
			t.html('Show Less');
			t.animate({
				opacity:1
			}, 500);
		});
		bio.animate({
			height: bioHeight
		}, 750);
	}

});

$('.mobile-home-button').click(function(e){
	e.preventDefault();
	t = $(this);
	panel = t.attr('href');
	panel = $(panel);
	$(panel).css('left', 0);

/*	panel.animate({
		left: 0
	}, 1000, 'easeOutQuart');
	*/
	panel.css('visibility', 'visible');
	panel.addClass('on-top').addClass('open').fadeTo(400, 1);
});
$('.mobile-back').click(function(e){
	e.preventDefault();
	t = $(this);
	panel = t.parent('.mobile-panel');
	panel.animate({
		left:'-400px'
	}, 350, 'easeOutQuart', function(){
//	    $(this).removeClass('on-top').removeClass('open');
		$(this).css('visibility', 'hidden');
	}).fadeTo('fast', 0, function(){
		  $(this).removeClass('on-top').removeClass('open');
	});
/*	panel.removeClass('open').fadeTo(1200, 0, function(){
		$(this).removeClass('on-top');
	}); */
});

  
if($('#contact-form').length > 0){
    $('#contact-form').validate();
}
$('.customcontactform div:even').addClass('clear');
if($('.customcontactform').length > 0){
    $('.customcontactform').validate();
/*	$('.customcontactform').ajaxForm({
		success: function(){
			$('.customcontactform').fadeTo(500, 0, function(){
				$('.customcontactform').html('<p>Thank you for your submission! We will be in touch soon.</p>').fadeTo(1000, 1);
		 });
	 }
	});
*/
}
$('#phone').click(function(){
    t = $(this)
    if(t.hasClass('open')){
        t.removeClass('open');
        t = t.add('#top_contact_wrap');
        t.animate({
            top: '-=25'
        }, 600);
    } else {
        t.addClass('open');
        t = t.add('#top_contact_wrap');
        t.animate({
            top: '+=25'
        }, 600);
    }
    return false;
});
$('a.comment-reply-link').attr('href', '#comments_cont');
    
    $('a.comment-reply-link').click(function () {
    		
    		var id = $(this).closest("div.comment").attr("id");
    		
    		id = id.replace('comment-', "");
    		
    		$('#comment_parent').val(id);
    		
    		//var id = 
    		
    		var title = $(this).closest('div').parent('div').children('.commenter').html();
    		
    		//alert(title);
    		
    		$('.comments_cont h3').html('Reply to: '+ title);
    		
    		//alert(id);
    		$('#author').focus();
    	return false;		
    });
                           
$('ul.page-numbers li').slice(1, -2).after("<span> | </span>");
//$("#content_area_tabs").hide();
//$(".tab_button").click(function () {
//      $("#content_area_tabs").slideToggle(1000);
//    });
//    
//    
   var clearMePrevious = '';
//   
   // clear input on focus
   $('.clearMeFocus').focus(function(){
     if($(this).val()==$(this).attr('data-val')){
         clearMePrevious = $(this).val();
         $(this).val('');
     }
   });
//   
   // if field is empty afterward, add text again
   $('.clearMeFocus').blur(function(){
    if($(this).val()==''){
        $(this).val(clearMePrevious);
     }
   });
var defaultHeight = $('#quote-wrap').height();
$('#quote-more').click(function(){
	
	var newHeight = $('#quote-wrap p').outerHeight() + $('#quote-wrap .author').outerHeight();

	if($(this).hasClass('open')){
		$(this).removeClass('open').html('View More');
		$('#quote-wrap').animate({'height':defaultHeight}, 'slow');
	} else {
		$(this).addClass('open').html('View Less');	
		$('#quote-wrap').animate({'height':newHeight}, 'slow');
	}
	return false;
});

});

