<!--

function login()
{
    var username=jQuery.trim($("#username").val());
    var userpwd=jQuery.trim($("#userpwd").val());
    if (username=='')
    {
	alert(gettext('JS_login_missing_azonosito'));
	$("#username").focus();
	return false;
    }
    if (userpwd=='')
    {
	alert(gettext('JS_login_missing_jelszo'));
	$("#userpwd").focus();
	return false;
    }
    
    $.post("modulok/User/includes/login.php",
	{
	    "username": encodeURIComponent(username),
	    "userpwd": encodeURIComponent(userpwd)
	},
	function(data,textStatus){
//	window.alert(data);
	    if (textStatus=='success')
	    {
		adatok=data.split('#');
		if (adatok[0]=='OK')
		{
		    document.location.href='index.php';
		}
		else
		if (adatok[0]=='SESSION_ERROR')
		{
		    window.alert(adatok[1]);
		    document.location.href='index.php';
		}
		else
		if (adatok[0]=='NEMOK')
		{
		    window.alert(adatok[1]);
		}
		else
		{
		    window.alert(adatok[1]);
		}
	    }
	    else
	    {
		window.alert('error');
	    }
	}
    );
    
    
}


function logout()
{
    $.post("modulok/User/includes/logout.php",
	{
	    "logout": 1
	},
	function(data,textStatus){
	    if (textStatus=='success')
	    {
		adatok=data.split('#');
		if (adatok[0]=='OK')
		{
		    document.location.href='index.php';
		}
		else
		if (adatok[0]=='SESSION_ERROR')
		{
		    window.alert(adatok[1]);
		    document.location.href='index.php';
		}
		else
		if (adatok[0]=='NEMOK')
		{
		    window.alert(adatok[1]);
		}
		else
		{
		    window.alert(adatok[1]);
		}
	    }
	    else
	    {
		window.alert('error');
	    }
	}
    );
    
}


function setHatter(szin)
{
    var newTheme;
    
    if (szin=="vilagos")
    {
	newTheme="White";
    }
    else
    {
	newTheme="Black";
    }

    $.post("modulok/Main/includes/setTheme.php",
	{
	    "theme": newTheme
	},
	function(data,textStatus){
	    if (textStatus=='success')
	    {
		adatok=data.split('#');
		if (adatok[0]=='OK')
		{
		    if (szin=="vilagos")
		    {
			$("body").css("background-color","#FFFFFF");
			$("#OLA_img_bw").attr("src","images/sotet.png");
			$("#OLA_img_logo").attr("src","images/ola_logo_ok_White.png");
			$("#main").css("color","#777777");
			$("#footer").css("color","#777777");
		    }
		    else
		    if (szin=="sotet")
		    {
			$("body").css("background-color","#000000");
			$("#OLA_img_bw").attr("src","images/vilagos.png");
			$("#OLA_img_logo").attr("src","images/ola_logo_ok_Black.png");
		    	$("#main").css("color","#33CBCC");
/*		    	$("#footer").css("color","#FF3901");*/
		    	$("#footer").css("color","#33CBCC");
		    }


		    //document.location.href='index.php';
		}
		else
		if (adatok[0]=='SESSION_ERROR')
		{
		    window.alert(adatok[1]);
		    document.location.href='index.php';
		}
		else
		if (adatok[0]=='NEMOK')
		{
		    window.alert(adatok[1]);
		}
		else
		{
		    window.alert(adatok[1]);
		}
	    }
	    else
	    {
		window.alert('error');
	    }
	}
    );


}

function reg()
{
    document.location.href='index.php?modul=Reg';
}

function changeHatter()
{
/*
	if ($("#color").val()=='#FFFFFF') $("#color").val('#000000');
	else $("#color").val('#FFFFFF');
	$("body").css("background-color",$("#color").val());
	$("#OLA_img_bw").attr("src","images/sotet.png");
*/

	if ($("#OLA_img_bw").attr("src")==="images/White.png")
	{
	    setHatter("vilagos");
	}
	else
	{
	    setHatter("sotet");
	}

	return false;
}

function setLocale(lang)
{
    document.location.href='index.php?setLocale='+lang;
}

function gettext(s)
{
    return js_array_gettext[s];
}

function waitingDialog(waiting) 
{ 
    // I choose to allow my loading screen dialog to be customizable, you don't have to 
    $("#loadingScreen").html(waiting.message && '' != waiting.message ? waiting.message : 'Please wait...'); 
    $("#loadingScreen").dialog('option', 'title', waiting.title && '' != waiting.title ? waiting.title : 'Loading'); 
    $("#loadingScreen").dialog('open'); 
} 

function closeWaitingDialog() 
{ 
    $("#loadingScreen").dialog('close'); 
}

$(document).ready(function() {

     $("#loadingScreen").dialog({
    	    autoOpen: false,
    	    // set this to false so we can manually open it 
    	    dialogClass: "loadingScreenWindow",
    	    closeOnEscape: false,
    	    draggable: false,
    	    width: 460,
    	    minHeight: 50,
    	    modal: true,
    	    buttons: {},
    	    resizable: false,
    	    open: function() {
    		// scrollbar fix for IE
    		$('body').css('overflow','hidden');
    	    },
    	    close: function() {
    		// reset overflow
    		$('body').css('overflow','auto');
    	    }
    }); // end of dialog 

    if ($("#OLA_calculator")!=null)
    {
	$("#OLA_calculator").sidebar({
	    position: "right",
	    width: 300,
	    height: 200
	});
    }

//    $("#button_reg").dblclick(function() {
//	window.alert("Dupla kattintás");
//    });


});

//-->

