pocetSuborov=11;

function addNewFotoToGalery(url,file)
 {
   document.getElementById('firstimagegalery').innerHTML='<a href="mod/galery/'+url+'"><img src="media/galery/'+url+'/'+file+'" alt="" /></a>';
 }

function addNextFileInput()
 {
   ss=pocetSuborov+1;
   document.getElementById('file'+pocetSuborov).innerHTML='<div class="popis w100"><b>Súbor '+pocetSuborov+':</b></div><div class="form"><input type="file" name="img'+pocetSuborov+'" class="input_text" /><input type="radio" class="chd" name="top_img" value="'+pocetSuborov+'" /> hlavný obrázok</div><div class="clear h5"></div><div class="popis w100"><b></b></div><div class="form"><input type="text" name="img_popis'+pocetSuborov+'" class="input_text w340" /></div><div class="clear h5"></div><div id="file'+ss+'"></div>';
   document.getElementById('formPocetSuborov').value=pocetSuborov;
   pocetSuborov=ss;
 }

function pause(millisecondi)
 {
   var now = new Date();
   var exitTime = now.getTime() + millisecondi;
   while(true)
    {
      now = new Date();
      if(now.getTime() > exitTime) return;
    }
 }
      
 
  function citanejsieBlink(vstup)
   {
     $("#xx1").addClass('white');
     $("#xx2").addClass('white');
     $("#xx3").addClass('white');
     
     $("#x1").addClass('hidden');
     $("#x2").addClass('hidden');
     $("#x3").addClass('hidden');
     
     document.getElementById('top_okna_X').style.backgroundImage=("url(design/back_block_top_x3_"+vstup+".png)");
     $("#xx"+vstup).removeClass('white');
     $("#x"+vstup).removeClass('hidden');
   } 

$(document).ready(function(){






 var options2 = {format: '%d. %B %Y | %H:%M:%S' }
  $('#clock').jclock(options2);



  
  $('#selectBezci').load('modules/bezci/generator.php');
         $('.roolBezci').click(function() { //start function when any link is clicked
         smer = $(this).attr("title");
         
          $("#selectBezci").fadeOut("fast", function() {
          
                    	 $.ajax({
  							method: "get",url: "modules/bezci/generator.php",data: "smer="+smer, success: function(html)
                  { //so, if data is retrieved, store it in html
  							    $("#selectBezci").fadeIn("fast"); //animation
  							    $("#selectBezci").html(html); //show the html inside .content div
  					      }
				     }); //close $.ajax(
          
          
          } );

          $("#selectBezci").fadeIn("fast" );
          
         }); //close click(
         




  $('#selectTimy').load('modules/timy/generator.php');
         $('.roolTimy').click(function() { //start function when any link is clicked
         smer = $(this).attr("title");
         
          $("#selectTimy").fadeOut("fast", function() {
          
                    	 $.ajax({
  							method: "get",url: "modules/timy/generator.php",data: "smer="+smer, success: function(html)
                  { //so, if data is retrieved, store it in html
  							    $("#selectTimy").fadeIn("fast"); //animation
  							    $("#selectTimy").html(html); //show the html inside .content div
  					      }
				     }); //close $.ajax(
          
          
          } );

          $("#selectTimy").fadeIn("fast" );
          
         }); //close click(






   $(".mesiaceposun").click(function()
    {
      hodnota = $(this).attr("title");
      aktual = $(".mesiacovanie").attr("title");
      
      $("#zoznamMesiacov").load("modules/behy/mesiacPosun.php?aktual="+aktual+"&kam="+hodnota);    
    });
    
    
   $(".reakcia").click(function()
    {
      hodnota = $(this).attr("title");
      $("#rea_"+hodnota).load("includes/reakcie.php?reakcia="+hodnota,function()
        {
          $(this).slideToggle('slow');
        });       
    });


   $(".reakciaForum").click(function()
    {
      hodnota = $(this).attr("title");
      $("#rea_"+hodnota).load("modules/forum/reakcie.php?reakcia="+hodnota,function()
        {
          $(this).slideToggle('slow');
          $('#rea_'+hodnota+' .kontrol_reakcia').html('<input type="hidden" name="kontrola" value="no' + 'spam" />');
        });       
    });
    

    $('#anketaVysledky').load('modules/anketa/anketa.php?rightbar');


    $('#vysledky').click(function() 
     {
       $("#udajeTerminovka").addClass("hidden");
       $("#udajeVysledky").removeClass("hidden");
       $("#menuUdajeOBehoch").removeClass("top_okno2");
       $('#terminovka').addClass("deselekt");
       $(this).removeClass("deselekt");
     });
     
     
    $('#terminovka').click(function() 
     { 
       $("#udajeTerminovka").removeClass("hidden");
       $("#udajeVysledky").addClass("hidden");
       $("#menuUdajeOBehoch").addClass("top_okno2");
       $('#vysledky').addClass("deselekt");
       $(this).removeClass("deselekt");
     });
     
     
     
          
}); //close $(
	 
	 
	 function hlasujAnketa(anketa,odpoved)
	  {
	    $('#anketaVysledky').load('modules/anketa/anketa.php?rightbar&anketa='+anketa+'&odpoved='+odpoved);
    }

  function starLight(vstup)
   {
     for(i=1;i<=5;i++)
      {
        if(i<=vstup) 
         {
          $("#hlas"+i).removeClass("gray");
          $("#hlas"+i).addClass("light");
         } 
        if(i>vstup) 
         {
          $("#hlas"+i).addClass("gray");
          $("#hlas"+i).removeClass("light");
         }
      }
   }
   	 
