/* 
  ------------------------------------------------
  PVII Equal CSS Columns scripts -Version 2
  Copyright (c) 2005 Project Seven Development
  www.projectseven.com
  Version: 2.1.0
  ------------------------------------------------
*/
function P7_colH2(){ //v2.1.0 by PVII-www.projectseven.com
 var i,oh,h=0,tg,el,np,dA=document.p7eqc,an=document.p7eqa;if(dA&&dA.length){
 for(i=1;i<dA.length;i+=2){dA[i+1].style.paddingBottom='';}for(i=1;i<dA.length;i+=2){
 oh=dA[i].offsetHeight;h=(oh>h)?oh:h;}for(i=1;i<dA.length;i+=2){oh=dA[i].offsetHeight;
 if(oh<h){np=h-oh;if(!an&&dA[0]==1){P7_eqA2(dA[i+1].id,0,np);}else{
 dA[i+1].style.paddingBottom=np+"px";}}}document.p7eqa=1;
 document.p7eqth=document.body.offsetHeight;
 document.p7eqtw=document.body.offsetWidth;}
}
function P7_eqT2(){ //v2.1.0 by PVII-www.projectseven.com
 if(document.p7eqth!=document.body.offsetHeight||document.p7eqtw!=document.body.offsetWidth){P7_colH2();}
}
function P7_equalCols2(){ //v2.1.0 by PVII-www.projectseven.com
 var c,e,el;if(document.getElementById){document.p7eqc=new Array();
 document.p7eqc[0]=arguments[0];for(i=1;i<arguments.length;i+=2){el=null;
 c=document.getElementById(arguments[i]);if(c){e=c.getElementsByTagName(arguments[i+1]);
 if(e){el=e[e.length-1];if(!el.id){el.id="p7eq"+i;}}}if(c&&el){
 document.p7eqc[document.p7eqc.length]=c;document.p7eqc[document.p7eqc.length]=el}}
 setInterval("P7_eqT2()",10);}
}
function P7_eqA2(el,p,pt){ //v2.1.0 by PVII-www.projectseven.com
 var sp=10,inc=20,g=document.getElementById(el);np=(p>=pt)?pt:p;
 g.style.paddingBottom=np+"px";if(np<pt){np+=inc;
 setTimeout("P7_eqA2('"+el+"',"+np+","+pt+")",sp);}
}

var urlRoot = '/lecebne_lazne_bohdanec/llb.cz/web/www/';

function vote(form, idInquiry, ajaxPath)
{
   var selected = false; 
   for (var i = 0; i < form.inquiryradio.length; i++) {
      if (form.inquiryradio[i].checked == true) {
         selected = true;
         idAnswer = form.inquiryradio[i].value;
         break;
      }
   }
   
   if (typeof(idAnswer) == 'undefined') {
      alert('Prosím, nezapomeňte vybrat svoji odpověď.');
   } else {
   
      var options = {
         method: 'post',
         onSuccess: function(response) {
            if ('!IP!' != trim(response.responseText)) {
               var hodnoty = response.responseText.split(/\//);
               // zmenime velikost pruhu s odpovedi
               var odpovedi = document.getElementsByClassName('graphb', $('inquiry-' + idInquiry));
               for (var i = 0; i < odpovedi.length; i++) {
                  // oddelime procenta od celkovych poctu
                  var hodnotyTmp = hodnoty[i].split(/#/);
                  odpovedi[i].style.width = hodnotyTmp[0] + '%';
               }
               // zmenime text
               var procentoText = document.getElementsByClassName('graphn', $('inquiry-' + idInquiry));
               for (var i = 0; i < odpovedi.length; i++) {
                  // oddelime procenta od celkovych poctu
                  var hodnotyTmp = hodnoty[i].split(/#/);
                  procentoText[i].innerHTML = hodnotyTmp[0] + '% (' + hodnotyTmp[1] + ')';
               }
               
               // nastavime text
               $('inquiry-result-' + idInquiry).innerHTML = 'Děkujeme za Váš hlas.';

                // nastavime cookie ze uz uzivatel hlasoval
                createCookie('anketa-' + idInquiry,'yes',180);
            } else {
               // nastavime text
               $('inquiry-result-' + idInquiry).innerHTML = 'Už jste hlasoval(a) v této anketě.';
            }
            
            // vypneme hlasovaci buttony
            var radioButtony = document.getElementsByClassName('inquiry-radio', $('inquiry-' + idInquiry));
            for (var i = 0; i < radioButtony.length; i++) {
               radioButtony[i].style.display = 'none';
            }
         }
      }
      
      var update = new Ajax.Request(urlRoot + 'ajax/vote/' + idAnswer + '/' + idInquiry, options);
   }
}

/**
 * Popup okno
 *
 */
function popup (url, width, height)
{
   var windowParams = ('width=' + width + ',height=' + height + ',resizable=no, scrollbars=no');
   var okno = open(url + '/', 'newWindow', windowParams);
   okno.focus();
}

function editContent(id)
{
   popup(id, 700, 900);
}

/**
 * Odstranuje netisknutelne znaky z konce a zacatku stringu
 *
 * @param string string k osetreni
 * @return string upraveny text
 */
function trim (string)
{
 return string.replace( /^\s*|\s*$/g, '');
}

/**
 * odkaz na otevirani odkazu do novych oken
 * k odkazu se prida atribut rel="external"
 */
function externalLinks() 
{
   if (!document.getElementsByTagName) {
      return;
   }
   var anchors = document.getElementsByTagName("a");
   for (var i = 0; i < anchors.length; i++) {
      var anchor = anchors[i];
      if (anchor.getAttribute("href") &&
          anchor.getAttribute("rel") == "external") {
         anchor.target = "_blank";
      }
   }
}
window.onload = externalLinks;

/* zobrazit element dle ID */
function show(show) {
	var show = document.getElementById(show);
	show.style.display = 'block';
}

function AddFavorite(linkObj,addUrl,addTitle)
{
  if (document.all && !window.opera)
  {
    window.external.AddFavorite(addUrl,addTitle);
    return false;
  }
  else if (window.opera && window.print)
  {
    linkObj.title = addTitle;
    return true;
  }
  else if ((typeof window.sidebar == 'object') && (typeof window.sidebar.addPanel == 'function'))
  {
    if (window.confirm('Přidat oblíbenou stránku jako nový panel?'))
    {
      window.sidebar.addPanel(addTitle,addUrl,'');
      return false;
    }
  }
  window.alert('Po potvrzení stiskněte CTRL-D,\nstránka bude přidána k vašim oblíbeným odkazům.');
  return false;
}


function openWindow(name,width,height) {
 iMyWidth = (window.screen.width/2) - (324)
 iMyHeight = (window.screen.height/2) - (275)
 fokus = 'f = window.open("","' + name + '", "width=' + width + ',height=' + height + ',resizable=no,left=' + iMyWidth + ',top=' + iMyHeight + ',screenX=' + iMyWidth + ',screenY=' + iMyHeight + ',scrollbars=1")';
 //alert(fokus);
 eval(fokus);
 f.focus();
}



function m(n)
{
    var v = document.getElementById("href"+n).style.display;

    if (document.getElementById("href"+n).style.display=="none")
    {
        document.getElementById("href"+n).style.display = "block";


    }
    else
    {
        document.getElementById("href"+n).style.display = "none";

    }
}

