$(document).ready(function() {
        
    // Autoclearing inputs
    $("input.autoClear").focus(function() {
        if( this.value == this.defaultValue ) {
            this.value = "";
        }
    }).blur(function() {
        if( !this.value.length ) {
            this.value = this.defaultValue;
        }
    });

    // Testimonies Box (Homepage Only)
    $('#testimonies .cycle').cycle({ 
        fx: 'fade', 
        prev: '#pager .prev', 
        next: '#pager .next',
        timeout: 0 });
		
	$('.tabbedItems').cycle({ 
        fx: 'fade',
		pager: '.tabbedNavigation',
		after: function (){
			soundManager.stopAll()
		},
		pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '.tabbedNavigation li:eq(' + idx + ') a'; 
    } ,
        timeout: 0 });
    
    // "Tabbed" sections for About pages
//    $('.tabbedNavigation a').click(function() {
//        if (!$(this).hasClass('current')) {
//            $('.tabbedNavigation a.current').removeClass('current');
//            $(this).addClass('current');
//            var itemId = $(this).attr('rel');
//            $('.tabbedItems li:visible').fade('fast',function() {
//                $('.tabbedItems #' + itemId).slideDown('fast'); 
//            });
//        }
//    });
    
    // Modal dialogs for Testimonials
    // (Unfortunately we need to copy some text first so it doesn't disappear when we load the modal)
    $('#testimonies div.hidden cite').each(function() {
        $(this).clone().appendTo($(this).prev());
    });
    $('#testimonies a.btn-more').each(function() {
        $(this).attr('href','#testimony'+$(this).attr('rel')+' .fullText');
    }).nyroModal().click(function() { $('#testimonies .cycle').cycle('pause'); });
			$('.nyroModal').nyroModal({
		minWidth: 600
			});
});
