/*
v1.03 Copyright (c) 2006 Stuart Colville
http://muffinresearch.co.uk/archives/2006/04/29/getelementsbyclassname-deluxe-edition/

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial 
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 
IN THE SOFTWARE.
*/
  
function getElementsByClassName(strClass, strTag, objContElm) {
  strTag = strTag || "*";
  objContElm = objContElm || document;    
  var objColl = objContElm.getElementsByTagName(strTag);
  if (!objColl.length &&  strTag == "*" &&  objContElm.all) objColl = objContElm.all;
  var arr = new Array();                              
  var delim = strClass.indexOf('|') != -1  ? '|' : ' ';   
  var arrClass = strClass.split(delim);    
  for (var i = 0, j = objColl.length; i < j; i++) {                         
    var arrObjClass = objColl[i].className.split(' ');   
    if (delim == ' ' && arrClass.length > arrObjClass.length) continue;
    var c = 0;
    comparisonLoop:
    for (var k = 0, l = arrObjClass.length; k < l; k++) {
      for (var m = 0, n = arrClass.length; m < n; m++) {
        if (arrClass[m] == arrObjClass[k]) c++;
        if ((delim == '|' && c == 1) || (delim == ' ' && c == arrClass.length)) {
          arr.push(objColl[i]); 
          break comparisonLoop;
        }
      }
    }
  }
  return arr; 
}

// To cover IE 5 Mac lack of the push method
Array.prototype.push = function(value) {this[this.length] = value; };

function in_array (needle, haystack, argStrict) {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: vlado houba
    // *     example 1: in_array('van', ['Kevin', 'van', 'Zonneveld']);
    // *     returns 1: true
    // *     example 2: in_array('vlado', {0: 'Kevin', vlado: 'van', 1: 'Zonneveld'});
    // *     returns 2: false
    // *     example 3: in_array(1, ['1', '2', '3']);
    // *     returns 3: true
    // *     example 3: in_array(1, ['1', '2', '3'], false);
    // *     returns 3: true
    // *     example 4: in_array(1, ['1', '2', '3'], true);
    // *     returns 4: false
    var key = '', strict = !!argStrict;
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
    return false;
}

function winW() {
	if (window.innerWidth) return window.innerWidth;
	else if (document.documentElement && document.documentElement.clientWidth)
		return document.documentElement.clientWidth;
	else if (document.body && document.body.clientWidth)
		return document.body.clientWidth;
	else return null;
}
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 getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

var zIndexPopUp = 150;
var spaceSet = 1;
function OpenPopupDiv(id, action, reply){

  var popupDiv = document.getElementById(id);
  var fade = document.getElementById("fade");
  var space = document.getElementById("space");
  if(action == "display"){

  var wHeight = document.body.scrollHeight;
  var wHeightF = winH();
  if(wHeight<winH() && spaceSet){
    space.style.height = (wHeightF-wHeight-20)+"px";
    spaceSet = 0;
  }
  wHeight = document.body.scrollHeight+21;

    var sliderpos = getScrollXY();
    var left = ((winW() - 500)/2);
    popupDiv.style.top = 215+sliderpos[1]+"px";
    popupDiv.style.left = left+"px";
    popupDiv.style.display = "block";
    popupDiv.style.zIndex = zIndexPopUp;
      zIndexPopUp = zIndexPopUp+1;
    fade.style.height = (wHeight)+"px";
    fade.style.display = "block";
    // nastavení textu pro guestbook popup
    if(id=="popupGuestbookReply"){
      document.getElementById("smileys").style.display = "block";
      if(reply==0){
        document.getElementById('popupReplyText').style.display = "none";
        document.getElementById('headPopupAddNick').innerHTML = headNewText+headReplyLink;
        document.getElementById('guestbookPopupLegend').innerHTML = headNewHead;
        document.getElementById('GBreply').value = 0;
      }
      else{
        document.getElementById('GBreply').value = reply;
        var user = document.getElementById("nickID"+reply).innerHTML;
        document.getElementById('popupReplyText').style.display = "block";
        document.getElementById('popupReplyText').innerHTML = "<span>"+user+":</span> "+document.getElementById("rText"+reply).innerHTML;
        document.getElementById('headPopupAddNick').innerHTML = headReplyText+" "+"#"+reply+": "+user+headReplyLink;
        document.getElementById('guestbookPopupLegend').innerHTML = headReplyHead;
      }
    }
  }
  else{
    popupDiv.style.display = "none";
    fade.style.display = "none";
  }
}

function smileys(id){
  document.getElementById("guestbookText").value += " "+id;
}
function smileysOpen(action){
  if(action=="open"){
    document.getElementById("smileys2").style.display = "block";
    document.getElementById("smileysLink").innerHTML = "<a href='#' OnClick=\"smileysOpen('close'); return false;\"><img src='/pictures/icon_minus.png' alt='minus' title='Minus' /></a>";
  }
  else{
    document.getElementById("smileys2").style.display = "none";
    document.getElementById("smileysLink").innerHTML = "<a href='#' OnClick=\"smileysOpen('open'); return false;\"><img src='/pictures/icon_plus.png' alt='open' title='Plus' /></a>";
  }
}

function strankovani(page){
  document.getElementById("pageLinkID"+page).className = "active";
  document.getElementById("pageLinkID"+fotogalerieStrana).className = "";
  document.getElementById("photoPage"+fotogalerieStrana).style.display = "none";
  document.getElementById("photoPage"+page).style.display = "block";
  fotogalerieStrana = page;
}



var tempX = 0;
var tempY = 0;
var IE = document.all?true:false;

function getMouseXY(e) {
  if (IE) {
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {
    tempX = e.pageX
    tempY = e.pageY
  }  
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  return true
}

function move(id){
  if (!IE) document.captureEvents(Event.MOUSEMOVE)
  document.onmousemove = getMouseXY;
  var zbyvaW = (winW()-tempX);
  if(zbyvaW<300){tempX = tempX-(300-zbyvaW);}

  var pocet = document.getElementById(id).value;
  if(pocet>1){
    var zbyvaH = (winH()-tempY);
    var vyska_div = 78*pocet;
    if(zbyvaH<vyska_div){tempY = tempY-(vyska_div-zbyvaH);}
  }

    var div = document.getElementById(id);
	  div.style.left = tempX + 12 + 'px';
	  div.style.top  = tempY + 20 + 'px';
    div.style.display = 'block';
}

function hide(id){
  document.getElementById(id).style.display = 'none';
}