$(document).ready(function() {
    //grid click
    if ($('div#calendar table.list a.title')) {
        $('div#calendar table.list a.title').parent('td').click(function() { window.location = $(this).find('a.title').attr('href'); return false; });
    }
    $('div#calendar table.list td').css({ cursor: 'pointer' });
    //grid hover
    $('div#calendar table.list td').hover(function() {
        $(this).parent('tr').children('td:first').find('a.title, span.hide, span.show').css({ 'background-position': '0 -80px', 'color': '#061caf' });
        $(this).parent('tr').children('td').animate({ backgroundColor: '#e7effd' }, 'fast');
    }
		, function() {
		    $(this).parent('tr').children('td:first').find('a.title, span.hide, span.show').css({ 'background-position': '0 0', 'color': '#2655d3' });
		    $(this).parent('tr').children('td').animate({ backgroundColor: '#c6d8f7' }, 'fast');
		})
    //info init
    CLASSSWITCH($('div#calendar table.list div.show'), 'show', 'hide');
    //info click
    if ($('div#calendar table.list span.hide, div#calendar table.list span.show')) {
		//if ($('div#calendar table.list span.hide')) {
        $('div#calendar table.list td').bind('click', function() {
            _listspan = $(this).children('span.hide');
            _listtd = $(this);
            _listdiv = _listtd.children('div');
            //if(document.getElementById("divexpand")!=null)
            //	alert(document.getElementById("divexpand").style.display);
            //	alert(_listdiv.attr('class'));
            if (_listdiv.attr('class') == 'hide') {
                _listdiv.css({ 'height': 'auto', 'display': 'block' });
                _listheight = _listdiv.height();
                _listdiv.css({ 'height': '0' });
                CLASSSWITCH(_listspan, 'hide', 'show');
                CLASSSWITCH(_listtd, 'hide', 'show');
                _listdiv.animate({ 'height': _listheight }, 'fast');
                CLASSSWITCH(_listdiv, 'hide', 'show');
            }
            //else if (document.getElementById("divexpand") != null && document.getElementById("divexpand").style.display == "block") {
                //alert(this.);
                //return false;
                //_listdiv.attr('class') = 'show';
           // }
            else {
                _listdiv.animate({ 'height': 0 }, 'fast', function() {
                    CLASSSWITCH(_listspan, 'show', 'hide');
                    CLASSSWITCH(_listtd, 'show', 'hide');
                    CLASSSWITCH(_listdiv, 'show', 'hide');
                    _listdiv.css({ 'display': 'none' });
                })
            }
        })
    }

    //else if(document.getElementById("divexpand").style.display)

})

function CLASSSWITCH(_classthis, _classremove, _classadd) { _classthis.removeClass(_classremove).addClass(_classadd); }
