﻿Type.registerNamespace('Linksoft');

Linksoft.Detail = {
	UpdateRating: function (articleId, rating, fromCat) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.UpdateRating, { articleId: articleId, rating: rating, fromCat: fromCat });
	},
	GuestRated: function (articleId, rating, fromCat) {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.GuestRated, { articleId: articleId, rating: rating, fromCat: fromCat }, Linksoft.Web.ShowModalDialog, null, [{ from: 'logintovote', to: '#modalDialog .popupInner:first'}]);
		return false;
	},
	WriteReview: function (articleId, fromCat) {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.WriteReview, { articleId: articleId, fromCat: fromCat }, Linksoft.Web.ShowModalDialog, null, [{ from: 'recenze-napsat', to: '#modalDialog .popupInner:first'}]);
		return false;
	},
	StoreReview: function (articleId, rating, title, text, nick, fromCat) {
		Linksoft.Web.HideModalDialog();
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.StoreReview, { articleId: articleId, rating: rating, title: title, text: text, nick: nick, fromCat: fromCat });
		return false;
	},
	UpdateReviewRating: function (rating) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.UpdateReviewRating, { rating: rating });
	},
	VoteForUserReview: function (articleId, userReviewId, withTitle) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.VoteForUserReview, { articleId: articleId, userReviewId: userReviewId, withTitle: withTitle });
	},
	SetWatchDog: function (articleId, fromCat) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.SetWatchDog, { articleId: articleId, fromCat: fromCat }, Linksoft.Web.ShowModalDialog, null, [{ from: 'watchdog', to: '#modalDialog .popupInner:first'}]); 
	},
	SaveWatchDog: function (articleId, email, fromCat) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.SaveWatchDog, { articleId: articleId, email: email, fromCat: fromCat }, Linksoft.Web.ShowModalDialog, null, [{ from: 'watchdog', to: '#modalDialog .popupInner:first'}]); 
	},
	ChangeEBookFormat: function (articleId, fromEBookFormatId, fromRecap) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeEBookFormat, { articleId: articleId, fromEBookFormatId: fromEBookFormatId, fromRecap: fromRecap }, Linksoft.Web.ShowModalDialog, null, [{ from: 'selectebookformat', to: '#modalDialog .popupInner:first'}]);
	}
}

Linksoft.MujKosmas = {
	DeactivateWatchDogDialog: function (articleId) {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.DeactivateWatchDogDialog, { articleId: articleId }, Linksoft.Web.ShowModalDialog, null, [{ from: 'watchdog', to: '#modalDialog .popupInner:first'}]);
		return false;
	},
	DeactivateWatchDog: function (articleId) {
		Linksoft.Web.HideModalDialog();
		Linksoft.Web.DoSimpleAjax(Linksoft.Web.ActionUrls.DeactivateWatchDog, { articleId: articleId });
		$('#watchdog' + articleId).css('display', 'none');
	},
	ComplaintCreate: function (orderId) {
		Linksoft.Web.DoAjax({ type: 'GET', url: Linksoft.Web.ActionUrls.ComplaintCreate, data: { orderId: orderId }, successHandler: Linksoft.Web.ShowModalDialog, renamings: [{ from: 'complaint', to: '#modalDialog .popupInner:first'}] });
	},
	GetComplaint: function (complaintId, updateGrid) {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.GetComplaint, { complaintId: complaintId, updateGrid: updateGrid });
	},
	AddComplaintStep: function (complaintId, newState, text, updateGrid) {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.AddComplaintStep, { complaintId: complaintId, newState: newState, text: text, updateGrid: updateGrid });
	},
	CreateVoucher: function () {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.CreateVoucher, {}, Linksoft.Web.ShowModalDialog, null, [{ from: 'createvoucher', to: '#modalDialog .popupInner:first'}]);
	},
	ShowLoyaltyProgramDetails: function () {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ShowLoyaltyProgramDetails, {}, Linksoft.Web.ShowModalDialog, null, [{ from: 'loyaltyprogramdetails', to: '#modalDialog .popupInner:first'}]);
	},
	DeleteStoredList: function (id) {
		Linksoft.Web.DoSimpleAjax(Linksoft.Web.ActionUrls.DeleteStoredList, { id: id },
			function () { Linksoft.Web.ShowModalDialog(); },
			null,
			"modalDialog .popupInner"
		);
	},
	DoDeleteStoredList: function (id) {
		Linksoft.Web.HideModalDialog();
		Linksoft.Web.DoSimpleAjax(Linksoft.Web.ActionUrls.DoDeleteStoredList, { id: id },
			function () { Linksoft.Grids.Refresh("SL"); Linksoft.Web.ShowTemporaryDialog("Seznam byl smazán"); },
			function () { Linksoft.Web.ShowTemporaryDialog("Seznam se nepodařilo smazat"); },
			"modalDialog .popupInner"
		);
	}
}

