// JavaScript Document
var email_filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
function check(){
	if(array_type.length!=array_msg.length){
		alert('javascript error')
		return false
	}
	for(i=1;i<=array_field.length;i++){
		t_field=this_form+'.'+eval('array_field['+(i-1)+']')
		t_msg=eval('array_msg['+(i-1)+']')
		type=eval('array_type['+(i-1)+']')
		switch (type)
		{
		  case "text": 
		  	if(!check_text(t_field,i,t_msg))return false
			break;
		  case "email": 
		  	if(!check_email(t_field,i,t_msg))return false
			break;
		  case "selectbox": 
		  	if(!check_selectbox(t_field,i,t_msg))return false
			break;
		  case "radio":
		  	if(!check_radio(t_field,i,t_msg))return false
			break;
		  default: break;
		}
	}
}

function check_text(t_field,num,tmsg){
	t_value=eval(t_field+'.value')
	if(t_value==''){
		eval("alert('"+t_msg+"')")
		eval(t_field+'.focus()')
		return false
	}
	return true
}
function check_email(t_field,num,tmsg){
	t_value=eval(t_field+'.value')
	if(t_value==''){
		eval("alert('"+t_msg+"')")
		eval(t_field+'.focus()')
		return false
	}
	if(!email_filter.test(t_value)){
		eval("alert('Email address is incorrect.')")
		eval(t_field+'.focus()')
		return false
	}
	return true
}
function check_selectbox(t_field,num,tmsg){
	t_value=eval(t_field+'.value')
	if(t_value==''){
		eval("alert('"+t_msg+"')")
		eval(t_field+'.focus()')
		return false
	}
	return true
}
function check_radio(t_field,num,tmsg){
	var checked=false
	var radio_length=eval(t_field+'.length')
	for(var j=0;j<radio_length;j++){
		if(eval(t_field+'['+j+'].checked==true')){
			checked=true
			val=eval(t_field+'['+j+'].value')
		}
	}
	if(checked==false){
		eval("alert('"+t_msg+"')")
		eval(t_field+'[0].focus()')
		return false
	}
	return true
}