﻿/// <reference path="jquery-1.2.6-vsdoc.js" />
/// <reference path="jquery-1.2.6.js" />

function swapShowHideImage(control) {
    $(control).attr("src", function() {
        if ($(control).data("state") === "show") {
            $(control).data("state", "hide");
            return "./Images/Buttons/button-hide.gif";
        }
        else {
            $(control).data("state", "show");
            return "./Images/Buttons/button-show.gif";
        }
    });
}

function showHideAll(state) {
    if (state === "hidden") {
        $(".showHideAll").text("hide all").data("state", "shown");
        $(document).find("img.showHide").each(function() {
            $(this).data("state", "show");
            swapShowHideImage(this);
        }).nextAll("p.serviceDescription").show("fast");
    }
    else {
        $(".showHideAll").text("show all").data("state", "hidden");
        $(document).find("img.showHide").each(function() {
            $(this).data("state", "hide");
            swapShowHideImage(this);
        }).nextAll("p.serviceDescription").hide("fast");
    }
}

function getDefaultImage(control) {
    return $(control).data("defaultImage");
}

function setDefaultImage(control, imageName) {
    $(control).attr("src", imageName);
    $(control).data("defaultImage", imageName);
}

function addSwapImage(control, pageName) {
    setDefaultImage($(control), $(control).attr("src"));
    $(control).hover(function() {
        $(this).attr("src", "./Images/Navigation/" + pageName + "-over.gif");
    }, function() {
        $(this).attr("src", getDefaultImage(this));
    });
}
