$(document).ready(function() {
	$("anketa > b:even").css('font-weight','normal');

    $('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		, slideExpr: 'div.x'
		, pause : 1
		, pager : "#nav"
		, before : function() {
            $('#popis').html(this.alt);
        }
	});
	$('#stop').click(function() {
		$('.slideshow').cycle('pause');
	});
	$('#play').click(function() {
		$('.slideshow').cycle('resume',true);
	});

	var $tabs = $('#tabs').tabs({
		collapsible: true,
		fx: { opacity: 'toggle'} ,
		speed: 'fast' ,
		cache: true
	});

	$('#1kc').click(function() {
		$tabs.tabs('select', 2);
		return false;
	});

	$('#1kc2').click(function() {
		$tabs.tabs('select', 2);
		return false;
	});


	$('#malo-kreditu').dialog({
		height: 170,
		width: 430,
		modal: true,
		show: 'scale',
		hide: 'scale',
		closeOnEscape: true,
		autoOpen: true,
		resizable: false,
		buttons: {
			'OK': function() {
				$tabs.tabs('select', 2);
				$(this).dialog('close');
				return false;
			}
		}
	});
	$('#skryj').delay(5000).hide('slow');

	$('#anonymni-platce').dialog({
		height: 192,
		width: 450,
		modal: true,
		show: 'scale',
		hide: 'scale',
		closeOnEscape: true,
		autoOpen: true,
		resizable: false,
		buttons: {
			'OK': function() {
				$(this).dialog('close');
			}
		}
	});

	$('.confirm').dialog({
		height: 160,
		width: 450,
		modal: true,
		show: 'scale',
		hide: 'scale',
		closeOnEscape: true,
		autoOpen: false,
		resizable: false,
		buttons: {
			'Cancel':function() {
				$(this).dialog('close');
			}
		}
	});
	
	$('#dobito').dialog({
		height: 135,
		width: 450,
		modal: true,
		show: 'scale',
		hide: 'scale',
		closeOnEscape: true,
		autoOpen: true,
		resizable: false,
		buttons: {
			'OK': function() {
				$(this).dialog('close');
			}
		}
	});


	$('#dialog').dialog({
		show: 'scale',
		hide: 'scale'
	});

	$('#chyba').dialog({
		show: 'scale',
		hide: 'scale',
		modal: true,
		closeOnEscape: true,
		autoOpen: true,
		resizable: false,
		width: 360,
		height: 150,
		buttons: {
			'OK': function() {
				$(this).dialog('close');
			}
		}
	});

	$('#podminky-iru').dialog({
		height: 315,
		width: 450,
		show: 'scale',
		hide: 'scale',
		modal: true,
		closeOnEscape: true,
		autoOpen: false,
		resizable: false,
		buttons: {
			'Souhlasím': function() {
				$('input[name=podminky]').attr('checked', true);
				$(this).dialog('close');
			},
			'Nesouhlasím': function() {
				$('input[name=podminky]').attr('checked', false);
				$(this).dialog('close');
			}
		}
	});

	$('#open-podminky').click(function() {
		$('#podminky-iru').dialog('open');
		return false;
	});

	$('#osobni-udaje').dialog({
		height: 315,
		width: 450,
		modal: true,
		show: 'scale',
		hide: 'scale',
		closeOnEscape: true,
		autoOpen: false,
		resizable: false,
		buttons: {
			'Souhlasím': function() {
				$('input[name=pravnik]').attr('checked', true);
				$(this).dialog('close');
			},
			'Nesouhlasím': function() {
				$('input[name=pravnik]').attr('checked', false);
				$(this).dialog('close');
			}
		}
	});


	$('#open-osobni-udaje').click(function() {
		$('#osobni-udaje').dialog('open');
		return false;
	});

	$("button, input:submit", "#registrace").button();
	
	
	$("#slider").slider({
		value:100,
		min: 50,
		max: 3000,
		step: 50,
		slide: function(event, ui) {
			$("#amount").val(ui.value);
		}
	});
	$("#amount").val($("#slider").slider("value"));
	

	$('form.ajax').submit(function() {
		var vysl = '#'+$(this).attr('vysledek');
		$(vysl).html('<img src="http://www.irucz.ru/css/iru-theme-12/images/ui-anim_basic_16x16.gif" border="0" alt="loading" title="Načítání"> Odesílá se');
		$.ajax({
			type: 'POST',
			url: 'http://www.irucz.ru/inc/process.php',
			data: $(this).serializeArray(),
			success: function(msg) {
				$(vysl).html(msg);
			}
		});
		return false;
	});


	
	
	$("a.ajax").click(function(){
		$('#result').html('<img src="http://www.irucz.ru/css/iru-theme-12/images/ui-anim_basic_16x16.gif" border="0" alt="loading" title="Načítání"> Odesílá se');
			$.ajax({ type: 'post', url: 'http://www.irucz.ru/inc/process.php', data: $(this).attr('ajax'), success: function(msg) {
	       		$('#result').html(msg);
	    	}});
	    return false;
	});
});