<script>
	function checkSubject(){
		if(document.getElementById("newPostSubject").value!=""){
			if(document.getElementById("newPostSubject").value.length<5){
				document.getElementById("subjectSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
				document.getElementById("subjectChecker").innerHTML="0";	
			}else{
				document.getElementById("subjectSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;'>";
				document.getElementById("subjectChecker").innerHTML="1";	
			}		
		}else{
			document.getElementById("subjectSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
			document.getElementById("subjectChecker").innerHTML="0";	
		}
	}
	
	function checkPost(){
		if(document.getElementById("newPost").value!=""){
			if(document.getElementById("newPost").value.length<5){
				document.getElementById("postSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
				document.getElementById("postChecker").innerHTML="0";	
			}else{
				document.getElementById("postSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='17' width='18' style='margin-left:10px;'>";
				document.getElementById("postChecker").innerHTML="1";	
			}			
		}else{
			document.getElementById("postSpan").innerHTML="<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
			document.getElementById("postChecker").innerHTML="0";	
		}
	}
	
	document.addEventListener("keyup", function(){
		if(document.getElementById("subjectChecker").innerHTML=="1" && document.getElementById("postChecker").innerHTML=="1"){
			document.getElementById("headStatus").innerHTML="<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/yes.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Nové hlásenie:</h3>";		
			document.getElementById("submitSpan").style.visibility = "visible";	
		}else{
			document.getElementById("headStatus").innerHTML="<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/Exclamation.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Nové hlásenie:</h3>";					
			document.getElementById("submitSpan").style.visibility = "hidden";
		}	
	});
</script>
<?php
	
 
		
	if ($this->session->userdata('permisson')==4 OR $this->session->userdata('permisson')==3 OR $this->session->userdata('permisson')==2) {
		$CI =& get_instance();
		$CI->load->library('libraryprofile');
		switch($this->session->userdata('permisson')){
			case 4: 
				$CI->libraryprofile->showMenuBarEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));
			break;
			case 3: 
				$CI->libraryprofile->showMenuBarDriver($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));			
			break;
			case 2: 
				$CI->libraryprofile->showMenuBarLeadEmployee($this->session->userdata('meno'),$this->session->userdata('priezvisko'),$this->session->userdata('id_zamestnanca'));
			break;
		}

		$this->load->helper("employee_helper");
		
		echo '<div id="default_container" style="height:340px">';
			echo '<span id="headStatus">';
			echo "<h3 style='padding-top:12px'><img src='http://martinbendik.studenthosting.sk/pictures/Exclamation.png' height='20' width='20' align='middle' style='padding-bottom:12px;padding-right:15px'>Nové hlásenie:</h3>";
			echo '</span>';
				echo "<span id='subjectSpan'style='position:absolute; margin-left:650px; margin-top:18px'>";
					echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
				echo "</span>";
				echo "<div id='subjectChecker' hidden>";
					echo "0";
				echo "</div>";
				
				echo "<span id='postSpan' style='position:absolute; margin-left:650px; margin-top:195px'>";
					echo "<img src='http://martinbendik.studenthosting.sk/pictures/no.png' height='17' width='18' style='margin-left:10px;'>";
				echo "</span>";
				echo "<div id='postChecker' hidden>";
					echo "0";
				echo "</div>";				
				
				echo form_open(base_url('main/saveNewPost'));
					echo "<p style='margin-left:50px;margin-top:15px'><b>Predmet: </b>";						
						echo form_input("newPostSubject",'' , 'id="newPostSubject" onkeyup="checkSubject()" class="login_textarea" style="margin-left:30px; width:500px"');					
					echo "</p>";										
					
					echo "<p style='margin-left:50px;margin-top:20px'><b>Hlásenie:</b></p>";
				echo '<textarea name="newPost" id="newPost" class="login_textarea" onkeyup="checkPost()" style="position: absolute;margin-left:142px; width:499px; margin-top:-20px; height:150px"></textarea>';	
				
				echo "<div class='vehicle_div' style='align:center; margin-top:155px; margin-bottom:10px'></div>";
				
				echo '<div class="button-group" style="margin-left:50px;margin-top:5px">';				
					echo '<a href="javascript:window.history.go(-1);" class="button">Späť</a>';
					echo '<span id="submitSpan">';			
						echo form_submit('input_form_submit' , 'Uložiť', 'class="button"');	
					echo '</span>';	
				echo '</div>';
				echo form_close();
		echo '</div>';			
	} else {
		redirect(base_url('main/restricted'));
	}		
?>


