function its_empty(string_value){ if(string_value=='' || string_value==null) return true; return false; }

function EmptyFields(it){
  for(var i=0; i<it.elements.length; i++) if(its_empty(it.elements[i].value) && it.elements[i].required == 'true') {
      alert("Ошибка: Не заполнены обязательные поля.\r\n"+it.elements[i].title);
      return false;
    }
  return true;
}

function OpenXF($href, $W, $H){ window.open($href, '', 'toolbar=0, location=0, menubar=0, width='+$W+', height='+$H); }

function vakansFormPrepare(it){
  var errors=[];
  
  if($('FIO').value=="Фамилия, Имя, Отчество" || $('FIO').value=='') 
	errors.push('Заполните поле "Ф.И.О."');
  if($('dolzh').value=="Предполагаемая должность" || $('dolzh').value=='') 
	errors.push('Заполните поле "Предполагаемая должность"');
  if($('tel').value=="Контактный телефон" || $('tel').value=='') 
	errors.push('Заполните поле "Контактный телефон"');
  if($('dohod').value=="Ожидаемый уровень дохода" || $('dohod').value=='') 
	errors.push('Заполните поле "Ожидаемый уровень дохода"');
  if($('EMail').value=="Ваш e-mail" || $('EMail').value=='') 
	errors.push('Заполните поле "Ваш e-mail"');
   
	if (errors.length) {
      var error_msg = "";
      for (var i=0; i<errors.length; i++) {
        error_msg += errors[i]+"\n";
      }
      alert(error_msg);
      return false;
    }
	
	if (!(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($('EMail').value))) 
		{alert('Введите корректный e-mail'); return false;}
	
	$('vakansForm').submit();return true;
}


function anketaFormPrepare(it){
	var errors=[];

	if($('FIO').value=="Фамилия, Имя, Отчество" || $('FIO').value=='') 
		errors.push('Заполните поле "Ф.И.О."');
	if($('vozrast').value=="Возраст" || $('vozrast').value=='') 
		errors.push('Заполните поле "Возраст"');
	if($('dolzh').value=="Предполагаемая должность" || $('dolzh').value=='') 
		errors.push('Заполните поле "Предполагаемая должность"');
	if($('EMail').value=="Ваш e-mail" || $('EMail').value=='') 
		errors.push('Заполните поле "Ваш e-mail"');
	if($('contactTel').value=="Контактный телефон" || $('contactTel').value=='') 
		errors.push('Заполните поле "Контактный телефон"');
	if($('dohod').value=="Ожидаемый уровень дохода" || $('dohod').value=='') 
		errors.push('Заполните поле "Ожидаемый уровень дохода"');
	if($('opit').value=="Опыт работы, год устройства - год увольнения. Название компании, функции, результаты деятельности" || $('opit').value=='') 
		errors.push('Заполните поле "Опыт работы"');
	
	if (errors.length) {
      var error_msg = "";
      for (var i=0; i<errors.length; i++) {
        error_msg += errors[i]+"\n";
      }
      alert(error_msg);
      return false;
    }
	
	if (!(/^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/.test($('EMail').value))) 
		{alert('Введите корректный e-mail'); return false;}
	
	$('orderForm').submit();return true;
}


function orderFormPrepare(it){
	if(document.getElementById('orderer1').value=="Заказчик" || document.getElementById('orderer1').value=='') {alert('Заполните поле "Заказчик"'); return false;};
	if(document.getElementById('trans_model').value=="Модель трансформатора" || document.getElementById('trans_model').value=='') {alert('Укажите модель трансформатора'); return false;};
	if(document.getElementById('kol_order_tt').value=="Количество заказываемых транформаторов" || document.getElementById('kol_order_tt').value=='') {alert('Укажите количество трансформаторов'); return false;};
	
	document.getElementById('orderForm').submit();
	return true;
}


function $(element) {
  if (typeof element == 'string') {
    element = document.getElementById(element);
  }
  return element;
}

  var ar_flashver      = 8;
  var ar_plugin        = 0;
  if(navigator.appName.indexOf('Microsoft') != -1 && navigator.userAgent.indexOf('MSIE') != -1 && navigator.appVersion.indexOf("Windows") != -1 && navigator.userAgent.indexOf('Opera') == -1){
    document.write('<SCRIPT LANGUAGE=VBScript\> \n');
    document.write('on error resume next \n');
    document.write('plugin = CreateObject("ShockwaveFlash.ShockwaveFlash.' + ar_flashver + '") \n');
    document.write('ar_plugin = IsObject(plugin) \n');
    document.write('</SCRIPT> \n');
  }
  else
    if (navigator.plugins && navigator.plugins["Shockwave Flash"]){
      var ar_FlashDescription = navigator.plugins["Shockwave Flash"].description;
      if (ar_flashver <= parseInt(ar_FlashDescription.charAt(ar_FlashDescription.indexOf(".") - 1))) ar_plugin = true;   //>
    }
  //ar_plugin=false;




