/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

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 clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
} 


function rowhover(rowname, ishover) {
	if (ishover) { 
		rowname.className='trhover';
	} else { 
		rowname.className='';
	}
}
function jump(url) {
document.location.href = url;
}


//browser 
var ie = (document.all)? true:false;
var ne6 = ((parseInt(navigator.appVersion) >= 5) && (ie == false))? true:false;
var ns4 = (document.layers);
var ie4 = (document.all && !document.getElementById);
var ie5 = (document.all && document.getElementById);
var ns6 = (!document.all && document.getElementById); 


//a megfelelol layer tartalmanak beallitasa
function setLayerText (layername,text) {
if (document.layers) {
		document.layers[layername].innerText = text ;
} else if (document.getElementById) {
		document.getElementById(layername).innerText = text ;
} else if (document.all) {
		document.all.layername.innerText = text ;
}
}


//a layer nevenek kiolvasasa
function getLayer(layerName) {
    if (document.layers) {
        return document.layers[layerName];
    } else if (document.getElementById) {
            return document.getElementById(layerName);
    } else if (document.all) {
        return eval("document.all." + layerName);
    } else return null;
}

//layer elrejtes
function hideLayer(layerName) {
var layerElement = getLayer(layerName);
if(layerElement != null) {
  	  ( ie || ne6 ) ? layerElement.style.visibility = "hidden": layerElement.visibility = "hide";
	  layerElement.style.display="none"; 

}
  }


//layer felfedes
function showLayer(layerName) {
var layerElement = getLayer(layerName);
if(layerElement != null) {
      ( ie || ne6 ) ? layerElement.style.visibility = "visible": layerElement.visibility = "show";
	layerElement.style.display="block";
}
}

function removeBlankLines(str) {
	var arr = str.split("\n");
	var newarr = [];
	for(var i=0;i<arr.length;i++) {
		if(arr[i].length!=0) newarr.push(arr[i]);
	}
	return newarr.join("\n");
}

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();



//---------AJAX funkciók---------------------------------------------------------------------
var ajax_request_num = 0;
var ajax_request_data = new Array();
var ajax_http_array = new Array();
var ajax_open_request = 0;

	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_process_data(num) {
		http=ajax_http_array[num].http;
		url=ajax_http_array[num].url;
		args=ajax_http_array[num].args;
		if (http.readyState == 4) {
			if (http.status>=400) {
				ajax_open_request--;
				alert("A kert cim ("+url+") nem elerheto");
				return;
			}
			var response = http.responseText;
			if(args[1]) {
				var bov=document.getElementById(args[1]);
				if (bov != null) { bov.innerHTML=response; }
				if(args[2]) {
					func=args[2];
					func();
				}
			} else {
				s2=response.split("--==SEPARATOR==--\n");
				for (a=0;a<s2.length;a++) {
					s_pos=s2[a].indexOf("\n");
					if ((s_pos>0) && (s_pos<50)) {
						blokk=s2[a].substr(s_pos+1);
						ctrl=s2[a].substr(0,s_pos);
					} else {
						blokk=s2[a];
						ctrl="HTML";
					}

					if (blokk.length<1) continue;

					s_pos=ctrl.indexOf("/");
					if ((s_pos>0) && (s_pos<5)) {
						pos=ctrl.substr(s_pos+1);
						type=ctrl.substr(0,s_pos);
						//Ha relativ a megadas
						if (pos[0]=="%")
							pos=args[1][pos.substr(1)];
					} else {
						type=ctrl;
						if (args.length>1) {
							pos=args[1];
						} else
							pos="";
					}

					if (type=="JS") eval(blokk);
					if (type=="HTML") {
						el=document.getElementById(pos);
						if (el) el.innerHTML=blokk;
					}
				}
			}
			ajax_open_request--;
			if (ajax_http_array[num].callback) ajax_http_array[num].callback();
			ajax_http_array[num]=null;
		}
	}

	function ajax_load(url) {
		ajax_open_request++;
		num=ajax_request_num;
		ajax_request_num++;
		ajax_http_array[num]=new Array();
		ajax_http_array[num].http = createRequestObject();
		ajax_http_array[num].url=url;
		ajax_http_array[num].args=arguments;
		ajax_http_array[num].http.open('get', url);
		ajax_http_array[num].http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		s='ajax_http_array['+num+'].http.onreadystatechange=function() { ajax_process_data('+num+'); }';
		eval(s);
		ajax_http_array[num].http.send(null);
	}

	function ajax_w_callback(url,func) {
		ajax_open_request++;
		var args = new Array();
		for (a=0;a<arguments.length;a++)
			if (a>=0) args[a-1]=arguments[a];

		num=ajax_request_num;
		ajax_request_num++;
		ajax_http_array[num]=new Array();
		ajax_http_array[num].http = createRequestObject();
		ajax_http_array[num].url=url;
		ajax_http_array[num].args=args;
		ajax_http_array[num].callback=func;
		ajax_http_array[num].http.open('get', url);
		ajax_http_array[num].http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		s='ajax_http_array['+num+'].http.onreadystatechange=function() { ajax_process_data('+num+'); }';
		eval(s);
		ajax_http_array[num].http.send(null);
	}

	function ajax_post(url,post_data) {
		ajax_open_request++;
		var args = new Array();
		for (a=0;a<arguments.length;a++)
			if (a>=0) args[a-1]=arguments[a];

		num=ajax_request_num;
		ajax_request_num++;
		ajax_http_array[num]=new Array();
		ajax_http_array[num].http = createRequestObject();
		ajax_http_array[num].url=url;
		ajax_http_array[num].args=args;
		ajax_http_array[num].http.open('post', url);
		ajax_http_array[num].http.setRequestHeader("X-Requested-With", "XMLHttpRequest");
		s='ajax_http_array['+num+'].http.onreadystatechange=function() { ajax_process_data('+num+'); }';
		eval(s);
		ajax_http_array[num].http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		ajax_http_array[num].http.setRequestHeader("Content-length", post_data.length);
		ajax_http_array[num].http.setRequestHeader("Connection", "close");
		ajax_http_array[num].http.send(post_data);
	}
	               	
	function ajax_wait() {
		return;
		while (ajax_open_request) {
			alert ('AJAX in progress...')	               		
		}
	}

// stíluskezelés
	
function getStyle(x,styleProp) {
	if(!x || !styleProp) return;
	if(BrowserDetect.browser!="Firefox" && BrowserDetect.browser!="Safari") {
		var prop= styleProp.split("-");
		styleProp=prop[0];
		for(var i=1;i<prop.length;i++) {
			styleProp+=prop[i].substr(0,1).toUpperCase()+prop[i].substr(1);
		}
	}
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle) 
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);

	return parseInt(y);
}

function getHeight(elem) {
	if(typeof(elem)=="string") elem=document.getElementById(elem);
	if(!elem) return;
	var o = 0;
	var s = [];
	s.push(getStyle(elem,'padding-top'));
	s.push(getStyle(elem,'padding-bottom'));
	//s.push(getStyle(elem,'margin-top'));
	//s.push(getStyle(elem,'margin-bottom'));
	s.push(getStyle(elem,'border-top-width'));
	s.push(getStyle(elem,'border-bottom-width'));
	for(var i=0;i<s.length;i++) {
		if(!isNaN(s[i])) o+=s[i];
	}
	return(elem.offsetHeight-o);
}

// Cookiekezelés, beállítások kezelése

function getQuerystring(key, url, default_) {
	if (default_==null) default_="";
	key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
	var qs = regex.exec(url);
	if(qs == null)
		return default_;
	else
		return qs[1];
} 	
	
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function DOtestCookies() {
	var date = new Date();
	var time = date.getTime();
	date.setTime(time+(5*1000));
	var expires = "; expires="+date.toGMTString();
	document.cookie = "DOtestCookie="+time+expires+"; path=/";
	if(readCookie("DOtestCookie")==time) return true;
	else return false;
}

// külső adatforrások frissítése
var DOexternals = [];
function DOupdateExternals() {
	var ext=DOexternals.shift();
	if(!ext) return;
	if(!ext['mod']) return;
	var urlplus='';
	if(ext['params']) urlplus='&params='+encodeURI(ext['params']);
	ajax_load('/ajax.php?p=extupdate&mod='+ext['mod']+urlplus);
}

var DOs = {};

function DOreadSettings() {
	var setenc=unescape(readCookie('settings'));
	if(setenc) {
		try {
			DOs = JSON.parse(Base64.decode(setenc));
		} catch(err) {
			DOs = {};
		}
	}
}

function DOgetSetting(name) {
	var setenc = unescape(readCookie('settings'));
	var settings = {};
	if(setenc) {
		try {
			settings = JSON.parse(Base64.decode(setenc));
		} catch(err) {
			settings = {};
		}
	} else return null;
	if(settings[name]) return settings[name];
	return 0;
}

function DOsaveSettings(name,value,rl) {
	var data = {};
	data[name]=value;
	var spl="";
	if(rl) spl="&rl=1";
	ajax_post('settings.php','data='+Base64.encode(JSON.stringify(data))+spl);
}

var DOalert;

function DOmakeAlert(text) {
	var alert=document.createElement('div');
	alert.className="alert";
	alert.innerHTML=text;
	var b = document.body;
	b.insertBefore(alert,b.firstChild);
}

function DOshowAlert() {
	if(DOalert) DOmakeAlert(DOalert);
}

function DOinitCheck() {
	if(DOtestCookies()==false) {
		DOalert='Az oldal megefelelő működéséhez engedélyeznie kell a sütiket!';
		return;
	}
	var res = DOgetSetting('res');
	var cres = screen.width;
	if(res!=null && res!=cres) {
		DOsaveSettings('res',cres,1);
	}
	if((BrowserDetect.browser=="Explorer" && parseInt(BrowserDetect.version)<7)) {
		DOalert='Az Ön böngészője elavult! Ezért az oldal egyes funkciói nem, vagy hibásan működhetnek!';
		return;
	}
}

var DOonload = [];

function DOinit() {
	DOshowAlert();
	DOeq();
	if(typeof(loadKeyCloud)=="function") setTimeout('loadKeyCloud()',500);
	DOupdateExternals();
	while(DOonload.length) {
		var f = DOonload.pop();
		if(typeof f == "function") f();
	}
}

function DOkethasab(d1,d2) {
	d1=document.getElementById(d1);
	d2=document.getElementById(d2);

	var d1_c=d1.childNodes;
	var nodes=new Array();
	for (a=0;a<d1_c.length;a++)
		nodes[a]=d1_c[a];
		
	var d1_p=0;
	var d2_p=0;
	for (a=0;a<nodes.length;a++) {
		if (nodes[a].nodeType!=1) continue;
		var dh=nodes[a].offsetHeight;
		if (d1_p>d2_p) {	//Mozgat
			d2_p+=dh;
			var mdiv=d1.removeChild(nodes[a]);
			d2.appendChild(mdiv);
		} else d1_p+=dh;	//Marad
	}
}

function DOeq() {
	var left=document.getElementById('innerleft');
	var right=document.getElementById('innerright');
	if(!left || !right) return;
	var lh = left.offsetHeight+50;
	var rh = right.offsetHeight;
	if(lh > rh) return;
	var rcn = right.childNodes;
	var ch=0;
	for(var i=0;i<rcn.length;i++) {
		if(rcn[i].nodeType!=1) continue;
		ch+=rcn[i].offsetHeight;
		if(ch>lh && rcn[i].className=='boxitem') rcn[i].parentNode.removeChild(rcn[i]);
	}
}

function moderateComm(id,a) {
	ajax_load("ajax.php?p=moderate&id="+id+"&a="+a);
}

function DDS_load_CSS(name) {
	var fileref=document.createElement("link")
	fileref.setAttribute("rel", "stylesheet")
	fileref.setAttribute("type", "text/css")
	fileref.setAttribute("href", "/"+name+".css");
	document.getElementsByTagName("head")[0].appendChild(fileref);
}

function DOopenURL(atag) {
	var u = atag.href;
	var lr = new RegExp('^http://'+document.domain);
	if(lr.test(u)) {
		return true;
	}
	var _m = u.match(/youtube\.com\/watch\?v=(.+?)(&|$)/);
	if(_m && _m[1]) {
		var div=document.createElement('div');
		div.id = 'yt_'+Math.round(Math.random()*1000);
		atag.parentNode.replaceChild(div,atag);
		swfobject.embedSWF("http://www.youtube.com/v/"+_m[1]+"?version=3&autoplay=1", div.id, "335", "250", "10.0.0","/expressInstall.swf", {}, {},{style:'display:block'});	
		return false;
	}
	var c = confirm('Ez egy külső oldalra mutató hivatkozás!\nA "'+u+'" címen található webhely tartalmáért a DO nem vállal felelősséget.\nBiztosan meg kívánod nyitni?');
	if(c) window.open(u);
	return false;
}