$(window).load(function () {
  $('#obrazok').imgAreaSelect({ x1: 0, y1: 0, x2: 155, y2: 155 }); 
  $('#obrazok').imgAreaSelect({ maxWidth: 155, maxHeight: 155 });
  $('#obrazok').imgAreaSelect({ minWidth: 77, minHeight: 77 });
  $('#obrazok').imgAreaSelect({ selectionColor: 'white', aspectRatio: '1:1' }); 
	$('#obrazok').imgAreaSelect({ onSelectChange: prepocet });
    
  $('#x1').val('0');
	$('#y1').val('0');
	$('#x2').val('155');
	$('#y2').val('155');
	$('#w').val('155');
	$('#h').val('155');
	
 });
 

function prepocet(img, selection)
{
  $('#x1').val(selection.x1);
	$('#y1').val(selection.y1);
	$('#x2').val(selection.x2);
	$('#y2').val(selection.y2);
	$('#w').val(selection.width);
	$('#h').val(selection.height);
}  


function changeFoto()
{
  document.getElementById('changeFoto').style.display="";
}

ktoraJeOtvorena='';
somNaSubMenu=0;

function displaySubMenu(vstup)
{
   if(document.getElementById(vstup)) document.getElementById(vstup).style.display="";
   if(ktoraJeOtvorena!='' & ktoraJeOtvorena!=vstup) if(document.getElementById(ktoraJeOtvorena)) document.getElementById(ktoraJeOtvorena).style.display="none";
   ktoraJeOtvorena=vstup;
}


function noDisplaySubMenu()
{
  if(ktoraJeOtvorena!='' && somNaSubMenu==0 ) if(document.getElementById(ktoraJeOtvorena)) document.getElementById(ktoraJeOtvorena).style.display="none";
}

function setSomNaSubmenu(vstup)
{
  somNaSubMenu=vstup; 
}


function potvrdenie(vstup)
{
potvrdenie=window.confirm("Skutočne chcete túto položku odstrániť?");

  if(potvrdenie)
   {
    window.top.location.href=vstup;
   }	
}



$(function() {
  $('a[rel=lightbox]').lightBox();
});

function openClose(vstup)
  {
         $("#"+vstup+" .center").slideToggle("slow");
         $("#"+vstup+" .bottom").slideToggle("slow");
  }

  $(document).ready(function(){
     
     $("#treningovaTrasa .top_close").click(function()
       {
           openClose('treningovaTrasa');
           $(this).toggleClass("top_open");
           if($(this).hasClass("top_open")) $("#treningovaTrasaObsah").load('modules/behy/nahodna_trasa.php'); 
       });
       
       
       
     $("#mapaBehu .top_close").click(function()
       {
        
           openClose('mapaBehu');
           $(this).toggleClass("top_open");
           
          
           $("#mapaBehuFake").toggleClass("fakeBehON");
              
           if($("#mapaBehu").hasClass("centerBlokOkno"))
            {
              $("#mapaBehu").removeClass("centerBlokOkno");
              $("#mapaBehu").addClass("fullBlokOkno");
            }
           else
            {
              $("#mapaBehu").removeClass("fullBlokOkno");
              $("#mapaBehu").addClass("centerBlokOkno");
            }
            
            
           
           mesto=document.getElementById('detailMapaBehu').title;
           
           init(mesto);
       });       


     $("#trasaBehu .top_close").click(function()
       {
        
           openClose('trasaBehu');
           $(this).toggleClass("top_open");
           
           $("#mapaBehuFake").toggleClass("fakeBehON");
              
           if($("#trasaBehu").hasClass("centerBlokOkno"))
            {
              $("#trasaBehu").removeClass("centerBlokOkno");
              $("#trasaBehu").addClass("fullBlokOkno");
            }
           else
            {
              $("#trasaBehu").removeClass("fullBlokOkno");
              $("#trasaBehu").addClass("centerBlokOkno");
            }
            
           zoom=document.getElementById('zoom_trasa').innerHTML;
           suradnice=document.getElementById('suradnice_trasa').innerHTML;
           centermap=document.getElementById('centermap_trasa').innerHTML;
           

				     
				     
				     $.post("modules/behy/vykresli_trasu.php", { zoom_behy: zoom, suradnice_behy: suradnice, centermap_behy: centermap },
              function(html)
                  { //so, if data is retrieved, store it in html
  							    $("#detailTrasaBehu").fadeIn("fast"); //animation
  							    $("#detailTrasaBehu").html(html); //show the html inside .content div
  					      });

          
       });           
       
  });


function focusInput(vstup)
{
 document.getElementById(vstup).focus();
}

function clearInput(vstup)
{
 document.getElementById(vstup).value='';	
}



//gooooooooooooooooogle mapy source code
    var map = null;
    var geocoder = null;

    function initialize(vstup) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("detailMapaBehu"));
        map.setCenter(new GLatLng(0, 0), 12);
        geocoder = new GClientGeocoder();
        map.setUIToDefault();
        map.setMapType(G_HYBRID_MAP);

            var address1 = vstup;
            if (geocoder) {
              geocoder.getLatLng(
                address1,
                function(point) {
                  if (!point) {
                    alert(address + " nenájdená");
                  } else {
                    var marker1 = new GMarker(point);
                    map.addOverlay(marker1);                    
                  }
                }
              );              
            }
         }
      }

    function showAddress(address) {
      if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
              map.setCenter(point, 12);
          }
        );
        
      }

       
    map.addControl(mapControl);
    }
    
    function init(vstup)
    {
      initialize(vstup);
      showAddress(vstup);
    }
      


