function modalOpen (dialog) {
	dialog.overlay.fadeIn('fast', function () {
		dialog.container.fadeIn('fast', function () {
			dialog.data.hide().slideDown('fast');	 
		});
	});
	
	$('#simplemodal-overlay').click(function(){
		$.modal.close();
											  });
}

$(document).ready(function () {
							
	$('.modal_pic_div').each(function(){
		$('.modal_pic', $(this)).after('<span class="scope_span"></span>');
			$('.scope_span', $(this)).click(function(es) {
				es.preventDefault();
				$(this).siblings('.modal_pic_big').modal({onOpen: modalOpen});
			})
				//.width($('.modal_pic', $(this)).width()+4)
				//.height($('.modal_pic', $(this)).height()+4);
				
			$('.scope_span', $(this)).hover(function(){
				$(this).css('background-position','50% 50%')
				
			}, function(){
				$(this).css('background-position','-1000px -1000px')
					
		});
		
	});
	
/*	$('#history .inimgwrap img').click(function(es){
			if($(this).next().is(".inimgdesc")){
				var src = $(this).attr('src');
				var srcArr = src.split('.');
				srcArr[0] += '-big';
				var src_big = srcArr.join('.');
				$(this).after('<img src="'+src_big+'" class="modal_pic_big">');
			}
			$(this).siblings('.modal_pic_big').modal({onOpen: modalOpen});
	})
*/	
});