function cTop() {
	var id = 'scHtml';
	var h = document.getElementsByTagName('html')[0];
	var b = document.getElementsByTagName('body')[0];
	var e = (h.scrollTop==0)?b:h;
	if(!e.id) e.id=id;
	else id = e.id;
	var d = document.getElementById('a3_bi_2');
	if(!d) return;
	var p = findPos(d)[1];
	//window.scrollTo(0,findPos(d)[1]);
	DDSanim.animate(id,{"scrollTop":[p,"easeOutSine"]},750);
}

function reply_to(id) {
	document.forms.commentform.reply.value=id;
	var cdiv = document.getElementById('comm'+id);
	if(!cdiv) return;
	DDSDialog.init('commentform','Új hozzászólás','comments',600);
	var cr = document.getElementById('crepl');
	var d = document.createElement('div');
	d.innerHTML = '<b>Válasz a következőre:</b> <div class="commentreplyto"> '+ cdiv.innerHTML+ '</div>';

	var i=0;
	var spans = d.getElementsByTagName('span');
	while(i<spans.length) {
		var s = spans[i];
		if(s.className=="commentname" || s.className=="commentnr") {
			i++;
			continue;
		}
		s.parentNode.removeChild(s);
	}
	cr.innerHTML='';
	cr.appendChild(d);
}

function linkcopy(el,l,rel) {
	var inp = document.createElement('input');
	inp.type='text';
	if(!rel && l[0]!='/') l='/'+l;
	inp.value=(rel)?l:'http://'+document.domain+l;
	inp.className='inp1';
	var p = findPos(el);
	inp.style.position='absolute';
	inp.style.left=p[0]+'px';
	inp.style.top=(p[1]+el.offsetHeight+2)+'px';
	inp.style.width=(rel)?"100px":"350px";
	inp.style.zIndex="100";
	document.getElementsByTagName('body')[0].appendChild(inp);
	inp.focus();
	inp.select();
	inp.onblur=function() {this.parentNode.removeChild(this);};
}

/*
    http://www.JSON.org/json2.js
    2009-08-17

    Public Domain.

    NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

    See http://www.JSON.org/js.html

    This file creates a global JSON object containing two methods: stringify
    and parse.

        JSON.stringify(value, replacer, space)
            value       any JavaScript value, usually an object or array.

            replacer    an optional parameter that determines how object
                        values are stringified for objects. It can be a
                        function or an array of strings.

            space       an optional parameter that specifies the indentation
                        of nested structures. If it is omitted, the text will
                        be packed without extra whitespace. If it is a number,
                        it will specify the number of spaces to indent at each
                        level. If it is a string (such as '\t' or '&nbsp;'),
                        it contains the characters used to indent at each level.

            This method produces a JSON text from a JavaScript value.

            When an object value is found, if the object contains a toJSON
            method, its toJSON method will be called and the result will be
            stringified. A toJSON method does not serialize: it returns the
            value represented by the name/value pair that should be serialized,
            or undefined if nothing should be serialized. The toJSON method
            will be passed the key associated with the value, and this will be
            bound to the value

            For example, this would serialize Dates as ISO strings.

                Date.prototype.toJSON = function (key) {
                    function f(n) {
                        // Format integers to have at least two digits.
                        return n < 10 ? '0' + n : n;
                    }

                    return this.getUTCFullYear()   + '-' +
                         f(this.getUTCMonth() + 1) + '-' +
                         f(this.getUTCDate())      + 'T' +
                         f(this.getUTCHours())     + ':' +
                         f(this.getUTCMinutes())   + ':' +
                         f(this.getUTCSeconds())   + 'Z';
                };

            You can provide an optional replacer method. It will be passed the
            key and value of each member, with this bound to the containing
            object. The value that is returned from your method will be
            serialized. If your method returns undefined, then the member will
            be excluded from the serialization.

            If the replacer parameter is an array of strings, then it will be
            used to select the members to be serialized. It filters the results
            such that only members with keys listed in the replacer array are
            stringified.

            Values that do not have JSON representations, such as undefined or
            functions, will not be serialized. Such values in objects will be
            dropped; in arrays they will be replaced with null. You can use
            a replacer function to replace those with JSON values.
            JSON.stringify(undefined) returns undefined.

            The optional space parameter produces a stringification of the
            value that is filled with line breaks and indentation to make it
            easier to read.

            If the space parameter is a non-empty string, then that string will
            be used for indentation. If the space parameter is a number, then
            the indentation will be that many spaces.

            Example:

            text = JSON.stringify(['e', {pluribus: 'unum'}]);
            // text is '["e",{"pluribus":"unum"}]'


            text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
            // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'

            text = JSON.stringify([new Date()], function (key, value) {
                return this[key] instanceof Date ?
                    'Date(' + this[key] + ')' : value;
            });
            // text is '["Date(---current time---)"]'


        JSON.parse(text, reviver)
            This method parses a JSON text to produce an object or array.
            It can throw a SyntaxError exception.

            The optional reviver parameter is a function that can filter and
            transform the results. It receives each of the keys and values,
            and its return value is used instead of the original value.
            If it returns what it received, then the structure is not modified.
            If it returns undefined then the member is deleted.

            Example:

            // Parse the text. Values that look like ISO date strings will
            // be converted to Date objects.

            myData = JSON.parse(text, function (key, value) {
                var a;
                if (typeof value === 'string') {
                    a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
                    if (a) {
                        return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
                            +a[5], +a[6]));
                    }
                }
                return value;
            });

            myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
                var d;
                if (typeof value === 'string' &&
                        value.slice(0, 5) === 'Date(' &&
                        value.slice(-1) === ')') {
                    d = new Date(value.slice(5, -1));
                    if (d) {
                        return d;
                    }
                }
                return value;
            });


    This is a reference implementation. You are free to copy, modify, or
    redistribute.

    This code should be minified before deployment.
    See http://javascript.crockford.com/jsmin.html

    USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
    NOT CONTROL.
*/

/*jslint evil: true */

/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
    call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
    getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
    lastIndex, length, parse, prototype, push, replace, slice, stringify,
    test, toJSON, toString, valueOf
*/

"use strict";

// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.

if (!this.JSON) {
    this.JSON = {};
}

