function selectcode(thingid)
{
    var theobject = document.getElementById(thingid);
    if(theobject==null)
    {alert('test');}
    selectNode(theobject);
}



function selectNode (node) {
   var selection, range, doc, win;
   if ((doc = node.ownerDocument) && (win = doc.defaultView) && typeof win.getSelection != 'undefined' && typeof doc.createRange != 'undefined' && (selection = window.getSelection()) && typeof selection.removeAllRanges != 'undefined') {
     range = doc.createRange();
     range.selectNode(node);
     selection.removeAllRanges();
     selection.addRange(range);
   }  else if (document.body && typeof document.body.createTextRange != 'undefined' && (range = document.body.createTextRange())) {
     range.moveToElementText(node);
     range.select();
   }

}



function makevotestring(thissiteID, thisrating, thisvotes, thisdailyrating, thisdailyvotes, thisweeklyrating, thisweeklyvotes, thismonthlyrating, thismonthlyvotes, thisyearlyrating, thisyearlyvotes, thissite_name)
{
    var point_dexclama = '<img src="graphix/point_dexclama.gif" alt="!" />';
    


        var graph = shoratt(thisdailyrating,thisdailyvotes,thisweeklyrating,thisweeklyvotes,thismonthlyrating,thismonthlyvotes,thisyearlyrating,thisyearlyvotes,thisrating,thisvotes);
        var shovotesstring = graph + "<center><a onclick='vote(" + thissiteID + ", " + '"' + thissite_name + '"' + ")' style='cursor:pointer;' id='vote_link_" + thissiteID + "'>vote " + point_dexclama + "</a></center>";



    return shovotesstring;
}
function updatevotestring(thissiteID, thisrating, thisvotes, thisdailyrating, thisdailyvotes, thisweeklyrating, thisweeklyvotes, thismonthlyrating, thismonthlyvotes, thisyearlyrating, thisyearlyvotes, thissite_name)
{
    var votedivid = 'votediv_' + thissiteID;
    document.getElementById(votedivid).innerHTML = makevotestring(thissiteID, thisrating, thisvotes, thisdailyrating, thisdailyvotes, thisweeklyrating, thisweeklyvotes, thismonthlyrating, thismonthlyvotes, thisyearlyrating, thisyearlyvotes, thissite_name);
}
function makevisittring(thissiteID, thissite_URL, thisclicks, thiscreation_time, thislast_visitor_time)
{
    if(thisclicks==1)
    {
        var clicksS = '';
    }
    else
    {
        var clicksS = 's';
    }
    if(thisclicks >= 1)
    {
        var lastvisitorinfo = ' last visitor <span id="lstvisitorspan_' + thissiteID + '">' + maketimus(thislast_visitor_time) + '</span>';
    }
    else
    {
        var lastvisitorinfo = '';
    }
    if(thiscreation_time == 0)
    {
        var thissincestring = '';
    }
    else
    {
        var thissincestring = ' since ' + maketimus(thiscreation_time);
    }
    var clicksinfo = '<span id="clicksspan_' + thissiteID + '">' + thisclicks + '</span> visitor<span id="clicksSspan_' + thissiteID + '">' + clicksS + '</span> sent' + thissincestring + '.' + lastvisitorinfo;
    var visitlink = clicksinfo;
    return visitlink;
}
function inc_clicks(thissiteID)
{
    var urlz = "xmlincclicks?site=" + thissiteID;
    loadXMLDocvisits(urlz);
}


function processReqChangevisits()
{
    if (reqvisits.readyState == 4)
    {
        if (reqvisits.status == 200)
        {
            var response = reqvisits.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var site = response.getElementsByTagName("site")[0].firstChild.data;
            var clicks = response.getElementsByTagName("clicks")[0].firstChild.data;
            var last_visitor_time = response.getElementsByTagName("last_visitor_time")[0].firstChild.data;
            if(result=='ok')
            {
                var clicksspanid = "clicksspan_" + site;
                var clicksSspanid = "clicksSspan_" + site;
                var lstvisitorspanid = "lstvisitorspan_" + site;
                document.getElementById(clicksspanid).innerHTML = clicks;
                if(clicks == 1)
                {
                    document.getElementById(clicksSspanid).innerHTML = '';
                }
                else
                {
                    document.getElementById(clicksSspanid).innerHTML = 's';
                }
                document.getElementById(lstvisitorspanid).innerHTML = maketimus(last_visitor_time);
            }
            else if(result=='error')
            {
                var loginmessage = 'problems reaching database, please try reloading the page';
                alert(loginmessage);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqsp.statusText);
        }
    }
}



function resize_movi_thum(maxwidth, maxheigth, thispicid, test)
{
    if(test == 'shiz')
    {
        var alertmess = 'iget dimens for pic ' + thispicid;
    //alert(alertmess);
    }
    var thepiconmypage = document.getElementById(thispicid);
    var image_source = thepiconmypage.src;
    var oImg = new Image();
    oImg.src = image_source;
    if (oImg.complete)
    {
        var width_of_this_pic_is_what_pr1_of_max = oImg.width / maxwidth;
        var height_of_this_pic_is_what_pr1_of_max = oImg.height / maxheigth;
        if(width_of_this_pic_is_what_pr1_of_max > 1 && width_of_this_pic_is_what_pr1_of_max >= height_of_this_pic_is_what_pr1_of_max)
        {
            var newwidth = Math.floor(oImg.width / width_of_this_pic_is_what_pr1_of_max);
            var newheigth = Math.floor(oImg.height / width_of_this_pic_is_what_pr1_of_max);
            thepiconmypage.style.width = newwidth + "px";
            thepiconmypage.style.height = newheigth + "px";
        }
        else if(height_of_this_pic_is_what_pr1_of_max > 1)
        {
            var newwidth = Math.floor(oImg.width / height_of_this_pic_is_what_pr1_of_max);
            var newheigth = Math.floor(oImg.height / height_of_this_pic_is_what_pr1_of_max);
            thepiconmypage.style.width = newwidth + "px";
            thepiconmypage.style.height = newheigth + "px";
        }
        else
        {
            thepiconmypage.style.width = oImg.width + "px";
            thepiconmypage.style.height = oImg.height + "px";
        }
    }
    else
    {
        var refunction = "resize_movi_thum(" + maxwidth + ", " + maxwidth + ", '" + thispicid + "', 'shiz')";
        var t=setTimeout(refunction,3000);
    }
}


function vote(siteID, thissite_name)
{
    var voteurl = "vote?site=" + siteID + "&site_name=" + escape(thissite_name);
    //var vote_window = window.open(voteurl, "vote", "width=550,height=200,scrollbars=yes,resizable=yes,");
    //vote_window.focus();
    var newdiv_id = 'vote_' + siteID;
    var newdiv_position = 'absolute';
    var newdiv_zIndex = 1000;
    //var newdiv_width = 650;
    var newdiv_height = 350;
    var vote_link_id = "vote_link_" + siteID;
    var vote_link = document.getElementById(vote_link_id);
    var newdiv_left = 100;
    var screen_width = screen.width;
    var newdiv_width = screen_width - 200;
    var ScrollTop = document.body.scrollTop;
    var newdiv_top = ScrollTop + 60;
    var makedraggable = 'yes';
    var newdiv_innerHTML = '<div style="background-color:#444444;padding:2px;"><div style="text-align:right;">[<acronym title="close this window"><a onclick="remove_element_by_id(' + "'" + newdiv_id + "'" + ')" style="cursor:pointer;">x</a></acronym>]</div><div style="text-align:center;">Vote for ' + thissite_name + '</div><iframe FRAMEBORDER=0 src="' + voteurl + '" style="width:' + newdiv_width + 'px;height:' + (newdiv_height - 60) + 'px;"></iframe></div>';
    pop_div(newdiv_id,newdiv_position,newdiv_zIndex,newdiv_width,newdiv_height,newdiv_innerHTML,newdiv_top,newdiv_left);
}

