$(function(){
	$("body").ajaxStart(function(){
		$("body").append("<div id='TB_load'><img src='"+imgLoader.src+"' /></div>");
		$('#TB_load').show();//show loader
	});
	$("body").ajaxStop(function(){
		$("#TB_load").remove();
	});

});



function openwin(url){
	window.scrollTo(0,0);
	tb_show("",url+"?width=1000&height=650");
}



function openwin2(url){
	window.scrollTo(0,0);
	tb_show("",url+"?width=683&height=364");
}



function closewin(){
	tb_remove();
}

function content(url){
	$.get(url,function(data){
		$("#video-box3").html(data);
	});
}

function login_submit () {

	var username = $("#username").val();
	var password = $("#password").val();

	$.post("/forum/login", { username: username, password: password },
		function(data){
			if (data == "error") {
				$("#login_msg")
				.html("Helytelen felhasználónév vagy jelszó!")
				.fadeIn('slow');
			} else {
				$("#login_msg").html("Bejelentkezés sikeres!")
				.fadeIn('slow')
				.animate({opacity: 1.0}, 2000)
				.fadeOut('slow', function() {
					$(this).remove();
				});
				$("#login_form")
				.animate({opacity: 1.0}, 2000)
				.fadeOut('slow', function() {
					$(this).remove();
					closewin();
				});
				// itt kell nyitni az swf-et
				openwin('/forum/swf');
			}
		});

}



function login_submit_flash (username, password) {

	$.post("/forum/login", { username: username, password: password },
		function(data){
			console.log(data);
			if (data == "error") {
				openwin('/forum/swf_login');
			} else {
				// itt kell nyitni az swf-et
				openwin('/forum/swf');
			}
		});

}



function checkData (type, value) {

	if (value.length != 0) {
		$.post("/forum/checkData/", { type: type, data: value },
			function (data) {
				if (data == "user_error") {
					$("#message")
					.html("Helytelen felhasználónév!")
					.fadeIn('slow')
					.animate({opacity: 1.0}, 2000)
					.fadeOut('slow');
				}
				if (data == "email_error") {
					$("#message")
					.html("Helytelen e-mail cím!")
					.fadeIn('slow')
					.animate({opacity: 1.0}, 2000)
					.fadeOut('slow');
				}
			}
		)
	}

}