(function () {

    function f(n) {
        // Format integers to have at least two digits.
        return n < 10 ? '0' + n : n;
    }

    if (typeof Date.prototype.toJSON !== 'function') {

        Date.prototype.toJSON = function (key) {

            return isFinite(this.valueOf()) ?
                   this.getUTCFullYear()   + '-' +
                 f(this.getUTCMonth() + 1) + '-' +
                 f(this.getUTCDate())      + 'T' +
                 f(this.getUTCHours())     + ':' +
                 f(this.getUTCMinutes())   + ':' +
                 f(this.getUTCSeconds())   + 'Z' : null;
        };

        String.prototype.toJSON =
        Number.prototype.toJSON =
        Boolean.prototype.toJSON = function (key) {
            return this.valueOf();
        };
    }

    var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
        gap,
        indent,
        meta = {    // table of character substitutions
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        rep;


    function quote(string) {

// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.

        escapable.lastIndex = 0;
        return escapable.test(string) ?
            '"' + string.replace(escapable, function (a) {
                var c = meta[a];
                return typeof c === 'string' ? c :
                    '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
            }) + '"' :
            '"' + string + '"';
    }


    function str(key, holder) {

// Produce a string from holder[key].

        var i,          // The loop counter.
            k,          // The member key.
            v,          // The member value.
            length,
            mind = gap,
            partial,
            value = holder[key];

// If the value has a toJSON method, call it to obtain a replacement value.

        if (value && typeof value === 'object' &&
                typeof value.toJSON === 'function') {
            value = value.toJSON(key);
        }

// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.

        if (typeof rep === 'function') {
            value = rep.call(holder, key, value);
        }

// What happens next depends on the value's type.

        switch (typeof value) {
        case 'string':
            return quote(value);

        case 'number':

// JSON numbers must be finite. Encode non-finite numbers as null.

            return isFinite(value) ? String(value) : 'null';

        case 'boolean':
        case 'null':

// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.

            return String(value);

// If the type is 'object', we might be dealing with an object or an array or
// null.

        case 'object':

// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.

            if (!value) {
                return 'null';
            }

// Make an array to hold the partial results of stringifying this object value.

            gap += indent;
            partial = [];

// Is the value an array?

            if (Object.prototype.toString.apply(value) === '[object Array]') {

// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.

                length = value.length;
                for (i = 0; i < length; i += 1) {
                    partial[i] = str(i, value) || 'null';
                }

// Join all of the elements together, separated with commas, and wrap them in
// brackets.

                v = partial.length === 0 ? '[]' :
                    gap ? '[\n' + gap +
                            partial.join(',\n' + gap) + '\n' +
                                mind + ']' :
                          '[' + partial.join(',') + ']';
                gap = mind;
                return v;
            }

// If the replacer is an array, use it to select the members to be stringified.

            if (rep && typeof rep === 'object') {
                length = rep.length;
                for (i = 0; i < length; i += 1) {
                    k = rep[i];
                    if (typeof k === 'string') {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            } else {

// Otherwise, iterate through all of the keys in the object.

                for (k in value) {
                    if (Object.hasOwnProperty.call(value, k)) {
                        v = str(k, value);
                        if (v) {
                            partial.push(quote(k) + (gap ? ': ' : ':') + v);
                        }
                    }
                }
            }

// Join all of the member texts together, separated with commas,
// and wrap them in braces.

            v = partial.length === 0 ? '{}' :
                gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
                        mind + '}' : '{' + partial.join(',') + '}';
            gap = mind;
            return v;
        }
    }

// If the JSON object does not yet have a stringify method, give it one.

    if (typeof JSON.stringify !== 'function') {
        JSON.stringify = function (value, replacer, space) {

// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.

            var i;
            gap = '';
            indent = '';

// If the space parameter is a number, make an indent string containing that
// many spaces.

            if (typeof space === 'number') {
                for (i = 0; i < space; i += 1) {
                    indent += ' ';
                }

// If the space parameter is a string, it will be used as the indent string.

            } else if (typeof space === 'string') {
                indent = space;
            }

// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.

            rep = replacer;
            if (replacer && typeof replacer !== 'function' &&
                    (typeof replacer !== 'object' ||
                     typeof replacer.length !== 'number')) {
                throw new Error('JSON.stringify');
            }

// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.

            return str('', {'': value});
        };
    }


// If the JSON object does not yet have a parse method, give it one.

    if (typeof JSON.parse !== 'function') {
        JSON.parse = function (text, reviver) {

// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.

            var j;

            function walk(holder, key) {

// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.

                var k, v, value = holder[key];
                if (value && typeof value === 'object') {
                    for (k in value) {
                        if (Object.hasOwnProperty.call(value, k)) {
                            v = walk(value, k);
                            if (v !== undefined) {
                                value[k] = v;
                            } else {
                                delete value[k];
                            }
                        }
                    }
                }
                return reviver.call(holder, key, value);
            }


// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.

            cx.lastIndex = 0;
            if (cx.test(text)) {
                text = text.replace(cx, function (a) {
                    return '\\u' +
                        ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
                });
            }

// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.

// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.

            if (/^[\],:{}\s]*$/.
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {

// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.

                j = eval('(' + text + ')');

// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.

                return typeof reviver === 'function' ?
                    walk({'': j}, '') : j;
            }

// If the text is not JSON parseable, then a SyntaxError is thrown.

            throw new SyntaxError('JSON.parse');
        };
    }
}());


var a3_ajax_req_num=0;
var ajax_last_request="";

function a3_ajax_setcontent(id,cont) {
	id_block=document.getElementById("template_abox_"+id);
	if (!id_block) {
		document.location=ajax_last_request;
		return;
	}
	id_block.innerHTML=cont;
}

function ajax_reloadbyid(id) {
	var elem = document.getElementById(id);
	if(!elem) return;
	var href = window.location.href;
	var qs = href.split('?');
	var url = 'domreload.php?htmlid='+id;
	if(qs[1]) url+='&'+qs[1];
	ajax_load(url);
}

function ajax_reload(box,u) {
	var href = window.location.href;
	var url = href.split('#');
	var fake_a = document.createElement('a');
	fake_a.href = (u)?u:url[0];
	ajax_url(fake_a,box);
	
}

function ajax_url(a_tag) {
	//Ha van megadva blokk
	a3_ajax_blokk="";
	if (arguments.length>1)
		a3_ajax_blokk=arguments[1];

	//Ha van target, akkor ez nem lehet
	if (a_tag.target) return true;
	
	//Utolso keres URL, hogy ha nem sikerul a keres, akkor ez legyen
	ajax_last_request=a_tag.href;

	//Az iframe url megvaltoztatasa
	a3_req_plus="&";
	if (a_tag.search.length==0) a3_req_plus="?";
	window.a3_ajax_frame=document.getElementById("a3_ajax_frame");
	window.a3_ajax_frame.src=a_tag.href+a3_req_plus+"ajax_mode=1&ajax_id="+a3_ajax_req_num+"&ajax_block="+a3_ajax_blokk;
	a3_ajax_req_num++;
	return false;
}


function clearText(thefield){
	if (thefield.defaultValue==thefield.value)
	thefield.value = ""
} 


//keresobox 
var boxname = "sboxextra";
function down(px) {
	if (px<170) {
		document.getElementById(boxname).style.height=px+"px";
		px=px+10;
		setTimeout("down("+px+")", 5);
	}
}

function sOut() {
	if(document.getElementById(boxname).style.display!="block") {
		document.getElementById(boxname).style.display="block"; 
		document.getElementById(boxname).style.height="0px";
		down(5);
	}
}

function sIn() {
	if(document.getElementById(boxname).style.display!="none") {
		document.getElementById(boxname).style.display="none";
	}
}

function changeCheck(obj) {
	elms=document.forms['search'].elements;
	if(obj.name=="t[0]") {
		for (i=1;i<8;i++) 
			if(elms["t["+i+"]"].type=="checkbox") {
				elms["t["+i+"]"].checked=0;
			}
	} else if(elms["t[0]"].checked==1) {
			elms["t[0]"].checked=0;
		}
	return;
}

// hintelés
var searchtext;
var htimer;
var currentitem=-1;
var hintitems=new Array();

function keyup(event) {
	var keynum;

	if(window.event) {
		keynum = event.keyCode;
	} else if(event.which) {
		keynum = event.which;
	}
	//alert(keynum);
	clearTimeout(htimer);
	if(keynum==38) {
		selectItem(0);
	}
	if(keynum==40) {
		selectItem(1);
	}
	if(keynum==13) {
		sIn();
		return false;
	}
	if((keynum<47 && keynum!=8 && keynum!=32) || (keynum>111 && keynum<184) ) {
		return false;
	}
	searchtext=document.forms.addform.s.value;
	if(searchtext.length>2) {
		htimer = setTimeout("getHint()",200);
	} else sIn();
}

function getHint() {
	ajax_load("/ajax.php?p=hints&s="+encodeURI(searchtext));
}
function selectItem(dir,nr) {
	if(currentitem!=-1 && currentitem!=hintitems.length) {
		var previtem = document.getElementById('tal'+currentitem);
		previtem.className="sboxhint";
	}
	if (typeof(nr)=="number") currentitem=nr;
	else {
		if(dir==0) currentitem--;
		else currentitem++;
	}
	
	if(currentitem==-1 || currentitem==hintitems.length) {
		document.forms.addform.s.value=searchtext;
		return;
	}
	if(currentitem<0) currentitem=hintitems.length-1;
	if(currentitem>hintitems.length) currentitem=0;
	
	var item=document.getElementById('tal'+currentitem);
	item.className="sboxhinta";
	if(typeof(nr)!="number") 
		document.forms.addform.s.value=hintitems[currentitem];
}


/*	SWFObject v2.2 <http://code.google.com/p/swfobject/> 
	is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> 
*/
var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();

// DDS Galéria + Dialog - 09.02.19.

var idstohide=new Array(); //TODO!! flash tartalmu elemek id-i.

var imgpath="/galeria/660x495/";
var imgpath2="/galeria/full/";
var thumbpath="/galeria/60x60/";
var videopath="/video/";
var vthumb1="/getvimage.php?img=";
var vthumb2="/getvimage.php?s=2&img=";
var noimage="images/sp.gif";
var initsize=new Array(950,560);
var mode=1; // 1 kép, 2 video
var slideshowtime=2000;
var player;
var sself;
var zoomed=null;
var inlinegal=null;

// --
var gloaded=0;
var startimg=0;
var imagedata=new Array();
var images=new Array();

var cp=0; // mode 2 aktuális oldal
var curdir=''; //aktuális mappanév
var curdirdesc=''; //aktuális mappa leírás
var curimgdiv=1;
var slideshow=0;
var TimeToFade = 200.0;
var TimeToResize = 200.0;

var slideshowtimer;
var thumbsloaded=0;

function galSize(width,height) {
	this.width = width;
	this.height = height;
}

function isArray(obj) {
    return obj.constructor == Array;
}

function array_chunk( input, size ) {
	for(var x, i = 0, c = -1, l = input.length, n = []; i < l; i++){
		(x = i % size) ? n[c][x] = input[i] : n[++c] = [input[i]];
	}
	return n;
}

function galImage(src,txt,pnr,desc,id) {
	this.src = imgpath+src;
	this.thumb = thumbpath+src
	this.full = imgpath2+src;
	this.text = txt;
	this.desc = desc;
	this.nr = pnr;
	this.top = '';
	this.left = '';
	this.width = '';
	this.height = '';
	this.afterLoad = '';
	this.id=id;
	var galimg=this;
	this.loadImage = function() {
		galimg.preimg=new Image();
		galimg.preimg.onload=function(){
			galimg.top=-1+(500-galimg.preimg.height)/2+'px';
        		galimg.left=-1+(670-galimg.preimg.width)/2+'px';
        		galimg.width=galimg.preimg.width;
        		galimg.height=galimg.preimg.height;
        		galimg.loaded=1;
        		if(typeof(galimg.afterLoad)=="function") {
        			galimg.afterLoad();
        			galimg.afterLoad='';
        		}
               	}
        	galimg.preimg.src=galimg.src;
	}
	this.loadThumb = function() {
		galimg.pretimg=new Image();
		galimg.pretimg.onload=function(){
			galimg.tloaded=1;
        		thumbsloaded+=1;
        		if(thumbsloaded==images.length) {
        			loadThumbs();
        		}
               	}
        	galimg.pretimg.src=galimg.thumb;
	}
}

function galVideo(src,txt,pnr,desc,id) {
	this.file = videopath+src;
	this.thumb = vthumb1+src.replace(/flv/,"jpg");
	this.thumb2 = vthumb2+src.replace(/flv/,"jpg");
	this.text = txt;
	this.desc = desc;
	this.nr = pnr;
	this.top = '';
	this.left = '';
	this.width = '';
	this.height = '';
	this.afterLoad = '';
	this.id=id;
	var galimg=this;
	this.loadThumb = function() {
		galimg.pretimg=new Image();
		galimg.pretimg.onload=function(){
			galimg.tloaded=1;
        		thumbsloaded+=1;
        		if(thumbsloaded==images.length) {
        			loadThumbs();
        		}
               	}
        	galimg.pretimg.src=galimg.thumb;
	}
}


function showGallery(gid,pid){
	if(mode==1) {
		var shslider = new Slider('lbslider', 60, 10, bgcolor="#ffffff", fgcolor="#206fa8", "1px solid #206fa8");
		shslider.onNewPosition = function() {
			stime=(2000 + (parseInt(shslider.position * 8000))) / 1000;
			document.getElementById("lbsliderlabel").innerHTML = stime.toFixed(1) + ' s'; 
			slideshowtime= (2000 + (parseInt(shslider.position * 8000)));
		}
	}
	if(pid) startimg=pid;
	else startimg=1;
	ipreload('/images/gallery/pause.gif');
	current=startimg-1;
	thumbsloaded=0;
}

function galleryReload() {
	image=document.getElementById('lbimage1');
	image2=document.getElementById('lbimage2');
	image2.src=noimage;
        cntr=document.getElementById('counter');
        keptxt=document.getElementById('lbtext');
        kepdesc=document.getElementById('lbdesc');
        thumbs=document.getElementById('lbthumbs');
	
	if(mode==1) {
		for(var im=0;im<imagedata.length;im++) {
			if(!images[im]) images[im] = new galImage(imagedata[im].file,imagedata[im].title,im,imagedata[im].desc,imagedata[im].id);
			//if(!images[im].loaded) images[im].loadImage();
			//if(!images[im].tloaded) images[im].loadThumb();
			images[im].w=imagedata[im].w;
			images[im].h=imagedata[im].h;
		}
	} else {
		for(var im=0;im<imagedata.length;im++) {
			if(!images[im]) images[im] = new galVideo(imagedata[im].file,imagedata[im].title,im,imagedata[im].desc,imagedata[im].id);
			//if(!images[im].loaded) images[im].loadImage();
			if(!images[im].tloaded) images[im].loadThumb();
		}
	
	}
	
	if (mode==1) {
		showItem('lbimage1',0);
		loadImages(current);
		loadImage(images[current].src);
		curimgdiv=1;
        } else {
        	//showItem('lbvideo');
        	setTimeout("videoLoad("+current+")",1000);
        }
        if(images[current].text) {
        	keptxt.innerHTML=images[current].text;
        	kepdesc.innerHTML=images[current].desc;
        }
        cntr.innerHTML=current+1+'/'+imagedata.length;
}


function prevImage(){
	
	if(curimgdiv==1) curimgdiv=2;
	else curimgdiv=1;
	image=document.getElementById('lbimage'+curimgdiv);
	changeOpacity(0,'lbimage'+curimgdiv);
	cntr=document.getElementById('counter');
	keptxt=document.getElementById('lbtext');
	kepdesc=document.getElementById('lbdesc');
	
	current--;
	if(current<0) current=images.length-1;
	if(mode==1) {
		
		loadImages(current);
		image.src=images[current].src;
		image.style.top=images[current].top;
		image.style.left=images[current].left;
		if (curimgdiv==1) { 
			fadeIn('lbimage1');
			fadeOut('lbimage2'); 
		} else { 
			fadeIn('lbimage2');
			fadeOut('lbimage1'); 
		} 
		
	} else {
		videoLoad(current);
	}
	cntr.innerHTML=current+1+'/'+images.length;
	if(images[current].text) {
		keptxt.innerHTML=images[current].text;
		kepdesc.innerHTML=images[current].desc;
		image.alt=images[current].text;
	} else {
		keptxt.innerHTML='';
		kepdesc.innerHTML='';
		image.alt='';
	}
	if(slideshow==1) {
		clearTimeout(slideshowtimer);
		slideshowtimer=setTimeout("nextImage()",slideshowtime);
	}

}

function nextImage(){
	if(curimgdiv==1) curimgdiv=2;
	else curimgdiv=1;
	image=document.getElementById('lbimage'+curimgdiv);
	changeOpacity(0,'lbimage'+curimgdiv);
	cntr=document.getElementById('counter');
	keptxt=document.getElementById('lbtext');
	kepdesc=document.getElementById('lbdesc');
	
	current++;
	if(current==images.length) current=0;

	if(mode==1){
		loadImages(current);
		image.src=images[current].src;
		image.style.top=images[current].top;
		image.style.left=images[current].left;
		if (curimgdiv==1) { 
			fadeIn('lbimage1');
			fadeOut('lbimage2'); 
		} else { 
			fadeIn('lbimage2');
			fadeOut('lbimage1'); 
		}
		
	} else {
		videoLoad(current);
	}
	cntr.innerHTML=current+1+'/'+images.length;
	if(images[current].text) {
		keptxt.innerHTML=images[current].text;
		kepdesc.innerHTML=images[current].desc;
		image.alt=images[current].text;
	} else {
		keptxt.innerHTML='';
		kepdesc.innerHTML='';
		image.alt='';
	}
	if(slideshow==1) {
		clearTimeout(slideshowtimer);
		slideshowtimer=setTimeout("nextImage()",slideshowtime);
	}
}

function prevfImage(){
	var image=document.getElementById('lbimage');
	current--;
	if(current<0) {
		current=0;
		return;//current=images.length-1;
	}
	loadImages(current,1);
	showfImage(current);
}

function nextfImage(){
	var image=document.getElementById('lbimage');
	current++;
	if(current==images.length) {
		current=images.length-1;
		return;//current=0;
	}
	loadImages(current,1);
	showfImage(current);
}

function changeImage(id) {
	if(mode==1 && !images[id].loaded) {
		images[id].afterLoad=function() {
			showImage(id);
		}
		loadImages(id);
	} else {
		showImage(id);
	}
	return false;
}

function showImage(id){
	if(curimgdiv==1) curimgdiv=2;
	else curimgdiv=1;
	image=document.getElementById('lbimage'+curimgdiv);
	changeOpacity(0,'lbimage'+curimgdiv);
	cntr=document.getElementById('counter');
	keptxt=document.getElementById('lbtext');
	kepdesc=document.getElementById('lbdesc');
	
	current=id;
	
	if(mode==1){
		image.src=images[current].src;
		image.style.top=images[current].top;
		image.style.left=images[current].left;
		if (curimgdiv==1) { 
			fadeIn('lbimage1');
			fadeOut('lbimage2'); 
		} else { 
			fadeIn('lbimage2');
			fadeOut('lbimage1'); 
		}
				
	} else {
		videoLoad(current);
	}
	cntr.innerHTML=current+1+'/'+images.length;
	//if(images[current].text) {
		keptxt.innerHTML=images[current].text;
		kepdesc.innerHTML=images[current].desc;
		image.alt=images[current].text;
	//} 
		
	if(slideshow==1) {
		clearTimeout(slideshowtimer);
		slideshowtimer=setTimeout("nextImage()",slideshowtime);
	}
}

function resizeImage(img){
 	pagesize=getPageSize();
 	arany=img.width/img.height;
 	if(img.height>pagesize[1]) {
 		img.height=pagesize[1]-80;
 		img.width=img.height*arany;
 	}
	if(img.width>pagesize[0]) {
 		img.width=pagesize[0]-80;
 		img.height=img.width/arany;
 	}
 	return img;
}

function showFullImage(id) {
	document.onkeydown=galkeyup;
	if(slideshow) slideShow();
	current=id;
	var pri=new Image();
	var page = getPageSize();
	var sizes = getImageSizes(images[id].w,images[id].h,page[0]-100,page[1]-170);
	var scroll = getPageScrollTop();
	showHideFlash();
	
	var gn=document.getElementById('gnext');
	var gp=document.getElementById('gprev');
	/*gn.style.color='';
	gp.style.color='';*/
	changeOpacity(100,'gprev');
	changeOpacity(100,'gnext');
	
	if(current==0) changeOpacity(40,'gprev');//gp.style.color="#dddddd";
	if(current==images.length-1) changeOpacity(40,'gnext');//gn.style.color="#dddddd";
	
	pri.onload=function() {
		var fimage=document.getElementById('lbimage');
		var box=document.getElementById('fullbox');
		var count=document.getElementById('lbcount');
		
		count.innerHTML=(current+1)+'/'+images.length;
		fimage.src=images[id].full;
		document.getElementById('lbfulltitle').innerHTML=(images[id].text)?images[id].text:'';
		fimage.width=sizes[0];
		fimage.height=sizes[1];
		overlayReload();
		center('fullbox',sizes[0]+40,sizes[1]);
		box.style.width=sizes[0]+'px';
		box.style.height=sizes[1]+'px';
		showItem('overlay');
		showItem('fullbox');
		window.onresize=overlayReload;
	}
	pri.src=images[id].full;
}

function showfImage(id) {
	
	current=id;
	var pri=new Image();
	var page = getPageSize();
	var sizes = getImageSizes(images[id].w,images[id].h,page[0]-100,page[1]-170);
	var positions = getcenter(sizes[0]+50,sizes[1]);
	var scroll = getPageScrollTop();
			
	var gn=document.getElementById('gnext');
	var gp=document.getElementById('gprev');
	/*gn.style.color='';
	gp.style.color='';*/
	changeOpacity(100,'gprev');
	changeOpacity(100,'gnext');
	var fbload =document.getElementById('fbloading');
	
	if(current==0) changeOpacity(40,'gprev');//gp.style.color="#dddddd";
	if(current==images.length-1) changeOpacity(40,'gnext');//gn.style.color="#dddddd";
	
	pri.onload=function() {
		var fimage=document.getElementById('lbimage');
		var count=document.getElementById('lbcount');
		var box=document.getElementById('fullbox');
		var samesize = (fimage.width==sizes[0] && fimage.height==sizes[1])?1:0;
		document.getElementById('lbfulltitle').innerHTML=(images[id].text)?images[id].text:'';
		fimage.width=sizes[0];
		fimage.height=sizes[1];
		count.innerHTML=(current+1)+'/'+images.length;
		fimage.src=images[id].full;
		if(!samesize) {
			document.getElementById('fbcont').style.display='none';
			box.postAction=function() {
				document.getElementById('fbcont').style.display='';
			}
			DDSanim.resizeTo('fullbox',sizes[0],sizes[1],positions[0],positions[1],500);
		}
		if(fbload) fbload.style.visibility='hidden';
	}
	if(fbload) fbload.style.visibility='visible';
	pri.src=images[id].full;
}

function hideFullImage(a) {
	document.onkeydown="";
	if(!a && !inlinegal) showImage(current);
	window.onresize='';
	hideItem('overlay');
	hideItem('fullbox');
	var fimage=document.getElementById('lbimage');
	fimage.src=noimage;
	document.getElementById('lbfulltitle').innerHTML='';
	showHideFlash(1);
}

function gInit(imagedata,sti,fpath) {
	current=(sti)?sti:0;
	images=[];
	for(var im=0;im<imagedata.length;im++) {
		if(!images[im]) images[im] = new galImage(imagedata[im].file,imagedata[im].title,im,imagedata[im].desc,imagedata[im].id);
		//if(!images[im].loaded) images[im].loadImage();
		//if(!images[im].tloaded) images[im].loadThumb();
		images[im].w=imagedata[im].w;
		images[im].h=imagedata[im].h;
		if(fpath) images[im].full=fpath+imagedata[im].file;
	}
	showFullImage(current);
}

showZoomImage = function(img) {
	var pri = new Image();
	var self = this;
	var page = getPageSize();
	var sizes = getImageSizes(img.w,img.h,page[0]-100,page[1]-150);
	//var sizes = [img.w,img.h];
	var positions = getcenter(sizes[0]+50,sizes[1]);
	var scroll = getPageScrollTop();
	var fimage=document.getElementById('zoom_image');
	var o_pos = findPos(zoomed);
	pri.onload=function() {
		fimage.src=img.src;
		fimage.width=sizes[0];
		fimage.height=sizes[1];
		fimage.style.top=positions[0]+"px";
		fimage.style.left=positions[1]+"px";
		/*fimage.style.width=zoomed.offsetWidth+'px';
		fimage.style.height=zoomed.offsetHeight+'px';
		fimage.style.top=(o_pos[1]-3)+"px";
		fimage.style.left=(o_pos[0]-3)+"px";*/
		zoomed=null;
		overlayReload();
		showItem('overlay');
		showItem('zoom_image');
		showHideFlash();
		//DDSanim.resizeTo('zoom_image',sizes[0],sizes[1],positions[0],positions[1],500)
		
		//window.onresize=overlayReload;
		//document.getElementsByTagName("body")[0].style.overflow = "hidden"; 
	};
	pri.src=img.src;
};
hideZoomImage = function() {
	hideItem('overlay');
	var fimage=document.getElementById('zoom_image');
	fimage.style.display='none';
	//fimage.style.width=fimage.style.height='0';
	fimage.src=noimage;
	showHideFlash(1);
}

function showItem(item,opc) {
	obj=document.getElementById(item);
	//alert(obj.id + ' ' + typeof(opc));
	obj.style.display='block';
	if (typeof(opc)=='number') {
		changeOpacity(opc,item);
	}
}

function hideItem(item,opc) {
	obj=document.getElementById(item);
	obj.style.display='none';
	if (typeof(opc)=='number') {
		changeOpacity(opc,item);
	}
}

function showHideItem(item) {
	obj=document.getElementById(item);
	(obj.style.display=='none')?obj.style.display='':obj.style.display='none';
}

function loadImage(src) {
	if(src.indexOf('.jpg')==-1) src=noimage;
	showItem('loading');
	image=document.getElementById('lbimage1');
	preimg=new Image();
	preimg.onload=function(){
		image.src=src;  //imgpath+imagelist[current];
		image.style.top=(500-preimg.height)/2+'px';
        	image.style.left=(670-preimg.width)/2+'px';
        	changeOpacity(0,'lbimage1');
        	fadeIn('lbimage1');
        	hideItem('loading');
        }
        preimg.src=src;
}

function loadImages(cur,conly) {
	var nxt=cur+1;
	if (nxt==images.length) nxt=0;
	var prv=cur-1;
	if (prv==-1) prv=images.length-1;
	
	if(!images[cur].loaded) images[cur].loadImage();
	if(conly) return;
	if(!images[nxt].loaded) images[nxt].loadImage();
	if(!images[prv].loaded) images[prv].loadImage();
} 

function loadThumbs() {
	 for (var x=0; x<images.length; x++) {
                var i=cp*20+x;
                var url=sself+"?p="
                url+=(mode==2)?"vgaleria":"galeria";
                url+="&amp;g="+curgal+"&amp;pic="+images[x].id;

                thumbs.innerHTML+='<a href="'+url+'" onclick="return changeImage('+x+');"><img id="thmb'+x+'" class="thumb" src="'+images[x].thumb+'" onmouseover="changeOpacity(60,this.id);" onmouseout="changeOpacity(100,this.id);" alt="'+images[x].text+'" title="'+images[x].text+'" /></a>';

        }
}

function changeOpacity(opacity, id) {
	var object = document.getElementById(id).style;
	object.opacity = (opacity / 100);
	object.MozOpacity = (opacity / 100);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}

function slideShow() {
	if(slideshow==0) {
		if (mode==2) return;
		slideshow=1;
		document.getElementById('slidestartstop').src="/images/gallery/pause.gif";
		document.getElementById('slidestartstop').alt="stop";
		slideshowtimer=setTimeout("nextImage()",slideshowtime);
	} else {
		slideshow=0;
		document.getElementById('slidestartstop').src="/images/gallery/play.gif";
		document.getElementById('slidestartstop').alt="start";
		clearTimeout(slideshowtimer);
	}
}

function ipreload(img) {
	preimg=new Image();
	preimg.src=img;
}

function fadeIn(eid) {
	fade(eid,1);
}

function fadeOut(eid) {
	fade(eid,-1);
}

function fade(eid,direction) {
	var element = document.getElementById(eid);
	if(element == null)
		return;
	element.FadeTimeLeft = TimeToFade;
	if(direction == 1) element.style.display = 'block';
	setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "', " + direction + ")", 33);
}

function animateFade(lastTick, eid, direction) { 
	var curTick = new Date().getTime();
	var elapsedTicks = curTick - lastTick;
	var element = document.getElementById(eid);
 
	if(element.FadeTimeLeft <= elapsedTicks) {
		element.style.opacity = direction == 1 ? '1' : '0';
		element.style.KhtmlOpacity = direction == 1 ? '1' : '0';
		element.style.filter = 'alpha(opacity=' + (direction == 1 ? '100' : '0') + ')';
		//element.FadeState = direction == 1 ? 2 : -2;
		
		if (direction == -1) element.style.display = 'none';
		if (typeof(element.AfterFade)!='undefined') element.AfterFade();
		return;
	}

	element.FadeTimeLeft -= elapsedTicks;
	var newOpVal = element.FadeTimeLeft/TimeToFade;
	if(direction == 1)
		newOpVal = 1 - newOpVal;

	element.style.opacity = newOpVal;
	element.style.MozOpacity = newOpVal;
	element.style.KhtmlOpacity = newOpVal;
	element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
	setTimeout("animateFade(" + curTick + ",'" + eid + "', " + direction +")", 33);
}

function galResize(eid,nw,mode) {
	var element = document.getElementById(eid);
	if(element == null)
		return;
	element.ResizeTimeLeft = TimeToResize;
	var ow = element.width;
	var oh = element.height;
	var nh = (oh/ow)*nw;
	setTimeout("animateResize(" + new Date().getTime() + ",'" + eid + "',"+ow+","+oh+","+nw+","+nh+")", 33);
	
}

function animateResize(lastTick, eid, ow,oh,nw,nh) { 
	var curTick = new Date().getTime();
	var elapsedTicks = curTick - lastTick;
	var element = document.getElementById(eid);
 
	if(element.ResizeTimeLeft <= elapsedTicks) {
		element.width = nw;
		element.height = nh;
		if (typeof(element.AfterResize)!='undefined') element.AfterResize();
		
		return;
	}

	element.ResizeTimeLeft -= elapsedTicks;
	var newWidth = ow + (nw - ow)*((TimeToResize-element.ResizeTimeLeft)/TimeToResize);
	var newHeight = oh + (nh - oh)*((TimeToResize-element.ResizeTimeLeft)/TimeToResize);

	element.width = newWidth;
	element.height = newHeight;
	center(eid,newWidth,newHeight);
	setTimeout("animateResize(" + curTick + ",'" + eid + "',"+ow+","+oh+","+nw+","+nh+")", 33);
}

function getPlayer(gid) {
        if(navigator.appName.indexOf("Microsoft") != -1) {
                return window[gid];
        } else {
                return document[gid];
        }
}

function videoLoad(id) {
        var obj = {file: images[id].file, image: images[id].thumb2 }; 
        player.sendEvent("STOP");
        player.sendEvent("LOAD",obj);
//        player.sendEvent("PLAY","true");
}
 
function playerReady(obj) {
	player = document.getElementById('lbvideo');
}

// lb
function overlayReload()
{
		if (window.innerHeight && window.scrollMaxY>=0 || window.innerWidth && window.scrollMaxX>=0) {
                yScroll = window.innerHeight + window.scrollMaxY;
                xScroll = window.innerWidth + window.scrollMaxX;
                var deff = document.documentElement;
                var wff = (deff&&deff.clientWidth) || document.body.clientWidth || window.innerWidth || self.innerWidth;
                var hff = (deff&&deff.clientHeight) || document.body.clientHeight || window.innerHeight || self.innerHeight;
                xScroll -= (window.innerWidth - wff);
                yScroll -= (window.innerHeight - hff);

        } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac
                yScroll = document.body.scrollHeight;
                xScroll = document.body.scrollWidth;
        } else { // Explorer Mac... Explorer 6 Strict, Mozilla, Safari
                yScroll = document.body.offsetHeight;
                xScroll = document.body.offsetWidth;
        }
        olay=document.getElementById('overlay');
        /*var pagesize = getPageSize();
        if(pagesize[1]>yScroll) yScroll=pagesize[1];
        if(pagesize[0]>xScroll) xScroll=pagesize[0];*/
        olay.style.height = yScroll +'px';
        olay.style.width = xScroll +'px';
}

function center(windowname, fwidth, fheight) {
        var successWin = document.getElementById(windowname);
        var pagesize = getPageSize();
        var arrayPageScroll = getPageScrollTop();
        lbtop = (arrayPageScroll[1] + (pagesize[1] - fheight)/3);
        lbleft = (arrayPageScroll[0] + (pagesize[0] - fwidth)/2);
        successWin.style.top = (lbtop < 0) ? "0px" : lbtop + "px";
        successWin.style.left = (lbleft < 0) ? "0px" : lbleft + "px";
}

function getcenter(fwidth,fheight) {
	  var pagesize = getPageSize();
	  var arrayPageScroll = getPageScrollTop();
	  lbtop = (arrayPageScroll[1] + (pagesize[1] - fheight)/3);
	  lbleft = (arrayPageScroll[0] + (pagesize[0] - fwidth)/2);
	  var t = (lbtop < 0) ? "0" : lbtop;
	  var l = (lbleft < 0) ? "0" : lbleft;
	  return [t,l];
}

function getPageSize(){
        var de = document.documentElement;
        var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
        var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight
        arrayPageSize = new Array(w,h)
        return arrayPageSize;
}

function getPageScrollTop(){
        var yScrolltop;
        var xScrollleft;
        if (self.pageYOffset || self.pageXOffset) {
                yScrolltop = self.pageYOffset;
                xScrollleft = self.pageXOffset;
        } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){     // Explorer 6 Strict
                yScrolltop = document.documentElement.scrollTop;
                xScrollleft = document.documentElement.scrollLeft;
        } else if (document.body) {// all other Explorers
                yScrolltop = document.body.scrollTop;
                xScrollleft = document.body.scrollLeft;
        }
        arrayPageScroll = new Array(xScrollleft,yScrolltop)
        return arrayPageScroll;
}


