function checkifValid(id, type, idResult){
	var pathScript = "ajaxCallers/ajaxValidator.php";
	var emailregex = "^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+[\.]{1}[a-zA-Z]{1,5}$";
	if (type=="username"){
		if ($("#" + id).val().length >= 6){
			//$.post("ajax_callers/ajaxValidator.php",{type:type,value:$("#" + id).val()},function(res){$("#" + idResult).html(res);});
			$.ajax({
				url:  pathScript,
				type: "POST",
				data: "type=" + type + "&value=" + $("#" + id).val(),
				beforeSend: function(res){$("#" + idResult).html('<img src="ajaxCallers/ajax-loader.gif" style="padding-left:2px;" />');},
				//error: function(){alert("Request data failed, Please refresh and try again.");},
				success: function(res){
					if (res=="valid"){
						$("#" + idResult).html('<img src="ajaxCallers/check_ico.gif" style="padding-left:2px;" />');
					}else if (res=="not_valid"){
						$("#" + idResult).html('<img src="ajaxCallers/x_ico.gif" style="padding-left:2px;" />');
					}
					$("#" + id + "Hide").attr({value: res});
				}
			});
		}else{
			$("#" + idResult).html("");
		}
	}else if (type=="email"){
		if ($("#" + id).val().match(emailregex)){
			$.ajax({
				url:  pathScript,
				type: "POST",
				data: "type=" + type + "&value=" + $("#" + id).val(),
				beforeSend: function(res){$("#" + idResult).html('<img src="ajaxCallers/ajax-loader.gif" style="padding-left:2px;" />');},
				//error: function(){alert("Request data failed, Please refresh and try again.");},
				success: function(res){
					if (res=="valid"){
						$("#" + idResult).html('<img src="ajaxCallers/check_ico.gif" style="padding-left:2px;" />');
					}else if (res=="not_valid"){
						$("#" + idResult).html('<img src="ajaxCallers/x_ico.gif" style="padding-left:2px;" />');
					}
					$("#" + id + "Hide").attr({value: res});
				}
			});
		}else{
			$("#" + idResult).html("");
		}
	}
}