(function(){
	jQuery.fn.promo = function(options){
		
		var defaults = {
			'position': 'right'
		}
		
		return this.each(function(){
			
			//defaults  object extends options object
			options = jQuery.extend(defaults, options);
			
			var obj = jQuery(this);
			var theWindow = jQuery(window);
			
			//provided image dimensions: image width=30, height=100
			function positionElement(){
				var elementWidth = obj.outerWidth();
				var elementHeight = obj.outerHeight();
				var windowWidth = theWindow.width();
				var windowHeight = theWindow.height();	
				var divWidth = 884;
				
				if(options.position == "right"){
					var X2 = (windowWidth-divWidth)/2 + divWidth;
				}
				else if(options.position == "left"){
					var X2 = (windowWidth-divWidth)/2 - elementWidth;
				}			
				
				var Y2 = windowHeight/2 - elementHeight/2;
				
				X2 = X2 + "px";
				Y2 = Y2 + "px"; 
				obj.css({
					'left':X2,
					'top':Y2,
					'position':'fixed'
				});						
			} //end of positionElement function
			
			positionElement(); //position the element on page load
			
			//bind various event handlers to mouseover, mouseoff, and window resize events
			theWindow.bind('resize',function(){
				positionElement();
			});
									
		}); //end of return this.each
	};
})(jQuery);

