﻿function getHeading(lsHeadingID) {
    var poststr = ""
    if (document.getElementById('heading_' + lsHeadingID)) {
        if (document.getElementById('heading_' + lsHeadingID).style.display=='block') {
            document.getElementById('heading_' + lsHeadingID).style.display='none'
        }
        else {
            document.getElementById('heading_' + lsHeadingID).style.display='block'
        }
    }
    else {
        poststr = poststr + "&hid=" + lsHeadingID
        postXML("ajax/headings.aspx?type=getheading",poststr)
    }
}

function closeCol1Panel() {
    document.getElementById('col_1_panel').innerHTML = ''
    document.getElementById('col_1_panel').style.display = 'none'
}

function expandSearchResult(lsItem) {
    document.getElementById('search_result_article').style.display = 'none'
    document.getElementById('search_result_heading').style.display = 'none'
    document.getElementById('search_result_plant').style.display = 'none'

    document.getElementById(lsItem).style.display='block'
    
    document.getElementById('search_result_article_link').style.backgroundColor = '#999999'
    document.getElementById('search_result_heading_link').style.backgroundColor = '#999999'
    document.getElementById('search_result_plant_link').style.backgroundColor = '#999999'
    document.getElementById(lsItem + '_link').style.backgroundColor = '#FFFFFF'
}

function getArticle(lsHeadingID, lsArticleID) {
    var poststr = ""
    poststr = poststr + "&hid=" + lsHeadingID
    poststr = poststr + "&aid=" + lsArticleID
    postXML("ajax/articles.aspx?type=getarticles",poststr)
}

function getAllHeadings() {
    var poststr = ""
    postXML("ajax/configuration.aspx?type=headings",poststr)
}

function getAllArticles() {
    var poststr = ""
    postXML("ajax/configuration.aspx?type=articles",poststr)
}

function getAllGroups(){
    var poststr = ""
    postXML("ajax/configuration.aspx?type=groups",poststr)
}

function getAllUsers(){
    var poststr = ""
    postXML("ajax/configuration.aspx?type=users",poststr)
}

function getAllSettings(){
    var poststr = ""
    postXML("ajax/configuration.aspx?type=settings",poststr)
}


function getSimpleSearch(lsSearch) {
    var poststr = ""
    poststr = poststr + "&sch=" + escapeIt(lsSearch)
    postXML("ajax/search.aspx?type=simple",poststr)
}

function escapeIt(lsString){
    //lsString = lsString.replace(/['"]/g,'');
    return lsString
}

function moveResult() {
    
    document.getElementById('paneltext').innerHTML = document.getElementById('maintext').innerHTML
    document.getElementById('move_results').innerHTML = ''
    document.getElementById('img_move').src = 'images/system/close.gif'
    document.getElementById('img_move').onclick = closeResult
}

function siteLogin() {
    var lsString = ''
    
    lsString = lsString + '<div class="form_title">Admin Login&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span id="form_login"><img id="img_login" src="/images/system/close.gif" onclick="closeResult()" /></span></div>'
    lsString = lsString + '<div class="form_field"><span class="form_label">User Name:</span><span class="form_value"><input id="username" type="textbox" size="10"/></span></div>'
    lsString = lsString + '<div class="form_field"><span class="form_label">Password:</span><span class="form_value"><input id="password" type="password" size="10"/></span></div>'
    lsString = lsString + '<div class="form_submit"><span class="form_value"><input id="form_subit" type="submit" value="OK" onclick="siteLoginProcess()"/></span></div>'
    document.getElementById('paneltext').innerHTML = lsString
}

function siteLoginProcess() {
    var poststr = ""
    poststr = poststr + "&username=" + document.getElementById('username').value
    poststr = poststr + "&password=" + document.getElementById('password').value
    postXML("ajax/Login.aspx?type=login",poststr)
}

function siteLogout() {
    var poststr = ""
    postXML("ajax/Login.aspx?type=logout",poststr)
}


function closeResult() {
    var poststr = ""
    postXML("ajax/sidecol.aspx?type=sidecol",poststr)
}

function incrementSlideshow(lsDirection) {
    var llUpperBound = parseInt(document.getElementById("slideshow_Upper_Bound").value)
        
    
    if (lsDirection == 'forwards') {
        var llSS0 = parseInt(document.getElementById("slideshow_Current_Count").value) - 2
        var llSS1 = parseInt(document.getElementById("slideshow_Current_Count").value) - 1
        var llSS2 = parseInt(document.getElementById("slideshow_Current_Count").value) + 0
        var llSS3 = parseInt(document.getElementById("slideshow_Current_Count").value) + 1
        var llSS4 = parseInt(document.getElementById("slideshow_Current_Count").value) + 2
        var llSS5 = parseInt(document.getElementById("slideshow_Current_Count").value) + 3
    }
    else {
        var llSS1 = parseInt(document.getElementById("slideshow_Current_Count").value) - 3
        var llSS2 = parseInt(document.getElementById("slideshow_Current_Count").value) - 2
        var llSS3 = parseInt(document.getElementById("slideshow_Current_Count").value) - 1
        var llSS4 = parseInt(document.getElementById("slideshow_Current_Count").value) + 0
        var llSS5 = parseInt(document.getElementById("slideshow_Current_Count").value) + 1
        var llSS0 = parseInt(document.getElementById("slideshow_Current_Count").value) + 2
    }
    
    if ((llSS2 < (llUpperBound - 2)) && (llSS2 >= 2)) {
        document.getElementById("ss_" + llSS0).className = 'slideshow_item_0'
        document.getElementById("ss_" + llSS1).className = 'slideshow_item_1'
        document.getElementById("ss_" + llSS2).className = 'slideshow_item_2'
        document.getElementById("ss_" + llSS3).className = 'slideshow_item_3'
        document.getElementById("ss_" + llSS4).className = 'slideshow_item_4'
        document.getElementById("ss_" + llSS5).className = 'slideshow_item_5'
        
        if (lsDirection == 'forwards') {
            document.getElementById("slideshow_Current_Count").value = parseInt(document.getElementById("slideshow_Current_Count").value) + 1
        }
        else {
            document.getElementById("slideshow_Current_Count").value = parseInt(document.getElementById("slideshow_Current_Count").value) - 1
        }
        
        document.getElementById("slideshow_Current_Item").innerHTML = (parseInt(document.getElementById("slideshow_Current_Count").value) - 2) + " of " + (llUpperBound - 4)
        
    
    }
}


