function ugras_a_mainapra_flashnaptar(){
	window.location="index.php?modul=personal&almenu=5";
}

function add_ido(ev, honap, nap, select_id, form_nev){
	s = document.getElementById(select_id);
	s.value = ev+"-"+honap+"-"+nap;
	document.getElementById('datum').innerHTML = ev+"."+honap+"."+nap;
	//document.personal.submit();
	return true;
}

function flashnaptar_end() {
}

function getWeek(year,month,day){
    //lets calc weeknumber the cruel and hard way :D
    //Find JulianDay
    month += 1; //use 1-12
    var a = Math.floor((14-(month))/12);
    var y = year+4800-a;
    var m = (month)+(12*a)-3;
    var jd = day + Math.floor(((153*m)+2)/5) +
                 (365*y) + Math.floor(y/4) - Math.floor(y/100) +
                 Math.floor(y/400) - 32045;      // (gregorian calendar)
    //var jd = (day+1)+Math.Round(((153*m)+2)/5)+(365+y) +
    //                 Math.round(y/4)-32083;    // (julian calendar)

    //now calc weeknumber according to JD
    var d4 = (jd+31741-(jd%7))%146097%36524%1461;
    var L = Math.floor(d4/1460);
    var d1 = ((d4-L)%365)+L;
    NumberOfWeek = Math.floor(d1/7) + 1;
    return NumberOfWeek;
}
var mainap = new Date();
var elseje_het=getWeek(mainap.getFullYear(),mainap.getMonth()+1,1);

function popup_up(name,file,width,height,scrollbar,modal) {
	childWindow=window.open(file,name,"modal=yes,width="+width+", height="+height+",scrollbars="+scrollbar);
	if (childWindow.opener == null) childWindow.opener = self;
	childWindow.focus();
}

function biztos(hova,kerdes){
	if (window.confirm(kerdes)){
		window.location.href=hova;
	}

}

function getWeek(year,month,day){
    //lets calc weeknumber the cruel and hard way :D
    //Find JulianDay
    month += 1; //use 1-12
    var a = Math.floor((14-(month))/12);
    var y = year+4800-a;
    var m = (month)+(12*a)-3;
    var jd = day + Math.floor(((153*m)+2)/5) +
                 (365*y) + Math.floor(y/4) - Math.floor(y/100) +
                 Math.floor(y/400) - 32045;      // (gregorian calendar)
    //var jd = (day+1)+Math.Round(((153*m)+2)/5)+(365+y) +
    //                 Math.round(y/4)-32083;    // (julian calendar)

    //now calc weeknumber according to JD
    var d4 = (jd+31741-(jd%7))%146097%36524%1461;
    var L = Math.floor(d4/1460);
    var d1 = ((d4-L)%365)+L;
    NumberOfWeek = Math.floor(d1/7) + 1;
    return NumberOfWeek;
}


var rTimer;
var most;
var utolsosutimentes;
var cookie_tomb;
utolsosutimentes=0;
function TimeTick() {
	var most = new Date();
	var ev=most.getFullYear();
	var ho=most.getMonth()+1;
	if (ho < 10) ho='0'+ho;
	var nap=most.getDate();
	if (nap < 10) nap='0'+nap;
	var ora=most.getHours();
	if (ora < 10) ora='0'+ora;
	var perc=most.getMinutes();
	if (perc < 10) perc='0'+perc;
	var mp=most.getSeconds();
	if (mp < 10) mp='0'+mp;
	document.getElementById('ora').firstChild.nodeValue =''+ev+'.'+ho+'.'+nap+'.'+' '+ora+':'+perc+':'+mp;
	if (cookie_tomb) {
		utolsosutimentes++;
		if (utolsosutimentes == 2) {
			fa_sutibement();
			utolsosutimentes=0;
			//alert('mentve');
		}
	}
	if(rTimer)
		{
			clearTimeout(rTimer);
		}

	rTimer = setTimeout('TimeTick()', 500);
}
function getkey(e) {
	if (window.event)
	   return window.event.keyCode;
	else if (e)
	   return e.which;
	else
	   return null;
}

function leutott(e) {
	var key, keychar;
	key = getkey(e);
//	alert (key);
	if ( key == 13) {
		return true;
	}
	else return false;
}

function entere(event) {
//	alert("asdfdsfsf");
	if (leutott(event)) return false;
	else return true;
}
function popup_up_szgep() {
	childWindow=open("szamologep.php","popup","width=200, height=200, scrollbars=no");
}

function expand(id) { // id id-ju table TR-t láthatóvá tesz
  var e = document.getElementById(id);
  e.style.display = "";
}

function collapse(id) { // id id-ju table TR-t láthatatlanná tesz
  var e = document.getElementById(id);
  e.style.display = "none";
}

function toggle(id) {
//alert(id);
  var e = document.getElementById(id);
  e.style.display = e.style.display == "none" ? "" : "none";
}

var mainap = new Date();
var elsejse_het=getWeek(mainap.getFullYear(),mainap.getMonth()+1,1);

