function js_href_init(){

	var close = new Image;
	close.src = "/images/close." + ((!/MSIE (5\.5|6\.)/.test(navigator.userAgent))? "png":"gif");

	var elems = document.getElementsByTagName('a');
	for(var i = elems.length; i > -1; i--){
		if(elems[i] && elems[i].id && elems[i].href.substr(0, 11)!='javascript:'){
			if(elems[i].id.substr(0,3)=='img') {
				elems[i].onclick = function(olnk, id){return function(){return open_img(olnk, id);}}(elems[i], i);
			}		
		}
	}
}

function open_img(olnk, id){

	lang = 1;
	function addEventListener(instance, eventName, listener) {    
		var listenerFn = listener;    
		if (instance.addEventListener) {        
			instance.addEventListener(eventName, listenerFn, false);    
		} else if (instance.attachEvent) {        
			listenerFn = function() {            
				listener(window.event);        
			}        
			instance.attachEvent("on" + eventName, listenerFn);    
		} else {        
			object.onkeypress = handler;
		}    return {        
			instance: instance,        
			name: eventName,        
			listener: listenerFn    
		};
	}
	function removeEventListener(event) {    
		var instance = event.instance;  
		if (instance.removeEventListener) {        
			instance.removeEventListener(event.name, event.listener, false);    
		} else if (instance.detachEvent) {        
			instance.detachEvent("on" + event.name, event.listener);    
		}
	}	
	
	function close_win(evt) {
	    // Получаем объект event
	    evt = evt || window.event;
	    var key = evt.keyCode || evt.which;
	    // Определяем нажатие Ctrl+S
	    key = ((key==27||key==32) ? 1 : 0);
	    if (key) {
	        evt.returnValue = false;
	        var div = document.getElementById("big_image_div");
	        if(div) document.getElementById("content_div").removeChild(div);

	        removeEventListener(esc_evt);
	        document.defaultAction = true;
	        // Возвращаем фокус в окно
	        window.focus();
	        return false;
	    } else evt.returnValue = false;
	}
	
	// Определяем браузеры
	var ua = navigator.userAgent.toLowerCase();
	var isIE = (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1);
	var isSafari = ua.indexOf("safari") != -1;
	var isGecko = (ua.indexOf("gecko") != -1 && !isSafari);
	
	// Добавляем обработчики
	if (isIE || isSafari) esc_evt = addEventListener (document, "keydown", close_win);
	else esc_evt = addEventListener (document, "keypress", close_win);

	if(document.getElementById("big_image_div")) return false;
	if(!olnk.attributes['src_width'] || !olnk.attributes['src_height']) return true;
	
	var src_width = olnk.attributes['src_width'].value;
	var src_height = olnk.attributes['src_height'].value;

	var min_width = olnk.attributes['min_width']? olnk.attributes['min_width'].value:0;
	var min_height = olnk.attributes['min_height']? olnk.attributes['min_height'].value:0;
	
	if(!src_width || !src_height) return true;
	if(olnk.attributes['description'])	title =	olnk.attributes['description'].value;
	else title = olnk.title;

	if(!title) {
		
//		var prj = document.getElementsByName('album-name')[0];
//		if(prj) title = prj.innerHTML;
	}

	var img_alt = ["Відкрити у новому вікні", "Открыть в новом окне", "Open in new window"][lang];
	var cls_alt = ["Закрити", "Закрыть", "Close"][lang];
	
	var ratio = src_width/src_height;
	
	var big_image_div = document.createElement('div');
	var big_image_lnk = document.createElement('a');
	var pattern_div = document.createElement('div');
	var title_div = document.createElement('div');
	var border_div = document.createElement('div');
	var big_image = document.createElement('img');
	var close_image = document.createElement('img');
	var pre_image = document.createElement('img');
	
	
	big_image_div.id = "big_image_div";

	// Ссылка на картинку
	big_image_lnk.href = olnk.href;
	big_image_lnk.target = "_blank";
	big_image_lnk.title = img_alt;
	
	// Фон
	pattern_div.style.position = "absolute";
	pattern_div.style.zIndex = 99;
	pattern_div.style.backgroundColor= "#000000";
	pattern_div.style.opacity = "0.6";
	pattern_div.style.MozOpacity="0.6";
	pattern_div.KHTMLOpacity="0.6";
	pattern_div.style.filter="alpha(opacity:60)";
	
	var width =  window.innerWidth? window.screen.availWidth - window.outerWidth + window.innerWidth:window.screen.availWidth-18;
	//var width = document.body.offsetWidth;

	var height = document.getElementById('content_div').clientHeight;
	var top = 0;
	var left = 0;

	pattern_div.style.left = left + "px";
	pattern_div.style.top = top + "px";
	pattern_div.style.width = width + "px";
	pattern_div.style.height = height + "px";
	
	var max_width = window.innerWidth? window.innerWidth-60:window.screen.availWidth*0.9;
	var max_height = window.innerHeight? window.innerHeight-120:window.screen.availHeight*0.6;
	
	// Картинка
	if(src_width>max_width){
		src_width = max_width;
		src_height = src_width/ratio;
	}
	if(src_height>max_height){
		src_height = max_height;
		src_width = src_height*ratio;
	}
	src_height = parseInt(src_height);
	src_width = parseInt(src_width);

	image_height = src_height;
	image_width = src_width;
	
	src_width = Math.max(src_width, min_width);
	src_height = Math.max(src_height, min_height);
	
	big_image_div.appendChild(pattern_div);
	document.getElementById('content_div').appendChild(big_image_div);
	
	
	title_div.style.position = "absolute";
	title_div.style.zIndex = 104;
	title_div.style.backgroundColor= "#FFFFFF";
	title_div.style.width = (src_width) + "px";
	//title_div.style.height = (55) + "px";
	title_div.style.padding = "5px 15px 10px 15px";
	//title_div.style.fontWeight = "bold";
	title_div.style.textAlign = "center";
	title_div.className = "gallery-photo-id-caption";
	title_div.innerHTML = title;
	big_image_div.appendChild(title_div);
	
	title_height = title_div.clientHeight;
	
	big_image.style.position = "absolute";
	big_image.style.zIndex = 102;
	big_image.alt = img_alt;
	big_image_lnk.appendChild(big_image);

	var scroll_top = document.body.scrollTop?document.body.scrollTop:document.documentElement.scrollTop;
	
	top = scroll_top + parseInt((max_height-src_height-title_height+115)/2); 
	left = parseInt((document.body.scrollWidth-src_width)/2);
	big_image.src = olnk.href;
	big_image.width = image_width;
	big_image.height = image_height;
	big_image.style.top = top + "px";
	big_image.style.left = (left+(src_width-image_width)/2) + "px";
	
	// Кнопка
	close_image.style.cursor = "pointer";
	close_image.style.position = "absolute";
	close_image.style.zIndex = 103;
	close_image.src = "/images/close." + ((!/MSIE (5\.5|6\.)/.test(navigator.userAgent))? "png":"gif");
	close_image.title = "Закрыть"
	close_image.alt = "Закрыть"
	close_image.width = 20;
	close_image.height = 20;
	close_image.style.top = (top-28) + "px";
	close_image.style.left = (left+src_width+8) + "px";
	close_image.onclick = function(img_div, esc_evt) {return function(){document.getElementById("content_div").removeChild(img_div);removeEventListener(esc_evt);}}(big_image_div, esc_evt);
	close_image.title = cls_alt;
	
	// Рамка
	border_div.style.position = "absolute";
	border_div.style.zIndex = 100;
	border_div.style.backgroundColor= "#FFFFFF";
	border_div.style.width = (src_width + 30) + "px";
	border_div.style.height = (src_height + 75) + "px";
	border_div.style.top = (top-15) + "px";
	border_div.style.left = (left-15) + "px";
	
	// Подпись
	title_div.style.top = (top+src_height) + "px";
	title_div.style.left = (left - 15) + "px";

	// Прелоадер
	pre_image.style.position = "absolute";
	pre_image.style.zIndex = 102;
	pre_image.src = "/images/loader/loader2.gif";
	pre_image.style.top = (parseInt(top + src_height/2-33)) + "px";
	pre_image.style.left = (left+src_width/2-33) + "px";
	
	big_image_div.appendChild(border_div);
	big_image_div.appendChild(pre_image);
	big_image_div.appendChild(big_image_lnk);
	big_image_div.appendChild(close_image);
	
	
	return false;
}