var thing = function(){

	var r = {},
	$,
	glow,
	g;

	// =================================================================
	// notification listeners

	r.thing = function(){
		//
	};


	// =================================================================
	r.imageFocus = function(){

		var images = $(".image");
		if(images.length == 0){ return false; }

		var image, frame, ratio, frameHeight, focus;

		images.each(function(i){

			image = $(images[i]);
			frame = $(images[i]).parent();

			ratio = 611 / parseInt( image.css("width") );

			//alert(ratio);

			image.css( "height", ( Math.round ( parseInt( image.css("height")) * ratio)) + "px" );
			image.css( "width", ( Math.round ( parseInt( image.css("width")) * ratio)) + "px");

			frame.addClass("frame");
			frame.html('<span class="subframe">' + frame.html() + '</span>');

            if(image.hasClass("potw")){ precaption = '<strong><a href="http://www.flickr.com/photos/northover/sets/72157623047548229/">Pic of the week</a>:</strong> '; } else { precaption = ""; };
            
			frame.after('<p class="caption">&#x21AA; ' + precaption + image.attr("alt") + '</p>');

			if(image.hasClass("special")){
				frame.addClass("specialframe");

				frameHeight = image.attr("class").match(/\by_(\w+)\b/)[1];

				frame.get(".subframe").css("height", frameHeight + "px");

				focus = image.attr("class").match(/\bfocus_(\w+)\b/)[1];
				frame.get(".special").css("top", focus * -1);				
			}

		});

	};

	// =================================================================
	// get going

	r.init = function(glow){
		g = glow;
		$ = g.dom.get;

		//this.thing();
		this.imageFocus();

	};
	// =================================================================

	return r;
	}();

	// =================================================================
	glow.ready(
		function(){
			thing.init(glow);
		}
	);
