function switch_menu() {

	if($('ul#acc').css('display') != 'none') 
	{
		$.cookie('selected_menu', '1'); 
		$('ul#acc').animate({opacity: 0}, 250, function () 
		{
			$(this).css('display', 'none');
			$('ul#acc2').css('display', 'block');
			$('ul#acc2').css('opacity', 0);
			$('ul#acc2').animate({opacity: 1}, 250); });
			
		$('#switch_menu').animate({opacity: 0}, 250, function () { $('#switch_menu span').html('<span class="menu_unactive">Panel Klienta</span>&nbsp;&nbsp;&nbsp; Menu główne'); $('#switch_menu').animate({opacity: 1}, 250); });
	}
	else 
	{
			$.cookie('selected_menu', '0');
			$('ul#acc2').animate({opacity: 0}, 250, function () { 
				$(this).css('display', 'none');
				$('ul#acc').css('display', 'block');
				$('ul#acc').css('opacity', 0);
				$('ul#acc').animate({opacity: 1}, 250); 
			});
			$('#switch_menu').animate({opacity: 0}, 250, function () { $('#switch_menu span').html('Panel Klienta&nbsp;&nbsp;&nbsp;<span class="menu_unactive"> Menu główne</span>'); $('#switch_menu').animate({opacity: 1}, 250); });
		}
}

$(document).ready(function() {
	//$("#tabs").tabs().show();
	
	//var ulid = $("#tabs > ul").attr('id');
	ulid = document.location.href;
	if(ulid){
		var activepage = 0;
		if (readCookie(ulid)) activepage = readCookie(ulid);
		$("#tabs").tabs({
			select: function(event,ui) {
				setCookie(ulid,ui.index,exp);
				$('.pole_message_err').hide();
				$('.pole_message').hide();

			},
			selected: activepage,
			fx: {
				opacity: "toggle",
				duration: "fast"
			}
		}).show();
	}

	$('#smsgroup').crossSlide({
			fade: 2,
			sleep: 2
		}, [
		{ src: 'img/smsgroup.jpg' },
		{ src: 'img/smsgroup2.jpg' },
		{ src: 'img/smsgroup3.jpg' }
		]);
	
	$('a').focus(function() {
		$(this).blur();
	});
	
	// button
	$('.buttons').addClass(
						'ui-state-default ' +
						'ui-corner-all ' +
						'mybutton'
					)
				.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
				.focus(function() {
						$(this).addClass('ui-state-focus');
				})
				.blur(function() {
						$(this).removeClass('ui-state-focus');
				});	
				
	$('.delete').addClass(
					'ui-state-default ' +
					'ui-corner-all ' +
					'mybutton'
				)
			.text('Usuń')
			.hover(
					function() {
						$(this).addClass('ui-state-hover');
					},
					function() {
						$(this).removeClass('ui-state-hover');
					}
				)
			.focus(function() {
					$(this).addClass('ui-state-focus');
			})
			.blur(function() {
					$(this).removeClass('ui-state-focus');
			});	
			
		// button koncowy
	$('.last').addClass(
						'ui-state-default ' +
						'ui-corner-all ' +
						'mybutton'
					)
				.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
				.focus(function() {
						$(this).addClass('ui-state-focus');
				})
				.blur(function() {
						$(this).removeClass('ui-state-focus');
				});		
	
	// button
	$('.bt_generate').addClass(
						'ui-state-default ' +
						'ui-corner-all ' +
						'mybutton'
					)
				.text('Generuj')
				.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
				.focus(function() {
						$(this).addClass('ui-state-focus');
				})
				.blur(function() {
						$(this).removeClass('ui-state-focus');
				});	
	
	
	$('#knowfrom_select').change( function() {
		//alert($('#knowfrom').val());
		if( $('#knowfrom_select').val() == 'inne' )
		{

			$('#knowfrom_text').css('display', 'block');
		}
		else $('#knowfrom_text').css('display', 'none');
	
	} );
	
	$('#form_register').submit( function() {
	//alert( $('#knowfrom_select').val() );
		if( $('#knowfrom_select').val() == 'inne' )
		{
			$('#knowfrom').val( $('#knowfrom_text').val() );
		}
		else $('#knowfrom').val( $('#knowfrom_select').val() );
	//	alert('a');
	//	alert( $('#knowfrom').val() );
	});
	
	
	$('#dialog').dialog({
		bgiframe: true,
		autoOpen: false,
		resizable: false,
		modal: true,
		height: 180, 
		buttons: {
			'Czekaj...': function() {}
		},
		close: function() { 
			$(this).dialog('option','buttons', {'Czekaj...': function() {} } );
		}
	});
	// button sendsms
	$('#sendsms_1,#sendsms_2,#sendsms_3').addClass(
						'ui-state-default ' +
						'ui-corner-all ' +
						'mybutton'
					)
				.text('Dalej')
				.click(function() {
					sendSMS($(this).attr('rel'));
				})
				.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
				.focus(function() {
						$(this).addClass('ui-state-focus');
				})
				.blur(function() {
						$(this).removeClass('ui-state-focus');
				});
	
	// button sendsms0
	$('#sendsms_0').addClass(
						'ui-state-default ' +
						'ui-corner-all ' +
						'mybutton'
					)
				.text('Wyślij')
				.click(function() {
					sendSMS($(this).attr('rel'));
				})
				.hover(
						function() {
							$(this).addClass('ui-state-hover');
						},
						function() {
							$(this).removeClass('ui-state-hover');
						}
					)
				.focus(function() {
						$(this).addClass('ui-state-focus');
				})
				.blur(function() {
						$(this).removeClass('ui-state-focus');
				});
				

				
	// date picker
	$('#data_od,#data_do').datepicker({
			showOn: 'button',
			buttonImage: 'img/cal.gif',
			buttonImageOnly: true,
			dateFormat: 'yy/mm/dd'
		});
	$('#time_0,#time_1,#time_2,#time_3').datepicker({
			showOn: 'button',
			buttonImage: 'img/cal.gif',
			buttonImageOnly: true,
			dateFormat: 'yy/mm/dd'
		});
	$('.send_change_cal').click(
		function () {
			rel = $(this).attr('rel');
			$('#send_now_'+rel).hide('fast');
			$('#send_calendar_'+rel).show('fast');
			$('#sms_schedule_'+rel).val(1);
		}
	);
	$('.send_change_now').click(
		function () {
			rel = $(this).attr('rel');
			$('#send_calendar_'+rel).hide('fast');
			$('#send_now_'+rel).show('fast');
			$('#sms_schedule_'+rel).val(0);
		}
	);
	$('#send_calendar_0,#send_calendar_1,#send_calendar_2,#send_calendar_3').hide();
			
// platnosci online
	$('#pay_online_amount_net').keyup(function() {
		var brutto = $(this).val();
		brutto = brutto.replace(',','.');
		brutto *= 1.22;
		brutto = Math.round(brutto*Math.pow(10,2))/Math.pow(10,2);
		$('#pay_online_amount_brut').val(brutto);
	});

	$('#pay_online_amount_net').change(function() {
		if ( (($(this).attr('name')) == 'amount2') && (($(this).val()) >= 2000) ) {
			$('#pay_online_amount_net').val('1999,99');
			$('#pay_online_amount_brut').val('2439,99');
			alert('Maksymalna płatność on-line wynosi 1999,99zł netto.\nAby zapłacić więcej skorzystaj z opcji \'Zapłać przelewem\'!');
		}
	});
// ---
	
});