function ChangeLang(url, value)
{
	if (url == "/admin.php")
		location.href=url+"?newlang="+value+"";
	else location.href=url+"&newlang="+value+"";
}

function SubListOff(parent, count)
{
	var i;
	for (i=1; i<=count; i++)
	{
		var div=document.getElementById("div"+parent+"_"+i);
		var hidden = document.getElementById("hidden"+parent+"_"+i);
		var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
		div.style.display = "none";
		if (hidden_count.value > 0)
			SubListff(hidden.value, hidden_count.value);
	}
}

function SubListOn(parent, count)
{
	var i;
	for (i=1; i<=count; i++)
	{
		var div=document.getElementById("div"+parent+"_"+i);
		var hidden = document.getElementById("hidden"+parent+"_"+i);
		var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
		div.style.display = "";
		var img=document.getElementById("img"+hidden.value);
		var buf = img.src.substring(img.src.length-7, img.src.length);
		if (buf != "off.gif")
			SubListOn(hidden.value, hidden_count.value);
	}
}

function SubList(parent, count)
{
	var img=document.getElementById("img"+parent);	
	var buf = img.src.substring(img.src.length-7, img.src.length);

	if (buf == "off.gif")
	{
		img.src = "aimages/blueon.gif";
		img.alt = "Скрыть";
		var i;
		for (i=1; i<=count; i++)
		{
			var div=document.getElementById("div"+parent+"_"+i);
			div.style.display = "";
			var hidden = document.getElementById("hidden"+parent+"_"+i);
			var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
			var img=document.getElementById("img"+hidden.value);
			var buf = img.src.substring(img.src.length-7, img.src.length);
			if (buf != "off.gif")
				SubListOn(hidden.value, hidden_count.value);
		}
	}
	else 
	{
		img.src = "aimages/blueoff.gif";
		img.alt = "Раскрыть";
		var i;
		for (i=1; i<=count; i++)
		{
			var div=document.getElementById("div"+parent+"_"+i);
			var hidden = document.getElementById("hidden"+parent+"_"+i);
			var hidden_count = document.getElementById("hidden"+parent+"_"+i+"_count");
			div.style.display = "none";
			if (hidden_count.value > 0)
				SubListOff(hidden.value, hidden_count.value);
		}
	}
}

function MakeOn(url)
{
	var expand = document.getElementById('expand');
	url = url+"&expand="+expand.value;
	location.href=url;
}

function DopImg()
{
        targetId="dopimg";
        targetElement = document.getElementById(targetId);
	if (targetElement.style.display == "none")
	        targetElement.style.display= "";
	else targetElement.style.display = "none";
	location.href = "#dopimg";
}

var curid;
function ContextMenu(event, id){
	if (event.button == 3) return false;

	if (curid)
	{
	        var o = document.getElementById(curid);
	       	o.style.visibility ='';
	}
	curid = id;
        var o = document.getElementById(id);
		o.style.left = event.clientX+document.body.scrollLeft;
        o.style.top = event.clientY+document.body.scrollTop;
        o.style.visibility ='visible';
		preventBubble(event);
}
function ContextMenuHide(){
	if (curid)
	{
	        var o = document.getElementById(curid);
        	o.style.visibility ='';
	}
}

function highlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor="highlight"
event.srcElement.style.color="white"
}
}

function lowlightie5(){
if (event.srcElement.className=="menuitems"){
event.srcElement.style.backgroundColor=""
event.srcElement.style.color="black"
window.status=''
}
}

function jumptoie5(){
if (event.srcElement.className=="menuitems"){
if (event.srcElement.getAttribute("target"))
window.open(event.srcElement.url,event.srcElement.getAttribute("target"))
else
window.location=event.srcElement.getAttribute("url")
}
}

function showImage(src){document.getElementById("bigimage").src=src;}

var u=navigator.userAgent;
var isIE=(u.indexOf("MSIE")>0);
var isMoz=(u.indexOf("Gecko")>0);
var isOp=(u.indexOf("Opera")>0);
if(isOp) isIE=false;

function preventBubble(E){
	if(isIE){
		event.cancelBubble=true;
		event.returnValue=false
	}
	else if(isOp){
		if(DocumentEvent.stopPropagation)DocumentEvent.stopPropagation();
		 else DocumentEvent.preventBubble()
	}
	else {
		if(E.stopPropagation)E.stopPropagation();
		 else E.preventBubble(event)
	}
}

function set_visible(id,show)
{
	var buf = document.getElementById(id);
	if (!buf) return;
	if (show)
	{
		buf.style.visibility = "";
		buf.style.display = "";		
	}
	else 
	{
		buf.style.visibility = "hidden";
		buf.style.display = "none";		
	}
}

function hide_all()
{
	document.getElementById('div1').style.visibility='hidden';
	document.getElementById('div2').style.visibility='hidden';
	document.getElementById('div3').style.visibility='hidden';
}

function high(which2)
{
	theobject=which2
	highlighting=setInterval("highlightit(theobject)",40)
}

function low(which2)
{
	clearInterval(highlighting)
	which2.filters.alpha.opacity=40
}

function highlightit(cur2)
{
	if (cur2.filters.alpha.opacity<100)
		cur2.filters.alpha.opacity+=12
	else if (window.highlighting)
		clearInterval(highlighting)
}

function Over(imgDocID,imgObjName)
{
	if (document.images)
		document.images[imgDocID].src = eval(imgObjName + ".src")
}

function SetPasswordType(element)
{
	var form = element.form;
	tdpass.innerHTML = '<input type="password" class="login" name="password" id="password" style="width:90px;" value="" onBlur="SetTextType(this)">';
	form.password.focus();
	form.password.focus();
}

function SetTextType(element)
{
var form = element.form;
if (!form.password.value)
{
	tdpass.innerHTML = '<input type="text" class="login" name="password" id="password" style="width:90px" value="Пароль" onFocus="SetPasswordType(this)">';
	frm_login.focus();
}
}

function page(page)
{
	var frm	= document.getElementById('search_form');
	if (frm)
	{
		frm.page.value = page;
		frm.submit();
	}
}
