
function isLoading() {
	return ( document.readyState != null && document.readyState != "complete" );
}

/********************************************************
 文字列コンテナ
*******************************************************/
function stringContainer() {
	var _str = new Array();

	this.add = function ( str ) {
		_str.push(str);
	}

	this.count = function () {
		return _str.length;
	}

	this.toString = function () {
		var strCount = _str.length;
		if( strCount == 0 ) {
			return "";
		}

		var str = new String();
		for( var i = 0; i < strCount; i++ ) {
			str = str.concat( _str[i] );
			str = str.concat( "\r\n" );
		}

		return str;
	}
}

/********************************************************
 未入力チェック
*******************************************************/
function isEmpty( text ) {
	return text.length == 0;
}

/********************************************************
 2バイトチェック
*******************************************************/
function isIncludeFullSize( text ) {
	var loopCount = text.length;

	for( var i = 0; i < loopCount; i++ ) {
		var escapeText = escape( text.charAt(i) );
		if( escapeText.length == 6 ) {
			return true;
		}
	}
	return false;
}

/********************************************************
 1バイトチェック
*******************************************************/
function isIncludeHalfSize( text ) {
	var loopCount = text.length;

	for( var i = 0; i < loopCount; i++ ) {
		var escapeText = escape( text.charAt(i) );
		if( escapeText.length != 6 ) {
			return true;
		}
	}
	return false;
}

/********************************************************
 電話番号チェック
*******************************************************/
function isValidPhoneNo( text ) {
	return text.match(/^\d/) != null;
}

/********************************************************
 郵便番号チェック
*******************************************************/
function isValidPostNo( text ) {
	return text.match(/^\d{3}-\d{4}/) != null;
}

/********************************************************
 全角→半角
*******************************************************/
function fullCharTohalfChar( source ) {
	var result = "";
	var count = source.length;

	for( var i = 0; i < count; i++ ) {
		var code = source.charCodeAt(i);
		if( 0xFF01 <= code && code <= 0xFF5E && code != 0xFF3C ) {
			code += String.fromCharCode( code - 0xFEE0 );
		} else if( code == 0x2019 ) {
			code += String.fromCharCode( 0x27 );	// '
		} else if( code == 0x201D ) {
			code += String.fromCharCode( 0x22 );	// "
		} else if( code == 0x3000 ) {
			code += String.fromCharCode( 0x32 );	//  
		} else if( code == 0xFFE3 ) {
			code += String.fromCharCode( 0x7E );	// ~
		} else if( code == 0xFFE5 ) {
			code += String.fromCharCode( 0x5C );	// \
		} else {
			code += source.charAt(i);
		}
	}
}

/********************************************************
 英数字チェック
*******************************************************/
function isNonSign( source ) {
	var count = source.length;
	for( var i = 0; i < count; i++ ) {
		var target = source.charAt(i);
		var code = source.charCodeAt(i);

		if( !( target.match(/[0-9A-Za-z]/) != null
			|| ( 0xFF10 <= code && code <= 0xFF19 )
			|| ( 0xFF21 <= code && code <= 0xFF3A )
			|| ( 0xFF41 <= code && code <= 0xFF5A )
		) ) {
			return false;
		}
	}
	return true;
}

/********************************************************
 英数字チェック
*******************************************************/
function isNumber( source ) {
	if( source.match(/[^0-9]+/) ) {
		return false;
	}
	return true;
}

/********************************************************
 会場２用
以下のものが定義済み
　１．会場ごとの開催日配列
	var _siteArray = new Array();
	_siteArray["01"] = new Array( "2008/01/01", "2008/01/02", "2008/01/03" );
	_siteArray["02"] = new Array( "2008/01/02", "2008/01/04", "2008/01/06" );

	_siteArray["会場コード"] = new Array( "開催日", "開催日", "開催日" );

　２．対象ドロップダウン
	var _optionControl = new optionControl(xx);

*******************************************************/
var _openDays = new ArrayExtention( new Array() );

function ArrayExtention() {
	var _array = new Array();
	this.items = _array;

	this.add = function( item ) {
		_array.push( item );
	}

	this.addRange = function( itemArray ) {
		for( var i = 0; i < itemArray.length; i++ ) {
			_array.push( itemArray[i] );
		}
	}

	this.clear = function() {
		_array = new Array();
		this.items = _array;
	}

	this.length = function() {
		return _array.length;
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _array.length; i++ ) {
			if( _array[i] == key ) {
				return true;
			}
		}
		return false;
	}

	this.remove = function( item ) {
		for( var i = 0; i < _array.length; i++ ) {
			if( _array[i] == item ) {
				_array.splice( i, 1 );
				return;
			}
		}
	}
}

