
function show_select(volaciPrvek)
{

   roletka = volaciPrvek;
   if (roletka.style.display=="none")
   {
      roletka.style.display="block";
   }
   else
   {
      roletka.style.display="none";
   }
}

function nastavHlavni(idecko,volaciPrvek)
{
    obsah = volaciPrvek.innerHTML;
    hlavni=document.getElementById("hlavni"+idecko);

    odkazalt=volaciPrvek.getElementsByTagName("img")[0].alt;
    odkazsrc=volaciPrvek.getElementsByTagName("img")[0].src;

    document.getElementById("input"+idecko).value=odkazalt;

    hlavni.getElementsByTagName("img")[0].src=odkazsrc;
    hlavni.getElementsByTagName("img")[0].alt=odkazalt;
}

function kratkezpravyprechod(trans,id,nula,strana,stav)
{
     trans=(Math.round(trans*10)/10);

     document.getElementById(id).style.opacity=trans;
     document.getElementById(id).filtersAlphaOpacity=trans;


     if (trans==0)
     {
        nula=true;
        zpravy=new Array();
        zpravy=kratke_zpravy(strana);
        document.getElementById(id).innerHTML=zpravy[0];

        if (stav==false)
        {
              if (strana==1)
              {
                  document.getElementById("act_pg").style.marginLeft="1px";
              }
              if (strana==2)
              {
                  document.getElementById("act_pg").style.marginLeft="19px";
              }
              if (strana==3)
              {
                  document.getElementById("act_pg").style.marginLeft="36px";
              }
              if (strana==4)
              {
                  document.getElementById("act_pg").style.marginLeft="54px";
              }
        }

        if (stav==true)
        {
           document.getElementById("listovani").innerHTML="<img id=\"act_pg\" src=\"http://www.intercup.cz/images/bck_listovani_kratke_zpravy_posuvnik.gif\" alt=\"Aktivní stránka\">";
           document.getElementById("act_pg").style.marginLeft="1px";
        }
        
        pocet_stran=zpravy[1];
        
        if (strana==1)
        {
            document.getElementById("listovani_zpet").innerHTML="";
            if (pocet_stran>1)
            {
            document.getElementById("listovani_dalsi").innerHTML="<div onclick=\"kratkezpravyprechod(1,'"+id+"',false,2,false)\"></div>";
            }
        }
        else if (strana==4 || strana==pocet_stran)
        {
            document.getElementById("listovani_zpet").innerHTML="<div onclick=\"kratkezpravyprechod(1,\'"+id+"',false,"+(pocet_stran-1)+",false)\"></div>";
            document.getElementById("listovani_dalsi").innerHTML="";
        }
        else
        {
           document.getElementById("listovani_zpet").innerHTML="<div onclick=\"kratkezpravyprechod(1,'"+id+"',false,"+(strana-1)+",false)\"></div>";
            document.getElementById("listovani_dalsi").innerHTML="<div onclick=\"kratkezpravyprechod(1,'"+id+"',false,"+(strana+1)+",false)\"></div>";
        }
        
     }

     if (nula==true)
     {
        new_trans=trans+0.1;
     }
     else
     {
        new_trans=trans-0.1;
     }

     if (nula==true && stav==true)
     {
          document.getElementById("listovani").style.opacity=trans;
          document.getElementById("listovani").filtersAlphaOpacity=trans;
     }

     if (stav==false)
     {
          document.getElementById("act_pg").style.opacity=trans;
          document.getElementById("act_pg").filtersAlphaOpacity=trans;
          
     }

     if (trans==1 && nula==true)
     {

     }
     else
     {
       reloading = setTimeout("kratkezpravyprechod("+new_trans+",\""+id+"\","+nula+","+strana+","+stav+")", 40);
     }
}

function poleReset(actPole,text)
{
    if (actPole.value==text)
    {
      actPole.style.textStyle="Normal";
      actPole.value="";
    }
    else if (actPole.value=="")
    {
      actPole.style.textStyle="Italic";
      actPole.value=text;
    }
}


