function gi(chid,els)
{
    //alert("bu");

    this.inf=null;
    this.elem=els;
    this.radio_id=chid;
    this.params="radio_id="+chid;
    this.wnd=null;
    this.sy=false;

    this.onFailure=function(xhr,opt)
    {
        alert("Ошибка загрузки данных!");
    }
    this.onLoading=function()
    {
        var t=this;
        var sw=($(window).width())/2;
        if(sw<600) sw=600;
        var sh=($(window).height())/2;
        if(sh<350) sh=350;
        var x=t.getX(t.elem);
        var y=t.getY(t.elem);
        //alert(y);

      if(t.wnd==null)
      {
        //var elw=$(t.elem).width();
        t.wnd=document.createElement("div");
        $(t.wnd).addClass("popup");
        var id=x.toString()+y.toString()+(Math.round(Math.random()*100)).toString();
        t.inf="c"+id;
        $(t.wnd).attr("id", id);
        var cl="popup_arrow_left";
        //alert($(document).scrollTop());
        if(y-$(document).scrollTop()<sh)
        {
            if(x>sw) {cl="popup_arrow_right";x=x-200}
            else x=x+160;
        }
        else
        {
            t.sy=y-100;
            if(x>sw) {
                cl="popup_arrow_bott_right";x=x-200
            }
            else {
                cl="popup_arrow_bott_left";x=x+160
            }
        }
        
        var content="<div class=\"popup_top_left\"></div><div class=\"popup_top\"></div><div class=\"popup_top_right\"></div><div class=\"popup_left\"></div>";
        content+="<div class=\"popup_right\"></div><div class=\"popup_bott_left\"></div><div class=\"popup_bott\"></div><div class=\"popup_bott_right\"></div>";
        content+="<div class=\""+cl+"\"></div>";
        content+="<div class=\"close_button\"><a style=\"cursor:pointer;\" onclick=\"wclose("+id+")\"><img src=\"/tmc_share/tmc_files/images/popup_close.gif\" width=\"14\" height=\"14\" align=\"right\" /></a></div>";
        content+="<div class=\"text\" id=\"c"+id+"\" style=\"background-color:#fff;width:200px;\">";
        content+="<p><img style=\"padding-left:20px;\" src=\"/tmc_share/tmc_files/progress.gif\" /></p>";
        content+="</div>";
        
        t.wnd.innerHTML=content;

        $(t.wnd).css({top:y,left:x});

        document.body.appendChild(t.wnd);

      }
    }
    this.onSuccess=function(xhr,opt)
    {
        var t=this;

        document.getElementById(t.inf).innerHTML=xhr;
        if(t.sy>0)
        {
            var y=t.sy-($(t.wnd).height()-135);
            $(t.wnd).css('top', y);
        }
    }
    this.load=function()
    {
        var t=this;
        t.onLoading();
        $.get("/min/radioinfo.php", t.params, function(data,textStatis){t.onSuccess(data,textStatis);}, "html");

    }
    this.close=function()
    {
        if($(t.wnd).display!="none")
        {
            $(t.wnd).hide();
        }
    }
 this.getX=function(obj)
{
    var left = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          left += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    }
    else if(obj.x)
    {
        left += obj.x;
    }
    return left;
}



this.getY=function(obj)
{
    var top = 0;
    if(obj.offsetParent)
    {
        while(1)
        {
          top += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    }
    else if(obj.y)
    {
        top += obj.y;
    }
    return top;
  }
}
function wclose(id)
{
    $("#"+id).hide();
}
