$(document).ready(
	function()
	{
		// Get the available screen height and width
    		if (document.all) {
	        	availW = document.body.clientWidth;
        		availH = document.body.clientHeight;
    		} else {
        		availW = innerWidth;
			availH = innerHeight;
    		}

		// Find all the images
		jQuery('img').each(
			function() {
				// Get this element
				el		= jQuery(this);
				// Get the src
				srcAttr = el.attr('src')||'';
				// Get the alt text
				altAttr = el.attr('alt')||'';
				// Get the types of valid image
				imageTypes 		= /\.jpg|\.jpeg|\.png|\.gif|\.bmp/g;
				// Check whether the source has 'screenshots' in it?
				if (srcAttr.toLowerCase().match(imageTypes) != null && altAttr != '' && srcAttr.toLowerCase().indexOf('screenshots') != -1) {
					// We need to construct a link
					anchorEl = document.createElement('a');
					jQuery(anchorEl).
						attr({
							title : altAttr,
							rel   : 'light-shots',
							href  : srcAttr // Get the original srcAttr
									.replace(/\/(w|h)\d+(\.|\/)/g, "$2") // Remove the existing width and height
									.replace(imageTypes, '/w'+(availW-100)+'/h'+(availH-175)+".jpg")
							});
					el.wrap(anchorEl);
					// Also turn off the borders
					el.attr('border', 0);
				}
			}
		);

		$.ImageBox.init(
			{
				loaderSRC	: '/jquery/images/loading.gif',
				closeHTML	: '<img src="/jquery/images/close.gif" border="0"/>',
				relValue	: 'light',
				DomIdPrefix	: 'LightBox',
				textImage	: 'Screenshot',
				textImageFrom	: 'of'
			}
		);
	}
);