function kratke_zpravy(pg)
{

var nadpisy=new Array();
var obsahy=new Array();
nadpisy[0]="28.01.2012 10:29:13 / Vouilloz";
obsahy[0]="5.2.2012 se uskuteční 1.Extreme rally 2012 více info na  http://www.rcrallysprint-irc.estranky.cz";
nadpisy[1]="21.01.2012 20:45:47 / Vouilloz";
obsahy[1]="Zprovozněno fórum Intercup";
nadpisy[2]="12.01.2012 19:57:55 / Vouilloz";
obsahy[2]="Občanské sdružení Intercup Zlín svolává valnou hromadu na 30.1.2012 v 18:00 v PARKHOTEL Zlín.";
nadpisy[3]="02.01.2012 21:54:44 / Vouilloz";
obsahy[3]="Byly zveřejněny pravidla a aktualizován kalendář pro rok 2012";
nadpisy[4]="05.12.2011 09:54:36 / Vouilloz";
obsahy[4]="5.12.2011 byl spuštěn nový web, během dne se můžou vyskytnout problémy s přechodem na nový server.";
nadpisy[5]="02.11.2011 06:51:25 / Vouilloz";
obsahy[5]="Letošním mistrem Intercupu se stal Petr Pavlát z týmu AMK Malá Sklála s vozem Toyota Celica GT4.Týmový pohár vyhrál tým GRIFONE.";
var max_pocet=6;
output="";

  if (pg<=0)
  {
    pg=1;
  }
  if (pg>4)
  {
    pg=4;
  }
  pocatek=3*(pg-1);

  for (i=pocatek;i<(pocatek+3) && i<max_pocet;i++)
  {
      output+="<div class=\"item\"><div class=\"datum_autor\">"+nadpisy[i]+"</div><div class=\"obsah\">"+obsahy[i]+"</div></div>";
      
  }


  
  pole_output=new Array();
  pole_output[0]=output;
  pole_output[1]=2;
  
  return pole_output;
}

function del_item(id,nazev,typ)
{
  info_del_vysledky="";
  hlaska_hlavni="Opravdu si přejete odstranit položku";
  if (typ=="klasifikace")
  {
      info_del_vysledky=" Veškeré výsledky této rally budou smazány !";
  }
  if (typ=="klasifikace_clk")
  {
      info_del_vysledky=" Veškeré výsledky této rally budou smazány !";
      hlaska_hlavni="Opravdu si přejete odstranit klasifikaci rally";
  }
  if (typ=="teamy")
  {
      info_del_vysledky=" Všem členům tohoto teamu se nastaví, že jsou jednotlivci (bez teamu). !";
  }
  if (typ=="parametry")
  {
      info_del_vysledky=" Uživatelům i v přihláškách zůstane zachován, znovu jej však, uživatelé, nebudou moci zvolit. !";
  }
  if (typ=="rally")
  {
      info_del_vysledky=" V případě, že rally již byla klasifikována, budou tato pořadí odstraněny. !";
  }
  if (typ=="fotogalerie")
  {
      info_del_vysledky=" Pokud album obsahuje fotografie, budou odstraněny !";
  }
  if (typ=="videogalerie")
  {
      info_del_vysledky=" Pokud album obsahuje videa, budou odstraněny !";
  }
  
  if (typ=="clanky")
  {
      info_del_vysledky=" Pokud clanek obsahuje dalsi fotografie, budou odstraněny !";
  }

  if (confirm(hlaska_hlavni+" "+nazev+"?"+info_del_vysledky))
  {
       if (typ=="prihlaska")
       {
          document.getElementById("fakeframe").src="http://www.intercup.cz/prihlaska_odhlasit.php?id="+id;
       }
       else if (typ=="clanky_fotografie")
       {
          document.getElementById("fakeframe").src="http://www.intercup.cz/adm_clanky_del_fotografie.php?idtd="+id;
       }
       else
       {

          document.getElementById("fakeframe").src="http://www.intercup.cz/adm_"+typ+"_del.php?idtd="+id;
       }

  }

}

function show_hide(id_polozky)
{

       stav=document.getElementById(id_polozky).style.display;

       if (!stav || stav=="none")
       {
           document.getElementById(id_polozky).style.display="block";
       }
       else
       {
           document.getElementById(id_polozky).style.display="none";
       }
}

function hide(id_polozky)
{

           document.getElementById(id_polozky).style.display="none";
}


function zobraz_skryj(zobrazit,skryt)
{
      document.getElementById(zobrazit).style.display="block";
      document.getElementById(skryt).style.display="none";
}

function pridej_jezdce(skryt_okno,id,hodnota)
{

      document.getElementById(id).value=hodnota;
      popup(skryt_okno);
      
}

