$(document).ready(function(){
	$(document).pngFix();
	$('#menu a')
		.css( {backgroundPosition: "-20px 35px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(-20px 94px)"}, {duration:500})
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(40px 35px)"}, {duration:200, complete:function(){
					$(this).css({backgroundPosition: "-20px 35px"})
				}})
		})
	
	$('#register').dialog({
		autoOpen: false,
		width: 400,
		buttons: {
			"Ok": function() { 
				$.post('/index.php', {action: 'register', email: $("#email").val(), pass: $("#pass").val(), confirm: $("#confirm").val(), wmr: $("#wmr").val()}, function(xml){ 
						if (xml == '1') {alert('Ваш аккаунт успешно создан!'); window.location='http://private-office.smszip.ru/index.php?action=login&login_email='+$("#email").val()+'&login_password='+$("#pass").val(); $("#email").val(''); $("#pass").val(''); $("#confirm").val(''); $("#wmr").val(''); $("#register").dialog("close"); return false; } else {alert(xml);}
						});
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
	
	$('#reminder').dialog({
		autoOpen: false,
		width: 400,
		buttons: {
			"Ok": function() { 
				alert('Запрос отправлен, пожалуйста, дождитесь ответа от сервера!');
				$.post('/index.php', {action: 'remind', email: $("#remind_email").val(), wmr: $("#remind_wmr").val()}, function(xml){ 
						alert(xml);
						});
				$(this).dialog("close"); 
			}, 
			"Cancel": function() { 
				$(this).dialog("close"); 
			} 
		}
	});
	
	// Dialog Link
	$('#register_link').click(function(){
		$('#register').dialog('open');
		return false;
	});
	
	$('#reminder_link').click(function(){
		$('#reminder').dialog('open');
		return false;
	});
});