
$(document).ready(function() {

$('a').focus(function() {
  this.blur();
});

$('ul.navbar').accordion({
      header: "span.hd",
      fillSpace: false,
      autoHeight: false,
      event: "click",
      active: false,
      selectedClass: 'tmpContentSelected',
      navigation: true,
      navigationFilter: function(){
      	return(
	      decodeURIComponent(this.href).toLowerCase() ==
  	    decodeURIComponent(location.href.toLowerCase())
        );
        }
}); // jquery.ui.accordion()

// highlight any links referring to current page:
var thisPage = document.URL.match(/[^/]*$/);
$('a[href$=' + thisPage + ']').css('color', 'red');

animateTime = 250;
var thisDiv; // global values required for showHide() to test for existence
var lastDiv;

// the infoPopup is positioned "fixed" which works vertically but needs this JQ hack to keep it positioned horizontally. 
// following script must not be used on index page
if( $('body').attr('id') != 'index' ){
	$('#infoPopup').css('left', $('#imageTop').offset().left);
}; // on load
$(window).resize(function(){															 // (on resize)
	$('body[id!=index] #infoPopup').css('left', $('#imageTop').offset().left);
});

function showHide(){
$(this).parents().find('.more').show();
thisDiv = $(this).attr('href');
if($('#background div#infoPopup:visible') != false){
		if(thisDiv == lastDiv){                   // clicked on same link twice; close
      thisDiv = 'closed';
    	$('#infoPopup').fadeOut(animateTime);
    } else {                                  // clicked on new link; close old and open new
			$('#infoPopup').fadeOut(animateTime);
      thisDiv = $(this).attr('href');
      var forPopup = $(thisDiv).html();
			setTimeout(function(){$('#infoPopupBox').html($(thisDiv).html())}, (animateTime + 50));
			setTimeout(function(){$('#infoPopup').fadeIn(animateTime)}, (animateTime + 100));
			$(this).parent().find('.more').hide();
    } // if/else end; if different 
 } // 1st if()
 else {                                  // popup not open, open new popup
			setTimeout(function(){$('#infoPopupBox').html(($($(this).attr('href')).html()))}, (1 + 1));
			setTimeout(function(){$('#infoPopup').fadeIn(animateTime)}, (1 + 10));
		$(this).parent().find('.more').hide();
 }
lastDiv = thisDiv;
return false;
} // showHide

$('#select a').click(showHide);

$('#inputform #message').blur(function(){
	if ($('#email').val() == ''){
  	alert('Just a reminder:\n  It\'s not necessary, but if you don\'t leave an email address, we can\'t reply to your message.');
    }
});

// following is for index. php
var FadeInOutTime = 1000;
var animateTime = 375;

function captionUpFeature(){
      	$(this).find('.target').animate({height : '100%'}, animateTime).end()
//        .find('img[src$=stardingbat.png].more').hide().end()
        .find('img.more').hide().end()
//        .find('.more').hide().end()
        .find('.reveal').animate({opacity : '1'}, animateTime)
        .end();
			}

function captionDownFeature(){
      	$(this).find('.target').animate({height : '85px'}, animateTime)
        .end()
        .find('img[src$=stardingbat.png].more').show()
        .end()
        .find('.reveal').animate({opacity : '0'}, animateTime)
        .end();
			}

function captionUpBottom(){
      	$(this).find('.target').animate({height : '22.5%'}, animateTime)
        .end()
        .find('img.more').hide()
        .end()
        .find('.reveal').animate({opacity : '1'}, animateTime)
        .end();
			}

function captionDownBottom(){
      	$(this).find('.target').animate({height : '28px'}, animateTime)
        .end()
        .find('img.more').show()
        .end()
        .find('.reveal').animate({opacity : '0'}, animateTime)
        .end();
			}

var hiHomeFeature = {   // settings for hoverintent    
    sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
    interval: 50, // number = milliseconds for onMouseOver polling interval    
    over: captionUpFeature, // function = onMouseOver callback (REQUIRED)    
    timeout: 250, // number = milliseconds delay before onMouseOut    
    out: captionDownFeature // function = onMouseOut callback (REQUIRED)
};

var hiHomeBottom = {   // settings for hoverintent    
    sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
    interval: 50, // number = milliseconds for onMouseOver polling interval    
    over: captionUpBottom, // function = onMouseOver callback (REQUIRED)    
    timeout: 250, // number = milliseconds delay before onMouseOut    
    out: captionDownBottom // function = onMouseOut callback (REQUIRED)
};

$('#feature > .featured').hoverIntent( hiHomeFeature );
$('#homeBottom').hoverIntent( hiHomeBottom );

}); // end doc ready()
