jsFlag = true;

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 {
		if(kit != "flv"){
			document.getElementById('previmage').innerHTML = "<IMG src='"+dir+fn+"'>";
		} else {
			document.getElementById('previmage').innerHTML = "";
		}
	}
}


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;
			}
			kit = fn.substr(fn.length-3, 3);
			if(kit == "swf" || kit == "flv"){
				opener.document.getElementById("kepkeret_"+num).innerHTML = fn;
			} else {
				opener.document.getElementById("kepkeret_"+num).innerHTML = "<IMG src='"+dir+fn+"' width='100' border='1' id='previmg"+id+"'>";
			}
			opener.document.getElementById(num).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(){
	f_h = document.getElementById("fejlec").offsetHeight;
	k_h = document.getElementById("keret").offsetHeight;
	b_h = document.getElementById("bal_flash_keret_div").offsetHeight;
	m_h = document.getElementById("menu_div").offsetHeight;
	a_h = document.getElementById("menu_also_div").offsetHeight;
	
	h = k_h-f_h-b_h-m_h;
	if(h>a_h){
		document.getElementById("menu_also_div").style.height = h+2;
	}
	k_h = document.getElementById("keret").offsetHeight;
	document.getElementById("jobb_arnyek").style.height = k_h;	
}

function Hossz_Beallit(id){
	d = document.getElementById(id);	
	h = d.offsetHeight;
	sor_h = 182;
	if(h%sor_h>0){
		h = (parseInt(h/sor_h)+1)*sor_h;
		d.style.height = h;
	}
}

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 HozzaszolasLista_Frissit(){
	if(AjaxObjFree(ajax_obj)){
		f = document.getElementById("hozzaszol_form");
		ciid = f["video_ciid"].value;	
		ajax_obj.hozzaszolaslista_frissit(ciid);
	}	
}

function VideoValt(ciid){
	f = document.getElementById("hozzaszol_form");
	f["video_ciid"].value = ciid;
	HozzaszolasLista_Frissit();
}

function AlmenuBetolt(mid,mod){
	if(AjaxObjFree(ajax_obj)){
		ajax_obj.almenubetolt(mid,mod);
	}
}

function CikkBetolt(ciid,mod){
	if(AjaxObjFree(ajax_obj)){
		ajax_obj.cikkbetolt(ciid,mod);
	}
}

function Sortores(input_id){
	i = document.getElementById(input_id);
	pos = getSelectionStart(i);
	if(pos != -1){
		t1 = i.value.substr(0,pos);
		t2 = i.value.substr(pos,i.value.length-pos);
		i.value = t1+"<br>"+t2;
	}
}

function getSelectionStart(o) {
	if (o.createTextRange) {
		var r = document.selection.createRange().duplicate()
		r.moveEnd('character', o.value.length)
		if (r.text == '') return o.value.length
		return o.value.lastIndexOf(r.text)
	} else return o.selectionStart
}

function setSound(){
	window.document.sound.SetVariable("_global.jsFlag", jsFlag);
	jsFlag = !jsFlag;
}

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

function loaded(nyelv){
	var MyClassHandler = {
		almenubetolt: function(result){
			document.getElementById("ajanlat_kep_div").innerHTML = result[0];;
			document.getElementById("ajanlatok_am_div").innerHTML = result[1];
			document.getElementById("ajanlatok_cikk_div").innerHTML = result[2];
			document.getElementById("ajanlatok_cikkek_div").innerHTML = result[3];
		},
		cikkbetolt: function(result){
			document.getElementById("ajanlatok_cikk_div").innerHTML = result;
		}			
	}
	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;
}

//PNG--------------------------------------------------------------------------------
function alphaFixIE() {
	var s, i, j;
	// IMG
	var els = document.getElementsByTagName("IMG");
	for (i=0; i<els.length; i++) {
		s = els[i].src;
		if (s.toLowerCase().indexOf(".png") != -1) {
			els[i].src = "/bitmap/spacer.gif";
			els[i].style.filter += "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + s + "', sizingMethod=image);";
		}
	}
	// CSS: background
	for (i=0; i<document.styleSheets.length; i++) {
		var pos = document.styleSheets[i].href.lastIndexOf("/");
		var cssDir = (pos != -1) ? document.styleSheets[i].href.substring(0, pos + 1) : "";
		for (j=0; j<document.styleSheets[i].rules.length; j++) {
			var style = document.styleSheets[i].rules[j].style;
			if (style.backgroundImage.toLowerCase().indexOf(".png") != -1) {
				var filename = style.backgroundImage.substring(4, style.backgroundImage.length - 1);
				if (filename.indexOf("http://") != 0 && filename.indexOf("/") != 0)
					filename = cssDir + filename;
				style.backgroundImage = "none";
				style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + filename + "', sizingMethod='crop');";
			}
		}
	}
}

//if (navigator.userAgent.indexOf("MSIE") != -1 && navigator.userAgent.indexOf("Windows") != -1)
	window.attachEvent("onload", alphaFixIE);
//-----------------------------------------------------------------------------------------











