function createRequestObject(){
    var req
    try{
        req=new ActiveXObject("Microsoft.XMLHTTP")
    }catch(e){
        req=new XMLHttpRequest()
    }
    return req
}
function browser(){
    if(document.all && document.getElementById){
        return 1;
    }else{
        return 2;
    }
}
function scrollDown2(n){
    window.scrollTo(0,n);
}
function winOpen(url,n,width,height){
    var newablak
    var sw=screen.width;
    var sh=screen.height;
    var left=sw?(sw-width)/2:0;
    var top=sh?(sh-height)/2:0;
    newablak=window.open(url,n,"width="+width+",height="+height+",top="+top+",left="+left+",resizable=1,location=0,statusbar=1,toolbar=0,scrollbars=1");
}
var t;
function sugo(sugo_id,width){
    t=setTimeout("sugoPrint("+sugo_id+","+width+")",200);
}
function hEllenor(obj){
    var retval=true;
    if(obj.ugyfel_nev.value==""){
        alert("Kérem adja meg a nevét!");
        obj.ugyfel_nev.focus();
        retval=false;
    }else if(obj.ugyfel_tel.value==""){
        alert("Kérem adja meg a telefonszámát!");
        obj.ugyfel_tel.focus();
        retval=false;
    }else if(obj.hitelosszeg.value==""){
        alert("Kérem töltse ki a \"Hitelösszeg\" mezőt!");
        obj.hitelosszeg.focus();
        retval=false;
    }
    return retval;
}
function setSzlaCim(f){
    f.szla_nev.value=f.nev.value;
    f.szla_irsz.value=f.irsz.value;
    f.szla_varos.value=f.varos.value;
    f.szla_cim.value=f.cim.value;
    return true;
}
function sugoPrint(sugo_id,width){
    sugo_id=(sugo_id)?sugo_id:0;
    width=(width)?width:300;
    var div=document.getElementById("sugo");
    var div2=document.getElementById("sugo"+sugo_id);
    
    x=findPosX(div2)+30
    y=findPosY(div2)

    div.style.display="block";
    div.innerHTML="";
    div.innerHTML="<table width='"+width+"' cellpadding='0' cellspacing='0' border='0'><tr><td class='sugobgkeret'><table width='100%' cellpadding='4' cellspacing='1' border='0'><tr><td class='sugobg'>"+content[sugo_id]+"</td></tr></table></td></tr></table>";
    div.style.left=x+"px"
    div.style.top=y+"px"
}
function getwsize(){
    var retval
    if(typeof(window.innerWidth)=="number"){
        retval=window.innerWidth
    }else if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
        retval=document.documentElement.clientWidth
    }else if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
        retval=document.body.clientWidth
    }
    return retval
}
function sugoOff(){
    if(t){
        clearTimeout(t);
    }
    var div=document.getElementById("sugo");
    div.innerHTML="";
    div.style.display="none";
}
function megelhetesiktgCalc(obj,div){
    var div=document.getElementById(div);

    keresok=obj.keresok.value;
    eltartottak=obj.eltartottak.value;
    lakohely=obj.lakohely.value;

    var http=createRequestObject();
    http.open("get","megelhetesi_ktg.ajax.php?lakohely="+lakohely+"&keresok="+keresok+"&eltartottak="+eltartottak,true);
    http.onreadystatechange=function(){
        if(http.readyState==4){
            div.innerHTML=http.responseText;
        }
    }
    http.send(null);
}
function findPosX(obj){
    var curleft=0
    if(obj.offsetParent){
        while(obj.offsetParent){
            curleft+=obj.offsetLeft
            obj=obj.offsetParent
        }
    }else if(obj.x) curleft+=obj.x
    return curleft
}
function findPosY(obj){
    var curtop=0
    if(obj.offsetParent){
        while(obj.offsetParent){
            curtop+=obj.offsetTop
            obj=obj.offsetParent
        }
    }else if(obj.y) curtop+=obj.y
    return curtop
}
var inmenu=false
var lastmenu=0
var orig_="";
var roll_="";
var kepid_="";
var erasing=""
//var cucc=""
//var opac=0
//var layeritem=""
function showmenu(o1,o2,orig,roll,kepid){

    layeritem=o2

    if(kepid_){
        document.getElementById(kepid_).src=orig_;
    }

    orig_=(orig)?orig:"";
    roll_=(roll)?roll:"";
    kepid_=(kepid)?kepid:"";
    
    if(roll_!=""){
        document.getElementById(kepid_).src=roll_;
    }
    
    sw=getwsize()
    kw=parseInt(document.getElementById(o2).style.width)
    kwimg=parseInt(document.getElementById(kepid).width)

    inmenu=true

    if(erasing) clearTimeout(erasing)
    /*if(cucc){
        clearTimeout(cucc)
        cucc=""
    }*/
    oldmenu=lastmenu

    lastmenu=o2
    if(oldmenu) erase(oldmenu)
    x=(findPosX(document.getElementById(o1))+menuLeft)
    y=(findPosY(document.getElementById(o1))+menuTop)
    
    if(x+kw>sw){
        x=x-kw+kwimg
    }
    
    document.getElementById(o2).style.visibility="visible"
    

/*    opac=0
    bcheck=browser()
    if(bcheck==1){
        document.getElementById(o2).style.filter="alpha(opacity="+opac+")";
    }else{
        document.getElementById(o2).style.MozOpacity=opac/100;
    }*/

    document.getElementById(o2).style.left=x+"px"
    document.getElementById(o2).style.top=y+"px"
    
    //fadeIn()
}
function fadeIn(){
    bcheck=browser()
    if(bcheck==1){
        document.getElementById(layeritem).style.filter="alpha(opacity="+opac+")";
    }else{
        document.getElementById(layeritem).style.MozOpacity=opac/100;
    }
    if(opac>=98){
        if(cucc){
            clearTimeout(cucc)
            cucc=""
        }
/*        opac=95
        if(bcheck==1){
            document.getElementById(layeritem).style.filter="alpha(opacity="+opac+")";
        }else{
            document.getElementById(layeritem).style.MozOpacity=opac/100;
        }*/
    }else{
        opac+=20
        cucc=setTimeout("fadeIn()",0)
    }
}
function erase(o2){
    if(inmenu&&lastmenu==o2){
        return;
    }

    if(!inmenu) document.getElementById(kepid_).src=orig_;
    document.getElementById(o2).style.visibility="hidden"
}
function timer(o2){
    inmenu=false
    erasing=window.setTimeout("erase('"+o2+"')",350)
}
function marad(o1,o2,m,c){
    inmenu=true
    if(erasing) clearTimeout(erasing)

    if(roll_!="") document.getElementById(kepid_).src=roll_;
    
    lastmenu=o2
    document.getElementById(m).className=c
}
function megy(o2,m,oc){
    timer(o2)
    document.getElementById(m).className=oc
}

