function readURL(input) {
	if (input.files && input.files[0]) {
		var reader = new FileReader();
		reader.onload = function (e) {
		$('#blah').attr('src', e.target.result);
	}
	reader.readAsDataURL(input.files[0]);
	}
}

function checkNationalID(id){
	if(id.value.length != 13){ alert('ERROR: เลขบัตรประจำตัวประชาชนไม่ครบ 13 หลัก'); return false; }
	for(i=0, sum=0; i < 12; i++) sum += parseFloat(id.value.charAt(i))*(13-i);
	if((11-sum%11)%10!=parseFloat(id.value.charAt(12))){ alert('ERROR: เลขบัตรประจำตัวประชาชนไม่ถูกต้อง'); return false; }
		return true;
}

function uzXmlHttp(){
    var xmlhttp = false;
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(e){
            xmlhttp = false;
        }
    }
	 
    if(!xmlhttp && document.createElement){
        xmlhttp = new XMLHttpRequest();
    } 
    return xmlhttp;
}

function newCardMenber(val){
	var url = 'newcard_find_member.php';	
	var pmeter = 'FindWord='+val.value;
	xmlhttp = uzXmlHttp();
    xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    xmlhttp.send(pmeter);
	if(xmlhttp.readyState == 4){ 
		document.getElementById('ShowMember').innerHTML = xmlhttp.responseText; 
	}
}

function oldCardMenber(val){
	var url = 'replacecard_find_member.php';	
	var pmeter = 'FindWord='+val.value+'&FindOld=true';
	xmlhttp = uzXmlHttp();
    xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    xmlhttp.send(pmeter);
	//alert(xmlhttp.responseText);
	if(xmlhttp.readyState == 4){ 
		document.getElementById('ShowOldMember').innerHTML = xmlhttp.responseText; 
	}
}

function CancelCardMenber(val){
	var url = 'cancelcard_find_member.php';	
	var pmeter = 'FindWord='+val.value;
	xmlhttp = uzXmlHttp();
    xmlhttp.open("POST", url, false);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
    xmlhttp.send(pmeter);
	if(xmlhttp.readyState == 4){ 
		document.getElementById('ShowMember').innerHTML = xmlhttp.responseText; 
	}
}

function ValidateEmail(inputText){
	var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	if(inputText.value.match(mailformat)){
		return true;
	}else{
		return false;
	}
}

function NumberOnly(e){
	if(window.event){
		var Code=window.event.keyCode;		//For IE
	}else{
		var Code=e.which;								//For Firefox
	}	
	var CodeToString=String.fromCharCode(Code);
	var regExp=/[-+0-9.]/;
	var Result=regExp.test(CodeToString);	
	if(Result==false&&Code!=13&&Code!=8&&Code!=0){//13 Enter 8 Back spec						
		alert('ERROR: ต้องเป็นตัวเลขเท่านั้น');
		return false;
	}
}