$(document).ready(function(){
/*	$("a").each(function(){
		if($(this).children("img").length && $(this).attr("href").match(/\.jpg$/i)){
			$(this).attr("rel", "prettyPhoto[auto]");
		}
	});*/
	
	$("a img").each(function(){
		if($(this).parents("a").length && $(this).parents("a").attr("href") && $(this).parents("a").attr("href").match(/\.jpg$/i)){
			$(this).parents("a").attr("rel", "prettyPhoto[auto]");
		}
	});
	$("a[rel^='prettyPhoto']").prettyPhoto({theme: "facebook", hideflash: true, social_tools: false, overlay_gallery: false});
	$(".datepicker").datepicker();
	$(".datepicker").each(function(){
		var date = $(this).val();
		$(this).datepicker("option", {dateFormat: "dd.mm.yy"});
		$(this).val(date);
	});

	$("#content img").each(function(){
		if($(this).attr("align") == "right"){
			$(this).css("margin-left", "20px");
			$(this).css("margin-right", "0");
		}
	});
	
	$("#content img").each(function(){
		if($(this).attr("align") == "right"){
			$(this).css("margin-left", "20px");
			$(this).css("margin-right", "0");
			$(this).css("float", "right");
		}else{
			$(this).css("margin-left", $(this).css("margin-left"));
			$(this).css("margin-right", $(this).css("margin-right"));
			if($(this).attr("align") == "left"){
				$(this).css("float", "left");
			}
		}
		$(this).css("margin-top", $(this).css("margin-top"));
		$(this).css("margin-bottom", $(this).css("margin-bottom"));
	});

	function myShow(){
		$(this).children("ul").slideDown('slow');
	}

/*	var myShowT = 0;
	$("ul.menu3 li li ul").hide();
	$("ul.menu3 li li").hover(function(){
		myShowT = setTimeout(myShow, 1000);
	}, function(){
		//$(this).children("ul").delay(1000).slideUp('slow');
	});*/
	
	$(".tabsmenu").removeClass("hidden");
	$(".tablerow.to").addClass("hidden");
	$("a#tablo_plain_from").addClass("active");
	$("a#tablo_plain_from").click(function(){
		$(this).addClass("active");
		$("a#tablo_plain_to").removeClass("active");
		$(".tablerow.from").removeClass("hidden");
		$(".tablerow.to").addClass("hidden");
		return false;
	});
	$("a#tablo_plain_to").click(function(){
		$(this).addClass("active");
		$("a#tablo_plain_from").removeClass("active");
		$(".tablerow.from").addClass("hidden");
		$(".tablerow.to").removeClass("hidden");
		return false;
	});
	
	$(".closejs").addClass("close");
	$(".closejs").parent("td").parent("tr").parent("tbody").parent("table").parent("li").children("ul").hide();
	$(".openjs").addClass("open");
	$(".openclose").click(function(){
		if($(this).hasClass("open")){
			$(this).removeClass("open");
			$(this).addClass("close");
			$(this).parent("td").parent("tr").parent("tbody").parent("table").parent("li").children("ul").slideUp();
			return false;
		}
		if($(this).hasClass("close")){
			$(this).removeClass("close");
			$(this).addClass("open");
			$(this).parent("td").parent("tr").parent("tbody").parent("table").parent("li").children("ul").slideDown();
			return false;
		}
		return true;
	});
		
	$("span.jsH").each(function(){
		var pt = Math.round(20 - $(this).height() / 2);
		if(pt > 0){
			$(this).css("padding-top", pt + "px");
		}
	});

});

