/**
 * The JavaScript for general site interaction
 */

// Default value, minified (for use with forms)
$.fn.setDefaultValue=function(b){var b=$.extend({d_css:"default_value",f_css:"filled_value"},b);return this.each(function(){var f=$(this);var h=f.attr("title");$(this).attr("autocomplete","off");if(f.val().length<=0||f.val()==h){f.addClass(b.d_css);f.val(h);f.removeClass(b.f_css)}f.click(a);f.blur(g);f.focus(a).blur();function a(){if(f.hasClass(b.d_css)||f.val()==h){f.val("");f.removeClass(b.d_css);f.addClass(b.f_css)}}function g(){if(f.val().length<=0){f.addClass(b.d_css);f.val(h);f.removeClass(b.f_css)}else{if(f.val()!=h){f.addClass(b.f_css)}}}$(window).unload(a)})};

$(document).ready( function( ) {
	/**
	 * Set up the qTip for the address
	 --------------------------------------------------------------*/
	// The qTip item
	var map = $( '#shf_address' );
	
	if ( map.html() != null )
	{
		// Set up the map content
		var map_content = '<div class="embed_map" style="width: 425px; height: 350px;"<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=24607+N.+E.+Colbern+Road+Lees+Summit,+Missouri+64086&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=51.443116,81.826172&amp;ie=UTF8&amp;hq=&amp;hnear=24607+NE+Colbern+Rd,+Missouri+64086&amp;t=h&amp;z=14&amp;iwloc=lyrftr:h,1575010889707611553,38.944407,-94.299495&amp;ll=38.944481,-94.299483&amp;output=embed"></iframe><a class="map-view-large" href="http://maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&amp;geocode=&amp;q=24607+N.+E.+Colbern+Road+Lees+Summit,+Missouri+64086&amp;aq=&amp;sll=37.0625,-95.677068&amp;sspn=51.443116,81.826172&amp;ie=UTF8&amp;hq=&amp;hnear=24607+NE+Colbern+Rd,+Missouri+64086&amp;t=h&amp;z=14&amp;iwloc=lyrftr:h,1575010889707611553,38.944407,-94.299495&amp;ll=38.944481,-94.299483">View Larger Map</a></div>'
	
		// Call the qTip
		var address_tooltip = map.qtip({
			content: map_content,
			show: { delay: 350 },
			hide: { fixed: true, delay: 600 },
			position: {
			      corner: {
			         target: 'topMiddle',
			         tooltip: 'bottomMiddle'
			      }
			},
			style: { 
				tip: 'bottomMiddle',
				width: 445,
				padding: 5,
				border: { color: '#9c9c69', radius: 5 },
				name: 'light'
			}
		});
		
		// Hightlight the address when map is focused
		var api = $( address_tooltip ).qtip( "api" );
		api.onShow = function( ) { map.addClass( 'border-focus' ); };
		api.onHide = function( ) { map.removeClass( 'border-focus' ); };
	}
	
	/**
	 * Set up the qTip for the links
	 --------------------------------------------------------------*/
	// Call the qTip
	$(".top-nav li a").qtip({
		show: { delay: 0 },
		position: {
		      corner: {
		         target: 'topMiddle',
		         tooltip: 'bottomMiddle'
		      }
		},
		style: { 
			tip: 'bottomMiddle',
			width: 200,
			padding: 5,
			border: { color: '#9c9c69', radius: 5 },
			textAlign: 'center',
			name: 'light'
		}
	});
	
	/**
	 * Set up the cycle image slideshow
	 --------------------------------------------------------------*/
	// Since javascript is working, change the default img.slideshow
	// style of 'hidden' to 'block'
	$( '.slideshow img' ).css( 'display', 'block' );
	
	// Call the slideshow
	$( '.slideshow' ).cycle({
		fx: 'fade',
		timeout: 6000
	});
	
	/**
	 * Utilize facebox for any anchor tags with rel=facebox
	 --------------------------------------------------------------*/
	// Set up facebox
	$.facebox.settings.closeImage = 'http://www.stonehausfarms.com/js/facebox/closelabel.png';
    $.facebox.settings.loadingImage = 'http://www.stonehausfarms.com/js/facebox/loading.gif';

	// Attach facebox
	$( 'a[rel*=facebox]' ).facebox( );
	
	/**
	 * Custom "View Larger Map" script
	 --------------------------------------------------------------*/
	$('.embed_map').hover( function( ) {
		$(this).find('.map-view-large').animate( { bottom: 0 }, 200 );
	}, function( ) {
		$(this).find('.map-view-large').animate( { bottom: -35 }, 150 );
	});
})
