function checkFieldText(elem, svalidator, smessage) {
  
  if (elem.value.match(svalidator)) return true;
  
  alert(smessage);
  elem.focus();
  return false;
  
}

function checkFieldSelect(elem, ivalue, smessage) {
  
  if (elem.value != ivalue) return true;
  
  alert(smessage);
  if (!elem.disabled) elem.focus();
  return false;
  
}

function checkFieldCheckBox(elem, smessage) {
  
  if (elem.checked) return true;
  
  alert(smessage);
  if (!elem.disabled) elem.focus();
  return false;
  
}

function confirmPassword(obj1, obj2) {
  
  if (obj1.value != obj2.value) {
    alert('Пожалуйста, подтвердите пароль!');
    obj2.focus();
    return false;
  }
  
  return true;
}

function fixPNG(element) {
  
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
    
    var src;
    
    if (element.tagName=='IMG') {
    
      if (/\.png$/.test(element.src)) {
        src = element.src;
		  	element.src = "/image/0.gif";
		  }
		
    } else {
        
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      
      if (src) {
			
        src = src[1];
			
        element.runtimeStyle.backgroundImage="none";
      }
    }
		
    if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
	}
}

function showAuthForm() {
  
  var req = new JsHttpRequest();
  
  req.onreadystatechange = function() {
    
    if (req.readyState == 4) {
      
      if (req.responseJS) {
        
        var tmp = $_j('#auth_div');
        
        tmp.css('display', 'block');
        tmp.css('visibility', 'visible');
        
        tmp.append(req.responseJS.content);
        
        $_j('#shadow_page').css('opacity', 0.67);
        
        if (!$_j('input[name=auth_login]').attr('value')) $_j('input[name=auth_login]').focus();
        
      }
    }
  }
  
  req.open('POST', '/rs/auth_user_form/', true);
  req.send();
  
}

function closeAuthForm() {
  
  var tmp = $_j('#auth_div');
  
  tmp.css('display', 'none');
  tmp.css('visibility', 'hidden');
  tmp.empty();
  
  return false;
  
}

function switchProgress(f) {
  
  var tmp = $_j('#o_m');
  tmp.css('display', (f ? 'block' : 'none'));
  tmp.css('visibility', (f ? 'visible' : 'hidden'));
  
}