Linksoft.Cart = {
	AddArticle: function (articleId, eBookFormatId, isMoreFormats, showWindowId) { // eBookFormat -1=select  0=noebook >0=formatid
		if (!!Linksoft.DontAddArticleWithAjax) {
			return true;
		} else {
			if (eBookFormatId == -1) { // && isMoreFormats == 1
				return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.SelectEBookFormat, { articleId: articleId, showWindowId: showWindowId }, Linksoft.Web.ShowModalDialog, null, [{ from: 'selectebookformat', to: '#modalDialog .popupInner:first'}]);
			} else {
				return Linksoft.Web.DoAjax(
					Linksoft.Web.ActionUrls.AddArticle,
					($("#cart").length == 0 ? {
						articleId: articleId, quantity: 1, vyklad: showWindowId, eBookFormatId: ((eBookFormatId == -1) ? 0 : eBookFormatId)
					} : {
						articleId: articleId, quantity: 1, refreshCart: true, vyklad: showWindowId, eBookFormatId: ((eBookFormatId == -1) ? 0 : eBookFormatId)
					}),
					function (data) {
						if ($('#alsoSeen').html().indexOf('###hide###') < 0) {
							if (lteie8) $('#alsoSeen').center().fadeIn(300);
							else $('#alsoSeen').center().fadeIn(300); //centerFixed
						}
					}
				);
			}
		}
	},
	HideAlsooSeen: function () { $('#alsoSeen').fadeOut(300); return false; },
	AddArticleSerie: function (serieId) {
		return Linksoft.Web.DoAjax(
			Linksoft.Web.ActionUrls.AddArticleSerie,
			{ serieId: serieId },
			function (data) {
				if (lteie8) $('#alsoSeen').center().fadeIn(300);
				else $('#alsoSeen').center().fadeIn(300); //centerFixed
			});
	},
	RemoveArticle: function (articleId, eBookFormatId) {
		return (!!Linksoft.DontAddArticleWithAjax) || Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.RemoveArticle, { articleId: articleId, eBookFormatId: eBookFormatId });
	},
	ChangeQuantity: function (articleId, quantity, eBookFormatId) {
		return (!!Linksoft.DontAddArticleWithAjax) || Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeQuantity, { articleId: articleId, quantity: quantity, eBookFormatId: eBookFormatId });
	},
	ChangeEFormat: function (articleId, fromEBookFormatId, eBookFormatId, fromRecap) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeEFormat, { articleId: articleId, fromEBookFormatId: fromEBookFormatId, eBookFormatId: eBookFormatId, fromRecap: fromRecap });
	},
	StoredListToCart: function (id) {
		Linksoft.Web.DoAjax(
			Linksoft.Web.ActionUrls.StoredListToCart,
			{ id: id, refreshCart: ($("#cart").length == 0 ? 'false' : 'true') },
			function (data) {
				if (lteie8) $('#alsoSeen').center().fadeIn(300);
				else $('#alsoSeen').centerFixed().fadeIn(300);
			});
	},
	CreateStoredList: function (fromStatus) {
		Linksoft.Web.DoSimpleAjax(Linksoft.Web.ActionUrls.CreateStoredList, { FromStatus: fromStatus, renderGrid: (Linksoft.Grids.Data['SL'] ? 'false' : 'true') },
			function () { Linksoft.Web.ShowModalDialog(); },
			null,
			"modalDialog .popupInner"
		);
	},
	CreatedStoredList: function (ajaxStatus) {
		var response = ajaxStatus.get_response();
		var ctype = response.getResponseHeader('Content-type');
		if (ctype.match(/^application\/json/)) {
			Linksoft.Web.HandleReplacements({}, false)(jQuery.parseJSON(ajaxStatus.get_data()));
			Linksoft.Web.HideModalDialog();
		} else {
			$('#CreateStoredListForm').html(ajaxStatus.get_data());
		}
	},
	ClearForLater: function () {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ClearForLater, {});
	},
	ClearCart: function () {
		Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ClearCart, {});
	},
	ChangeCountry: function (countryId) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeCountry, { countryId: countryId });
	},
	ChangeGift: function (salutation, text, signature, wrappingPaperId, wrappingPaperOnlyAdd, addBillOfDelivery) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeGift, { salutation: salutation, text: text, signature: signature, wrappingPaperId: wrappingPaperId, wrappingPaperOnlyAdd: wrappingPaperOnlyAdd, addBillOfDelivery: addBillOfDelivery, fromCart: $("#cartRecapitulation").length == 0 });
	},
	UpdateGift: function (renamings, successHandler) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.UpdateGift, null, successHandler, null, renamings);
	},
	ClearMessageOnClient: function () {
		$("#messageSalutation").val('');
		$("#messageText").val('');
		$("#messageSignature").val('');
		return false;
	},
	ChangeDeliveryService: function (deliveryServiceId, deliveryPointId) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangeDeliveryService, { deliveryServiceId: deliveryServiceId, deliveryPointId: deliveryPointId });
	},
	ChangePayment: function (paymentId) {
		if (paymentId == null || paymentId == '') return;
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.ChangePayment, { paymentId: paymentId });
	},
	MoveBetweenCartAndForLater: function (articleId, moveToCart, eBookFormatId) {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.MoveBetweenCartAndForLater, { articleId: articleId, moveToCart: moveToCart, eBookFormatId: eBookFormatId });
	},
	AddVoucher: function (codeId) {
		var code = $("#" + codeId);
		var voucherCode = code.val();
		if (voucherCode == '') {
			code.removeClass("input-validation-error");
			return Linksoft.Cart.RemoveVoucher();
		}
		else {
			return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.AddVoucher, { voucherCode: voucherCode }, function (data) {
				if (!data.IsSuccess) {
					code.addClass("input-validation-error");
				}
			});
		}
	},
	RemoveVoucher: function () {
		return Linksoft.Web.DoAjax(Linksoft.Web.ActionUrls.RemoveVoucher);
	},
	PrepareHandlers2: function (o) {
		Linksoft.Cart.PrepareHandlers(o.get_updateTarget());
	},

	PrepareHandlers: function (context) {
		$('.knihobox:not(.navbottom) .fixBottomLink', context).each(function (index) {
			$(this).css('right', function (gwidth) {
				gwidth = gwidth == null ? $(this).parent().children('.gliderNav .squares').outerWidth() : gwidth;
				gwidth = gwidth + 18 + 56 + 20 + 20;
				return gwidth;
			});
		});

		$('#modalDialog', context).appendTo(document.body);
		$('.closePopup', context).click(function () {
			var parent = $(this).parent();
			parent.fadeOut(300);
			if (parent.attr('id') == "modalDialog") {
				$('#qtip-blanket').fadeOut(300);
				Linksoft.Web.CancelTemporaryDialogTimeout();
			}
			return false;
		});

		/*
		ADDED: 2011-16-16
		AUTHOR: Matous Havlena (matous@havlena.net)
		DESC: these 2 triggers hide dialogs when user click outside them
		*/
		$("#page").click(function () {
			if ($("#alsoSeen").is(":visible")) {
				$("#alsoSeen").fadeOut(300);
				if ($("#alsoSeen").attr('id') == "modalDialog") $('#qtip-blanket').fadeOut(300);
			}
		});

		$("#qtip-blanket").click(function () {
			if ($("#modalDialog").is(":visible")) {
				Linksoft.Web.HideModalDialog();
			}
		});


		$("#giftCloseButton", context).click(function () {
			Linksoft.Cart.ChangeGift($('#messageSalutation').val(), $('#messageText').val(), $('#messageSignature').val(), $('input[name=\'wrappingPaper\']:checked').val(), $('#wrappingPaperOnlyAdd').is(':checked'), $('input[name=\'billOfDelivery\']:checked').val() == '1');
			Linksoft.Web.HideModalDialog();
			return false;
		});

		$('.titul-showmore', context).click(function () {
			if ($(this).attr('href') == null) {
				var text = $(this).attr('content');
				$(this).parent().html(text);
			} else {
				Linksoft.Web.DoSimpleAjax({
					url: $(this).attr('href'),
					successHandler: function (a, b) {
						$('#modalDialog .popupInner:first').html(a);
						Linksoft.Web.ShowModalDialog();
					},
					dataType: 'html'
				});
			}
			return false;
		});

		$('#giftTarget', context).click(
		function () {
			Linksoft.Cart.UpdateGift([{ from: 'gift', to: '#modalDialog .popupInner:first'}], Linksoft.Web.ShowModalDialog);
			return false;
		});

		$(".imageToResize", context).click(
			function () {
				var item = $(this).next();
				item.animate({ width: "300px", height: "300px", left: "-110px", top: "-100px", opacity: 1 }, 300);
			});

		$(".imageFullSize", context).click(
			function () {
				var item = $(this);
				item.animate({ width: "0", height: "0", left: "40px", top: "40px", opacity: 0 }, 300);
			});

		$('#country', context).change(function () {
			var that = $(this);
			var countryId = that.val();
			var value = parseInt(this.value);
			Linksoft.Cart.ChangeCountry(value);
		});
		$('.accordion', context).click(function () { $(this).next().toggle(400); });

		$('.xqtip', context).qtip({
			content: {
				text: function () {
					return $(this).children('.qtip_content').html();
				}
			},
			position: {
				my: 'top right',  // Position my top left...
				at: 'top left', // at the bottom right of...
				adjust: { x: -5, y: 0 }
			},
			show: {
				event: 'click',
				effect: function (offset) {
					$(offset.elements.target).closest('li').addClass('hover');
					$(this).slideDown(400);
				}
			},
			hide: {
				fixed: true,
				event: 'click unfocus',
				target: $('.close'),
				effect: function (offset) {
					$(this).slideUp(400);
					$(offset.elements.target).closest('li').removeClass('hover');
				}
			},
			style: {
				classes: 'ui-tooltip-ship ui-tooltip-shadow',
				tip: {
					width: 10,
					height: 20,
					corner: 'right top',
					mimic: 'center'
				}
			},
			prerender: true
		});

		$("#voucherCode", context).watermark();
		$("#fulltext_query_input", context).watermark();
		$("#fulltext_query_input2", context).watermark();
		var inputs = $(":input.cart-input-count[articleid]", context);
		inputs.keypress(function (event) {
			if (event.which == '13') {
				event.preventDefault();
				this.blur();
			}
		});
		inputs.blur(function () {
			var that = $(this);
			var articleId = that.attr("articleid");
			var eformatid = that.attr("eformatid");
			var value = parseInt(this.value);
			if (isNaN(value)) {
				that.addClass("input-validation-error");
				that.focus();
			}
			else {
				that.removeClass("input-validation-error");
				Linksoft.Cart.ChangeQuantity(articleId, value, eformatid);
			}
		});
		inputs = $(":input.paymentOption-button", context);
		inputs.click(function () {
			Linksoft.Cart.ChangePayment($("input[name='paymentOption']:checked").val());
		});

		inputs = $(":input.deliveryService-button", context);
		inputs.click(function () {
			var value = $("input[name='deliveryService']:checked").val();
			var i = value.indexOf('-');
			var serviceId = value;
			var pointId = null;
			if (i != -1) {
				serviceId = value.substring(0, i);
				pointId = value.substring(i + 1);
			}
			Linksoft.Cart.ChangeDeliveryService(serviceId, pointId);
		});

	}
};

