<!--
//Author Makoto
//Date 2004/09/31
//if the end of document.forms[j].elements[i].name is 'F', that is valid.
//
function chkData(){

	for(var j=0;j < document.forms.length; j++){

		with(document.forms[j]){

			for(var i=0; i < length; i++){

				if(elements[i].type=='password' || 
					elements[i].type=='checkbox' ||
					elements[i].type=='radio' ||
					elements[i].type=='text' || 
					elements[i].type=='textarea' || 
					(elements[i].type).toString().indexOf('select-',0) ==0){

					if(!chkString(elements[i]) || !chkInvalid(elements[i])){
						chkAttention(elements[i]);
						return false;
					}
				}
			}
		}
	}

	return true;
}

function chkString(a){
	var allowString = "\n\r abcdefghijklmnopqrstuvwxyz;:\\^()$%+{}[]?!~*&0123456789/,.@-_#!'\""
	var srcStr;

	for(var i=0; i<a.value.toString().length; i++){
		srcStr = a.value.toString().substring(i,i+1).toString().toLowerCase();

		if(allowString.indexOf(srcStr,0) < 0){

			alert(srcStr + ': this character is invalid.');

			return false;
		}
	}

	return true;
}

//a :document.forms[i].elements[i]
function chkInvalid(a){



//	if(a.name.toString().substr(a.name.length-1,1)!="F" && (Trim(a.value)).toString().replace(/[\n\r]/g,"")==""){
//	if(a.id.toString().substr(a.id.length-1,3)=="hoehoe" && (Trim(a.value)).toString().replace(/[\n\r]/g,"")==""){
	if(a.id.toString()=="hoehoe" && (Trim(a.value)).toString().replace(/[\n\r]/g,"")==""){

		a.value="This item is invalid!!!";
		alert('This item is invalid.');
		a.value="";
		return false;
	}

	return true;
}

//a :document.forms[i].elements[i]
function chkAttention(a){
	if(a.type=='text'){
		if(!a.disabled==true){
			a.focus();
		}
	}
	else if(a.type=='textarea'){
		a.focus();
	}
	else if((a.type).toString().indexOf('select-',0) == 0){

		a.focus();
	}
	else if(a.type=='radio'){
		//a.focus();
	}
	else if(a.type=='checkbox'){
		//a.focus();
	}

	return true;
}

//------------------------------------------------------------
//javascript by usa http://www.usagi-js.com/
//------------------------------------------------------------
function Trim(strTemp)
{
	var strRet, strFinal;
	strRet = LTrim(strTemp);
	strFinal = RTrim(strRet);

	return strFinal;
}
function RTrim(strTemp)
{
	var nLoop = 0;
	var strReturn = strTemp;
	while (nLoop < strTemp.length)
	{
		if (strReturn.substring(strReturn.length - 1, strReturn.length) == " ")
		{
			strReturn = strTemp.substring(0, strTemp.length - (nLoop + 1));
		}
		else
		{
			break;
		}
		nLoop++;
	}
	return strReturn;
}
function LTrim(strTemp)
{
	var nLoop = 0;
	var strReturn = strTemp;
	while (nLoop < strTemp.length)
	{
		if (strReturn.substring(0, 1) == " ")
		{
			strReturn = strTemp.substring(nLoop + 1, strTemp.length);
		}
		else
		{
			break;
		}
		nLoop++;
	}
	return strReturn;
}
//-->

