// Title: Tigra Tree
// Description: See the demo at url
// URL: http://www.softcomplex.com/products/tigra_menu_tree/
// Version: 1.1 (size optimized)
// Date: 11-12-2002 (mm-dd-yyyy)
// Notes: This script is free. Visit official site for further details.

function tree(tm0,tm1,elem)
{
    this.tm2=tm1;
    this.tm3=tm0;
    this.tm4=this;
    this.tm5=[];
    this.tm6=null;
    this.tm7=-1;
    var tm8=new Image(),tm9=new Image();
    tm8.src=tm1['icon_e'];
    tm9.src=tm1['icon_l'];
    tm1['im_e']=tm8;
    tm1['im_l']=tm9;
    for(var i=0;i<64;i++)
        if(tm1['icon_'+i]){
            var tmA=new Image();
            tm1['im_'+i]=tmA;
            tmA.src="/"+tm1['icon_'+i]
        }
        this.tmB=function(tmC){
            var tmD=this.tm5[tmC];
            tmD.tmE(tmD.tmF)
        };
        this.tmG=function(tmC){
            return this.tm5[tmC].tmG()
        };
        this.tmH=function(tmC){
            this.tm5[tmC].tmI(true)
        };
        this.tmJ=function(tmC){
            this.tm5[tmC].tmI()
        };
        this.tmK=[];
        for(var i=0;i<tm0.length;i++)
            new tmL(this,i);
        this.tmC=trees.length;
        trees[this.tmC]=this;
        for(var i=0;i<this.tmK.length;i++){
            elem.innerHTML = (this.tmK[i].tmM());this.tmK[i].tmE()
        }
}
function tmL(tmN,tmO){
    this.tm7=tmN.tm7+1;
    this.tm3=tmN.tm3[tmO+(this.tm7?2:0)];
    if(!this.tm3)return;
    this.tm4=tmN.tm4;
    this.tmN=tmN;
    this.tmO=tmO;
    this.tmF=!this.tm7;
    this.tmC=this.tm4.tm5.length;
    this.tm4.tm5[this.tmC]=this;
    tmN.tmK[tmO]=this;
    this.tmK=[];
    for(var i=0;i<this.tm3.length-2;i++)
        new tmL(this,i);
    this.tmP=tmQ;
    this.tmE=tmR;
    this.tmG=tmS;
    this.tmM=tmT;
    this.tmI=tmU;
    this.tmV=function(){
        return this.tmO==this.tmN.tmK.length-1
    }
}
function tmR(tmW){
    var tmX=tmY('i_div'+this.tm4.tmC+'_'+this.tmC);
    if(!tmX)
        return;
    if(!tmX.innerHTML){
        var tmK=[];
        for(var i=0;i<this.tmK.length;i++)
            tmK[i]=this.tmK[i].tmM();
        tmX.innerHTML=tmK.join('')
    }
    tmX.style.display=(tmW?'none':'block');
    this.tmF=!tmW;
    var tmZ=document.images['j_img'+this.tm4.tmC+'_'+this.tmC],tma=document.images['i_img'+this.tm4.tmC+'_'+this.tmC];
    if(tmZ)tmZ.src="/"+this.tmP(true);
    if(tma)tma.src="/"+this.tmP();
    this.tmI()
}
function tmS(tmb){
    if(!tmb){
        var tmc=this.tm4.tm6;
        this.tm4.tm6=this;
        if(tmc)
            tmc.tmG(true)
    }
    var tma=document.images['i_img'+this.tm4.tmC+'_'+this.tmC];
    if(tma)
        tma.src="/"+this.tmP();
    tmY('i_txt'+this.tm4.tmC+'_'+this.tmC).style.fontWeight=tmb?'normal':'bold';
    this.tmI();
    return Boolean(this.tm3[1])
}
function tmU(tmd){
    window.setTimeout('window.status="'+(tmd?'':this.tm3[0]+(this.tm3[1]?' ('+this.tm3[1]+')':''))+'"',10)
}
function tmT(){
    var tme=[],tmf=this.tmN;
    for(var i=this.tm7;i>1;i--){
        tme[i]='<img src="/'+this.tm4.tm2[tmf.tmV()?'icon_e':'icon_l']+'" style="width:19px;height:16px;" border="0" align="absbottom">';
        tmf=tmf.tmN
    }
    return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>'+(this.tm7?tme.join('')+(this.tmK.length?'<a class="menu" title="'+this.tm3[0]+'" href="javascript: trees['+this.tm4.tmC+'].tmB('+this.tmC+')" onmouseover="trees['+this.tm4.tmC+'].tmJ('+this.tmC+')" onmouseout="trees['+this.tm4.tmC+'].tmH('+this.tmC+')"><img src="/'+this.tmP(true)+'" border="0" align="absbottom" style="width:19px;height:16px;" name="j_img'+this.tm4.tmC+'_'+this.tmC+'"></a>':'<img src="/'+this.tmP(true)+'" border="0" align="absbottom" style="width:19px;height:16px;" >'):'')+'<a class="menu" title="'+this.tm3[0]+'" href="'+ eldonto(this.tm3[1],this.tm4.tmC, this.tmC) +'" onmouseover="trees['+this.tm4.tmC+'].tmJ('+this.tmC+')" onmouseout="trees['+this.tm4.tmC+'].tmH('+this.tmC+')" class="t'+this.tm4.tmC+'i" id="i_txt'+this.tm4.tmC+'_'+this.tmC+'">'+this.tm3[0]+'</a></td></tr></table>'+(this.tmK.length?'<div id="i_div'+this.tm4.tmC+'_'+this.tmC+'" style="display:none"></div>':'')
    }
    function tmQ(tmg){
        return this.tm4.tm2['icon_'+((this.tm7?0:32)+(this.tmK.length?16:0)+(this.tmK.length&&this.tmF?8:0)+(!tmg&&this.tm4.tm6==this?4:0)+(tmg?2:0)+(tmg&&this.tmV()?1:0))]
    }
    var trees=[];
    tmY=document.all?function(tmh){return document.all[tmh]}:function(tmh){return document.getElementById(tmh)};