function popup_naptar(select_nev, form_nev){
   newWindow=window.open("popup/popup_naptar.php?select_nev="+select_nev+"&form_nev="+form_nev+"&het="+elsejse_het, 'Naptár', 'width=460, height=165, statusbar=yes');
   if (window.focus) {newWindow.focus()}
}
function popup_naptar_popup(select_nev, form_nev){
   newWindow=window.open("popup_naptar.php?select_nev="+select_nev+"&form_nev="+form_nev+"&het="+elsejse_het, 'Naptár', 'width=170, height=165, statusbar=yes');
   if (window.focus) {newWindow.focus()}
}
function combo_box(pattern, lista_szam, list, id_list, select_nev){

   end_pos = pattern.length;
   szam = 0;
   document.getElementById(select_nev).options.length=0;
   for (i=1; i<=lista_szam; i++){
      reszlet = list[i].substring(0,end_pos);
      keres = pattern.toLowerCase();
      if(keres === reszlet.toLowerCase()){
         //alert("ok");
         szam++;
         lista_elem = new Option(list[i], id_list[i], false, false);
         document.getElementById(select_nev).options[szam] = lista_elem;
      }
   }
   document.getElementById(select_nev).options[0] = new Option("Találatok: "+szam+" db", "0", true, true);
   if(szam == 1) document.getElementById(select_nev).selectedIndex = 1;
}
function rel_todo_user(id,todo_id) {
   newWindow=window.open("popup/user.php?todo_id="+todo_id+"&project_id="+id, 'User list', 'width=800, height=600, statusbar=yes');
   if (window.focus) {newWindow.focus()}
}
function rel_todo_bill(item_id) {
   newWindow=window.open("popup/todo.php?item_id="+item_id, 'Todo list', 'width=800, height=600, scrollbars=yes');
   if (window.focus) {newWindow.focus()}
}

function szamformazo(be,mit) {	//by norbi legalabb reszben
	var e = document.getElementById(be);
	s = e.value;
	number=	s.replace(/\s/g,'');	//spacek kiszedve
	if (mit == 1) {	//mit, ha 1 akkor ugye formaz, ha nem akkor csak a fenti 2 sor fut le
		if (number.length <= 3)
			return (number == '' ? '0' : number);
		else {
			var mod = number.length%3;
			var output = (mod == 0 ? '' : (number.substring(0,mod)));
			for (i=0 ; i < Math.floor(number.length/3) ; i++) {
				if ((mod ==0) && (i ==0))
					output+= number.substring(mod+3*i,mod+3*i+3);
				else
					output+= ' ' + number.substring(mod+3*i,mod+3*i+3);
			}
			e.value=output;		//kimenet=formazott szoveg
		}
	} else {
		e.value=number;	//kulonben a space nelkuli bemenet
	}
	return true;
}

function beirva_br() {
	szamformazo('br',0);
	szamformazo('nt',0);
	szamformazo('afa',0);
	if (document.getElementById('afa').value > 0) {
		document.getElementById('nt').value=parseInt(document.getElementById('br').value)-parseInt(document.getElementById('afa').value);
	}
	szamformazo('br',1);
	szamformazo('nt',1);
	szamformazo('afa',1);
}

function beirva_nt() {
	szamformazo('br',0);
	szamformazo('nt',0);
	szamformazo('afa',0);
	if (document.getElementById('afa').value > 0) {
		document.getElementById('br').value=parseInt(document.getElementById('nt').value)+parseInt(document.getElementById('afa').value);
	}
	szamformazo('br',1);
	szamformazo('nt',1);
	szamformazo('afa',1);
}

function beirva_afa() {
	szamformazo('br',0);
	szamformazo('nt',0);
	szamformazo('afa',0);
	if (document.getElementById('nt').value > 0) {
		document.getElementById('br').value=parseInt(document.getElementById('nt').value)+parseInt(document.getElementById('afa').value);
	}
	else {
		if (document.getElementById('br').value > 0) {
			document.getElementById('nt').value=parseInt(document.getElementById('br').value)-parseInt(document.getElementById('afa').value);
		}
	}
	szamformazo('br',1);
	szamformazo('nt',1);
	szamformazo('afa',1);
}
function jovahagy(mit,item_id){
	var k = window.confirm("Az oldal tartalmaz nem mentett változtatásokat. Kívánja menteni?");
	if(k==true){

		var v = document.getElementById("status");
		v.value = 2;
		document.getElementById(mit).submit();
	} else location.href='bill/form/approve?item_id='+item_id;
}
function divisionValaszto() {
	var a = document.getElementById('assoc');
	var szam = a.value;
	for (i=0;i<a.length-1;i++) {
		if(document.getElementById('div_id['+i+']'))
		document.getElementById('div_id['+i+']').style.display='none';
	}
	szam--;
	document.getElementById('div_id['+szam+']').style.display='';
}
function rejt(mitId) {
	var e = document.getElementById(mitId);
	if (e.style.display == "none") esemeny = 1; // nyitás
	else esemeny = 2; // zárás
	e.style.display = esemeny == 1 ? "" : "none";
}
