function PopupImage(url, x, y){
	newWindow=open(url,'','toolbar=no,directories=no,menubar=no,width=' + x + ',height= ' + y + ',scrollbars=no,status=no,resizable=no');
	newWindow.focus();
}

function PopupPage(url, x, y){
	newWindow=open(url,'','toolbar=no,directories=no,menubar=no,width=' + x + ',height= ' + y + ',scrollbars=no,status=no,resizable=no');
	newWindow.focus();
}

function PopupPage1(url, x, y){
	newWindow=open(url,'','toolbar=yes,directories=no,menubar=yes,width=' + x + ',height= ' + y + ',scrollbars=yes,status=no,resizable=yes');
	newWindow.focus();
}


function startHighlight() {
	if (document.all && document.getElementById) {
		navRoot = document.getElementById("myGrid");
		// Get a reference to the TBODY element 
		tbody = navRoot.childNodes[0];
		for (i = 1; i < tbody.childNodes.length; i++) {
			node = tbody.childNodes[i];
			if (node.nodeName == "tr") {
				node.onmouseover=function() {
					this.className = "over";
				}
				node.onmouseout=function() {
					this.className = this.className.replace("over", "");
				}
			}
		}
	}
}

function OpenWin(url,target) {
	x=700;
	y=500;
	if (arguments.length>3) {
		x=arguments[2];
		y=arguments[3];
	}
	window.open(url,target,"directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no,width="+x+",height="+y+",resizable=yes,scrollbars=yes");
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	return el;
}

function getElemRefs2(obj,id) {
	var el = (obj.document.getElementById)? obj.document.getElementById(id): (obj.document.all)? obj.document.all[id]: (obj.document.layers)? obj.document.layers[id]: null;
	return el;
}

function showelement(val) {
		ename="e"+val;
		el=getElemRefs(ename);
		if (el) el.style.display="block";
}

function hideall() {
	for (a=1;a<15;a++) {
		ename="e"+a;
		el=getElemRefs(ename);
		if (el)
			el.style.display="none";
	}
}

function page_refresh() {
	if (arguments.length==0) {
		if ('function' == typeof(submit_xinha)) {
			submit_xinha();
		}
		document.forms.addform.formsent.value="2";
		document.forms.addform.submit();
	} else document.forms.listform.submit();
}

function confdel() {
	return(confirm("Biztos, hogy törölni akar?"));
}

function del_gct(name,val) {
	name.value=val;
	page_refresh();
}

function up_gct(name,val) {
	name.value=val;
	page_refresh();
}
function down_gct(name,val) {
	name.value=val;
	page_refresh();
}

function move_dtable(tobj,move_dir,inputobj) {
	//Up mezo sorszama
	moveindex=tobj.cellIndex;
	if (move_dir==1) moveindex-=1;

	//aktualis tabla
	tblEl=tobj.parentNode.parentNode;
	//	var tblEl = document.getElementById("table1");

	//sorok szama
	rowcount=tblEl.rows.length;

	//aktualis sor
	rnum=tobj.parentNode.rowIndex;

	//Rejtett cellak megjelenitese
	tblEl.rows[0].cells[moveindex].style.visibility="visible";
	tblEl.rows[rowcount-1].cells[moveindex+1].style.visibility="visible";
	if (move_dir==0) {
		tmpEl = tblEl.removeChild(tblEl.rows[rnum]);
		tblEl.insertBefore(tmpEl, tblEl.rows[rnum-1]);
	} else {
		tmpEl = tblEl.removeChild(tblEl.rows[rnum]);
		tblEl.insertBefore(tmpEl, tblEl.rows[rnum+1]);
	}

	//Cellak elrejtese
	tblEl.rows[0].cells[moveindex].style.visibility="hidden";
	tblEl.rows[rowcount-1].cells[moveindex+1].style.visibility="hidden";

	//Input mezok osszeszedese
	data=":";
	for (a=0;a<rowcount;a++)
		data=data+tblEl.rows[a].cells[moveindex-1].childNodes[0].value+":";

	//Beiras az input mezobe
	inputobj.value=data;
}

function form_set_language(lang) {
	if ('function' == typeof(submit_xinha)) {
		submit_xinha();
	}
	document.forms.addform.formsent.value="1";
	document.forms.addform.form_new_language.value=lang;
	document.forms.addform.submit();
}

//Listazo
var lister3_form;

function lister3_setorder(id,order) {
	lister3_form.lister3_id.value=id;
	lister3_form.lister3_order.value=order;
	lister3_form.lister3_page.value=1;
	lister3_form.submit();
}

function lister3_setpage(id,page) {
	lister3_form.lister3_id.value=id;
	lister3_form.lister3_page.value=page;
	lister3_form.submit();
}

function a3l_disable_tr_click() {
	a3l_clicked=1;
}

function lister3_setvalue(id,field,value) {
	a3l_disable_tr_click();
	lister3_form.lister3_id.value=id;
	lister3_form.lister3_field.value=field;
	lister3_form.lister3_value.value=value;
	lister3_form.submit();
}

function lister3_submit(id) {
	lister3_form.lister3_id.value=id;
	return true;
}

