// JavaScript Document


jQuery(document).ready(function(){
	
	
	jQuery('.colorbox').colorbox();
	
								
	// POPULATE CONTACT FORM WITH DYNAMIC SUBJECT FOR EXPEDITION POST TYPE
	// ... this way we can use one form for every post type, then populate subject on page load.
	
	//alert('jq loaded');
	
	var expeditionText = '';
	jQuery('.special-img-text').children('div').not(':last').each(function(){
	
		expeditionText += jQuery(this).text() + ' ';
	
	});
	
	jQuery('input.hidden').val(expeditionText);
	
	jQuery('#expedition-nav a[href=#]').click(function(e){

	e.preventDefault();
	
			var thisId = jQuery(this).attr('id').substr(5);
			jQuery.scrollTo('#scroll-'+thisId, 800, {offset:-30});
			
	});
	
	
	
	// color coded rows for single trip details table
	jQuery('table.details tr:odd').addClass('odd');
	jQuery('table.details tr:even').addClass('even');
	
	
	
	
		
	// adjust image summary box for larger than normal summaries
	if(jQuery('.image-summary').height() > 150){	
		jQuery('.image-summary').animate({top: '15'}, 1);
	
	}
	
	//adjust the button color on dynamic upcoming trip form, according to accent color
	jQuery('input.wpcf7-submit').css('background-color', (jQuery('#contact-form h4').css('background-color')));
								
								
	
	// hide / show behavior for upcoming trips
	jQuery('.trips .trip').hover(function(){
															
		jQuery(this).children('.img').children('.hide').stop().fadeOut();	
		jQuery(this).children('.img').children('.click-details').show();
		jQuery(this).children('h2').children('a').css('text-decoration', 'underline');
		
															
											}, function(){
																															
		jQuery(this).children('.img').children('.hide').stop().fadeIn();															
		jQuery(this).children('.img').children('.click-details').hide();
		jQuery(this).children('h2').children('a').css('text-decoration', 'none');

															});
	
	
	
	
	
	
jQuery(document).keyup(function(e){

	var code = returnKeyPress(e);
	
	if(jQuery('img#TB_Image').size() > 0){
		if(code == 37){
			jQuery('#TB_prev a').click();
		}
		if(code == 39){
			jQuery('#TB_next a').click();
		}
	}
	
	if(jQuery('#cboxWrapper').size() > 0){
		if(code == 37){
			jQuery('#cboxPrevious').click();
		}
		if(code == 39){
			jQuery('#cboxNext').click();
		}
	}
	

});
								
								});






function returnKeyPress(e){
    
		var code = (e.keyCode ? e.keyCode : e.which);
        return code;
}

