var winonload_65325 = window.onload;
window.onload = function(){
  if (winonload_65325) winonload_65325();
  ysgfx(false);
};

//setTimeout("ysgfx();",2000);

var to_65325 = null;
var winonresize_65325 = window.onresize;
window.onresize = function(){
  if (winonresize_65325) winonresize_65325();
  if (to_65325) clearTimeout(to_65325);
  to_65325=setTimeout("ysgfx(true)",200);
};



function ysgfx(resizevolt) {
  ysgfx_recu(document,resizevolt);
};




function ygetstyle_bgimage(elem) {
  var res = "";

  if (elem && elem.tagName) {

    if (window.getComputedStyle
    /*&& document.defaultView && document.defaultView.getComputedStyle*/) {
      var cs;
      //cs=document.defaultView.getComputedStyle(elem,null);
      cs=window.getComputedStyle(elem,null);
      res=cs.getPropertyValue("background-image");
      ////res=cs.backgroundImage;

    } else if (elem.currentStyle) {
      res=elem.currentStyle.backgroundImage;

    } else if (elem.style) {
      res=elem.style.backgroundImage;
    };
  };

  return res;
};



function ysgfx_recu(elem,resizevolt ) {
  var c = elem.childNodes.length;
  for (var n=0; n<c; ++n) {
    ysgfx_recu(elem.childNodes[n],resizevolt);
  };

  var rfw,rfh,kbc;
  var swmost,shmost;
  var s,se,su;
  var p,p2;

  s=ygetstyle_bgimage(elem);

  if (s && s!="") {
    se=s;
    //s=s.toLowerCase();
    if (s.indexOf("/gfx/")>=0) {
      rfw=false; rfh=false; kbc=false;
      swmost=""; shmost="";

      if (s.indexOf("rfw-1")>=0 || s.indexOf("rfw=-1")>=0) {
        if (!resizevolt) rfw=true;
      } else if (s.indexOf("rfw")>=0 /*&& s.indexOf("rfw0")<0*/) {
        rfw=true;
      };
      if (s.indexOf("rfh-1")>=0 || s.indexOf("rfh=-1")>=0) {
        if (!resizevolt) rfh=true;
      } else if (s.indexOf("rfh")>=0 /*&&s.indexOf("rfh0")<0*/   ) {
       rfh=true;
      };

      if (rfw) swmost=(""+elem.offsetWidth);
      if (rfh) shmost=(""+elem.offsetHeight);

      if (swmost) {
        p=s.indexOf("w=");
        if (p>=0) {
          p+=2;
          p2=s.indexOf(",",p);
          if (p2>=p) {
            su=s.substr(0,p)+swmost+s.substr(p2);
            s=su;
          };
        };
      };
      if (shmost) {
        p=s.indexOf("h=");
        if (p>=0) {
          p+=2;
          p2=s.indexOf(",",p);
          if (p2>=p) {
            su=s.substr(0,p)+shmost+s.substr(p2);
            s=su;
          };
        };
      };
      if (s!=se) {
//alert("volt: "+se+" -> uj: "+s);
        elem.style.backgroundImage=su;
        if (!kbc) elem.style.backgroundColor="transparent";
      };
    };
  };
};


