// JavaScript Document
function mbtel_chk(){
//	alert(this.value.length);
	if(event.keyCode == 0008){ //バックスペース判定	
		//alert('bs');
		switch(this.value.length){
			case 4:
				//this.value = this.value.substring(0,3);
				break;
			case 9:
				//this.value = this.value.substring(0,8);
				break;
		}
		return;
	}else{
		if(this.value.charAt((this.value.length)-1).match( /[0-9]/ )){
			//alert('1');
		}else{
			this.value = this.value.substring(0,(this.value.length)-1);
		}
		switch(this.value.length){
			case 1:
				if(this.value.charAt(0) != '0'){
					this.value = '';
				}
				break;
			case 2:
				if(this.value.charAt(1) != '9' && this.value.charAt(1) != '8' && this.value.charAt(1) != '7'){
					this.value = this.value.charAt(0);
				}
				break;
			case 3:
				if(this.value.charAt(2) != '0'){
					this.value = this.value.substring(0,2);
				}
				break;
			case 4:
				if(this.value.charAt(3) != '-'){
					this.value = this.value.substring(0,3) + '-' + this.value.charAt(3);
				}
				break;
			case 9:
				if(this.value.charAt(8) != '-'){
					this.value = this.value.substring(0,8) + '-' + this.value.charAt(8);
				}
				break;
		}
		if(this.value.length == 3 || this.value.length == 8){
			this.value = this.value + '-';
		}
	}
	if(!this.value.match( /[0-9]/ )){
		this.value = '';
	}
}

