

function checklogin(e, field)
{

	if(!e) e = window.event;

	if (e.type=="keyup" || e.type=="blur")
	{
		$("#login_error").removeClass('ok');
		
		if(field.value.match(/[^a-z0-9\-]+/i))
		{
			
			$("#login_error").html(errorstr[0]);

		} else if (field.value.length < 3) {
			
			$("#login_error").html(errorstr[1]);
			
		} else if (field.value.length > 25) {
			
			$("#login_error").html(errorstr[2]);

		} else {
			$("#login_error").html('');
			
			clearTimeout(logintimer);
			logintimer = setTimeout(function() {
				checkpost("login", field.value);
			}, 500);
		}
	
//		if (e.type=="blur")
//			alert(e.type);
		
	} else if (e.type=="keydown") {
		
		clearTimeout(logintimer);
		
	}
	
	return ;
	
}


function checkemail(e, field)
{

	if(!e) e = window.event;
	
	if (e.type=="keyup" || e.type=="blur")
	{
		
		$("#email_error").removeClass('ok');
		
		if(field.value.match(/[^a-z0-9\_\.\-\@]+/i))
		{
			
			$("#email_error").html(errorstr[0]);

		} else if (!field.value.match(/^[a-z0-9][a-z0-9_.-]*@[a-z0-9_.-]+\.[a-z]{2,7}$/i)) {
			
			$("#email_error").html(errorstr[3]);

		} else {
			$("#email_error").html('');
			
			clearTimeout(emailtimer);
			emailtimer = setTimeout(function(){
				checkpost("email", field.value);
			}, 500);
		}
		
//		alert(e.type);
		
	} else if (e.type=="keydown") {
		
		clearTimeout(emailtimer);
		
	}
	
	return ;
	
}






function checkl(field)
{
	
		$("#login_error").removeClass('ok');
		
		if(field.match(/[^a-z0-9\-]+/i))
		{
			if (!loginfocus)
				$("#login_error").html(errorstr[0]);

		} else if (field.length < 3) {
			
			if (!loginfocus)
				$("#login_error").html(errorstr[1]);
			
		} else if (field.length > 25) {
			
			$("#login_error").html(errorstr[2]);

		} else {
			$("#login_error").html('');
			
			clearTimeout(logintimer);
			logintimer = setTimeout(function() {
				checkpost("login", field);
			}, 500);
		}
	
	return ;
	
}

$(document).bind("ready", function() {
	
	
	$("input[name='name']").bind("change keyup", function(){
		checkl($("input[name='name']").attr("value"));
	});
	
	$("input[name='name']").bind("keydown", function(){
		clearTimeout(logintimer);
	});
	
	

	
	$("input[name='email']").bind("change keyup", function(){
		checke($("input[name='email']").attr("value"));		
	});
	$("input[name='email']").bind("keydown", function(){
		clearTimeout(emailtimer);	
	});
	
	
	
	$("input[name='password1']").bind("change keyup", function(){
		field=$("input[name='password1']").attr("value");
		
		if (field.length < 6) {
			
			$("#password1_error").removeClass('ok');
			$("#password1_error").html(errorstr[4]);
			
		} else {
			
			$("#password1_error").addClass('ok');
			$("#password1_error").html('V');
	
		}
	});	
	
	
	$("input[name='password2']").bind("change keyup", function(){
		field=$("input[name='password2']").attr("value");
		
		if (field.length < 6 || field!=$("input[name='password1']").attr("value")) {
			
			$("#password2_error").removeClass('ok');
			$("#password2_error").html(errorstr[5]);
			
		} else {
			
			$("#password2_error").addClass('ok');
			$("#password2_error").html('V');
	
		}
	});	
	
	
	$("#glasss input[name='sec_code']").bind("change keyup", function(){
		
		field=$("#glasss input[name='sec_code']").attr("value");
		
		glasss="#glasss #sec_code_error, #glasss #sec_code_error2, #glasss #sec_code_error3";
		
		if (field.length != 6) {
			
			$(glasss).removeClass('ok');
			$(glasss).html(errorstr[6]);
			
		} else {
			
			$(glasss).addClass('ok');
			$(glasss).html('V');
	
		}
	});	
	
	$("#reminding-pop-up input[name='sec_code']").bind("change keyup", function(){
		
		field=$("#reminding-pop-up input[name='sec_code']").attr("value");
		
		if (field.length != 6) {
			
			$("#sec_code_error3").removeClass('ok');
			$("#sec_code_error3").html(errorstr[6]);
			
		} else {
			
			$("#sec_code_error3").addClass('ok');
			$("#sec_code_error3").html('V');
	
		}
	});	

	$("#registration-pop-up input[name='sec_code']").bind("change keyup", function(){
		
		field=$("#registration-pop-up input[name='sec_code']").attr("value");
		
		if (field.length != 6) {
			
			$("#sec_code_error2").removeClass('ok');
			$("#sec_code_error2").html(errorstr[6]);
			
		} else {
			
			$("#sec_code_error2").addClass('ok');
			$("#sec_code_error2").html('V');
	
		}
	});	
	
	$('.b-silver-button-registration, .b-sub-monitor a strong').bind('click', function () {
		showregistrationform();
		return false;
	});
	

});



var reg_h_s_timer = null;

function showregistrationform()
{
	$('.b-monitor-embed').css({'display': 'none'});
	
	$('#registration-pop-up').css({display : 'block'});
	$('#registration-pop-up').css({'top' : (document.body.scrollTop+20) + 'px'});
	$('#screen2').css({display : 'block', height : getyScroll() + 'px'});

	clearTimeout(reg_h_s_timer);
	
	reg_h_s_timer = setInterval(reg_h_s, 500);
	
}

function hideregistrationform()
{
	
	clearTimeout(reg_h_s_timer);
	
	$('#registration-pop-up').css({display : 'none'});
	$('#screen2').css({display : 'none'});
	$('.b-monitor-embed').css({'display': 'block'});
}


function reg_h_s()
{
	var reg_i = 0;
	
	$('#registration-pop-up ins').each( function () {
		if ($(this).text() == 'V')
		{
			reg_i++;
		} else {
			reg_i--;
		}
	});
	
	if (reg_i == 4 && $('#registration-pop-up input:checkbox').attr('checked'))
	{
		$('#registration-pop-up input:submit').removeAttr('disabled');
	} else {
		$('#registration-pop-up input:submit').attr('disabled','true');
	}	
	
//	alert(reg_i);
}


function showlostpasswordform()
{
	$('#reminding-pop-up').css({display : 'block'});
	$('#screen3').css({display : 'block', height : getyScroll() + 'px'});
}

function hidelostpasswordform()
{
	$('#reminding-pop-up').css({display : 'none'});
	$('#screen3').css({display : 'none'});
//	$('#dle-captcha')
}