﻿var xmlHttp = false;

function getXmlHttpRequestObject()
{
    try
    {
        //IE implementation
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            //Legacy implementation
            xmlHttp = new ActiveXObject("MsXml2.XMLHTTP");
        }
        catch(exp)
        {
            xmlHttp = false;
        }
    }
    if (!xmlHttp && typeof XMLHttpRequest != 'undefined')
    {
        //Mozilla based browsers
        //creating a native request object
        xmlHttp = new XMLHttpRequest();
    }
}

function showSearchTip(remoteFile) 
{   
    getXmlHttpRequestObject();
    // Avoid IE Cache Issue, You need to construct a random query string
    xmlHttp.open("GET", remoteFile + '?time=' + new Date().getTime(), true);
    xmlHttp.onreadystatechange = function()
    {
        if (xmlHttp.readyState == 4)
        {
            if (xmlHttp.status == 200)
            {
                document.getElementById("tip").innerHTML = xmlHttp.responseText;
            }
        }
    }
    xmlHttp.send(null);
}

function printSelection(node){
    var content=node.innerHTML
    var pwin=window.open('','print_content','width=100,height=100');

    pwin.document.open();
    pwin.document.write('<html><body onload="window.print()">'+content+'</body></html>');
    pwin.document.close();

    setTimeout(function(){pwin.close();},1000);
}

