$(function()
{
    $("#admin-actions").livequery(function() { $(this).hide() });
    $("#category_cloud").livequery(function() { $(this).hide() });
    $("#archives").livequery(function() { $(this).hide() });
    $(".reader-publisher-module > ul, .f").livequery(function() { $(this).hide() });
    $(".reader-publisher-module > ul > li > a").livequery(function() { $(this).attr( "target", "_blank" ) });
    $("#twitter_update_list > li > a").livequery(function() { $(this).attr( "target", "_blank" ) });
    $(".reader-publisher-module > h3").livequery(function()
    {
        $(this).addClass( "collapsed-panel-title" );
        $(this).attr( "title", "My 10 most recent Google Reader shared items" );
        $(this).click(function() { ToggleSidebarBlock( $(this), $(".reader-publisher-module > ul, .f") ) });
    });
    
    $("#camera-phone-photos-feed").mouseover(function()
    {
        $("#CameraPhonePhotos")
            .animate({ opacity: "0.1" }, 500)
            .animate({ opacity: "1.0" }, 500);
    });
    
    $("#google-reader-shared-items-feed").mouseover(function()
    {
        $(".reader-publisher-module")
            .animate({ opacity: "0.1" }, 500)
            .animate({ opacity: "1.0" }, 500);
    });
    
    $("#sidebar").livequery(function() { $(this).fadeIn() });
    
    $("a[@href *= '.jpg'], a[@href *= '.png'], a[@href *= '.gif']").livequery(function()
    {
        $(this).lightBox();
    });
    
    SaveTheDevelopers();
});

function ToggleSidebarBlock( header, block )
{
	if( $(block).is(":visible") )
	{
		$(block).slideUp();
		$(header).removeClass( "expanded-panel-title" ).addClass( "collapsed-panel-title" );
	}
	else
	{
		$(block).slideDown();
		$(header).removeClass( "collapsed-panel-title" ).addClass( "expanded-panel-title" );
	}
}

function SaveTheDevelopers()
{
	var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
	if(IE6)
	{
		var now = new Date();
		var time = now.getTime();
		var div = document.createElement('a');
		var id = 'saynotoie6_div_' + time;
		div.setAttribute('id',id);
		div.setAttribute('href','http://www.savethedevelopers.org/');
		div.setAttribute('target','_blank');
		div.style.display = 'block';
		div.style.color = '#1d1d1d';
		div.style.textAlign = 'left';
		div.style.fontFamily = 'Arial';
		div.style.fontSize = '11px';
		div.style.background = 'url(images/SaveTheDevelopers.gif)';
		div.style.padding = '0';
		div.style.position = 'absolute';
		div.style.top = '0';
		// div.style.right = '40px';
		div.style.right = document.documentElement.clientWidth / 2 - 150 + 'px';
		div.style.zIndex = '999999';
		div.style.width = '330px';
		div.style.height = '63px';
		div.style.marginTop = '-80px';
		div.style.filter = 'alpha(opacity=95)';
		document.body.appendChild(div);
		
		var animate = function()
		{
			var myDiv = document.getElementById(id);
			var value = parseInt(myDiv.style.marginTop)
			myDiv.style.marginTop = value + 1 + 'px';
			if(parseInt(myDiv.style.marginTop) < -1)
			{
				var timer = setTimeout(animate,30 * 80/Math.abs(value) * .27);
			}
			else
			{
				var timer = setTimeout(hide,15000);
			}
		}
		
		var hide = function()
		{
			var myDiv = document.getElementById(id);
			var value = parseInt(myDiv.style.marginTop)
			myDiv.style.marginTop = value - 1 + 'px';
			if(parseInt(myDiv.style.marginTop) > -80)
			{
				var timer = setTimeout(hide,1.4 * 80/Math.abs(value) * 3.70);
			}
		}
		
		setTimeout(animate,1000);
	}
}
