$("document").ready(function(){
			/* Billy Reid Light Box Implementation - By Randy Little */
			/* Published Jan 2010 */
			
				/* jQuery Implementation for http://www.billyreid.com
				 * Revised version. January 21, 2010
				 * 
				 * Authors: Randy Little.
				 *
				 * Referenced Authors: 
				 *
				 * Libraries Used: jQuery (http://www.jQuery.com)
				 * Revision: Randy Little
				 * Code Researched: Visual jQuery (http://www.visualjQuery.com)*/
			
				var _brlbw, _brlbh, _brlbx, _brlby, _brlbs, _brlbxp, _brlbyp;

				$(".brlb").click(function(evt){
					_brlbs = $(this).attr('href');
					constructLightBox( $(this).attr("title") );
					evt.preventDefault();
				});
				function constructLightBox( _brlbtitle )
				{
					_brlbw = getLightBoxDimension('width', _brlbtitle);
					_brlbh = getLightBoxDimension('height', _brlbtitle);
					_brlbx = getLightBoxCoords('x', _brlbtitle) - 10;
					_brlby = getLightBoxCoords('y', _brlbtitle) - 30;
					_brlbyp= $(".brlb[title=" + _brlbtitle + "]").offset().top;
					_brlbxp= $(".brlb[title=" + _brlbtitle + "]").offset().left;
					
					//$('body').append("<div class=\"brlbwrapper\"></div>");
					$('body').append("<div class=\"brlbw\" title=\"" + _brlbtitle + "\" style=\"width:50px;height:1px;top:" + _brlbyp + "px;left:" + _brlbxp + "px;\"></div>");
					//$('.brlbwrapper').css("height",$('body').height());
					$("#blocker").show();
					$(".brlbw").show();
					inflateLightBox();
					/*$('html, body').animate({
						scrollTop: 0
					}, 750);*/
				}
				
				function destructLightBox()
				{
					$(".brlbw").remove();
					//$(".brlbwrapper").remove();
					$("#blocker").hide();
				}
				
				function inflateLightBox ()
				{
					$(".brlbw").animate({
						"left":_brlbx,
						"width":_brlbw,
						"top":_brlby,
						"height":_brlbh,
						"opacity":"1.0"
					},325, populateLightBox);
				}
				
				function deflateLightBox()
				{
					$(".brlbw").html("");
					$(".brlbw").animate({
						"left":_brlbxp,
						"width":"1px",
						"top":_brlbyp,
						"height":"1px",
						"opacity":"0.0"
					},325, destructLightBox);
				}
				
				function populateLightBox()
				{
					$(".brlbw").html( "<iframe id=\"_brlbf\" width=\"100%\" style=\"display:none;\" height=\"100%\" frameborder=\"0\" cellspacing=\"0\" border=\"0\" src=\"about:blank\" name=\"_brlbw\" />" );
					$(".brlbw").append("<div class=\"btnclose\"><img alt=\"\" src=\""+_ROOT_PATH+"../media/loaders/btnclose.jpg\" /></div>");
					
					if ( !$.browser.msie )
					{
						setTimeout ( function() {
							_html = $('html', $("#_brlbf")[0].contentDocument);
							_body = $('body', $("#_brlbf")[0].contentDocument);
							
							$(_body).css({"background":"#000000","color":"white"});
							_body.append("<div style=\"margin-left:49%;margin-top:28%;\"><img alt=\"Loading...\" src=\""+_ROOT_PATH+"../media/loaders/ajax-loader.gif\" /></div>");
							
						}, 10);
						
						$("iframe[name=_brlbw]").fadeIn(750, function() { $("iframe[name=_brlbw]").attr("src", _brlbs); });
					} else {
						//$("iframe[name=_brlbw]").fadeIn(750, function() { $("iframe[name=_brlbw]").attr("src", _ROOT_PATH + "../media/loaders/ie-loader.php?url=" + _brlbs); });
						$("iframe[name=_brlbw]").fadeIn(750, function() { $("iframe[name=_brlbw]").attr("src", _brlbs); });
					}
					
					$(".btnclose").click(function(evt){
						deflateLightBox();
					});
				}
				
				function getLightBoxDimension ( orientation, _brlbtitle )
				{
					switch ( orientation )
					{
						case 'width':
							return $("input[title=" + _brlbtitle + "_width]").attr("value");
							break;
						case 'height':
							return $("input[title=" + _brlbtitle + "_height]").attr("value");
							break;
					}
				}
			
				function getLightBoxCoords( orientation, _brlbtitle )
				{
					switch ( orientation )
					{
						case 'x':
							return ( $(window).width() / 2 ) - ( _brlbw / 2 );
							break;
						case 'y':
							return (( $(window).height() / 2 ) - ( _brlbh / 2 ) + ( $(window).scrollTop()) );
							break;
					}
				}
				
				/* End Light Box Implementation */
});