(function($){
	$.fn.jRoller = function(area,textWidth,textHeight,textSide){
		var self = this;
		/* each form */
		return this.each(function(){
				var thisclass = $(this).attr("class");
				var thisid = $(this).attr("id");
				var parentLoc = $(this).position();
				
				var replacementText = "<div class='rollerimg";
				if (thisclass) {
					replacementText += " " + thisclass;
				}
				
				replacementText += "' ";
				
				
				if (thisid) {
					replacementText += "id='" + thisid + "'";
				}
				
				replacementText += "style='background-repeat:no-repeat; background-image: url(\""+$(this).attr("src")+"\");";
				replacementText += "height:"+$(this).attr('height')/2+"px; ";
				replacementText += "width:"+$(this).attr('width')+"px; ";
				
				
				
				replacementText += "overflow:hidden;'>";
				replacementText += "</div>";
				if (area) {
					replacementText += "<p id='"+thisid+"' class='"+thisid+"' ";
					replacementText += "style='";
					replacementText += "width:"+textWidth+"px; ";
					replacementText += "height:"+textHeight+"px; ";
					
					if(textSide == "left") {
						replacementText += "top:"+parentLoc.top+"px; ";
						replacementText += "left:"+(parentLoc.left-textWidth)+"px; ";
						replacementText += "margin-right:1px; ";
					}
					if(textSide == "right") {
						replacementText += "top:"+parentLoc.top+"px; ";
						replacementText += "left:"+(parentLoc.left+$(this).attr('width'))+"px; ";
						replacementText += "margin-left:5px; ";
					}
					replacementText += "display:none;'>" + area + "</p>";
					
				}
				
				
				$(this).replaceWith(replacementText);
				$('body').find(".rollerimg").hover(function(e) {
					$(this).css("background-position", "0 -"+$(this).height()+"px");
					var txtid = "." + $(this).attr("id");
					$(txtid).show();
				},
				function(e) {
					var txtid  = "." + $(this).attr("id");
					$(this).css("background-position", "0 0");
					$(txtid).hide();
				});
			});
	};/* End the Plugin */


	/* Automatically apply to any forms with class jRoller */
	$(function(){$('#rollernav img').jRoller();	});
	$(function(){$('.rollernav img').jRoller();	});
})($);