﻿$(function()
{
    // Hide paragraphs until expanded
    $('ul#serviceList > li > p').hide();

    var config =
    {
        sensitivity: 7,
        interval: 1,
        over: serviceListOver,
        timeout: 1,
        out: serviceListOut
    };
    
    // Add bottom padding after the last list element
    $('ul#serviceList').append('<div style="display:block; height: 30px"></div>');

    $('ul#serviceList li h3').hoverIntent(config);
    
    function serviceListOver()
    {
        $(this).css(
        {
            'cursor' : 'pointer', 
            'border-bottom' : '1px solid white',
            'margin-bottom' : '-1px'
        });
    }
    
    function serviceListOut()
    {
        $(this).css(
        {
            'cursor' : 'auto', 
            'border-bottom' : '0',
            'margin-bottom' : '0'
        });
    }
    
    $('ul#serviceList li h3').click(function()
    {        
        if ($(this).siblings().css('display') == "none")
        {
            $('ul#serviceList > li > p').slideUp(200, setupScroll);
            $('ul#serviceList > li > h3').css(
            {
                'background' : 'transparent url("_images/main/rightArrow.png") 2px 12px no-repeat'
            });
            
            $(this).siblings().slideDown(200, setupScroll);
            $(this).css(
            {
                'background' : 'transparent url("_images/main/downArrow.png") 0 15px no-repeat'
            });
        }
        else
        {
            $(this).siblings().slideUp(200, setupScroll);
            $(this).css(
            {
                'background' : 'transparent url("_images/main/rightArrow.png") 2px 12px no-repeat'
            });
        }
    });
    
    var timeOutID = 0;
    
    function setupScroll()
    {
        var scrollOptions =
            {
                'showArrows': true,
                'arrowSize': 15,
                'wheelSpeed': 30,
                'scrollbarWidth': 10
            };
        $('ul#serviceList').jScrollPane(scrollOptions);
        
        $('.jScrollPaneDrag').css('background-image','url(\'/v1/_images/projects/scrollBar.gif\')');
        $('a.jScrollArrowUp').css('background-image','url(\'/v1/_images/projects/upArrow.png\')');
        $('a.jScrollArrowDown').css('background-image','url(\'/v1/_images/projects/downArrow.png\')');
    }
});