function checkemail(){
    if($('#email').val().length > 6){
$.ajax({
    url: '/modules/register/reg.php?do=email&email='+$('#email').val(),
    type: 'GET',
    dataType: 'html',
    timeout: 1000,
    error: function(){
		$('#email_msg').hide();
    },
    success: function(html){
$('#email_msg').show().removeClass('ER_01 ER_02');
if(html=="&#10003;"){
      $('#email_msg').html(html).addClass("ER_02");
}else{
      $('#email_msg').html(html).addClass("ER_01");
}
    }
}); 
}
}

function checkemail2(){
    if($('#confirmemail').val().length > 6){
$.ajax({
    url: '/modules/register/reg.php?do=email2&email='+$('#email').val()+'&confirmemail='+$('#confirmemail').val(),
    type: 'GET',
    dataType: 'html',
    timeout: 1000,
    error: function(){
		$('#confirmemail_msg').hide();
    },
    success: function(html){
$('#confirmemail_msg').show().removeClass('ER_01 ER_02');
if(html=="&#10003;"){
      $('#confirmemail_msg').html(html).addClass("ER_02");
}else{
      $('#confirmemail_msg').html(html).addClass("ER_01");
}
    }
}); 
}
}

function checkmobile(){

$('#mobile').val($('#mobile').val().replace(/ /g, ""));
    if($('#mobile').val().length > 10){
$.ajax({
    url: '/modules/register/reg.php?do=mobile&mobile='+$('#mobile').val(),
    type: 'GET',
    dataType: 'html',
    timeout: 1000,
    error: function(){
		$('#mobile_msg').hide();
    },
    success: function(html){
$('#mobile_msg').show().removeClass('ER_01 ER_02');
if(html=="&#10003;"){
      $('#mobile_msg').html(html).addClass("ER_02");
}else{
      $('#mobile_msg').html(html).addClass("ER_01");
}
    }
}); 
}
}

function checkmobile2(){

$('#confirmmobile').val($('#confirmmobile').val().replace(/ /g, ""));
    if($('#confirmmobile').val().length > 10){
$.ajax({
    url: '/modules/register/reg.php?do=mobile2&mobile='+$('#mobile').val()+'&confirmmobile='+$('#confirmmobile').val(),
    type: 'GET',
    dataType: 'html',
    timeout: 1000,
    error: function(){
		$('#confirmmobile_msg').hide();
    },
    success: function(html){
$('#confirmmobile_msg').show().removeClass('ER_01 ER_02');
if(html=="&#10003;"){
      $('#confirmmobile_msg').html(html).addClass("ER_02");
}else{
      $('#confirmmobile_msg').html(html).addClass("ER_01");
}
    }
}); 
}
}

function usercheck(){

$('#username').val($('#username').val().replace(/ /g, ""));
$('#username').val($('#username').val().replace(/[^0-9A-Za-z_.]/g, ""));
    if($('#username').val().length >= 5 ){
$.ajax({
    url: '/modules/register/reg.php?do=user&user='+unescape($('#username').val()),
    type: 'GET',
    dataType: 'html',
    timeout: 1000,
    error: function(){
		$('#username_msg').hide();
    },
    success: function(html){
$('#username_msg').show().removeClass('ER_01 ER_02');
if(html=="OK"){
      $('#username_msg').html('Username Available').addClass("ER_02");
}else{
      $('#username_msg').html('Username Taken').addClass("ER_01");
}
    }
}); 
}else{
$('#username_msg').show().removeClass('ER_01 ER_02');
$('#username_msg').html('Must be longer than 5 chars').addClass("ER_01");
}
}



$(document).ready(function(){
$('#email').keyup(function(event){ checkemail();});
$('#email').blur(function(event){ checkemail();});
$('#confirmemail').keyup(function(event){ checkemail2();});
$('#confirmemail').blur(function(event){ checkemail2();});
$('#mobile').keyup(function(event){ checkmobile();});
$('#mobile').blur(function(event){ checkmobile();});
$('#confirmmobile').keyup(function(event){ checkmobile2();});
$('#confirmmobile').blur(function(event){ checkmobile2();});
$('#username').keyup(function(event){ usercheck();});
$('#username').blur(function(event){ usercheck();});
$('#username').focus(function(event){ usercheck();});
});