jQuery(document).ready(function($) {


 // FORMULARIO DE COMENTARIOS
 
   	var top = $('#comments_form').offset().top - parseFloat($('#comments_form').css('marginTop').replace(/auto/, 0));
 
 	$(window).scroll(function (event) {
 		var y = $(this).scrollTop();
 		if ( y >= top ) {
 			$('#comments_form').addClass('fixed');
 		} else {
 			$('#comments_form').removeClass('fixed');
 		}
 	}); 	

 // ORNAMENTOS DE LOS TITULOS
 
   	$('h2.neutral span').each(function(){
  		var ornNum = Math.floor(Math.random() * 14);
  		$(this).css({ background : 'transparent url(http://derberalbicker.com/wp-content/themes/ComoD/i/orn' + ornNum + '.png) no-repeat right -113px' });
  	});

 // ORNAMENTO GRANDE
 
	$('h2#comod a').hover(function(){
		var backNum = Math.floor(Math.random() * 4);
		if (backNum == 0) { backNum = '-72px'; }
		if (backNum == 1) { backNum = '-189px'; }
		if (backNum == 2) { backNum = '-306px'; }
		if (backNum == 3) { backNum = '-423px'; }
		$(this).css({ backgroundPosition: '5px ' + backNum });
	}, function(){
		$(this).css({ backgroundPosition: '5px 45px' });
	});
  	
 // COLORES DE LOS LINKS AL AZAR
 
 	$(".post p a:not(.image)").each(function(){
 		$(this).hover(function(){
 			var colNum = Math.floor(Math.random() * 4);
 			if (colNum == 0) { var colorHover = '#ec3d4d'; }
 			if (colNum == 1) { var colorHover = '#fe773d'; }
 			if (colNum == 2) { var colorHover = '#feb73b'; }
 			if (colNum == 3) { var colorHover = '#67b079'; }
 			$(this).css({ backgroundColor : colorHover });
		},function(){
			$(this).css({ backgroundColor : 'transparent' });
		});
 	});

 // TOGGLE

	$("div.toggle > div").each(function(){
		$(this).hover(function(){
			$(this).stop().find("p").toggle(300);
		},function(){
			$(this).stop().find("p").toggle(300);
		});
	});
	
 // FANCYAPP
	
	$("a.image").fancybox({
		'hideOnContentClick': true,
		'zoomSpeedIn' : 300,
		'zoomSpeedOut' : 300,
		'padding' : 10,
		'overlayOpacity' : 0.5,
		'centerOnScroll' : true
	});
	
});