$(function() {

  /* ----------------------------------------------------------------
    Debugging
  ---------------------------------------------------------------- */
  $.fn.log = function (msg) {
    if (window.console && window.console.log) {
      if (msg) {
        window.console.log('[schlecker] %s: %o', msg, this);
      } else {
        window.console.log('[schlecker] ' + this);
      }
    }
    return this;
  };

  function log(variable, msg) {
    if (window.console && window.console.log) {
      if (msg) {
        window.console.log('[schlecker] %s: %o', msg, variable);
      } else {
        window.console.log('[schlecker] ' + variable);
      }
    }
  }


  /* ----------------------------------------------------------------
    Browsers and versions
  ---------------------------------------------------------------- */
  var isIE = ($.browser.msie);
  var isOpera = ($.browser.opera);

  // add styles for Opera browser
  if (isOpera) {
    $('head').append('<link rel="stylesheet" type="text/css" href="css/screen-opera.css" media="screen,projection" />');
  }


  /* ----------------------------------------------------------------
    Tabs
  ---------------------------------------------------------------- */
  var tabContainers = $('div.tabs > div');
  tabContainers.hide().filter(':first').show();

  $('div.tabs ul.tabNavigation a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('div.tabs ul.tabNavigation a').removeClass('selected');
    $(this).addClass('selected');
    return false;
  }).filter(':first').click();

  // if we are in section pharmacy (body class) - display second tab
  $('.pharmacy div.tabs ul.tabNavigation li.second a').click();
    

  /* ----------------------------------------------------------------
    Corners
  ---------------------------------------------------------------- */
  if (isIE || isOpera) {
    $('a.button, #ver-program').corners({
      debug: true
    });
    $('input[type=submit]').corners({
      wrap: true,
      display: 'inline-block',
      debug: true
    });
    $('.tabNavigation a').corners({
      bottomLeft: false,
      bottomRight: false,
      debug: true
    });
    $('a.button3, .box, #letter-box').corners({
      width: '7px',
      height: '7px',
      debug: true
    });
  }


  /* ----------------------------------------------------------------
    Vlozeni odkazu pro tisk do paticky
  ---------------------------------------------------------------- */
  $('#footer-top').prepend('<p id="print"><a href="javascript:window.print();">Vytisknout</a></p>');


  /* ----------------------------------------------------------------
    Fancybox
  ---------------------------------------------------------------- */
  $("a.text-box").fancybox({
    'padding': 3,
    'hideOnContentClick': false,
    'overlayShow': false,
    'frameWidth': 500,
    'frameHeight': 500
  });
  $("a.flash-box").fancybox({
    'padding': 3,
    'hideOnContentClick': false,
    'centerOnScroll': false,
    'overlayShow': true,
    'frameWidth': 900,
    'frameHeight': 595
  });
  $("a.flash-coupon-box").fancybox({
    'padding': 3,
    'hideOnContentClick': false,
    'centerOnScroll': false,
    'overlayShow': true,
    'frameWidth': 1024,
    'frameHeight': 345
  });
  // fancy text box corners
  $('#fancy_bg').append('<span class="cs tl"></span><span class="cs bl"></span><span class="cs br"></span>');


  /* ----------------------------------------------------------------
    Maps
  ---------------------------------------------------------------- */
  $('#map-small, #regions').maps();
  $('#map-small-green').maps({
    height: 101
  });
  
});



$(document).ready(function(){

    // homepage audio player
    var html = '';
    html += '<div class="audio-player">';
    html += '<div class="jp-audio">';
    html += '<div class="jp-type-playlist">';
    html += '<div class="jp-jplayer" id="jquery_jplayer_1"></div>';
    html += '<div class="jp-interface" id="jp_interface_1">';
    html += '<ul class="jp-controls">';
    html += '<li><a class="jp-play jp-video-play" href="#">play</a></li>';
    html += '<li><a class="jp-pause jp-video-pause" href="#">pause</a></li>';
    html += '<li style="display: none;"><a class="jp-stop" href="#">stop</a></li>';
    html += '<li><a class="jp-mute" href="#">mute</a></li>';
    html += '<li><a class="jp-unmute" href="#">unmute</a></li>';
    html += '</ul>';
    html += '<div class="jp-progress"><div class="jp-seek-bar"><div class="jp-play-bar"></div></div></div>';
    html += '<div class="jp-volume-bar"><div class="jp-volume-bar-value"></div></div>';
    html += '<div class="jp-current-time"></div>';
    html += '<div class="jp-duration"></div>';
    html += '</div></div></div></div>';


    //$('.body-hp #content .box-bottom-hp').append(html);

    $("#jquery_jplayer_1").jPlayer({
        ready: function () {
            $(this).jPlayer("setMedia", {
                mp3: "/data/files/audio-video/promo-1.mp3"
            }).jPlayer("play");
        },
        solution: "flash, html",
        swfPath: "/js/jplayer.2.0.0",
        supplied: "mp3",
        volume: 0.5
    });
}); 

