var TextImage = Class.create(
{
	initialize: function()
	{
	},
	
	parse: function()
	{
		if (this.container = $$('#content').shift()){ this.init(); }
	},
	
	init: function()
	{
		$$("#content .text img").each(function(img){
			
			var rel = img.readAttribute("rel");
			if(rel != "nohighres")
			{
				var wrapper = new Element('div', { 'class': 'imgwrapper' });
				img.wrap(wrapper);
				var imgname = img.readAttribute("src");
				var imgarr = imgname.split("/");
				var file = imgarr[imgarr.length-1];
				wrapper.insert("<div class=\"highres\"><a href=\"/upload/2/textimage/highres/"+file+"\"><img src=\"/images/high-res.png\"  alt=\"Download high-res\" /></a></div>");
			}
			
		},this);
		
		$$(".highres img").each(function(img){
			img.observe("mouseover",function(evt){ evt.target.setAttribute("src","/images/high-res_over.png"); });
			img.observe("mouseleave",function(evt){ evt.target.setAttribute("src","/images/high-res.png"); });
		},this);
	}
	
});
var textimg = new TextImage();
document.observe('dom:loaded', function(event) { textimg.parse(); });