
        var same =  Math.floor(Math.random()*1000000);


        var box_height = 230;
    var cl_line_bg = '#EEEEEE';
    var cl_line_active = '#BCCED9';
    var cl_line_selected = '#FFFFFF';
    var cl_box_active = '#F37121';

    var active='';
    
    var base_left = '';
    var base_right = '';
    var sel_left = '';
    var sel_right = '';
    var sel_center = '';

    var abcleftfull=Array();
    var abcrightfull=Array();
    var abccenterfull=Array();
    var box_full=Array();

    var state = false;



function init()
{
    if ( base_left != 'L' ) {
        moveto('left',base_left);
        SetBG(base_left,cl_line_active);
    }

    if ( base_right != 'R' ) {
        moveto('right',base_right);
        SetBG(base_right,cl_line_active);
    }




  if (extended_java2) {
    if (document.getElementsByTagName) {
        rows = document.getElementsByTagName('tr');
    } else {
        if (document.all) {
            rows = document.all.tags('tr');
        }
    }

    for(var i = 0; i < rows.length; i++) {
        if (rows[i].id != '') {
            rows[i].onmouseover = sel;
            rows[i].ondblclick  = defclick;
        }
    }

    if (active == '') setactive('left');
  }


}



function findelement(id)
{
    return document.all ? document.all(id) : document.getElementById ? document.getElementById(id) : null;

}



function SetBG(id, color)
{
    var what = findelement(id);
    if (what.style) {
        what.style.background = color;
    }

}



function sel(x, y)
{
    if (y != 'move') {
        x = this;
    }

    chr = x.id.charAt(0);

    if (chr == 'L') {
        if ((sel_left != base_left) && (sel_left != '')) SetBG(sel_left, cl_line_bg);
        sel_left = x.id;
    }

    if (chr == 'R') {
        if ((sel_right != base_right) && (sel_right != '')) SetBG(sel_right, cl_line_bg);
        sel_right = x.id;
    }

    if (chr == 'C') {
        if (sel_center != '') SetBG(sel_center, cl_line_bg);
        sel_center = x.id;
    }

    if ((x.id == base_left) || (x.id == base_right)) return;

    SetBG(x.id, cl_line_selected);

}


function sel_line(x)
{
    x = this.id;
    SetBG(x, cl_line_selected);
}



function desel_line(x)
{
    x = this.id;
    SetBG(x, cl_line_bg);
}



function defclick()
{
    var a = findelement('a'+this.id);
    if (a != null) {
        window.location = a.href;
    } else {
        var ap = findelement('ap'+this.id);
        if (ap != null) {
            ap.onclick();
                    }
    }



 

}



function setactive(x)
{
    if (!extended_java) return;

    var what = findelement(x);

    if (active != '') {
        active.style.borderColor = "#000000";
        active.style.borderWidth = 1;
    };

    if (what) {
        active = what;
        what.style.borderColor = cl_box_active;
        what.style.borderWidth = 2;
    }

}



function setfullsize(x, y, height)
{
    var what = findelement(x);

    if (what.style.height != 'auto') {
                if ((x == 'left')  && (abcleftfull.length  > 0)) moveto('left', abcleftfull[0][1]);
        if ((x == 'right') && (abcrightfull.length > 0)) moveto('right', abcrightfull[0][1]);
        what.style.height = 'auto';
        y.innerHTML = '<img src="img/d/i_box_small.gif">';
    } else {
        what.style.height = height;
        y.innerHTML = '<img src="img/d/i_box_full.gif">';
    }

    return false;

}



function setfullsize_box(x)
{
    var what = findelement(x);
    var txt  = findelement(x+"t");
    var img  = findelement(x+"i");

    if (what.style.height=='auto') {
        what.style.height = 51;
        txt.innerHTML = 'Az összes ár listázása';
        img.innerHTML = '<img src="img/d/i_box_full.gif">';
    } else {
        moveto(x, x+'start');
        what.style.height = 'auto';
        img.innerHTML = '<img src="img/d/i_box_small.gif">';
        txt.innerHTML = 'Csak a legjobb 3 ár mutatása';
    }

    return false;

}