function eldonto(str,egy,ketto){
    if (str.substr(0,11) == "Javascript:"){
        return str;
    } else {
        if (str != "") return(str + '&tmB=' + ketto);
        else return('javascript: trees['+egy+'].tmB('+ketto+')');
    }
}


/*
	Feel free to use your custom icons for the tree. Make sure they are all of the same size.
	User icons collections are welcome, we'll publish them giving all regards.
*/

var tree_tpl = {
	'target'  : '_self',				// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top
	'icon_e'  : 'scripts/icons/empty.gif', 		// empty image
	'icon_l'  : 'scripts/icons/line.gif', 		// vertical line
    'icon_32' : 'scripts/icons/base.gif',   	// root leaf icon normal
    'icon_36' : 'scripts/icons/base.gif',   	// root leaf icon selected
	'icon_48' : 'scripts/icons/base.gif',   	// root icon normal
	'icon_52' : 'scripts/icons/base.gif',   	// root icon selected
	'icon_56' : 'scripts/icons/base.gif',   	// root icon opened
	'icon_60' : 'scripts/icons/base.gif',   	// root icon selected
	'icon_16' : 'scripts/icons/folder.gif', 	// node icon normal
	'icon_20' : 'scripts/icons/folderopen.gif', 	// node icon selected
	'icon_24' : 'scripts/icons/folderopen.gif', 	// node icon opened
	'icon_28' : 'scripts/icons/folderopen.gif', 	// node icon selected opened
	'icon_0'  : 'scripts/icons/page.gif', 		// leaf icon normal
	'icon_4'  : 'scripts/icons/page.gif', 		// leaf icon selected
	'icon_2'  : 'scripts/icons/joinbottom.gif', 	// junction for leaf
	'icon_3'  : 'scripts/icons/join.gif',       	// junction for last leaf
	'icon_18' : 'scripts/icons/plusbottom.gif', 	// junction for closed node
	'icon_19' : 'scripts/icons/plus.gif',       	// junctioin for last closed node
	'icon_26' : 'scripts/icons/minusbottom.gif',	// junction for opened node
	'icon_27' : 'scripts/icons/minus.gif'       	// junctioin for last opended node
};


