$(document).ready(function(){
	// Start the timer for the main image loader
//	setInterval( "slideSwitch()", 6000 ); 

    // Animate the Slide boxes 
    $('.post_img,.post_img_l').hover(
		function(){
                        var $box = $(this).find('img').height();
			$(".boxcaption", this).stop().animate(
				{top: $box-$('.boxcaption').height()+"px"},
				{queue:false,duration:300}
			); 
		}, 
		function(){
                        var $box = $(this).find('img').height();
			$(".boxcaption", this).stop().animate(
				{top: $box+"px"},
				{queue:false,duration:200}
			); 
		}  
    ); 

    // Get the Links
    $(".search-content").click(function() { window.location.href=$(this).find(".search-link").html(); });
    $(".cat-outer").click(     function() { window.location.href=$(this).find(".cat-link").html();    });    
    $(".gallery-link").click(  function() { window.location.href=$(this).find(".gal-link").html();    });			    
    $(".index-link").click(    function() { window.location.href=$(this).find("#index-url").html();   });
    $(".main-link").click(     function() { window.location.href=$(this).find("#main-url").html();    });			    			     
    
	// Bind Search Box Background Color
    $("#search #s").focus(function(){ $(this).css('background-color','#FFFFFF');});
    $("#search #s").blur( function(){ $(this).css('background-color','#DDDDDD');}); 
    
    // Sidebard Caption boxes
    $('.gal_img, .about_img, .index_img').hover(
		function(){ $(".caption", this).stop().animate({top:'0px', left:'0px'},{queue:false,duration:300}); }, 
		function(){ $(".caption", this).stop().animate({top:'500px', left:'500px'},{queue:false,duration:500});     }
	);

	// Bind Post img to Light Box
	$('.post_lb').lightBox({fixedNavigation:true});

	// Gallery images
	$('.slide_img').fadeIn('slow', function() {$(this).css({'opacity' : '1.0', 'filter' : 'alpha(opacity=100)'}); });
});

// Function for loading images on the main page
function slideSwitch() {
    $.ajax({
	    cache: false,
		type: "GET",
		url: "<?php echo bloginfo('url'); ?>/random",
		dataType: 'html',
		success: function(data){ 
			$('.slide_img').fadeOut(2000,function(){ $(this).html(data); })
			$('.slide_img').fadeIn(2000,function(){});								 
		}
	});
}
