/* FUNCTIONS */

// Clearing form fields (YWN)
(function( $ ){
	$.fn.clearMe = function( options ) {

		return this.each(function() {
			// Clear input fields focus function:
			$(this).focus(function() {
				var $input = $(this);
				if ($input.attr('value') === $input.attr('defaultValue')) {
					$input.attr('value', '');	
				}
			});
			// Clear input fields blur function:
			$(this).blur(function () {
				var $input = $(this);
				if ($input.attr('value') === '') {
					$input.attr('value', $input.attr('defaultValue'));	
				}
			});
		});

	};
})( jQuery );

// Simple image display (YWN)
(function( $ ){
	$.fn.nokkel = function( options ) {
		
		// Default settings here:
		var settings = {
			largeImage	: "#lareImage",
			imageLink	: "#fancylink"
		};
	
		return this.each(function() {        
			// If options exist, lets merge them with our default settings
			if ( options ) { $.extend( settings, options ); }
			// CODE:
			
			$(this).click(function() {
				var $smallRel = $(this).attr('rel');
				
				$(settings.largeImage).fadeOut('fast', function() {
					$(this).attr('src', $smallRel).fadeIn('fast');
					$(settings.imageLink).attr('href', $smallRel);
				});
			});
		});

	};
})( jQuery );

/* DOCUMENT READY */
$(document).ready(function() {
						   
	// Clearing form fields
	$('input[type=text]').clearMe();
	
	// Simple image display (YWN)
	$('.extraImages').nokkel({
		largeImage	: "#mainImage", // Selector of main image
		imageLink	: "#fancylink" // Selector of fancybox link
	});
});

/* WINDOW RESIZE */