function getImageSizes(xsize,ysize,maxx,maxy) {
	if(xsize>maxx || ysize>maxy) {
		var ax=xsize/maxx;
		var ay=ysize/maxy;
	
		var direction=1;
		if (ay>ax) direction=0;

		if (direction) {
			xsize=Math.floor(xsize/ax);
			ysize=Math.floor(ysize/ax);
		} else {
			xsize=Math.floor(xsize/ay);
			ysize=Math.floor(ysize/ay);
		}
		if(xsize<370) {
			var r=ysize/xsize;
			xsize=370;
			ysize=Math.floor(xsize*r);
		}
	}
	return [xsize,ysize];
}

function showHideFlash(s) {
	var elemse = document.getElementsByTagName('embed');
	var elemso = document.getElementsByTagName('object');
	var elemss = document.getElementsByTagName('select');
	for(var i=0;i<elemse.length;i++) {
		elemse[i].style.visibility = (s)?'visible':'hidden';
	}
	for(var i=0;i<elemso.length;i++) {
		elemso[i].style.visibility = (s)?'visible':'hidden';
	}
	for(var i=0;i<elemss.length;i++) {
		elemss[i].style.visibility = (s)?'visible':'hidden';
	}
	for(var i=9;i<13;i++) {
		var banner = document.getElementById('banner_'+i);
		if(!banner) continue;
		banner.style.visibility = (s)?'visible':'hidden';
	}
}

