function MM_findObj(n, d) { 
	var p,i,x;  
	if(!d)d=document; 
	if((p=n.indexOf("?"))>0&&parent.frames.length){
		d=parent.frames[n.substring(p+1)].document; 
		n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all)x=d.all[n]; 
	for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  	for(i=0;!x&&d.layers&&i<d.layers.length;i++)x=MM_findObj(n,d.layers[i].document);
  	if(!x && document.getElementById)x=document.getElementById(n); 
	return x;
}

function turnDiv(d){
	tmpObject=MM_findObj(d);
	if(tmpObject.style.display=='none'){
		tmpObject.style.display='';
	} else {
		tmpObject.style.display='none';
	}
}

function turnDivOn(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='';
}

function turnDivOff(d){
	tmpObject=MM_findObj(d);
	tmpObject.style.display='none';
}

function bigpicview(piclink, width, height){
	x=(screen.width-width)/2;
	y=(screen.height-height)/2;
	window.open('/picview.php?pic='+piclink, 'bpv', 'width='+width+', height='+height+', left='+x+', top='+y+', resizeable=0, scrollbars=0');
}

function changeClass(ele,cls){
	row.className=cls;
}

function changeRowClass(ele,cls){
	row=document.getElementById(ele);
	row.className=cls;
}

function js_in_array(a,v){
	for(js_in_i=0;js_in_i<a.length;js_in_i++){
		if(a[js_in_i]==v)return true;
	}
	return false;
}


//cross frame spoofing
//if(parent!=self)top.location.href=location.href;

//fotoalbum
var albumpopUp='/photoalbum_popup.php';
var albumpopW=600;
var albumpopH=565;
//var albumpopUp='<? echo $cfg['site']['fotoalbum_popup']; ?>';
//var albumpopW=<? echo $cfg['site']['fotoalbum_popup_width']; ?>;
//var albumpopH=<? echo $cfg['site']['fotoalbum_popup_height']; ?>;

function fotoAlbum(albumid){
	winleft=(screen.width-albumpopW)/2;
	winUp=(screen.height-albumpopH)/2;
	winProp='width='+albumpopW+',height='+albumpopH+',left='+winleft+',top='+winUp+',scrollbars=0,resizable';
	Win=window.open(albumpopUp+'?id='+albumid, 'fotoAlbum', winProp);
}

function is_email(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false
	 }

	 return true					
}

var newsAlbumPopUp='/news_photoalbum_popup.php';
var newsAlbumPopW=900;
var newsalbumPopH=700;

function newsFotoAlbum(albumid,lan,pid){
	winleft=(screen.width-newsAlbumPopW)/2;
	winUp=(screen.height-newsalbumPopH)/2;
	winProp='width='+newsAlbumPopW+',height='+newsalbumPopH+',left='+winleft+',top='+winUp+',scrollbars=0,resizable';
	Win=window.open((lan==''?'':'/'+lan)+newsAlbumPopUp+'?id='+albumid+'&pid='+pid, 'newsFotoAlbum', winProp);
}

//--- TAB ----------------------------------

var tab_active='';

function tab_on(a,b,c){
    //elozo kikapcsolasa
    if(tab_active!='')tab_off(a,b,tab_active);
    //uj bekapcsolasa
    changeRowClass(a+c,'item selected hand');     
    changeRowClass(b+c,'tabcontenton');
    //ez az aktiv most     
    tab_active=c;
}

function tab_off(a,b,c){
    changeRowClass(a+c,'item hand');     
    changeRowClass(b+c,'tabcontentoff');     
}

//------------------------------------------------------------------------------
//ICI ACCORDION 0.5 ------------------------------------------------------------
var ici_accordion_items='a';

function ici_accordion_toggle(){
	const itemToggle=this.getAttribute('aria-expanded');

	console.log(ici_accordion_items);

	for(i=0;i<ici_accordion_items.length;i++) {
	  ici_accordion_items[i].setAttribute('aria-expanded','false');
	}

	if(itemToggle=='false') {
	  this.setAttribute('aria-expanded','true');
	}
}

function ici_accordion_init(){
	console.log(ici_accordion_items);
	ici_accordion_items=document.querySelectorAll(".ici_accordion button");
	ici_accordion_items.forEach(item=>item.addEventListener('click',ici_accordion_toggle));
	console.log(ici_accordion_items);
}