﻿$(document).ready(function() {

    $(".moreOrLess").click(function() {

        switch (this.innerHTML) {

            case "More...":
                $("#div" + this.id).show("fast");
                this.innerHTML = "...Less"
                this.parentNode.parentNode.style.borderLeft = "1px dotted #ccc";
                this.parentNode.style.borderBottom = "1px dotted #ccc";
                this.parentNode.style.borderLeft = "1px dotted #ccc";
                this.parentNode.style.borderRight = "1px dotted #ccc";
                this.parentNode.style.width = "130px";
                this.parentNode.style.marginLeft = "-6px";
                this.parentNode.style.paddingLeft = "4px";
                this.style.font = "bold 11px arial";
                this.style.color = "#000";
                break;

            case "...Less":
                this.innerHTML = "More..."
                this.parentNode.parentNode.style.borderLeft = "0px";
                this.parentNode.style.borderBottom = "0px";
                this.parentNode.style.borderLeft = "0px";
                this.parentNode.style.borderRight = "0px";
                this.parentNode.style.width = "130px";
                this.parentNode.style.marginLeft = "-6px";
                this.parentNode.style.paddingLeft = "4px";
                this.style.font = "normal 11px arial";
                this.style.color = "#666";
                $("#div" + this.id).hide("fast");
                break;
        }
    });
});

// Calls a webservice to get the html for the Learn More PopUp
function ShowLearnMorePopUp(divID, popUpID, winnowingAttributeID) {
 
    //ship everything off to the webservice
    FoodServiceWarehouse.WebServices.WinnowingLocalService.GetWinnowingAttributeOverriddenAttributeDescription(divID, popUpID, winnowingAttributeID, ShowLearnMorePopUpCallback);
}

// Hit via the webservice to fill the Learn More PopUp
function ShowLearnMorePopUpCallback(result, eventArgs) {

    // Get the controls
    var theDiv = document.getElementById(result[0]);
    var thePopUp = document.getElementById(result[1]);

    //  set the HTML in the DIV
    theDiv.innerHTML = result[2];

    // Position
    theDiv.Left = (screen.width / 2);

    // turn the popUp to visible
    thePopUp.style.display = "block";
}

function HideLearnMorePopUp(popUpID) {
    document.getElementById(popUpID).style.display = 'none';
}

// Used for showing/hiding header
function toggleHeader(element) {
    var headers = $("span[id$=lblHeaderPart2]");
    if (headers.css("display") == "none") {
        headers.show("fast");
        headers.next().text("Hide this Content");
    }
    else {
        headers.hide("fast");
        headers.next().text("Read More");
    }
}