var mouseX = 0;
var mouseY = 0;
var mehet = true;
var akciotime = null;
String.prototype.replaceAll=function(s1,s2){return this.split(s1).join(s2)};
function QueryString(key){ret="";str=window.location.search.substring(1).split("&");for(i=0;i<str.length;i++){x = str[i].split("=");if(x[0]==key){ret=x[1];}}ret=ret.replaceAll("+",String.fromCharCode(32));return unescape(ret);};
function isset(){var a=arguments;var l=a.length; var i=0;if(l==0){throw new Error('Empty isset');}while (i!=l){if(typeof(a[i])=='undefined'||a[i]===null){return false;}else{i++;}}return true;};
function GetXmlHttpObject(){var xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}return xmlHttp;};
function checkemail(x){var filter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;if(filter.test(x))return true;else return false;};
function findPosition(oElement){if(typeof(oElement.offsetParent)!='undefined'){for(var posX=0,posY=0;oElement;oElement=oElement.offsetParent){posX+=oElement.offsetLeft;posY+=oElement.offsetTop;}return[posX,posY];}else{return[oElement.x,oElement.y];}};
function substr_count(haystack,needle,offset,length){var pos=0,cnt=0;if(isNaN(offset))offset=0;if(isNaN(length))length=0;offset--;while((offset=haystack.indexOf(needle,offset+1))!=-1){if(length>0&&(offset+needle.length)>length){return false;}else{cnt++;}}return cnt;}
function loadjscssfile(filename, filetype){if(filetype=="js"){var fileref=document.createElement('script');fileref.setAttribute("type","text/javascript");fileref.setAttribute("src", filename);}else if(filetype=="css"){var fileref=document.createElement("link");fileref.setAttribute("rel", "stylesheet");fileref.setAttribute("type", "text/css");fileref.setAttribute("href", filename);}if(typeof fileref!="undefined"){document.getElementsByTagName("head")[0].appendChild(fileref);}}
function listat_atmeretez(){
    div = document.getElementById('lista');
    div.style.height = 300 + 'px';
    div.style.overflow = 'scroll';
    div.style.visibility = 'visible';
}
function changetab(param){
    if (param == "auto"){
        document.getElementById('auto').className = "gyorskereso_felso_link_aktiv";
        document.getElementById('meret').className = "gyorskereso_felso_link_sima";
        new tree (TREE_ITEMS_AUTO, tree_tpl,document.getElementById('lista'));
    } else {
        document.getElementById('auto').className = "gyorskereso_felso_link_sima";
        document.getElementById('meret').className = "gyorskereso_felso_link_aktiv";
        new tree (TREE_ITEMS_MERET, tree_tpl,document.getElementById('lista'));
    }
    if (QueryString('tmb1')){
        trees[0].tmB(QueryString('tmb1'));
        trees[0].tmB(QueryString('tmb2'));
        trees[0].tmB(QueryString('tmb3'));
    }
    if (nyitva = QueryString("tmb1")){
        id = ('i_txt0_' + QueryString('tmb1'));
        if (document.getElementById('lista')){
            listaheight = document.getElementById('lista').clientHeight;
            listat_atmeretez();
        }
        divpos = findPosition(document.getElementById('lista'));
        apos = findPosition(document.getElementById(id));
        apos[1] = apos[1] - divpos[1];
        st = document.getElementById('lista').scrollTop = apos[1];
        if ((st + 300) > listaheight){
            st = listaheight - 280;
        }
        document.getElementById('lista').scrollTop = st;
    } else {
        listat_atmeretez();
    }
}
function listat_megjelenit() {
}
function init(){
    /*loadjscssfile("/scripts/tree_items_auto.js","js");
    loadjscssfile("/scripts/tree_items_meret.js","js");
    var lista = "";
    if (qs = QueryString("lista")){
        lista = qs;
    } else {
        lista = "auto";
    }
    if (document.getElementById("lista")) {
        setTimeout("changetab('" + lista + "');",3000);
    }*/
    try {
        var pageTracker = _gat._getTracker("UA-8367714-1");
        pageTracker._trackPageview();
    } catch(err) {}
}
function akciomutat(el,html,url) {
    mehet = true;
    //var pos = findPos(el.parentNode);
    if (el.parentNode.parentNode.childNodes.item(0).tagName == "TD") {
        var pos = findPos(el.parentNode.parentNode.childNodes.item(0));
    } else {
        var pos = findPos(el.parentNode.parentNode.childNodes.item(1));
    } 
    akciotelrejt();
    var div = document.createElement("div");
    div.style.position = "absolute";
    div.style.top = (pos[1] + el.parentNode.clientHeight) +"px";
    div.style.left = pos[0] + "px";
    div.style.backgroundColor = "white";
    div.style.border = "3px double #000000";
    div.style.padding = "5px";
    div.style.zIndex = 100;
    div.id = "floatingdiv";
    var t = document.createElement("table");
    var tbody = document.createElement("tbody");
    var tr = document.createElement("tr");
    var td = document.createElement("td");
    td.innerHTML = "<a href=\"Javascript:void(0);\" title=\"Kattintson ide az akciós ablak bezárásához!\" onclick=\"mehet=false;akciotelrejt();\"><small>Bezár</small></a>";
    td.setAttribute("align","right");
    tr.appendChild(td);
    tbody.appendChild(tr);
    var tr = document.createElement("tr");
    var td = document.createElement("td");
    td.innerHTML = html;
    td.setAttribute("style","font-family:Arial;font-size:12px;");
    tr.appendChild(td);
    tbody.appendChild(tr);
    t.appendChild(tbody);
    t.style.width = "600px";
    div.appendChild(t);
    div.onmouseout = new Function("akciotime = setTimeout('akciotelrejt()',1500);this.style.cursor='';");
    div.onmouseover = new Function("if (akciotime != null) {clearTimeout(akciotime)};this.style.cursor='pointer';");
    div.onclick = new Function("if (mehet) window.location.href='" + url + "'");
    div.setAttribute("title","Kattintson ide az akció részleteihez!");
    var b = getBody();
    b.appendChild(div);
}
function akciotelrejt() {
    clearTimeout(akciotime);
    if (document.getElementById('floatingdiv')) {
        document.getElementById('floatingdiv').parentNode.removeChild(document.getElementById('floatingdiv'));
    }
}
function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }
}
function getBody() {
    return document.getElementsByTagName('body').item(0);
}
function getMousePos(e) {
    if (document.layers||document.getElementById&&!document.all) {
        mouseX = e.pageX
        mouseY = e.pageY
    } else if (document.all) {
        mouseX = event.clientX
        mouseY = event.clientY
    }
}
if(!window.captureEvents) document.onmousemove=getMousePos
if (window.captureEvents) {
window.captureEvents(Event.MOUSEMOVE)
window.onmousemove=getMousePos
}
function IE() {
    var agt=navigator.userAgent.toLowerCase();
    if (agt.indexOf("opera") != -1) return 'Opera';
    if (agt.indexOf("staroffice") != -1) return 'Star Office';
    if (agt.indexOf("webtv") != -1) return 'WebTV';
    if (agt.indexOf("beonex") != -1) return 'Beonex';
    if (agt.indexOf("chimera") != -1) return 'Chimera';
    if (agt.indexOf("netpositive") != -1) return 'NetPositive';
    if (agt.indexOf("phoenix") != -1) return 'Phoenix';
    if (agt.indexOf("firefox") != -1) return 'Firefox';
    if (agt.indexOf("safari") != -1) return 'Safari';
    if (agt.indexOf("skipstone") != -1) return 'SkipStone';
    if (agt.indexOf("msie") != -1) return true;
    if (agt.indexOf("netscape") != -1) return 'Netscape';
    if (agt.indexOf("mozilla/5.0") != -1) return 'Mozilla';
    if (agt.indexOf('\/') != -1) {
    if (agt.substr(0,agt.indexOf('\/')) != 'mozilla') {
    return navigator.userAgent.substr(0,agt.indexOf('\/'));}
    else return 'Netscape';} else if (agt.indexOf(' ') != -1)
    return navigator.userAgent.substr(0,agt.indexOf(' '));
    else return navigator.userAgent;
}
function number_format(number, decimals, dec_point, thousands_sep) {
    var n = !isFinite(+number) ? 0 : +number, 
        prec = !isFinite(+decimals) ? 0 : Math.abs(decimals),
        sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep,        dec = (typeof dec_point === 'undefined') ? '.' : dec_point,
        s = '',
        toFixedFix = function (n, prec) {
            var k = Math.pow(10, prec);
            return '' + Math.round(n * k) / k;        };
    s = (prec ? toFixedFix(n, prec) : '' + Math.round(n)).split('.');
    if (s[0].length > 3) {
        s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep);    }
    if ((s[1] || '').length < prec) {
        s[1] = s[1] || '';
        s[1] += new Array(prec - s[1].length + 1).join('0');
    }    return s.join(dec);
}
function checkemail(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(email) == false) {
        return false;
    } else {
        return true;
    }
}
function print_r(theObj){
    if(theObj.constructor == Array || theObj.constructor == Object){
        document.write("<ul>")
        for(var p in theObj){
            if(theObj[p].constructor == Array||theObj[p].constructor == Object){
                document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
                document.write("<ul>")
                print_r(theObj[p]);
                document.write("</ul>")
            } else {
                document.write("<li>["+p+"] => "+theObj[p]+"</li>");
            }
        }
        document.write("</ul>")
    }
}
function myMenu(id) {
    this.id = id;
    this.type = "array";
    this.deffirstTDClass = "firsttdclass";
    this.deffirstAClass = "firstaclass";
    this.defTDClass = "tdclass";
    this.defAClass = "aclass";
    this.divClass = "divclass";
    this.defTarget = "_self";
    this.equalWidth = false;
    this.table = null;
    this.OP = false;
    this.FF = false;
    this.IE = false;
    this.opened = null;
    this.timeOut = 1000;
    
    this.browserType = function() {
        if (navigator.userAgent.toLowerCase().indexOf("opera") != -1){
            this.OP = true;
        }
        if (navigator.userAgent.toLowerCase().indexOf("msie") != -1){
            this.IE = true;
        }
        if (navigator.userAgent.toLowerCase().indexOf("firefox") != -1){
            this.FF = true;
        }
    }
    this.setClass = function(elem,classname) {
        if (this.FF){
            elem.setAttribute("class",classname);
        } else if (this.IE) {
            elem.className = classname;
        } else if (this.OP) {
            elem.className = classname;
        } else {
            elem.className = classname;
        }
    }
    this.getMenuItems = function(items) {
        switch (this.type) {
            case "XML":
            break;
            case "array":
                if (items == null) {
                    alert("Menu items are not available!");
                    return false;
                } else {
                    this.menuItems = items;
                    this.getMenuItemsfromArray();
                }
            break;
        }
    }
    this.getMenuItemsfromXML = function (params) {
    }
    this.getMenuItemsfromArray = function () {
        for (i in this.menuItems) {
            if (i < this.menuItems.length) {
                this.menuItems[i] = this.checkItem(this.menuItems[i],true);
            }
        }
    }
    this.checkItem = function (item,first) {
        if ((item['3'] == null)||(item['3'] == "")){
            if (first != null) {
                item['3'] = this.deffirstTDClass;
            } else {
                item['3'] = this.defTDClass;
            }
        }
        if ((item['4'] == null)||(item['4'] == "")){
            if (first != null) {
                item['4'] = this.deffirstAClass;
            } else {
                item['4'] = this.defAClass;
            }
        }
        if ((item['5'] == null)||(item['5'] == "")){
            item['5'] = this.defTarget;
        }
        if (item['1'] == "") {
            item['1'] = "#";
            item['5'] = "_self";
        }
        if ((item['2'] != null) && (is_array(item['2']))) {
            for (i = 0;i < item['2'].length;i++) {
                item['2'][i] = this.checkItem(item['2'][i]);
            }
        } else {
            item['2'] = "";
        }
        return item;
    }
    this.createTable = function () {
        var table = document.createElement("table");
        table.setAttribute("cellpadding",0);
        table.setAttribute("cellspacing",0);
        table.setAttribute("border",0);
        var tbody = document.createElement("tbody");
        var tr = document.createElement("tr");
        for (i = 0;i < this.menuItems.length;i++) {
            var item = this.menuItems[i];
            var td = document.createElement("td");
            this.setClass(td,item[3]);
            var menuPoint = document.createElement("a");
            this.setClass(menuPoint,item[4]);
            menuPoint.setAttribute("href",item[1]);
            menuPoint.setAttribute("target",item[5]);
            menuPoint.style.display = "block";
            menuPoint.style.width = "100%";
            menuPoint.setAttribute("style","display:block;width:100%;height:100%;");
            menuPoint.innerHTML = "&nbsp;" + item[0] + "&nbsp;";
            menuPoint.onmouseover = new Function (this.id + ".openFirst(" + i + ");");
            menuPoint.onmouseout = new Function (this.id + ".time=setTimeout('" + this.id + ".closeFirst()'," + this.timeOut +");");
            this.setClass(menuPoint,item[4]);
            td.appendChild(menuPoint);
            tr.appendChild(td);
        }
        tbody.appendChild(tr);
        table.appendChild(tbody);
        this.table = table;
    }
    this.openFirst = function (id) {
        if (document.getElementById) {
            var t = document.getElementsByTagName("div");
            for (i = 0;i < t.length;i++){
                //alert(t[i].id + ' -> ' + t[i].innerHTML);
            }
        }
        if (this.opened == id) {
            clearTimeout(this.time);
        } else if (this.opened != null){
            this.closeFirst();
        }
        this.opened = id;
        if (is_array(this.menuItems[id][2])) {
            var x = document.getElementById(this.id + "_firstSubmenu_" + id);
            if (x) {
                x.style.visibility='visible';
            }
        }
    }
    this.closeFirst = function () {
        clearTimeout(this.time);
        if ((this.opened != null)&&(this.opened != 'undefined')&&(is_array(this.menuItems[this.opened][2]))){
            var x = document.getElementById(this.id + "_firstSubmenu_" + this.opened);
            if (x) {
                x.style.visibility='hidden';
            }
            this.opened = null;
        }
    }
    this.formatTable = function () {
        if (this.equalWidth) {
            var w = 0;
            var tds = document.getElementById(this.id + "_contentdiv").childNodes[0].getElementsByTagName("td");
            for (i = 0;i < tds.length;i++){
                if (w < tds[i].offsetWidth) {
                    w = tds[i].offsetWidth;
                }
            }
            for (i = 0;i < tds.length;i++){
                tds[i].style.width = w + 'px';
                tds[i].style.textAlign = 'center';
            }
        } else {
            document.getElementById(this.id + "_contentdiv").childNodes[0].style.width = "100%";
        }
        document.getElementById(this.id + "_contentdiv").style.visibility = 'visible';
    }
    this.createFirstSubs = function () {
        var t = document.getElementById(this.id + "_contentdiv").childNodes[0];
        var tds = t.getElementsByTagName("a");
        for (i = 0;i < tds.length;i++) {
            if ((this.menuItems[i][2] != null)&&(is_array(this.menuItems[i][2]))) {
                var pos = findPos(tds[i]);
                pos[1] += tds[i].parentNode.offsetHeight;
                var table = document.createElement("table");
                table.setAttribute("border",0);
                table.setAttribute("cellpadding",0);
                table.setAttribute("cellspacing",0);
                var tbody = document.createElement("tbody");
                for (j = 0;j < this.menuItems[i][2].length;j++) {
                    var tr = document.createElement("tr");
                    var td = document.createElement("td");
                    this.setClass(td,this.menuItems[i][2][j][3]);
                    td.setAttribute("style","white-space:nowrap;");
                    td.setAttribute("nowrap","nowrap");
                    var menuPoint = document.createElement("a");
                    this.setClass(menuPoint,this.menuItems[i][2][j][4]);
                    menuPoint.setAttribute("href",this.menuItems[i][2][j][1]);
                    menuPoint.setAttribute("target",this.menuItems[i][2][j][5]);
                    menuPoint.innerHTML = "&nbsp;" + this.menuItems[i][2][j][0] + "&nbsp;";
                    menuPoint.style.display = "block";
                    menuPoint.style.width = "100%";
                    menuPoint.setAttribute("style","display:block;width:100%;");
                    td.appendChild(menuPoint);
                    tr.appendChild(td);
                    tbody.appendChild(tr);
                }
                table.appendChild(tbody);
                var div = document.createElement("div");
                this.setClass(div,this.divClass);
                if (document.getElementById(this.id + "_firstSubmenu_" + i)) {
                    document.getElementById(this.id + "_firstSubmenu_" + i).parentNode.removeChild(document.getElementById(this.id + "_firstSubmenu_" + i));
                }
                div.setAttribute("id",this.id + "_firstSubmenu_" + i);
                div.id = this.id + "_firstSubmenu_" + i;
                div.name = this.id + "_firstSubmenu_" + i;
                div.appendChild(table);
                div.style.position = "absolute";
                div.style.top = pos[1] + "px";
                div.style.left = pos[0] + "px";
                div.style.zIndex = 100;
                if (this.OP) {
                div.style.visibility = "visible";
                } else {
                div.style.visibility = "hidden";
                }
                div.style.border = "0px";
                div.onmouseover = new Function ("if (" + this.id + ".time) {clearTimeout(" + this.id + ".time);}");
                div.onmouseout = new Function (this.id + ".time=setTimeout('" + this.id + ".closeFirst()'," + this.timeOut + ");");
                if (this.OP) {
                    document.appendChild(div);
                } else {
                    document.body.appendChild(div);
                }
                var max = 0;
                var tds1 = document.getElementById(this.id + "_firstSubmenu_" + i).childNodes[0].getElementsByTagName("td");
                for (j = 0;j < tds1.length;j++){
                    if (tds1[j].offsetWidth > max) {
                        max = tds1[j].offsetWidth;
                    }
                }
                if (max < tds[i].offsetWidth) {
                    document.getElementById(this.id + "_firstSubmenu_" + i).childNodes[0].style.width = max + "px";
                }
            }
        }
    }
    this.createSubs = function (item) {
    }
    this.show = function(params) {
        document.write("<div id='" + this.id + "_contentdiv' style='position:relative;top:0px;left:0px;border:0px solid red;visibility:hidden'></div>");
        this.browserType();
        this.getMenuItems(params);
        this.createTable();
        document.getElementById(this.id + "_contentdiv").appendChild(this.table);
        if (window.onload){
            var ol = window.onload.toString();
            var pattern = new RegExp("\{([^\}]*\)}");
            ol = ol.match(pattern)[1] + ' ' + this.id + ".formatTable();\n" + this.id + ".createFirstSubs();\n";
        } else {
            var ol = this.id + ".formatTable();\n" + this.id + ".createFirstSubs();\n";
        }
        var func = function () {eval(ol);}
        window.onload  = func;
        window.onresize = func;

        //document.getElementById(this.id + "_contentdiv").style.visibility = 'visible';
    }
}

