﻿// JScript File

function openEditor(id, skinId, scope) {
    var win;
    win = window.open('admin/EditContent.aspx?ContentTag=' + id + '&ContentScope=' + scope + '&SkinID=' + skinId,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}


function openResourceEditor(resourceId) {
    var win;
    win = window.open('admin/EditResource.aspx?ResourceID=' + resourceId,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}


function openNewsArticleEditor(articleId) {
    var win;
    win = window.open('admin/EditNewsArticle.aspx?NewsArticleID=' + articleId,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}

function openFAQEditor(FAQID) {
    var win;
    win = window.open('admin/EditFAQ.aspx?FAQID=' + FAQID,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}



function addFAQ() {
    var win;
    win = window.open('admin/EditFAQ.aspx','EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}

function confirmDeleteFAQ(FAQID, link) {
//    var win;
//    win = window.open('admin/EditFAQ.aspx?FAQID=' + FAQID,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');

    if (confirm('Are you sure you want to delete this question: ' + FAQID + '?'))
    {
        deleteFAQ(FAQID, link);
    }
}

function deleteFAQ(FAQID, link) {
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp2=new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
 
    xmlhttp2.onreadystatechange=function() {
        if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
        {
//            document.getElementById("TicketDetails").innerHTML = xmlhttp2.responseText;
            alert(xmlhttp2.responseText);
            if (xmlhttp2.responseText == "Question Deleted.")
            {
                link.innerHTML = "Deleted";
                link.onclick = "return false";
            }
        }
        else
        {
            try {
                //document.getElementById("TicketDetails").innerHTML = xmlhttp2.readyState + " - " + xmlhttp2.status;
            } catch (err) { }
        }
    }
 
    xmlhttp2.open("POST","admin/DeleteFAQQuestion.ashx", true);
 
    var params = "FAQID=" + FAQID + "";
    xmlhttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp2.setRequestHeader("Content-length", params.length);
    xmlhttp2.setRequestHeader("Connection", "close");
    xmlhttp2.send(params);
}




function addNewsArticle() {
    var win;
    win = window.open('admin/EditNewsArticle.aspx','EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}


function confirmDeleteNewsArticle(NewsArticleID, link) {
//    var win;
//    win = window.open('admin/EditFAQ.aspx?FAQID=' + FAQID,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');

    if (confirm('Are you sure you want to delete this article: ' + NewsArticleID + '?'))
    {
        deleteNewsArticle(NewsArticleID, link);
    }
}

function deleteNewsArticle(NewsArticleID, link) {
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp2=new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
 
    xmlhttp2.onreadystatechange=function() {
        if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
        {
//            document.getElementById("TicketDetails").innerHTML = xmlhttp2.responseText;
            alert(xmlhttp2.responseText);
            if (xmlhttp2.responseText == "News Article Deleted.")
            {
                link.innerHTML = "Deleted";
                link.onclick = "return false";
            }
        }
        else
        {
            try {
                //document.getElementById("TicketDetails").innerHTML = xmlhttp2.readyState + " - " + xmlhttp2.status;
            } catch (err) { }
        }
    }
 
    xmlhttp2.open("POST","admin/DeleteNewsArticle.ashx", true);
 
    var params = "NewsArticleID=" + NewsArticleID + "";
    xmlhttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp2.setRequestHeader("Content-length", params.length);
    xmlhttp2.setRequestHeader("Connection", "close");
    xmlhttp2.send(params);
}











function addResource() {
    var win;
    win = window.open('admin/EditResource.aspx','EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');
}

function confirmDeleteResource(ResourceID, link) {
//    var win;
//    win = window.open('admin/EditResource.aspx?ResourceID=' + ResourceID,'EditHTML','location=1,status=1,scrollbars=1,width=980,height=680,resizable=1');

    if (confirm('Are you sure you want to delete this resource: ' + ResourceID + '?'))
    {
        deleteResource(ResourceID, link);
    }
}

function deleteResource(ResourceID, link) {
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp2=new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
    }
 
    xmlhttp2.onreadystatechange=function() {
        if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
        {
//            document.getElementById("TicketDetails").innerHTML = xmlhttp2.responseText;
            alert(xmlhttp2.responseText);
            if (xmlhttp2.responseText == "Resource Deleted.")
            {
                link.innerHTML = "Deleted";
                link.onclick = "return false";
            }
        }
        else
        {
            try {
                //document.getElementById("TicketDetails").innerHTML = xmlhttp2.readyState + " - " + xmlhttp2.status;
            } catch (err) { }
        }
    }
 
    xmlhttp2.open("POST","admin/DeleteResource.ashx", true);
 
    var params = "ResourceID=" + ResourceID + "";
    xmlhttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp2.setRequestHeader("Content-length", params.length);
    xmlhttp2.setRequestHeader("Connection", "close");
    xmlhttp2.send(params);
}

