﻿
$(document).ready(function() {

    $(".leaf-indent").click(function () {
        
        if ($(this).next().is(":hidden") == true) {
            $(this).next().animate({ height: 'show', opacity: 'show' }, 'slow');
            $(".contribute-detail").hide();
           // $(this).next().show();
            
        }
        else {
            //$(this).next().hide();
            $(this).next().animate({ height: 'hide', opacity: 'hide' }, 'slow');
        }
    });

    $(".showbelow").click(function () {

        if ($(this).next().is(":hidden") == true) {
            
            $(this).next().animate({ height: 'show', opacity: 'show' }, 'slow');
            $(".hideme").hide();
            // $(this).next().show();

        }
        else {
            //$(this).next().hide();
            $(this).next().animate({ height: 'hide', opacity: 'hide' }, 'slow');
        }
    });
});

function GoToEditor(doWhat, itemID)
{
      if (itemID != -1)
      {
            location.href = "editor.aspx?dowhat=" + doWhat + "&itemid=" + itemID;
      }
      else
      {
            document.getElementById("errdiv").innerHTML = "Please choose an item to edit";
      }
      
       
}

function GoToEventEditor(doWhat, itemID) {
    if (itemID != -1) {
        location.href = "eventeditor.aspx?dowhat=" + doWhat + "&itemid=" + itemID;
    }
    else {
        document.getElementById("errdiv").innerHTML = "Please choose an item to edit";
    }

}

function ShowTerms() {
    termsString = "<div class=\"breadcrumb\"><ul><li><a href=\"default.aspx\">Home</a></li><li class=\"bc_end\"><span>// Terms and Disclaimer</span></li></ul></div><h3>Terms and Disclaimer</h3><p>All rights, including copyright and database rights are owned by the East Lothian Community Planning Partnership.</p><p>The information including photographs, text and any other material contained within the pages of this website, unless otherwise stated, are copyright protected. All rights are reserved.</p><p>East Lothian Community Planning Partnership seeks to ensure that the information it publishes on its web site is up to date and accurate. However, the information on the web site does not constitute legal or professional advice and the Partnership cannot accept any liability for any loss arising in any way whatsoever out of the use of its site.</p><p>The East Lothian Community Planning Partnership cannot be held responsible for the data policies, procedures or contents of any pages referenced by an external link from its site.</p>";
    document.getElementById("content").innerHTML = termsString;
    return false;
}

function DelNews(newsID) {
    
    if (isNaN(newsID)) {
        alert('please select an item to delete');
        return false;
    }
    
    var answer = confirm("This will delete this news item from the system - this action cannot be undone\n Do you wish to delete?");

    if (answer == 1) {
        location.href = 'news.aspx?del=true&newsID=' + newsID;
        return false;
    } 
    return false;

}

function DelEvent(eventID) {

    if (isNaN(eventID)) {
        alert('please select an item to delete');
        return false;
    }

    var answer = confirm("This will delete this event item from the system - this action cannot be undone\n Do you wish to delete?");

    if (answer == 1) {
        location.href = 'events.aspx?del=true&eventID=' + eventID;
        return false;
    }
    return false;

}

/**/


function DeletePersonForum(forumID, peopleID, roleID) {
    var forID = forumID;
    var peopID = peopleID;
    var rlID = roleID;
    var date = new Date(); var timestamp = date.getTime();
    var mydata = { dowhat: "DeletePersonFromForum", forumID: forID, peopleID: peopID, roleID: rlID, randTime: timestamp };
    
    $.ajax({
        type: "GET",
        url: "../ajax/ajax.aspx",
        data: mydata,
        error: function(msg) {
            alert("error: " + msg);
        },
        success: function(response) {

            if (response != "") {
                $("#adminWrapper").attr("innerHTML", response).show();
            }
            else {
                
                alert('err');
                
            }
        }

    });
}


function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g, "");
}

function Left(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else
        return String(str).substring(0, n);
}
