<% @page_title = "Sensor | Авторизация" -%>

<style>
@font-face { font-family: ClearSans; src: url('assets/ClearSans-Regular.ttf') fromat('truetype');}
@font-face { font-family: ClearSans; font-weight:bold; src: url('assets/ClearSans-Bold.ttf') fromat('truetype');}
html *{font-size: 1em;font-family: ClearSans !important;-webkit-font-smoothing: antialiased;}
.text_field{
	border:0;
	background:<%= $white %>;
	color:<%= $d_blue %>;
	outline:0;
	width:200px;
	height:30px;
	text-align:center;
	font-size:20px;
	border-bottom:1px solid <%= $gray %>;
	position:absolute;
	top:0px;
}

</style>
<div id="login_name" style="overflow:hidden;transition:1s;width:0px;height:160px;position:absolute;top:calc(50% - 80px);left:calc(50% - 2px);line-height:160px;font-size:80px;color:<%= $d_blue %>;" align="center">
	<div style="top:20px;left:10px;position:absolute;line-height:40px;font-size:26px"><b>DIA</b><b style="color:<%= $red %>">SOFT</b></div>
	<b style="color:<%= $red %>" >SEN</b><b>SOR</b>
</div>
<div id="login_line" style="transition:1s;width:4px;height:0px;position:absolute;top:calc(50% - 0px);left:calc(50% - 2px);background:<%= $d_blue %>"></div>
<div id="login_data" style="overflow:hidden;transition:1s;width:0px;height:160px;position:absolute;top:calc(50% - 80px);left:calc(50% + 2px)">
  <%= form_tag(:controller => 'sessions', :action => "login_attempt", :target => params[:target]) do %>
  		
		<%= image_tag( "language/ru.png", style: "right:150px;top:3px;width:24px;height:24px;position:absolute;cursor:pointer", onclick: "login_change_local('ru')") %>
		<%= image_tag( "language/en.png", style: "right:150px;top:33px;width:24px;height:24x;position:absolute;cursor:pointer", onclick: "login_change_local('en')") %>
    <p><%=  text_field_tag(:username,nil, class: "text_field",placeholder: t(:loginname),style: "right:190px;top:0px;width:200px;height:30px") %></p> 
    <p><%= password_field_tag(:login_password,nil, class: "text_field",placeholder: t(:password),style: "right:190px;top:40px;width:200x;height:30px") %></p> 
		<%= check_box_tag(:ad_auth_check,0,'', style: "display:none") %>
    <%= submit_tag("Login",style: "display:none",id:"login_enter_button") %>
  <% end %>
  <% if LdapParameter.where(:parameter => 'server').first[:value] != nil && LdapParameter.where(:parameter => 'server').first[:value] != '' %>
  <div style="top:85px;right:190px;width:200px;height:30px;line-height:30px;position:absolute">
	<%= render partial: "shared/check_box_v2", locals: {
					id_name:'ad_auth',
					class_name:'',
					style_custom:'',
					top:'0px',
					left:'0px',
					width:'calc(100% - 10px)',
					click_action:'change_ad_auth()',
					hover_action:'',
					text:t(:domain),
					selected:0
	}%>
  </div>
  <% end %>
  <div style="top:125px;right:190px;width:200px;height:30px;line-height:30px" onclick="login_enter_button()" class="button"><b><%= t(:log_in) %></b> <%= image_tag( "login.png", height: "20", width:"20",style:"top:5px;position:relative") %></div>
</div>
<script>
function login_enter_button(){
	document.getElementById('login_enter_button').click()
}
window.onload = function(){
	setTimeout(function() {
		document.getElementById('login_name').style.width='400px'
		document.getElementById('login_name').style.left='calc(50% - 402px)'
		document.getElementById('login_data').style.width='400px'
	}, 1000)
	document.getElementById('login_line').style.height='160px'
	document.getElementById('login_line').style.top='calc(50% - 80px)'
	

}
function login_change_local(locale){
	target='<%= params[:target] %>'
	target_params=''
	if (target.length > 0){
		target_params='&target='+target
	}
	window.open('login?locale='+locale+target_params, '_self')
}
function change_ad_auth(){
	document.getElementById('ad_auth_check').value=cb_ad_auth_value
}
$( "body" ).on( "keyup", function(e) {
	if (e.keyCode == 13) {
		login_enter_button()
	}
});
</script>