$top = 1;
$stop = 0;
/*function showTime(){
  if($stop!=-2)
  {
    if($top==$ct) $top=1;
      else $top++;
    for(i=1;i<=$ct;i++)
  {
    if(i==$top) {$('top'+i).style.display='inline';}
    else $('top'+i).style.display='none';
  }
  $aktiv=setTimeout('showTime()',7000);
  }
}
*/
function showTime(){
  if($stop == 1){
    $stop = 2;
    return ;
  }

  if($stop == -2){
    //$top_ = $top;
    $('top'+$top).style.display = 'none';
    /*if($top_>$ct){
      $('top'+$ct).style.display = 'none';
      $top = 1;
    }
    else{
      if($top_ > 1)
        $('top'+($top-1)).style.display = 'none';
    }*/
  }
  else
    if($top>$ct){
      $('top'+$ct).style.display = 'none';
      $top = 1;
    }
    else{
      if($top > 1)
        $('top'+($top-1)).style.display = 'none';
    }

  if($stop < 0){
    $top--;
    if($stop == -1){
      $stop=-2;
      $top--;
    }
    if($top < 1)
      $top = $ct;
  }

  $('top'+$top).style.display = 'inline';

  if($stop < 1){
    if($stop > -1)
      $top++;
    $aktiv = setTimeout('showTime()', 7000);
  }
}
function $(element) {
  if (typeof element == 'string')
    element = document.getElementById(element);
  return element;
}

function showGal(T_Code,Code)
{
  loadHTML("/ajaxGal.php?T_Code="+T_Code+"&Code="+Code,"galPlace");
  $('Gallery').style.display='inline-block';
  $('Gallery').style.height = document.body.offsetHeight;
  $('galPlace').style.display='inline-block';
  $('galPlace').style.top=(document.body.offsetHeight-$('galPlace').offsetHeight)/2;
  $('galPlace').style.left=(document.body.offsetWidth-$('galPlace').offsetWidth)/2;
  slideMargin=0;
  slideValue = 0;
  maxSlide = 0;
}


var dest;
var ddd;
function processStateChange(){
 if (request.readyState == 4){
    contentDiv = document.getElementById(dest);
    if (request.status == 200){
  response = request.responseText;
  contentDiv.innerHTML = response;
      }
    }
  }
function loadHTML(URL, destination){
dest = destination;
if(window.XMLHttpRequest){
    request = new XMLHttpRequest();
    request.onreadystatechange = processStateChange;
      request.open("GET", URL, true);
      request.send(null);
  } else if (window.ActiveXObject) {
  request = new ActiveXObject("Microsoft.XMLHTTP");
      if (request) {
  request.onreadystatechange = processStateChange;
  request.open("GET", URL, true);
  request.send();
      }
    }
  }
function showPhot(path){
if(path)
  {
    $('mainImage').innerHTML = '<img src="/Pages/images/B/'+path+'.jpg">';
  }

}
var slideMargin=0;
var slideValue = 50;
var maxSlide = 0;
function child(id, tag) {
  var node = document.getElementById(id),
  children = node.childNodes,
  i, length = children.length, array = [];
  tag = tag.toUpperCase();
  for(i = 0; i < length; i++) {
    if(children[i].tagName == tag) {
      array.push(children[i]);
    }
  }
  return array;
}

var childArray = new Array();

function slide_right()
{
  if(maxSlide==0)
  {
  childArray = child('Slide','li');
  maxSlide = ((childArray.length - 6) * 70)*(-1);
    slideValue = childArray[0].offsetWidth;
  }


  if(slideMargin>maxSlide)
  {
    slideMargin-=slideValue;
    $('Slide').style.marginLeft=slideMargin;
    
  }
}
function slide_left()
{
  if(slideMargin<0)
  {
    slideMargin+=slideValue;
    $('Slide').style.marginLeft=slideMargin;
  }
}
function hide_gallery(){
  $('Gallery').style.display='none';
  $('galPlace').style.display='none';
}
