function Set_Cookie( name, value, expires, path, domain, secure )
{
// set time, it's in milliseconds
var today = new Date();
today.setTime( today.getTime() );

/*
if the expires variable is set, make the correct
expires time, the current script below will set
it for x number of days, to make it for hours,
delete * 24, for minutes, delete * 60 * 24
*/
if ( expires )
{
expires = expires * 1000 * 60 * 60 * 24;
}
var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}

function Get_Cookie( check_name ) {
	// first we'll split this cookie up into name/value pairs
	// note: document.cookie only returns name=value, not the other components
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; // set boolean t/f default f

	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		// now we'll split apart each name=value pair
		a_temp_cookie = a_all_cookies[i].split( '=' );


		// and trim left/right whitespace while we're at it
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');

		// if the extracted name matches passed check_name
		if ( cookie_name == check_name )
		{
			//alert(a_all_cookies);
			b_cookie_found = true;
			// we need to handle case where cookie has no value but exists (no = sign, that is):
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			// note that in cases where cookie is initialized but no value, null is returned
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found )
	{
		return null;
	}
}

function Kedvenc(cikkszam){
	kedvencek = Get_Cookie('o-4_kedvencek');
	if(!kedvencek) kedvencek='';
	uj = '';
	lista = kedvencek.split("#");
	l = lista.length;
	uj = true;
	i = 0;
	uj_lista = "";
	while(i<l && uj==true){
		if(lista[i] == cikkszam){
			uj = false;
		}
		if(lista[i]!=''){
			uj_lista += "#"+lista[i];
		}
		i++;
	}
	//lista = lista.substring(1,lista.length);
	if(uj==true){
		uj_lista = cikkszam+uj_lista;
		Set_Cookie( 'o-4_kedvencek', uj_lista, '', '/', '', ''  );
	}
	//alert(Get_Cookie('o-4_kedvencek'));
}

function KedvencTorles(cikkszam){
		kedvencek = Get_Cookie('o-4_kedvencek');
		lista = kedvencek.split("#");
		l = lista.length;
		uj_lista = "";
		for(i=0; i<l; i++){
			if(lista[i]!='' && lista[i]!=cikkszam){
				//alert(cikkszam+" != "+lista[i]);
				uj_lista += "#"+lista[i];
			}
		}
		Set_Cookie( 'o-4_kedvencek', uj_lista, '', '/', '', ''  );
		return true;
}


function Hasonlit(cikkszam){
	hasonlit = Get_Cookie('o-4_hasonlit');
	uj = '';
	if(!hasonlit) hasonlit='';	
	lista = hasonlit.split("#");
	l = lista.length;
	uj = true;
	i = 0;
	uj_lista = cikkszam;
	n = 1;
	while(i<l && uj==true && n<3){
		if(lista[i]!='' && lista[i]!=cikkszam){
			uj_lista += "#"+lista[i];
			n++;
		}
		i++;
	}
	Set_Cookie( 'o-4_hasonlit', uj_lista, '', '/', '', ''  );	
}

function HasonlitTorles(cikkszam){
		hasonlit = Get_Cookie('o-4_hasonlit');
		lista = hasonlit.split("#");
		l = lista.length;
		uj_lista = "";
		for(i=0; i<l; i++){
			if(lista[i]!='' && lista[i]!=cikkszam){
				uj_lista += "#"+lista[i];
			}
		}
		Set_Cookie( 'o-4_hasonlit', uj_lista, '', '/', '', ''  );
		return true;
}


function SzuresErtekBetolt(kereses_mit,cikkszam){
	if(AjaxObjFree(ajax_obj)){
		cb = document.getElementById("szures_ertek");
		cb.disabled = true;
		cb = document.getElementById("szures_mezo");
		jellemzo = cb[cb.selectedIndex].value;
		f = document.getElementById("szures_form");
		i = 0;
		szuresek = "";
		while(f["szures_ertek_"+i] ){
			szuresek += f["szures_ertek_"+i].value+"#";
			i++;
		}
		ajax_obj.szuresertekek(jellemzo,szuresek,kereses_mit,cikkszam);
	}
}















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

function KosarErtek2(obj,min){
	obj.value = obj.value.replace(/[^0-9, ',']/g, '');
	if(parseInt(obj.value)<min){
		obj.value = min;
	}
	if(obj.value==""){
		obj.value = min;
	}
}



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,dir){
	ablak = open("kepdialog.php?mod=1&num="+n+"&curr_dir="+dir, "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();
	
	max = k_h-f_h-l_h;
	
	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 Galeria(g){
		ablak = open(g, "kepdialog", "toolbar=0, location=0, directories=0, status=0, menubar=0, resizable=0, width=540, height=430, scrollbars=0");
}


//---Ajax--------------------------------------------------------------------
var ajax_obj;

function loaded(nyelv){
	var MyClassHandler = {
		ureshelykitolt: function(result){
			document.getElementById("tartalom").innerHTML += result;
		},
		
		szuresertekek: function(result){
			document.getElementById("szuro_ertekek").innerHTML = result;
		}
	}
	ajax_obj = new myclass(MyClassHandler); 
	
	f_h = document.getElementById("fej").offsetHeight;
	l_h = document.getElementById("lab").offsetHeight;
	b_h = document.getElementById("bal").offsetHeight;
	t_h = document.getElementById("tartalom").offsetHeight;
	j_h = document.getElementById("jobb").offsetHeight;
	max = t_h;
	if(b_h>max) max = b_h;
	if(j_h>max) max = j_h;
	//ajax_obj.ureshelykitolt(t_h,max);
}

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










