/*	******************************
		Plugin:		parallax 
		Author:		Jorge Soriano - Tecknosfera DBNet
	******************************	*/
	
(function($){

	$.fn.parallax = function(opt){
			opt = $.extend({
				ratio 	: 1,
				bg		: true,
				bg_X	: '50%',
				center  : true
			},opt);
			
 			return this.each(function(){
 				var $this = $(this);
 				$this.attr({'rel':$this.offset().top});
 				
 				$(window).scroll(function(){
 					 					
 					var windowScrollY = $(window).scrollTop();
 					var windowH = $(document).height();
 					var orig = $this.attr('rel');
 					var move = Math.round(0 - (windowScrollY * opt.ratio));
 					
 					if ( opt.bg == true && opt.center == true){
 	 					var coords = '50% '+ move + 'px';
 	 					$this.css({ backgroundPosition: coords });
 					}
 					
 					if ( opt.bg == true && opt.center == false){
 	 					var coords = move + 'px ' +opt.bg_X;
 	 					$this.css({ backgroundPosition: coords }); 						
 					}
 					
 					if ( opt.bg == false){
 						var move = Math.round(orig - (windowScrollY * opt.ratio));
 						var coords = move + 'px';
 						$this.css({ top : coords });
 					}
 					
 				}); 				
		});
	}
})(jQuery);
