function afiseaza_jurnal()
{

 if ($("#jurnal_ro").css('display')=='none')
 {
    $("#jurnal_ro").show();
    $("#player_ro").hide();
    $("#continut_ro").hide();
    $("#head_jurnal_ro").hide();

    $("#continut_fr").show();
    $("#jurnal_fr").hide();
    $("#player_fr").show();
    $("#head_jurnal_fr").show();
 }
 else
 {
    $("#jurnal_ro").hide();
    $("#player_ro").show();
    $("#continut_ro").show();
    $("#head_jurnal_ro").show();

    $("#continut_fr").hide();
    $("#jurnal_fr").show();
    $("#player_fr").hide();
    $("#head_jurnal_fr").hide();

 }

}

function cele_mai_citite()
{
    document.getElementById('caseta_citite').style.display="";
    document.getElementById('caseta_comentate').style.display="none";

    document.getElementById('tab_citite').setAttribute("class", "tab_ales");
    document.getElementById('tab_citite').setAttribute("className", "tab_ales");

    document.getElementById('tab_comentate').setAttribute("class", "tab");
    document.getElementById('tab_comentate').setAttribute("className", "tab");

}


function cele_mai_comentate()
{
    document.getElementById('caseta_citite').style.display="none";
    document.getElementById('caseta_comentate').style.display="";

    document.getElementById('tab_citite').setAttribute("class", "tab");
    document.getElementById('tab_citite').setAttribute("className", "tab");

    document.getElementById('tab_comentate').setAttribute("class", "tab_ales");
    document.getElementById('tab_comentate').setAttribute("className", "tab_ales");

}


function vremea_in_tara()
{
    document.getElementById('caseta_vremea').style.display="";
    document.getElementById('caseta_valutar').style.display="none";

    document.getElementById('tab_vremea').setAttribute("class", "tab_ales");
    document.getElementById('tab_vremea').setAttribute("className", "tab_ales");

    document.getElementById('tab_valutar').setAttribute("class", "tab");
    document.getElementById('tab_valutar').setAttribute("className", "tab");

}


function curs_valutar()
{
    document.getElementById('caseta_vremea').style.display="none";
    document.getElementById('caseta_valutar').style.display="";

    document.getElementById('tab_vremea').setAttribute("class", "tab");
    document.getElementById('tab_vremea').setAttribute("className", "tab");

    document.getElementById('tab_valutar').setAttribute("class", "tab_ales");
    document.getElementById('tab_valutar').setAttribute("className", "tab_ales");

}





function evenimente(ziua, mod)
{
    if (mod==1)
    mod='';
    else
    mod='none';

    document.getElementById('ev_'+ziua).style.display=mod;
}


function alege_luna(luna, anul)
{
    $.get("/calendar_evenimente.php", { luna: luna, anul: anul }, function (data)
    {
	document.getElementById('calendar_evenimente').innerHTML=data;
//	$('calendar_evenimente').html=data;
    } );

//    schimba('/calendar_evenimente.php?luna='+luna+'&anul='+anul,'calendar_evenimente',1);
}


// ------------- meniu de sus
// bug - merge sa dai clik repede ce multe ori
    if (typeof(nr_curent_meniu)=='undefined')
    var nr_curent_meniu=9;


    var cat_vizibile=9;



    function start_meniu()    
    {


	var cate_categorii=$('#lista_meniu li').size();

	$('#meniu_dreapta').click(function()
	{

	    if (nr_curent_meniu<cate_categorii)
	    {
	    $('#lista_meniu').animate({marginLeft:'-=101'},400, function ()
	    {
		nr_curent_meniu=nr_curent_meniu+1;
		if (nr_curent_meniu==cate_categorii)
		$('#meniu_dreapta').attr("src","/imagini/site/sageata_meniu_dreapta_i.png");

		$('#meniu_stanga').fadeIn("fast");
	    });
	    }
	});

	$('#meniu_stanga').click(function()
	{
	    if (nr_curent_meniu>cat_vizibile)
	    {
	    $('#lista_meniu').animate({marginLeft:'+=101'},400, function ()
	    {
		$('#meniu_dreapta').attr("src","/imagini/site/sageata_meniu_dreapta.png");


		nr_curent_meniu=nr_curent_meniu-1;

		if (nr_curent_meniu==cat_vizibile)
		$('#meniu_stanga').hide("fast");



	    });
	    }

	    
	    

	});
    }
// -----------------------------



