
var varInterval; // variable fot clearing header slide show (stop slide show)
var varIntervalReferences; // varibale for clearing references interval (hide active references info) 
var direct = 1; // default direct for header picture cycle (1=ahead; -1=back)

// onload
jQuery(document).ready(function() {
  jQuery("#mycarousel").jcarousel({
    scroll: 3,
    initCallback: mycarousel_initCallback,
    // This tells jCarousel NOT to autobuild prev/next buttons
    buttonNextHTML: null,
    buttonPrevHTML: null
  });
  // header slide show
  //varInterval = setInterval( "slideSwitch()", 5000 );
      $("a.viewBig").fancybox({
        'overlayShow'  : false,
        'transitionIn'  : 'elastic',
        'transitionOut'  : 'elastic'
      });
  
  
  $(function() {
    setInterval( "changeButtonAndText(0);", 5000 );
  });
  
});

// header slide show
function slideSwitch() {
/*
  var $active = $('#flash DIV.active');
   
  if ( $active.length == 0 ) $active = $('#flash DIV:last');

  if(direct==1)var $next =  $active.next().length ? $active.next() : $('#flash DIV:first');
  else var $next =  $active.prev().length ? $active.prev() : $('#flash DIV:last');

  $active.addClass('last-active');

  $next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 0, function() {
      $active.removeClass('active last-active');
    });
*/
}

function setAutoChange()
{
  clearInterval(varInterval);
}


/**
 * We use the initCallback callback
 * to assign functionality to the controls
 * functions for references Box
 */
function mycarousel_initCallback(carousel) {
  jQuery('.jcarousel-control a').bind('click', function() {
    carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text())*3-2);
    
    var $active = $('#numbering .active');
    $active.removeClass('active last-active');
    $('.cislovani-2:first').addClass('active');
    for(i=1;i<jQuery.jcarousel.intval(jQuery(this).text());i++)setClassForActualIndex(1);
    
    return false;
  });

  jQuery('.jcarousel-scroll select').bind('change', function() {
    carousel.options.scroll = jQuery.jcarousel.intval(this.options[this.selectedIndex].value);
    setClassForActualIndex();
    return false;
  });

  jQuery('#mycarousel-next').bind('click', function() {
    carousel.next();
    setClassForActualIndex(1);
    return false;
  });

  jQuery('#mycarousel-prev').bind('click', function() {
    carousel.prev();
    setClassForActualIndex(-1);
    return false;
  });
    
};

function setClassForActualIndex(direct) {
  
  var $active = $('#numbering .active');
  
  if ( $active.length == 0 ) $active = $('.cislovani-2 .active:last');

  if(direct==1)var $next =  $active.next().length ? $active.next() : $('.cislovani-2 .active:first');
  else var $next =  $active.prev().length ? $active.prev() : $('.cislovani-2 .active:last');

  $active.addClass('last-active');

  $next.css({opacity: 0.0})
    .addClass('active')
    .animate({opacity: 1.0}, 0, function() {
      $active.removeClass('active last-active');
    });
} 

function setDisplay(id)
{ 
  clearInterval(varIntervalReferences);
  clearAllReferences();
  $("#"+id).removeClass('nodisplay');
  $("#"+id).addClass('display');
  varIntervalReferences = setInterval( "clearAllReferences()", 5000 );
}

function clearAllReferences() {
  $('.reference-info').removeClass('display');
  $('.reference-info').addClass('nodisplay');
}


// new references
/* Case Studies Boxes */
$(function(){
  $('.box').hover(function(){
		$('.details',$(this)).stop().animate({top:"0"}, 400)
		$('.details p',$(this)).stop().animate({opacity:"1"}, 400)
	},function(){
		if(false == $(this).hasClass('current'))
		{
			$('.details',$(this)).stop().animate({top:"-100"}, 400)
			$('.details p',$(this)).stop().animate({opacity:"0"}, 400)
		}
	})
});


// or specify the exact effects you want using a comma delimited string; 
// you can disable the effect randomization by setting the  
// 'randomizeEffects' option to false 
$(document).ready(function() {
  //$('#flash').before('<div id="nav">'); 
  $('#flash').cycle({  
    randomizeEffects: false, 
    easing:          'easeInBack', // easing supported via the easing plugin
    speed:    2000,
    timeout:  5000,
    pause:   1,		    
    fx:       'fade',
    before:   function(c,n,o) {$(o.caption).html(o.currFx);},
    caption:  '#caption1',
    prev:   '#sipka-leva', 
    next:   '#sipka-prava'
    //pager:  '#nav'  
  }); 
});


