﻿function childs(id) {
    var d = document.getElementById(id);
    var src = '';
    
    if (d) {
        var dl = d.getElementsByTagName('div');
        for (var i=0;i<dl.length;i++) {
            if (dl[i].className == 'hfolder') {
                dl[i].className = 'folder';
                src = '/images/arr_d.gif';
            } else if (dl[i].className == 'folder') {
                dl[i].className = 'hfolder';
                src = '/images/arr_r.gif';
            } else if (dl[i].className == 'hsec' && dl[i].parentNode==d) {
                dl[i].className = 'sec';
                src = '/images/arr_d.gif';
            } else if ((dl[i].className == 'sec' || dl[i].className == 'ssec')&& dl[i].parentNode==d) {
                dl[i].className = 'hsec';
                src = '/images/arr_r.gif';
            }
        }
        var img = document.getElementById(id.replace('s','i'));
        if (img) {
            img.src = src;
        }
    }
}
function locate(id) {
    var d = document.getElementById(id);
    var root_id = '';
    if (d) {
        if (d.nodeName == 'DIV' && d.id ) {
            root_id = d.id;
            
            
            if (d.className == 'sec' || d.className == 'hsec'){
                d.className = 'ssec';
            }
            if (d.className == 'folder' || d.className == 'hfolder'){
                d.className = 'sfolder';
            }
        }
        d = d.parentNode;
        while (d) {
            if (d.nodeName == 'DIV' && d.id) {
                if (d.className=='catalog' || d.className=='folder' || d.className=='hfolder'){
                    root_id = d.id;
                    force_childs(d);
                }
            }
            d = d.parentNode;
        }
    }
}

function force_childs(d) {
    var dl = d.getElementsByTagName('div');
    if (d.className == 'hfolder') {
        d.className = 'folder';
    }
    var img = document.getElementById(d.id.replace('s','i'));
    if (img) {
        img.src = '/images/arr_d.gif';
    }
    for (var i=0;i<dl.length;i++) {
        if (dl[i].className == 'hfolder' && dl[i].parentNode==d) {
            dl[i].className = 'folder';
            continue;
        } else if (dl[i].className == 'hsec' && dl[i].parentNode==d) {
            dl[i].className = 'sec';
            continue;
        }
    }
}

function buy(cur) {
    document.form1.type_curr.value = cur;
    document.form1.submit();
}
function addbookmark() {

  var url = 'http://keysshop.ru'; 
  var title = 'KeysShop.RU:Магазин выгодных цен'; 
  
  //Gecko 
  if ((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) window.sidebar.addPanel (title, url, ""); 
  //IE4+ 
  else if (typeof window.external == "object") window.external.AddFavorite(url, title); 
  //Opera7+ 
  else if (window.opera && document.createElement) 
  { 
    var a = document.createElement('A'); 
    if (!a) return false; //IF Opera 6  
    a.setAttribute('rel','sidebar'); 
    a.setAttribute('href',url); 
    a.setAttribute('title',title); 
    a.click(); 
  } 
  else return false; 
  
  return true; 
}
