// #@(#)sliding_panels.js	1.1 15:40:23,08/11/20 (yy/mm/dd)
/**
 * @author Mark.Kennard
 */
$(document).ready(function(){
 // find each panel that contains hidden content and append it with the expand link image..
    $('.sliderIcons').each(function(){
        $(this).prepend('<span class="panelLink"><a href="#" class="expandLink"><img src="images/expand_icon.gif" border="0" /></a></span>')
    })
  
    $('.expandLink').click(function(event){
    var strGrowPanel = $(this).parent().parent().parent().parent().parent().attr('class')
        var strShrinkPanel = '';
        var intShrinkSpeed;
        var intGrowSpeed;
        $(this).parent().parent().parent().find('.expandLink').hide()
        $(this).parent().parent().parent().find('.expandLink').css('margin-right', '40px')
        // This is for left hand panel events....
        if (strGrowPanel === 'panel_left') {
            strShrinkPanel = '.panel_right';
            intShrinkSpeed = 200;
            intGrowSpeed = 300;
            $(this).parent().parent().parent().parent().parent().parent().find(strShrinkPanel).animate({
                width: '0px',
                left: '600px'
            }, intShrinkSpeed);
            $(this).parent().parent().parent().parent().parent().animate({
                width: "600px",
                left: '0px'
            }, intGrowSpeed);
        }else {
            strShrinkPanel = '.panel_left'
            intShrinkSpeed = 200
            intGrowSpeed = 300
            
            $(this).parent().parent().parent().parent().parent().parent().find(strShrinkPanel).animate({
                width: '0px'
            
            }, intShrinkSpeed);
            
            $(this).parent().parent().parent().parent().parent().animate({
                width: '600px',
                left: '0px'
            }, intGrowSpeed);
        }
        $(this).parent().parent().find('img').show()
        event.preventDefault()
    });
    $('img.shrinkIcon').click(function(event){
        $(this).hide();
        var strShrinkBack = $(this).parent().parent().parent().parent().attr('class')
        
        
        if (strShrinkBack === 'panel_left') {
        
            $(this).parent().parent().parent().parent().parent().parent().find('.panel_left').animate({
                width: '290px'
            
            }, 200);
            $(this).parent().parent().parent().parent().parent().parent().find('.expandLink').show()
            $(this).parent().parent().parent().parent().parent().parent().find('.panel_right').animate({
                width: '290px',
                left: '320px'
            }, 300);
            
        }
        else {
        
            $(this).parent().parent().parent().parent().parent().parent().find('.panel_right').animate({
                width: '290px'
            
            }, 200);
            $(this).parent().parent().parent().parent().parent().parent().find('.expandLink').show()
            $(this).parent().parent().parent().parent().parent().parent().find('.panel_left').animate({
                width: '290px',
                left: '320px'
            }, 300);
            
        }
        
    })
    
})

