$(document).ready(function(){
	//Ascund element de event calendar de care nu am nevoie
	$("#ec3_publish").hide();
	
	
	//Pentru luna in curs folosesc o functie bazata pe click event
	$(".ec3_postday").live('click', function() {
		var ziua = $(this).find('a').html();
		var content = $(this).find(".calendar_hidden").html();
		
		$("#text-3").find('h2').html("Evenimente din data de "+ziua);
		$(".event_calendar_day").html("Evenimente din data de "+ziua);
		$("#calendar_eveniment").html(content);
		content = "";
		return false;
	});
	
	$(".the_category li").hover(
		function () {
			$(this).css('background','#EEEEEE');
		}, 
		function () {
			$(this).css('background','#FFFFFF');
		}
	);
	

	$(".f5, .f6, .f7, .f8, .f9").css("display","none");
	setTimeout("swap_featured_articles1(0)",20000);




	$(".featured_article").hover(
	  function () {
	    $(this).css('border','1px solid #FFAA00');
	  }, 
	  function () {
	    $(this).css('border','1px solid #78B3B4');
	  }
	);
	
	
	$(".featured_article h3 a").each(function() {
		var h=$(this).height();
		if(h>32){
			$(this).parent().css("margin","-50px 0 0");
			$(this).parent().css("height","46px");
		}
	});
	
	
	
	
	
	
	//Sterg cuvantul cauta atunci cand dau click pe inputul de cautare
	$("#s").focus(function(){
		$(this).val("");
	});
	
	
	//Pentru evenimente sterg data postarii si bag in loc perioada in care se desfasoara evenimentul
	var perioada = $("table .ec3_schedule").html();
	$("table .ec3_schedule").html("");
	
	$(".category-evenimente small").html(perioada);
	
	
	$("#post-489 .ec3_schedule").html("");
	
	
	
	//Pentru post-uri cu feedback
	$(".announcement_post").parent().find("p:not(.announcement_post>p)").html("");
	$(".announcement_post").parent().find("ol").html("");
	$(".announcement_post").parent().parent().find(".postmetadata").html("");
	
	var response = $(".announcement_post").parent().parent().parent().find("#respond");
	$(response).find("h3:not(.title)").html("Împărtăşeşte-ne impresiile tale:");
	$(response).find("#commentform>p>#submit").val("Trimite povestea ta")
	$(response).find("#commentform>p>#comment").css("width","100%");
	
	//Special pentru povestit
	$("#post-1332").find("small").html("");
	
	
	
	
	//Spots on map
	$(".spot").hover(
	  function () {
	    $(this).addClass("spot_selected");
	  }, 
	  function () {
	    $(this).removeClass("spot_selected");
	  }
	);
	
	$(".spot").click(function(){
		
		var the_tag = $(this).attr("rel"); 
		$("#galleries_new").css("display","none");
	 	$("#atractii_turistice_cazare1").css("display","block");
		$("#atractii_turistice_cazare").html("Informaţiile se încarcă...");
		$("#atractii_turistice_cazare1").html("Informaţiile se încarcă...");
		
		$.get("http://www.traiesteromaneste.ro/wp-content//themes/TraiesteRomaneste/ajax_harta_atractii_turistice.php", { tag: the_tag }, function(data){
			var header="<div id='close_atractii_turistice_cazare' title='Închide'></div><h3>Articole din zona "+the_tag+"</h3>"
		   $("#atractii_turistice_cazare").html(header+data);
		   $("#atractii_turistice_cazare").css("display","block");
		   
		   $("#atractii_turistice_cazare1").html(header+data);
		   
		   $("#close_atractii_turistice_cazare").click(function(){
		   		$(this).parent().css("display","none");
		   		$("#galleries_new").css("display","block");
		   });
		 });	
	});

});






	function swap_featured_articles(i){
		var j=i+4;
		if($(".f"+i).css("display")=="block") 
		{
			var tmp=$(".f"+i).html();
			var tmp2=$(".f"+j).html();
			$(".f"+i).fadeOut("fast");
			$(".f"+i).html(tmp2);
			$(".f"+i).fadeIn("fast");
			$(".f"+j).html(tmp);
		}
		else
		{
			var tmp=$(".f"+i).html();
			var tmp2=$(".f"+j).html();
			$(".f"+i).fadeOut("fast");
			$(".f"+i).html(tmp2);
			$(".f"+i).fadeIn("fast");
			$(".f"+j).html(tmp);
		}	
		i++;
		if(i<4) setTimeout("swap_featured_articles("+i+")", 3000)
		else setTimeout("swap_featured_articles(0)", 20000);
	}
	
	function swap_featured_articles1(i){
		var j=i+5;
		if($(".f"+i).css("display")=="block") 
		{
			var tmp=$(".f"+i).html();
			var tmp2=$(".f"+j).html();
			$(".f"+i).fadeOut("fast");
			$(".f"+i).html(tmp2);
			$(".f"+i).fadeIn("fast");
			$(".f"+j).html(tmp);
		}
		else
		{
			var tmp=$(".f"+i).html();
			var tmp2=$(".f"+j).html();
			$(".f"+i).fadeOut("fast");
			$(".f"+i).html(tmp2);
			$(".f"+i).fadeIn("fast");
			$(".f"+j).html(tmp);
		}	
		i++;
		if(i<5) setTimeout("swap_featured_articles("+i+")", 3000)
		else setTimeout("swap_featured_articles(0)", 20000);
	}
	
function showEvent(idEvent)
{
	var txt = document.getElementById(idEvent).innerHTML;
	document.getElementById('calendar_eveniment').innerHTML = txt;
}


  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17067649-1']);
  _gaq.push(['_setDomainName', '.traiesteromaneste.ro']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
