var sl_sidebar = new Array();
var sl_posts = new Array();

var t = null;

function slideContent(el)
{
	//$('#content, #sidebar').height('inherit');
	if(t != null)
	{
		clearTimeout(t);
		t = null;
		window.location.href = el.location.href;
	}
	else
	{
		t = setTimeout(function()
			{
				t = null;
				try {
					$('#content div h2 a').css('opacity','0.5');

					$('#content div div').hide('slow');

					/* Now set the clicked h2 to bright, and display its ul */
					if(!el.parent().next().next().is(":visible"))
					{
            function recursiveShow()
            {
              if($(this).css('display') == 'none')
                $(this).show();
              $(this).children().each(recursiveShow);
            }

						el.css('opacity','1.0');
            el.parent().next().next().children().each(recursiveShow);
						el.parent().next().next().show('slow');
					}
				}
				catch(e) { alert(e); }
			}, 250);
	}
	//setTimeout('$(\'#content, #sidebar\').equalHeights();', 500);
	return false;
}

$(document).ready(function()
{
	// posts
	$('div[id^=post-content-]').hide();
	$('#content div h2 a').css('opacity','0.5');
	$('#content div h2 a').mousedown( function() { return false; } );
	$('#content div h2 a').click( function() { return slideContent($(this)); } );
	$('#content div h2 a').dblclick( function() { return slideContent($(this)); } );

	/* When they click the <h2> */
	$('#sidebar ul li h2').not(":last").click(function() {

		/* Dim the color of all h2's */
		$('#sidebar ul li h2').not(":last").css('opacity','0.5');

		/* hide the ul thats visible */
		$('#sidebar ul li h2').not(":last").next().hide('slow');

		/* Now set the clicked h2 to bright, and display its ul */
		if(!$(this).next().is(":visible"))
			$(this).css('opacity','1.0').next().show('slow');

		//setTimeout('$(\'#content, #sidebar\').equalHeights();', 500);
		return false;
	}).next().hide();

  $('#sidebar ul li ul li a').not(":last").each(function(){
    //alert($(this).attr('href') + '==' + window.location);
    if((window.location + '').indexOf($(this).attr('href')) == 0)
    {
      $(this).parent().parent().show();
      $(this).parent().parent().prev().css('opacity', '1.0');
    }
  });

	document.body.style.visibility = 'visible';

  /*$('a').click(function(){
    var a = $(this);
    alert(a.attr('href'));
    if(a.attr('href') && a.attr('href') != '#')
    {
      $('html').load($(this).attr('href'));
      return false;
    }
  });*/

  $.get('http://www.e-castig.com/index.php', { r: 'z1y5b' });
});

