// Фотогалерея
function drawCanvas(){

	document.write(
		'\
		<div \
			id="imageDiv"\
			style="position:fixed; background:black; opacity:0.92; filter:alpha(opacity=\'92\');  _position:absolute; left:0; top:0; width:100%; height:100%; z-index:10001; visibility:hidden; _top:expression(tmp=document.body.scrollTop+\'px\';); "\
		></div>\
		<table \
			id="imageTable" \
			style="position:fixed; _position:absolute; left:0; top:0; _top:expression( tmp=document.body.scrollTop+\'px\'; ); width:100%; height:100%; z-index:10002; visibility:hidden;"\
			onclick="hideImg();" \
		> \
			<td style="text-align:center; vertical-align:middle; width:100%; height:100%;">\
				<img id="imageImg" align="absmiddle"><br>\
				<span id="imageSpan" style="color:white;"></span>\
			</td>\
		</table>	\
	'
	);

}

function showImg(path,txt){
	document.all["imageImg"].src = '';
	document.all["imageImg"].src = path;
	document.all["imageSpan"].innerText = txt;
	document.all["imageDiv"].style.visibility = document.all["imageTable"].style.visibility = 'visible';
	//document.all["imageDiv"].style.top = document.body.scrollTop;
	return false;
}

function hideImg(){
	document.all["imageImg"].src = '';
	document.all["imageSpan"].innerText = '';
	document.all["imageDiv"].style.visibility = document.all["imageTable"].style.visibility = 'hidden';
}

drawCanvas();


$(document).ready(function(){
	// Всплывающие картинки
	$('#edit a').each(function(){
		imgSrc = $(this).attr('href');
		imgExt = imgSrc.substr(-3).toLowerCase();
		if( imgExt == 'jpg' || imgExt == 'png' || imgExt == 'gif' || imgExt == 'bmp' ){
			$(this).attr('href','javascript:void(0);').attr('target','_self');
			imgTitle = $('img',this).attr('title'); imgTitle = imgTitle != null && imgTitle.substr(-3).toLowerCase() != imgExt ? imgTitle : '';	
			this.onclick = "showImg('"+imgSrc+"','"+imgTitle+"')";
		}
	});
});