function setfullsize_all(todo)
{

    for (i = 0; i < box_list.length; i++) {
        var x = box_list[i];
        var what = findelement(x);
        var txt  = findelement(x+"t");
        var img  = findelement(x+"i");

        if (todo == 'open') {
            moveto(x, x+'start');
            what.style.height = 'auto';
            img.innerHTML = '<img src="img/d/i_box_small.gif">';
            txt.innerHTML = 'Csak a legjobb 3 ár mutatása';
        }

        if (todo == 'close') {
            what.style.height = 51;
            txt.innerHTML = 'Az összes ár listázása';
            img.innerHTML = '<img src="img/d/i_box_full.gif">';
        }
    }

    return false;

}



function moveto(cont_id, el_id)
{
    var cont = findelement(cont_id);
    var el = findelement(el_id);

    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;
    }

        sel(el,'move');


        if (active == '') cont.scrollTop = el.offsetTop;
    else {
        if ((active.style.height != 'auto') && (active.id != 'center')) {
            cont.scrollTop = el.offsetTop;
        } else {
            scroll(0, findPosY(cont)+el.offsetTop+2);
        }
    }

}



function whichKey(e)
{
    if (active!='') {
        if (typeof e=='undefined') key=event.keyCode; else key=e.which;

    if ( (key>=65 && key<=90) )
  {
   var x=0;
   var found=false;

   if (active.id=='left')
   {

      if (sel_left!='')
      for (i=0; i<abcleftfull.length; i++)
       if (abcleftfull[i][1]==sel_left) {x=i; break;}

      for (i=x; i<abcleftfull.length; i++)
       if (abcleftfull[i][0]==String.fromCharCode(key))
       {
        if (abcleftfull[i][1]!=sel_left)
        { moveto('left',abcleftfull[i][1]); found=true; break; }
       }

      if ( (x!=0) && (found==false) )
      {
        for (i=0; i<abcleftfull.length; i++)
       if (abcleftfull[i][0]==String.fromCharCode(key))
       {
        if (abcleftfull[i][1]!=sel_left)
        { moveto('left',abcleftfull[i][1]); break; }
       }
      }
     }

     if (active.id=='right')
   {
      if (sel_right!='')
      for (i=0; i<abcrightfull.length; i++)
       if (abcrightfull[i][1]==sel_right) {x=i; break;}

      for (i=x; i<abcrightfull.length; i++)
       if (abcrightfull[i][0]==String.fromCharCode(key))
       {
        if (abcrightfull[i][1]!=sel_right)
        { moveto('right',abcrightfull[i][1]); found=true; break; }
       }

      if ( (x!=0) && (found==false) )
      {
        for (i=0; i<abcrightfull.length; i++)
       if (abcrightfull[i][0]==String.fromCharCode(key))
       {
        if (abcrightfull[i][1]!=sel_right)
        { moveto('right',abcrightfull[i][1]); break; }
       }
      }
     }

     if (active.id=='center')
   {
      if (sel_center!='')
      for (i=0; i<abccenterfull.length; i++)
       if (abccenterfull[i][1]==sel_center) {x=i; break;}

      for (i=x; i<abccenterfull.length; i++)
       if (abccenterfull[i][0]==String.fromCharCode(key))
       {
        if (abccenterfull[i][1]!=sel_center)
        { moveto('center',abccenterfull[i][1]); found=true; break; }
       }

      if ( (x!=0) && (found==false) )
      {
         for (i=0; i<abccenterfull.length; i++)
       if (abccenterfull[i][0]==String.fromCharCode(key))
       {
        if (abccenterfull[i][1]!=sel_center)
        { moveto('center',abccenterfull[i][1]); break; }
       }
      }
     }
  }


    if (key==16 || key==17)
  {
   if (active.id=='left')
   {
    if (sel_left=='') moveto('left',abcleftfull[0][1]);
    else
    {
     for (i=0; i<abcleftfull.length; i++)
       if (abcleftfull[i][1]==sel_left) {x=i; break;}

       if (key==16)
       {
        if (x==0) moveto('left',abcleftfull[abcleftfull.length-1][1]);
        else
         moveto('left',abcleftfull[x-1][1]);
       }

       if (key==17)
       {
        if (x==(abcleftfull.length-1) ) moveto('left',abcleftfull[0][1]);
        else
         moveto('left',abcleftfull[x+1][1]);
     }
    }
   }

   if (active.id=='right')
   {
    if (sel_right=='') moveto('right',abcrightfull[0][1]);
    else
    {
     for (i=0; i<abcrightfull.length; i++)
       if (abcrightfull[i][1]==sel_right) {x=i; break;}

       if (key==16)
       {
        if (x==0) moveto('right',abcrightfull[abcrightfull.length-1][1]);
        else
         moveto('right',abcrightfull[x-1][1]);
       }

       if (key==17)
       {
        if (x==(abcrightfull.length-1) ) moveto('right',abcrightfull[0][1]);
        else
         moveto('right',abcrightfull[x+1][1]);
     }
    }
   }

   if (active.id=='center')
   {
    if (sel_center=='') moveto('center',abccenterfull[0][1]);
    else
    {
     for (i=0; i<abccenterfull.length; i++)
       if (abccenterfull[i][1]==sel_center) {x=i; break;}

       if (key==16)
       {
        if (x==0) moveto('center',abccenterfull[abccenterfull.length-1][1]);
        else
         moveto('center',abccenterfull[x-1][1]);
       }

       if (key==17)
       {
        if (x==(abccenterfull.length-1) ) moveto('center',abccenterfull[0][1]);
        else
         moveto('center',abccenterfull[x+1][1]);
     }
    }
   }

  }

    if (key==13)
  {
      if (active.id == 'left') {
    x = 'a'+sel_left;
    y = 'ap'+sel_left;
   }

   if (active.id == 'right') {
    x = 'a'+sel_right;
    y = 'ap'+sel_right;
   }

   if (active.id == 'center') {
    x = 'a'+sel_center;
    y = 'ap'+sel_center;
   }

   var what = findelement(x);
   if (what != null) {
    window.location = what.href;
   } else {
    var what = findelement(y);
    if (what != null) what.onclick();
   }
  }
 }
}