function remove_element_by_id(element_id)
{
    var oldelem = document.getElementById(element_id);
    oldelem.innerHTML = '';
    document.body.removeChild(oldelem);
}



function pop_div(newdiv_id,newdiv_position,newdiv_zIndex,newdiv_width,newdiv_height,newdiv_innerHTML,newdiv_top,newdiv_left,makedraggable)
{
    var newdiv = document.createElement("div");
    newdiv.setAttribute("id",newdiv_id);
    document.body.appendChild(newdiv);
    newdiv.style.position = newdiv_position;
    newdiv.style.zIndex = newdiv_zIndex;
    if(newdiv_width!='none')
    {
        newdiv.style.width = newdiv_width + "px";
    }
    if(newdiv_height!='none')
    {
        newdiv.style.height = newdiv_height + "px";
    }
    newdiv.innerHTML = newdiv_innerHTML;
    newdiv.style.top = newdiv_top + "px";
    newdiv.style.left = newdiv_left + "px";
}


function add_starting_point(siteID)
{
    var sp_URL = document.getElementById("sp_URL").value;
    var sp_levels_to_go = document.getElementById("sp_levels_to_go").value;
    var sp_containing_folder = document.getElementById("sp_containing_folder").value;
    var urlz = "xmlpostsp?site=" + siteID + "&sU=" + escape(sp_URL) + "&sl=" + escape(sp_levels_to_go) + "&sc=" + escape(sp_containing_folder);
    loadXMLDocsp(urlz);
}
function processReqChangesp()
{
    if (reqsp.readyState == 4)
    {
        if (reqsp.status == 200)
        {
            var response = reqsp.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var site = response.getElementsByTagName("site")[0].firstChild.data;
            var userID = response.getElementsByTagName("userID")[0].firstChild.data;
            var moderator_level = response.getElementsByTagName("moderator_level")[0].firstChild.data;
            if(result=='ok')
            {
                showstartingpoints(site,'last',userID,moderator_level,'time',0);
            }
            else if(result=='login')
            {
                var loginmessage = 'please login to add a crawling starting point';
                alert(loginmessage);
            }
            else if(result=='error')
            {
                var loginmessage = 'problems reaching database, please try reloading the page';
                alert(loginmessage);
            }
            else if(result=='tooshort')
            {
                var loginmessage = 'this URL is too short';
                alert(loginmessage);
            }
            else if(result=='ctooshort')
            {
                var loginmessage = 'this containing folder is too short';
                alert(loginmessage);
            }
            else if(result=='exists')
            {
                var loginmessage = 'we already have this URL';
                alert(loginmessage);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqsp.statusText);
        }
    }
}

var global_userID = 0;
var global_moderator_level = 0;
function showstartingpoints(site,page,userID,moderator_level,order,shownuserID)
{
    global_userID = userID;
    global_moderator_level = moderator_level;
    var urlz = "xmlsp?site=" + site + "&page=" + page + "&order=" + order + "&shownuserID=" + shownuserID;
    loadXMLDocssp(urlz);
}
//read crawling start points from xml
function processReqChangessp()
{
    if (reqssp.readyState == 4)
    {
        if (reqssp.status == 200)
        {
            var result_string = "";
            var response = reqssp.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var pagination_string = '';
                var totallinks = response.getElementsByTagName("totallinks")[0].firstChild.data;
                var totalpages = response.getElementsByTagName("totalpages")[0].firstChild.data;
                var thispage = response.getElementsByTagName("thispage")[0].firstChild.data;
                var siteID = response.getElementsByTagName("site")[0].firstChild.data;
                var order = response.getElementsByTagName("order")[0].firstChild.data;
                var shownuserID = response.getElementsByTagName("shownuserID")[0].firstChild.data;

                if(totallinks==0)
                {
                    result_string = result_string + 'empty<br />';
                    if(shownuserID!=0)
                    {
                        document.getElementById('userpageblankor').innerHTML = '';
                    }
                }

                totalpages = Math.abs(totalpages);
                if(totalpages > 1)
                {
                    var previouspage = Math.abs(thispage)-1;
                    var nextpage = Math.abs(thispage)+1;
                    if(thispage>1)
                    {
                        var previouspagebutton = '<a onclick="showstartingpoints(' + siteID + ', ' + previouspage + ', ' + "'" + global_userID + "'" + ', ' + global_moderator_level + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;">previous</a> | ';
                    }
                    else
                    {
                        var previouspagebutton = '';
                    }
                    if(thispage<totalpages)
                    {
                        var nextpagebutton = ' | <a onclick="showstartingpoints(' + siteID + ', ' + nextpage + ', ' + "'" + global_userID + "'" + ', ' + global_moderator_level + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;">next</a>';
                    }
                    else
                    {
                        var nextpagebutton = '';
                    }
                    pagination_string = '<div class="effect" style="font-size:80%;">' + previouspagebutton + 'page ' + thispage + ' of ' + totalpages + nextpagebutton + '</div>';
                }
                result_string = result_string + pagination_string;
                var count = 0;
                while (count < totallinks)
                {
                    count++;
                    var thiswebpageIDname = "webpageID_" + count;
                    var thisURLname = "URL_" + count;
                    var thislevels_to_goname = "levels_to_go_" + count;
                    var thiscontaining_foldername = "containing_folder_" + count;
                    var thisuserIDname = "userID_" + count;
                    var thistimename = "time_" + count;
                    var thislast_crawl_timename = "last_crawl_time_" + count;
                    var thislast_completed_crawl_timename = "last_completed_crawl_time_" + count;
                    var thiswebpageID = response.getElementsByTagName(thiswebpageIDname)[0].firstChild.data;
                    var thisURL = response.getElementsByTagName(thisURLname)[0].firstChild.data;
                    var thislevels_to_go = response.getElementsByTagName(thislevels_to_goname)[0].firstChild.data;
                    var thiscontaining_folder = response.getElementsByTagName(thiscontaining_foldername)[0].firstChild.data;
                    var thisuserID = response.getElementsByTagName(thisuserIDname)[0].firstChild.data;
                    var this_publicname_name = "public_name_" + thisuserID;
                    var this_publicname = response.getElementsByTagName(this_publicname_name)[0].firstChild.data;
                    var thistime = response.getElementsByTagName(thistimename)[0].firstChild.data;
                    var thislast_crawl_time = response.getElementsByTagName(thislast_crawl_timename)[0].firstChild.data;
                    var thislast_completed_crawl_time = response.getElementsByTagName(thislast_completed_crawl_timename)[0].firstChild.data;
                    if(thisuserID==global_userID || global_moderator_level>0)
                    {
                        var deletebutton = ' <a onclick="erase_sp(' + thiswebpageID + ', ' + siteID + ', ' + thispage + ', ' + global_userID + ', ' + global_moderator_level + ', ' + "'" + escape(this_publicname) + "'" + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;color:red;">X</a>';
                    }
                    else
                    {
                        var deletebutton = '';
                    }
                    var showurl = 'URL: <a href="' + thisURL + '" target="_blank">' + thisURL + '</a>';
                    var showlevelstogo = thislevels_to_go + ' levels to go';
                    var showcontainingfolder = 'containing folder: ' + thiscontaining_folder;
                    if(siteID==0)
                    {
                        var thissiteIDname = "siteID_" + count;
                        var thissite_namename = "site_name_" + count;
                        var thissiteID = response.getElementsByTagName(thissiteIDname)[0].firstChild.data;
                        var thissite_name = response.getElementsByTagName(thissite_namename)[0].firstChild.data;
                        var dapage = '<a href="details?site=' + thissiteID + '">' + thissite_name + '</a>';
                        var onpagestring = ' on page ' + dapage;
                    }
                    else
                    {
                        var onpagestring = '';
                    }
                    if(this_publicname=='nabocode_is_deleted_user_is_nabocode')
                    {
                        var userlink = 'deleted user';
                    }
                    else
                    {
                        var userlink = '<a href="userpage?u=' + thisuserID + '">' + this_publicname + '</a>';
                    }
                    var postedbystring = 'posted by ' + userlink + onpagestring;
                    var timezstringus = '<div style="font-size:80%;">added on ' + maketimus(thistime) + ', last crawl attempt on ' + maketimus(thislast_crawl_time) + ', last successful crawl on ' + maketimus(thislast_completed_crawl_time) + '</div>';
                    var thisdatarow = showurl + deletebutton + '<br />' + showlevelstogo + '<br />' + showcontainingfolder + "<br />" + postedbystring + timezstringus;
                    result_string = result_string + "<p>" + thisdatarow + "</p>";
                }
                result_string = result_string + pagination_string;
            }
            else
            {
                result_string = 'error connecting to database';
            }
            document.getElementById('crstpo').innerHTML = result_string;
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqssp.statusText);
        }
    }
}







