/*
function openBigImage(url,width,height,title) {
	var min_bottom_shift=60;
	var win_width=width+20;
	var win_height=height;
	var not_full=false;
	if (win_width>(screen.width-10)) {
		win_width=screen.width-10;
		not_full=true;
	}
	if (win_height>(screen.height-min_bottom_shift)) {
		win_height=screen.height-min_bottom_shift;
		not_full=true;
	}
	if (not_full) {
		full_width=width;
		full_height=height;
		var k=width/height;
		if (k<((win_width-20)/(win_height-22))) {
			height=win_height-22;
			width=height*k;
		} else {
			width=win_width-20;
			height=width/k;
		}
	}
	var left=Math.round((screen.width-win_width)/2)-5;
	var top=Math.round((screen.height-win_height)/2)-30;
	ow=window.open("","_blank","dependent=1,width="+win_width+",height="+win_height+",status=no,resizable=yes,scrollbars=yes,toolbar=no,top="+top+",left="+left);
	ow.document.open();
	ow.document.write("<html><title>"+title+"</title><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" width=\""+width+"\" height=\""+height+"\"");
	if (not_full) {
		ow.document.write(" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\'if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\'><sc"+"ript>var full=false;</scr"+"ipt>");
	} else {
		ow.document.write(" alt=\""+title+"\">");
	}
	ow.document.write("</center></body></html>");
	ow.document.close();
}

function openImageWindow(url,title) {
	ow=window.open("","_blank","dependent=1,status=no,resizable=yes,scrollbars=yes,toolbar=no");
	ow.document.open();
//	ow.document.write("<html><title>"+title+"</title><scr"+"ipt language=\"javasc"+"ript\" src=\"/js/optimage.js\"></scr"+"ipt><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" alt=\""+title+"\" name=\"img1\" id=\"img1\" on1load=\'OptimizeImageWindow(document.getElementById(\"img1\"));\'>");
	ow.document.write("<html><title>Увеличенное изображение</title><body style=\"margin: 0px;\"><center><img border=\"0\" src=\""+url+"\" alt=\""+title+"\">");
	ow.document.write("</center></body></html>");
	ow.document.close();
} 

function openBigImage2(url,title) {

//	var inscript = 'alert(1); var full=false; var img=document.getElementById("img1"); img.onload=function() { var width=img.width; var height=img.height; var min_bottom_shift=60; var win_width=width+20; var win_height=height; var not_full=false; if (win_width>(screen.width-10)) { win_width=screen.width-10; not_full=true; } if (win_height>(screen.height-min_bottom_shift)) { win_height=screen.height-min_bottom_shift; not_full=true; } if (not_full) { full_width=width; full_height=height; var k=width/height; if (k<((win_width-20)/(win_height-22))) { height=win_height-22; width=height*k; } else { width=win_width-20; height=width/k; } } var left=Math.round((screen.width-win_width)/2)-5; var top=Math.round((screen.height-win_height)/2)-30; if (not_full) { src=img.src; img.innerHTML = "<img border=\"0\" src=\""+src+"\" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\"if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\">"); } window.resizeTo(win_width,win_height); window.moveTo(left,top); }';

	//ВСЕ ЧТО НИЖЕ ЗАКОММЕНТИРОВАНО
	var full=false;
	var img=document.getElementById("img1");
	img.onload=function() {
		var width=img.width;
		var height=img.height;
		var min_bottom_shift=60;
		var win_width=width+20;
		var win_height=height;
		var not_full=false;
		if (win_width>(screen.width-10)) {
			win_width=screen.width-10;
			not_full=true;
		}
		if (win_height>(screen.height-min_bottom_shift)) {
			win_height=screen.height-min_bottom_shift;
			not_full=true;
		}
		if (not_full) {
			full_width=width;
			full_height=height;
			var k=width/height;
			if (k<((win_width-20)/(win_height-22))) {
				height=win_height-22;
				width=height*k;
			} else {
				width=win_width-20;
				height=width/k;
			}
		}
		var left=Math.round((screen.width-win_width)/2)-5;
		var top=Math.round((screen.height-win_height)/2)-30;
		if (not_full) {
			src=img.src; 
			img.innerHTML = "<img border=\"0\" src=\""+src+"\" alt=\"Увеличить до полного размера\" style=\"cursor: hand;\" onClick=\'if (full) { this.width="+width+"; this.height="+height+"; this.alt=\"Увеличить до полного размера\"; full=false; } else { this.width="+full_width+"; this.height="+full_height+"; this.alt=\"Уменьшить до размера окна\"; full=true; }\'>");
		}
		window.resizeTo(win_width,win_height);
		window.moveTo(left,top);
	} //ВСЕ ЧТО ВЫШЕ КОММЕНТИРОВАНО
	

	ow=window.open("","_blank","dependent=1,status=no,resizable=yes,scrollbars=yes,toolbar=no");
	ow.document.open();
	ow.document.write("<html><title>"+title+"</title><body style=\"margin: 0px;\"><sc"+"ript>"+inscript+"</scr"+"ipt><center><img border=\"0\" name=\"img1\" id=\"img1\" src=\""+url+"\" alt=\""+title+"\">");
	ow.document.write("</center></body></html>");
	ow.document.close();
}
*/
function imagePreview(){	
	/* CONFIG */
		
		xOffset = 10;
		yOffset = 30;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</p>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

$(document).ready(function(){



	imagePreview();
	
});



