var yui_abuse_panel;

function abuse_panel_init()
{
	yui_abuse_panel = new YAHOO.widget.Panel("myAbusePanel", { width:"450px", fixedcenter:true, visible:false, constraintoviewport:true, underlay:"none", modal:false} );
	yui_abuse_panel.render();
}
Event.on(window, "load", abuse_panel_init);

function showAbusePanel(sect_id, user_from_id, user_to_id, object_id, redirect_url)
{
    if (redirect_url){
        location.href = redirect_url;
        return false;
    }
    var ncallback = {
        success: function(o) {
            resp = o.responseText.split('|');
            getElement('vs_abuse_header').innerHTML     = resp[0];
            getElement('vs_abuse_body').innerHTML       = resp[1];
            getElement('vs_abuse_footer').innerHTML     = resp[2];
            abusepanel_show_tip();
        },
        failure:function(o){
            reportError('{/literal}{strings var=errorNoConnection}{literal}');
        }
    };
    var url = '/abusepanel.php?&t='+Math.random()+'&mode=show&ab_sect_id='+sect_id+'&ab_user_from_id='+user_from_id+'&ab_user_to_id='+user_to_id+'&ab_object_id='+object_id;
    Connect.asyncRequest('GET', url, ncallback);
}

function reportAbuse()
{
    var object_id   = getElement('ab_object_id').value.trim();
    var section_id  = getElement('ab_sect_id').value.trim();
    var ncallback = {
        success: function(o){
            hideLoading();
            resp = o.responseText.split('|');
            getElement('vs_abuse_header').innerHTML = resp[0];
            getElement('vs_abuse_body').innerHTML   = resp[1];
            getElement('vs_abuse_footer').innerHTML = resp[2];
            Dom.setStyle('flag_' + object_id + '_' + section_id, 'display', 'none');
        },
        failure: function(o){
            hideLoading();
            reportError('{/literal}{strings var=errorNoConnection}{literal}');
        }
    };

    Connect.setForm('abusepanelform');
    showLoading();
    Connect.asyncRequest('POST', '/abusepanel.php?&t='+Math.random()+'&mode=rprt', ncallback);
}

function abusepanel_show_tip()
{
    Dom.setStyle('myAbusePanel', 'display', 'block');
    yui_abuse_panel.show();
}

function abusepanel_hide_tip()
{
    yui_abuse_panel.hide();
    Dom.setStyle('myAbusePanel', 'display', 'none');
}