// ---------------------- ultima ora
// trebuie modificat sa calculeze diferenta intre unde e si ce a ramas
    function start_ultima_ora()
    {
	var cate_ore=$('#lista_ora li').size();
	var inaltime=$('#lista_ora').height();
	var limita=650;

	$('#sageata_jos_ora').click(function()
	{
	    var diff=inaltime*1+$('#lista_ora').css('margin-top').replace("px", "")*1;

	    if (diff>limita)
	    {
		$('#lista_ora').animate({marginTop:'-=150'},400, function()
		{
//		    var verifica=$('#lista_ora').css('margin-top').replace("px", "")*1-150;
//		    if (verifica<=inaltime*(-1))
//		    $('#lista_ora').css('margin-top',inaltime);
		
		});
	    }	
	});

	$('#sageata_sus_ora').click(function()
	{
	    var diff=inaltime*1+$('#lista_ora').css('margin-top').replace("px", "")*1;



	    if (diff<inaltime)
	    {
		$('#lista_ora').animate({marginTop:'+=150'},400, function ()
		{
		    var verifica=$('#lista_ora').css('margin-top').replace("px", "")*1+150;
		    if (verifica>=0)
		    $('#lista_ora').css('margin-top',0);
		
		});
	    }


	});

    }
    
    
// -----------------------------


// --------------------- fotografia zilei
var nr_curent_foto=1;
function start_foto()
{

    if (typeof(limita)=='undefined')
    limita=4;

    if (typeof(distanta)=='undefined')
    distanta=219;


    var cate_foto=$('#lista_foto li').size();
    
    var cate_foto_fara=cate_foto-limita;
    
    var latime=$('#lista_foto li').outerWidth(true)+20; // era 20

//alert(cate_foto);

    var latime_totala=latime*cate_foto;
    $('#lista_foto').width(latime_totala);


	$('#sageata_dreapta_foto').click(function()
	{
	    if (nr_curent_foto<=cate_foto_fara)
	    {
		$('#lista_foto').animate({marginLeft:'-='+distanta},400);
		nr_curent_foto=nr_curent_foto+1;
	    }
	});

	$('#sageata_stanga_foto').click(function()
	{
	    if (nr_curent_foto>1)
	    {
		$('#lista_foto').animate({marginLeft:'+='+distanta},400);
		nr_curent_foto=nr_curent_foto-1;
	    }
	});
}

// -----------------------------



function abonare_newsletter(form, care)
{
    mail=form.e_mail.value;

 if (verifica_adresa_mail(mail))
 {
    $.get("/adauga_newsletter.php", { email: mail }, function (data)
    {
	document.getElementById('abonare_newsletter'+care).innerHTML=data;
    } );

 }
 else
 alert("Adresa introdusa nu este valida.");

    return false;
}


function anulare_nl()
{
    $.get("/adauga_newsletter.php", { email: 'test@test.com' }, function (data)
    {
	
    } );

}

function verifica_adresa_mail(adresa)
{

    if (adresa!="")
    {
	filtru=/^.+@.+\..{2,3}$/;
	if (!filtru.test(adresa))
	{return false;}
	else
	{return true;}
    }

}


function aplica_quiz(ce_quiz)
{
    formu=document.forms.quiz_form;



    tip=formu.tip_quiz.value;
    raspuns=formu.rasp;
 if (raspuns.length>0)
 {

    if (tip==0) // quiz
    {
	este=false;
	raspuri=new Array();

	nr=0;
	for (i=0;i<raspuns.length;i++)
	{
	    if (raspuns[i].checked==true)
	    {
	        este=true;
	        raspuri[nr]=raspuns[i].value;
	        nr=nr+1;
	    }
	}

	if (este==true)
	{
	    raspunsuri=raspuri.join(",");
//	    schimba('/raspuns_quiz.php?tip='+formu.tip_quiz.value+'&raspuns='+raspunsuri+'&ce_quiz='+ce_quiz,'form_quiz',1);
    $.get("/raspuns_quiz.php", { tip: formu.tip_quiz.value , raspuns:raspunsuri ,ce_quiz:ce_quiz }, function (data)
    {
	document.getElementById('form_quiz').innerHTML=data;

    } );

	}
	else
	alert('Alegeti cel putin un raspuns.');
    }
    else if (tip==1) // poll
    {

	este=false;
	raspuri=new Array();

	for (i=0;i<raspuns.length;i++)
	{
	    if (raspuns[i].checked==true)
	    {
	        este=true;
	        raspuri=raspuns[i].value;
	    }
	}

	if (este==true && raspuri!='')
	{
	    raspunsuri=raspuri;
//	    schimba('/raspuns_quiz.php?tip='+formu.tip_quiz.value+'&raspuns='+raspunsuri+'&ce_quiz='+ce_quiz,'form_quiz',1);
    $.get("/raspuns_quiz.php", { tip: formu.tip_quiz.value , raspuns:raspunsuri ,ce_quiz:ce_quiz }, function (data)
    {
	document.getElementById('form_quiz').innerHTML=data;

    } );



	}
	else
	alert('Alegeti cel putin un raspuns.');
    
    }
 }
 else
 alert('Alegeti cel putin un raspuns.');

}

