$(document).ready(function() {
			$(document).pngFix();
			$("#login_link").click(function() {
				$("#login_window").dialog('open');
				return false;
			});
			
			$("#login_window").dialog({
					autoOpen: false,
					modal: true,
					draggable: false,
					width: 350
			});
			
			$('#faq').accordion({ autoHeight: false });
			
			$("#register_link").click(function() {
				$("#register_window").dialog('open');
				return false;
			});
			
			$("#register_window").dialog({
					autoOpen: false,
					modal: true,
					draggable: false,
					width: 350
			});

			$("#send_feedback").submit(function() {
				alert('Ваш запрос поставлен в очередь на отправку!');
				var str = '/sendEmail.php?message='+$("#message").val()+'&reply='+$("#reply").val();
				$.get(str, function(xml){
					alert(xml);
				});
				return false;
			});
			
			$("#forgotten").submit(function() {
				alert('Ваш запрос поставлен в очередь на отправку!');
				var str = '/forgotten.php?wmr='+$('#forgotten_wmr').val()+'&email='+$("#forgotten_email").val();
				$.get(str, function(xml){
					alert(xml);
				});
				return false;
			});
			
			$("#register_user").submit(function() {
				var str = '/register.php?understand='+$("#understand").attr('checked')+'&read='+$("#read").attr('checked')+'&register_email='+$("#register_email").val() + '&register_password='+$("#register_password").val() + '&register_password_confirm='+$("#register_password_confirm").val()+'&wmr='+$("#wmr").val();
				$.get(str, function(xml){
					if (xml == '1') {alert('Регистрация произведена успешно'); window.location = 'http://stat.zippro.ru/?action=login&first_time=1&login_email='+$("#register_email").val()+'&login_password='+$("#register_password").val();} else {alert(xml);}
				});
				return false;
			});
		
		
			$.featureList(
				$("#tabs li a"),
				$("#output li"), {
					start_item	:	0
				}
			);
});

function new_freecap()
{
	// loads new freeCap image
	if(document.getElementById)
	{
		// extract image name from image source (i.e. cut off ?randomness)
		thesrc = document.getElementById("freecap").src;
		thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
		// add ?(random) to prevent browser/isp caching
		document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
	} else {
		alert("Sorry, cannot autoreload freeCap image\nSubmit the form and a new freeCap will be loaded");
	}
}