function ipcspopup(url)
{
    window.name = 'ipcs_hu_main';

    width  = 520;
    height = 610;

    Agent= navigator.userAgent.toLowerCase();
    isOpera = (Agent.indexOf("opera") != -1);

        centerx = (screen.width-width)/2;
    if (isOpera) centery=(screen.height-height)/4;
    else centery=(screen.height-height)/2;

    store = window.open(url,'ipcs_hu_popup',"toolbar=no,height="+height+",width="+width+",scrollbars=yes,resizable=yes,left="+centerx+",top="+centery+"");
    if (store.focus) {store.focus()};

    return false;
}



function talkback(url)
{
    w = window.open(url, 'ipcs_hu_main');
    if (w.focus) {w.focus()};

    return false;
}



function decode_email(email_encode_chars)
{
    if (document.getElementsByTagName)
        hrefs = document.getElementsByTagName('a');
    else if (document.all)
        hrefs = document.all.tags('a');

    var replaces=0;
    for (var i=0; i<hrefs.length; i++) {
        if (hrefs[i].href.indexOf('mailto:')!=-1) {
            for (j=0; j<email_encode_chars.length; j++) {
                replaces=0;
                while (hrefs[i].innerHTML.indexOf(email_encode_chars[j][1])!=-1 && replaces<10) {
                    hrefs[i].innerHTML=hrefs[i].innerHTML.replace(email_encode_chars[j][1],email_encode_chars[j][0]);
                    replaces++;
                }
            }
            hrefs[i].href='mailto:'+hrefs[i].innerHTML;
        }
    }
}



function hideloading()
{
    var x=findelement('loading');
    if (x != null) {
        x.style.visibility='hidden';
    }

}



function printarticle(di)
{

    di.style.visibility = 'hidden';

    if (window.print) {
        setTimeout('window.print();', 50);
    } else {
        alert("Nyomja meg a 'Ctrl+p' gombokat a cikk nyomtatásához!");
    }

    return false;

}



function URLEncode(plaintext)
{
	var SAFECHARS = "0123456789" +
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";

	var HEX = "0123456789ABCDEF";

	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {

		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
				switch(charCode) {
                    case 337: encoded += "%F5"; break;
                    case 336: encoded += "%D5"; break;
                    case 369: encoded += "%FB"; break;
                    case 368: encoded += "%DB"; break;
				    default: encoded += "+"; break;
				}
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	}

	return encoded;
}



