function getElementsByClass(searchClass,node,tag)
{
  var classElements = new Array();
  if (node == null)
    node = document;
  if (tag == null)
    tag = '*';
  var els = node.getElementsByTagName(tag);
  var elsLen = els.length;
  var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
  var j = 0;
  for (i = 0; i < elsLen; i++)
  {
    if (pattern.test(els[i].className))
    {
      classElements[j] = els[i];
      j++;
    }
  }
  return classElements;
}

function tisk()
{
  ver = parseInt(navigator.appVersion)
  if (ver >= 4) self.print()
}

function bookmarksite(title,url)
{
  if (window.sidebar) // firefox
	 window.sidebar.addPanel(title, url, "");
	else if(window.opera && window.print)
  { // opera
    var elem = document.createElement('a');
		elem.setAttribute('href',url);
		elem.setAttribute('title',title);
		elem.setAttribute('rel','sidebar');
		elem.click();
	}
  else if(document.all)// ie
	 window.external.AddFavorite(url, title);
}

function ShowElement(id){
	if(document.getElementById(id).style.display=='none'){
		Effect.BlindDown(id, {duration: 1.0});
// 		setTimeout("document.getElementById('"+id+'_link'+"').innerHTML=document.getElementById('"+id+'_link'+"').innerHTML.replace(/Zobrazit/,\"Skrýt\");",1000);
	} else {
		Effect.BlindUp(id, {duration: 1.0});
// 		setTimeout("document.getElementById('"+id+'_link'+"').innerHTML=document.getElementById('"+id+'_link'+"').innerHTML.replace(/Skrýt/,\"Zobrazit\");",1000);
	}
}


function blind(divid) {
  jQuery('#'+divid).slideToggle(1000);
  return false;
}

$(document).ready(function() {

	$('.soupis tr').mouseover(function(e) {
// 	alert(this+' td');
    $(this ).addClass('over');
  });

	$('.soupis tr').mouseout(function(e) {
    $(this).removeClass('over');
  });


  //transition effect
  $('#kategorie_tree .row').mouseover(function (e) {
  	$(this).css('background', '#E5E5E5');
  
  	$(this).mouseout(function (e) {
  		$(this).css('background', '#EEE');
  	});

  });

});

$(document).ready(function() {
  $('#search_text, .input_text, .textarea').click(function(e) {
  	$(this).attr('value','');
  });
  
  $('#search_text').focusout(function(e) {
    var obsah = $(this).attr('value');
    if(obsah == '')
    {
      $(this).attr('value','hledáte...')
    }
  });
  $('[name=email]').focusout(function(e) {
    var obsah = $(this).attr('value');
    if(obsah == '')
    {
      $(this).attr('value','Email')
    }
  });
  $('[name=jmeno]').focusout(function(e) {
    var obsah = $(this).attr('value');
    if(obsah == '')
    {
      $(this).attr('value','Jméno')
    }
  });
  $('.dotaz .textarea').focusout(function(e) {
    var obsah = $(this).attr('value');
    if(obsah == '')
    {
      $(this).attr('value','Text Vašeho dotazu')
    }
  });
  
});

$(document).ready(function() {
  // po odeslání formuláře zvaliduje pole
  $('.validate').submit(function(e) {
  
    var id = $(this).attr('id');
  	// validní nastavime na true
    var validni = true
  
    // zresetujeme obsah elementu pro chybovou hlášku
    $('.form_error').html('');
  
    // projedeme všechny "required_field"
    $('#'+id +' .required_field').each(function() {
      var hodnota = $(this).attr('value');
      var name = $(this).attr('name');
      if(hodnota == '' || hodnota == 'Jméno' || hodnota == '@' || hodnota == 'Email')
      {
        // pokud je nulová hodnota, nastaví se validni = false a nastaví se barva labelu na červenou
        validni = false;
        $('input[name*='+name+']').css('color','#F00').css('border','0px solid #F00');        
      }
      else
      {
        $('input[name*='+name+']').css('color','#000').css('border','none');
      }
    });
  
    if(validni == false)
    {
      $('.form_error').html('Formulář nebyl odeslán, vyplňte prosím všechna zvýrazněná pole');
      // zrušíme akci odesílání formuálře
  		e.preventDefault();
  	}
  });


//   $('#ke_stazeni a').click(function(e) {
//     e.preventDefault();
// 
//     $('.window').show();
//     //Get the screen height and width
//     var maskHeight = $(window).height();
//     var maskWidth = $(window).width();
// 
//     //Set height and width to mask to fill up the whole screen
//     $('#mask').css({'width':maskWidth,'height':maskHeight});
// 
//     $('#mask').fadeTo("slow",0.8);
//   });
// 
//   $('#mask').click(function() {
//     $(this).hide();
//     $('.window').hide();
//   });

    $('img[align=right]').addClass('fright');
    $('img[align=left]').addClass('fleft');

});
