
var WF_TABS     = new Array  ('webTab'                                   , 'textTab'                         , 'dictTab'                     );
var WF_PICT_HU  = new Array  ('weblapfordito'                            , 'szovegfordito'                   , 'szotar'                      );
var WF_PICT_EN  = new Array  ('translate_web'                            , 'translate_text'                  , 'dictionary'                  );
var WF_PICT_MHU  = new Array ('weblap'                                   , 'szoveg'                          , 'szo'                         );
var WF_PICT_MEN  = new Array ('webpage'                                  , 'text'                            , 'word'                        );

var WF_BASEIMAGE  = 'http://www.webforditas.hu/boxes/images/';
var WF_ALTSTYLE   = 0;
var WF_BASESTYLE  = '';
var WF_BASEIFRAME = 'http://www.webforditas.hu/boxes/iframe.php?';

var wf_box_active = 1;

function SetLabelSource(lang, frame, form, box_id, type)
{
  var pict;
  if (WF_ALTSTYLE == 1)
  {
    if (lang == 'hu') pict = WF_PICT_MHU[box_id];
    else              pict = WF_PICT_MEN[box_id];
  }
  else
  {
    if (lang == 'hu') pict = WF_PICT_HU[box_id];
    else              pict = WF_PICT_EN[box_id];
  }  

  var html;
  if (type == 'active')
  {
    html  = "<img src=\""+WF_BASEIMAGE+pict+"_active.gif\" border=\"0\">";
  }
  else
  {
    html  = "<a class=\"wfanchor\" onclick=\"SetWFBoxTab('"+lang+"','"+frame+"','"+form+"',"+box_id+");\">";
    html += "<img src=\""+WF_BASEIMAGE+pict+"_"+type+".gif\" border=\"0\" ";
    html += 'onmouseover="this.src=\''+WF_BASEIMAGE+pict+'_inactive_hover.gif\'" ';
    html += 'onmouseout ="this.src=\''+WF_BASEIMAGE+pict+'_inactive.gif\'"       ';
    html += "></a>";
  }
  document.getElementById(WF_TABS[box_id]+'Label').innerHTML = html;
}

function SetFrameSource(lang, frame, form, box_to)
{
  var newsrc = ""+WF_BASEIFRAME+"lang="+lang+"&form="+form+"&target="+WF_TABS[box_to];
  if (WF_BASESTYLE != '') newsrc += "&css="+WF_BASESTYLE;
  var frm    = document.getElementById(frame);
  if (frm && (frm.src != newsrc)) frm.src = newsrc;
}

function OnWFBoxLoaded(lang, frame, form, altstyle, skindir)
{
  if (!document.getElementById) return;
  
  if (typeof altstyle != 'undefined')  WF_ALTSTYLE  = altstyle;
  if (typeof skindir != 'undefined') { WF_BASEIMAGE = 'http://' + skindir; WF_BASESTYLE = skindir + 'style.css'; }
  
  SetLabelSource(lang, frame, form, 0, 'inactive');
  SetLabelSource(lang, frame, form, 1, 'inactive');
  SetLabelSource(lang, frame, form, 2, 'inactive');
  
  SetLabelSource(lang, frame, form, wf_box_active, 'active');
  SetFrameSource(lang, frame, form, wf_box_active);
}

function SetWFBoxTab(lang, frame, form, box_to)
{
  if (wf_box_active >= 0) SetLabelSource(lang, frame, form, wf_box_active, 'inactive');
  SetLabelSource(lang, frame, form, box_to, 'active');
  SetFrameSource(lang, frame, form, box_to)
  wf_box_active = box_to;
}


