var xpos = 0;
var ypos = 0;

$().mousemove(function(e){
    xpos = e.pageX;
    ypos = e.pageY;
});

$(document).ready(
    function()
    {
        var loader = $('<div id="loader"><img src="images/loading.gif" alt="loading..." /></div>')
            .css({position: "absolute", top: "1em", left: "1em", zIndex: "100"})
            .hide()
            .appendTo("body");
        $().ajaxStart(function() {
            loader.show();
        }).ajaxStop(function() {
            loader.hide();
        });
		
		$.meta.setType("attr", "test");
		
		doLogon();
    }
);

function doPosition(idname) {
    wBody = $("#idBody").width();
    hBody = $("#idBody").height();
    w = $(idname).width();
    h = $(idname).height();
    xpos = (xpos+w > wBody) ? xpos-w : xpos;
    xpos = (xpos < 0) ? 0 : xpos;
    $("#"+idname).css({ top: ypos, left: xpos });
}


function doLogon() {
	$("#frmLogon").validate({
		showErrors: function(errors, validator) {
			var message = "";
			$.each(errors, function(i, n) {
				message += n + "\n";
			});
			if (message != "") alert(message);
		},
		submitHandler: function(form) {
			$(form).ajaxSubmit({
				beforeSend: function() {
					$("#loadingL").show();
					$("#contentL").hide();
				}, 
				success: function(responseText, statusText) {
					$("#contentL").html(responseText);
					$("#loadingL").hide();
					$("#contentL").show("fast");
					doLogon();
				}
			});
		}
	});
}
	

