


        function findPos(obj) {
                var curleft = curtop = 0;
                if (obj.offsetParent) {
                        curleft = obj.offsetLeft
                        curtop = obj.offsetTop
                        while (obj = obj.offsetParent) {
                                curleft += obj.offsetLeft
                                curtop += obj.offsetTop
                        }
                }
                return [curleft,curtop];
        }

     function report_abuse(cid, java_title) {
      report_abuse_window = null;
        var anchor = document.getElementById('msg');
        var pos    = findPos(anchor);
                var table_contents  = '';
                table_contents += '<form method="get" action="/cgi-bin/MarketPlace/report_abuse.cgi" onSubmit="Submitabuse(this); return false;">';
                table_contents += '<input type=hidden name="cid" value="'+cid+'">';
                table_contents += '<table cellpadding="3" cellspacing="0" width=100%>';
                table_contents += '<tr class="section-content-header"><td colspan="2">Report Abuse</td></tr>';
                table_contents += '<tr >';
                table_contents += '<th align="right">Listing Title:</th>';
                table_contents += '<td>'+java_title+'</td>';
                table_contents += '</tr>';
                table_contents += '<tr >';
                table_contents += '<th align="right" valign=top>Flag:</th>';
                table_contents += '<td><label><input type=radio name="flag" value="1"> Not Local</label><br />';
                    table_contents += '<label><input type=radio name="flag" value="2"> Miscategorized</label><br />';
                    table_contents += '<label><input type=radio name="flag" value="3"> Inappropriate</label><br />';
                    table_contents += '<label><input type=radio name="flag" value="4"> Spam</label></td /></tr>';
                    table_contents += '<tr><th colspan="2"><input type="submit" value="Submit" /></td></tr>';
                table_contents += '</table>';
                table_contents += '</form>';



                report_abuse_window = new DialogBox('report_abuse_window');
                report_abuse_window.setSize(400,300);
                report_abuse_window.setContents(table_contents);
                report_abuse_window.moveTo(pos[0]-200,pos[1]+1,1);
                      //report_abuse_window.moveTo(parseInt(screen.width/2),parseInt(screen.height/2));

                report_abuse_window.show();

     }

function Submitabuse(thisForm) {
                        var cid = thisForm.cid.value;
                        var flag = '';

                     for (var i=0; i < thisForm.flag.length; i++)
                        {
                        if (thisForm.flag[i].checked)
                           {
                           flag = thisForm.flag[i].value;
                           }
                        }

                       if (flag != "") {
                                var query_string = 'cid=' + cid + '&flag=' + flag;
                                sndReqabuse(query_string);
                        }

                        return false;
                }

                function createRequestObject() {
                        var ro;
                        var browser = navigator.appName;
                        if(browser == "Microsoft Internet Explorer"){
                                ro = new ActiveXObject("Microsoft.XMLHTTP");
                        }else{
                                ro = new XMLHttpRequest();
                        }
                        return ro;
                }

                var http = createRequestObject();

                function sndReqabuse(action) {
                        if (action != '') {
                                http.open('get', '/cgi-bin/MarketPlace/report_abuse.cgi?cachebuster=' + new Date().getTime() + '&' + action);
                                http.onreadystatechange = handleResponseabuse;
                                http.send(null);
                        }
                }

                function handleResponseabuse() {
                        if(http.readyState == 4){
                                var response = http.responseText;
                                var update = new Array();

                                if(response.indexOf('|' != -1)) {
                                        update = response.split('|');

                                        if (update[0] != "") {
                                        var text = update[0];
                                        document.getElementById('msg').innerHTML = 'Thank you, your "'+text+'" abuse report has been received';
                                        }
                                        else {
                                        document.getElementById('msg').innerHTML = 'Thank you, your abuse report has been received';
                                        }
                                        report_abuse_window.hide();
                                }
                        }
                }