function ezresbonto(form){
    var szam=form.value;
    var sep=" ";
    szam=szam.replace(/ /g,"");
    szam=szam.replace(".","");
    szam=szam.replace(",","");
    if(szam.length==5){
        szam=szam.substring(0,2)+sep+szam.substring(2);
    }else if(szam.length==6){
        szam=szam.substring(0,3)+sep+szam.substring(3);
    }else if(szam.length==7){
        szam=szam.substring(0,1)+sep+szam.substring(1,4)+sep+szam.substring(4);
    }else if(szam.length==8){
        szam=szam.substring(0,2)+sep+szam.substring(2,5)+sep+szam.substring(5);
    }else if(szam.length==9){
        szam=szam.substring(0,3)+sep+szam.substring(3,6)+sep+szam.substring(6);
    }else if(szam.length==10){
        szam=szam.substring(0,1)+sep+szam.substring(1,4)+sep+szam.substring(4,7)+sep+szam.substring(7);
    }else if(szam.length==11){
        szam=szam.substring(0,2)+sep+szam.substring(2,5)+sep+szam.substring(5,8)+sep+szam.substring(8);
    }else if(szam.length==12){
        szam=szam.substring(0,3)+sep+szam.substring(3,6)+sep+szam.substring(6,9)+sep+szam.substring(9);
    }else if(szam.length==13){
        szam=szam.substring(0,4)+sep+szam.substring(4,7)+sep+szam.substring(7,10)+sep+szam.substring(10);
    }
    form.value=szam;
}