function shownspages_to_search(site,page,userID,moderator_level,order,shownuserID)
{
    global_userID = userID;
    global_moderator_level = moderator_level;
    var urlz = "xmlshownspages_to_search?site=" + site + "&page=" + page + "&order=" + order + "&shownuserID=" + shownuserID;
    loadXMLDocshownspages_to_search(urlz);
}
//read pages_to_search from xml
function processReqChangeshownspages_to_search()
{
    if (reqshownspages_to_search.readyState == 4)
    {
        if (reqshownspages_to_search.status == 200)
        {
            var result_string = "";
            var response = reqshownspages_to_search.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var pagination_string = '';
                var totallinks = response.getElementsByTagName("totallinks")[0].firstChild.data;
                var totalpages = response.getElementsByTagName("totalpages")[0].firstChild.data;
                var thispage = response.getElementsByTagName("thispage")[0].firstChild.data;
                var siteID = response.getElementsByTagName("site")[0].firstChild.data;
                var order = response.getElementsByTagName("order")[0].firstChild.data;
                var shownuserID = response.getElementsByTagName("shownuserID")[0].firstChild.data;

                if(totallinks==0)
                {
                    result_string = result_string + 'empty<br />';
                    if(shownuserID!=0)
                    {
                        document.getElementById('userpageblankor').innerHTML = '';
                    }
                }

                totalpages = Math.abs(totalpages);
                if(totalpages > 1)
                {
                    var previouspage = Math.abs(thispage)-1;
                    var nextpage = Math.abs(thispage)+1;
                    if(thispage>1)
                    {
                        var previouspagebutton = '<a onclick="shownspages_to_search(' + siteID + ', ' + previouspage + ', ' + "'" + global_userID + "'" + ', ' + global_moderator_level + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;">previous</a> | ';
                    }
                    else
                    {
                        var previouspagebutton = '';
                    }
                    if(thispage<totalpages)
                    {
                        var nextpagebutton = ' | <a onclick="shownspages_to_search(' + siteID + ', ' + nextpage + ', ' + "'" + global_userID + "'" + ', ' + global_moderator_level + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;">next</a>';
                    }
                    else
                    {
                        var nextpagebutton = '';
                    }
                    pagination_string = '<div class="effect" style="font-size:80%;">' + previouspagebutton + 'page ' + thispage + ' of ' + totalpages + nextpagebutton + '</div>';
                }
                result_string = result_string + pagination_string;
                var count = 0;
                while (count < totallinks)
                {
                    count++;
                    var thispage_numbername = "page_number_" + count;
                    var thispages_to_searchIDname = "pages_to_searchID_" + count;
                    var thisurlname = "url_" + count;
                    var thismovieIDname = "movieID_" + count;
                    var thisscannername = "scanner_" + count;
                    var thisuserIDname = "userID_" + count;
                    var thistimename = "time_" + count;
                    var thisflagname = "flag_" + count;
                    var thissiteIDname = "movieID_" + count;
                    var thispage_number = response.getElementsByTagName(thispage_numbername)[0].firstChild.data;
                    var thispages_to_searchID = response.getElementsByTagName(thispages_to_searchIDname)[0].firstChild.data;
                    var thisurl = response.getElementsByTagName(thisurlname)[0].firstChild.data;
                    var thismovieID = response.getElementsByTagName(thismovieIDname)[0].firstChild.data;
                    var thisscanner = response.getElementsByTagName(thisscannername)[0].firstChild.data;
                    var thisuserID = response.getElementsByTagName(thisuserIDname)[0].firstChild.data;
                    var this_publicname_name = "public_name_" + thisuserID;
                    var this_publicname = response.getElementsByTagName(this_publicname_name)[0].firstChild.data;
                    var thistime = response.getElementsByTagName(thistimename)[0].firstChild.data;
                    var thisflag = response.getElementsByTagName(thisflagname)[0].firstChild.data;
                    var thissiteID = response.getElementsByTagName(thissiteIDname)[0].firstChild.data;
                    if(thisuserID==global_userID || global_moderator_level>0)
                    {
                        var deletebutton = ' <a onclick="erase_page_to_search(' + thispages_to_searchID + ', ' + siteID + ', ' + thispage + ', ' + global_userID + ', ' + global_moderator_level + ', ' + "'" + escape(this_publicname) + "'" + ', ' + "'" + order + "'" + ', ' + shownuserID + ')" style="cursor:pointer;color:red;">X</a>';
                        var scannowlink = ' (<a href="nabosearch?siteID=' + thissiteID + '&page=' + thispage_number + '" target="_blank">scan now</a>)';
                    }
                    else
                    {
                        var deletebutton = '';
                        var scannowlink = '';
                    }

                    var maxURLlen=240;
                    var lenofthisurl = thisurl.length;
                    if(lenofthisurl > maxURLlen)
                    {
                        var firsthalf = thisurl.substring(0,Math.floor(lenofthisurl/2));
                        var secondhalf = thisurl.substring(Math.floor(lenofthisurl/2));
                        if(firsthalf.length > maxURLlen/2)
                        {
                            firsthalf = firsthalf.substring(0,maxURLlen/2);
                        }
                        if(secondhalf.length > maxURLlen/2)
                        {
                            secondhalf = secondhalf.substring(secondhalf.length-maxURLlen/2);
                        }
                        var showurl = '<acronym title="' + thisurl + '">' + firsthalf + "..." + secondhalf + "</acronym>";
                    }
                    else
                    {
                        var showurl = thisurl;
                    }
                    var showurl = 'URL: <a href="' + thisurl + '" target="_blank">' + showurl + '</a>';
                    var showscanner = 'scanner: <b>' + thisscanner + '</b>';
                    var showflag = 'flag: <b>' + thisflag + '</b>';
                    if(siteID==0)
                    {
                        var thissite_namename = "site_name_" + count;
                        var thissite_name = response.getElementsByTagName(thissite_namename)[0].firstChild.data;
                        var dapage = '<a href="details?site=' + thissiteID + '">' + thissite_name + '</a>';
                        var onpagestring = ' on page ' + dapage;
                    }
                    else
                    {
                        var onpagestring = '';
                    }
                    if(this_publicname=='nabocode_is_deleted_user_is_nabocode')
                    {
                        var userlink = 'system';
                    }
                    else
                    {
                        var userlink = '<a href="userpage?u=' + thisuserID + '">' + this_publicname + '</a>';
                    }
                    var postedbystring = 'posted by ' + userlink + onpagestring;
                    var timezstringus = ' added on ' + maketimus(thistime);
                    var thisdatarow = showurl + deletebutton + ' ' + showscanner + ' ' + showflag + " " + postedbystring + timezstringus + scannowlink;
                    result_string = result_string + "<div>" + thisdatarow + "</div>";
                }
                result_string = result_string + pagination_string;
            }
            else
            {
                result_string = 'error connecting to database';
            }
            document.getElementById('crstpo2').innerHTML = result_string;
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqshownspages_to_search.statusText);
        }
    }
}




















