/*
Library: Static.js
Theme URI: http://www.congresovisible.org
Description: Congreso Visible Páginas Estáticas
Version: 1.0
Author: http://www.monoku.com

Creada : 16.01.10
Modificada : 16.01.10
*/
$(function(){
	var hijos=$(".static-content .content").children();
	var ultimoh3;
	for ( var i = 0; i < hijos.length; i++) {
		ultimoh3=$("<li>").html($(hijos[i]).html());
		if($(hijos[i]).is("h3")){
			setScroll(ultimoh3,hijos[i]);
			$("#submenustatic ul.f").append(ultimoh3);
			if($(hijos[i]).prev().is("p") && $(hijos[i]).prev().text().length > 10){
				$(hijos[i]).prev().append($("<a>").html("Ir arriba &#8593;").addClass("top").click(function(event){		
					$.scrollTo(0,800);
				}));
			}
		}
		if($(hijos[i]).is("h4")){
			setScroll(ultimoh3,hijos[i]);
			if($("#submenustatic ul.f>li:last ul").length==0){
				$("#submenustatic ul.f>li:last").append($("<ul>").addClass("s"));
			}
			$("#submenustatic ul.f>li:last ul").append(ultimoh3);
		}
	}
	$(".static-content .content p:last").append($("<a>").html("Ir arriba &#8593;").addClass("top").click(function(event){		
		$.scrollTo(0,800);
	}));
	if($(".static-content h3").length==0 && $(".static-content h4").length==0){
		$(".content").width(870);
	}
});
function setScroll(source, destino){
	$(source).click(function(event){		
		$.scrollTo($(destino),800);
		event.stopPropagation();
	});
}
