function substr_count (haystack, needle, offset, length) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Onno Marsman
 
    var pos = 0, cnt = 0;
 
    haystack += '';
    needle += '';
    if (isNaN(offset)) {offset = 0;}
    if (isNaN(length)) {length = 0;}
    offset--;
 
    while ((offset = haystack.indexOf(needle, offset+1)) != -1){
        if (length > 0 && (offset+needle.length) > length){
            return false;
        } else{
            cnt++;
        }
    }
 
    return cnt;
}

$(function() {
    $(".fauxlink").each(function() {
        $(".hidden", $(this).parent()).hide();
        $(this).click(function(event) {
            event.preventDefault(); $(".hidden", $(this).parent()).toggle();
            if (substr_count($(this).attr("title"), "show")) {
                $(this).attr("title", $(this).attr("title").replace("show", "hide"));
            } else {
                $(this).attr("title", $(this).attr("title").replace("hide", "show"));
            }
        });
    });
});