function showwebpages(site,page,order)
{
    var urlz = "xmlwp?site=" + site + "&page=" + page + "&order=" + order;
    loadXMLDocwp(urlz);
}
//read indexed webpages from xml
function processReqChangewp()
{
    if (reqwp.readyState == 4)
    {
        if (reqwp.status == 200)
        {
            var result_string = "";
            var response = reqwp.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var pagination_string = '';
                var totallinks = response.getElementsByTagName("totallinks")[0].firstChild.data;
                var totalpages = response.getElementsByTagName("totalpages")[0].firstChild.data;
                var thispage = response.getElementsByTagName("thispage")[0].firstChild.data;
                var siteID = response.getElementsByTagName("site")[0].firstChild.data;
                var order = response.getElementsByTagName("order")[0].firstChild.data;

                //order by:
                var orderbytimelink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'time'" + ')">oldest</a>';
                var orderbytimerevlink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'time_DESC'" + ')">most recent</a>';
                var orderbylast_crawl_timelink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'last_crawl_time'" + ')">oldest crawl attempt</a>';
                var orderbylast_crawl_timerevlink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'last_crawl_time_DESC'" + ')">latest crawl attempt</a>';
                var orderbylast_completed_crawl_timelink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'last_completed_crawl_time'" + ')">oldest successful crawl</a>';
                var orderbylast_completed_crawl_timerevlink = ' -<a style="cursor:pointer" onclick="showwebpages(' + siteID + ',1,' + "'last_completed_crawl_time_DESC'" + ')">latest successful crawl</a>';
                var reorderstring = orderbytimelink + orderbytimerevlink + orderbylast_crawl_timelink + orderbylast_crawl_timerevlink + orderbylast_completed_crawl_timelink + orderbylast_completed_crawl_timerevlink;
                if(order=='time')
                {
                    var orderedby = 'oldest';
                }
                else if(order=='time_DESC')
                {
                    var orderedby = 'most recent';
                }
                else if(order=='last_crawl_time')
                {
                    var orderedby = 'oldest crawl attempt';
                }
                else if(order=='last_crawl_time_DESC')
                {
                    var orderedby = 'latest crawl attempt';
                }
                else if(order=='last_completed_crawl_time')
                {
                    var orderedby = 'oldest successful crawl';
                }
                else if(order=='last_completed_crawl_time_DESC')
                {
                    var orderedby = 'latest successful crawl';
                }
                var orderstring = '<div class="effect" style="font-size:80%;">currently ordered by: ' + orderedby + '<br /> re-order by: ' + reorderstring + '</div>';
                if(totallinks==0)
                {
                    result_string = result_string + 'empty<br />';
                }
                else
                {
                    result_string = result_string + orderstring;
                }

                totalpages = Math.abs(totalpages);
                if(totalpages > 1)
                {
                    var minus100page = Math.abs(thispage)-100;
                    var minus10page = Math.abs(thispage)-10;
                    var previouspage = Math.abs(thispage)-1;
                    var nextpage = Math.abs(thispage)+1;
                    var plus10page = Math.abs(thispage)+10;
                    var plus100page = Math.abs(thispage)+100;

                    var minus100pagebutton = '';
                    var minus10pagebutton = '';
                    var previouspagebutton = '';
                    var nextpagebutton = '';
                    var plus10pagebutton = '';
                    var plus100pagebutton = '';

                    if(thispage>100)
                    {
                        minus100pagebutton = '<a onclick="showwebpages(' + siteID + ', ' + minus100page + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">-100</a> | ';
                    }
                    if(thispage>10)
                    {
                        minus10pagebutton = '<a onclick="showwebpages(' + siteID + ', ' + minus10page + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">-10</a> | ';
                    }
                    if(thispage>1)
                    {
                        previouspagebutton = '<a onclick="showwebpages(' + siteID + ', ' + previouspage + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">previous</a> | ';
                    }
                    if(thispage<totalpages)
                    {
                        nextpagebutton = ' | <a onclick="showwebpages(' + siteID + ', ' + nextpage + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">next</a>';
                    }
                    if(thispage<(totalpages-10))
                    {
                        plus10pagebutton = ' | <a onclick="showwebpages(' + siteID + ', ' + plus10page + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">+10</a>';
                    }
                    if(thispage<(totalpages-100))
                    {
                        plus100pagebutton = ' | <a onclick="showwebpages(' + siteID + ', ' + plus100page + ', ' + "'" + order + "'" + ')" style="cursor:pointer;">+100</a>';
                    }


                    pagination_string = '<div class="effect" style="font-size:80%;">' + minus100pagebutton + minus10pagebutton + previouspagebutton + 'page ' + thispage + ' of ' + totalpages + nextpagebutton + plus10pagebutton + plus100pagebutton + '</div>';
                }
                result_string = result_string + pagination_string;
                var count = 0;
                while (count < totallinks)
                {
                    count++;
                    var thiswebpageIDname = "webpageID_" + count;
                    var thisURLname = "URL_" + count;
                    var thistitlename = "title_" + count;
                    var thislevels_to_goname = "levels_to_go_" + count;
                    var thisuseraddedname = "useradded_" + count;
                    var thistimename = "time_" + count;
                    var thislast_crawl_timename = "last_crawl_time_" + count;
                    var thislast_completed_crawl_timename = "last_completed_crawl_time_" + count;
                    var thislinking_text_startname = "linking_text_start_" + count;
                    var thiswebpageID = response.getElementsByTagName(thiswebpageIDname)[0].firstChild.data;
                    var thisURL = response.getElementsByTagName(thisURLname)[0].firstChild.data;
                    var thisthistitle = response.getElementsByTagName(thistitlename)[0].firstChild.data;
                    var thislevels_to_go = response.getElementsByTagName(thislevels_to_goname)[0].firstChild.data;
                    var thisthisuseradded = response.getElementsByTagName(thisuseraddedname)[0].firstChild.data;
                    var thistime = response.getElementsByTagName(thistimename)[0].firstChild.data;
                    var thislast_crawl_time = response.getElementsByTagName(thislast_crawl_timename)[0].firstChild.data;
                    var thislast_completed_crawl_time = response.getElementsByTagName(thislast_completed_crawl_timename)[0].firstChild.data;
                    var thislinking_text_start = response.getElementsByTagName(thislinking_text_startname)[0].firstChild.data;
                    var shourl = thisURL;
                    var maxurllen = 50;
                    if(thisURL.length>maxurllen)
                    {
                        shourl = '<acronym title="' + thisURL + '">' + thisURL.substring(0,(maxurllen-2)) + '...</acronym>';
                    }
                    var showurl = '<a href="' + thisURL + '" target="_blank">' + shourl + '</a>';
                    var thistextdivid = "text" + thiswebpageID;
                    if(thislast_completed_crawl_time==0)
                    {
                        var lastcrawltime = '<span style="color:#AAAAAA;">never crawled</span>. ';
                    }
                    else
                    {
                        var lastcrawltime = 'last completed crawl: ' + maketimus(thislast_completed_crawl_time) + ', last crawl attempt: ' + maketimus(thislast_crawl_time) + '. ';
                    }
                    var showstats = '<div style="font-size:80%;">' + lastcrawltime + "added on " + maketimus(thistime) + ". " + thislevels_to_go + " levels to go</div>";
                    var showtext = '<div id="' + thistextdivid + '" style="font-size:70%;"><a onclick="xpand_text(' + thiswebpageID + ')" style="cursor:pointer;">show text</a></div>';
                    var thisdatarow = "<span style='font-weight:bold;'>" + thislinking_text_start + "</span> " + thisthistitle + "<br />" + showurl + "<br />" + showstats + showtext;
                    result_string = result_string + "<div>" + thisdatarow + "</div>";
                }
                result_string = result_string + pagination_string;
            }
            else
            {
                result_string = 'error connecting to database';
            }
            document.getElementById('inpa').innerHTML = result_string;
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqwp.statusText);
        }
    }
}