galkeyup = function(e) {
	var keynum;
	if(window.event) {
		e = window.event;
		keynum = e.keyCode;
	} else if(e.which) {
		keynum = e.which;
	}
	
	if(keynum==27) {	// Esc
		if(document.getElementById('helpbox').style.display!='none') hideItem('helpbox');
		else hideFullImage();
		return false;
	}
	
	if(keynum==35) {	// End
		showfImage(images.length-1);
		return false;
	}
	if(keynum==36) {	// Home
		showfImage(0);
		return false;
	}
	
	if(keynum==37) {	// <--
		prevfImage();
		return false;
	}
	if(keynum==39) {	// -->
		nextfImage();
		return false;
	}
	if(keynum==112) {	// F1
		showHideItem('helpbox');
		return false;
	}
	
	return;
}

zoomImage = function(img,z) {
	zoomed=z;
	ajax_load('/zoomlb.php?kep='+img);
};

DDSDialog = function() {
	var dialogopen = 0;
	var elem = null;
	var dparent = null;
	var dialog = null;
	var title = null;
	var content = null;
	var close = null;
	var error = null;
	this.width = "500";
	this.boxname = "";
	this.onInit = null;
	this.onClose = null;
	
	this.init = function(id,t,box,w) {
	
		dialog = document.getElementById('dds_dialog');
		title = document.getElementById('dds_dialog_title');
		content = document.getElementById('dds_dialog_content');
		close = document.getElementById('dds_dialog_close');
		error = document.getElementById('dds_dialog_error');
		
		this.reset();
		
		/*var dia = this;
		close.onclick= function() {
			dia.hide();
		}*/
		elem = document.getElementById(id);
		if(!elem) return;
		dparent = elem.parentNode;
		var cont = dparent.removeChild(elem);
		content.appendChild(cont);
		cont.style.display = '';
		title.innerHTML = t;
		if(box) this.boxname = box;
		if(w) this.width = w;
		this.show();
		if(typeof(this.onInit) == "function") {
			this.onInit();
			this.onInit=null;
		}
		
	};
	this.show = function() {
		dialog.style.width=this.width+'px';
		dialog.style.display='';
		showItem('overlay');
		center('dds_dialog',this.width,dialog.offsetHeight);
		/*var t = dialog.style.top;
		dialog.style.top="-600px";
		content.style.visibility='hidden';
		dialog.postAction= function () {
			content.style.visibility='visible';
		}
		DDSanim.animate('dds_dialog',{"top":[parseInt(t),"easeOutSine"]},500);*/
		overlayReload();
		window.onresize=overlayReload;
		showHideFlash();
		this.dialogopen = 1;
	};
	this.hide = function(rl) {
		if(BrowserDetect.browser=="Opera" && rl) {
			window.location.reload();
			return;
		}
		if(typeof(this.onClose) == "function") {
			this.onClose();
			this.onClose=null;
		}
		if(this.boxname) {
			ajax_reload(this.boxname);
		} else {
			var cont = elem;
			if(elem.parentNode) cont = elem.parentNode.removeChild(elem);
			dparent.appendChild(cont);
			cont.style.display = 'none';
		}
		showHideFlash(1);
		dialog.style.display='none';
		hideItem('overlay');
		window.onresize="";
		this.dialogopen = 0;
	};
	this.close = function() {
		this.hide();
	};
	this.setTitle = function(t) {
		title.innerHTML = t;
	};
	this.setError = function(t) {
		error.innerHTML = t;
		error.style.display = (t=="")?'none':'';
	};
	this.setContent = function(t) {
		content.innerHTML = t;
	};

	this.reset = function() {
		dialogopen = 0;
		this.setTitle("");
		this.setContent("");
		this.setError("");
		this.boxname = "";
		this.width='500';
	};
	this.realign = function() {
		center('dds_dialog',this.width,dialog.offsetHeight);
	};
};

DDSDialog = new DDSDialog();

// DDS Javascript Animation Library 1.1

function DDSAnimation() {
	this.objs = [];
	this.lastid = null;
	
	this.init = function(eid,initonce) {
		if(!initonce || (!this.objs[eid] && initonce)) { 
			this.objs[eid] = document.getElementById(eid);
			this.objs[eid].startvalues = [];
			this.objs[eid].newvalues = [];
			this.objs[eid].easings = [];
			this.objs[eid].duration = 1000;
		}
	};
	
	this.animate = function(eid,changes,time,p,initonce) {
		this.init(eid,initonce);
		var obj = this.objs[eid];
		if(p) obj.postAction=p;
			obj.lastaction = [];
			obj.lastaction['time'] = time;
			obj.lastaction['changes'] = [];
			obj.animState=1;
		this.lastid = eid;
		
		for(var i in changes) {
			var startvalue = 0;
			var newvalue = 0;
			var easing = "easeLinear";
			switch (i) {
				case "width": startvalue = (obj.style.width)?obj.style.width:obj.offsetWidth; break;
				case "height": startvalue = (obj.style.height)?obj.style.height:obj.offsetHeight; break;
				case "top": startvalue = (obj.style.top)?obj.style.top:obj.offsetTop; break;
				case "left": startvalue = (obj.style.left)?obj.style.left:obj.offsetLeft; break;
				case "fadeIn": startvalue = 0; break;
				case "fadeOut": startvalue = 100; break;
				case "fadeTo": startvalue = this.getOpacity(obj); break;
				case "scrollLeft": startvalue = obj.scrollLeft; break;
				case "scrollTop": startvalue = obj.scrollTop; break;
				default: startvalue = this.objs[eid].style[i]; break;
			}
			
			obj.startvalues[i]=parseInt(startvalue);
			
			if (i == "fadeIn") newvalue = 100;
			else if (i == "fadeOut") newvalue = 0;
			else newvalue=changes[i][0];
			
			obj.newvalues[i]= newvalue;
			if(changes[i][1] != undefined) easing=changes[i][1];
			if(!obj.easings[i]) obj.easings[i]=eval(easing);
			switch (i) {
				case "fadeIn": obj.lastaction['changes']["fadeOut"] = [0,easing]; break;
				case "fadeOut": obj.lastaction['changes']["fadeIn"] = [0,easing]; break;
				default: obj.lastaction['changes'][i] = [startvalue,easing]; break;
			}
		}
		if(time) obj.duration = time;
		
		obj.timeLeft = obj.duration;
		
		var self = this;
		this.process = function(lastTick,eid) {
			var obj = self.objs[eid];
			var curTick = new Date().getTime();
			var elapsedTicks = curTick - lastTick;
			if(obj.timeLeft <= elapsedTicks) {
				for(var i in obj.newvalues) {
					switch (i) {
						case "fadeIn": self.setOpacity(obj,100); break;
						case "fadeOut": self.setOpacity(obj,0); break;
						case "fadeTo": self.setOpacity(obj,obj.newvalues[i]); break;
						case "scrollLeft": obj.scrollLeft = obj.newvalues[i]; break;
						case "scrollTop": obj.scrollTop = obj.newvalues[i]; break;
						default: obj.style[i] = obj.newvalues[i]+'px'; break;
					}
				}
				if(obj.hide) {
					obj.style.display='none';
					obj.hide=null;
				}
				if(obj.show) {
					obj.style.display='';
					obj.show=null;
				}
				obj.animState=0;
				if(typeof(obj.postAction) == "function") {
					obj.postAction();
				} else if(obj.postAction!=""){
					eval(obj.postAction);
				}
				obj.postAction="";
				return;
			}

			obj.timeLeft -= elapsedTicks;
			for(var i in obj.newvalues) {
				var easeFunc = obj.easings[i];
				var newval = easeFunc((obj.duration-obj.timeLeft),obj.startvalues[i],obj.newvalues[i]-obj.startvalues[i],obj.duration);
				switch (i) {
					case "fadeIn":
					case "fadeOut":
					case "fadeTo":
						self.setOpacity(obj,newval);
						break;
					case "scrollLeft": obj.scrollLeft = newval; break;
					case "scrollTop": obj.scrollTop = newval; break;
					default: obj.style[i] = newval+'px'; break;
				}
			}
			var timer = setTimeout(function(){ self.process(curTick,eid); }, 33);
		}
		
		this.process(new Date().getTime(),eid);
	};
	
	this.zoom = function(e,percent,t,f) {
		this.init(e);
		var obj = this.objs[e];
		var ow = obj.offsetWidth;
		var oh = obj.offsetHeight;
		
		var nw = (ow*percent)/100;
		var nh = (oh*percent)/100;
		
		var ot = obj.offsetTop;
		var ol = obj.offsetLeft;
		var ch = ow/2 + ol;
		var cv = oh/2 + ot;
		
		var nl = ch - nw/2;
		var nt = cv - nh/2;
		if(f) this.animate(e,{"width":[nw],"height":[nh],"left":[nl],"top":[nt],"fadeOut":[]},t);
		else this.animate(e,{"width":[nw],"height":[nh],"left":[nl],"top":[nt]},t);
	};
	
	this.resizeTo = function(e,w,h,t,l,time) {
		this.init(e);
		var obj = this.objs[e];
		var ow = obj.offsetWidth;
		var oh = obj.offsetHeight;
		
		var nw = w;
		var nh = h;
		
		var ot = obj.offsetTop;
		var ol = obj.offsetLeft;
		var ch = ow/2 + ol;
		var cv = oh/2 + ot;
		
		/*var nl = ch - nw/2;
		var nt = cv - nh/2;*/
		var nl = l;
		var nt = t;
		
		this.animate(e,{"width":[nw,"easeOutSine"],"height":[nh,"easeOutSine"],"left":[nl,"easeOutSine"],"top":[nt,"easeOutSine"]},time);
	};
	this.revert = function(a,e) {
		var id;
		if(!e && !this.lastid) return;
		if(e) id = e;
		else if(this.lastid) id = this.lastid;
		else return;
		if(id == a) return;
		var last = this.lastaction[id]; 
		this.lastaction[id] = new Array();
		this.animate(id,last['changes'],last['time'],1);
	};
	
	this.setOpacity = function(object,opacity) {
		object.style.opacity = (opacity / 100);
		object.style.MozOpacity = (opacity / 100);
		object.style.KhtmlOpacity = (opacity / 100);
		object.style.filter = "alpha(opacity=" + opacity + ")";
	};
	this.getOpacity = function(object) {
		if(object.style.opacity && object.style.opacity!="") return parseFloat(object.style.opacity)*100;
		if(object.style.MozOpacity && object.style.MozOpacity!="") return parseFloat(object.style.MozOpacity)*100;
		if(object.style.KhtmlOpacity && object.style.KhtmlOpacity!="") return parseFloat(object.style.KhtmlOpacity)*100;
		if(object.style.filter && object.style.filter!="") return parseInt(object.style.filter.match(/\d{1,3}/g));
		return 100;
	};
	
	this.fadeIn = function(e,t) {
		this.animate(e,{"fadeIn":[]},t);
	};
	this.fadeInS = function(e,t) {
		this.init(e);
		this.objs[e].show=1;
		this.objs[e].hide=null;
		this.animate(e,{"fadeIn":[]},t);
	};
	this.fadeOut = function(e,t,p) {
		this.animate(e,{"fadeOut":[]},t,p);
	};
	this.fadeOutH = function(e,t) {
		this.init(e);
		this.objs[e].hide=1;
		this.objs[e].show=null;
		this.animate(e,{"fadeOut":[]},t);
	};
	this.fadeTo = function(e,to,t) {
		this.animate(e,{"fadeTo":[to]},t);
	};
	
	this.postproc = function(e,p) {
		this.init(e);
		this.objs[e].postProcess=p;
	};
	// easing equations by Robert Penner http://robertpenner.com/

	easeLinear = function (t, b, c, d) {
 		return (c/d)*t + b;
	};

	easeInQuad = function (t, b, c, d) {
		return c*(t/=d)*t + b;
	};
	easeOutQuad = function (t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	};
	easeInOutQuad = function (t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	};
	easeInCubic = function (t, b, c, d) {
		return c*(t/=d)*t*t + b;
	};
	easeOutCubic = function (t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	};
	easeInOutCubic = function (t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	};
	easeInQuart = function (t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	};
	easeOutQuart = function (t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};
	easeInOutQuart = function (t, b, c, d) {
	 	if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
	 	return -c/2 * ((t-=2)*t*t*t - 2) + b;
	};
	easeInQuint = function (t, b, c, d) {
	 	return c*(t/=d)*t*t*t*t + b;
	};
	easeOutQuint = function (t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	};
	easeInOutQuint = function (t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	};
	easeInSine = function (t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	};
	easeOutSine = function (t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	};
	easeInOutSine = function (t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	};
	easeInExpo = function (t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	};
	easeOutExpo = function (t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	};
	easeInOutExpo = function (t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	};
	easeInCirc = function (t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	};
	easeOutCirc = function (t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	};
	easeInOutCirc = function (t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	};
	//a: amplitude (optional), p: period (optional)
	easeInElastic = function (t, b, c, d, a, p) {
		if (t==0) { return b; } 
		if ((t/=d)==1) { return b+c; }
		if (!p) { p=d*.3; }
		if (a < Math.abs(c)) {  a=c; s=p/4; }
		else { a=Math.abs(c); s = p/(2*Math.PI) * Math.asin(c/a);}
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	};
	easeOutElastic = function (t, b, c, d, a, p) {
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else {   a=Math.abs(c); var s = p/(2*Math.PI) * Math.asin (c/a);}
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	};
	easeInBounce = function (t, b, c, d) {
 		return c - easeOutBounce (d-t, 0, c, d) + b;
	};
	easeOutBounce = function (t, b, c, d) {
 		if ((t/=d) < (1/2.75)) {
  			return c*(7.5625*t*t) + b;
 		} else if (t < (2/2.75)) {
  			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
 		} else if (t < (2.5/2.75)) {
  			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
 		} else {
  			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
 		}
	};
	easeInOutBounce = function (t, b, c, d) {
 		if (t < d/2) return easeInBounce (t*2, 0, c, d) * .5 + b;
 		return easeOutBounce (t*2-d, 0, c, d) * .5 + c*.5 + b;
	};
};