Linksoft.Web.OnAjaxPerItem( Linksoft.Cart.PrepareHandlers);


$(function () {
	Linksoft.Cart.PrepareHandlers();
	$('<div id="qtip-blanket">')
	  .css({
		  position: 'absolute',
		  top: $(document).scrollTop(),
		  left: 0,
		  height: $(document).height(),
		  width: '100%',
		  opacity: 0.7,
		  backgroundColor: 'black',
		  zIndex: 5000
	  })
	  .appendTo(document.body).hide();
		 $('<div id="jquery-blanket">')
	  .css({
		  position: 'absolute',
		  top: $(document).scrollTop(),
		  left: 0,
		  height: $(document).height(),
		  width: '100%',
		  opacity: 0.15,
		  backgroundColor: 'black',
		  zIndex: 5000
	  })
	  .appendTo(document.body).hide();
	  /*
		 $('<div id="jquery-blanket"><p><img src="/Content/Layout/indicator2.gif" /></p>')
	  .css({
	  	position: 'absolute',
	  	top: $(document).scrollTop(),
	  	left: 0,
	  	height: $(document).height(),
	  	width: '100%',
	  	opacity: 0.15,
	  	backgroundColor: 'black',
	  	zIndex: 5000
	  })
	  .appendTo(document.body).hide();*/
  });

