
			$(document).ready(function(){
			
				$('.before-after-gall-cont .big-imgs').cycle({
					timeout: 5000,
					pager:  '.small-imgs', 
    				pagerAnchorBuilder: function(idx, slide) { 
        			// return selector string for existing anchor 
        				return '.small-imgs div:eq(' + idx + ') img'; 
    				} 
					});
					
					$('.before-after-gall-cont .big-imgs .big-item').show();
					
					
				$('.before-after-gall-cont .big-imgs img.big-img').click(function(){
					
				
					$('body').append('<div id="overlay"></div><div id="modal"><div id="modalInner"><a href="#" id="close" title="Close">Close</a><div id="modalImageColumn"></div><div id="modalTextColumn"></div><div class="clearing"></div></div></div>');
		
					if($.browser.msie && $.browser.version <= 6.0) {
						var windowHeight = $(document).height();
						$('#overlay').height(windowHeight);
					}
		
					$('#overlay').css('opacity', 0.8).fadeIn('fast');
					$('#modal').fadeIn('slow');
		
					//Position it in the viewport
					var scrollPos = $(window).scrollTop() + 50;		
					$('div#modal').css('top',scrollPos+'px');
		
					//Handle the clicking of close button or clicking the background
					$('div#modal a#close,div#overlay').bind('click', function() {
					$('div#modal').fadeOut('fast',function() {
					$('div#overlay').fadeOut('fast',function() {
					$(this).remove();							   
				});
				$(this).remove();							   
			});
			return false;
		});
			
			$(this).parent().find("img").each(function(i){
				if($(this).hasClass('single')){
					var maxWidth = 700;
				} else {
					var maxWidth = 500;
				}
			
				var imgUrl = $(this).attr('src');
				$('div#modalImageColumn').append('<img src="'+imgUrl+'" alt="" class="frame" />');
				
				$('img.frame').each(function(){
					var currentWidth = $(this).width();
					if(currentWidth > maxWidth){
						var newWidth = maxWidth;
						var currentHeight = $(this).height();
						var ratio = maxWidth / currentWidth;
						var newHeight = currentHeight * ratio;
						$(this).height(newHeight);
						$(this).width(newWidth);
				}
				});
				
				$('img.ornament').load(function() {
				
				
				
				$(this).fadeIn();
				});
			});
			
			
					
			
					
					return false;
				});	
				
				
			});

