function xdb_popup_img (sys_img_dir, fn, name, w, h, fl_view, tag_img_param)
{
	if (fl_view==1) {
		$('div_xdb_popup_img').innerHTML='<a onClick="javascript:xdb_popup_img(\''+sys_img_dir+fn+'\', \''+name+'\', '+w+', '+h+', 0)" style="cursor: hand;"><img src="'+sys_img_dir+'img/bt_close.jpg" border=0 hspace=2 vspace=2></a><br clear="all"><a onClick="javascript:xdb_popup_img(\''+fn+'\', \''+name+'\', 0, \''+tag_img_param+'\')" style="cursor: hand;"><img src="'+sys_img_dir+fn+'" '+tag_img_param+' title="скрыть фото: '+name+'"></a>';
		$vis('div_xdb_popup_img', 1);

		//document.body.onscroll = function() {
			x=getClientCenterX()-w/2; if (x<0) x=0;
			y=getClientCenterY()-h/2; if (y<0) y=0;
			$('div_xdb_popup_img').style.left=x;
			$('div_xdb_popup_img').style.top=y;
		//}
		
		if (!IE) fade ($('div_xdb_popup_img'),100,300);
	}
	else {
		document.body.onscroll=null;

		if (IE) $vis('div_xdb_popup_img', 0);
		else fade ($('div_xdb_popup_img'),0,300, xdb_popup_img_hide);
	}
}

function xdb_popup_video (v_link, name, fl_view)
{
	w=425; h=344;
	if (fl_view==1) {
		$('div_xdb_popup_img').innerHTML='<a onClick="javascript:xdb_popup_img(\''+v_link+'\', \''+name+'\', 0)" style="cursor: hand;"><img src="img/bt_close.jpg" border=0 hspace=2 vspace=2></a><br clear="all"><object width="425" height="344"><param name="movie" value="'+v_link+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+v_link+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>';
		$vis('div_xdb_popup_img', 1);
		
		//document.body.onscroll = function() {
			x=getClientCenterX()-w/2; if (x<0) x=0;
			y=getClientCenterY()-h/2; if (y<0) y=0;
			$('div_xdb_popup_img').style.left=x;
			$('div_xdb_popup_img').style.top=y;
		//}
		
		if (!IE) fade ($('div_xdb_popup_img'),100,300);
	}
	else {
		document.body.onscroll=null;

		if (IE) $vis('div_xdb_popup_img', 0);
		else fade ($('div_xdb_popup_img'),0,300, xdb_popup_img_hide);
	}
}

function xdb_popup_img_hide (){
	$vis('div_xdb_popup_img', 0);
}

function fade(obj,alpha_to,time,callback){
	var IE=/*@cc_on!@*/false;
	if(IE) {
		from = obj.style.filter.replace(/.*opacity=([0-9]*).*/,'$1'); 
		if(!from) {from=100;}
		from=parseFloat(from);
	}
	else {
		var from=obj.style.opacity;
		if(from==''){from=1;}
		from=parseFloat(from);
		alpha_to=alpha_to/100;
	}
	var start = new Date().getTime();
	setTimeout (function() {
		var now=(new Date().getTime())-start;
		var progress=now/time;
		var result=(alpha_to-from)*progress+from;
		
		if (IE) { obj.style.filter="alpha(opacity="+result+")"; }
		else { obj.style.opacity=result; }
		if (progress<1) { setTimeout(arguments.callee,10); }
		else {
		if (IE) { obj.style.filter="alpha(opacity="+alpha_to+")"; }
		else {obj.style.opacity=alpha_to;}
		
		if (callback) { setTimeout(callback,0); }
		}},10);
	};
	
document.write('<div id="div_xdb_popup_img"></div>');