function w(url, type) {
	var posWidth;
	var posHeight;
	switch (type) {
		case 1:
			posWidth = 1044;
			posHeight = 1044;
			wname = 'galerie-full';
			break
		case 2:
			posWidth = 900;
			posHeight = 640;
			wname = 'cizi-okno';
			break
		default:
			posWidth = 690;
			posHeight = 720;
			wname = 'galerie';
	}
	if (window.screen.availHeight < posHeight) { posHeight = window.screen.availHeight; }
	if (window.screen.availWidth < posWidth) { posWidth = window.screen.availWidth; }
	var posLeft = (window.screen.availWidth - posWidth) / 2;
	var posTop = (window.screen.availHeight - posHeight) / 2;
	var args = 'scrollbars=yes,location=no,resizable=yes,';
	args += 'width=' + posWidth + ',height=' + posHeight + ',left=' + posLeft + ',top=' + posTop;

	var win = window.open(url, wname, args);
	if (win) {
		win.focus;
		return false;
	} else return true;
}

function reply2(what, par) {
	if (!par) {
		par = 0;
	}
	document.addpost.parent.value = par
	var text_now = document.addpost.text.value; // ziskani soucasneho obsahu
	if (text_now == "") {
		document.addpost.text.value = what;
	} else {
		document.addpost.text.value + "\n\n" + what;
	}
}