var DDSanim = new DDSAnimation();


/**************************************************
 * dom-drag.js
 * 09.25.2001
 * www.youngpup.net
 **************************************************
 * 10.28.2001 - fixed minor bug where events
 * sometimes fired off the handle, not the root.
 **************************************************/

var Drag = {

	obj : null,

	init : function(o, oRoot, minX, maxX, minY, maxY, bSwapHorzRef, bSwapVertRef, fXMapper, fYMapper)
	{
		o.onmousedown	= Drag.start;

		o.hmode			= bSwapHorzRef ? false : true ;
		o.vmode			= bSwapVertRef ? false : true ;

		o.root = oRoot && oRoot != null ? oRoot : o ;

		if (o.hmode  && isNaN(parseInt(o.root.style.left  ))) o.root.style.left   = "0px";
		if (o.vmode  && isNaN(parseInt(o.root.style.top   ))) o.root.style.top    = "0px";
		if (!o.hmode && isNaN(parseInt(o.root.style.right ))) o.root.style.right  = "0px";
		if (!o.vmode && isNaN(parseInt(o.root.style.bottom))) o.root.style.bottom = "0px";

		o.minX	= typeof minX != 'undefined' ? minX : null;
		o.minY	= typeof minY != 'undefined' ? minY : null;
		o.maxX	= typeof maxX != 'undefined' ? maxX : null;
		o.maxY	= typeof maxY != 'undefined' ? maxY : null;

		o.xMapper = fXMapper ? fXMapper : null;
		o.yMapper = fYMapper ? fYMapper : null;

		o.root.onDragStart	= new Function();
		o.root.onDragEnd	= new Function();
		o.root.onDrag		= new Function();
	},

	start : function(e)
	{
		var o = Drag.obj = this;
		e = Drag.fixE(e);
		
		var targ;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;
		if (targ!=o) return;
		
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		o.root.onDragStart(x, y);
		y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );

		o.lastMouseX	= e.clientX;
		o.lastMouseY	= e.clientY;

		if (o.hmode) {
			if (o.minX != null)	o.minMouseX	= e.clientX - x + o.minX;
			if (o.maxX != null)	o.maxMouseX	= o.minMouseX + o.maxX - o.minX;
		} else {
			if (o.minX != null) o.maxMouseX = -o.minX + e.clientX + x;
			if (o.maxX != null) o.minMouseX = -o.maxX + e.clientX + x;
		}

		if (o.vmode) {
			if (o.minY != null)	o.minMouseY	= e.clientY - y + o.minY;
			if (o.maxY != null)	o.maxMouseY	= o.minMouseY + o.maxY - o.minY;
		} else {
			if (o.minY != null) o.maxMouseY = -o.minY + e.clientY + y;
			if (o.maxY != null) o.minMouseY = -o.maxY + e.clientY + y;
		}
		
		document.onmousemove	= Drag.drag;
		document.onmouseup		= Drag.end;

		return false;
	},

	drag : function(e)
	{
		e = Drag.fixE(e);
		var o = Drag.obj;

		var ey	= e.clientY;
		var ex	= e.clientX;
		var y = parseInt(o.vmode ? o.root.style.top  : o.root.style.bottom);
		var x = parseInt(o.hmode ? o.root.style.left : o.root.style.right );
		var nx, ny;

		if (o.minX != null) ex = o.hmode ? Math.max(ex, o.minMouseX) : Math.min(ex, o.maxMouseX);
		if (o.maxX != null) ex = o.hmode ? Math.min(ex, o.maxMouseX) : Math.max(ex, o.minMouseX);
		if (o.minY != null) ey = o.vmode ? Math.max(ey, o.minMouseY) : Math.min(ey, o.maxMouseY);
		if (o.maxY != null) ey = o.vmode ? Math.min(ey, o.maxMouseY) : Math.max(ey, o.minMouseY);

		nx = x + ((ex - o.lastMouseX) * (o.hmode ? 1 : -1));
		ny = y + ((ey - o.lastMouseY) * (o.vmode ? 1 : -1));

		if (o.xMapper)		nx = o.xMapper(y)
		else if (o.yMapper)	ny = o.yMapper(x)

		Drag.obj.root.style[o.hmode ? "left" : "right"] = nx + "px";
		Drag.obj.root.style[o.vmode ? "top" : "bottom"] = ny + "px";
		Drag.obj.lastMouseX	= ex;
		Drag.obj.lastMouseY	= ey;

		Drag.obj.root.onDrag(nx, ny);
		return false;
	},

	end : function()
	{
		document.onmousemove = null;
		document.onmouseup   = null;
		Drag.obj.root.onDragEnd(	parseInt(Drag.obj.root.style[Drag.obj.hmode ? "left" : "right"]), 
									parseInt(Drag.obj.root.style[Drag.obj.vmode ? "top" : "bottom"]));
		Drag.obj = null;
	},

	fixE : function(e)
	{
		if (typeof e == 'undefined') e = window.event;
		if (typeof e.layerX == 'undefined') e.layerX = e.offsetX;
		if (typeof e.layerY == 'undefined') e.layerY = e.offsetY;
		return e;
	}
};


function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

// Iguana

function dragInit(id,name) {
	var iefix = (BrowserDetect.browser=="Explorer" && parseInt(BrowserDetect.version)<8)?true:false;
	var handle = document.getElementById("bih_"+id);
	var root   = document.getElementById(name);
	if(!handle || !root) return;
	if(typeof(root.onDrag) == "function") return;
	handle.className+=" move";
	var rw = root.offsetWidth;
	var rh = root.offsetHeight;
	var rt = root.offsetTop;
	var rl = root.offsetLeft;

	var prt = 0;
	var prl = 0;
	
	if(iefix) {
		var pos = findPos(root);
		rt=pos[1];
		rl=pos[0];
		root.iefixot=rt;
		//root.parentNode.style.position='relative';
	}
	
	
	Drag.init(handle, root);
	//Drag.init(root,null);

	root.onDragStart = function (x,y) {
		root.ozIndex=root.style.zIndex;
		root.style.zIndex=10000;
		
		rt = root.offsetTop;
		rl = root.offsetLeft;
		
		
		if(iefix) {
			var pos = findPos(root);
			//document.getElementById('debug').innerHTML = root.offsetParent.offsetParent.id;
			rt=pos[1];
			rl=pos[0];
			root.iefixot=rt;
			root.iefixol=rl;
			//root.parentNode.style.position='relative';
		}

		//alert(rt + ' ' + rl);
		root.style.position='absolute';
		root.style.top=((rt-5))+'px';
		root.style.left=(rl)+'px';
		
		//Iguana.placeholder.style.width=rw+'px';
		Iguana.placeholder.style.height=(root.offsetHeight-12)+'px';
		root.parentNode.insertBefore(Iguana.placeholder,root.nextSibling);
		//root.className="boxd";
				
	}
	
	root.onDragEnd = function (x,y) {
		var p=document.getElementById('placeholder');
		root.postAction = function() {
			//root.className='box';
			root.style.zIndex=root.ozIndex;
			root.style.position='relative';
			root.style.top='0px';
			root.style.left='0px';
			child=p.parentNode.replaceChild(root,p);
			Iguana.rebuildBoxdata();
		};
		var ppos = findPos(p);
		var atop=(iefix)?ppos[1]:p.offsetTop;
		var aleft=(iefix)?ppos[0]:p.offsetLeft;
		//DDSanim.animate(root.id,{"top":[p.offsetTop+p.parentNode.offsetTop,"easeOutSine"],"left":[p.offsetLeft+p.parentNode.offsetLeft,"easeOutSine"]},300);	
		DDSanim.animate(root.id,{"top":[(atop-5),"easeOutSine"],"left":[aleft-5,"easeOutSine"]},300);
	}
	
	root.onDrag = function (x,y) {
		var center=[x+(root.offsetWidth/2),y];
		var wn=0;
		var p=document.getElementById('placeholder');
		//if(center[0]>p.offsetLeft && center[0]<p.offsetLeft+p.offsetWidth && center[1]>p.offsetTop && center[1]<p.offsetTop+p.offsetHeight-20)
			//alert('haho');
		var areas=Iguana.getAreas();
		var boxes=Iguana.getBoxes();
		for(var i=0;i<areas.length;i++) {
			var abox = document.getElementById(areas[i]);
			if(!abox) continue;
			if(iefix) abox.iefixol = findPos(abox)[0];
				
			var aol=(iefix && abox.iefixol)?abox.iefixol:abox.offsetLeft;
			
			if(center[0]>aol && center[0]<aol+abox.offsetWidth) {
				var child=p.parentNode.removeChild(p);
				for(var n=0; n<abox.childNodes.length;n++) {
					var cnode=abox.childNodes[n];
					if(iefix) cnode.iefixot = findPos(cnode)[1];
					if(cnode.nodeType!=1) {
						abox.removeChild(cnode);
					}
					if(cnode.id!=root.id && cnode.nodeType==1 && in_array(cnode.id,boxes)) {
						var cot=(iefix && cnode.iefixot)?cnode.iefixot:cnode.offsetTop;
						if(center[1]<cot+cnode.offsetHeight-20) {
							abox.insertBefore(child,cnode);
							return;
						} 
						wn=n;
					}
				}
				abox.insertBefore(child,abox.childNodes[wn].nextSibling);
			}
		}		
	}
}
function in_array(needle, haystack) {
	var key;
	for (key in haystack) {
		if (haystack[key] == needle) {
			return true;
		}
	}
	return false;
}

