$(document).ready(function() {

 	$(".emailtext").each(function() {
 		var e = $(this).attr("href") + "@" + $(this).text();
 		$(this).text(e);
 		$(this).attr("href", "mailto:" + e);
 	});
	/* css fix */
	var height = $("#container-page").height(); 
	$("#boxfon").css("height",height);
	
	
	
	if ($("#text").length) {
		var height = $("#text").height();
		var menu_height = $("#menu").height();
		if(height>menu_height) { 
			$("#iemenu").css("height",height-menu_height)
		}
	}
	/* */
	$('img.tumbhail').click(function(){
		var el = this;
		var params = $(el).attr('id').toString();
		params = params.split("_");
		var table = params[0];
		var id = params[1];
		show_photo(table,id);
 })
});

function show_photo(table,id)
{
 var top =$(window).scrollTop();
 var windowheight = $(window).height();	
 var indicatortop = top - 16 + windowheight/2;
 // написать плагин для этого дела	
 var height = $("#container-page").height();	
 var width = $("#container-page").width();	
 $("#bigimgfon").css( {
 	width: width+"px",
    height:height+"px"
 });
 $("#bigimgfon").show();

 
 
 $("#bigimgbox").css("top",indicatortop);
 $("#bigimg").show();
 $("#bigimg").html("<div class=\"bigimgbox\" style=\"top:"+indicatortop+"px;background:none;\"><img src=\"/i/ajax/loadimg.gif\" alt=\"\" width=\"32\" height=\"32\" /></div>");
 $.getJSON(
 '/gallery',
 {
  id: id,
  table: table,
  top: top,
  height: windowheight,
  show_img: true
 },
 function(obj)
 {	
  $("#bigimg").html(obj.html);

  
  if ($.browser.msie && $.browser.version <= 6 ) {
  		$("#imgsrc").attr("src",obj.src)
		$("#imgsrc").show("");	
	} else {
  		$("#imgsrc").attr("src",obj.src).load( function() {
  			$("#imgsrc").show("");	
  		});
	}
 });
}

function closeimg() {
	$('#bigimg').hide();
	$('#bigimgfon').hide();
	$('#imgsrc').hide();
}
