function init_portal() {
}

function sure(txt,cmd) {
  if (confirm(txt)) {
    window.location=cmd;
  }
}

function popup(url,title,w,h) {
  popupwin=window.open(url,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h);
  popupwin.focus();
}

function popup_normal(url,title,w,h) {
  popupwin=window.open(url,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+w+",height="+h);
  popupwin.focus();
}

function v_popup(url,title,w,h) {
  x=screen.availWidth /2-w/2;
  y=screen.availHeight/2-h/2;
  popupwin=window.open(url,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width="+w+",height="+h+",left="+x+",top="+y);
  popupwin.focus();
}

function v_popup_normal(url,title,w,h) {
  x=screen.availWidth /2-w/2;
  y=screen.availHeight/2-h/2;
  popupwin=window.open(url,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=no,resizable=0,width="+w+",height="+h+",left="+x+",top="+y);
  popupwin.focus();
}

function div_toggle(divname,tablename,h) {
  var ie=document.all;

  if (ie) {
    cmd="obj_div=document.all."+divname;  eval(cmd);
    cmd="obj_tbl=document.all."+tablename;  eval(cmd);
  }
  else {
    cmd="obj_div=document.getElementById('"+divname+"')";  eval(cmd);
    cmd="obj_tbl=document.getElementById('"+tablename+"')";  eval(cmd);
  }

  if (obj_div.style.visibility=="hidden") {
    obj_div.style.visibility="visible";
    obj_tbl.style.height=h;
  }
  else {
    obj_div.style.visibility="hidden";
    obj_tbl.style.height=0;
  }
}

function replaceString(oldS,newS,fullS) {
   for (var i=0; i<fullS.length; i++) {
      if (fullS.substring(i,i+oldS.length) == oldS) {
         fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)
      }
   }
   return fullS
}

function crsr_on(obj,c) {
  obj.oldcolor=obj.style.backgroundColor;
  obj.style.backgroundColor=c;
}
function crsr_off(obj) {
    obj.style.backgroundColor=obj.oldcolor;
}


function obj_select(id,s_var_name,c) {
  var ie=document.all;

  eval("s_var="+s_var_name);
 
  if (ie) { cmd="obj=document.all."+id+";";  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+"');";  eval(cmd); }

  if (s_var>"") {
    if (ie) { cmd="obj_old=document.all."+s_var+";"; eval(cmd); }
    else { cmd="obj_old=document.getElementById('"+s_var+"');";  eval(cmd); }

    obj_old.style.backgroundColor="";
    s_var="";
  }
  obj.style.backgroundColor=c;
  eval(s_var_name+"=id");
}


// id: az objektum id-je
// var_selected: ebben tárolja a kiválsztott objektum id-jét (pl document.selected)
// c: crsr színe

function crsr_on_id(id,var_selected,c) {
  var ie=document.all;
  if (ie) { cmd="obj=document.all."+id;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+"')";  eval(cmd); }

  if (var_selected=="") {
    obj.oldcolor=obj.style.backgroundColor;
    obj.style.backgroundColor=c;
  }
  else {
    eval("var_selected0="+var_selected);
    if (var_selected0!=id) {
      obj.oldcolor=obj.style.backgroundColor;
      obj.style.backgroundColor=c;
    }
  }
}
function crsr_off_id(id,var_selected) {
  var ie=document.all;
  if (ie) { cmd="obj=document.all."+id;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+"')";  eval(cmd); }

  if (var_selected=="") {
    obj.style.backgroundColor=obj.oldcolor;
  }
  else {
    eval("var_selected0="+var_selected);
    if (var_selected0!=id) {
      obj.style.backgroundColor=obj.oldcolor;
    }
  }
}



// name: ezt az objektumot kell kiválasztani (id)
// var_selected: ebben tárolja a kiválsztott objektum id-jét (pl document.selected)
function select2var(id,var_selected) {
  var ie=document.all;

  eval("var_selected0="+var_selected);

  if (ie) { cmd="obj_selected=document.all."+name+"_i"+var_selected0;  eval(cmd); }
  else { cmd="obj_selected=document.getElementById('"+name+"_i"+var_selected0+"')";  eval(cmd); }

  if (ie) { cmd="obj=document.all."+name+"_i"+id;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+name+"_i"+id+"')";  eval(cmd); }

  if (ie) { cmd="obj_crsr=document.all."+name+""+id;  eval(cmd); }
  else { cmd="obj_crsr=document.getElementById('"+name+""+id+"')";  eval(cmd); }

  if (var_selected0==0) {
    obj_crsr.style.backgroundColor=obj_crsr.oldcolor;
    obj.style.backgroundColor="#dd99ff";
    eval(var_selected+"=id");
  }
  else if (var_selected0==id) {
    eval(var_selected+"=0");
    obj.style.backgroundColor="";
  }
  else {
    obj_crsr.style.backgroundColor=obj_crsr.oldcolor;
    obj_selected.style.backgroundColor="";
    obj.style.backgroundColor="#dd99ff";
    eval(var_selected+"=id");
  }
}


function goto_page(url_g) {
//alert(window.location+" és "+url_g);
  window.location=url_g;
//  window.location.reload();
}


function listobj(obj) {
  w=window.open("","","");
  w.document.writeln("<table>");
  for (i in obj) {
    cmd="val=obj."+i; eval(cmd);
    w.document.writeln("<tr><td>");
    w.document.writeln(i);
    w.document.writeln("</td><td>");
    w.document.writeln(val);
    w.document.writeln("</td></tr>");
  }
  w.document.writeln("</table>");
  w.focus();
}






function c_select(id,s_var_value,s_var_name,c) {
  var ie=document.all;

  eval("s_var="+s_var_name);

// if set -> unset color
  if (s_var>"") {
    if (ie) { cmd="obj_old=document.all."+id+""+s_var+";"; eval(cmd); }
    else { cmd="obj_old=document.getElementById('"+id+""+s_var+"');";  eval(cmd); }
    obj_old.style.backgroundColor="";
    s_var="";
  }

// set color
  if (ie) { cmd="obj=document.all."+id+""+s_var_value;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+""+s_var_value+"')";  eval(cmd); }
  obj.style.backgroundColor=c;

// set var
  cmd=s_var_name+"="+s_var_value;
  eval(cmd);
}

function c_crsr_on(id,var_value,s_var_name,c) {
  cmd="val_selected="+s_var_name; eval(cmd);

  var ie=document.all;
  if (ie) { cmd="obj=document.all."+id+""+var_value;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+""+var_value+"')";  eval(cmd); }

  if (val_selected!=var_value) {
    obj.oldcolor=obj.style.backgroundColor;
    obj.style.backgroundColor=c;
  }
}

function c_crsr_off(id,var_value,s_var_name) {
  cmd="val_selected="+s_var_name; eval(cmd);
  var ie=document.all;

  if (ie) { cmd="obj=document.all."+id+""+var_value;  eval(cmd); }
  else { cmd="obj=document.getElementById('"+id+""+var_value+"')";  eval(cmd); }

  if (val_selected!=var_value) {
    obj.style.backgroundColor=obj.oldcolor;
  }
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

function popup(img,title,w,h) {
  popupwin=window.open("img_view.php?img="+img+"&w="+w+"&h="+h,title,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,width="+w+",height="+h);
  popupwin.focus();
}

