jQuery(document).ready(function() {

		//tour mesta
		if ($('div#mapTour').height() != null) {
		$('div#mapTour span').bind("mouseover", cityOver);
		$('div#mapTour span').bind("mouseout", cityLeave);
		}
		
    /*
    popup na Homapage
    
    if ($('body#index').height() != null) {
      $.fancybox({
          'width': 640,
          'height': 420,
          'autoScale': false,
          'transitionIn': 'fade',
          'transitionOut': 'fade',
          'type': 'iframe',
          'href': '/easytone-hp-info.html'
      });
    };  
    */
		
		// fancybox
		if ($('div.inGallery').height() != null) {
		$('div.inGallery a').fancybox();
		}
		if ($('div.imagemapBlock').height() != null) {
		$('div.imagemapBlock a').fancybox();
		}
		if ($('a.l2').height() != null) {
		$('a.l2').fancybox();
		}
		
		// popup 3D
		$('a.d3button, a.d3buttonZig, p.d3view a').bind("click", open3D);
		
		// popup Download
		$('a.download, a.downloadDoc').bind("click", openDowload);
		
		// popup New Page
		$('.out').bind("click", openNewPage);
		
		// hide na startu
		$('div.selectKraj ul, div.selectMesto ul, div.facebookApp, div#blockSubcat02, div#blockSubcat03, div#blockSubcat04, div#blockSubcat05, div#blockSubcat06, div#blockSubcat07, div#blockSubcat08').hide();
		
    // spustení submenu
    if ($('ul.menuProductHorizont01').height() != null) {
		  changeBlockTabLink();
		}
			
			
		// over na clik pro vyber kraje a mesta
	  $('div.selectKraj p').bind("click", showSubmenuSelectKraj);
	  $('div.selectMesto p').bind("click", showSubmenuSelectMesto);
	  
	  // proma na indexu
	  $('#indexPromos .promoAreaIndex div').bind("mouseenter", overPromo);
	  $('#indexPromos .promoAreaIndex div').bind("mouseleave", outPromo);
	  
		// záložky
		$('ul.menuProductHorizont li a').bind("click", changeBlock);

		// záložky
		$('ul.menuProductHorizont01 li a').bind("click", changeBlock01);
		$('a.rozcestnik').bind("click", changeBlock01);

		// odkazy na zalozky
		//$('a.tablink').bind("click", changeBlockTabLink);

		if ($('div.selectKraj').height() != null) {
	  // vyber kraj
	  //$('div.selectKraj ul li').bind("click", selectValueKrajUl);
	  // vyber mesto
	  //$('div.selectMesto ul li').bind("click", selectValueMestoUl);
		}
	  
	  //  button Facebook
		$('a.facebook').bind("click", showFacebook);
		$('div.uchoFB').bind("click", hideFacebook);
		$('div.facebookApp').bind("mouseleave", hideFacebook);

		//  checkboxy
		$('table.tableFilter input').change(function() {
		  $(this).parent('td').parent('tr').children('th').children('label').toggleClass('boldet');
		});
	  jQuery.each('table.tableFilter input:checked', function() {
			$('table.tableFilter input:checked').parent('td').parent('tr').children('th').children('label').toggleClass('boldet');
	  });

		$('a#productsAnchor').click(function(e) {
			jQuery.each('ul.menuProductHorizont01 li a', function(e) {
			$('ul.menuProductHorizont01 li a').removeClass('selected');
		});
		$('.blokSubCat').hide();
		$('ul.menuProductHorizont01 li:first-child a').addClass('selected');
		$('div#blockSubcat01').show();
		$('div#cageblockSubcat01').show();
		var destination = $('#cageblockSubcat01').offset().top;
		$('html:not(:animated),body:not(:animated)').animate({scrollTop: destination-20}, 500 );
		e.preventDefault();
		})

		// selektor produktu - prodejny

		// inicializace
		/*
		span = $('<span class="ico-easytone-obleceni item"></span>');
		$('#prodEasytoneObleceni').parent().append(span);
		span = $('<span class="ico-easytone-obuv item"></span>');
		$('#prodEasytoneObuv').parent().append(span);
		span = $('<span class="ico-volnocas item"></span>');
		$('#prodVolnocas').parent().append(span);
		span = $('<span class="ico-lucka item"></span>');
		$('#prodLucka').parent().append(span);
		span = $('<span class="ico-zig item"></span>');
		$('#prodZig').parent().append(span);
		span = $('<span class="ico-vse"></span>');
		$('#prodVse').parent().append(span);
    */
		$.each($('.kolekce-select span input:checked'), function() {
			$(this).next().addClass('selected');
		});

		// udalosti
		$('.kolekce-select').find('td.item span').click(function(){
			if ($(this).hasClass('selected')) {
				$(this).removeClass('selected');
				$(this).prev().removeAttr('checked');
				$('.prodVse').removeClass('selected');
				$('.prodVse input').removeAttr('checked');
				
			}
			else {
				$(this).addClass('selected');
				$(this).prev().attr('checked', true);
				$('.prodVse').removeClass('selected');
				$('.prodVse input').removeAttr('checked');
			}
		})
		$('.prodVse span').click(function(){
			if ($(this).parent('span').hasClass('selected')) {
				$('.kolekce-select').find('span').removeClass('selected');
				/*$('.kolekce-select').find('input').removeAttr('checked');*/

				$.each($('.kolekce-select span input'), function() {
					$(this).removeAttr('checked');
				});

				$(this).parent('span').removeClass('selected');
				$(this).prev().removeAttr('checked');
			}
			else {
				$('.kolekce-select').find('span').removeClass('selected');
				/*$('.kolekce-select').find('input').removeAttr('checked');*/
      
				$.each($('.kolekce-select span input'), function() {
					$(this).removeAttr('checked');
				});

				$(this).parent('span').addClass('selected');
				$(this).prev().attr('checked', true);  
			}
		})
});