function xpand_text(xpandwebpageID)
{
    var urlz = "xmlxpandtext?webpage=" + xpandwebpageID;
    loadXMLDocxpandtext(urlz);
}
//read indexed webpages from xml
function processReqChangexpandtext()
{
    if (reqxpandtext.readyState == 4)
    {
        if (reqxpandtext.status == 200)
        {
            var result_string = "";
            var response = reqxpandtext.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var thiswebpage = response.getElementsByTagName("webpage")[0].firstChild.data;
                result_string = result_string + "<a onclick='dexpandtext(" + thiswebpage + ")' style='cursor:pointer;'>hide text</a>";
                var thislinking_text = response.getElementsByTagName("linking_text")[0].firstChild.data;
                var thistext = response.getElementsByTagName("text")[0].firstChild.data;
                var thisdatarow = "<span style='font-weight:bold;'>linking text:</span><br />" + thislinking_text + "<br /><span style='font-weight:bold;'>text:</span><br />" + thistext;
                result_string = result_string + "<div>" + thisdatarow + "</div>";
            }
            else
            {
                result_string = 'error connecting to database';
            }
            var xpandtextboxidman = 'text' + thiswebpage;
            document.getElementById(xpandtextboxidman).innerHTML = result_string;
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqxpandtext.statusText);
        }
    }
}
function dexpandtext(wpID)
{
    var boxidd = 'text' + wpID;
    var initedxmpandlink = '<a onclick="xpand_text(' + wpID + ')" style="cursor:pointer;">show text</a>';
    document.getElementById(boxidd).innerHTML = initedxmpandlink;
}


function shownsresults(site,page,order,alpha)
{
    var urlz = "xmlshownsresults?site=" + site + "&page=" + page + "&order=" + order + "&alpha=" + alpha;
    loadXMLDocshownsresults(urlz);
}
//read search results from xml
function processReqChangeshownsresults()
{
    if (reqshownsresults.readyState == 4)
    {
        if (reqshownsresults.status == 200)
        {
            var result_string = "";
            var response = reqshownsresults.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var pagination_string = '';
                var totallinks = response.getElementsByTagName("totallinks")[0].firstChild.data;
                var totalpages = response.getElementsByTagName("totalpages")[0].firstChild.data;
                var thispage = response.getElementsByTagName("thispage")[0].firstChild.data;
                var siteID = response.getElementsByTagName("site")[0].firstChild.data;
                var order = response.getElementsByTagName("order")[0].firstChild.data;
                var alpha = response.getElementsByTagName("alpha")[0].firstChild.data;




                //alpha
                var alphanner_string = '-<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1, ' + "'" + order + "'" + ',' + "'all'" + ')">all</a> -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1, ' + "'" + order + "'" + ',' + "'num'" + ')">#</a>';

                var i=0;
                for (i=65;i<=90;i++)
                {
                    var thisletter = String.fromCharCode(i);
                    var alphanner_string = alphanner_string + ' -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1, ' + "'" + order + "'" + ',' + "'" + thisletter + "'" + ')">' + thisletter + '</a>';
                }


                if(alpha=='num')
                {
                    var alphaded = '#';
                }
                else
                {
                    var alphaded = alpha;
                }

                var alphastring = '<div class="effect" style="font-size:80%;">currently showing links starting with: ' + alphaded + '<br /> show links starting with: ' + alphanner_string + '</div>';


                result_string = result_string + alphastring;

                //order by:
                var orderbytimelink = ' -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1,' + "'time'" + ',' + "'" + alpha + "'" + ')">oldest</a>';
                var orderbytimerevlink = ' -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1,' + "'time_DESC'" + ',' + "'" + alpha + "'" + ')">most recent</a>';
                var orderbytextlink = ' -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1,' + "'text'" + ',' + "'" + alpha + "'" + ')">alphabetical order</a>';
                var orderbytextrevlink = ' -<a style="cursor:pointer" onclick="shownsresults(' + siteID + ',1,' + "'text_DESC'" + ',' + "'" + alpha + "'" + ')">reverse alphabetical order</a>';
                var reorderstring = orderbytimelink + orderbytimerevlink + orderbytextlink + orderbytextrevlink;
                if(order=='time')
                {
                    var orderedby = 'oldest';
                }
                else if(order=='time_DESC')
                {
                    var orderedby = 'most recent';
                }
                else if(order=='text')
                {
                    var orderedby = 'alphabetical order';
                }
                else if(order=='text_DESC')
                {
                    var orderedby = 'reverse alphabetical order';
                }
                var orderstring = '<div class="effect" style="font-size:80%;">currently ordered by: ' + orderedby + '<br /> re-order by: ' + reorderstring + '</div>';



                if(totallinks==0)
                {
                    result_string = result_string + 'empty<br />';
                }
                else
                {
                    result_string = result_string + orderstring;
                }

                totalpages = Math.abs(totalpages);
                if(totalpages > 1)
                {



                    var minus100page = Math.abs(thispage)-100;
                    var minus10page = Math.abs(thispage)-10;
                    var previouspage = Math.abs(thispage)-1;
                    var nextpage = Math.abs(thispage)+1;
                    var plus10page = Math.abs(thispage)+10;
                    var plus100page = Math.abs(thispage)+100;

                    var minus100pagebutton = '';
                    var minus10pagebutton = '';
                    var previouspagebutton = '';
                    var nextpagebutton = '';
                    var plus10pagebutton = '';
                    var plus100pagebutton = '';

                    if(thispage>100)
                    {
                        minus100pagebutton = '<a onclick="shownsresults(' + siteID + ', ' + minus100page + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">-100</a> | ';
                    }
                    if(thispage>10)
                    {
                        minus10pagebutton = '<a onclick="shownsresults(' + siteID + ', ' + minus10page + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">-10</a> | ';
                    }
                    if(thispage>1)
                    {
                        previouspagebutton = '<a onclick="shownsresults(' + siteID + ', ' + previouspage + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">previous</a> | ';
                    }
                    if(thispage<totalpages)
                    {
                        nextpagebutton = ' | <a onclick="shownsresults(' + siteID + ', ' + nextpage + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">next</a>';
                    }
                    if(thispage<(totalpages-10))
                    {
                        plus10pagebutton = ' | <a onclick="shownsresults(' + siteID + ', ' + plus10page + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">+10</a>';
                    }
                    if(thispage<(totalpages-100))
                    {
                        plus100pagebutton = ' | <a onclick="shownsresults(' + siteID + ', ' + plus100page + ', ' + "'" + order + "'" + ',' + "'" + alpha + "'" + ')" style="cursor:pointer;">+100</a>';
                    }


                    pagination_string = '<div class="effect" style="font-size:80%;">' + minus100pagebutton + minus10pagebutton + previouspagebutton + 'page ' + thispage + ' of ' + totalpages + nextpagebutton + plus10pagebutton + plus100pagebutton + '</div>';
                }
                result_string = result_string + pagination_string;
                var count = 0;
                while (count < totallinks)
                {
                    count++;
                    var thisresultIDname = "resultID_" + count;
                    var thistextname = "text_" + count;
                    var thisurlname = "url_" + count;
                    var thisdomainname = "domain_" + count;
                    var thislasttimename = "lasttime_" + count;
                    var thisresultID = response.getElementsByTagName(thisresultIDname)[0].firstChild.data;
                    var thistext = response.getElementsByTagName(thistextname)[0].firstChild.data;
                    var thisurl = response.getElementsByTagName(thisurlname)[0].firstChild.data;
                    var thisdomain = response.getElementsByTagName(thisdomainname)[0].firstChild.data;
                    var thislasttime = response.getElementsByTagName(thislasttimename)[0].firstChild.data;
                    var showurl = '<a href="' + thisurl + '" target="_blank">' + thistext + '</a>';
                    var showtime = maketimus(thislasttime);
                    var thisdatarow = showurl + " (" + showtime + ")<br />";
                    result_string = result_string + "<div>" + thisdatarow + "</div>";
                }
                result_string = result_string + pagination_string;
            }
            else
            {
                result_string = 'error connecting to database';
            }
            document.getElementById('inpa2').innerHTML = result_string;
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqshownsresults.statusText);
        }
    }
}











