function Preview(num,filenev){
	document.form1.action = filenev;
	document.form1.target="self";
	document.form1.prev.value=num;
}


function Rogzit(filenev){
	document.form1.action = filenev;
	document.form1.target="menu";
	document.form1.prev.value='';
}


function KepDialog(n,mod){
	ablak = open("kepdialog.php?mod=1&num="+n, "kepdialog", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=417, height=342, scrollbars-1");
}

function KepDialog3(n,d){
	//if(mod == 1){
		ablak = open("kepdialog.php?mod=1&num="+n+"&curr_dir="+d, "kepdialog", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=417, height=342, scrollbars-1");
	//} else {
	//	ablak = open("./admin/kepdialog.php?mod=2&num="+n, "kepdialog", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=417, height=342, scrollbars-1");
	//}

}


function KepDlgPreview(dir){
	fn = document.kepform.filenev.options[document.kepform.filenev.selectedIndex].value;
	kit = fn.substr(fn.length-3, 3);
	if(kit == "swf"){
		html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="100%" height="100%">';
        html +=	'<param name="movie" value="'+dir+fn+'">';
        html += '<param name="quality" value="high">';
        html += '<embed src="'+dir+fn+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed></object>';
        document.getElementById('previmage').innerHTML = html;
	} else {
		document.getElementById('previmage').innerHTML = "<IMG src='"+dir+fn+"'>";
	}
}


function KepDlgBeszur(dir,num){
	if(document.kepform.filenev.selectedIndex > -1){
		fn = document.kepform.filenev.options[document.kepform.filenev.selectedIndex].value;
		if(num == 0){
			opener.document.form1.kep.value=fn;
		} else {
			id = "";
			if(num != 1){
				id = num;
			}
			opener.document.getElementById('kepkeret'+id).innerHTML = "<IMG src='"+dir+fn+"' width='100' border='1' id='previmg"+id+"'>";
			opener.document.getElementById('kep'+id).value=fn;
		}
		self.close();
	}
}


function TartalomUrit(url){
	window.parent.document.getElementById("tartalom").src = "ures.html";
}


function PreviewFrissit(url){
	if(url != ''){
		window.parent.document.getElementById("preview").src = url;
	}
}


function MenuAktiv(classnev,id){
	currlayer = document.getElementById("menu_layer"+id);
	currlayer.className = classnev;
}

function CreatePreview(){
	konyvtar = document.form1.konyvtar.options[document.form1.konyvtar.selectedIndex].text;
	ablak = open("./createpreview.php?dir="+konyvtar, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=320, height=240, scrollbars=0");
}


function Vissza(){
	history.go(-1);
}


function UgyfelSzures(id){
	f = document.getElementById("szukitform_"+id);
	f.submit();
}

function urldialog(mid){
	ablak = open("./urldialog.php?mid="+mid, "", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=240, height=100, scrollbars=0");
}

function UserLapoz(pos){
	document.oldal.pos.value = pos;
	document.oldal.submit();
}


function Kijelol(obj,alapszoveg){
	if(obj.value.indexOf(alapszoveg)==0){
		obj.value="";
		obj.alapszoveg = alapszoveg;
	}
	obj.select();
}

function InputKitolt(obj){
	if(obj.value == ""){
		obj.value = obj.alapszoveg;
	}
}


function Login_Kijelol(obj,alapszoveg1,alapszoveg2){
	i1 = document.getElementById("usrnev");
	i2 = document.getElementById("pwd");

	if(i1.value.indexOf(alapszoveg1)==0){
		i1.value="";
		i1.alapszoveg = alapszoveg1;
	}
	if(i2.value.indexOf(alapszoveg2)==0){
		i2.value="";
		i2.alapszoveg = alapszoveg2;
	}	
	if(obj==i1){
		i2.value="";
	}
	
	obj.select();
}

function Login_InputKitolt(obj){
	i1 = document.getElementById("usrnev");
	i2 = document.getElementById("pwd");

	if(i1.value == ""){
		i1.value = i1.alapszoveg;
	}
	if(i2.value == ""){
		i2.value = i2.alapszoveg;
	}	
}


function takaro(n){
	d = document.getElementById("takaro_div");
	if(n==1){
		d.style.display = "";
	} else {
		d.style.display = "none";
	}
}

function CsakSzam(obj){
	obj.value = obj.value.replace(/[^0-9, ',']/g, '');
}

function MagassagBeallit(){
	k_h = document.getElementById("kozepre").offsetHeight;
	f_h = document.getElementById("fejlec").offsetHeight;
	l_h = document.getElementById("lablec").offsetHeight
	full_h = f_clientHeight();
	if(document.getElementById("mikrositekeret")){
		max = k_h-f_h-l_h;
		
		t_h = document.getElementById("tartalom_kozep_div").offsetHeight;
		if(t_h>max){
			document.getElementById("bal_oldal").style.height = t_h;
			document.getElementById("jobb_oldal").style.height = t_h;
		} else {
			document.getElementById("bal_oldal").style.height = max;
			document.getElementById("oldal_kozep").style.height = max;
			document.getElementById("jobb_oldal").style.height = max;
		}	
	
		//d1 = document.getElementById("tartalom_kozep_div");
		//d2 = document.getElementById("tartalom_lezaro_div");
		//if(d1.offsetHeight+d2.offsetHeight<max){
		//	d2.style.height = max-d1.offsetHeight;
		//}
	}
	
}

function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
			
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
			
			
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function Termeklista_Gyartok(id){
	if(AjaxObjFree(ajax_obj)){
		if(id == 0){
			document.getElementById('termeklista_gyartok_popup_div').innerHTML = "";
			document.getElementById('termeklista_gyartok_popup_div').style.display = "none";
		} else {
			//if(AjaxObjFree(ajax_obj)){
				ajax_obj.termeklista_gyartok(id);
			//}
		}
	}
}

function getAbsoluteTop(objectId){
	o = document.getElementById(objectId)
	oTop = o.offsetTop            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oTop += oParent.offsetTop // Add parent top position
		o = oParent
	}
	return oTop
}

function getAbsoluteLeft(objectId){
	o = document.getElementById(objectId)
	oLeft= o.offsetLeft            // Get top position from the parent object
	while(o.offsetParent!=null) { // Parse the parent hierarchy up to the document element
		oParent = o.offsetParent  // Get parent object reference
		oLeft += oParent.offsetLeft // Add parent top position
		o = oParent
	}
	return oLeft
}

//---Ajax--------------------------------------------------------------------

function ws_lista_kijelol(obj,mod){
	if(mod == 1){
		obj.style.border = "#cccccc 1px solid";
	} else {
		obj.style.border = "";
	}
}

function ws_kivalaszt(obj,id,form){
	obj.style.background = "#cccccc";
	if(form["curr"+id].value != ""){
		regi = document.getElementById(form["curr"+id].value);
		if(regi != obj){
			regi.style.background = "";
		}
	}
	form["curr"+id].value = obj.id;
}

function ws_Vissza(form_id,action){
	f = document.getElementById(form_id);
	if(f["func"]){
		n = parseInt(f["func"].value);
		f["func"].value = n-2;
		if(f["mod"]){
			f["mod"].value = "";
		}
	}
	f.action = action;
	f.submit();
}

function ws_GyartoGyakori(){
	f = document.getElementById("gyarto_form");
	gy = "N";
	if(f["gyakori"].checked){
		gy = "I";
	}
	if(AjaxObjFree(ajax_obj)){
		f["currgyarto"].value = "";
		f["currmodell"].value = "";
		ajax_obj.gyartobetolt(gy);
	}
}

function ws_GyartoKivalaszt(obj,num,gyarto){
	if(AjaxObjFree(ajax_obj)){		
		f = document.getElementById("gyarto_form");
		gyakori = 'N';
		if(f["gyakori"].checked){
			gyakori = 'I';
		}
		ws_kivalaszt(obj,"gyarto",f);
		f["currmodell"].value = "";
		m = document.getElementById("modell_lista_div");
		m.innerHTML = "Kérem várjon!";	

		ajax_obj.modellbetolt(gyarto,gyakori);	
	}	
}

function ws_Gyarto_Tovabb(){
	f = document.getElementById("gyarto_form");
	if(f["currgyarto"].value!="" && f["currmodell"].value!=""){
		gy_i = f["currgyarto"].value;
		gy_i = gy_i.replace("_div", "_input");
		gy_url = document.getElementById("url_"+gy_i).value;
		f["gyarto"].value = document.getElementById(gy_i).value;
		
		m_i = f["currmodell"].value;
		m_i = m_i.replace("_div", "_input");
		m_url = document.getElementById("url_"+m_i).value;
		f["modell"].value = document.getElementById(m_i).value;		
		
		f.action += "__"+gy_url+"__"+m_url+"/";
		
		f.submit();	
	}
}

function ws_ModellKivalaszt(obj,gyarto,modell){
	f = document.getElementById("gyarto_form");
	ws_kivalaszt(obj,"modell",f);

	//if(AjaxObjFree(ajax_obj)){
	//	f = document.getElementById("modelltipus_form");
	//	f["currtipus"].value = "";
	//	ws_kivalaszt(obj,"modell",f);
	//	m = document.getElementById("tipus_lista_div");
	//	m.innerHTML = "Kérem várjon!";	
	//	ajax_obj.tipusbetolt(gyarto,modell);	
	//}
}

function ws_TipusKivalaszt(obj,num,ktypnr){
	f = document.getElementById("modelltipus_form");
	ws_kivalaszt(obj,"tipus",f);
	ws_Tipus_Info(num);
}

function ws_Tipus_Info(num){
	tipus = document.getElementById("info_tipus_"+num+"_input").value;
	ccm = document.getElementById("info_ccm_"+num+"_input").value;
	kw = document.getElementById("info_kw_"+num+"_input").value;
	le = document.getElementById("info_le_"+num+"_input").value;
	megj_b = document.getElementById("info_megj_b_"+num+"_input").value;
	megj_b2 = document.getElementById("info_megj_b2_"+num+"_input").value;
	megj_b3 = document.getElementById("info_megj_b3_"+num+"_input").value;
	megj_b4 = document.getElementById("info_megj_b4_"+num+"_input").value;
	
	d = document.getElementById("ws_tipus_info_div");
	html = '<div class="ws_tipus_info_tartalom_div">';
	html += tipus+"<br>";
	html += ccm+" ccm<br>";
	if(megj_b != "") html += megj_b+"<br>";
	if(megj_b2 != "") html += megj_b2+"<br>";
	if(megj_b3 != "") html += megj_b3+"<br>";
	if(megj_b4 != "") html += megj_b4+"<br>";
	html += "</div>";
	d.innerHTML = html;
}


function ws_Modell_Tipus_Tovabb(){
	f = document.getElementById("modelltipus_form");
	if(f["currtipus"].value!=""){
		t_i = f["currtipus"].value;
		t_i = t_i.replace("_div", "_input");
		f["tipus"].value = document.getElementById(t_i).value;	
		t_url = document.getElementById("url_"+t_i).value;	
		
		f.action += "__"+t_url;
		
		f.submit();
	}
}


function ws_FocsoportKivalaszt(obj,fcs,ktypnr,num){
	if(AjaxObjFree(ajax_obj)){
		f = document.getElementById("focsoportalcsoport_form");
		f["curralcsoport"].value = "";
		ws_kivalaszt(obj,"focsoport",f);
		a = document.getElementById("alcsoport_lista_div");
		a.innerHTML = "Kérem várjon!";	
		ajax_obj.alcsoportbetolt(ktypnr,fcs);		
	}
}

function ws_AlcsoportKivalaszt(obj,num){
	f = document.getElementById("focsoportalcsoport_form");
	ws_kivalaszt(obj,"alcsoport",f);
}

function ws_Focsoport_Alcsoport_Tovabb(){
	f = document.getElementById("focsoportalcsoport_form");
	if(f["currfocsoport"].value!="" && f["curralcsoport"].value!=""){
		f_i = f["currfocsoport"].value;
		f_i = f_i.replace("_div", "_input");
		f_url = document.getElementById("url_"+f_i).value;	
		f["focsoport"].value = document.getElementById(f_i).value;		
		a_i = f["curralcsoport"].value;
		a_i = a_i.replace("_div", "_input");
		a_url = document.getElementById("url_"+a_i).value;	
		f["alcsoport"].value = document.getElementById(a_i).value;		
		
		f.action += f_url+"__"+a_url;
		
		f.submit();
	}
}

function ws_AlkTipusKivalaszt(obj,ktypnr,focsoport,alcsoport,alktipus,num){
	if(AjaxObjFree(ajax_obj)){
		f = document.getElementById("alktipusgyartmany_form");
		f["curralkgyartmany"].value = "";
		ws_kivalaszt(obj,"alktipus",f);
		a = document.getElementById("alkgyartmany_lista_div");
		a.innerHTML = "Kérem várjon!";		
		ajax_obj.alkgyartmanybetolt(ktypnr,focsoport,alcsoport,alktipus);
	}
}

function ws_AlkGyartmanyKivalaszt(obj,num){
	f = document.getElementById("alktipusgyartmany_form");
	ws_kivalaszt(obj,"alkgyartmany",f);
}

function ws_Tipus_Gyartmany_Tovabb(){
	f = document.getElementById("alktipusgyartmany_form");
	if(f["curralktipus"].value!="" && f["curralkgyartmany"].value!=""){
		t_i = f["curralktipus"].value;
		t_i = t_i.replace("_div", "_input");
		t_url = document.getElementById("url_"+t_i).value;	
		f["alktipus"].value = document.getElementById(t_i).value;		
		gy_i = f["curralkgyartmany"].value;
		gy_i = gy_i.replace("_div", "_input");
		gy_url = document.getElementById("url_"+gy_i).value;	
		f["alkgyartmany"].value = document.getElementById(gy_i).value;		
		
		f.action += "__"+t_url+"__"+gy_url;
		
		f.submit();
	}
}

function ws_AlkatreszKivalaszt(obj,num,cikkszam,tid,cikktorzsid){
	f = document.getElementById("alkatresz_form");
	f.action += "/"+cikkszam;
	f.submit();
}

function ws_Utvonal(pos){
	f = document.getElementById("utvonal_form");
	f["func"].value = pos;
	f.submit();
}

function ws_Hasonlit(){
	if(AjaxObjFree(ajax_obj)){
		if(document.getElementById("hasonlit_div")){
			ajax_obj.hasonlit();
		}
	}
}

function ws_Hasonlit_bezar(){
	if(document.getElementById("hasonlit_div")){
		document.getElementById("hasonlit_div").innerHTML = "";
	}
}

//-------------------------------------------------------------------------------------------------------

function ws_CikkcsoportKivalaszt(obj,num){
	f = document.getElementById("cikkcsoport_form");
	ws_kivalaszt(obj,"cikkcsoport",f);	
}

function ws_Cikkcsoport_Tovabb(){
	f = document.getElementById("cikkcsoport_form");
	if(f["currcikkcsoport"].value!=""){
		c_i = f["currcikkcsoport"].value;
		c_i = c_i.replace("_div", "_input");
		c_url = document.getElementById("url_"+c_i).value;	
		f["cikkcsoport"].value = document.getElementById(c_i).value;
		
		f.action += "__"+c_url+"/";		
		
		f.submit();	
	}
}

function ws_CikkkategoriaKivalaszt(obj,num){
	f = document.getElementById("cikkkategoria_form");
	ws_kivalaszt(obj,"cikkkategoria",f);	
}

function ws_Cikkkategoria_Tovabb(){
	f = document.getElementById("cikkkategoria_form");
	if(f["currcikkkategoria"].value!=""){
		c_i = f["currcikkkategoria"].value;
		c_i = c_i.replace("_div", "_input");
		c_url = document.getElementById("url_"+c_i).value;			
		f["cikkkategoria"].value = document.getElementById(c_i).value;
		
		f.action += "__"+c_url+"/";		
		
		f.submit();	
	}
}

function ws_CikkalkategoriaKivalaszt(obj,num){
	f = document.getElementById("cikkalkategoria_form");
	ws_kivalaszt(obj,"cikkalkategoria",f);	
}

function ws_Cikkalkategoria_Tovabb(){
	f = document.getElementById("cikkalkategoria_form");
	if(f["currcikkalkategoria"].value!=""){
		c_i = f["currcikkalkategoria"].value;
		c_i = c_i.replace("_div", "_input");
		c_url = document.getElementById("url_"+c_i).value;	
		f["cikkalkategoria"].value = document.getElementById(c_i).value;
		
		f.action += "__"+c_url+"/";		
		
		f.submit();	
	}
}

function ws_Cikkalkategoria2Kivalaszt(obj,num){
	f = document.getElementById("cikkalkategoria2_form");
	ws_kivalaszt(obj,"cikkalkategoria2",f);	
}

function ws_Cikkalkategoria2_Tovabb(){
	f = document.getElementById("cikkalkategoria2_form");
	if(f["currcikkalkategoria2"].value!=""){
		c_i = f["currcikkalkategoria2"].value;
		c_i = c_i.replace("_div", "_input");
		c_url = document.getElementById("url_"+c_i).value;	
		f["cikkalkategoria2"].value = document.getElementById(c_i).value;
		
		f.action += "__"+c_url+"/";		
		
		f.submit();	
	}
}

function ws_Cikkalkategoria3Kivalaszt(obj,num){
	f = document.getElementById("cikkalkategoria3_form");
	ws_kivalaszt(obj,"cikkalkategoria3",f);	
}

function ws_Cikkalkategoria3_Tovabb(){
	f = document.getElementById("cikkalkategoria3_form");
	if(f["currcikkalkategoria3"].value!=""){
		c_i = f["currcikkalkategoria3"].value;
		c_i = c_i.replace("_div", "_input");
		c_url = document.getElementById("url_"+c_i).value;	
		f["cikkalkategoria3"].value = document.getElementById(c_i).value;
		
		f.action += "__"+c_url+"/";		
		
		f.submit();	
	}
}


function ws_Nagykep(cikkszam){
	cikkszam = cikkszam.replace("+", "%2B");
	//document.title = cikkszam;
	ablak = open("/template/nagykep.php?cikkszam="+cikkszam, "nagykep", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=1, width=320, height=200, scrollbars=1");
}

function ws_Feldolgozas(host_id,dir,rid,fmod,szmod){
	//alert(szmod);
	if(ajax_obj){
		if(AjaxObjFree(ajax_obj)){
			ajax_obj.ws_feldolgozas(host_id,dir,rid, fmod, szmod);
		}	
	} else {
		f = "ws_Feldolgozas('"+host_id+"','"+dir+"','"+rid+"','"+fmod+"','"+szmod+"')";
		setTimeout(f,1000);
	}
}

function ws_Keszleten(obj){
	f = document.getElementById("alkatresz_form");
	f.submit();
}

//---------------------------------------------------------------------------------------------------------

var ajax_obj;

function loaded(nyelv){
	var MyClassHandler = {
		gyartobetolt: function(result){
			document.getElementById("modell_lista_div").innerHTML = "";
			document.getElementById("gyarto_lista_div").innerHTML = result;		
		},	
		modellbetolt: function(result){
			document.getElementById("modell_lista_div").innerHTML = result;		
		},		
		tipusbetolt: function(result){
			document.getElementById("tipus_lista_div").innerHTML = result;		
		},
		alcsoportbetolt: function(result){
			document.getElementById("alcsoport_lista_div").innerHTML = result;		
		},
		alkgyartmanybetolt: function(result){
			document.getElementById("alkgyartmany_lista_div").innerHTML = result;		
		},
		referenciabetolt: function(result){
			document.getElementById("referencia_lista_div").innerHTML = result;		
		},
		alkategoriabetolt: function(result){
			document.getElementById("alkategoria_lista_div").innerHTML = result;		
		},
		hasonlit: function(result){
			document.getElementById("hasonlit_div").innerHTML = result;	
			window.scrollTo(0,20000);	
		},
		ws_feldolgozas: function(result){
			if(result[0] == 1){
				document.getElementById("amix_valasz_div").innerHTML = result[1];	
				try {
					var pageTracker = _gat._getTracker("UA-8967961-1");
					pageTracker._initData();
					pageTracker._trackPageview();
					//alert(result[7]);
					pageTracker._addTrans(
						result[4], // Rendelésazonosító
						"", // Részleg
						result[7], // Összesen
						"0", // Adó
						"0", // Szállítás
						"", // Város
						"", // Állam
						"" // Ország
					);	
					l = result[6].length;
					for(i=0; i<l; i++){
						//alert();
						pageTracker._addItem(
									result[4], // Rendelésazonosító
									result[6][i][0], // Cikkszám
									result[6][i][1], // Terméknév
									"", // Kategória
									result[6][i][2], // Ár
									result[6][i][3] // Mennyiség
									);						
					}
					pageTracker._trackTrans();
				} catch(err) {}
			} else {
				setTimeout("ws_Feldolgozas('"+result[2]+"','"+result[3]+"','"+result[4]+"','"+result[5]+"')",1000);
			}
		}
	}
	ajax_obj = new myclass(MyClassHandler);
	MagassagBeallit();
}

function AjaxObjFree(obj){
	res = false;
	if(!ajax_obj.__client){
		res = true;
	} else {
		if(ajax_obj.__client.xmlhttp.readyState == 4){
			res = true;
		}
	}
	return res;
}










