// JScript File
var objGetNotification = null;
var objGetNew = null;
var objGetNewContent = null;
var objCloseNews = null;
var newsIDs;
function ajaxGetNotification() {
    if (window.ActiveXObject) {
        try {
            objGetNotification = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNotification = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNotification = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objGetNotification = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNotification = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNotification = null;
            }
        }
    }
    if (objGetNotification != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objGetNotification.onreadystatechange = Process_Response_GetNotification;
            var url = window.location.pathname.split("/").slice(-1);
            objGetNotification.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Notification", false);
            objGetNotification.send(null);
        } else if (window.XMLHttpRequest) {
            var url = window.location.pathname.split("/").slice(-1);
            objGetNotification.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Notification", false);
            objGetNotification.send(null);
            objGetNotification.onreadystatechange = Process_Response_GetNotification();
        }
    }
    return false;
}
function Process_Response_GetNotification() {
    if (objGetNotification.readyState == 4) {
        if (objGetNotification.status == 200) {
            var retval = objGetNotification.responseText;
            if (retval == "") {
                document.getElementById("ctl00_notification").style.display = 'block';
                $('#ctl00_Notcount').text(0);
                $('#ctl00_NotCount2').text('You Have 0 Notification');
            }
            else if (retval == "*No") {
                document.getElementById("ctl00_notification").style.display = 'none';
            }
            else {
                if (retval.length > 0 && retval != "Fail") {
                    var arr = retval.split('~');
                    document.getElementById("ctl00_notification").style.display = 'block';
                    $('#ctl00_NotMenu').append(arr[0]);
                    $('#ctl00_Notcount').text(arr[1]);
                    $('#ctl00_NotCount2').text('You Have ' + arr[1] + ' Notification');
                }
            }
        }
        else if (objGetNotification.status == 404) {
            var url = window.location.pathname.split("/").slice(-1);
            objGetNotification.open("GET", "../MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Notification", false);
            objGetNotification.send(null);
            objGetNotification.onreadystatechange = Process_Response_GetNotification();
        }
    }
}

function ajaxGetNews() {
    if (window.ActiveXObject) {
        try {
            objGetNew = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNew = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNew = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objGetNew = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNew = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNew = null;
            }
        }
    }
    if (objGetNew != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objGetNew.onreadystatechange = Process_Response_GetNews;
            var url = window.location.pathname.split("/").slice(-1);
            objGetNew.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=News", false);
        } else if (window.XMLHttpRequest) {
            var url = window.location.pathname.split("/").slice(-1);
            objGetNew.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=News", false);
            objGetNew.send(null);
            objGetNew.onreadystatechange = Process_Response_GetNews();
        }
    }
    return false;
}
function Process_Response_GetNews() {
    if (objGetNew.readyState == 4) {
        if (objGetNew.status == 200) {
            var retval = objGetNew.responseText;
            if (retval == "") {
                document.getElementById("ctl00_listNews").style.display = 'block';
                $('#ctl00_lblNoofNews').text(0);
                $('#ctl00_lblNoofNewsDetails').text('You Have 0 News & Events');
            }
            else if (retval == "*No") {
                document.getElementById("ctl00_listNews").style.display = 'none';
            }
            else {
                if (retval.length > 0 && retval != "Fail") {
                    var arr = retval.split('~');
                    document.getElementById("ctl00_listNews").style.display = 'block';
                    $('#ctl00_NewsMenu').append(arr[0]);
                    $('#ctl00_lblNoofNews').text(arr[1]);
                    $('#ctl00_lblNoofNewsDetails').text('You Have ' + arr[1] + ' News & Events');
                }
            }
        }
        else if (objGetNew.status == 404) {
            var url = window.location.pathname.split("/").slice(-1);
            objGetNew.open("GET", "../MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=News", false);
            objGetNew.send(null);
            objGetNew.onreadystatechange = Process_Response_GetNews();
        }
    }
}

function ajaxGetNewsContent(Newid) {
    if (window.ActiveXObject) {
        try {
            objGetNewContent = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNewContent = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNewContent = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objGetNewContent = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objGetNewContent = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objGetNewContent = null;
            }
        }
    }
    if (objGetNewContent != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objGetNewContent.onreadystatechange = Process_Response_GetNewsContent;
            var url = window.location.pathname.split("/").slice(-1);
            newsIDs = Newid;
            objGetNewContent.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=NewsContent&NewsID=" + Newid, false);
        } else if (window.XMLHttpRequest) {
            var url = window.location.pathname.split("/").slice(-1);
            newsIDs = Newid;
            objGetNewContent.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=NewsContent&NewsID=" + Newid, false);
            objGetNewContent.send(null);
            objGetNewContent.onreadystatechange = Process_Response_GetNewsContent();
        }
    }
    return false;
}
function Process_Response_GetNewsContent() {
    if (objGetNewContent.readyState == 4) {
        if (objGetNewContent.status == 200) {
            var retval = objGetNewContent.responseText;
            if (retval == "") {
                $('#divNew').append('');
            }
            else {
                document.getElementById('divNew').innerHTML = "";
                //$('#divNew').append('');
                $('#divNew').append(retval);
                if (newsIDs == 0) {
                    $('#myModalForNewsAndEvent').modal('show');
                }
            }
        }
        else if (objGetNewContent.status == 404) {
            var url = window.location.pathname.split("/").slice(-1);
            objGetNewContent.open("GET", "../MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=NewsContent&NewsID=" + newsIDs, false);
            objGetNewContent.send(null);
            objGetNewContent.onreadystatechange = Process_Response_GetNewsContent();
        }
    }
}


function ajaxCloseNews() {
    if (window.ActiveXObject) {
        try {
            objCloseNews = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objCloseNews = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e1) {
                objCloseNews = null;
            }
        }
    } else if (window.XMLHttpRequest) {
        try {
            objCloseNews = new XMLHttpRequest("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                objCloseNews = new XMLHttpRequest("Microsoft.XMLHTTP");
            } catch (e1) {
                objCloseNews = null;
            }
        }
    }
    if (objCloseNews != null) {
        var k = Math.floor(Math.random() * 111);
        if (window.ActiveXObject) {
            objCloseNews.onreadystatechange = Process_Response_CloseNews;
            var url = window.location.pathname.split("/").slice(-1);
            objCloseNews.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Close", false);
            objCloseNews.send(null);
        } else if (window.XMLHttpRequest) {
            var url = window.location.pathname.split("/").slice(-1);
            objCloseNews.open("GET", "MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Close", false);
            objCloseNews.send(null);
            objCloseNews.onreadystatechange = Process_Response_CloseNews();
        }
    }
    return false;
}
function Process_Response_CloseNews() {
    if (objCloseNews.readyState == 4) {
        if (objCloseNews.status == 200) {
            var retval = objCloseNews.responseText;
            if (retval == "") {

            }
        }
        else if (objCloseNews.status == 404) {
            var url = window.location.pathname.split("/").slice(-1);
            objCloseNews.open("GET", "../MasterFile/GetNotification.aspx?pathname=" + url + "&IsFrom=Close", false);
            objCloseNews.send(null);
            objCloseNews.onreadystatechange = Process_Response_CloseNews();
        }
    }
}


