function formatNumber(mezo)
{
	szam=mezo.value;
	ujszam=szam.replace(/ /g,'');
	uj='';
	szamlalo=1;
	if (isNaN(ujszam))
		mezo.value=szam.substr(0,szam.length-1);
	else
	{
		szam=ujszam;
		for (i=szam.length-1;i>=0;--i)
		{
			ch=szam.substr(i,1);        //IE nem ismeri a szam[i] string elem formtumot!!!!!!
			uj=ch+uj;
			if (szamlalo==3)
			{
				uj=' '+uj;
				szamlalo=0;
			}
			szamlalo+=1;
				
		}
		mezo.value=uj;   
	}
}

function kepCsere(img)
{                       
	document.getElementById('nagykep').innerHTML='<img border=0 src='+img+' width=360>';
}

function flashCsere(id,img)
{
	document.getElementById('nagykep').innerHTML='<embed flashvars="vID=3882a7e949&autostart=false" wmode="transparent" src="http://automery.hu/gallery/model_'+id+'/flash/'+img+'" quality="high" bgcolor="transparent" width="360" height="236" name="guPlayer3882a7e949" align="middle" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
}

function initMoving(target, topPosition, topLimit, btmLimit) {
 if (!target)
 return false;

 var obj = target;
 obj.initTop = topPosition;
 obj.topLimit = topLimit;
 obj.bottomLimit = document.documentElement.scrollHeight - btmLimit;

 obj.style.position = "absolute";
 obj.top = obj.initTop;
 obj.left = obj.initLeft;
 obj.style.top = obj.top + "px";
 obj.getTop = function() {
 return document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
 }
 
 obj.getHeight = function() {
 return document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
 }
 
 obj.move = setInterval(function() {
 pos = obj.getTop() + topPosition;
 // pos = obj.getTop() + obj.getHeight() / 2 - 15;
  
 if (pos > obj.bottomLimit)
 pos = obj.bottomLimit
 if (pos < obj.topLimit)
 pos = obj.topLimit

 interval = obj.top - pos;
 obj.top = obj.top - interval /3;
 obj.style.top = obj.top + "px";
 }, 30)
}


function ShowKep(parent, kepurl)
{
	de=document.getElementById('lebego');
	de.innerHTML='<img src="img/kiskephatter_top.jpg" onClick="HideKep();">'+
	'<img src="'+kepurl+'" width="200" onClick="HideKep();" >'+
	'<img src="img/kiskephatter_bottom.jpg" onClick="HideKep();">';
	de.style.display="block";
	x=findPosX(parent);
	y=findPosY(parent);
//	alert("x: "+x+", y: "+y);
	de.style.top=y + "px";
	de.style.left=x + "px";

}
function HideKep()
{
	document.getElementById('lebego').style.display="none";
}

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;
}

function ShowLegordul(mid,magas)
{
  parent_obj=document.getElementById('menu'+mid);
  div_obj=document.getElementById('menu_pont'+mid);
  var aleft=findPosX(parent_obj);
  var atop=findPosY(parent_obj)-magas;
  //div_obj.style.position='absolute';
 // div_obj.style.left=aleft+'px';
  var aleft=findPosX(div_obj)+30;
  var atop=findPosY(div_obj)+30;
  parent_obj.style.left=aleft+'px';
  parent_obj.style.top=atop+'px';
  
  parent_obj.style.display='block';  
  parent_obj.style.display='block';
}
function ShowKereso(div_obj)
{
  parent_obj=document.getElementById('menu6');
  var aleft=findPosX(parent_obj);
  var atop=findPosY(parent_obj)-magas;
  //div_obj.style.position='absolute';
 // div_obj.style.left=aleft+'px';
  var aleft=findPosX(div_obj)+30;
  var atop=findPosY(div_obj)+30;
  parent_obj.style.left=aleft+'px';
  parent_obj.style.top=atop+'px';
  
}
function ShowLemenu(mid,magas)
{
  parent_obj=document.getElementById('almenu'+mid);
  div_obj=document.getElementById('almenu_pont1');
  var aleft=findPosX(parent_obj);
  var atop=findPosY(parent_obj)-magas;
  //div_obj.style.position='absolute';
 // div_obj.style.left=aleft+'px';
  var aleft=findPosX(div_obj)+30;
  var atop=findPosY(div_obj)+43;
  parent_obj.style.left=aleft+'px';
  parent_obj.style.top=atop+'px';
  
  parent_obj.style.display='block';  
  parent_obj.style.display='block';
  }
  