function update_kw(id)
{

     document.getElementById("jedci_na_fotografii_txt"+id).value="";



      prvku=0;
      for(i = 0; i < document.getElementById("jedci_na_fotografii"+id).length; i++)
      {

           if(document.getElementById("jedci_na_fotografii"+id)[i].selected == true)
           {


                keyword=document.getElementById("jedci_na_fotografii"+id).options[i].value;




                if (!prvku)
                {
                   document.getElementById("jedci_na_fotografii_txt"+id).value=keyword;
                }
                else
                {
                   document.getElementById("jedci_na_fotografii_txt"+id).value+=" "+keyword;
                }
                prvku++;


           }


      }



}

function winH() {
  if (window.innerHeight)
    return window.innerHeight;
  else if  (document.documentElement && document.documentElement.clientHeight)
    return document.documentElement.clientHeight;
  else if  (document.body && document.body.clientHeight)
    return document.body.clientHeight;
  else
    return null;
  }

function toggle(div_id) {
	var el = document.getElementById(div_id);
	if ( el.style.display == 'none' ) {	el.style.display = 'block';}
	else {el.style.display = 'none';}
}
function blanket_size(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportheight = window.innerHeight;
	} else {
		viewportheight = document.documentElement.clientHeight;
	}
	if ((viewportheight > document.body.parentNode.scrollHeight) && (viewportheight > document.body.parentNode.clientHeight)) {
		blanket_height = viewportheight;
	} else {
		if (document.body.parentNode.clientHeight > document.body.parentNode.scrollHeight) {
			blanket_height = document.body.parentNode.clientHeight;
		} else {
			blanket_height = document.body.parentNode.scrollHeight;
		}
	}

  var blanket = document.getElementById('stranka_dis');
	blanket.style.height = blanket_height + 'px';
	var popUpDiv = document.getElementById(popUpDivVar);
	popUpDiv_height=winH()/2-225;//150 is half popup's height
	popUpDiv.style.top = popUpDiv_height + 'px';
}
function window_pos(popUpDivVar) {
	if (typeof window.innerWidth != 'undefined') {
		viewportwidth = window.innerHeight;
	} else {
		viewportwidth = document.documentElement.clientHeight;
	}
	if ((viewportwidth > document.body.parentNode.scrollWidth) && (viewportwidth > document.body.parentNode.clientWidth)) {
		window_width = viewportwidth;
	} else {
		if (document.body.parentNode.clientWidth > document.body.parentNode.scrollWidth) {
			window_width = document.body.parentNode.clientWidth;
		} else {
			window_width = document.body.parentNode.scrollWidth;
		}
	}
	var popUpDiv = document.getElementById(popUpDivVar);
	window_width=window_width/2-200;//150 is half popup's width
	popUpDiv.style.left = window_width + 'px';
}
function popup(windowname) {
	blanket_size(windowname);
	window_pos(windowname);
	toggle('stranka_dis');
	toggle(windowname);
}

function zmen_ppp(prvek)
{
    index=prvek.selectedIndex;
    hodnota=prvek.options[index].value;
    document.getElementById("fakeframe").src="http://www.intercup.cz/change_ppp.php?ppp="+hodnota;
}

function show_all_profil_photos(volac,pro_zobrazeni,mezera)
{
  volac.style.display="none";
  document.getElementById(pro_zobrazeni).style.display="block";
  document.getElementById(mezera).style.display="none";
}

function add(happy,id_input) {
id=id_input+"txt";
smiledone = false; G = document.getElementById(id);
if ((navigator.appName=='Microsoft Internet Explorer')&&(!window.opera)) {
if((document.selection)&&(G.value.indexOf(document.selection.createRange().text)>-1)) {
G.focus ();
if (!document.selection.createRange().text) {
document.selection.createRange().text = happy;
smiledone = true; };};}
else { var selLength = G.textLength;
var selStart = G.selectionStart;
var selEnd = G.selectionEnd;
var s1 = (G.value).substring(0,selStart);
var s2 = (G.value).substring(selStart, selEnd);
var s3 = (G.value).substring(selEnd, selLength);
if (s2=='') G.value = s1 + happy + s3;
if (s2=='') smiledone=true;
};

hide(id_input+"velikost_pisma");
hide(id_input+"barva_pisma");

if (!smiledone) G.value += happy; G.focus();

};
