function makeDispURL(id) {
	document.location.href = '?pID='+id+'&menu='+divz;
}

function makeDispURLfull(url) {
	if (url.charAt(0) == '?') {
	document.location.href = url +'&menu='+divz;
	} else {
		document.location.href = url;
	}
}

function checkEnter(){
	if (window.event && window.event.keyCode == 13) {
		document.getElementById('search_pat').value = document.getElementById('search_text').value; 
		document.getElementById('search').submit();
	} else return true;
}
//------------------------------------------------------------------------------------------------


function OpenNewWindow(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=" + x + ",height=" + y;
    if (x=="full") options = "toolbar=no,fullscreen=yes,menubar=no,scrollbars=yes";
		msgWindow=window.open(url,"", options);
}

function OpenNewWindowNoScroll(url, x, y) {
	var options = "toolbar=no,menubar=no,scrollbars=no,resizable=yes,width=" + x + ",height=" + y;
		msgWindow=window.open(url,"", options);
}
//------------------------------------------------------------------------------------------------

function eventList(limit,sestyp){ // -1->endless
	var url = baseURL + "event_list.php?limit=" + limit + "&sestyp=" + sestyp;
	xmlHttp=GetXmlHttpObject(stateChanged);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function showGaleryElement(pic,page,fld){
    //window.alert(pic + " " + page + " " + fld);
	var url = baseURL + "gal_handle.php?pic=" + pic + "&page=" + page + "&fld=" + fld;
	xmlHttp=GetXmlHttpObject(stateChanged2);
	xmlHttp.open("GET", url , true);
	xmlHttp.send(null);
}

function showProg(id){
    //window.alert(id);
    document.getElementById("panel_title").innerHTML="Betöltés...";
    document.getElementById("infopanel").innerHTML="<center><img src='http://baptistaifi.hu/images/load.gif'><br />Betöltés folyamatban, kis türelmet ...</center>";
    document.getElementById("fuggony").style.display="block";
    //window.alert(pic + " " + page + " " + fld);
    var url = baseURL + "getevent.php?eID=" + id ;
    //window.alert(url);
    xmlHttp=GetXmlHttpObject(stateChanged_prog);
    xmlHttp.open("GET", url , true);
    xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById('eventlist').innerHTML = xmlHttp.responseText;
		//window.location.reload();
	} 
} 

function stateChanged2() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById('sh_galery').innerHTML = xmlHttp.responseText;
		//window.location.reload();
	} 
}

function stateChanged_prog() 
{ 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
       // window.alert(xmlHttp.responseText);
        document.getElementById("infopanel").innerHTML = xmlHttp.responseText.split(";_;_;_;_;_;_;_;_;")[0];
        document.getElementById("panel_title").innerHTML = xmlHttp.responseText.split(";_;_;_;_;_;_;_;_;")[1];
        //window.location.reload();
    } 
}

function GetXmlHttpObject(handler)
{

	var objXmlHttp=null

	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
			strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler
			return objXmlHttp
		} 
		catch(e)
			{ 
				alert("Error. Scripting for ActiveX might be disabled") 
				return 
			} 
	} 
	if (navigator.userAgent.indexOf("Mozilla")>=0 || navigator.userAgent.indexOf("Opera")>=0 || navigator.userAgent.indexOf("Safari")>=0)
    {
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
}

function detSearch() {
        if (document.getElementById('search_detail').style.display == 'none') {
            document.getElementById('search_detail').style.display = 'block';
        } else  document.getElementById('search_detail').style.display = 'none';
    }
    
function cancelClick(event) {
  event.cancelBubble = true;
  if (event.stopPropagation)
    event.stopPropagation();
}

function clearField(obj) {
     if (obj.name == 'login' || obj.name == 'pass' ) {
         if (document.login_form.login.value == "Felhasználói név" && document.login_form.pass.value == "jelszo") {
            document.login_form.login.value = '';
            document.login_form.login.style.color = '#010101';
            document.login_form.pass.value = '';
            document.login_form.pass.style.color = '#010101'; 
        }
    }
}

function readMsg(id){
    document.msgform.readMsg.value = id;
    document.msgform.submit();
}

function printDiv (div) {
    var a = window.open('','','width=800,height=600');
    a.document.open("text/html");

    a.document.write('<html><head><link rel="stylesheet" href="/css/index.css"></link><link rel="stylesheet" href="/css/base.css"></link></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
    a.document.write(document.getElementById(div).innerHTML);

    a.document.close();
    a.print();
    a.close();
}

function copyJelform(esid) {
    if (confirm("Valóban másolni akarod ezt a form-ot?\nHa volt már létrehozott form, akkor az felülíródik!")) {
        copyid=$("#masol").val();
        func = function (result) {
            alert(result);
        }
        $.get(baseURL+"sub/jelformmasolas.php", { command: "copyJelform", copyid: copyid, esid: esid },func);
    }
}