jQuery(function($) {
  
  /* ---------------------------------------------------------------- 
  	vlozeni odkazu pro tisk do paticky
  ---------------------------------------------------------------- */
  $('#footer > ul').append('<li class="flr no-bull"><a href="javascript:window.print();">'+textPrint+'</a></li>');
  
  
  /* ---------------------------------------------------------------- 
  	search focus
  ---------------------------------------------------------------- */
    $(".auto-defaults textarea[title], .auto-defaults input[title][type=text], .auto-defaults input[title][type=password]").each( function(index) {
        if( '' == $(this).val() || $(this).attr('title') == $(this).val() ) {
            $(this).val( $(this).attr('title') );
            $(this).addClass('default');
        }
        $(this).focus( function() {
            if( $(this).attr('title') == $(this).val() ) {
                $(this).val('');
                $(this).removeClass('default');
            } 
        });
        $(this).blur( function() {
            if( '' == $(this).val() ) {
                $(this).val( $(this).attr('title') );
                $(this).addClass('default');
            } 
        });
    });

  /* ---------------------------------------------------------------- 
  	fancy box (lightbox viewer)
  ---------------------------------------------------------------- */
  $("a[rel='thumbnail']").fancybox({
    'centerOnScroll': false,
    //'imageScale': true, 
    'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500 
  });
  // ajax viewer
  $("a.text-box").fancybox({
    'centerOnScroll': false, 
    'zoomOpacity': true,
		'overlayShow': true,
		'zoomSpeedIn': 500,
		'zoomSpeedOut': 500,
		'frameWidth': 600,
		'frameHeight': 500,
		'hideOnContentClick': false
  });
  
  
  /* ---------------------------------------------------------------- 
  	corners
  ---------------------------------------------------------------- */
  $.fn.corners = function(options) {
    var opts = $.extend({}, $.fn.corners.defaults, options);
    return this.each(function() {
      $this = $(this);
      var corners = '';
      if (opts.topLeft) { corners += '<div class="top-left"></div>'; }
      if (opts.topRight) { corners += '<div class="top-right"></div>'; }
      if (opts.bottomLeft) { corners += '<div class="bottom-left"></div>'; }
      if (opts.bottomRight) { corners += '<div class="bottom-right"></div>'; }
      
      var mTop = $this.css('margin-top');
      if (mTop != '0px') {
        $this.css({'margin-top': '0px'});
      }
      
      $this.wrap('<div class="corners"></div>').parent().css({'margin-top': mTop}).append(corners);
    });
  };
  // corners defaults
  $.fn.corners.defaults = {
    topLeft: true,
    topRight: true,
    bottomLeft: true,
    bottomRight: true
  };
  
  /*
  // init corners
  if ($('.shp').length == 0) { // všechny stránky kromě Super HP
    $('#product-of-day, .banner').not('#header .banner').corners();
  }
  else { // Super HP
    $('#product-of-day, #aside-right .banner:first').corners({topLeft: false, topRight: false});
    $('.banner').not('#aside-right .banner:first, #header .banner').corners();
  }
  $('.banner-top, .dark-block').corners({topLeft: false, topRight: false});
  $('.cTop').corners({bottomLeft: false, bottomRight: false});
  ie6 = $.browser.msie && $.browser.version < 7;
  if (!ie6) { $('#login-form').corners({topLeft: false, topRight: false}); }
  */
  
  /* ---------------------------------------------------------------- 
  	toggle
  ---------------------------------------------------------------- */
	$('.toggle').next().hide().end().click(function() {
    $(this).next().slideToggle();
  });
  
  
  /* ---------------------------------------------------------------- 
  	form legend
  ---------------------------------------------------------------- */
	$('form legend:not(:has(span))').wrapInner('<span/>');
	
	
	/* ---------------------------------------------------------------- 
  	table fix (if data overflow)
  ---------------------------------------------------------------- */
	$('#content table').wrap('<div class="table-fix" />');
	

});

