var mImages = Array(100);
var mComments = Array(300);
var CurImage = "myImageID_0";

function changeComment(iNum)
{
	//document.TEXT_FORM.CHANGABLE_COMMENT.value = mComments[iNum];
	document.getElementById('okey').innerHTML = mComments[iNum];
}
var CurImage = "link_" + 0;
var cm = 0;
var mas = Array(100);
function changeImage(name, src, elem, id, cimg)
{
    var rimg = document[name];
    var img = document.getElementById(CurImage);

    if (img.style)
    {
        img.style.backgroundColor = '#BADA7A';
        img.style.color = '#C7DE99';
    }
    
    var m_img = mas[cimg];
    //alert(cimg);
    var w = m_img.width;
    var h = m_img.height;
    if (m_img.width > 300)
    {
        w=300;
        h = Math.round(w*m_img.height/m_img.width);
    }
    if (h > 300)
    {
        h=300;
        w = Math.round(h*m_img.width/m_img.height);
    }


    if (elem.style)
    {
        elem.style.backgroundColor = '#C7DE99';
        elem.style.color = '#BADA7A';
        CurImage = id;
    }
    w = 500;
    h = 333;
    m_img.width = w;
    m_img.height = h;
    
    rimg.src = m_img.src;
    rimg.width = w;
    rimg.height = h;
}
var brname=navigator.appName, BrVer='';
if(brname.substring(0,2)=="Mi")
	BrVer='E';
var timer = 0;
lastid = -1;
function showKampas(id)
{
	var ob = document.getElementById('menu_pointer_'+id)
	ob.src = "/bitrix/templates/tfk/images/menu_pointer.gif"
}
function hideKampas(id)
{
	var ob = document.getElementById('menu_pointer_'+id)
	ob.src = "/bitrix/templates/tfk/images/menu_pointer_.gif"
}

function show(id)
{
	if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
		return;
	clearTimeout(timer);
	if((id != lastid) && (lastid!=-1))
		((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'hidden';
	hideElement("SELECT", document.getElementById('menu'+lastid));
	lastid = id;
	((document.all)?document.all['menu'+lastid]:document.getElementById('menu'+lastid)).style.visibility = 'visible';
}

function hidden(id)
{
	if(!((document.all)?document.all['menu'+id]:document.getElementById('menu'+id)))
		return;
	showElement("SELECT");
	timer = setTimeout("if('"+id+"' == '"+lastid+"'){((document.all)?document.all['menu"+lastid+"']:document.getElementById('menu"+lastid+"')).style.visibility = 'hidden';}", 000)
}


function GetPos(el)
{
	if (!el || !el.offsetParent)return false;
	var res=Array()
	res["left"] = el.offsetLeft;
	res["top"] = el.offsetTop;
	var objParent = el.offsetParent;
	while (objParent.tagName.toUpperCase()!="BODY")
	{
		res["left"] += objParent.offsetLeft;
		res["top"] += objParent.offsetTop;
		objParent = objParent.offsetParent;
	}
	res["right"]=res["left"]+el.offsetWidth;
	res["bottom"]=res["top"]+el.offsetHeight;
	return res;
}

function hideElement(elName, Menu)
{
	if(BrVer!='E') return;
	for (i = 0; i < document.all.tags(elName).length; i++)
	{
		Obj = document.all.tags(elName)[i];
		if(!(pMenu=GetPos(Menu)))continue;
		if(!(pObj=GetPos(Obj)))continue;

		if(pObj["left"]<pMenu["right"] && pMenu["left"]<pObj["right"] && pObj["top"]<pMenu["bottom"] && pMenu["top"]<pObj["bottom"])
			Obj.style.visibility = "hidden";
	}
}

function showElement(elName)
{
	if(BrVer!='E') return;
	for (i = 0; i < document.all.tags(elName).length; i++)
	{
		obj = document.all.tags(elName)[i];
		if (!obj || !obj.offsetParent)continue;
		if(obj.style.visibility=="hidden")
			obj.style.visibility = "visible";
	}
}
function atidaryk(psl, title)
{
	var X = screen.width / 2 - 500/2;
	var Y = screen.height / 2 - 400/2;
	//alert(w); alert(h);
	var img = new(Image);
	img.src = psl;
	//alert(img.width);
	w=img.width;
	h=img.height;
	myWin= open("", "displayWindow", "width="+w+", height="+h+", status=no, toolbar=no, menubar=no, resizable=yes, left="+X+", top="+Y+"");
	myWin.document.open();
	myWin.document.write("<html><head><title>"+title+"</title>");
	myWin.document.write("</head><body topmargin=0 leftmargin=0>");
	myWin.document.write("<a href='javascript:close()'><center><img src="+psl+" border=0></center></a>");
	myWin.document.write("</body></html>");
	myWin.document.close();
}
