/**
* Grid plugin
* --------------------------------------------------
* 
* File: js/jquery.grid.js
* Created:
* Modified:
* Author: David Geilfus
*/

/**
* Closure
*/
(function($) {
	/**
	* Plugin definition
	*/
	$.fn.grid = function(options) {
		var settings = $.extend({
			image: null,
			repeat: null
		}, options);
		
		return this.each(function() {
			var bg = 'url(' + settings.image + ') ';
			
			if (settings.repeat != null) {
				if (settings.repeat != '') {
					bg += 'repeat-' + settings.repeat;
				}
			} else {
				bg += 'no-repeat';
			};
			
			$(this).append('<div id="grid"></div>');
			$('#grid').css({
				background: bg,
				height: $(this).outerHeight(),
				left: $(this).offset().left,
				opacity: 0.5,
				position: 'absolute',
				top: $(this).offset().top,
				width: $(this).outerWidth()
			}).hide();
			
			$(window).keydown(function(e) {
				if (e.keyCode == 71) {
					$('#grid').toggle();
				}
			});
		});
	};
})(jQuery);