jQuery.noConflict();

function katAlfaCallback(data){
	jQuery("#menu-kat div.alfa").append(data);
}

jQuery(document).ready(function(){

	var menuKat = jQuery("#menu-kat");

	//przyciski do zmiany menu (tree/alfa)
	menuKat.find("p.title a").click(function(){
		menuKat.attr('class', jQuery(this).attr('class'));
		return false;
	});

	jQuery("#nav-tree").treeview({
		animated: "fast",
		//persist: "location",
		persist: "cookie",
		collapsed: true,
		unique: true
	//	toggle: function() { window.console && console.log("%o was toggled", this); }
	});

	//dodaj akcje do liter w alfa
	menuKat.find("p.letters a[href='#']").click(function(){
		var letter = jQuery.trim(jQuery(this).text().replace(/[\[\]]/g, '')),
			node = null;
		nodes = menuKat.find("ul#kat_alfa_"+letter);
		jQuery("#menu-kat div.alfa ul.alfa").hide();
		if(nodes.length){
			//console.log('juz jest "'+letter+'"');
			nodes.show();
		}
		else {
			//console.log('nie ma "'+letter+'" -> zaladuj');
			jQuery.get("ajax/kat_alfa.php?letter="+letter, katAlfaCallback);
		}
		return false;
	});

	var domain=(location.host==='localhost')?'localhost/biall.com.pl':location.host;
	jQuery('a.lightbox').each(function(){
		jQuery(this).lightBox({
			overlayBgColor:'#000',
			overlayOpacity:0.7,
			imageLoading:'http://'+domain+'/images/lightbox/loading.gif',
			imageBtnClose:'http://'+domain+'/images/lightbox/close.gif',
			imageBtnPrev:'http://'+domain+'/images/lightbox/prev.gif',
			imageBtnNext:'http://'+domain+'/images/lightbox/next.gif',
			imageBlank:'http://'+domain+'/images/lightbox/blank.gif',
			containerResizeSpeed:350,
			txtImage:'Obrazek',
			txtOf:'z'
		});
	});
	jQuery('span.gallery').each(function(){
		jQuery(this).find('a.lightbox').lightBox({
			overlayBgColor:'#000',
			overlayOpacity:0.7,
			imageLoading:'http://'+domain+'/images/lightbox/loading.gif',
			imageBtnClose:'http://'+domain+'/images/lightbox/close.gif',
			imageBtnPrev:'http://'+domain+'/images/lightbox/prev.gif',
			imageBtnNext:'http://'+domain+'/images/lightbox/next.gif',
			imageBlank:'http://'+domain+'/images/lightbox/blank.gif',
			containerResizeSpeed:350,
			txtImage:'Obrazek',
			txtOf:'z'
		});
	});


	jQuery('#search_fraza').click(function(){
		if (jQuery(this).val()!=='') jQuery(this).val('');
	});

});