// font size changer

function initFontSizeChanger(w,hw,is) {
	var minsize = 11;
	var range = 6;
	
	var handle = document.getElementById("fcslider");
	if(is) {
		handle.style.left = ((parseInt(is)-minsize)*((w-hw)/range))+'px';
	}

	Drag.init(handle, null,0,(w-hw),0,0);

	handle.onDragStart = function (x,y) {

	}
	
	handle.onDragEnd = function (x,y) {
		DOsaveSettings("fontSize",Math.round(x/((w-hw)/range))+minsize);
	}
	
	handle.onDrag = function (x,y) {
		var val=Math.round(x/((w-hw)/range));
		document.getElementById("contentbody").style.fontSize = document.getElementById("fcvalue").innerHTML = (minsize + val) + 'px'; 
		//document.getElementById("fsvalue").innerHTML = (minsize + val) + 'px';
	}
}


Array.prototype.inArray = function (value) {
	var i;
	for (i=0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

function isArray(obj) {
	if (!obj) return false;
	if (obj.constructor.toString().indexOf("Array") == -1) return false;
	else return true;
};

function libform3_ajaxPostForm(form,target) {
	if(!form || !form.elements) return false;
	
	var fe = form.elements;
	var fields = new Array();
	for(var i=0;i<fe.length;i++) {
		var fn = fe[i].name;
		var fv = null;
		switch (fe[i].type) {
			case "text":
			case "password":
			case "textarea":
			case "hidden":
			case "select-one":
				fv=fe[i].value;
				break;
			case "radio":
			case "checkbox":
				if (fe[i].checked) fv=fe[i].value;
				break;
			case "select-multiple":
				fv = new Array();
				for (a=0;a<fe[i].options.length;a++) {
					if (fe[i].options[a].selected) {
						fv.push(fe[i].options[a].value);
						vpos++;
					}
				}
				break;
			default: fv=fe[i].value;
		}
		if(isArray(fv)) {
			for(var v=0;v<fv.length;v++) {
				fields.push({"n":fn,"v":fv[v]});
			}
		} else fields.push({"n":fn,"v":fv});
	}
	var post_data='formdata='+Base64.encode(JSON.stringify(fields));
	//var url='ajax_index.php'+window.location.search;
	var url=window.location.href;
	if(target) url=target;
	ajax_post(url,post_data);
	libform3_postNotify();
	return false;
}

function libform3_postNotify(remove) {
	if(remove) {
		var d = document.getElementById('libformpostnotify');
		if(d) d.parentNode.removeChild(d);
		return;
	}
	var b = document.getElementsByTagName('body')[0];
	var d = document.createElement("div");
	d.id="libformpostnotify";
	d.innerHTML='<img border="0" src="/images/loading.gif" width="22" height="21"> Adatküldés folyamatban... Kérem várjon!';
	b.appendChild(d);
	center("libformpostnotify",d.offsetWidth,d.offsetHeight);
}

function libform3_ajaxPostResult(result,formname) {
	libform3_postNotify(1);
	var form = document.forms[formname];
	if(!form) return;
	
	for(var f in result['data']) {
		if(form[f])	form[f].className = "inp1";
	}
	
	if(result['error']) {
		DDSDialog.setError(result['error']);
		if(result['error_fields']) {
			for(var f in result['error_fields']) {
				if(form[f]) form[f].className = "inperr";
			}
		}
	}
	if(result['processed']==1) {
		if(result['message']) {
			DDSDialog.setContent(result['message']);
			DDSDialog.setError("");
		} else {
			DDSDialog.hide();
		}
	}
	return false;
}

function libform3_root() {
	//SYS felviteli mezők
	this.fields_SYS=new Array;
	this.fields_USER=new Array;

	//Egy objektum tomb-e
	this.isArray = function(val) {
		if (typeof(val)!="object") return(false);
		if (typeof(val.length)=="undefined") return(false);
		if (typeof(val[0])=="undefined") return(false);
		return(true);
	}

	//Query string search részét parseolja
	this.parse_qs = function() {
		var q=window.location.search;
		if (q.length>1) q=q.substring(1,q.length);
		else q=null;
		
		this.qs=new Array;
		if (q)
			for(var i=0;i<q.split("&").length;i++) {
				blokk=q.split("&")[i];
				var s1=blokk.substring(0,blokk.indexOf("="));
				var s2=blokk.substring(blokk.indexOf("=")+1);
				this.qs[s1]=s2;
			}
	}

	this.ajax_loadLanguage = function(fname,lang) {
		var http = createRequestObject();
		var url="ajax_index.php?func="+this.qs['func']+"&module="+this.qs['module']+"&form_language="+lang;
		if (this.qs['func']=="mod") url+="&id="+this.qs['id'];
		
		http.open('get', url);
		http.onreadystatechange=function() {
			if(http.readyState == 4) {
				var response = http.responseText;
				var langdata=eval("("+response+")");
				libform3.forms[fname]['data'][lang]=langdata.data;
				libform3.setAll(fname);
			}
		}
		http.send(null);
	}
	
	//Nyelv vátlás
	this.setLanguage = function(fname,lang) {
		//Aktuális nyelv lekérése
		currlang=this.forms[fname].lang;
		deflang=this.forms[fname].def_lang;
		//Ha nincs nyelv váltás
		if (lang==currlang) return;
		//Adatok lekérése
		this.getAll(fname);
	
		//Ha a nyelv nem az alapnyelv, akkor mezők elrejtése, egyébként megjelenítése
		if (lang==deflang) this.ro_not_ml(fname, 0);
		else this.ro_not_ml(fname, 1);

		//Aktuális nyelv beállítása
		this.forms[fname].lang=lang;

		//Nyelvi adatok AJAX lekérése, ha még nincs letöltve
		if (!this.forms[fname]['data'][lang]) this.ajax_loadLanguage(fname, lang);
		else this.setAll(fname);
	}

	this.create_structure = function() {
		if (typeof(this.forms)!="undefined") return;
		this.forms=new Array;
		this.parse_qs();
	}

	this.register = function(formname,json) {
		this.create_structure();
		this.forms[formname]=new Array();
		this.forms[formname]=eval("("+json+")");
		//this.getAll(formname);
	}

	this.getAll = function(formname) {
		for (f in this.forms[formname].fields) {
			flag=this.forms[formname].fields[f].f;
			if (flag<2) continue;
			//Még nem kezeljük a user objectet
			uo=this.forms[formname].fields[f].uo;
			if (uo) continue;
			//Az adott mező több nyelvű?
			ml=this.forms[formname].fields[f].ml;
			//Ha a mező nem több nyelvű és ez nem az alapnyelv, akkor nem kell lekérdezni
			if ((!ml) && (this.forms[formname].lang!=this.forms[formname].def_lang)) continue;
			val=this.getValue(formname,f);
			if (val===null) continue;
			this.forms[formname].data[this.forms[formname].lang][f]=val;
		}
	}

	this.setAll = function(formname) {
		var val=new Array;
		for (f in this.forms[formname].fields) {
			flag=this.forms[formname].fields[f].f;
			if (flag<2) continue;
			//Még nem kezeljük a user objectet
			uo=this.forms[formname].fields[f].uo;
			if (uo) continue;
			//Az adott mező több nyelvű?
			ml=this.forms[formname].fields[f].ml;
			//Ha a mező nem több nyelvű és ez nem az alapnyelv, akkor nem kell lekérdezni
			if ((!ml) && (this.forms[formname].lang!=this.forms[formname].def_lang)) continue;
			val[0]=this.forms[formname].data[this.forms[formname].lang][f];
			this.setValue(formname,f,val);
		}
	}

	this.getValue = function(formname,inpfield) {
		t=this.forms[formname].fields[inpfield].t;
		if (this.fields_SYS[t]) return(this.fields_SYS[t].get(formname,inpfield));
		//alert("A mezőtípushoz nem tartozik JS objektum: "+inpfield+"("+t+")");
		return(null);
	}

	this.setValue = function(formname,inpfield,val) {
		t=this.forms[formname].fields[inpfield].t;
		if (this.fields_SYS[t]) return(this.fields_SYS[t].set(formname,inpfield,val));
		//alert("A mezőtípushoz nem tartozik JS objektum: "+inpfield);
	}

	this.setRO = function(formname,inpfield,ro) {
		t=this.forms[formname].fields[inpfield].t;
		if (this.fields_SYS[t]) {
			if (ro=1) return(this.fields_SYS[t].disable(formname,inpfield));
			else return(this.fields_SYS[t].enable(formname,inpfield));
		}
		return;
		//alert("A mezőtípushoz nem tartozik JS objektum: "+inpfield);
	}

	this.ro_not_ml = function(formname,ro) {
		for (f in this.forms[formname].fields) {
			ml=this.forms[formname].fields[f].ml;
			if (!ml) this.setRO(formname,f,ro);
		}
	}

	this.HTMLsetRO = function(formname,inpfield,ro) {
		//Ha nincs ilyen form
		if (typeof(document.forms[formname])=="undefined") return;

		field_o=document.forms[formname][inpfield];
		//Ha nincs ilyen mezo
		if (typeof(field_o)=="undefined") return;
	
		var apos = 0;

		while (1) {
			if ((this.isArray(field_o)) && (typeof(field_o.type)=="undefined")) field=field_o[apos];
			else field=field_o;
			if (typeof(field)=="undefined") return;
			if (ro==1) {
				field.disabled=true;
				if (field.className.indexOf("inp1i")==-1) field.className=field.className+" inp1i";
			} else {
				field.disabled=false;
				field.className=field.className.replace(" inp1i","");
			}
			if (field!=field_o) apos++;
			else return;
		}
	}

	//Egy form elem ertekenek lekerese
	this.HTMLgetValue = function(formname,inpfield) {
		//Ha nincs ilyen form
		if (typeof(document.forms[formname])=="undefined") return;

		field_o=document.forms[formname][inpfield];
		//Ha nincs ilyen mezo
		if (typeof(field_o)=="undefined") return;
	
		var val = Array();
		var apos = 0;
		var vpos=0;

		while (1) {
			if ((this.isArray(field_o)) && (typeof(field_o.type)=="undefined")) field=field_o[apos];
			else field=field_o;
			if (typeof(field)=="undefined") return(val);

			switch (field.type) {
				case "text":
				case "password":
				case "textarea":
				case "hidden":
				case "select-one":
					val[vpos]=field.value;
					vpos++;
					break;
				case "radio":
				case "checkbox":
					if (!field.checked) break;
					val[vpos]=field.value;
					vpos++;
					break;
				case "select-multiple":
					for (a=0;a<field.options.length;a++) {
						if (field.options[a].selected) {
							val[vpos]=field.options[a].value;
							vpos++;
						}
					}
					break;
				default:
			}
			if (field!=field_o) apos++;
			else return(val);
		}
	}

	//Egy form elem ertekenek lekerese
	this.HTMLsetValue = function(formname,inpfield,val) {
		//Ha nincs ilyen form
		if (typeof(document.forms[formname])=="undefined") return;

		field_o=document.forms[formname][inpfield];
		//Ha nincs ilyen mezo
		if (typeof(field_o)=="undefined") return;

		//Megnezzuk, hogy tomb-e
		if (typeof(val)=="undefined") return;
		if (typeof(val[0])=="undefined") return;
	
		var apos = 0;
		var vpos=0;

		while (1) {
			if ((this.isArray(field_o)) && (typeof(field_o.type)=="undefined")) field=field_o[apos];
			else field=field_o;
			if (typeof(field)=="undefined") return(val);

			switch (field.type) {
				case "text":
				case "password":
				case "textarea":
				case "hidden":
					field.value=val[vpos];
					vpos++;
					break;
				case "select-one":
					for (s=0;s<field.options.length;s++) {
						if (field.options[s].value==val[vpos]) {
							field.options[s].selected=true;
							vpos++;
							break;
						}
					}
					break;
				case "radio":
				case "checkbox":
					if (field.value==val[vpos]) {
						field.checked=true;
						vpos++;
					} else
						field.checked=false;
					break;
				case "select-multiple":
					for (a=0;a<field.options.length;a++) {
						if (val.inArray(field.options[a].value)) field.options[a].selected=true;
						else field.options[a].selected=false;
					}
					break;
				default:
			}
			if (field!=field_o) apos++;
			else return(val);
		}
	}
}

var libform3 = new libform3_root();

//Egy felviteli mező skeleton
function libform3_field_root(type_char,user_type) {
	this.enable = function(formname,inpfield) {
		libform3.HTMLsetRO(formname,inpfield,0);
		return;
	}

	this.disable = function(formname,inpfield) {
		libform3.HTMLsetRO(formname,inpfield,1);
		return;
	}
	
	this.get = function(formname,inpfield) {
		val=libform3.HTMLgetValue(formname, inpfield);
		v=val[0];
		return(v);
	}
		
	this.set = function(formname,inpfield,value) {
		libform3.HTMLsetValue(formname, inpfield, value);
	}
	
	this._constructor = function(type_char,user_type) {
		if (user_type) libform3.fields_USER[user_type]=this;
		else libform3.fields_SYS[type_char]=this;
	}
	
	this._constructor(type_char,user_type)
	return;
	
}

var libform3_field_I = new libform3_field_root("I","");
var libform3_field_S = new libform3_field_root("S","");
var libform3_field_T = new libform3_field_root("T","");
var libform3_field_C = new libform3_field_root("C","");
var libform3_field_tree = new libform3_field_root("%","");
var libform3_field_C = new libform3_field_root("D","");

//HTML típusú felviteli mező
var libform3_field_H = new libform3_field_root("H","");

libform3_field_H.enable=function(formname,inpfield) {
	alert(inpfield);
	alert("enable");
}

libform3_field_H.disable=function(formname,inpfield) {
	alert(inpfield);
	alert("disable");
}

libform3_field_H.get=function(formname,inpfield) {
	return(xinha_editors[inpfield].getHTML());
}

libform3_field_H.set=function(formname,inpfield,value) {
	return(xinha_editors[inpfield].setHTML(value));
}

//N:M típusú felviteli mező
var libform3_field_X = new libform3_field_root("X","");
libform3_field_X.enable=function(formname,inpfield) {
	inpf=inpfield+"[]";
	libform3.HTMLsetRO(formname,inpf,0);
}

libform3_field_X.disable=function(formname,inpfield) {
	inpf=inpfield+"[]";
	libform3.HTMLsetRO(formname,inpf,1);
}

libform3_field_X.get=function(formname,inpfield) {
	inpf=inpfield+"[]";
	val=libform3.HTMLgetValue(formname, inpf);
	return(val);
	//return(xinha_editors[inpfield].getHTML());
}

libform3_field_X.set=function(formname,inpfield,value) {
	inpf=inpfield+"[]";
	val=libform3.HTMLsetValue(formname, inpf,value);
	//return(xinha_editors[inpfield].setHTML(value));
}
//libform3.fields_SYS['H'].enable("valami");

/* Iguana v1.0
 * (c) DDS     
 * * * * * * * */

Iguana = function () {
	this.browser = BrowserDetect.browser + BrowserDetect.version;
	this.placeholder = document.createElement("div");
	this.placeholder.className="placeholder";
	this.placeholder.id="placeholder";
	var areas=[];
	var boxes=[];
	var tmplbyid={};
	var minclass = [];
	minclass[0]="mincontrol";
	minclass[1]="mincontroloff";
	this.tbi = {};
	var boxdata;
	var max = 5;
	var min = 0;
	this.data = boxdata;
	var tabs = {};
	var rinterval = 10000;
	this.tabs = {};
	this.init = function(data) {
		boxdata = data;
		for(var i in boxdata) {
			areas.push('a3_bb_'+i);
			var tmpls = boxdata[i];
			for(var a=0;a<tmpls.length;a++) {
				if(tmpls[a]['par'].search('fix')==-1) {
					boxes.push('a3_bi_'+tmpls[a]['id']);
				}
				tmplbyid[tmpls[a]['id']]=tmpls[a];
			}
				
		}
		this.tbi = tmplbyid;
		for(var i=0;i<boxes.length;i++) {
			dragInit(boxes[i].replace(/a3_bi_/,''),boxes[i]);
		}
	}
	this.getAreas = function() {
		return areas;
	}
	this.getBoxes = function() {
		return boxes;
	}
	this.changeNum = function(id,dir) {
		if(!tmplbyid[id]) return;
		var num = parseInt(tmplbyid[id]['num']);
		if(isNaN(num)) num = min;
		var plusctrl = document.getElementById('biplusz_'+id);
		var minusctrl = document.getElementById('biminusz_'+id);
		
		if(dir) {
			num++;
			if(num > max) {
				num = max;
				return;
			}
		} else {
			num--;
			if(num < 0) {
				num = 0;
				return;
			}
		}
		tmplbyid[id]['num']=num;
		/*var pbi = null;
		var te = document.getElementById('a3_bi_'+id);
		if(te) pbi = te.parentNode.id;*/
		this.rebuildBoxdata('a3_bi_'+id);
	}
	this.min = function(id) {
		if(!tmplbyid[id]) return;
		var ctrl = document.getElementById('bimin_'+id);
		var cont = document.getElementById('bic_'+id);
		if(!cont || !ctrl) return;
		if(cont.style.display=='none') {
			dir=0;
		} else {
			dir=1;
		}
		ctrl.className=minclass[dir];
		var par = tmplbyid[id].par;
		if(par!="") {
			par=par.split(',');
		} else {
			par=[];
		}
		if(dir) {
			cont.style.height=cont.offsetHeight;
			cont.style.overflow='hidden';
			cont.hide = 1;
			DDSanim.animate(cont.id,{"height":[0,"easeOutSine"]},250);
			//cont.style.display="none";
			if(!in_array('mn',par))	par.push("mn");
		} else {
			cont.style.overflow='';
			cont.style.display="";
			cont.style.height='';
			var f=0;
			for(var a=0;a<par.length;a++) {
				if(par[a]=='mn') {
					par.splice(a,1);
					break;
				}
			}
		}
		tmplbyid[id]['par']=par.join(',');
		this.rebuildBoxdata();
	}

	this.rebuildBoxdata = function(rl) {
		var b = {};
		for(var i=0;i<areas.length;i++) {
			var box = document.getElementById(areas[i]);
			var boxname = areas[i].replace(/a3_bb_/,'');
			b[boxname]=new Array();
			if(!box) {
				if(!boxdata[boxname]) continue;
				b[boxname]=boxdata[boxname];
				continue;
			}
			var nodes = box.childNodes;
			var c=1;
			for(var t=0;t<nodes.length;t++) {
				if(nodes[t].nodeType==1 && nodes[t].id.substr(0,6)=='a3_bi_') {
					var id=nodes[t].id.replace(/a3_bi_/,'');
					var o_data = tmplbyid[id];
					if(o_data) {
						o_data['prio']=c;
						b[boxname].push(o_data);
						c++;
					}
				}
			}
		}
		boxdata=b;
		//this.data=b;
		save(rl);		
	}
	var save = function (rl) {
		var spl="";
		if(rl) spl="&rl="+rl;
		setTimeout("ajax_post('settings.php','tb="+Base64.encode(JSON.stringify(boxdata))+spl+"')",500);
	}
	
	// tabs
	this.addTabs = function(box,tab,mode,auto,t) {
		/* mode 1: fade, 2: slide */
		if(tabs[box]) {
			if(tabs[box]['timer']) clearTimeout(tabs[box]['timer']);
			delete tabs[box];
		}
		tabs[box]=tab;
		tabs[box]['mode']=mode;
		if(mode==2) tabs[box]['sdir']=1;
		tabs[box]['interval']=(t)?t:10000;
		if(auto) {
			tabs[box]['timer'] = setTimeout("Iguana.rotateTabs('"+box+"')",tabs[box]['interval']);
			tabs[box]['auto']=1;
		}
		
	}
	this.switchTab = function(b,t) {
		var tab = tabs[b];
		if(!tab || !tab['num']) return;

		var ctab = (tab['cnum'])?tab['cnum']:1;
		if (ctab==t) return;
		
		var pre = b+'_tab_';
		var spre = b+'_sw_';
		
		var curr = document.getElementById(pre+ctab);
		
		if(!curr) return;
		switch(tab['mode']) {
			case 1: DDSanim.fadeOutH(pre+ctab,500); break;
			case 2: //DDSanim.animate(pre+'wrapper',{'scrollLeft':[(t-1)*curr.parentNode.offsetWidth,'easeOutSine']});
					break;
			default: curr.style.display='none';
		}
		
		var csw = document.getElementById(spre+ctab);
		if(tab['class'] && csw) csw.className=tab['class'];
		
		tabs[b]['cnum']=t;
		curr = document.getElementById(pre+t);
		if(!curr) return;
		
		curr.style.display='';
		if(tab['mode']==1) DDSanim.fadeInS(pre+t,500);
		if(tab['mode']==2) {
			var sl=0;
			for(var i=1;i<t;i++) {
				sl+=document.getElementById(pre+i).parentNode.offsetWidth;
			}
			DDSanim.animate(pre+'wrapper',{'scrollLeft':[sl,'easeOutSine']});
		}
		
		if(tab['auto']) {
			if(tab['timer']) clearTimeout(tab['timer']);
			tab['timer'] = setTimeout("Iguana.rotateTabs('"+b+"')",tab['interval']);
		}
		
		var csw = document.getElementById(spre+t);
		if(tab['class'] && csw) csw.className=tab['class']+'_on';
		
		this.tabs=tabs;
	}
	this.rotateTabs = function(b) {
		var tab = tabs[b];
		if(tab['mode']==2) {
			if(tab['sdir']==1) {
				var nxt = ((tab['cnum']+1)>tab['num'])?1:(tab['cnum']+1);
				if(nxt == 1) {
					tab['sdir']=-1;
					this.prevTab(b);
				} else {
					this.nextTab(b);
				}
			} else {
				var prv = ((tab['cnum']-1)==0)?tab['num']:(tab['cnum']-1);
				if(prv == tab['num']) {
					tab['sdir']=1;
					this.nextTab(b);
				} else {
					this.prevTab(b);
				}
			}
			
		} else {
			this.nextTab(b);
		}
		
	}
	this.nextTab = function(b,u) {
		var tab = tabs[b];
		var nxt = ((tab['cnum']+1)>tab['num'])?1:(tab['cnum']+1);
		if(u) {
			if(nxt == 1) return;
			else tab['sdir']=1;
		}
		//if(tab['cnum']>tab['num']) tabs[b]['cnum'] = tab['cnum'] = 2;
		this.switchTab(b,nxt);
	}
	this.prevTab = function(b,u) {
		var tab = tabs[b];
		var prv = ((tab['cnum']-1)==0)?tab['num']:(tab['cnum']-1);
		if(u) {
			if(prv == tab['num']) return;
			else tab['sdir']=-1;
		}
		this.switchTab(b,prv);
	}
	
	this.EQTabs = function(b) {
		var tab = tabs[b];
		var maxheight = 0;
		for(var i=1;i<=tab['num'];i++) {
			var elem = document.getElementById(b+"_tab_"+i);
			var h = 0;
			if(tab['cnum'] == i) {
				h=getHeight(elem);
			} else {
				elem.style.display='';
				h=getHeight(elem);
				elem.style.display='none';
			}
			if(h>maxheight) {
				maxheight=h;
			}
		}
		for(var i=1;i<=tab['num'];i++) {
			document.getElementById(b+"_tab_"+i).style.height=maxheight+'px';
		}
	}
	
	var addClass = function(e,c) {
		if(!e || !c) return;
		if(!e.className) {
			e.className=c;
			return;
		}
		var cl = e.className.split(" ");
		var found = 0;
		for(var a=0;a<cl.length;a++) {
			if(cl[a]==c) {
				found=1;
				break;
			}
		}
		if(found) return;
		cl.push(c);
		e.className=cl.join(" ");
	}
	var delClass = function(e,c) {
		if(!e || !c) return;
		if(e.className == c) {
			e.className='';
			return;
		}
		var cl = e.className.split(" ");
		for(var a=0;a<cl.length;a++) {
			if(cl[a]==c) {
				cl.splice(a,1);
				break;
			}
		}
		e.className=cl.join(" ");
	}
}
var Iguana = new Iguana();



