// scroll newer
scrollStep=3

timerLeft=""
timerRight=""

function toLeft(id){
  document.getElementById(id).scrollLeft=0
}

function scrollDivLeft(id){
  clearTimeout(timerRight) 
  document.getElementById(id).scrollLeft+=scrollStep
  timerRight=setTimeout("scrollDivLeft('"+id+"')",10)
}

function scrollDivRight(id){
  clearTimeout(timerLeft)
  document.getElementById(id).scrollLeft-=scrollStep
  timerLeft=setTimeout("scrollDivRight('"+id+"')",10)
}

function toRight(id){
  document.getElementById(id).scrollLeft=document.getElementById(id).scrollWidth
}

function stopMe(){
  clearTimeout(timerRight) 
  clearTimeout(timerLeft)
}


  var intRegex = /^(0|[0-9][0-9]*)$/; // positive integer values

  function CheckInt (fileld) {

    var data = document.getElementById(fileld);
    if (data.value!='') {
      if (intRegex.test(data.value)==true) {
      } else {
        alert ('Поле должно содержать только числовое значение'); 
        data.value='';
        data.focus();
        return;
      }
    }
  }



function CheckEMail(str_email) {
        if (str_email == null) return false;
        var t = str_email.indexOf("@");
        if ((str_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > str_email.length - 5) || (str_email.charAt(t - 1) == '.') || (str_email.charAt(t + 1) == '.'))  {
        return false;
        }
        return true;
    }

  function CheckEMail2(str_email) {
    t = str_email.indexOf("@");
    if ((str_email.indexOf(".") == -1) || (t == -1) || (t < 1) || (t > str_email.length - 5) || (str_email.charAt(t - 1) == '.') || (str_email.charAt(t + 1) == '.'))  {
    return false;
    }
    return true;
  }

    function CustomCheckForm(c_form, c_mandatory_fields) {
      var error = 0;
    	for(i=0;i<c_mandatory_fields.length;i++) {
        if($("#"+c_form+"_"+c_mandatory_fields[i]).val() == "") {
          error = 1;
          $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
        } else {
          $("#check_"+c_form+"_"+c_mandatory_fields[i]).removeClass('font_red_color');
        }


        if(c_mandatory_fields[i] == 'email') {
          if(CheckEMail($("#"+c_form+"_email").val()) == false) {
            error = 1;
            window.alert("Неверный формат Е-mail !");
            $("#check_"+c_form+"_"+c_mandatory_fields[i]).addClass('font_red_color');
          }
        }

        if(c_mandatory_fields[i] == 'form_question') {
          if($("#form_question1").val() == "" || $("#form_question").val() == "") {
          error = 1;
          window.alert('Вы не внесли оценку работы компании');
          }
        }



      }

      if(error == 1) {
        alert ("Обязательные поля не заполнены !")
        return false;
      }
      else
        return true;
    }

    function CheckFormInput(ref) {

      var _error = 0;
      var _message = "Пожалуйста, заполните поля:\n";
      var _add = "";
      var _class = "";
      if(ref == 1){
        _add = "#";
        _class = "font_red_color";
      }
      else{
        if(ref == 2){
          _add = "#check_";
          _class = "font_red_color_file";
        }
        else{
          _add = "#check_";
          _class = "font_red_color";
        }
      }

      for(i=0;i<mandatory_fields.length;i++) {
        if($("#"+mandatory_fields[i]).val() == ""
           && mandatory_fields[i] != 'email'
           && mandatory_fields[i] != 'smail'
           && mandatory_fields[i] != 'agree'
           && mandatory_fields[i] != 'mail' ) {

          _error = 1
          if(mandatory_fields[i] == 'file')
            $("#check_"+mandatory_fields[i]).addClass('font_red_color_file');
          else
            $(_add+mandatory_fields[i]).addClass(_class);

            _message += ' - '+window[mandatory_fields[i]]+'\n';


        } else {
          if(mandatory_fields[i] == 'file')
            $("#check_"+mandatory_fields[i]).removeClass('font_red_color_file');
          else
            $(_add+mandatory_fields[i]).removeClass(_class);
        }

        if(mandatory_fields[i] == 'email' || mandatory_fields[i] == 'smail' || mandatory_fields[i] == 'mail') {

          if(CheckEMail2($("#"+"email").val()) == false) {
            _error = 1;

            _message += ' - '+window[mandatory_fields[i]]+'\n';

            $(_add+mandatory_fields[i]).addClass(_class);
          } else {
            $(_add+mandatory_fields[i]).removeClass(_class);
          }
        }
        if(mandatory_fields[i] == 'agree') {
          if(document.getElementById('agree').checked != true) {
            _error = 1;

            _message += ' - '+window[mandatory_fields[i]]+'\n';

            $(_add+"check_"+mandatory_fields[i]).addClass(_class+"2");
          } else {
            $(_add+"check_"+mandatory_fields[i]).removeClass(_class+"2");
          }
        }

      }

      if(_error == 1) {
            alert(_message+"field(s)!");
        if(ref == 1)
          RefillAll();

        return false;
      } else
        return true;

    }

