var Ajax = new Object();

Ajax.Request = function(url,id, callbackMethod)
{
    Page.getPageCenterX();
    Ajax.request = Ajax.createRequestObject();
    Ajax.request.onreadystatechange = callbackMethod;
    Ajax.request.open("POST", url+id, true);
    Ajax.request.send(url);
    generte_pagination(id);
        
}

Ajax.Response = function ()
{
    if(Ajax.CheckReadyState(Ajax.request))
    {
        var	response = Ajax.request.responseXML.documentElement;
        var _data = response.getElementsByTagName('comment');
        var inside = '';
        if(_data.length == 0)
        {
            inside = 'No hay comentarios por el momento';
            document.getElementById('comments_fill').innerHTML = inside;
        } else {
            var i
            for ( i = 0 ; i < _data.length ; i ++ )
            {
                id = response.getElementsByTagName('id_comment')[i].firstChild.data;
                inside+= '<div class="comm_num"><div class="data clearfix"><p class="left"><span>';
                inside+= response.getElementsByTagName('name')[i].firstChild.data + '</span> ';
                inside+= response.getElementsByTagName('comment_date')[i].firstChild.data + " - " + response.getElementsByTagName('comment_time')[i].firstChild.data + '</p>';
                inside+= ' <div id="reportar_abuso_';
                inside+= id;
                inside+= '" style="display:none;">';
                inside+= '<div id="border"><div id="pop_ups"><h1 class="title">Estas denunciando una infracción o un abuso</h1>';
                inside+= '<h1>Todas las denuncias se tratan con estricta confidencialidad.</h1><fieldset class="reportar">';
                inside+= '<form id="rep_abuso_';
                inside+= id;
                inside+= '" name="rep_abuso_';
                inside+= id;
                inside+= '" method="post" enctype="text/plain">';
                inside+= '<div><label>motivo</label><textarea  cols="30" rows="5"id="motivo" height="200" width="200" name="motivo" />';
                inside+= '</textarea>';
                inside+= '<input type="button" id="btn_enviar" name="btn_enviar" value="Enviar"';
                inside+= 'onclick="validaRe(';
                inside+= "'";
                inside+= id;
                inside+= "'";
                inside+= ')" />';
                inside+= '</div>';
                inside+= '<div id="msj_abuso_';
                inside+= id;
                inside+= '"></div>';
                inside+= '</form></fieldset></div></div></div>';
                inside+= '<a href="#TB_inline?height=400&width=570&inlineId=reportar_abuso_';
                inside+= id;
                inside+= '" class="right thickbox"><img src="/images/structure/report_abuse.gif" alt="Reportar Abuso" /></a>';
                inside+= '</div><p>';
                inside+= response.getElementsByTagName('comment_text')[i].firstChild.data;
                inside+= '</p></div>';
            ///inside+= '<div class="comm_num"> <div class="data"><h1>'+response.getElementsByTagName('name')[i].firstChild.data+'</h1><h2>'+response.getElementsByTagName('comment_date')[i].firstChild.data+'</h2><h4>'+response.getElementsByTagName('comment_time')[i].firstChild.data+'</h4><a href="javascript:popItUp(\'popup/report.php?id='+response.getElementsByTagName('id_comment')[i].firstChild.data+'\',\'Report\',\'550\',\'370\')"><img src="images/structure/report_abuse.gif" alt="Reportar Abuso" /></a></div><p>'+response.getElementsByTagName('comment_text')[i].firstChild.data+'</p><div class="clear"></div></div>';
            }
            document.getElementById('comments_fill').innerHTML =  inside;
        }
    }
}

Ajax.createRequestObject = function()
{
    var obj;
    if(window.XMLHttpRequest)
    {
        obj = new XMLHttpRequest();
    }
    else if(window.ActiveXObject)
    {
        obj = new ActiveXObject("MSXML2.XMLHTTP");
    }
    return obj;
}

Ajax.CheckReadyState = function(obj)
{
    if(obj.readyState == 4)
    {
        if(obj.status == 200)
        {
            return true;
        }
    }
}

var Page = new Object();
Page.width;
Page.height;
Page.top;

Page.getPageCenterX = function ()
{
    var fWidth;
    var fHeight;
    //For old IE browsers
    if(document.all)
    {
        fWidth = document.body.clientWidth;
        fHeight = document.body.clientHeight;
    }
    //For DOM1 browsers
    else if(document.getElementById &&!document.all)
    {
        fWidth = innerWidth;
        fHeight = innerHeight;
    }
    else if(document.getElementById)
    {
        fWidth = innerWidth;
        fHeight = innerHeight;
    }
    //For Opera
    else if (is.op)
    {
        fWidth = innerWidth;
        fHeight = innerHeight;
    }
    //For old Netscape
    else if (document.layers)
    {
        fWidth = window.innerWidth;
        fHeight = window.innerHeight;
    }
    Page.width = fWidth;
    Page.height = fHeight;
    Page.top = window.document.body.scrollTop;
}