/********************************************************
 オプション操作クラス。
 コンストラクタ
 	操作対象のselect を指定
*******************************************************/
function OptionControl( dropDownList ) {
	var _options = dropDownList.options;
	var _source = new Array();

	this.add = function( item ) {
		if( !this.contentsKey( item ) ) {
			_source.push( item );
		}
		this.reflect();
	}

	this.addRange = function( items ) {
		for( var i = 0; i < items.length; i++ ) {
			this.add( items[i] );
		}
		_source.sort();
		_source.reverse();

		this.reflect();
	}

	this.length = function() {
		return _source.length;
	}

	this.clear = function() {
		_options.length = 0;
		_source.length = 0;
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _source.length; i++ ) {
			if( _source[i] == key ) {
				return true;
			}
		}
		return false;
	}

	this.reflect = function(){
		_options.length = 0;
		for( var i = 0; i < _source.length; i++ ) {
			_options.length++;
			_options[i].text = _source[i];
		}
	}
}

/********************************************************
 オプション操作クラス。
 コンストラクタ
 	操作対象の label を指定
*******************************************************/
function LabelOptionControl( control ) {
	var _option = control;

	this.add = function( item ) {
		if( !this.contentsKey( item ) ) {
			_option.innerText = item;
		}
	}

	this.addRange = function( items ) {
		if( items.length != 1 ) {
			_option.innerText = "";
			return;
		}else{
			_option.innerText = items[0];
		}
	}

	this.clear = function() {
		_option.innerText = "";
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _options.length; i++ ) {
			if( _option.innerText == key ) {
				return true;
			}
		}
		return false;
	}
}

/********************************************************
 会場選択３オプション操作クラス。
 出品明細、落札明細、書類名変の場合
 コンストラクタ
 	操作対象のselect を指定
*******************************************************/
function ListBoxControl( listBox ) {
	var _options = listBox.options;
	var _source = new Array();

	this.add = function( item ) {
		if( !this.contentsKey( item ) ) {
			_source.push( item );
		}
	}

	this.addRange = function( items ) {
		for( var i = 0; i < items.length; i++ ) {
			this.add( items[i] );
		}
		_source.reverse();
		this.reflect();
	}

	this.clear = function() {
		_options.length = 0;
		_source.length = 0;
	}

	this.length = function() {
		return _source.length;
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _source.length; i++ ) {
			if( _source[i] == key ) {
				return true;
			}
		}
		return false;
	}

	this.reflect = function() {
		_options.length = 0;
		for( var i = 0; i < _source.length; i++ ) {
			_options.length++;
			_options[i].text = _source[i];
		}
	}
}

/********************************************************
 会場選択３オプション操作クラス
 計算書の場合
 	操作対象のselect を指定
*******************************************************/
function StatementControl( dropDownList ) {
	var _options = dropDownList.options;
	var _source = new Array();

	this.selected = function() {
		_options[0].selected = true;
	}

	this.add = function( item ) {
		if( !this.contentsKey( item ) ) {
			_source.push( item );
		}
		this.reflect();
	}

	this.addRange = function( items ) {
		for( var i = items.length -1 ; i >= 0; i-- ) {
			if(i == items.length -6 ){
				break;
			}
			this.add( items[i] );
		}
		_source.sort();
		_source.reverse();

		this.reflect();
		if( items.length == 0 ){
			return;
		}
		this.selected();
	}

	this.length = function() {
		return _source.length;
	}

	this.clear = function() {
		_options.length = 0;
		_source.length = 0;
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _source.length; i++ ) {
			if( _source[i] == key ) {
				return true;
			}
		}
		return false;
	}

	this.reflect = function(){
		_options.length = 0;
		for( var i = 0; i < _source.length; i++ ) {
			_options.length++;
			_options[i].text = _source[i];
		}
	}
}

/********************************************************
 会場選択３オプション操作クラス。
 計算書の場合計算書区分
 コンストラクタ
 	操作対象のselect を指定
*******************************************************/
function StatementBidControl( dropDownList ) {
	var _options = dropDownList.options;
	var _source = new Array();

	this.add = function( item ) {
		if( !this.contentsKey( item ) ) {
			_source.push( item );
		}
		this.reflect();
	}

	this.addRange = function( items ) {
		for( var i = 0; i < items.length; i++ ) {
			this.add( items[i] );
		}
		this.reflect();
	}

	this.length = function() {
		return _source.length;
	}

	this.clear = function() {
		_options.length = 0;
		_source.length = 0;
	}

	this.contentsKey = function( key ) {
		for( var i = 0; i < _source.length; i++ ) {
			if( _source[i] == key ) {
				return true;
			}
		}
		return false;
	}

	this.reflect = function(){
		_options.length = 0;
		for( var i = 0; i < _source.length; i++ ) {
			_options.length++;
			_options[i].text = _source[i];
		}
	}
}

function getSubWindowX() {
	return ( screen.width ) - 650 / 2;
}

function getSubWindowY() {
	return ( screen.height ) - 630 / 2;
}
