﻿// RESET ALL
function resetAll()
{
    $(".full").slideUp();
    $(".intro").slideDown();
}



// CHECK ANCHOR
function checkAnchor()
{
    var url = new String(document.location);
    var position = url.search("#");
    
    if (position > 0)
    {
        var size = url.length - position;
        anchor = String(url.substr(position + 1, size - 1));
        
        selecteditem = $('a[title="' + anchor + '"]');
        openItem(selecteditem);            
    }
}



// OPEN ITEM
function openItem(item)
{
    resetAll();
    item.parent().parent().parent().children(".full").slideDown();
    item.parent().parent().parent().children(".intro").slideUp();
}


// ON PAGE LOAD
$(document).ready(
    function()
    {
        // start fresh
        $(".full").hide();
        $(".intro").show();
        
        // on readmore click
        $("a.readmore").click(
            function(event)
            {
                openItem($(this));
            }
        );
        
        // if anchor present
        checkAnchor();
    }
);
