


function withdraw_kwg(amount) {
	var withdraw_amount = $("#kwave_amount").val();
	var user_balance = $("#kwg_balance").val();
	var minimum_withdraw = $("#minimum_withdraw").val();
	
	if(minimum_withdraw > withdraw_amount) {
		alert('Minimum Withdraw Amount is '+minimum_withdraw+'KWG.');
		return false;
	}
	if(withdraw_amount > user_balance) {
		alert('Not enough KWG Balance. Please check your KWG Balance.');
		return false;
	}
	if(confirm('Will you request withdraw KWG?')) {
		var post_data = { withdraw_amount: withdraw_amount };
		call_ajax_util_post('withdraw_kwg', post_data);
	} else {
		return false;
	}
}

function kwave_unfinished_tr(data) {
	alert('You have unfinished withdraw request. If the processing does not complete for more than 2 days, please contact the administrator.');
}
function kwave_login_error(data){
	alert('login error. Please login');
	location.href=admin_base;
}


// ajax util 호출
function call_ajax_util(function_name, parameter, confirm_message = ""){

				var call_url = admin_base+'ajax_call_util/'+function_name+'/'+parameter;
				
				if(confirm_message != "") {
					var confirm_result = confirm(confirm_message);	
					if(!confirm_result) { 
						return false; 
					} 
				}
 
				console.log(call_url);
				
				
				//show_progress();
				
				$.ajax({
				  url: call_url,
				  type: "POST",
				  dataType: "JSON",
				  beforeSend: function( xhr ) {
					xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
				  }
				})
				.done(function( data ) {
					console.log(data);
					
					//hide_progress();

					if(data) {

						if(data.result == "success"){
							if(data.message != "") {
								alert("Message : "+data.message);
							}
							if(data.refresh == '1') { location.reload(); }

							if(data.result_action != '') {
								eval(data.result_action);
							}
						} else {
							alert(data.message);
							console.log("Error Message : "+data.message);
						}
					
					} else {
						console.log("Error. No Data.");
					}

			  });
			  

}
// end


// ajax util Call
function call_ajax_util_no_profress(function_name, parameter, confirm_message = ""){

				var call_url = admin_base+'ajax_call_util/'+function_name+'/'+parameter;
				
				if(confirm_message != "") {
					var confirm_result = confirm(confirm_message);	
					if(!confirm_result) { 
						return false; 
					} 
				}
 
				console.log(call_url);
				
				
				
				$.ajax({
				  url: call_url,
				  type: "POST",
				  dataType: "JSON",
				  beforeSend: function( xhr ) {
					xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
				  }
				})
				.done(function( data ) {
					console.log(data);
					

					if(data) {

						if(data.result == "success"){
							if(data.message != "") {
								alert("Message : "+data.message);
							}
							if(data.refresh == '1') { location.reload(); }

							if(data.result_action != '') {
								eval(data.result_action);
							}
						} else {
							alert(data.message);
							console.log("Error Message : "+data.message);
							if(data.message == "sign in error") {
								ajax_call_result_go_to_login();
							}
						}
					
					} else {
						console.log("Error. No Data.");
					}

			  });
			  

}
// end


// ajax util Call
function call_ajax_util_post(function_name, post_data, confirm_message = ""){

				var call_url = admin_base+'ajax_call_util_post/'+function_name;
				
				if(confirm_message != "") {
					var confirm_result = confirm(confirm_message);	
					if(!confirm_result) { 
						return false; 
					} 
				}
 
				console.log(call_url);
				console.log(post_data);
				
				//show_progress();
				
				$.ajax({
				  url: call_url,
				  type: "POST",
                  data: post_data,
				  dataType: "JSON",
				  beforeSend: function( xhr ) {
					xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
				  }
				})
				.done(function( data ) {
					console.log(data);
					
					//hide_progress();

					if(data) {

						if(data.result == "success"){
							if(data.message != "") {
								alert("Message : "+data.message);
							}
							if(data.refresh == '1') { location.reload(); }

							if(data.result_action != '') {
								eval(data.result_action);
							}
						} else {
							alert(data.message);
							console.log("Error Message : "+data.message);
							if(data.message == "sign in error") {
								ajax_call_result_go_to_login();
							}
						}
					
					} else {
						console.log("Error. No Data.");
					}

			  });
			  

}
// end
// ajax util Call
function call_ajax_util_post_without_wait(function_name, post_data, confirm_message = ""){

				var call_url = admin_base+'ajax_call_util_post/'+function_name;
				
				if(confirm_message != "") {
					var confirm_result = confirm(confirm_message);	
					if(!confirm_result) { 
						return false; 
					} 
				}
 
				console.log(call_url);
				console.log(post_data);
				
			//	show_progress();
				
				$.ajax({
				  url: call_url,
				  type: "POST",
                  data: post_data,
				  dataType: "JSON",
				  beforeSend: function( xhr ) {
					xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
				  }
				})
				.done(function( data ) {
					console.log(data);
					
			//		hide_progress();

					if(data) {

						if(data.result == "success"){
							if(data.message != "") {
								alert("Message : "+data.message);
							}
							if(data.refresh == '1') { location.reload(); }

							if(data.result_action != '') {
								eval(data.result_action);
							}
						} else {
							alert(data.message);
							console.log("Error Message : "+data.message);
							if(data.message == "sign in error") {
								ajax_call_result_go_to_login();
							}
						}
					
					} else {
						console.log("Error. No Data.");
					}

			  });
			  

}


function isAddress(address) {
        return (/^(0x){1}[0-9a-fA-F]{40}$/i.test(address));
}
