jQuery.fn.reset = function () {
  $(this).each (function() { this.reset(); });
}

function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
		obj.value=obj.value.substring(0,mlength)
}

$(document).ready(function(){
	
	/* Authorization */
	var options = { 
   		dataType:	'json',
   		success:    function(data) { 
   			if (data.result == 'error') {
   				$("#LoginMessage").text('Неверный логин или пароль.');
   			} else {
   				window.location.reload();
   			}
 			
   		} 
	};
	$('#LoginForm').ajaxForm(options);
	
	/* Authorization 2 */
	var options = { 
   		dataType:	'json',
   		success:    function(data) { 
   			if (data.result == 'error') {
   				//$("#LoginMessage").text('Неверный логин или пароль.');
   				alert('Неверный логин или пароль.');
   			} else {
   				window.location.reload();
   			}
 			
   		} 
	};
	$('#LoginBox form').ajaxForm(options);
	
	$("#LoginLink").click(function() {
		$("#Fader").show();
		$("#LoginPopup").show();
		return false;
	});
	
	$("#Fader, #LoginPopup #close").click(function() {
		$("#Fader").hide();
		$("#LoginPopup").hide();
		$("#LoginMessage").text('');
		$("#LoginForm").reset();
	});
	
	$('#LoginForm').submit(function() {
		$("#LoginMessage").text('');
		return true;
	});

	
});

//preload

if (document.images)
{
  pic1= new Image(); 
  pic1.src="/img/preload2.gif"; 
 
}