var template_directory = "http://yaestabaregistrado.com.s76945.gridserver.com/wp-content/themes/YER/";

$(document).ready(function(){

	   
	 $("#nav>li:nth-child(2)>a").attr("id", "nav-trailer").parents("li").next().find("a").attr("id", "nav-jpg").parents("li").next().find("a").attr("id", "nav-script").parents("li").next().find("a").attr("id", "nav-sonido").parents("li").next().find("a").attr("id", "nav-linkografia").parents("li").next().find("a").attr("id", "nav-notas");
	 	 
	 $("#otrasentregas").find("ul").hide().end().find("h2").css("cursor", "pointer").append("<img src='" + template_directory + "images/bajar.gif' alt='Bajar' style='padding-left:10px;' />").click(function () { $(this).parents("#otrasentregas").find("ul").slideToggle("fast"); });
	 $("#otrasentregas ul").hide();
	 $("#otrasentregas h2").wrapInner("<span></span>");
	 	 	 
	 	 
$(".sonidopost:nth-child(odd)").addClass("odd");

 /* Manejador de popups */
	
	$("<div id='mask'></div><div id='popup'></div>").appendTo("body").hide();
	 
	$("#sidebarseguinos a, #navlogin, #navregistro, #navseguinos").click(function() {
		var maskHeight = $(document).height();   
		var maskWidth = $(document).width();
		var url = $(this).attr("href");
		var section = $(this).attr("title");
		$('#mask').css('width',maskWidth);
		$('#mask').css('height',maskHeight);
		$('#mask').show();
		$("#popup").css("left", $(document).width() / 2 - 480).html("").append("<div></div>").find("div").load(url + " #" + section, function() { $("#popup h2").append('<img src="' + template_directory + 'images/close.gif" class="closebutton" alt="Cerrar" />'); $(".closebutton").click(function () {$("#popup").hide(); $("#mask").hide(); $("object").show(); $("embed").show();}); } ).end().show();
		$("object").hide();
		$("embed").hide();
		return false;
	});
	
	
	$("#creado a, #acercade a").click(function() {
		var maskHeight = $(document).height();   
		var maskWidth = $(document).width();
		var url = $(this).attr("href");
		var section = "authorpopup";
		$('#mask').css('width',maskWidth);
		$('#mask').css('height',maskHeight);
		$('#mask').show();
		$("#popup").css("left", $(document).width() / 2 - 480).html("").append("<div></div>").find("div").load(url + " ." + section, function() { $("#popup h2").append('<img src="' + template_directory + 'images/close.gif" class="closebutton" alt="Cerrar" />'); $(".closebutton").click(function () {$("#popup").hide(); $("#mask").hide(); $("object").show(); $("embed").show();}); } ).end().show();
		$("object").hide();
		$("embed").hide();
		return false;
	});
	
	/* FIN POPUPS */
	
$(".otropost").hide();
$(".vermas.show .otropost").show();
$(".vermas h2").css("cursor","pointer").click(function() { $(".otropost").toggle(); });
	
$(".comment:nth-child(3)").before("<p id='toggleComments'>Ver todos</p>");
$(".comment:nth-child(2) ~ .comment").hide();
$("#toggleComments").css("cursor","pointer").click(function () { jQuery(this).text(jQuery(this).text() == "Ver todos" ? "Ver menos" : "Ver todos"); $("#toggleComments ~ .comment").toggle("fast");  });
$("#firma").hide();
$(".logged #commenttextarea").append("<span>FIRMA</span>").find("span").css("cursor","pointer").click(function() { $("#firma").toggle("fast"); });;

$("#submit").after("<span id='previewbutton'>Vista previa</span>");

$("#respond").before("<div id='preview-box'></div>");
$("#preview-box").hide()
   
   var $comment = ''; // that's two single quotation-marks at the end
   $('#previewbutton').click(function() {
	 $comment = $("#comment").val();
	 $comment = $comment.replace(/\n/g, "<br />")
       .replace(/\n\n+/g, '<br /><br />');
	 $('#preview-box').show().html( $comment );
	 $("#respond").hide();
	});
$('#preview-box').click( function () {$(this).hide(); $("#respond").show() } );

//$("#share div").hide();
//$("#sharebutton").click(function() { $("#share div").toggle("fast"); });


 });
