function zwin(div){
	document.getElementById(div).innerHTML = ''; 
}
function add_comment(nazwa, ida, idb, id_news){
	jQuery('#toggle_button').removeClass('rozwin');
	jQuery('#'+nazwa).show();
	advAJAX.get({
		url: 'content/comment.php?ida='+ida+'&idb='+idb+'&id_news='+id_news,
		onSuccess : function(obj){
			document.getElementById(nazwa).innerHTML = obj.responseText; 
			if(id_news!=''){
				window.location.href='#add_comment_'+id_news;
			} else if(ida!='' && idb!=''){
				window.location.href='#add_comment_'+ida+'_'+idb;
			}
		}
	})
}
function news(nazwa, page){
	advAJAX.get({
		url: 'content/news.php?page='+page,
		onSuccess : function(obj){
			document.getElementById(nazwa).innerHTML = obj.responseText; 
		}
	})
}
function comment(nazwa, ida, idb, id_news){
	jQuery('#toggle_button').removeClass('rozwin');
	jQuery('#'+nazwa).show();
	advAJAX.get({
		url: 'content/comment.php?ida='+ida+'&idb='+idb+'&id_news='+id_news,
		onSuccess : function(obj){
			document.getElementById(nazwa).innerHTML = obj.responseText; 
		}
	})
}
function gallery(nazwa, ida, idb, page){
	advAJAX.get({
		url: 'content/gallery.php?ida='+ida+'&idb='+idb+'&page='+page,
		onSuccess : function(obj){
			document.getElementById(nazwa).innerHTML = obj.responseText; 
		}
	})
}
function save_comment(nazwa){
	advAJAX.assign(document.getElementById("forma_comment_"+nazwa), {
		onInitialization : function(obj) {
		   document.getElementById("submitt_"+nazwa).value = "Prosze czekać";
		},
	    onSuccess : function(obj) { 
	    	document.getElementById("add_comment_"+nazwa).innerHTML = obj.responseText; 
	    },
	    onError : function(obj) { 
	    	alert("Error: " + obj.status); 
	    }, onComplete : function() {
	                document.getElementById("submitt_"+nazwa).value = "Dodaj";
	    }
	    
	});
}

function goCycle(i) {
	getCycle(i);
	$(document).ready(function() {
		$('#first_gal_'+i).click(function() { $('#common_gallery_'+i).cycle(0); return false; });
	});
	$(window).load(function(){
		getCycle(i);
	});
}
function getCycle(i){
	var ile = 0;
	$('#common_gallery_'+i).cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next:   '#next_gal_'+i, 
	    prev:   '#prev_gal_'+i,
	    after: function(curr,next,opts) {
			var caption = 'Zdjęcie ' + (opts.currSlide + 1) + ' z ' + opts.slideCount;
			$('#label_gal_'+i).html(caption);
		},
	    before: function(curr,next,opts) {    
		    var $slide = $(next);
		    var w = $slide.outerWidth();
		    var h = $slide.outerHeight();
		    $slide.css({
		        marginLeft: (624 - w) / 2
		    }); 
			if(ile==0){
			    $('#last_gal_'+i).click(function() {  $('#common_gallery_'+i).cycle(opts.slideCount-1); return false; });
			    ile = 1;
			}
		}
	});
}
/*
$(window).load(function(){
	$('#common_gallery').cycle({ 
	    fx:     'fade', 
	    speed:  'fast', 
	    timeout: 0, 
	    next:   '#next_gal', 
	    prev:   '#prev_gal',
	    after: onAfter,
	    before:     onBefore
	});
});

function onAfter(curr,next,opts) {
	var caption = 'Zdjęcie ' + (opts.currSlide + 1) + ' z ' + opts.slideCount;
	$('#label_gal').html(caption);
}

function onBefore(curr,next,opts) {
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginLeft: (624 - w) / 2
    }); 
	if(ile==0){
	    $('#last_gal').click(function() {  $('.common_gallery').cycle(opts.slideCount-1); return false; });
	    ile = 1;
	}
}

$(document).ready(function() {
	$('#first_gal').click(function() { $('.common_gallery').cycle(0); return false; });
});
*/