function is_array( mixed_var ) {
    var key = '';
    if (!mixed_var) {
        return false;
    }
    if (typeof mixed_var === 'object') {
        return true;
        if (mixed_var.hasOwnProperty) {
            for (key in mixed_var) {
                if (false === mixed_var.hasOwnProperty(key)) {
                    return false;
                }
            }
        }
        return true;
    }
    return false;
}
function print_r(theObj) {
    if(theObj.constructor == Array || theObj.constructor == Object){
        document.write("<ul>")
        for(var p in theObj){
            if(theObj[p].constructor == Array || theObj[p].constructor == Object){
                document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
                document.write("<ul>")
                print_r(theObj[p]);
                document.write("</ul>")
            } else {
                document.write("<li>["+p+"] => "+theObj[p]+"</li>");
            }
        }
        document.write("</ul>")
    }
}
function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        do {
            curleft += obj.offsetLeft;
            curtop += obj.offsetTop;
            } while (obj = obj.offsetParent);
        return [curleft,curtop];
    }
}
/* TODO_HEMU
    Az intelligens url meghívásnál a márka változót nem kapja meg, vagy nullázva kapja az afrissit fgv.
TODO */

var marka = QueryString("marka").toUpperCase();
var tipus = QueryString("tipus").toUpperCase();
var kivitel = QueryString("kivitel").toUpperCase();
var gyido = QueryString("gyido").toUpperCase();
var page = "{PAGE}";
var pattern = "auto[-_]?keres[o|e]?[s]?\/([^\/]*)\/([^\/]*)\/([^\/]*)\/(.*)$";
var m = window.location.href.match(pattern);
if (m != null){
    marka = m[1].toUpperCase();
    tipus = m[2].toUpperCase();
    kivitel = m[4].toUpperCase();
    gyido = m[3].toUpperCase();
}
var markaselect = "";
var tipusselect = "";
var gyidoselect = "";
var kivitelselect = "";
function akeres(){
    if (document.getElementById('markaselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        marka = document.getElementById('markaselect').options[document.getElementById('markaselect').selectedIndex].value;
    }
    if (document.getElementById('tipusselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        tipus = document.getElementById('tipusselect').options[document.getElementById('tipusselect').selectedIndex].value;
    }
    if (document.getElementById('gyidoselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        gyido = document.getElementById('gyidoselect').options[document.getElementById('gyidoselect').selectedIndex].value;
    }
    if (document.getElementById('kivitelselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        kivitel = document.getElementById('kivitelselect').options[document.getElementById('kivitelselect').selectedIndex].value;
    }
    var str = "/index.php?page=" + page + "&marka=" + escape(marka) + "&tipus=" + escape(tipus) + "&gyido=" + escape(gyido) + "&kivitel=" + escape(kivitel);
    window.location.href = str;
}
function afrissit(param){
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    if (param == 0){
        markaselect = "";
        tipusselect = "";
        gyidoselect = "";
        kivitelselect = "";
    } else if (param == 1) {
        markaselect = marka;
        tipusselect = tipus;
        gyidoselect = gyido;
        kivitelselect = kivitel;
    } else if (param == 2){
        markaselect = document.getElementById('markaselect').options[document.getElementById('markaselect').options.selectedIndex].value;
        tipusselect = "";
        gyidoselect = "";
        kivitelselect = "";
    } else if (param == 3){
        markaselect = document.getElementById('markaselect').options[document.getElementById('markaselect').options.selectedIndex].value;
        tipusselect = document.getElementById('tipusselect').options[document.getElementById('tipusselect').options.selectedIndex].value;
        gyidoselect = "";
        kivitelselect = "";
    } else if (param == 4){
        markaselect = document.getElementById('markaselect').options[document.getElementById('markaselect').options.selectedIndex].value;
        tipusselect = document.getElementById('tipusselect').options[document.getElementById('tipusselect').options.selectedIndex].value;
        gyidoselect = document.getElementById('gyidoselect').options[document.getElementById('gyidoselect').options.selectedIndex].value;
        kivitelselect = "";
    } else if (param == 5){
        markaselect = document.getElementById('markaselect').options[document.getElementById('markaselect').options.selectedIndex].value;
        tipusselect = document.getElementById('tipusselect').options[document.getElementById('tipusselect').options.selectedIndex].value;
        gyidoselect = document.getElementById('gyidoselect').options[document.getElementById('gyidoselect').options.selectedIndex].value;
        kivitelselect = document.getElementById('kivitelselect').options[document.getElementById('kivitelselect').options.selectedIndex].value;
    }
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
            while (!xmldoc){
                var xmldoc = xmlHttp.responseXML;
            }
            if (xmldoc){
                var markak = xmldoc.getElementsByTagName("MARKA");
                afeltolt(markak,document.getElementById('markaselect'),markaselect);
                var tipusok = xmldoc.getElementsByTagName("TIPUS");
                afeltolt(tipusok,document.getElementById('tipusselect'),tipusselect);
                var gyidok = xmldoc.getElementsByTagName("GYIDO");
                afeltolt(gyidok,document.getElementById('gyidoselect'),gyidoselect);
                var kivitelek = xmldoc.getElementsByTagName("KIVITEL");
                afeltolt(kivitelek,document.getElementById('kivitelselect'),kivitelselect);
            }
        }
    };
    xmlHttp.open("GET","/ajax/" + page + "?marka=" + escape(markaselect) + "&tipus=" + escape(tipusselect) + "&kivitel=" + escape(kivitelselect) + "&gyido=" + escape(gyidoselect),true);
    xmlHttp.send(null);
}
function afeltolt(adatok,elem,selected){
    elem.options.length = 0;
    elem.options[elem.options.length] = new Option("","");
    for (i = 0;i < adatok.length;i++){
        elem.options[elem.options.length] = new Option(adatok[i].childNodes[0].nodeValue.toUpperCase(),adatok[i].childNodes[0].nodeValue);
        if ((unescape(selected) == adatok[i].childNodes[0].nodeValue)||(unescape(selected) == adatok[i].childNodes[0].nodeValue.toUpperCase())){
            elem.options[elem.options.length-1].selected = true;
        }
    }
}

var csavar = QueryString("csavar").toUpperCase();
var et = QueryString("et").toUpperCase();
var meret1 = QueryString("meret1").toUpperCase();
var meret2 = QueryString("meret2").toUpperCase();
var csavarselect = "";
var etselect = "";
var meret1select = "";
var meret2select = "";

function fkeres(){
    if (document.getElementById('csavarselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        csavar = document.getElementById('csavarselect').options[document.getElementById('csavarselect').selectedIndex].value;
    }
    if (document.getElementById('etselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        et = document.getElementById('etselect').options[document.getElementById('etselect').selectedIndex].value;
    }
    if (document.getElementById('meret1select').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        meret1 = document.getElementById('meret1select').options[document.getElementById('meret1select').selectedIndex].value;
    }
    if (document.getElementById('meret2select').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        meret2 = document.getElementById('meret2select').options[document.getElementById('meret2select').selectedIndex].value;
    }
    var str = "/index.php?page=fkeres&csavar=" + escape(csavar) + "&et=" + escape(et) + "&meret1=" + escape(meret1) + "&meret2=" + escape(meret2);
    window.location.href = str;
}
function ffrissit(param){
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    if (param == 0){
        csavarselect = "";
        etselect = "";
        meret1select = "";
        meret2select = "";
    } else if (param == 1) {
        csavarselect = csavar;
        etselect = et;
        meret1select = meret1;
        meret2select = meret2;
    } else if (param == 2){
        csavarselect = document.getElementById('csavarselect').options[document.getElementById('csavarselect').options.selectedIndex].value;
        etselect = "";
        meret1select = "";
        meret2select = "";
    } else if (param == 3){
        csavarselect = document.getElementById('csavarselect').options[document.getElementById('csavarselect').options.selectedIndex].value;
        etselect = document.getElementById('etselect').options[document.getElementById('etselect').options.selectedIndex].value;
        meret1select = "";
        meret2select = "";
    } else if (param == 4){
        csavarselect = document.getElementById('csavarselect').options[document.getElementById('csavarselect').options.selectedIndex].value;
        etselect = document.getElementById('etselect').options[document.getElementById('etselect').options.selectedIndex].value;
        meret1select = document.getElementById('meret1select').options[document.getElementById('meret1select').options.selectedIndex].value;
        meret2select = "";
    } else if (param == 5){
        csavarselect = document.getElementById('csavarselect').options[document.getElementById('csavarselect').options.selectedIndex].value;
        etselect = document.getElementById('etselect').options[document.getElementById('etselect').options.selectedIndex].value;
        meret1select = document.getElementById('meret1select').options[document.getElementById('meret1select').options.selectedIndex].value;
        meret2select = document.getElementById('meret2select').options[document.getElementById('meret2select').options.selectedIndex].value;
    }
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
            while (!xmldoc){
                var xmldoc = xmlHttp.responseXML;
            }
            if (xmldoc){
                var csavarok = xmldoc.getElementsByTagName("CSAVAR");
                ffeltolt(csavarok,document.getElementById('csavarselect'),csavarselect);
                var etk = xmldoc.getElementsByTagName("ET");
                ffeltolt(etk,document.getElementById('etselect'),etselect);
                var meret1ek = xmldoc.getElementsByTagName("MERET1");
                ffeltolt(meret1ek,document.getElementById('meret1select'),meret1select);
                var meret2ek = xmldoc.getElementsByTagName("MERET2");
                ffeltolt(meret2ek,document.getElementById('meret2select'),meret2select);
            }
        }
    };
    xmlHttp.open("GET","/ajax/fkeres.php?csavar=" + escape(csavarselect) + "&et=" + escape(etselect) + "&meret1=" + escape(meret1select) + "&meret2=" + escape(meret2select),true);
    xmlHttp.send(null);
}
function ffeltolt(adatok,elem,selected){
    elem.options.length = 0;
    elem.options[elem.options.length] = new Option("","");
    for (i = 0;i < adatok.length;i++){
        elem.options[elem.options.length] = new Option(adatok[i].childNodes[0].nodeValue.toUpperCase(),adatok[i].childNodes[0].nodeValue);
        if ((unescape(selected) == adatok[i].childNodes[0].nodeValue)||(unescape(selected) == adatok[i].childNodes[0].nodeValue.toUpperCase())){
            elem.options[elem.options.length-1].selected = true;
        }
    }
}

var profil = escape(QueryString("profil").toUpperCase());
var szelmag = escape(QueryString("szelmag").toUpperCase());
var atmero = escape(QueryString("atmero").toUpperCase());
var marka = escape(QueryString("marka").toUpperCase());
var patternmeret = "\/([0-9]{3})\/([0-9]{1,2})R([0-9]{2})";
var patterngyarto = "\/([^\/]*)\/[0-9]{3}\/[0-9]{1,2}R[0-9]{2}";
var m = window.location.href.match(patternmeret);
if (m != null){
    var profil = m[1];
    var szelmag = m[2];
    var atmero = m[3];
}
var m = window.location.href.match(patterngyarto);
if (m != null){
    var marka = m[1];
}
var profilselect = "";
var szelmagselect = "";
var atmeroselect = "";
var markaselect = "";
function gkeres(){
    if (document.getElementById('profilselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        profil = document.getElementById('profilselect').options[document.getElementById('profilselect').selectedIndex].value;
    }
    if (document.getElementById('szelmagselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        szelmag = document.getElementById('szelmagselect').options[document.getElementById('szelmagselect').selectedIndex].value;
    }
    if (document.getElementById('atmeroselect').selectedIndex == 0){
        alert("Minden adat megadása kötelező!");
        return false;
    } else {
        atmero = document.getElementById('atmeroselect').options[document.getElementById('atmeroselect').selectedIndex].value;
    }
    if (document.getElementById('markaselect').selectedIndex > 0){
        marka = document.getElementById('markaselect').options[document.getElementById('markaselect').selectedIndex].value;
    } else {
        marka = "";
    }
    var ideny = document.getElementById("ideny").value;
    location.href = "/index.php?page=gkeres&profil=" + profil + "&szelmag=" + szelmag + "&atmero=" + atmero + "&marka=" + marka + "&" + ideny + "=on";
}
function gfrissit(param){
    xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null){
        alert ("Your browser does not support AJAX!");
        return;
    }
    if (param == 0){
        profilselect = "";
        szelmagselect = "";
        atmeroselect = "";
        markaselect = "";
    } else if (param == 1) {
        profilselect = profil;
        szelmagselect = szelmag;
        atmeroselect = atmero;
        markaselect = marka;
    } else if (param == 2){
        profilselect = document.getElementById('profilselect').options[document.getElementById('profilselect').options.selectedIndex].value;
        szelmagselect = "";
        atmeroselect = "";
        markaselect = "";
    } else if (param == 3){
        profilselect = document.getElementById('profilselect').options[document.getElementById('profilselect').options.selectedIndex].value;
        szelmagselect = document.getElementById('szelmagselect').options[document.getElementById('szelmagselect').options.selectedIndex].value;
        atmeroselect = "";
        markaselect = "";
    } else if (param == 4){
        profilselect = document.getElementById('profilselect').options[document.getElementById('profilselect').options.selectedIndex].value;
        szelmagselect = document.getElementById('szelmagselect').options[document.getElementById('szelmagselect').options.selectedIndex].value;
        atmeroselect = document.getElementById('atmeroselect').options[document.getElementById('atmeroselect').options.selectedIndex].value;
        markaselect = "";
    } else if (param == 5){
        profilselect = document.getElementById('profilselect').options[document.getElementById('profilselect').options.selectedIndex].value;
        szelmagselect = document.getElementById('szelmagselect').options[document.getElementById('szelmagselect').options.selectedIndex].value;
        atmeroselect = document.getElementById('atmeroselect').options[document.getElementById('atmeroselect').options.selectedIndex].value;
        markaselect = document.getElementById('markaselect').options[document.getElementById('markaselect').options.selectedIndex].value;
    }
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
            while (!xmldoc){
                var xmldoc = xmlHttp.responseXML;
            }
            if (xmldoc){
                var profilok = xmldoc.getElementsByTagName("profil");
                gfeltolt(profilok,document.getElementById('profilselect'),profilselect);
                var szelmagok = xmldoc.getElementsByTagName("szelmag");
                gfeltolt(szelmagok,document.getElementById('szelmagselect'),szelmagselect);
                var atmerok = xmldoc.getElementsByTagName("atmero");
                gfeltolt(atmerok,document.getElementById('atmeroselect'),atmeroselect);
                var markak = xmldoc.getElementsByTagName("gyarto");
                gfeltolt(markak,document.getElementById('markaselect'),markaselect);
            }
        }
    };
    xmlHttp.open("GET","/ajax/gkeres.php?profil=" + escape(profilselect) + "&szelmag=" + escape(szelmagselect) + "&atmero=" + escape(atmeroselect) + "&marka=" + escape(markaselect),true);
    xmlHttp.send(null);
}
function gfeltolt(adatok,elem,selected){
    if (elem){
        elem.options.length = 0;
        elem.options[elem.options.length] = new Option("","");
        for (i = 0;i < adatok.length;i++){
            elem.options[elem.options.length] = new Option(adatok[i].childNodes[0].nodeValue.toUpperCase(),adatok[i].childNodes[0].nodeValue);
            if ((unescape(selected) == adatok[i].childNodes[0].nodeValue)||(unescape(selected) == adatok[i].childNodes[0].nodeValue.toUpperCase())){
                elem.options[elem.options.length-1].selected = true;
            }
        }
    }
}