var global_userID = 0;
var global_moderator_level = 0;
function shochat(section, subsection, poster_userID, order, page, visitor_userID, moderator_level)
{
    global_userID = visitor_userID;
    global_moderator_level = moderator_level;
    var urlz = "xmlchat?section=" + section + "&subsection=" + subsection + "&userID=" + poster_userID + "&order=" + order + "&page=" + page;
    loadXMLDocttyuse4(urlz);
}
function erase_post(droppi, section, subsection, userID, order, page, poster, visitor_userID, moderator_level)
{
    global_userID = visitor_userID;
    global_moderator_level = moderator_level;
    var urlz = "xmlerase_post?droppi=" + droppi + "&section=" + section + "&subsection=" + subsection + "&userID=" + userID + "&order=" + order + "&page=" + page;
    var eraseconfmessage = 'are you sure you want to erase this post from: ' + poster;
    var r=confirm(eraseconfmessage);
    if(r==true)
    {
        loadXMLDoc56m243cxsd(urlz);
    }
}



//read chitchat from xml and shit it out!
function processReqChangettyuse4()
{
    if (reqttyuse4.readyState == 4)
    {
        if (reqttyuse4.status == 200)
        {
            var result_string = "<h4>comments:</h4>";
            var response = reqttyuse4.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            if(result == "ok")
            {
                var pagination_string = '';
                var totalboxes = response.getElementsByTagName("totalboxes")[0].firstChild.data;
                var totalpages = response.getElementsByTagName("totalpages")[0].firstChild.data;
                var thispage = response.getElementsByTagName("thispage")[0].firstChild.data;
                var section = response.getElementsByTagName("section")[0].firstChild.data;
                var subsection = response.getElementsByTagName("subsection")[0].firstChild.data;
                var userID = response.getElementsByTagName("userID")[0].firstChild.data;
                var order = response.getElementsByTagName("order")[0].firstChild.data;
                var orderbytimelink = ' -<a style="cursor:pointer" onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'posting_time'" + ', 1, ' + global_userID + ', ' + global_moderator_level + ')">oldest</a>';
                var orderbytimerevlink = ' -<a style="cursor:pointer" onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'posting_time_DESC'" + ', 1, ' + global_userID + ', ' + global_moderator_level + ')">most recent</a>';
                var orderbyratinglink = ' -<a style="cursor:pointer" onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'rating'" + ', 1, ' + global_userID + ', ' + global_moderator_level + ')">best rating</a>';
                var orderbyratingrevlink = ' -<a style="cursor:pointer" onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'rating_DESC'" + ', 1, ' + global_userID + ', ' + global_moderator_level + ')">worst rating</a>';
                var reorderstring = orderbytimelink + orderbytimerevlink + orderbyratinglink + orderbyratingrevlink;
                if(order=='posting_time')
                {
                    var orderedby = 'oldest';
                }
                else if(order=='posting_time_DESC')
                {
                    var orderedby = 'most recent';
                }
                else if(order=='rating')
                {
                    var orderedby = 'best rating';
                }
                else if(order=='rating_DESC')
                {
                    var orderedby = 'worst rating';
                }
                var orderstring = '<div class="effect" style="font-size:80%;">currently ordered by: ' + orderedby + '<br /> re-order by: ' + reorderstring + '</div>';
                if(totalboxes==0)
                {
                    result_string = result_string + 'no comments posted yet. be the first to comment. use the box below to write a comment:<br /><br />';
                }
                else
                {
                    result_string = result_string + orderstring;
                }
                totalpages = Math.abs(totalpages);
                if(totalpages > 1)
                {
                    var previouspage = Math.abs(thispage)-1;
                    var nextpage = Math.abs(thispage)+1;
                    if(thispage>1)
                    {
                        var previouspagebutton = '<a onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'" + order + "'" + ', ' + previouspage + ', ' + global_userID + ', ' + global_moderator_level + ')" style="cursor:pointer;">previous</a> | ';
                    }
                    else
                    {
                        var previouspagebutton = '';
                    }
                    if(thispage<totalpages)
                    {
                        var nextpagebutton = ' | <a onclick="shochat(' + "'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'" + order + "'" + ', ' + nextpage + ', ' + global_userID + ', ' + global_moderator_level + ')" style="cursor:pointer;">next</a>';
                    }
                    else
                    {
                        var nextpagebutton = '';
                    }
                    pagination_string = '<div class="effect" style="font-size:80%;">' + previouspagebutton + 'page ' + thispage + ' of ' + totalpages + nextpagebutton + '</div>';
                }
                result_string = result_string + pagination_string;
                var count = 0;
                while (count < totalboxes)
                {
                    count++;
                    var thispostIDname = "postID_" + count;
                    var thissectionname = "section_" + count;
                    var thissubsectionname = "subsection_" + count;
                    var thisuserIDname = "userID_" + count;
                    var thisposting_timename = "posting_time_" + count;
                    var thisratingname = "rating_" + count;
                    var thisvotesname = "votes_" + count;
                    var thispostname = "post_" + count;
                    var thispostID = response.getElementsByTagName(thispostIDname)[0].firstChild.data;
                    var thissection = response.getElementsByTagName(thissectionname)[0].firstChild.data;
                    var thissubsection = response.getElementsByTagName(thissubsectionname)[0].firstChild.data;
                    var thisuserID = response.getElementsByTagName(thisuserIDname)[0].firstChild.data;
                    var thisposting_time = response.getElementsByTagName(thisposting_timename)[0].firstChild.data;
                    var thisrating = response.getElementsByTagName(thisratingname)[0].firstChild.data;
                    var thisvotes = response.getElementsByTagName(thisvotesname)[0].firstChild.data;
                    var thispost = response.getElementsByTagName(thispostname)[0].firstChild.data;
                    if(thisuserID==0)
                    {
                        var posterlink = 'a guest';
                        var usernameforbuttons = 'a guest';
                    }
                    else
                    {
                        var thispublicnamename = "public_name_" + thisuserID;
                        var thispublicname = response.getElementsByTagName(thispublicnamename)[0].firstChild.data;
                        var posterlink = "<a href='userpage?u=" + thisuserID + "'>" + thispublicname + "</a> ";
                        var usernameforbuttons = thispublicname;
                    }
                    if((thisuserID==global_userID && thisuserID!=0) || global_moderator_level>0)
                    {
                        var deletebutton = '<a onclick="erase_post(' + thispostID + ",'" + section + "'" + ', ' + "'" + subsection + "'" + ', ' + userID + ', ' + "'" + order + "'" + ', ' + thispage + ', ' + "'" + usernameforbuttons + "'" + ', ' + global_userID + ', ' + global_moderator_level + ')" style="cursor:pointer;color:red;">X</a>';
                    }
                    else
                    {
                        var deletebutton = '';
                    }
                    var thisdatarow = "<span style='background-color:#1A1A1A;font-size:110%;'>" + thispost + "</span> by " + posterlink + " " + maketimus(thisposting_time) + " <span id='postvotesstring" + thispostID + "'>" + makevotesstring(thisrating, thisvotes, thispostID, 'post') + "</span>  " + deletebutton;
                    result_string = result_string + "<hr />" + thisdatarow;
                }
                result_string = result_string + pagination_string;
                if(global_userID==0)
                {
                    var randomnumber=Math.floor(Math.random()*100001)
                    var imagever = '<br /><input type="hidden" id="random" value="' + randomnumber + '" /><img src="image_verification?name=' + randomnumber + '" style="vertical-align:text-bottom;" /> -> retype this number -> <input type="text" id="numba" />';
                }
                else
                {
                    var imagever = '<input type="hidden" id="random" value="0" /><input type="hidden" id="numba" value="0" />';
                }
                var adsrc = "squaread?ad=2";
                var onloader = ' onload="rotatad(' + "'" + 'squaro' + "'" + ')"';
                if(safeforgoogle=="yes")
                {
                    adsrc = "squaread?ad=1";
                    var onloader = "";
                }
                var joyous_ad = '<IFRAME FRAMEBORDER=0 MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=NO WIDTH=300 HEIGHT=250 SRC="' + adsrc + '" id="squaro"' + onloader + '></IFRAME>';
                var postform = '<div class="togrey" style="background-color:#444444;"><br /><center><table class="effect" style="background-color:#000000;"><tr><td>&#160;</td><td style="vertical-align:top;"><br /><textarea id="chit" style="width:420px;height:220px;"></textarea>' + imagever + '<br /><center><input type="submit" onclick="post_chat(' + section + ', ' + subsection + ', ' + global_userID + ', ' + global_moderator_level + ')" value="post comment" /></center></td><td  style="vertical-align:top;"><br />' + joyous_ad + '</td><td>&#160;</td></tr></table></center></div>';
                result_string = result_string + postform;
            }
            else
            {
                result_string = 'error connecting to database';
            }
            document.getElementById("chat").innerHTML = result_string;
            wimg_putpreviews();
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqttyuse4.statusText);
        }
    }
}
function processReqChange56m243cxsd()
{
    if (req56m243cxsd.readyState == 4)
    {
        if (req56m243cxsd.status == 200)
        {
            var response = req56m243cxsd.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var thispage = response.getElementsByTagName("page")[0].firstChild.data;
            var section = response.getElementsByTagName("section")[0].firstChild.data;
            var subsection = response.getElementsByTagName("subsection")[0].firstChild.data;
            var userID = response.getElementsByTagName("userID")[0].firstChild.data;
            var order = response.getElementsByTagName("order")[0].firstChild.data;
            if(result=='ok')
            {
                shochat(section, subsection, userID, order, thispage, global_userID, global_moderator_level);
            }
            else if(result=='error')
            {
                var loginmessage = 'problems reaching database, please try reloading the page';
                alert(loginmessage);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + req56m243cxsd.statusText);
        }
    }
}

