﻿// FAQ Single List begins... //
var popupMOM;
function showPopup(e, elemID, txtWhen, txtWhere) {
    if (txtWhen == '')
        txtWhen = 'All Day';
    popupMOM = document.createElement('div');
    popupMOM.className = 'tooltip';
    //popupMOM.style.cssText = 'position: absolute; border: 2px groove #b3b3b3; left: 0px; top: 0px; padding: 2px;';
    if (txtWhen.length > 0)
        popupMOM.innerHTML = '<span class="when">When: </span>' + txtWhen + '<br />';

    if (txtWhere.length > 0)
        popupMOM.innerHTML += '<span class="where">Where: </span>' + txtWhere;

    document.body.appendChild(popupMOM);
    positionPopup(e, elemID);
}

function positionPopup(e, elemID) {
    var docb = document.body;
    if (popupMOM == null) return;

    var newLeft = ((e.clientX + docb.scrollLeft) + 4);
    var newTop = ((e.clientY + docb.scrollTop) + 4);

    if (newLeft + popupMOM.offsetWidth > (docb.clientWidth + docb.scrollLeft)) {
        var newerLeft = ((e.clientX + docb.scrollLeft) - 4) - popupMOM.offsetWidth;
        if (newerLeft > 0) newLeft = newerLeft;
    }

    if (newTop + popupMOM.offsetHeight > (docb.clientHeight + docb.scrollTop)) {
        var newerTop = ((e.clientY + docb.scrollTop) - 4) - popupMOM.offsetHeight;
        if (newerTop > 0) newTop = newerTop;
    }

    var popStyle = popupMOM.style;
    popStyle.left = newLeft + 'px';
    popStyle.top = newTop + 'px';
}

function hidePopup() {
    if (popupMOM == null) return;
    document.body.removeChild(popupMOM);
    popupMOM = null;
}

function ToggleElement(elementId) {
    element = document.getElementById(elementId);
    if (element != null)
        element.style.display = (element.style.display == "none" ? "block" : "none");
}

// ...Ends FAQ Single List //

// XMLHTTP Object //
function xmlHttp_Get(xmlhttp, url) {
    xmlhttp.open('GET', url, true);
    xmlhttp.setRequestHeader("If-Modified-Since", "Fri, 31 Dec 1999 23:59:59 GMT"); //This line of code solves the cache issue in IE. 
    xmlhttp.send(null);
}

function GetXmlHttpObject(handler) {
    var objXmlHttp = null;
    if (navigator.userAgent.indexOf('MSIE') >= 0) // is IE
    {
        // Check IE5 or later. 
        var strObjName = (navigator.appVersion.indexOf("MSIE 5.5") != -1) ? 'Microsoft.XMLHTTP' : 'Msxml2.XMLHTTP';
        try {
            objXmlHttp = new ActiveXObject(strObjName);
            objXmlHttp.onreadystatechange = handler;
        }
        catch (e) {
            alert('IE detected, but object could not be created. Verify that active scripting and activeX controls are enabled');
            return;
        }
    }
    else if ((navigator.userAgent.indexOf("Opera6") != -1) || (navigator.userAgent.indexOf("Opera/6") != -1)) {
        // Opera
        alert('Opera detected. The page may not behave as expected.');
        return;
    }
    else {
        // Mozilla | Netscape | Safari 
        objXmlHttp = new XMLHttpRequest();
        objXmlHttp.onload = handler;
        objXmlHttp.onerror = handler;
    }

    return objXmlHttp;
}
