$(document).ready(
	function() {
		try {
			tabs("dwojka");
		}
		catch(exc) {}
		try {
			qtabs("trojka");
		}
		catch(exc) {}
	}
);

function tabs(id) {
//	$("#"+id+" h3:first.tab a").addClass("active");	
//	$("#"+id+" div.tab_content").not(":first").hide();

	$("#"+id+" h3.tab a").click(function() {
		var licznik = $("#"+id+" h3 *").index(this);
		$("#"+id+" h3.tab a").removeClass("active");
		$(this).addClass("active");

		$("#"+id+" div:visible.tab_content").hide();
		$("#"+id+" div.tab_content").eq(licznik).show();

		return false;
		}
	);
}

function qtabs(id) {
	$("#"+id+" div.long_box").not(":first").hide();
	
	$("#"+id+" h3.tab a").click(function() {
		if ($(this).hasClass('active'))
			return false;
		var licznik = $("#"+id+" h3 *").index(this);
		$("#"+id+" h3.tab a").toggleClass("active");

		$("#"+id+" div:visible.tab_content").hide();
		$("#"+id+" div.tab_content").eq(licznik % 2).show();
		return false;

		}
	);
}

function hideOther(div) {
	if($('.' + div + ' ul').is(':visible')) {
		$('.' + div + ' ul').slideUp('slow');
		$('.' + div + ' .slide').html('Rozwiń &gt;');
	}
	else {
		$('.' + div + ' ul').slideDown('slow');
		$('.' + div + ' .slide').html('Zwiń &gt;');
	}
	return false;
}
function reloadOther(element, box) {
	$(box).fadeOut();
	$(element).addClass('animate');
	$.ajax({
		type: "POST",
		url: $(element).attr('href'),
		data: { ajax : 1},
			success: function(msg) {
				$(box).html(msg);
				$(box).fadeIn();
				$(box).parents('.other_questions').find('.slide').html('Zwiń &gt;');
				$(element).removeClass('animate');
		}
	});
	return false;
}

$(document).ready(function() {
	$('.other_questions .slide').click(function() { return hideOther('other_questions'); });
	$('.other_questions .reload').click(function() { return reloadOther('.other_questions .reload', '.other_questions ul'); });
});

$(document).ready(function() {
	$('#q_add_details').click(function() {
		if ($('.examples').hasClass('examples_more')) {
			$('.examples').removeClass('examples_more');
			$(this).html('Pokaż szczegóły');
		
		}
		else {
			$('.examples').addClass('examples_more');
			$(this).html('Ukryj szczegóły');
		}
		return false;
	});
	
	$(".examples input").change(function(){
		if ($(this).val() == 'C') {
			$('.q_add_form .answers span').html('Wielokrotny wybór - wpisz odpowiedzi w osobnych wierszach');
			$('.q_add_form .answers').slideDown();
		}
		else if ($(this).val() == 'R') {
			$('.q_add_form .answers span').html('Jedna z wielu - wpisz odpowiedzi w osobnych wierszach');
			$('.q_add_form .answers').slideDown();
		}
		else 
			$('.q_add_form .answers').slideUp();		
	});


});


