function Toggle(node){
	// Unfold the branch if it isn't visible
	if (node.nextSibling.style.display == 'none'){
		// Change the image (if there is an image)
		if (node.childNodes.length > 0){
			if (node.childNodes.item(0).nodeName == "IMG"){
				node.childNodes.item(0).src = "../img/minus.gif";
			}
		}
		node.nextSibling.style.display = 'block';
	} // Collapse the branch if it IS visible
	else {
		// Change the image (if there is an image)
		if (node.childNodes.length > 0){
			if (node.childNodes.item(0).nodeName == "IMG"){
				node.childNodes.item(0).src = "../img/plus.gif";
			}
		}
		node.nextSibling.style.display = 'none';
	}
}

function toggleLayer( whichLayer ){
  var elem, vis, kep;
  if( document.getElementById ) {// this is the way the standards work
		elem = document.getElementById( whichLayer );
		kep = document.getElementById( whichLayer+'_img' );
  } else if( document.all ) {// this is the way old msie versions work
		elem = document.all[whichLayer];
		kep = document.all[whichLayer+'_img'];
  } else if( document.layers ) {// this is the way nn4 works
		elem = document.layers[whichLayer];
		kep = document.layers[whichLayer+'_img'];
  } 
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if ( vis.display =='' && elem.offsetWidth != undefined && elem.offsetHeight != undefined ) {
		vis.display = (elem.offsetWidth != 0 && elem.offsetHeight != 0) ? 'block':'none';
  }
  
  if (vis.display == '' || vis.display == 'block' ) {
	vis.display = 'none';
	kep.src = "../img/plus.gif";
  } else {
	vis.display = 'block';
	kep.src = "../img/minus.gif";
  }
}

var xmlHttp;
var szrv;

function jelzo_akcio(str) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
	var url="konyvjelzok.php";
	url=url+"?mv="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged1;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-2'); 
	xmlHttp.send(url);
}


function jegyzet_akcio(str) { 
	xmlHttp=GetXmlHttpObject();
	szrv=str;
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
	var url="jegyzet.php";
	url=url+"?jegyez="+str;
	if (str==2) {
		var jegyzet = document.getElementById("jegyzetem").value.replace(/\n/g, "<br />");
		url = url + "&jegyzet=" + jegyzet;
	}
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange = stateChanged2;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-2'); 
	xmlHttp.send(url);
}

function fog_akcio(str) { 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null) {
	 alert ("Browser does not support HTTP Request");
	 return;
	 }
	var url="fogalmak.php";
	url=url+"?mv="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateChanged3;
	xmlHttp.open("GET",url,true);
	xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=ISO-8859-2'); 
	xmlHttp.send(url);
}

function stateChanged1 () { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("konyvjelzok").innerHTML=xmlHttp.responseText;
	} 
}
function stateChanged2 (){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		document.getElementById("jegyzet_inc").innerHTML=xmlHttp.responseText;
		if (szrv == 1) {
			document.getElementById("jegyzetem").focus();
			szamlalo_main();
		}
	} 
}

function stateChanged3 (){ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
		parent.document.getElementById("fogalmak").innerHTML=xmlHttp.responseText;
	} 
}

function stateChanged (x){ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
 document.print(x);
 document.getElementById(x).innerHTML=xmlHttp.responseText;
 } 
}

function GetXmlHttpObject(){
var xmlHttp=null;
try {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 } catch (e) {
 //Internet Explorer
 try  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e)  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}


function marad(x) {
	return document.getElementById(x)
} 
szam=2000;
uz=" karakter van hátra."
ie = (navigator.appName=="Microsoft Internet Explorer") ? 1:0;
function as(e) {
	if (ie) {
		x2 = 1
	} else {
		if (e.which=="8"){
			x2 = 0
		} else {
			x2 = 1
		}
	}
	if (marad("jegyzetem").value.length >= szam && x2) {
		if(ie){
			event.returnValue=false
		}
	return false;
	}
	return true;
}
function bs(){
	marad("jegyzetem").value = marad("jegyzetem").value.slice(0,szam);
	cs();
}
function cs() {
	marad("szamlalo").innerHTML=szam-marad("jegyzetem").value.length+uz;
}
function szamlalo_main(){
	marad('szamlalo').innerHTML=szam-marad('jegyzetem').value.length+uz;
	setInterval('bs();',500);
	marad("jegyzetem").onkeyup = cs;
	marad("jegyzetem").onkeypress = as
}

