$(document).ready(function(){

	$('ul.tabs').tabs('div.panes > div');
	$('#main-menu ul > li:last-child').css('background-image','none');
	$('#productParameters dt:first, #productParameters dd:first, #odporucame li:last, #kategorie-obchodu .Cat > li > a:last, #aktuality .articleSummary:last').css('border',0);
	
	$('#left ul.Cat li.selected > a').css('text-decoration','underline');
	$('.ShopProductParentCategories ul').prepend('<li><a href="/">Úvod</a>  &gt;&gt; </li>');

	$("#productparams table tr:nth-child(odd), table#order tr:nth-child(odd)").addClass('odd');
  	$("#productparams table tr:nth-child(even), table#order tr:nth-child(even)").addClass('even');
	$("table#order").before('<h2>Moje objednávky</h2>');
	
	$("#special_buttons .comparelink a").html("Pridať produkt do porovnania");
	$("#special_buttons .comparelink img").parent().html("Produkt je pridaný do porovnania");	
	$(".prorating .message").remove();
	
	$("#paymentsBox .payment:nth-child(odd)").addClass('odd');
  	$("#paymentsBox .payment:nth-child(even)").addClass('even');
	
	$(".WithBorder tr:nth-child(1)").addClass('header');
	
	if($('#right .SeenProducts').length){
		var seencontent = $('#right .SeenProducts').html();
		$('#right .SeenProducts').removeClass('SeenProducts').addClass('basic002 seenproductbox').html('<h2 class="title">Naposledy videné</h2><div class="content">'+seencontent+'</div>');
	}
	
	$('.totop').click(function() {
		 goToByScroll("top");
     	return false;
     });


	/*
	$(".ShopIcons button, .ProductButtons button").hover(
	  function () {
		$(this).parent().find('label').addClass('hover');
	  }, 
	  function () {
		$(this).parent().find('label').removeClass('hover');
	  }
	);
	*/
	/* funkcionalita popup menu v login-menu */
	objhide = objshow = objshowtimer = objhidetimer = null;

	$('#login-menu ul.logged > li').hover(function() {
		if (objhide) {
			if ($(this).attr('class') == objhide.attr('class')) {
				clearTimeout(objhidetimer);
			} else {
				checkHover();
			}
		}
		
		objshow = $(this);
		objshowtimer = setTimeout('delayedShow()', 200);
	}, function() {
		clearTimeout(objshowtimer);
		objhide = $(this);
		objhidetimer = setTimeout('checkHover()', 500);
	});
	/* /funkcionalita popup menu v head-menu */


	/* inline label pre query */
	
	input_query = $('#adresat');
	input_query.attr('value', input_query.attr('title')).bind('focus', function(){	
		if (input_query.attr('value') == input_query.attr('title')) {
			input_query.attr('value', '').removeClass('empty');
		}
	}).bind('blur', function(){
		if ((input_query.attr('value') == '') || (input_query.attr('value') == input_query.attr('title'))) {
			input_query.attr('value', input_query.attr('title')).addClass('empty');
		}
	});
	
	/* /inline label pre query */


	/* oprava png s alpha kanálom pre IE5.5 a IE6 */
	if ($.browser.msie && $.browser.version < 7) {
		$(this).find('*').each(function() {
			
			b = $(this).css('background-image');
			if (b.indexOf('.png') != -1) {
				var f = b.split('url("')[1].split('")')[0];
				$(this).css('background-image', 'none');
			}
	
			if ($(this).is('[src$=.png]')) {
				var f = $(this).attr('src');
				$(this).attr({
					src: '/Data/default/UserFiles/images/blank.gif',
					width: $(this).width(),
					height: $(this).height()
				});
			}
	
			if (f) $(this).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + f + "',sizingMethod='crop')";
		});
	}
	/* /oprava png s alpha kanálom pre IE5.5 a IE6 */		
	
	/*  new */
	if($('#main-cart .cena-s .kosik-obsah').text()!='0 ks za'){
		$("#box-left").html($("form.search").parent().html());
		$("#box-right").html($("#kosik").html());
		
		objSearchHtml = $(".top form.search").html();
		setMainBar();
		
		$(window).bind("scroll",function(){setMainBar()});
	}		
	
	$('#totop a').click(function(){
		$(document).scrollTo(0, 500);
		return false;
	});

	$(window).scroll(function () { 	
	 if($(window).scrollTop()!=0) $("#totop a").css("display", "block"); 	
	 else $("#totop a").css("display", "none");	
	});
	/*****************/
});




/* funkcie pre popup menu v head-menu */
function checkHover() {
	if (objhide) {
		objhide.find('ul').hide();
		objhide = null;
	}
}

function delayedShow() {
	if (objshow) {
		objshow.find('ul').show();	
	}
}
/* /funkcie pre popup menu v head-menu */

function goToByScroll(id){
	$('html,body').animate({scrollTop: $("#"+id).offset().top},1000);
}

function setMainBar(){

	var a=$(document).scrollTop();	
	if(a<210){
		$("#main-bar").slideUp().css({top:"5px"})
		$(".top form.search").html(objSearchHtml);
		$("#box-left form.search").find("#search_suggest").html('');
	}else{
		if($('body').width()>=1245){
			$("#main-bar").slideDown().css({top:"5px"})
			$(".top form.search").html('').find("#search_suggest").html('');
			document.getElementById("main-bar").style.position="fixed";
		}
	}	
}