function doBookmark() {
 ap=navigator.appName;
 url=location.href;
 t=document.getElementById("pageTitle").innerHTML;

 if (window.sidebar) {
 window.sidebar.addPanel(t,url,'');
 } else if (window.external) {
 window.external.AddFavorite(url,t);
 } else if (window.addNet) {
 addNet(url,t);
 } else {
 alert("Your browser does not support this functionality.\nPlease add the bookmark manually.");
 }
}

var opened_sub_block = '';

function ShowHideSMenu (oElement) {
  var oElementNode = document.getElementById(oElement);
  if (oElementNode.style.display == 'none' ) {
    if(window.opened_sub_block != ''){
      window.opened_sub_block.style.display = 'none';
    }
    window.opened_sub_block = oElementNode;
    oElementNode.style.display = 'block';
  } else {
    oElementNode.style.display = 'none';
  }
}


function go_comnav_url(){
  box = document.getElementById('comnav');
  destination = box.options[box.selectedIndex].value;
  if (destination) location.href = destination;
}

function PrintVersion(cur_id) {
  var cur_id = cur_id || false;
  new_window = null;
  aw = 900;
  ah = 600;

  w=900;
  h=600;

  if (new_window==null || new_window.closed) {
    settings=
    "left=" + (aw-w)/2 + ","
    +"top=" + (ah-h)/2 + ","
    +"screenX=" + (aw-w)/2 + ","
    +"screenY=" + (ah-h)/2 + ","
    +"width=" + w + ","
    +"height=" + h + ","
    +"innerWidth=" + w + ","
    +"innerHeight=" + h + ","
    +"toolbar=no,"
    +"location=no,"
    +"directories=no,"
    +"status=yes,"
    +"menubar=no,"
    +"scrollbars=yes,"
    +"resizable=no"
    new_window = window.open("", '_blank', settings);
  }
  new_window.document.open();
  new_window.document.clear();

  new_window.document.write(
  '<html><head><meta http-equiv="Content-Language" content="ru"><BASE href="http://www.tcm-russia.ru/"><meta http-equiv="Content-Type" content="text/html; charset=windows-1251"><title>'
  +document.getElementById('pageTitle').innerHTML +
  '</title><link rel="stylesheet" href="style/style.css" type="text/css" /><script type="text/javascript" src="js/jquery.js"></script><script type="text/javascript" src="site.js" /></script><style type="text/css">.noprint{display:none;}</style></head><BODY leftMargin=0 topMargin=0 border="0" marginheight="0" marginwidth="0"><div align="center"><table border="0" style="border-collapse: collapse" width="800" cellpadding="5" bgcolor="#FFFFFF"><tr><td rowspan="9" width="32">&nbsp;</td><td height="32" width="100%">&nbsp;</td><td rowspan="9" width="32">&nbsp;</td></tr><tr><td valign="top" width="100%"><table border="0" style="border-collapse: collapse" width="100%" cellpadding="0" ><tr><td><div align="center"><table border="0" style="border-collapse: collapse" width="100%" cellpadding="0" height="70" ><tr><td width="502"><img border="0" src="images/logo_velikan.gif" ></td><td><table border="0" style="border-collapse: collapse" cellpadding="0" align="left"><tr><td width="16"></td><td valign="bottom"><a href="#" style="color:#000;" title="Распечатать" onClick="window.print(); return false;">Распечатать</a></td><td>&nbsp;&nbsp;&nbsp;</td><td  valign="bottom"><a style="color:#000;" href="javascript:window.close()">Закрыть окно</a></td></tr></table></td></tr></table></div></td></tr></table></td></tr><tr><td valign="top" height="30" width="100%">&nbsp;</td></tr><tr><td valign="top" width="100%"><h3>'
  +document.getElementById('topic_title').innerHTML+'</h3>'
  +document.getElementById('main_content').innerHTML+
  '</td></tr><tr><td valign="top" height="32" width="100%">&nbsp;</td></tr></table></div></td></tr><tr><td height="32" width="100%">&nbsp;</td></tr></table></div><script type="text/javascript" />setTimeout("OnDocumentReady(\''+cur_id+'\')",500);  </script></body></html>' );

  new_window.document.close();
  new_window.focus();
}