function showCollapsible(this_item) {
	this_item.addClass('open');
	this_item.find('#menu li').removeClass('akt');
	this_item.parent('li').addClass('akt');
	this_item.parent('li').find('.submenu').stop(true, true).slideDown('fast');
}

function hideCollapsible(this_item) {
	this_item.removeClass('open');
	this_item.parent('li').removeClass('akt');
	this_item.parent('li').find('.submenu').stop(true, true).slideUp('fast');
}

var mouse_is_inside = false;
$(function () {

	$("body").mouseup(function () {
		if (!mouse_is_inside) {
			hideCollapsible($("#menu .rozbalovaci a"));
		}
	});

	// Rozbalovaci menu
	$('#menu .rozbalovaci a.all').click(function () {
		if ($(this).hasClass('open')) hideCollapsible($("#menu .rozbalovaci a"));
		else showCollapsible($(this));
		return false;
	});


	$('#menu .rozbalovaci .submenu, #menu .rozbalovaci a').hover(function () {
		mouse_is_inside = true;
	}, function () {
		mouse_is_inside = false;
	});





	// Checkboxy, dohodlo se ze nechame defaultni
	//$('input:checkbox').checkbox();


	// Inicializace zalozek
	$('.tabs').tabs();

	// Inicializace qtipu kosiku
	$('#basket').qtip({
		content: {
			text: function () {
				return $(this).children('.qtip_content').html();
			}
		},
		position: {
			my: 'top right',  // Position my top left...
			at: 'bottom right', // at the bottom right of...
			adjust: { x: 0, y: 5 }
		},
		show: {
			event: 'none',
			effect: function (offset, event) {
				$(this).slideDown(400);
			}
		},
		hide: {
			fixed: true,
			event: 'click unfocus',
			target: $('.close'),
			effect: function (offset) {
				$(this).slideUp(400);
			}
		},
		style: {
			classes: 'ui-tooltip-basket ui-tooltip-shadow',
			tip: {
				width: 20,
				height: 10,
				corner: 'top right',
				mimic: 'center'
			}
		},
		prerender: true
	});
	$('#basket').click(function () { location.href = "/kosik"; });


	// Inicializace qtipu napovedy ve formularich
	$('.tooltip_form').qtip({
		content: {
			text: function () {
				return $(this).next('.qtip_content').html();
			}
		},
		position: {
			my: 'left center',  // Position my top left...
			at: 'top right', // at the bottom right of...
			adjust: { x: 5, y: 14 }
		},
		show: {
			event: 'mouseenter'
		},
		hide: {
			fixed: true,
			event: 'mouseleave',
			delay: 200
		},
		style: {
			width: 100,
			classes: 'ui-tooltip-shadow ui-tooltip-form'
		},
		prerender: true
	});

	// Inicializace qtipu napovedy 
	$('.tooltip').qtip({
		content: {
			text: function () {
				return $(this).next('.qtip_content').html();
			}
		},
		position: {
			my: 'left center',  // Position my top left...
			at: 'top right', // at the bottom right of...
			adjust: { x: 10, y: 70 }
		},
		show: {
			event: 'mouseenter'
		},
		hide: {
			fixed: true,
			event: 'mouseleave',
			delay: 200
		},
		style: {
			classes: 'ui-tooltip-decription ui-tooltip-shadow',
			tip: {
				width: 10,
				height: 20
			}
		},
		prerender: true
	});


	// Inicializace qtipu vydani knihy 
	$('.tooltip-book').qtip({
		content: {
			text: function () {
				return $(this).find('.qtip_content').html();
			}
		},
		position: {
			my: 'right center',  // Position my top left...
			at: 'left top', // at the bottom right of...
			adjust: { x: -7, y: 70 }
		},
		show: {
			event: 'mouseenter'
		},
		hide: {
			event: 'mouseleave'
		},
		style: {
			classes: 'ui-tooltip-book ui-tooltip-shadow',
			tip: {
				width: 10,
				height: 20
			}
		},
		prerender: true
	});


	// Inicializace qtipu postovneho
	$('.tooltip-delivery').qtip({
		content: {
			text: function () {
				return $(this).children('.qtip_content').html();
			}
		},
		position: {
			my: 'left center',  // Position my top left...
			at: 'right center', // at the bottom right of...
			adjust: { x: -53, y: 64 }
		},
		show: {
			event: 'click'
		},
		hide: {
			fixed: true,
			event: 'click unfocus',
			target: $('.close')
		},
		style: {
			classes: 'ui-tooltip-delivery ui-tooltip-shadow',
			tip: {
				width: 10,
				height: 20
			}
		},
		prerender: true
	});


	// Inicializace qtipu dostupnosti
	$('.tooltip-availability').qtip({
		content: {
			text: function () {
				return $(this).children('.qtip_content').html();
			}
		},
		position: {
			my: 'right center',  // Position my top left...
			at: 'left center', // at the bottom right of...
			adjust: { x: -10, y: 0 }
		},
		show: {
			event: 'click'
		},
		hide: {
			fixed: true,
			event: 'click unfocus',
			target: $('.close')
		},
		style: {
			classes: 'ui-tooltip-availability ui-tooltip-shadow',
			tip: {
				width: 10,
				height: 20
			}
		},
		prerender: true
	});

	// Inicializace hodnoceni
	$("input.star").rating();

});

