trans_bck=document.createElement('div');
trans_bck.className="fullbck";

var maxAppearM=0;
function show_prev_img(url,tx,w,h)
{
	trans_bck.style.opacity="0.5";
	trans_bck.style.filter="alpha(opacity=50)";
	document.body.appendChild(trans_bck);
	
	fs_im=document.getElementById('full_size_image');
	nw=(w+100<document.documentElement.clientWidth)?w:document.documentElement.clientWidth-100;
	nh=(h+100<document.documentElement.clientHeight)?h:document.documentElement.clientHeight-100;
	prop=(nh/h<nw/w)?nh/h:nw/w;
	prop=(prop>1)?1:prop;
	w=w*prop;
	h=h*prop;
	fs_im.parentNode.style.width=w+"px";
	fs_im.style.width=w+"px";
	fs_im.parentNode.style.height=h+"px";
	fs_im.style.height=h+"px"
	//fs_im.parentNode.style.opacity="";
	//fs_im.parentNode.style.filter="alpha(opacity=65)";
	fs_tx=document.getElementById('prev_image_text');
	fs_tx.innerHTML=tx;
	fs_tx.style.width=w+"px";
	prev_img.style.display="block";
	
	maxAppearM=Math.round((document.documentElement.clientHeight)/2);
	def_top=-prev_img.clientHeight;
	prev_img.style.top=def_top+"px";
	prev_img.style.marginTop=-h/2-21+"px";
	prev_img.style.marginLeft=-w/2-52+"px";
	bufferTout("tout_appear('"+url+"',"+def_top+",0)",25);
}
function bufferTout(func,tout)
{
	tOut=setTimeout(func,tout);
}


function tout_appear(url,prev_top,bc)
{
	clearTimeout(tOut);
	bc+=0.1;
	prev_top+=50;
	
	//trans_bck.style.opacity=bc;
	//trans_bck.style.filter="alpha(opacity="+ bc*100 +")";
	
	prev_img.style.top=prev_top+"px";
	if(prev_top>=maxAppearM-50)
	{
		prev_img.style.top="";//maxAppearM+"px";
// 		prev_img.className='IeScroll';
		fs_im=document.getElementById('full_size_image');
		fs_im.src=url;
		
		fs_im.onload=function()
		{
			//this.parentNode.style.opacity="1";
			//this.parentNode.style.filter="alpha(opacity=100)";
			this.style.visibility="visible";
		}
	}
	else bufferTout("tout_appear('"+url+"',"+prev_top+","+bc+")",30);
}

function tout_disappear(prev_left,bc)
{
	clearTimeout(tOut);	
	prev_left-=100;
	bc-=0.06;
	prev_img.style.left=prev_left+"px";
// 		trans_bck.style.opacity=bc;
// 		trans_bck.style.filter="alpha(opacity="+ bc*100 +")";
	if(prev_left+document.documentElement.scrollLeft<=-prev_img.clientWidth)
	{
		prev_img.style.left="";
		fs_im=document.getElementById('full_size_image');
		fs_im.parentNode.style.width=0;
		fs_im.parentNode.style.height=0;
		//fs_im.src='';
		fs_im.style.visibility='';
		fs_tx=document.getElementById('prev_image_text');
		fs_tx.innerHTML='';
		prev_img.style.display="";
		document.body.removeChild(trans_bck);
	}
	else bufferTout("tout_disappear("+prev_left+","+bc+")",20);
}

function hide_prev_img()
{
	prev_img.className='';
	bufferTout("tout_disappear("+document.documentElement.clientWidth/2+","+trans_bck.style.opacity+")",25);
}


var scrllMod=0;
	
function scroll_content(mode,dest,blockId,thumbId,step,tOut)
{
	scrllMod=mode;
	
	if(mode!=0)
	{
		list=document.getElementById(blockId);
		if(thumbId!=null) thumb=document.getElementById(thumbId);
		else thumb=null;
		var ord,item;
		switch(dest)
		{
			case 'left':
				ord="Left";
				item="Width";
				r=-1;
			break;
			
			case 'top':
				ord="Top";
				item="Height";
				r=-1;
			break;
			
			case 'right':
				ord="Left";
				item="Width";
				r=1;
			break;
			
			case 'bottom':
				ord="Top";
				item="Height";
				r=1;
			break;
		}
		
		listMarg=list['scroll'+ord];
		if(listMarg+r*step<=0)
		{
			list['scroll'+ord]=0;
			if(thumb!=null) thumb.style[ord.toLowerCase()]="0px";
			return false;
		}
		if(listMarg + r* step>=list['scroll'+item]-list['client'+item])
		{
			list['scroll'+ord]=list['scroll'+item]-list['client'+item];
			if(thumb!=null) thumb.style[ord.toLowerCase()]=list['scroll'+ord]*thumb.parentNode['client'+item]/list['scroll'+item]+"px";
			return false;
		}
		list['scroll'+ord]=listMarg+r*step;
		if(thumb!=null) thumb.style[ord.toLowerCase()]=list['scroll'+ord]*thumb.parentNode['client'+item]/list['scroll'+item]+"px";
		
		if(tOut!=null) setTimeout("timeoutContScrll('"+dest+"','"+blockId+"','"+thumbId+"',"+step+","+tOut+")",tOut);
		return true;
	}
	
}
function timeoutContScrll(dest,blockId,thumbId,step,tOut)
	{
		if(scrllMod!=0)
		{
			scroll_content	(scrllMod,dest,blockId,thumbId,step,tOut);
		}
	}