function wnew(o){
	window.open(o);
}
	
function JSL(url, jmeno, w, h)
{
    okno = window.open("", jmeno, 'resizable=0,top=50,left=50,menubar=0,width=' + w + ',height=' + h);
        okno.document.write("<html><body style='margin:0px;padding:0px;' ><img src='"+url+"' onclick='window.close();' style='cursor: hand'></body></html>");
}

	function testEmail(strIn) {
		re = /^[^.]+(\.[^.]+)*@([^.]+[.])+[a-z]{2,5}$/;
		return strIn.search(re) == 0;
	}
	function validate(f) {
		if (f.email.value == "" || f.email.value == "@") {
			alert("Vyplňte prosím emailovou adresu!");
			f.email.focus();
			return false;
		} else if (!testEmail(f.email.value)) {
			alert("V emailové adrese je pravděpodobně chyba!");
			f.email.focus();
			return false;
		} else if (f.telefon.value == "") {
			alert("Vyplňte prosím telefonní číslo!");
			f.telefon.focus();
			return false;
		}
		return true;
	}
	
/*
* vertical news ticker
* Tadas Juozapaitis ( kasp3rito@gmail.com )
* http://plugins.jquery.com/project/vTicker
*/
(function(a){a.fn.vTicker=function(b){var c={speed:700,pause:4000,showItems:3,animation:"",mousePause:true,isPaused:false,direction:"up",height:0};var b=a.extend(c,b);moveUp=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:first").clone(true);if(e.height>0){d=f.children("li:first").height()}f.animate({top:"-="+d+"px"},e.speed,function(){a(this).children("li:first").remove();a(this).css("top","0px")});if(e.animation=="fade"){f.children("li:first").fadeOut(e.speed);if(e.height==0){f.children("li:eq("+e.showItems+")").hide().fadeIn(e.speed)}}h.appendTo(f)};moveDown=function(g,d,e){if(e.isPaused){return}var f=g.children("ul");var h=f.children("li:last").clone(true);if(e.height>0){d=f.children("li:first").height()}f.css("top","-"+d+"px").prepend(h);f.animate({top:0},e.speed,function(){a(this).children("li:last").remove()});if(e.animation=="fade"){if(e.height==0){f.children("li:eq("+e.showItems+")").fadeOut(e.speed)}f.children("li:first").hide().fadeIn(e.speed)}};return this.each(function(){var f=a(this);var e=0;f.css({overflow:"hidden",position:"relative"}).children("ul").css({position:"absolute",margin:0,padding:0}).children("li").css({margin:0,padding:0});if(b.height==0){f.children("ul").children("li").each(function(){if(a(this).height()>e){e=a(this).height()}});f.children("ul").children("li").each(function(){a(this).height(e)});f.height(e*b.showItems)}else{f.height(b.height)}var d=setInterval(function(){if(b.direction=="up"){moveUp(f,e,b)}else{moveDown(f,e,b)}},b.pause);if(b.mousePause){f.bind("mouseenter",function(){b.isPaused=true}).bind("mouseleave",function(){b.isPaused=false})}})}})(jQuery);


function showNews(event)
{
	elNews = event.currentTarget;
	elDetail = document.getElementById("det"+elNews.id);
	if(elDetail.style.display=="block")
		elDetail.style.display = "none";
	else
		elDetail.style.display = "block";
}// end of 


var actButton = 1;
var stopAutoChange = 0;
function changeButtonAndText(handChange)
{

if(handChange==1)
  {
    for(i=1;i<=5;i++)document.getElementById("rm_mid"+i).className="";
    for(i=1;i<=5;i++)document.getElementById("h2box"+i).className="odrazka-1 nodisplay";
    document.getElementById("h2box"+actButton).className="odrazka-1";
  }
  if(stopAutoChange==0)
  {
    document.getElementById("rm_mid"+actButton).className="";
    document.getElementById("h2box"+actButton).className="odrazka-1 nodisplay";
    actButton=actButton+1;
    if(actButton>5)actButton=1;

    document.getElementById("rm_mid"+actButton).className="but";
    document.getElementById("h2box"+actButton).className="odrazka-1";
  } else if(stopAutoChange==1)document.getElementById("rm_mid"+actButton).className="";
}
