// JavaScript Document


//swfファイルを書き出す
function flash_write(name,width,height)
{
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+width+"' height='"+height+"'>");
	document.write("<param name='movie' value='../js_common/"+name+"'>");
	document.write("<param name='quality' value='high'>");
	document.write("<embed src='../js_common/"+name+"' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+width+"' height='"+height+"'></embed>");
	document.write("</object>");
}

//子ウィンドを開く
function smallwinopen(url,windowname,height,width,scrallbars)
{
	window.open(url,''+windowname+'','width='+width+',height='+height+',status=no,scrollbars='+scrallbars+',directories=no,menubar=no,resizable=yes,toolbar=no');
}

//フォーカスをあてる
function touckFoucs(windowname)
{
	window.focus();
}


//フォームチェック
function mai_valueCheck()
{
	//空白チェック
	this.checkNull = function (inputString)
	{
		if(inputString == "")
		{
			return false;
		}
		return true;
	}
	//文字列の長さチェック
	this.checkLengthMatch = function (inputString,lengthString)
	{
		if(inputString.length != lengthString)
		{
			return false;
		}
		return true;
	}
	//数字列チェック
	this.checkNumber = function (inputString)
	{
		if (isNaN(inputString))
		{
			return false;
		}
		return true;
	}
	//電話番号チェック
	this.checkTel = function (inputValue)
	{
		var numValue = inputValue.replace("-","");
		numValue = numValue.replace("-","");
		numValue = numValue.replace("-","");
		numValue = numValue.replace("-","");
		
		if (isNaN(numValue) || numValue.length < 10)
		{
			return false;
		}
		return true;
	}
	//E-mailチェック - @が含まれていて、最後が .(ドット)でないなら正しいとする
	this.checkEmail = function (inputValue)
	{
		var Seiki=/[!#-9A-~]+@+[a-z0-9]+.+[^.]$/i;
		var str = inputValue;
    	
		if(str == "" || str == undefined)
		{
			return false;
		}
		if(!str.match(Seiki))
		{
			return false;
		}
		return true;
	}
}


//簡易入力チェック
function AddChecker(name,type,error)
{
	this.type[name] = type;
	this.error[name] = error;
}
function Checker()
{
	var at = document[this.id];
	var str;
	var error = "";
	var name = "";
	var pat;
	for( var i in this.type )
	{
		str = at[i].value;
		if(this.type[i] == "exist" )
		{
			if( str == "" )
			{
				//空白だった場合
				error = this.error[i];
				name = i;
	 			break;
			 }
		}
		else
		{
			name = i;
			//
			if( this.type[i] == "keyword" )
			{
				pat = new RegExp( "^[0-9a-zA-Z]+$" );
			}
			else if( this.type[i] == "password" )
			{
				pat = new RegExp( "^[!-~]{7,8}$" );
		 	}
			else if( this.type[i] == "zip" )
			{
				pat = new RegExp( "^￥￥d{3}-￥￥d{4}$" );
			}
			else if( this.type[i] == "phone" )
			{
				pat = new RegExp( "^[0-9-]+$" );
		 	}
			else if( this.type[i] == "number" )
			{
				pat = new RegExp( "^[+-]?￥￥d+(￥.￥￥d*)?$" );
			}
			else if( this.type[i] == "integer" )
			{
				pat = new RegExp( "^[+-]?￥￥d+$" );
			}
			else if( this.type[i] == "natural" )
			{
				pat = new RegExp( "^￥￥d+$" );
		 	}
			 else
			 {
				pat = new RegExp( this.type[i] ); 
			}
			
			//エラーがあった場合
		 	if(!pat.test(str))
			{
				error = this.error[i];
				break;
			}
		}
	}
	//実行確認ダイアログ
	if(error == "" ) {
		return formConfirm(this.message);
	}
	//エラーダイアログ表示＆フォーカス
	else
	{
		alert(error);
		at[name].focus();
		return false;
	}
}

function FormChecker(id ,message)
{
	this.message = message;
	this.id = id;
	this.add = AddChecker;
	this.check = Checker;
	this.type = new Object();
	this.error = new Object();
}



