function ShowHideDiv(obj_id,show, parent)
{
    obj=document.getElementById('hidediv_'+obj_id);
    if (obj.style.display=='none')
    {
        for (i=0;i<1000;++i)
        {
            if (ob=document.getElementById('hidediv_'+i))
            {
                ob.style.display='none';
                par=document.getElementById('gyik_kerdes_'+i);
                par.style.fontWeight='normal';
                par.style.color="#000000";
                ob=document.getElementById('hrdiv_'+i);
                ob.style.display='none';
            }                
        }
        obj.style.display=show;
        document.getElementById('hrdiv_'+obj_id).style.display=show;
    }
    else 
    {
        obj.style.display='none';
        document.getElementById('hrdiv_'+obj_id).style.display='none';
    }
    if (parent)
    {
        if (parent.style.fontWeight=='bold')
        {
             parent.style.fontWeight='normal';
             parent.style.color="#000000";
        }
        else
        {
            parent.style.fontWeight='bold';
            parent.style.color="#3d4f77";
        }
    }
}
function checkBelephet(obj)
{
    nev=document.getElementById('i_name');
    pw=document.getElementById('i_pw');
    str=obj.value;
    if (str.length>5 && nev.value.length>2 && pw.value.length>2 )
    {
        document.getElementById('btn_belep').style.visibility="visible";
    }
    else
        document.getElementById('btn_belep').style.visibility="hidden";
}
function nagyit()
{
    e=document.getElementById('hirek_doboz');
    if (e.style.fontSize=='16px' || e.style.fontSize=='18px')
		e.style.fontSize='18px';
	else if (e.style.fontSize=='10px')
		e.style.fontSize='12px';
	else if (e.style.fontSize=='12px')
		e.style.fontSize='14px';
	else
		e.style.fontSize='16px';
	e=document.getElementById('hirek_dobozfent');
    if (e.style.fontSize=='16px' || e.style.fontSize=='18px')
		e.style.fontSize='18px';
	else if (e.style.fontSize=='10px')
		e.style.fontSize='12px';
	else if (e.style.fontSize=='12px')
		e.style.fontSize='14px';
	else
		e.style.fontSize='16px';
}
function kicsinyit()
{
	var e=document.getElementById('hirek_doboz');
	if (e.style.fontSize=='16px')
		e.style.fontSize='14px';
	else if (e.style.fontSize=='18px')
		e.style.fontSize='16px';
	else if (e.style.fontSize=='12px' || e.style.fontSize=='10px')
		e.style.fontSize='10px';
	else
		e.style.fontSize='12px';
	e=document.getElementById('hirek_dobozfent');
	if (e.style.fontSize=='16px')
		e.style.fontSize='14px';
	else if (e.style.fontSize=='18px')
		e.style.fontSize='16px';
	else if (e.style.fontSize=='12px' || e.style.fontSize=='10px')
		e.style.fontSize='10px';
	else
		e.style.fontSize='12px';
}
function ShowMailForm(url)
{
	var de=document.getElementById('arnyek');
	var fr=document.getElementById('op_form');
	de.style.display="block";
	getTop = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
    var ttop =(getTop-200);
    
	fr.style.top=ttop+"px";
	var parent=document.getElementById('lablec_szoveg');
    hh=findPosY(parent);
	hh=1.0*hh+1.0*100;
	de.style.height=hh+"px";
	document.getElementById('op_form').style.display='block';
    document.getElementById('i_link').value= url;
    document.getElementById('i_cont').value= 'Érdekes hír a Bagaméry-Szalay Ügyvédi Iroda honlapján';
}

function SHdiv(obj_id)
{
    var obj=document.getElementById(obj_id);
    if (obj.style.display=='none')
        obj.style.display='block';
    else
        obj.style.display='none';
}