function cityOver() {
	$('div.buble').hide();
	$('div#'+$(this).attr('class')).show();
}
function cityLeave() {
	$('div.buble').hide();
}

function changeBlockTabLink() {  
	jQuery.each('ul.menuProductHorizont01 li a', function() {
		$('ul.menuProductHorizont01 li a').removeClass('selected');
	});
	if (window.location.hash != "") {
				var hashUrl = window.location.hash;
	      var idVybranehoBloku = hashUrl.replace("#","");
	      var idVybranehoBloku = idVybranehoBloku.replace("AddressJS","");
      	$('ul.menuProductHorizont01 li a').each(function() {
      		var href = $(this).attr('href');
				  var hashUrl = window.location.hash;
      		if (href == hashUrl.replace("AddressJS","")) {
      			$(this).addClass('selected');
      		}
      	});

	} else {
	  var idVybranehoBloku = $(this).attr('href');
  	if (!idVybranehoBloku) {
      var idVybranehoBloku = "#blockSubcat01";
    }
	}
	$('ul.menuProductHorizont01 li a').each(function() {
		var href = $(this).attr('href');
		if (href == idVybranehoBloku) {
			$(this).addClass('selected');
		}
	});
	$('.blokSubCat').hide();
	$('div#'+idVybranehoBloku).show();
	$('div#cage'+idVybranehoBloku.replace("#","")).show();
  window.location.hash=idVybranehoBloku.replace("#","")+"AddressJS";
  return false;
}

function changeBlock() {   
  jQuery.each('ul.menuProductHorizont li a', function() {
		$('ul.menuProductHorizont li a').removeClass('selected');
  });
	$(this).addClass('selected');
	var idVybranehoBloku = $(this).attr('href').replace("#","");
	$('.blokSubCat').hide();
	$('div#'+idVybranehoBloku).show();
	$('div#cage'+idVybranehoBloku).show();
}
function changeBlock01() {   
  jQuery.each('ul.menuProductHorizont01 li a', function() {
		$('ul.menuProductHorizont01 li a').removeClass('selected');
  });
	$(this).addClass('selected');
	var idVybranehoBloku = $(this).attr('href').replace("#","");
  //$(this).addClass('selected');
  $('a.'+idVybranehoBloku).addClass('selected');
	$('.blokSubCat').hide();
	$('div#'+idVybranehoBloku).show();
	$('div#cage'+idVybranehoBloku).show();
  window.location.hash=idVybranehoBloku.replace("#","")+"AddressJS";
  return false;
}



function open3D() {
      window.open(''+$(this).attr('href'),'3D | Reebok', 'left=150,top=150,width=640,height=420,toolbar=0,resizable=1');
      return false;
}

function openDowload() {
      window.open(''+$(this).attr('href'),'Stažení souboru | Reebok', 'left=0,top=0,width=600,height=420,toolbar=1,resizable=1');
      return false;
}
function openNewPage() {
      window.open($(this).attr('href'));
      return false;
}

function overPromo() {
	$(this).children('div').children('h2').animate({
    bottom: '30px'
  }, 300, function() {
    // Animation complete.
  });
}

function outPromo() {
	$(this).children('div').children('h2').stop().animate({
    bottom: '10px'
  }, 200,  function() {
    // Animation complete.
  });
}
function showFacebook() {
	$('a.facebook').addClass('fbover');
	$('div.facebookApp').show();
}
function hideFacebook() {
	$('a.facebook').removeClass('fbover');
	$('div.facebookApp').hide();
}
function showSubmenuSelectKraj() {
	$('.selectMesto ul').hide();
	$(this).parent('div').children('ul').toggle();
}
function showSubmenuSelectMesto() {
	$('.selectKraj ul').hide();
	$(this).parent('div').children('ul').toggle();
}

// měření výšky
function winH() {
 if (window.innerHeight)
    /* NN4 a kompatibilní prohlížeče */
    return window.innerHeight;
 else if
 (document.documentElement &&
 document.documentElement.clientHeight)
    /* MSIE6 v std. reľimu - Opera a Mozilla
    jiľ uspěly s window.innerHeight */
    return document.documentElement.clientHeight;
 else if
 (document.body && document.body.clientHeight)
    /* starąí MSIE + MSIE6 v quirk režimu */
    return document.body.clientHeight;
 else
    return null;
}
