<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="sl-si" lang="sl-si" class="ozadje" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>MindIT | Login</title>
  <meta name="keywords" content="MindIt" />
  <meta name="description" content="MindIt" />
  
  <link href="_css/main.css" rel="stylesheet" type="text/css" />
  <script type="text/javascript" src="_javascript/jquery.js"></script>
		<style type="text/css">
			.hole {

 				padding: 0px;
				height: 600px;width: 800px;
				}

				.loginErrorMsgTitle {
					padding-top:2px;
					font: 26px tahoma,arial,helvetica,sans-serif
				}
				.loginErrorMsg{

					font: 14px tahoma,arial,helvetica,sans-serif
				}
				/* Z-index of #mask must lower than #boxes .window */
				#mask {
				  position:absolute;
				  z-index:9000;
				  background-color:#000;
				  display:none;
				}

				#boxes .window {
				  position:absolute;
				  width:440px;
				  height:200px;
				  display:none;
				  z-index:9999;

				   background-color:#ced9e7;
				}


				/* Customize your modal window here, you can add background image too */
				#boxes #dialog {
				  width:300px;
				  height:150px;
				}
		</style>
</head>
<body leftmargin="0" marginwidth="0">

  <div id="stranp">
    <div id="logo_rest_t">
     <!-- <div class="logo" style="margin-left:16%;">
      
      </div>
      <div class="logo_sr">
         Uporabniško ime ali geslo ni pravilno.
      </div> -->
    </div>
    <div id="logo_rest_b">
      <div class="sdr" style="margin-top:-20px;">
      	<img src="http://www.elixormedical.si/kepek/elixor_logo.png">
      	<br /><b>MindIt</b> je spletno orodje za ,......
       </div>
      <div class="sdl">
      	 <div style="display:none" id="errorLoginMsg"> 
      	 <div class="nap"></div><div class="vnos" style="margin-left:10px;" >Uporabniško ime ali geslo ni pravilno.</div>
         </div>
      	 <div class="nap">Uporabniško ime</div><div class="vnos"><input name="user" id="username" type="text" value="" /></div>
         <div class="nap" style="clear:both">Geslo</div><div class="vnos"><input name="pass" id="password" type="password" value=""/></div>
         <div class="nap" style="clear:both"></div><div class="vnos" style=" margin-left:10px;"><a href="#" style="color:#3c6a80;font-size:16px;"></a><a href="#"><div id="loginBtn" class="shrani">Vstopite</div></a></div>
      </div>
      <div id="noga_p">
        &copy; 2014 Elixor & mindIT
      </div>
    </div>
  </div>
<script>
	// temp variable for checking if we need to focus password after pressing Enter key
	var usernameFocus = 1;
    var showError = 0;

	// if you click on button Login we check if login parameters are ok with function checkLogin
    $('#loginBtn').click(checkLogin);

   

    // ajax function which checks if login parameters are correct
    function checkLogin() {
    	$("#errorLoginMsg").hide();	
    	$.ajax({
         		url: "<?php echo PATH_TO_ROOT;?>_ajaxManipulators/ajax.Login.php",
         		data: 'action=login&survey=1&user='+$('#username').val()+'&pass='+$('#password').val(),
         		success: function(data){
         			if (data == 'true') {
         					document.location = 'index.php';
         			} else {
	  					$("#errorLoginMsg").show();	 
         			}
      			}
         	});
    }


  
	$(document).keydown(function(e){
		if (e.which == '13' && usernameFocus == 1 ) {
			// on Enter keydown and focus on username change focus to password field
			$('#password').focus().select();
			usernameFocus = 0
		} else if (e.which == '13' && showError == 0 ) {
			// on Enter keydown take off focus from password and username fields
			$('#password').blur();
			$('#username').blur();
			checkLogin();
		} else if (e.which == '27' || ( e.which == '13' && showError == 1)) {
			
			showError = 0;
			$('#username').focus().select();
		}
	})

	//on startup focus on username
	$('#username').focus();
	// if focus on username temp variable usernameFocus set to 1. If you click enter automaticaly focus password field
	$('#username').focusin(function(){ usernameFocus = 1;})
	$('#password').focusin(function(){ usernameFocus = 0;})
</script>

</body>
</html>