var inDragin=false;
var mousePos;
var c_scrollThumbMarg=0;
var dragObj=null;
var dragPrnt=null;
var dragDest=null;
function startDrag(e)
{
	if(inDragin)
	{
		if(dragObj!=null && dragPrnt!=null && dragDest!=null && (dragDest.toUpperCase()=='X' || dragDest.toUpperCase()=='Y'))
		{
			if(mousePos==null) mousePos=e['client'+dragDest.toUpperCase()];
			
			m=e['client'+dragDest.toUpperCase()]-mousePos;
			mousePos=e['client'+dragDest.toUpperCase()];
			if(dragDest.toUpperCase()=='X')
			{
				dest=(m>0)?'right':'left';
				Ratio=document.getElementById(dragObj).clientWidth/document.getElementById(dragObj).parentNode.clientWidth;
			}
			else
			{
				dest=(m>0)?'bottom':'top';
				Ratio=document.getElementById(dragObj).clientHeight/document.getElementById(dragObj).parentNode.clientHeight;
			}
			scroll_content(1,dest,dragPrnt,dragObj,Math.abs(m/Ratio),null)
			return false;
		}
	}
	else return true;
}
var wheelMax=0;
function wheel(event,scrollObj,scrollThumb,step,ord)
{
	var wheelDelta = 0;
	var step =(step)?step : 45;
	var ord =(ord)?ord : 'Y';
	if (!event) event = window.event;
	if (event.wheelDelta) wheelDelta = -event.wheelDelta/120;
	else if (event.detail) wheelDelta = event.detail/3;
	if(ord=="X")dest=(wheelDelta>0)?'right':'left';
	if(ord=="Y")dest=(wheelDelta>0)?'bottom':'top';
	if(scroll_content(1,dest,scrollObj,scrollThumb,Math.abs(step*wheelDelta),null))
	{
		wheelMax=0
		if (event.preventDefault) event.preventDefault();
		event.returnValue = false;
		
	}
	else
	{
		wheelMax+=Math.abs(wheelDelta);
		if(wheelMax<4)
		{
			if (event.preventDefault) event.preventDefault();
			event.returnValue = false;
		}
		else wheelMax=4;
	}
}

function getAbsolutePos(el)
{
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent)
		{
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
		}
	return r;
}

function setCookie (name, value, expires, path, domain, secure)
{
	document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = "";
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function add_c_adm_pl(mode)
{
	var current_date = new Date;
	var cookie_year = current_date.getFullYear() + 1;
	var cookie_month = current_date.getMonth();
	var cookie_day = current_date.getDate();
	var the_exp = cookie_day+"/" + cookie_month + "/" + cookie_year + " 00:00:00";
	
	setCookie("adm_pl_op", mode, the_exp, "/");
}

function vis_adm_place(t)
{
	var vis_t={'hide':{0:'hidden',1:'visible',2:8},'show':{0:'visible',1:'hidden',2:36}};
	var pls=document.getElementById('adm_place').childNodes;
	var pl;
	for(i=0;i<pls.length;i++)
	{
		if(pls[i].nodeType!=3) 
			{
				pl=pls[i];
				break;
			}
	}
	var alements=pl.childNodes;

	for(ind in alements)
	{
		el = alements[ind];
		if(el.nodeType!=3 && !isNaN(ind)) el.style.visibility=vis_t[t][0];
	}
	arr=document.getElementById('a_show_lnk').style.visibility=vis_t[t][0];
	arr=document.getElementById('a_hide_lnk').style.visibility=vis_t[t][1];
	pl.style.height=vis_t[t][2]+'px';
	add_c_adm_pl(t);
	return false;
}
