/*
 * boedesign global js
 * http://boedesign.com/
 *
 * Date: 2009-10-18
 */
var BD = {
	
	/**************************
	* Elements/Options
	*/
	e_search: '#search',
	o_search_default_val: 'Search',
	
	/**************************
	* Functions
	*/
	 
	// Setup public default functionality
	init: function(){
		
		// Call a few private methods
		this._searchFormBlurFocus();
		
	},
	
	// Cufonify what you need!
	cufonReplacements: function(){
		
		Cufon.replace('#topnav a', { 
			fontFamily: 'Helvetica Neue',
			color: '-linear-gradient(#fff, #eee)',
			textShadow: '1px 1px #222',
			hover: {
				color: '-linear-gradient(#fff, #aaa)'
			}
		});
		
		Cufon.replace('.main-heading, .post h3', { 
			fontFamily: 'Helvetica Neue'
		});
		
		Cufon.replace('#intro', { 
			fontFamily: 'Lacuna Regular',
			textShadow: '1px 1px #111'
		});
		
	},
	
	// Run the jsquares plugin for the 
	setupLabGrid: function(container){
		
		$(container).jsquares({
			js_image: 'li', // target (div) holding info
			js_caption: '.small-caption', // target caption
			js_caption_overlay_spacing: 4, // caption overlay padding/spacing... sort of
			js_caption_width: 350, // caption overlay width
			js_caption_height:98, // caption overlay height
			js_shuffle_in: false, // have the pictures all fade in on page load?
			js_fade_on_hover: true, // do we want the images to fade on hover or just change opacity?
			js_caption_slide_down: true // do we want the caption to slide down or just appear?
		});
		
	},
	
	// Use the ever-so popular jquery form validation plugin to work it's magic on forms
	setupFormValidation: function(selectors){

		$(selectors).validate({
		
			onfocusout: false,
			errorElement: "span",
			errorPlacement: function(error, element) {
				error.appendTo( element.parent() );
				element.parent().find('span.error').before('<br/>');
			},
			rules: {
				email: {
					email: true
				}
			}
			
		});

		
	},
	
	// Setup the search input with default text (focus/blur)
	_searchFormBlurFocus: function(){
		
		var default_val = this.o_search_default_val;
		
		$(this.e_search).focus(function(){
			if($(this).val() == default_val){
				$(this).val('');
			}
		}).blur(function(){
			if($(this).val() == ''){
				$(this).val(default_val);
			}
		})
		
	}
	
}