$(function() {
	if($("#pics").length > 0) {
		$('#pics').before('<div id="nav">').cycle({
			fx:     'fade',
			speed:  700,
			timeout: 5000,
			pager:  '#nav',
			next: '#pics'
		});
	}
	
	$("#login").tabs();
	
	if($("#abc").length > 0 && window.location.href.match("#")) {
		var c = window.location.href.substring(window.location.href.lastIndexOf('#')).substr(1);
		$("#"+c+"").addClass("active");
		getwords(c);
	}
	$("#abc li a").click(function(event) {
		event.preventDefault();
		$("#abc li").each(function() {
			$(this).children().removeClass("active");
		});
		var c = ($(this).attr("href").substr(1));
		$("#"+c+"").addClass("active");
		getwords(c);
	});
	
	$(".galleryitem").fancybox({
		'transitionIn':	'elastic',
		'transitionOut':	'elastic',
		'easingIn': 'swing',
		'speedIn':	300, 
		'speedOut':	200, 
		'overlayShow':	false,
		'cyclic': true,
		'titleShow': true,
		'titlePosition': 'over'
	});
	
});

function getwords(startswith) {
	$.ajax({ 
		type: "POST", 
		url: "/content/themes/szolvegy/panel-lexikon.php", 
		data: "c="+startswith,
		beforeSend: function() { 
			$('#results').html('<span class=\"loading\">Betöltés...</span>'); 
		},
		success: function(data) { 
			$("#results").empty().show();
			$("#results").append(data); 
		}
	});
}