//Szuro kezeles
function a3l_createMNEV(listid,f_id) {
        var elem = document.createElement('select');
        elem.className="inp1";
	elem.name=listid+"_f[]";
	elem.options[elem.options.length]=new Option("",0);

	//Lista mezoinek berakasa
	for (a=0;a<a3l_fields[listid].length;a++) {
		elem.options[elem.options.length]=new Option(a3l_fields[listid][a],a+1);
	}
	elem.options.selectedIndex=f_id;

	elem.onchange=function() {
		val=this.value;
		listid=this.name.substring(0,36);
		a3l_load(this,listid);
	}
        return elem;
}

function a3l_createMMUV(listid,f_id) {
        var elem = document.createElement('select');
        elem.className = "inp1";
        elem.style.width = "150";
	elem.name=listid+"_m[]";

	//Megvizsgaljuk, hogy mely elemek lehetnek
	ltype=a3l_types[listid][f_id-1];
	
	a_to=10;
	if (ltype==1) a_to=6;

	//Lista mezoinek berakasa
	for (a=0;a<a_to;a++) {
		elem.options[elem.options.length]=new Option(a3l_hlist[a],a+1);
	}
        return elem;
}

function a3l_createMERTEK(listid) {
        var elem = document.createElement('input');
        elem.className = "inp1";
	elem.name=listid+"_e[]";
        elem.size = 40;
        return elem;
}

function a3l_delrow(o) {
	row=o.parentNode.parentNode;
	table=row.parentNode.parentNode;
	table.deleteRow(row.rowIndex);
}
function a3l_update_row(f_id,from,listid) {
	//Sor
	upd_row=from.parentNode.parentNode;
	//Tabla
	table=upd_row.parentNode.parentNode;
	//Aktualis sor
	row_pos=upd_row.rowIndex;
	//Osszes sor
	row_num=table.rows.length;
	//MezO valaszto select
	td1=upd_row.cells[0];
	td2=upd_row.cells[1];
	td3=upd_row.cells[2];
	td4=upd_row.cells[3];

	//Jelenlegi cella tartalmak torlese
	td1.innerHTML="";
	td2.innerHTML="";
	td3.innerHTML="";
	td4.innerHTML="";

	//Mezonev valaszto Select mezo beszurasa
	td1.appendChild(a3l_createMNEV(listid,f_id));
	td1.className="szurorow";

	//Hasonlitas mod valaszto mezo beszurasa
	td2.appendChild(a3l_createMMUV(listid,f_id));

	//Input mezo beszurasa
	td3.appendChild(a3l_createMERTEK(listid));

	//Torles ikon hozzaadasa
	td4.innerHTML="<img onClick=\"a3l_delrow(this);\" src=\"images/icons/del.gif\">";

	table=upd_row.offsetParent;
        var lastRow = table.rows.length;
	//Aktualis sor meghatarozasa

	//Ha utolso sor, akkor ures sor letrehozasa
	if (row_pos+1==row_num) {
		//Uj ures sor letrehozasa
	        var newrow = table.insertRow(-1);
		var td1=newrow.insertCell(-1);
		td1.appendChild(a3l_createMNEV(listid,0));	
		//3 ures cella
		row=newrow.insertCell(-1);
		row=newrow.insertCell(-1);
		row=newrow.insertCell(-1);
//		row.colSpan=3;
		row.align="right";

		//Torles ikon hozzaadasa
		row.innerHTML="<input type=\"submit\" value=\"Küldés\" onClick=\"lister3_submit('"+listid+"')\" class=\"inpbutton\">";
	}
}

function a3l_load(from,listid) {
	a3l_update_row(from.value,from,listid);
	value=from.value;
}

function a3l_hf(id,type,mode) {
	ename=id+"_div_"+type;
	el=getElemRefs(ename);

	ename2=ename+"c0";el_c0=getElemRefs(ename2);
	ename2=ename+"c1";el_c1=getElemRefs(ename2);
	
	if (!el) return;
	if (mode==1) {
		el.style.display="block";
		el_c1.style.display="none";
		el_c0.style.display="block";
	} else {
		el.style.display="none";
		el_c1.style.display="block";
		el_c0.style.display="none";
	}
}

var a3l_clicked=0;
function a3l_conf() {
	a3l_clicked=1;
	return(confirm("Biztos?"));	//TODO
}

function a3l_sethref(val) {
	if (a3l_clicked==1) {
		a3l_clicked=0;
		return;
	}
	document.location.href=val;
}

function a3_del_detail(url,checked) {
	if (checked) ajax_load(url,"bovebb");
	else {
		var bov=document.getElementById("bovebb");
		bovebb.innerHTML="";
	}
}

function createRequestObject() {
   var ro;
   var browser = navigator.appName;
   var uagent = navigator.userAgent.indexOf("Opera 8.5")!=-1; //okos opera miatt, aki IE-nek hazudja magat
   if(browser == "Microsoft Internet Explorer" && uagent==false){
       ro = new ActiveXObject("Microsoft.XMLHTTP");
   }else{
       ro = new XMLHttpRequest();
   }
   return ro;
}

function ajax_load(url,element) {
	var http = createRequestObject();
	
	http.open('get', url);
	http.onreadystatechange=function() {
  		if(http.readyState == 4) {
   			var response = http.responseText;
			var bov=document.getElementById(element);
			bov.innerHTML=response;
  		}
	}


   	http.send(null);

}

window.focus();