var global_userID = 0;
var global_moderator_level = 0;
function post_chat(section, subsection, visitor_userID, moderator_level)
{
    global_userID = visitor_userID;
    global_moderator_level = moderator_level;
    var dipost = document.getElementById("chit").value;
    var numba = document.getElementById("numba").value;
    var random = document.getElementById("random").value;
    var urlz = "xmlpost_chat?section=" + section + "&subsection=" + subsection + "&numba=" + numba + "&random=" + random + "&post=" + encodeURIComponent(dipost);
    loadXMLDocasdfasr(urlz);
}
function processReqChangeasdfasr()
{
    if (reqasdfasr.readyState == 4)
    {
        if (reqasdfasr.status == 200)
        {
            var result_string = "";
            var response = reqasdfasr.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var section = response.getElementsByTagName("section")[0].firstChild.data;
            var subsection = response.getElementsByTagName("subsection")[0].firstChild.data;
            if(result=='ok')
            {
                shochat(section, subsection, 0, 'posting_time_DESC', 1, global_userID, global_moderator_level);
            }
            else if(result=='error')
            {
                var loginmessage = 'problems reaching database, please try reloading the page';
                alert(loginmessage);
            }
            else if(result=='tooshort')
            {
                var loginmessage = 'this post is too short';
                alert(loginmessage);
            }
            else if(result=='badcode')
            {
                var loginmessage = 'the number that you have entered in the box did not match the number in the picture next to it, please try again or reload this page if the problem persists';
                alert(loginmessage);
            }
            else if(result=='bannedfromcomments')
            {
                var loginmessage = 'this ip address has been temporarily banned from posting comments. please try again later';
                alert(loginmessage);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqasdfasr.statusText);
        }
    }
}