(function ($) {
	$.fn.center= function(){
		return this.each(function() {
			var $self = jQuery(this);
			var width = $self.width();
			var height = $self.height();
			var top = parseInt($(window).scrollTop());
			var halfWidth = - width / 2;
			var halfHeight = - height / 2;
			var cssProp = {position: 'absolute', width: width, left: '50%', marginLeft: halfWidth, marginTop: halfHeight+top-60, top: '50%'};
			$self.css(cssProp);
		});
	};
})(jQuery);

$(function () { $('#filtr-temata, #rating-info-top').localScroll(); });

var GliderData = new Array();
function ShowWindowGliderPageShowed(id, page) {
	var gliderdata = GliderData[id];
	if (gliderdata.seen.length > page && !gliderdata.seen[page]) {
		if (gliderdata.pages.length > page) {
			//window.alert(id + ':' + page);
			$.ajax({
				dataType: 'html',
				cache: false,
				data: { showWindowId: gliderdata.windowid, articleIds: gliderdata.pages[page] },
				type: 'POST',
				url: Linksoft.Web.ActionUrls.RegisterThumbnailView
			});
		}
		gliderdata.seen[page] = true;
	}
}

/*
ADDED: 2011-07-22
AUTHOR: Matous Havlena (matous@havlena.net)
DESC: Fixed centering which can be called by jquery fn this.centerFixed();
*/
jQuery.fn.centerFixed = function () {
	this.css("position", "fixed");
	this.css("left", "50%");
	this.css("top", "40%");
	this.css("margin-top", -(this.outerHeight() / 2) + "px");
	this.css("margin-left", -(this.outerWidth() / 2) + "px");
	return this;
}
