function openNav() {
	document.getElementById("myNav").style.width = "calc(100% + 10px)";
	document.getElementById('closebuta').style.display = 'block';
}
function closeNav() {
	document.getElementById("myNav").style.width = "0%";
	document.getElementById('closebuta').style.display = 'none';
}
function openSearch() {
	document.getElementById("mySearch").style.width = "calc(100% + 10px)";
	document.getElementById('closebutb').style.display = 'block';
}
function closeSearch() {
	document.getElementById("mySearch").style.width = "0%";
	document.getElementById('closebutb').style.display = 'none';
}

// Zählt Zeichen bei Eingabe
function count_chars(_text,_max,_elm) {
	var div = document.getElementById(_elm);
	var str = (_max - _text.length);
	div.innerHTML = str;
	if(_text.length > _max) {
		alert('Du darfst maximal ' +_max + ' Zeichen eingeben!');
	}
}

// Overlay
function ovon() {
	$("#over1").show();
	$("#over2").hide();
	document.getElementById("overlay").style.display = "block";
}
function ovoff() {
	document.getElementById("overlay").style.display = "none";
}

/* Check all Checkboxes */
function checkAll(o) {
	var x = document.getElementsByClassName(o);
	var i;
	for (i = 0; i < x.length; i++) {
		if (x[i].type == "checkbox") {
			x[i].checked = true;
		}
	}
}

function linecount(div){
	
	var diva = document.getElementById(div);
	
	var lin = diva.value.split("\n").length;
	if(lin > 4){
		diva.style.cssText = 'height:auto; padding:0';
		console.log("xx--"+diva.scrollHeight);
		diva.style.cssText = 'height:' + diva.scrollHeight + 'px';
		//document.getElementById(div).style.cssText.height = "200px";
		
		}
	console.log("jj-"+lin);
}


function txtsticky(div){
	
	var io= 120;
	var lex ="asd asd";
	
	var diva = document.getElementById(div);	
	diva.classList.toggle("mystyle");
	
	diva.querySelector('textarea').value= lex;
	
	//diva.querySelector('textarea').value='Let´s go!';
	//diva.querySelector('textarea').focus();
	//diva.querySelector('textarea').click();
	var x = diva.classList.contains('mystyle');
	
	if(x == true){
		diva.querySelector('textarea').focus();
		diva.querySelector('textarea').style.height = io+"px";
//		document.getElementById('momo').focus();
		//document.documentElement.style.position = "fixed";
		//document.documentElement.style.height = "240px";
		
		 var w = window.innerWidth;
		var h = window.innerHeight;
		//alert("W:"+w+" - H:"+h);
		console.log("W:"+w+" - H:"+h);

	}else{
		document.documentElement.style.position = "";
		//window.removeEventListener('scroll', noScroll);
	}

}

/* BigTXT-Formular prefill*/
function getbigtxt(a){
	var splitted = a.split("_",3,toggleDiv);
	
	toggleDiv('komtex');
	toggleDiv('texadiv');
	toggleDiv('texadiv2');
	
	var top = document.getElementById('end').offsetTop;
	window.scrollTo(0, top);

	document.getElementById("txttit").innerHTML = splitted[2];
	document.getElementById("txttyp").value = splitted[0];
	document.getElementById("txtnum").value = splitted[1];
	alert("OK");
	document.getElementById("texa").focus();
	

	if(splitted[3]===true){	
	}
}

/* Textarea vergrößern */
var textarea = document.getElementById('texa');
textarea.addEventListener('keydown', autosize);
 

function sizeup(div){
	
	var el = this;
	var texadiv = document.getElementById(div);
	console.log(el.style);
	setTimeout(function(){
		el.style.cssText = 'height:auto; padding:0';
		console.log(el.scrollHeight);
		el.style.cssText = 'height:' + el.scrollHeight + 'px';
		texadiv.style.height = el.scrollHeight + 13 + 'px';
	},0);
}


function autosize(){
	var el = this;
	var texadiv = document.getElementById('texadiv');
	var btbu = document.getElementById('bigtxtbut');

	setTimeout(function(){
		el.style.cssText = 'height:auto; padding:0';
		console.log(el.scrollHeight);
		el.style.cssText = 'height:' + el.scrollHeight + 'px';
		texadiv.style.height = el.scrollHeight + 13 + 'px';
		btbu.style.height = (el.scrollHeight-30) + 'px';
	},0);
}

function haha(xx){
	xx.style.height = "180px";
	var ta = document.getElementById("JOA");
	var ss = document.getElementById("titel");

	ss.style.display="block";
	ta.style.height = "200px";
}

/* Toggle DIV */
function toggleDiv(divid){
	var div = divid;
	//alert("JAULER");
	var res	= div.split("#");
	
	console.log(res);
	//alert(res[0]);
	//alert(res[1]);
	
	var divi	= res[0]+res[2];
	//alert(divi);
	
	var xer = document.getElementById(divi).style.display;
	
	
	var divi2	= document.getElementById(divi);	
	
	var x = divi2.style;
	
	console.log(xer + "--" + x);
	
	if(x.display == 'none' || x.display == ''){
		x.display = 'block';     
	}else{
		x.display = 'none';
	}
}

/* Haupt-Textfeld schliessen */
function lala(div,divorig,divorig2){
	var xx=document.getElementById("texa").value;
	
	var diva=document.getElementById(divorig2);
	diva.querySelector('textarea').value=xx;

	var diva2=document.getElementById(div);
	diva2.querySelector('textarea').value=xx;

	toggleDiv(div);
	toggleDiv(divorig2);
	toggleDiv(divorig);
}
/*MAGAZIN*/
function scro(ele){
	var elmnt = document.getElementById(ele);
	elmnt.scrollIntoView();
}