function makevotesstring(rating, votes, linkID, thinger)
{
    if(votes==1)
    {
        var votesS = '';
    }
    else
    {
        var votesS = 's';
    }
    var votesstring = "rating: " + rating + ", " + votes + " vote" + votesS + ".";
    if(thinger!='pagelist')
    {
        votesstring = votesstring + "<span style='font-size:75%;'>vote: <a onclick='vote" + thinger + "(" + linkID + ", 0)' style='cursor:pointer;'>0</a>, <a onclick='vote" + thinger + "(" + linkID + ", 1)' style='cursor:pointer;'>1</a>, <a onclick='vote" + thinger + "(" + linkID + ", 2)' style='cursor:pointer;'>2</a>, <a onclick='vote" + thinger + "(" + linkID + ", 3)' style='cursor:pointer;'>3</a>, <a onclick='vote" + thinger + "(" + linkID + ", 4)' style='cursor:pointer;'>4</a>, <a onclick='vote" + thinger + "(" + linkID + ", 5)' style='cursor:pointer;'>5</a>, <a onclick='vote" + thinger + "(" + linkID + ", 6)' style='cursor:pointer;'>6</a>, <a onclick='vote" + thinger + "(" + linkID + ", 7)' style='cursor:pointer;'>7</a>, <a onclick='vote" + thinger + "(" + linkID + ", 8)' style='cursor:pointer;'>8</a>, <a onclick='vote" + thinger + "(" + linkID + ", 9)' style='cursor:pointer;'>9</a>, <a onclick='vote" + thinger + "(" + linkID + ", 10)' style='cursor:pointer;'>10</a></span>";
    }
    return votesstring;
}

function votepost(postID, note)
{
    var votesbox = 'postvotesstring' + postID;
    document.getElementById(votesbox).innerHTML = '...Loading...';
    var urlz = "xmlvoteposts?postID=" + postID + "&note=" + note;
    loadXMLDocvotepost(urlz);
}
function processReqChangevotepost()
{
    if (reqvotepost.readyState == 4)
    {
        if (reqvotepost.status == 200)
        {
            var response = reqvotepost.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var rating = response.getElementsByTagName("rating")[0].firstChild.data;
            var votes = response.getElementsByTagName("votes")[0].firstChild.data;
            var postID = response.getElementsByTagName("postID")[0].firstChild.data;
            if(result=='ok')
            {
                var votesbox = 'postvotesstring' + postID;
                var redonevotesbox = makevotesstring(rating, votes, postID, 'post');
                document.getElementById(votesbox).innerHTML = redonevotesbox;
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqvotepost.statusText);
        }
    }
}

var global_userID = 0;
var global_moderator_level = 0;
function erase_sp(webpageID, site, page, esp_userID, esp_moderator_level, publicname, order, shownuserID)
{
    var areyousuremessage = 'are you sure you want to delete this crawling start point posted by ' + unescape(publicname);
    var r_esp=confirm(areyousuremessage);
    if(r_esp==true)
    {
        exec_erase_sp(webpageID, site, page, esp_userID, esp_moderator_level, order, shownuserID);
    }
}
function exec_erase_sp(webpageID, site, page, esp_userID, esp_moderator_level, order, shownuserID)
{
    global_userID = esp_userID;
    global_moderator_level = esp_moderator_level;
    var urlz = "xmlerase_sp?droppi=" + webpageID + "&site=" + site + "&page=" + page + "&order=" + order + "&shownuserID=" + shownuserID;
    loadXMLDocerase_sp(urlz);
}
function processReqChangeerase_sp()
{
    if (reqerase_sp.readyState == 4)
    {
        if (reqerase_sp.status == 200)
        {
            var response = reqerase_sp.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var site = response.getElementsByTagName("site")[0].firstChild.data;
            var page = response.getElementsByTagName("page")[0].firstChild.data;
            var order = response.getElementsByTagName("order")[0].firstChild.data;
            var shownuserID = response.getElementsByTagName("shownuserID")[0].firstChild.data;
            if(result=='ok')
            {
                showstartingpoints(site,page,global_userID,global_moderator_level, order, shownuserID);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqerase_sp.statusText);
        }
    }
}






function erase_page_to_search(webpageID, site, page, esp_userID, esp_moderator_level, publicname, order, shownuserID)
{
    var areyousuremessage = 'are you sure you want to delete this "page to search" posted by ' + unescape(publicname);
    var r_esp=confirm(areyousuremessage);
    if(r_esp==true)
    {
        exec_erase_page_to_search(webpageID, site, page, esp_userID, esp_moderator_level, order, shownuserID);
    }
}
function exec_erase_page_to_search(webpageID, site, page, esp_userID, esp_moderator_level, order, shownuserID)
{
    global_userID = esp_userID;
    global_moderator_level = esp_moderator_level;
    var urlz = "xmlerase_page_to_search?droppi=" + webpageID + "&site=" + site + "&page=" + page + "&order=" + order + "&shownuserID=" + shownuserID;
    loadXMLDocerase_page_to_search(urlz);
}
function processReqChangeerase_page_to_search()
{
    if (reqerase_page_to_search.readyState == 4)
    {
        if (reqerase_page_to_search.status == 200)
        {
            var response = reqerase_page_to_search.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var site = response.getElementsByTagName("site")[0].firstChild.data;
            var page = response.getElementsByTagName("page")[0].firstChild.data;
            var order = response.getElementsByTagName("order")[0].firstChild.data;
            var shownuserID = response.getElementsByTagName("shownuserID")[0].firstChild.data;
            if(result=='ok')
            {
                shownspages_to_search(site,page,global_userID,global_moderator_level, order, shownuserID);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqerase_page_to_search.statusText);
        }
    }
}


function add_page_to_search()
{
    var ps_siteID = document.getElementById("siteID").value;
    var ps_URL = document.getElementById("ps_URL").value;
    var ps_scanner = document.getElementById("ps_scanner").value;
    var ps_flag = document.getElementById("ps_flag").value;
    var urlz = "xmladd_page_to_search?site=" + ps_siteID + "&sU=" + escape(ps_URL) + "&ss=" + escape(ps_scanner) + "&sf=" + escape(ps_flag);
    loadXMLDocadd_page_to_search(urlz);
}
function processReqChangeadd_page_to_search()
{
    if (reqadd_page_to_search.readyState == 4)
    {
        if (reqadd_page_to_search.status == 200)
        {
            var response = reqadd_page_to_search.responseXML.documentElement;
            var result = response.getElementsByTagName("result")[0].firstChild.data;
            var site = response.getElementsByTagName("site")[0].firstChild.data;
            var userID = response.getElementsByTagName("userID")[0].firstChild.data;
            var moderator_level = response.getElementsByTagName("moderator_level")[0].firstChild.data;
            if(result=='ok')
            {
                shownspages_to_search(site,'last',userID,moderator_level,'time',0);
            }
            else if(result=='login')
            {
                var loginmessage = 'please login to add a crawling starting point';
                alert(loginmessage);
            }
            else if(result=='error')
            {
                var loginmessage = 'problems reaching database, please try reloading the page';
                alert(loginmessage);
            }
            else if(result=='tooshort')
            {
                var loginmessage = 'this URL is too short';
                alert(loginmessage);
            }
            else if(result=='ctooshort')
            {
                var loginmessage = 'this flag is too short';
                alert(loginmessage);
            }
            else if(result=='exists')
            {
                var loginmessage = 'we already have this URL';
                alert(loginmessage);
            }
        }
        else
        {
            alert("There was a problem retrieving the XML data:\n" + reqadd_page_to_search.statusText);
        }
    }
}
