document.write('<style type="text/css">.hide-from-js{display:none;}</style>')
function confirmation(text){
  return confirm('Opravdu chcete \n\n'+text+' ???');
}
function open_podrobnosti(href){
  if (  window.open(href)  )
      return false
  else
      return true
}

function open_foto(href, w, h){
  if (isNaN(w)) w=640;
  if (isNaN(h)) h=480;
  if (  window.open(href, '', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width='+w+',height='+h+'')  )
      return false
  else
      return true
}
function is_valid_tel(tel){
  if (tel.length<9 || isNaN(tel)) return false
  else return true
}
function check_pozadavek()
{
  var jmeno   = pozadavek.jmeno_zakaznika.value;
  var telefon = pozadavek.telefon_zakaznika.value;
  var kontakt = pozadavek.kontakt_zakaznika.value;
  var err='';
  if (!kontakt){
      err +="Zadejte prosím další kontakt na sebe (např.: mail, další telefon)\n";
      pozadavek.kontakt_zakaznika.style.background='#faa';
      pozadavek.kontakt_zakaznika.focus();
  }
  if (!telefon || !is_valid_tel(telefon)) {
      err +="Vyplňte prosím svůj telefon (alespoň 9 čísel, bez mezer a lomítek).\n";
      pozadavek.telefon_zakaznika.style.background='#faa';
      pozadavek.telefon_zakaznika.focus();
  }
  if (!jmeno){
      err +="Zadejte prosím své jméno.\n";
      pozadavek.jmeno_zakaznika.style.background='#faa';
      pozadavek.jmeno_zakaznika.focus();
  }
  if (err!='') {
    alert(err);
    return false;
  } else return true;
}

$(document).ready(function()
{
	$(".contactBroker").click(function()
  {
		$("#contactBroker").fadeToggle("slow", "linear");
	});

  $(".printPage").click(function()
  {
    var printPageHref = $('.printPage').attr('href');
    if($("#contactBroker").css('display') == 'none')
      $('.printPage').attr('href', printPageHref + '&contactBroker=1');
    //console.debug(printPageHref);
  });


});

$(document).ready(function()
{
	$(".slider .inzerat-foto").live('mouseover', function(){
		$("#main_foto_link").attr('href', $(this).attr('href'));
    $("#main_foto").attr('src', $(this).find('img').attr('src'));
	});
});

$(function() {
    $(".slider").jCarouselLite({
        btnNext: ".next",
        btnPrev: ".prev",
        circular: false
    });
});

// fotogalerie
$(document).ready(function() {
    $("#topImages .inzerat-foto").fancybox({'overlayOpacity':0.7});
});

//casovace
var actualDatetime;
$(function(){
  actualDatetime = new Date($('#current_datetime').attr('value'));
  if($('#aukce').length > 0)
  {//aktivni pouze u aukce
    var timeStampRemaining = $('#timestamp_remaining').attr('value');
    if(timeStampRemaining > 0)
    {
      $('#remaining_datetime').countdown(
      {
        until: + timeStampRemaining,
        layout: '{dn} {dl}, {hn} {hl}, {mn} {ml}, {sn} {sl}',
        onExpiry: Reload,
        onTick: AuctionTimer, tickInterval: 1
      });
      if ($('#aukce_login').length == 0) setTimeout('window.location.reload()', 20000); //obnovi stranku kazdych 20 sekund
    }
  }
});

function Reload()
{
  window.location.reload();
}

function AuctionTimer()
{
  actualDatetime.setSeconds(actualDatetime.getSeconds()+1);
  var month = (actualDatetime.getMonth()+1).toString();
  var day = (actualDatetime.getDate()).toString();
  var hours = actualDatetime.getHours().toString();
  var minutes = actualDatetime.getMinutes().toString();
  var seconds = actualDatetime.getSeconds().toString();
  if (month.length == 1) month = '0' + month;
  if (day.length == 1) day = '0' + day;
  if (hours.length == 1) hours = '0' + hours;
  if (minutes.length == 1) minutes = '0' + minutes;
  if (seconds.length == 1) seconds = '0' + seconds;
  $('#actual_datetime').text(day+'.'+month+'.'+actualDatetime.getFullYear()+' '+hours+':'+minutes+':'+seconds);
}

function priceFormat(nStr)
{
	nStr += '';
	x = nStr.split(',');
	x1 = x[0];
	x2 = x.length > 1 ? ',' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ' ' + '$2');
	}
  if (x2 == '') x2 = ',-'
	return x1 + x2;
}

