// Dispay the I-Load window using the GreyBox library
function CustomWindowProvider_WindowOpen (controlId, windowLabel, windowId, url, w, h, modal, center, resizable, title)
{
    if (window.ttHPHeader)
    {
        window.ttHPHeader.qtip("hide");
    }
    if (window.ttHPILoad2)
    {
        window.ttHPILoad2.qtip("hide");
    }
    var options = {
        caption: title,
        height: h,
        width: w,
        fullscreen: false,
        show_loading: false,
        center_win: true,
        show_close_img: true
    }
    var win = new GB_Window(options);
    return win.show(url);
}

// Hide an I-Load window displayed using the GreyBox library
function CustomWindowProvider_WindowClose (controlId, windowLabel, windowId, w)
{
    GB_hide();
}

function LBT_CustomWindowProvider_WindowOpen(controlId, windowLabel, windowId, url, w, h, modal, center, resizable, title)
{
    var dt = new Date();

    var url2 = "/Services/Tracker_IL_WO.aspx";
    url2 += "?p=" + encodeURIComponent(GB_PT);
    url2 += "&wl=" + encodeURIComponent(windowLabel);
    url2 += "&cid=" + encodeURIComponent(controlId);
    url2 += "&u=" + encodeURIComponent(url);
    url2 += "&fr=" + encodeURIComponent("" + dt.getTime());
    return Radactive.WebControls.ILoad.ShowLightBox(controlId, windowLabel, windowId, url2, w, h, modal, center, resizable, title);
    
    //return Radactive.WebControls.ILoad.ShowLightBox(controlId, windowLabel, windowId, url, w, h, modal, center, resizable, title);
}

function LBT_CustomWindowProvider_WindowClose(controlId, windowLabel, windowId, w)
{
    Radactive.WebControls.ILoad.HideLightBox(controlId, windowLabel, windowId, w);
}

function getIEVersion()
{
    var userAgent = navigator.userAgent;
    var offset = userAgent.indexOf("MSIE ");

    if (offset >= 0)
    {
        var result = parseFloat(userAgent.substring(offset + 5, userAgent.indexOf(";", offset)));
        return result;
    } 
    else
    {
        return 0;
    }
}

function M1__body_resize()
{
    var ieVersion = getIEVersion();
    if ((ieVersion > 0) && (ieVersion < 8)) 
    {
        var windwHeight = parseInt(document.documentElement.clientHeight);
	    if (windwHeight > 0)
	    {
	        var h = windwHeight - (318 + 265 + 1);
	        if (h < 1)
	        {
	            h = 1;
	        }
	        var td = document.getElementById("Master_M1_ML_Table_Left");
	        if (td)
	        {
	            td.style.height = h;
	        }
	    }
    }
}

function smtc()
{
    var str = "ma" + "il" +    "to:";
    str += "sup" + "por" + "t@r" + "ada" + "ctiv" + "e.co" + "m?s" + "ub" + "ject=" + "RA" + "Dac" + "tiv" + "e -Su" + "ppo" + "rt-";
    document.location.href= str;
}

function doGoogleSearch(query)
{
    if (query == null)
    {
        var oTxtGoogleSearch = document.getElementById("txtGoogleSearch");
        if (oTxtGoogleSearch)
        {
            query = oTxtGoogleSearch.value;
        }
    }

    var url = "http://www.google.com/custom";
    url += "?as_sitesearch=" + encodeURIComponent("radactive.com");
    url += "&hl=" + encodeURIComponent("en");
    url += "&q=" + encodeURIComponent(query);

    document.location.href = url;
}

function txtGoogleSearch_keyDown(e)
{
    if (!e)
    {
        e = window.event;
    }

    if (e.keyCode == 13)
    {
        e.returnValue = false;
        e.cancel = true;
        doGoogleSearch();
        return false;
    }
}