// JavaScript Document
function getMailForm(oper){
    var form = document.getElementById("contact_form");
    if(oper.indexOf("close") >= 0){
        form.style.display = "none";
    } else {  
        form.style.opacity = "0";
        form.style.display = "block";
        form.style.opacity = 10;
    }
}
function resizeCors(values,id){
    //получаем элементы
    var elem = document.getElementById(id);
    if(elem != null){
      var element = elem;
      oldValue = element.value;
    tdElem = element.parentNode;
    tdId = tdElem.getAttribute("class");
    var cnt_money = document.getElementById("center_"+tdId);
    cnt_money_input_name = cnt_money.getElementsByTagName("input")[0].getAttribute("name");
    var rg_money = document.getElementById("right_"+tdId);
    //--    
    //изменяем содержимое
    money_old = parseInt(rg_money.innerHTML.split("<")[0]);
    money_one = money_old/oldValue;
    money_n = money_one*parseInt(values);
    money_new = Math.round(money_n);
    rg_money.innerHTML="";
    rg_money.innerHTML = ""+money_new;
    if(cnt_money != null){    
      cnt_money.innerHTML="";
      textElCnt = document.createTextNode(""+money_new);
      inputElem = document.createElement("input");
      inputElem.setAttribute("type","hidden");
      inputElem.setAttribute("name",cnt_money_input_name);
      inputElem.setAttribute("value",money_new);
      cnt_money.appendChild(textElCnt);
      cnt_money.appendChild(inputElem);
    }
    if(element != null){    
    element.value = values;
    }
    }
    //--
}
function getOneSearch(log,cont){
    var standart = document.getElementById("stand");
    var search = document.getElementById("search");
    search.value = cont;
    standart.value = log;
    scrolling();    
}
function scrolling(){
    x = document.body.scrollTop;
    x --;
    scrollTo(x,0);
    if(x <= 0){
      return false;
    } else {
        setTimeout(function(){scrolling();},100);
    }
}
function goImage(imgName){
    var newWin = window.open("http://pkmspb.ru/wp-content/themes/PKM/getImg.php?img="+imgName,
                              "imgOpen",
                              "width=560, height=400, resizable=no,scrollbars=no,status=no"
                            );
         newWin.moveTo(250,200);                   
}
function visibleAll(other,id,iden){
    var elem = document.getElementById(id);
    elements = elem.getElementsByTagName("tr");
    other.style.display = "none";
    for(var y=0; y<elements.length; y++){
        if(elements[y].hasAttribute("id")){
            attr = elements[y].getAttribute("id");
            if(attr.indexOf(""+ iden +"") >= 0){
                elements[y].style.display = "block";
            }
        }
    }
}
function noneVisibleAll(other,id,iden){
    var elem = document.getElementById(id);
    elements = elem.getElementsByTagName("tr");
    document.getElementById(other).style.display = "block";
    for(var y=0; y<elements.length; y++){
        if(elements[y].hasAttribute("id")){
            attr = elements[y].getAttribute("id");
            if(attr.indexOf(""+ iden +"") >= 0){
                elements[y].style.display = "none";
            }
        }
    }
}
