jQuery(document).ready(function($) {
	$('a[rel*=facebox]').facebox();
	$.facebox.settings.opacity = 0.4;
	$('.lightboxGallery').each(function() {
		$('.lightbox', this).lightBox({fixedNavigation:true,txtImage:'Imagen',txtOf: 'de'});
	});
	
	// Tags
	$('#apariencia').toggle(function() {
		$("#tags ul").hide().addClass("alt").fadeIn("fast");
	}, function() {
		$("#tags ul").hide().removeClass("alt").fadeIn("fast");
	});		
	$('#importancia').toggle(function() {
		$("#tags ul li").tsort({order:"desc",attr:"class"});	
	}, function() {
		$("#tags ul li").tsort({order:"asc",attr:"class"});
	});	
	$('#abc').toggle(function() {
		$("#tags ul li").tsort({order:"asc"});
	}, function() {
		$("#tags ul li").tsort({order:"desc"});
	});	
	
	// Sólo aquellos atributos rel con valor fade sobre los elementos select y a producirán fundido sobre el contenedor contenido
	$('select').change(function() {
		if ($(this).attr('rel') == "fade") {
			$('#contenido').animate({
				height: 'hide', 
				opacity: 'hide'
			}, 'fast', function() {
				$("#contenido").animate({ height: 'show', opacity: 'show' }, 'fast');
			});
		}
	});	
	$('a').click(function() {
		if ($(this).attr('rel') == "fade") {
			$('#contenido').animate({
				height: 'hide', 
				opacity: 'hide'
			}, 'fast', function() {
				$("#contenido").animate({ height: 'show', opacity: 'show' }, 'fast');
			});
		}
	});	
	
})

function moveCloseLink() {
	var cb=document.getElementById('sb-nav-close');
	var tb=document.getElementById('sb-title'); 
	if(tb) tb.appendChild(cb); 
} 


Shadowbox.init({
	players:    ["html","iframe"],
	handleOversize: "resize",
	showOverlay: false, 
	slideshowDelay: 4, 
	viewportPadding: 20, 
	skipSetup: false,
	language: 'es',
	autoplayMovies: true,
	onOpen: moveCloseLink
});
function abrirSB(url,titulo) {
	Shadowbox.open({player: "iframe", content: url, title: titulo, height: 570 , width: 850});
}; 

/* input_id is the ID of the input element */
/* container_class will let you control the text input background color and padding */
/* border_class will let you control the border color */
function roundInput(input_id, container_class, border_class) {
	var input = $('#'+input_id+'');
	var input_width = input.css("width"); //get the width of input
	var wrap_width = parseInt(input_width) + 10; //add 10 for padding
	wrapper = input.wrap("<div class='"+container_class+"'></div>").parent();
	wrapper.wrap("<div class='"+border_class+"' style='width: "+wrap_width+"px;'></div>"); //apply border
	wrapper.corner("round 8px").parent().css('padding', '2px').corner("round 10px"); //round box and border
}
$(document).ready(function() {
	$("form input.input_redondeado, form textarea.input_redondeado, form select.input_redondeado").each(function(){
		roundInput($(this).attr('id'),'contenido_redondeado','borde_redondeado');
    });
});

