// For toggling input boxes
jQuery.fn.toggleVal=function(focusClass){this.each(function(){$(this).focus(function()
{if($(this).val()==this.defaultValue){$(this).val("")}if(focusClass)
{$(this).addClass(focusClass)}}).blur(function(){if($(this).val()=="")
{$(this).val(this.defaultValue)}if(focusClass){$(this).removeClass(focusClass)}})})}

$(document).ready(function(){

	// Toggle the value of an input or textarea on focus
	$(".toggle").toggleVal("active");

	$('#nav li:last a').css('borderRight', 'none').css('paddingRight', '0');
	$('#nav ul li:last a').css('borderRight', 'none');
	
	$('#sidebar img.fade').hover(function(){
		$('#sidebar img.fade').not($(this)).stop().animate({opacity:0.3}, 'slow');
	}, function(){
		$('#sidebar img.fade').not($(this)).stop().animate({opacity:1}, 'slow');
	});
	
	$('#sidebar img.fadedetails').hover(function(){
		$('#sidebar img.fadedetails').stop().animate({opacity:1}, 'slow');
		$('#sidebar img.fadedetails').not($(this)).not('.current_post').stop().animate({opacity:0.3}, 'slow');
	}, function(){
		$('#sidebar img.fadedetails').not('.current_post').stop().animate({opacity:0.3}, 'slow');
	});
	
	// For Lightbox
	$(".fancybox").fancybox(
		{'titleShow': true,
		'titlePosition':'inside',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic'}
	);	
	
	// For dropdown menu to work in older IE versions
	$("ul.dropdown li").dropdown();
	
});

$.fn.dropdown = function() {
	if($(this).parent().hasClass("currentcat")) return false;
	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});
}
