$(function() {


if (document.location.href.match(/places_description/)) {
$("span#rasptcena").each(function(){
if ($(this).text() == " руб.") $(this).text("Бесплатно");
});
}

if (document.location.href.match(/vyezd.html/)) {
  $("span[name='svn1'], span[name='svz1']").each(function() { if ($(this).text().length < 4) $(this).parent().remove(); });
}

if (document.location.href.match(/tags.php|nds.html|nalognapribyl.html/))
{
	if (found = document.location.href.match(/p_6_tag=(.*)/)) {
		tagid = found[1];
		$("h2#bytheme").html($("h2#bytheme").html() + ($("a[href='/tags.php?p_6_tag=" + tagid + "']").text()));
	}

	$("td.shed_1").each(function(){
		if (found = $(this).html().match(/(\d+?)\.(\d+?)\.(\d+?)\s-/)) {
			startdate = new Date(found[3], found[2]-1, found[1]);
			today = new Date();                      
			if (today > startdate) $(this).parent().remove();
		}
	});
}

// if (document.location.href.match(/tag3|seminary/))

 $("div[name='tags3']").each(function()  {



	var newdiv = document.createElement("DIV");	
	$(newdiv).load("/tags_service.php div#tags span", function() {				


			
			$("div[name='tags3']").find("a").each(function() {



				t3a = $(this);

				$(newdiv).find("span[name='" + t3a.text().toLowerCase() + "']").each(function() {
				   t3a.css("font-size", $(this).css("font-size"));
				});   			
			});
			
	});





 });

 
 $("div#tags").each(function()  {

	tagsd = $(this);
	var newdiv2 = document.createElement("DIV");	
	$(newdiv2).load("/tag-seminars-tag.php div#actualtags", function() {				


		var ta = new Object;
		var today = new Date();                      


		$(this).find("span").each(function() {

			ta[($(this).text())]=1;
			
/*
			if (found = $(this).attr("name").match(/(\d+?)\.(\d+?)\.(\d+)/)) {
                  
				 startdate = new Date(found[3], found[2]-1, found[1]);

	   			 if (today < startdate)  {
	   		
					 tmp1 = $(this);				   
					 $(this).find("span").each(function() {	

						ta[($(this).text())]=1;
					});
				}
			}

*/

		});


//		console.log (ta);

		tagsd.find("a").each(function(){

//			console.log ("this = " + $(this).text().toLowerCase());
//			console.log ( ta[$(this).text().toLowerCase()] );

			if (!ta[$(this).text().toLowerCase()]) $(this).remove();
		});


	 $("div#tags_div1").css("display", "block");

         var ct =  $("div#current_tag1").text();
         $("a[href*='seminary']").each(function() {
            	if ($(this).text() == ct) {
			$("div#current_tag1").html($("<a href='" + $(this).attr('href') + "'>Семинары по теме</a>"));
			$("div#current_tag1").css("display", "block");
		}
         });

	
	 });

 });





});