function lapoz(name) {
for(j=1; j<=5; j++)
	document.getElementById("nyito_lap"+j).style.display= "none";
    document.getElementById(name).style.display= "block";
}

function showtab(i) {
	for(j=1; j<=5; j++)	{
		var show= (i!=j)? "none" : "block";
		document.getElementById("nyito_tabimg"+j).style.display= show;
		document.getElementById("nyito_lap"+j   ).style.display= show;
	}
}

function toggle(name) {
	document.getElementById(name).style.display= "block";
	//var e= document.getElementById(name);
	//e.style.display= "";( e.style.display == "block")? "none" : "block";
}

function mindenKonyvjelzo() {
     var mehet = confirm ('Biztos, hogy minden könyvjelzőt törölni akar?');
	 if (mehet) {
		jelzo_akcio('MALL');
	 }
}

function mindenForgalom() {
    var mehet = confirm ('Biztos, hogy törölni akarja a kigyűjtött fogalmak listáját?');
	if (mehet) {
		fog_akcio('MALL');
	}
}

function hover(e,path){
	if(!e) {
		var e=window.event;
    }
  
	var targ;
	if(e.target)
  	targ= e.target;
	else if (e.srcElement)
  	targ= e.srcElement;

	if (targ.nodeType==3) // defeat Safari bug
  	targ = targ.parentNode;

	var elem= document.getElementById(targ.id);

	if(e.type=='mouseover')      elem.src= path+elem.id+'_h.png';
	else if(e.type=='mouseout')  elem.src= path+elem.id+'.png';
}


function sorosszeg(id)
{
	var db=   document.getElementById(id);
	var ar=   document.getElementById(id+'_ar');
	var ossz= document.getElementById(id+'_ossz');
	var s=    ar.innerHTML;
	s= s.substr(0, s.length-3);
	var i=    parseInt(db.value);
	if(isNaN(i) || (i<0))
	  i= 0;
	  
	db.value= i;
	ossz.innerHTML= '' + (i*s) + ' Ft';
}


function submit_action(formid,act)
{
	var f= document.getElementById(formid);
	if(f)
	{
		f.action= act;
		f.submit();
		return true;
	}
	return false;
}

//Chechkbox
function checkCB(akcio, name){
	var df = document.getElementById(name);
	var inp = df.getElementsByTagName('input');

	for (c=0; c<inp.length; c++) {
		if ( inp[c].type=='checkbox' && akcio == 1) {
			inp[c].checked = true;
	   } else 
			if  ( inp[c].type=='checkbox' && akcio == 0) {
				inp[c].checked =false; 
			}
	}
}

function validCB(name){
    var i = 0;
	var df = document.getElementById(name);
	var inp = df.getElementsByTagName('input');
	
	for (c=0; c<inp.length; c++) {
		if (inp[c].checked == true) {
			i++;
		}
	}
	if (i>0) return true; 
	else {
		alert('Kérem jelölje be a nyomtatni kívánt tartalmat!');
		return false;
	}
}

/*Vedelem*/
/*var uzenet = "A MindiGIS Kft. tulajdona!";
function st(sz){window.status=sz;return true} 
function clickIE(e) {
  if (document.all) {
	  if (event.button == 2) {
		  alert(uzenet);
	 	  return false;
	  } else 
	  return true;
  }
}

function clickNS(e) {
  if (document.layers || (document.getElementById && !document.all)) {
   if (e.which==2 || e.which==3) {
      alert(uzenet);
	  return false;
   }
  }
}

if (document.layers) {
 	document.captureEvents(Event.MOUSEDOWN);
	document.onmousedown=clickNS;
  } else {
    document.onmouseup=clickNS;
    document.onmousedown=clickIE;
    //document.oncontextmenu=clickIE;
  }
  
document.oncontextmenu=new Function("return false")

function nyom(e) {
   if (!e) e = window.event;
   if (e.keyCode == '17')
	 {
		 alert(uzenet);
		 return false;
	 }
    return true;
}
document.onkeydown = nyom;
*/
