

function adSearch() {
	var pager = $("div.pager form");	
			$("#search").toggleClass("sAdvBg");
	$("#aS").toggleClass("sAdvBg");
	if ($("#search").hasClass("sAdvBg")) { 
		if(pager.length > 1) { $("div.pager form:first").hide(); }
		$("#advancedSearch").show();	
		$("#sB1").hide();	
	}
	else { 
		if(pager.length > 1) { $("div.pager form:first").show(); }
		$("#advancedSearch").hide();	
		$("#sB1").show();	
	}	
}

var Accordion =	{
	hideAll : function() { $("div.accordion").hide(); },
	showItem : function(e) {
		if($(this).hasClass("ico_minus")){
			$(this).parent().next().hide();
			$(this).removeClass("ico_minus");
			$(this).addClass("ico_plus");
		}
		else{
			$(this).parent().next().show();
			$(this).removeClass("ico_plus");
			$(this).addClass("ico_minus");
		}
	},
	init : function() {
		var i = 0;
		$("h3.accordion").each(function(index) {
			AccordionTitle=$(this);
			anchor = document.createElement('a');
			anchor.className = "ico_minus";
			anchor.href = "#tail"+i;
			anchor.active = 0;
			AccordionTitle.append(anchor);
			$(anchor).bind("click",Accordion.showItem);
			i++;
		});
		/*
		var hash = window.location.hash.substring(1);
		var tail = document.getElementById(hash);
		if (tail) {
			var a = tail.getElementsByTagName('A')[0];
			$(a).addClass("ico_minus");
			$(tail).next().show();
		}
		*/
	}
}



var DateTime = {

	insertData : function(date) {
		var input = $("input.selectedInput").val(date);
		input.removeClass("selectedInput");
		$("#cal").hide();
	},
	removeCal : function(e) {
		$("#cal").hide();
		$("body").unbind("click");
	},
	showCal : function(e) {	
		$("body").unbind("click");
		$("input.calendar").each(function(index) {
			$(this).removeClass("selectedInput");
		});

		$("#cal").show();
		$(this).addClass("selectedInput");
		var obj = $(this).offset();
	
		$("#cal").css("left",obj.left);
		$("#cal").css("top",obj.top+20);

		var p = $(this).val().split(".");

		if(p==""){
			var mesic=2;
			var rok=2012;
		}
		else{
			var mesic=p[1];
			var rok=p[2];
		}	

		$.ajax({
			url: "",
			data: "month="+mesic+"&year="+rok,
			cache: false,
			success: function(html){
				$("#cal").html(html);
				$("body").bind("click",DateTime.removeCal);
			}
		});	
	},

	init : function() {
		$("input.calendar").each(function(index) {
			input=$(this);
			$(this).bind("click",DateTime.showCal);
		});
	}
}

function ajax(place, url, write) {
	$("body").unbind("click");
	$.ajax({
		url: url,
		cache: false,
		success: function(html){
			if(write=="a"){
				$("#"+place).append(html);						
			}
			else{
				$("#"+place).html(html);				
			}
			$("body").bind("click",DateTime.removeCal);
		}
	});
}


function ajaxOpenReply(place, url, e) {
	$.ajax({
		url: url,
		cache: false,
		success: function(html){		

			if($("#"+place).hasClass("traverse")){
				$("#"+place).removeClass("traverse");
				$(e).html("Показать ответы");	
				$("#"+place).empty();
			}
			else{
				$("#"+place).addClass("traverse");				
				$(e).html("Спрятать ответы");
				$("#"+place).html(html);					
			}
		}
	});
}


function ajaxCloseReply(place, e){
	if($("#"+place).hasClass("traverse")){
		$("#"+place).removeClass("traverse");
		$(e).html("Спрятать ответы");
		$("#"+place).show();
	}
	else{
		$("#"+place).addClass("traverse");				
		$(e).html("Показать ответы");
		$("#"+place).hide();
	}
}



/* -- ALL --- */

function ajaxOpenReplyAll(place, url, e) {
	$.ajax({
		url: url,
		cache: false,
		success: function(html){		
			if($("#"+place).hasClass("traverseAll")){
				$("#"+place).removeClass("traverseAll");
				$(e).html("Показать всё");	
			// link na zobrazeni odpovedi			
				$("#"+place).removeClass("traverse");
				$(e).prev().html("Показать ответы");
				$(e).prev().show();		

				$("#"+place).empty();
			}
			else{
				$("#"+place).addClass("traverseAll");				
				$(e).html("Спрятать всё");
				$(e).prev().hide();
				$("#"+place).html(html);				
			}
		}
	});
}













function redir() {
	window.location.href = ($("#filter1").val());
}

