function findClass(str, node) 
	{
      if(document.getElementsByClassName) return (node || document).getElementsByClassName(str);
       else {
        var node = node || document;
        var list = node.getElementsByTagName('*');
        var length = list.length;
        var Class = str.split(/\s+/);
        var classes = Class.length;
        var array = []
        var i, j, key;
        for(i = 0; i < length; i++) {
            key = true;
            for(j = 0; j < classes; j++) if(list[i].className.search('\\b' + Class[j] + '\\b') == -1) key = false;
            if(key) array.push(list[i]);
            }
        return array;
            }
    }

function replaceroot(node)
{
    var list = findClass('root', node);
    var i = 0;
    var length = list.length;
    var rootImages = Array (0, 10, 14, 19, 24, 28, 34, 40, 47, 54, 61, 68, 75, 80, 85, 90, 95, 100, 400);
	var rootImagesCount = rootImages.length-1;
	for(i = 0; i < length; i++) 
     {
      var w = list[i].scrollWidth;
	  var j = 0;
	  while (j<rootImagesCount && rootImages[j]<w) 
	  {
		  j++;
	  }
	  list[i].style.background = "url(../Icons/root/root"+rootImages[j]+".gif) no-repeat 50% 0%";
	  list[i].style.lineHeight = "22px";
     }
    
	list = findClass('suffix', node);
    length = list.length;
    rootImages = Array (0, 5, 7, 9, 11, 13, 15, 17, 19, 23, 27, 31, 37, 43, 51, 61, 71, 101);
	rootImagesCount = rootImages.length-1;
	for(i = 0; i < length; i++) 
     {
      var w = list[i].scrollWidth;
	  var j = 0;
	  while (j<rootImagesCount && rootImages[j]<w) 
	  {
		  j++;
	  }
	  list[i].style.background = "url(../Icons/root/suffix"+rootImages[j]+".gif) no-repeat 50% 0%";
	  list[i].style.lineHeight = "22px";
     }
}


function GoLink(arc, id)
{
  window.open('../' + arc +'/' + id + '.xml','tooltip','copyhistory=no');
}

function GoTo(arc, id)
{
  window.location.href = '../' + arc +'/' + id + '.xml';
}

function GoTest(id)
{
  window.open('../2010/runtest.html#tid='+id,'test','copyhistory=no');
}

function analize()
{
 var q = window.location.hash;
 if (q.indexOf("run")>-1)
 {
  var list = findClass('testheader',document);
  if (list.length>0)
  {list[0].onclick();}
  else
  {
   list = findClass('task',document);
   if (list.length>0)
    {list[0].onclick();}
  }
 }
}

function initall()
{
  replaceroot(document);
  analize();
}
