var Search = 
{
    // public static void ReadExtendedInformation( MouseEvent e, String data )
    ReadExtendedInformation : function (e,tipo,id)
    {
        var x, y;

        if (!e) var e = window.event;
        if (e.pageX || e.pageY)
        {
            x = e.pageX;
            y = e.pageY;
        }
        else if (e.clientX || e.clientY)
        {
            x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
            y = e.clientY + document.body.scrollTop  + document.documentElement.scrollTop;
        }

        x -= 5; // put the div inside the pointer
        y -= 5; // put the div inside the pointer

        var div = Search.CreateDivElement();
        div.style.visibility = "visible";
        div.style.left = (x + "px");
        div.style.top  = (y + "px");
        div.innerHTML = "Carregando, aguarde..."; // we can change this to put one image saying "loading" instead
        PageMethods.someMethod(tipo,id,Search.Sucess,Search.Fail); // makes the remote call
    },

    // public static void Sucess( Object r )
    Sucess : function (r)
    {
        Search.WriteData(r);
    },

    // public static void Fail( Exception ex )
    Fail : function (ex)
    {
        Search.WriteData(ex.get_message());
    },

    // public static void HideExtendedInformation( )
    HideExtendedInformation : function (event)
    {
        if (!event) event = window.event;
    
        try
        {
            if (event.explicitOriginalTarget) // Gecko
            {
                if (event.explicitOriginalTarget.tagName == "DIV")
                {
                    //Fechava a janela automaticamente - 19/08/08
                    //setTimeout('Search.ReallyHideExtendedInformation()',500);
                }
            }
            if (event.srcElement && event.toElement) // IE4+
            {
                if (
                    !(
                           (event.srcElement.tagName == "DIV" && event.toElement.tagName == "UL") 
                        || (event.srcElement.tagName == "DIV" && event.toElement.tagName == "LI")
                        || (event.srcElement.tagName == "DIV" && event.toElement.tagName == "A")
                        || (event.srcElement.tagName == "UL" && event.toElement.tagName == "DIV")
                        || (event.srcElement.tagName == "UL" && event.toElement.tagName == "LI")
                        || (event.srcElement.tagName == "UL" && event.toElement.tagName == "A")
                        || (event.srcElement.tagName == "LI" && event.toElement.tagName == "DIV")
                        || (event.srcElement.tagName == "LI" && event.toElement.tagName == "UL")
                        || (event.srcElement.tagName == "LI" && event.toElement.tagName == "LI")
                        || (event.srcElement.tagName == "LI" && event.toElement.tagName == "A")
                        || (event.srcElement.tagName == "A" && event.toElement.tagName == "DIV") 
                        || (event.srcElement.tagName == "A" && event.toElement.tagName == "UL") 
                        || (event.srcElement.tagName == "A" && event.toElement.tagName == "LI") 
                        || (event.srcElement.tagName == "A" && event.toElement.tagName == "A")
                    )
                )
                {
                     //Fechava a janela automaticamente IE4 - 19/08/08
                    //setTimeout('Search.ReallyHideExtendedInformation()',500);
                    if (event.cancelBubble) event.cancelBubble = true;
                    //alert(event.srcElement.tagName + " -> " + event.toElement.tagName);
                }
            }
        }
        catch(ex)
        {
           setTimeout('Search.ReallyHideExtendedInformation()',500);
        }
    },
    
    // public static void ReallyHideExtendedInformation( div )
    ReallyHideExtendedInformation : function ()
    {
        var div = $get("test");
        if (div) div.style.visibility = "hidden";
    },

    // public static void WriteData( String data )
    WriteData : function (data)
    {
        var div = $get("test");
        div.innerHTML = data;
    },
    
    CreateDivElement : function()
    {
        if (document.getElementById('test')) return document.getElementById('test');

        var div = document.createElement('div');

        div.onmouseout = Search.HideExtendedInformation;

        div.id = 'test';
        div.className = 'showOptions';
        div.style.position = 'absolute';

        document.body.appendChild(div);

        return div;
    }
      
};

//Fecha todos Modais popups passando somente o seu id
 function ModalClose(PopupID)
 { 
    var mydocument = $get(PopupID);
    mydocument.style.display = 'none';
 }
 
 //Abre todos Modais popups passando somente o seu id
  function ShowModalPopupGood(PopupID)
  {
    var mydocument = $get(PopupID);
    mydocument.style.display = 'block';
  }

