function check(id_1, id_2){
    var elem = document.getElementById(id_2);
    if(document.getElementById(id_1).checked){
      elem.disabled = true;
    }else {
      elem.disabled = false;
    }
}
    function get(id){
      return document.getElementById(id).value;
    }

    function getNChange(dd, voc){
        document.getElementById(dd).value = voc;
        hideProgress();
    }

       function submit(id) {
          document.getElementById(id).submit();
      }

      function ajaxonsubmit(id){
        clear_element('sys_messages');
        var form = document.getElementById(id);
          if(form.onsubmit()){
            form.submit();
          }
      }

  function clear_element(id){
    var elem = document.getElementById(id), child;
      while(child = elem.firstChild){
        elem.removeChild(child);
      }
   }

  //===================================== Pagination scripts =====================================

  // Function for get page parameter
  function getUrlVars(str){
    var vars = [], hash;
    var hashes = str.slice(str.indexOf('?') + 1).split('&');
    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
  }

  // Function for set pagination for will_paginate plugin
  // To use it you will need to add class to will_paginate and define this function in view.
  // Example: <%= will_paginate @objects, :class => "ajax pagination" %> ;
  // in view: <script> ajax_pagination(".ajax.pagination", url) </script> ;
  // (url for example can be '/engineer/project/some_ajax_method'

  function ajax_pagination(class_name, link){
    document.observe("dom:loaded", function() {
      var container = document.body;
      if (container) {
        container.observe('click', function(e) {
          var el = e.element();
          if (el.match(class_name + ' a')){
            el.up(class_name);
            var url = link + "?page=" + getUrlVars(el.href)["page"];
            new Ajax.Request(url, { method: 'get' });
            e.stop()
          }
        });
      }
    });
  }
  //==============================================================================================

   function link_to_unless_set_class(id){
     alert('sdadasas');
     var elem = document.getElementById(id);
     if(elem.className == 'button_inside'){
       elem.className = 'button_inside_current';
     } else{
       elem.className = 'button_inside';
     }
   }

  function stripHTML(text){
    text = text.replace(/(&nbsp;)/gi, " ");
    text = text.replace(/(<([^>]+)>)/gi, " ");
    return text;
  }

  function submit_form(form_id, inputs){
     var errors = "";
     var email_reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

     for(var i = 0; i < inputs.length; i++){
       var form = document.getElementById(inputs[i][0]);
       var has_errors = false;
       if(form.value == ""){
         errors += form.id + " cannot be blank\n";
         has_errors = true;
       }else if(inputs[i][1] && (form.value.length < inputs[i][1] && inputs[i][1] != 0)){
         errors += form.id + " is less then " + inputs[i][1] + " symbols\n";
         has_errors = true;
       }else if(inputs[i][2]){
         if(!email_reg.test(form.value)){
           errors += "Wrong " + form.id + " format\n";
           has_errors = true;
         }
       }
       if(has_errors){
         form.style.border = "2px solid red";
       }else {
         form.style.border = "";
       }
     }
     if(errors == ""){
       document.getElementById(form_id).submit();
     }else {
       alert(errors);
     }
  }
