$(document).ready(function() {
	var ie6 = ($.browser.msie && $.browser.version.substr(0,1)<7);

$('a.help').click(function() {
	$("#form-container").ajaxSend(function(r, s) {
		$("#working").hide();
	});
});

$('a.help').each(function() {
	$(this).qtip( {
		 content: {
			// Set the text to an image HTML string with the correct src URL to the loading image you want to use
			text: '<img class="throbber" src="/assets/img/ajax-loader.gif" alt="čekejte, prosím..." />',
			url: $(this).attr('href'), // Use the rel attribute of each element for the url to load
			title: {
			   text: 'on-tisk nápověda', // Give the tooltip a title using each elements text
			   button: '<img width="20" height="11" class="description-close" alt="Zavřít" src="/assets/img/kalkulace-tisku-close.png">' // Show a close link in the title
			}
		 },
		 position: {
			corner: {
			   target: 'leftBottom', // Position the tooltip above the link
			   tooltip: 'topRight'
			},
			adjust: {
			   screen: true // Keep the tooltip on-screen at all times
			}
		 },
		 show: { 
			when: 'click', 
			solo: true // Only show one tooltip at a time
		 },
		 hide: 'unfocus',
		 style: {
			tip: true, // Apply a speech bubble tip to the tooltip at the designated tooltip corner
			border: {
			   width: 4,
			   radius: 3,
			   color: '#7D7D7D'
			},
			name: 'light', // Use the default light style
			width: 570 // Set the tooltip width
		 },
		 api : {
		  onShow : function() {if (ie6) $("input,select").css( { 'visibility' : 'hidden' });},
		  onHide : function() {if (ie6) $("input,select").css( { 'visibility' : 'visible' });}
		 }
	})
});


$(".toggler").click(function() {
	var myid = $(this).attr("id").substring(1);
	$('#m' + myid).toggle();
	$('#d' + myid).toggle();
});

$(".toggler-msg").click(function() {
	var myid = $(this).attr("id").substring(1);
	$('#m' + myid).toggle();
	$('#d' + myid).toggle();
	$.post("/zpravy/prectene", {
		messageid : myid
	});
});
	
// animace description
$("a[name='menu-kalkulace-tisku']").click(function() {
	$("#desc-digitisk").slideUp(400) + $("#desc-kalkulace").slideToggle(400);
});
$("a[name='menu-digitalni-tisk']").click(function() {
	$("#desc-kalkulace").slideUp(400) + $("#desc-digitisk").slideToggle(400);
}); 
$("img.description-close").click(function() {
	$("#desc-kalkulace").slideUp(400) + $("#desc-digitisk").slideUp(400) + $("#desc-archiv-poptavek").slideUp(400);;
});
$("a[name='menu-archiv-poptavek']").click(function() {
	$("#desc-archiv-poptavek").slideToggle(400);
	return false;
});
	
//LOGIN z horniho panelu
$('#login').click(function() { // kliknuti na prihlaseni
	$("#form-container").ajaxSend(function(r, s) {
		$("#working").hide();
	});
	var bheight = 240;
	$('#boxcontent').css('height', bheight + 'px');
	$('#boxcontent').load("/prihlaseni",
		{ pieces : $("#pieces").val() },
		function() {
			processlogin(true); // RELOAD
			$("#username").focus();
		}
	);
	//return false;
});

$('#people_rotator').cycle({
	fx: 'fade' ,
	speed:  4500,
	random : 1,
	delay: 2000,
	timeout: 4000
});

$('#sidebar_care').click(function(){
	location.href = 'kontakt';
});

});

