	function doSubmit( strEvent ) {
		document.frmData.event.value = strEvent;
		document.frmData.submit();
		return false;
	}

	function selectMenu( strEvent ) {

		document.frmMenu.event.value = strEvent;
		document.frmMenu.submit();
		return false;
	}

	function movePage( strEvent, strPage ) {

		document.frmData.page_no.value = strPage;
		document.frmData.event.value = strEvent;
		document.frmData.submit();
		return false;
	}

	function setCode( strEvent, strCode ) {

		document.frmData.code.value = strCode;
		document.frmData.event.value = strEvent;
		document.frmData.submit();
		return false;
	}

	function setCsvInfo( strCsvPath, strCsvName ) {
		document.frmData.csv_path.value = strCsvPath;
		document.frmData.csv_name.value = strCsvName;
		document.frmData.submit();
		return false;
	}

	function setAuctionInfo( strEvent, strCode, strName, strBidSys ) {

		document.frmData.code.value = strCode;
		document.frmData.event.value = strEvent;
		document.frmData.auc_bid_sys.value = strBidSys;
		document.frmData.auction_name.value = strName;
		document.frmData.submit();
		return false;
	}

	function setTenderCancelInfo( strEvent, strSeqNo , strCancel ) {

		document.frmData.event.value = strEvent;
		document.frmData.seq_no.value = strSeqNo;
		document.frmData.cancel.value = strCancel;
		document.frmData.submit();
		return false;
	}

	function sort( strEvent, sortKbn ) {

		document.frmData.sort.value = sortKbn;
		document.frmData.event.value = strEvent;
		document.frmData.submit();
		return false;
	}

	function sort_kbn( strEvent, sortKbn ) {

		document.frmData.sort_kbn.value = sortKbn;
		document.frmData.event.value = strEvent;
		document.frmData.submit();
		return false;
	}

	function changeImages( objControl, strImage ) {

		document.images[objControl].src = strImage;
	}

	function openUploadWindow( strURL ) {

		newWindow = window.open("","upd","width=320,height=200,menubar=no,toolbars=0,scrollbars=1,resizable=0");
		newWindow.location = strURL;
		newWindow.focus();

	}

	function windowOpen( strURL ) {

		newWindow = window.open('','lets','width=700,height=650,scrollbars=no,resizable=yes,toolbar=no,location=no,directories=no,status=no,top=30,left=30')
		newWindow.location = strURL;
		newWindow.focus();
	}

	function openNewWindow( strURL ) {

		newWindow = window.open("","new","width=710,height=710,menubar=no,toolbars=0,scrollbars=1,resizable=0");
		newWindow.location = strURL;
		newWindow.focus();

	}

	function dispSysDate() {

		now = new Date() ;
		year	= now.getFullYear() ;
		month 	= now.getMonth() + 1 ;
		day 	= now.getDate() ;
		hour 	= now.getHours();
		min 	= now.getMinutes();
		sec 	= now.getSeconds();

		if ( month < 10 ) 	{ month = "0" + month; 	}
		if ( day < 10 ) 	{ day  	= "0" + day;   	}
		if ( hour < 10 ) 	{ hour  = "0" + hour; 	}
		if ( min < 10 ) 	{ min 	= "0" + min;  	}
		if ( sec < 10 ) 	{ sec  	= "0" + sec; 	}

		document.frmData.sysDate.value = year + "/" + month + "/" + day + " " + hour + ":" + min + ":" + sec;
	}

	function fncAddBidPrice(obj) {
		var cur_price = parseInt(document.getElementById("current").innerHTML.replace(/,/g, ''));
		var bid_price = parseInt(document.getElementById("bidprice").innerHTML.replace(/,/g, ''));
		var add 	 = parseInt(obj.value.replace(/,/g, ''));
		if ( bid_price + add >= cur_price + parseInt(document.getElementById("bid_cnt").innerHTML) ) {
			bid_price = bid_price + add;
		}
		document.getElementById("bid_price").value = fncFormatNumber(bid_price);
		document.getElementById("bidprice").innerHTML = fncFormatNumber(bid_price);
		return 0;
	}

	function fncAddTenderPrice(obj) {
		var cur_price = parseInt(document.getElementById("current").innerHTML.replace(/,/g, ''));
		var bid_price = parseInt(document.getElementById("bidprice").innerHTML.replace(/,/g, ''));
		var add 	 = parseInt(obj.value.replace(/,/g, ''));
		if ( bid_price + add >= cur_price ) {
			bid_price = bid_price + add;
		}
		document.getElementById("bid_price").value = fncFormatNumber(bid_price);
		document.getElementById("bidprice").innerHTML = fncFormatNumber(bid_price);
		return 0;
	}

	function fncFormatNumber(str){
		var ret = Math.floor(str).toString();
		ret = ret.match(/./g).reverse().join("");
		ret = ret.replace(/(\d{3})/g,"$1,");
		ret = ret.match(/./g).reverse().join("").replace(/^,/,"");
		return ret;
	}

	function doBid() {
		document.getElementById("bid_price").value = parseInt(document.getElementById("bidprice").innerHTML.replace(/,/g, ''));
		return 0;
	}

	function doCheckedAll(name, check){
		var count;
		for(count = 0; count < document.frmData[name].length; count++){
			document.frmData[name][count].checked = check;
		}
	}


	function m_is_window() {

		var uAgent = navigator.userAgent
		if( !!window.opener ) {
			if( ( uAgent.indexOf('Gecko')!=-1 || uAgent.indexOf('MSIE 4')!=-1 )
				&& uAgent.indexOf('Win')!=-1 ) {
				return !window.opener.closed ;
			} else {
				return typeof window.opener.document  == 'object';
			}
		} else {
			return false;
		}
	}

	function m_is_opener_object(){
		if ( typeof window.opener == 'object'
			&& typeof window.opener.document == 'object'
			&& typeof window.opener.document.frmData == 'object'
			&& typeof window.opener.document.frmData.ITEM_ID == 'object'
			&& typeof window.opener.document.frmData.txtPIC_PATH  == 'object' ){
			return true;
		} else {
			return false;
		}
	}
	function parentWindowCheck(){
		if(m_is_window() == true ) {

					document.frmImg.flgImg.value = 'true';
					return true;
		}
		forceClose();
		return false;
	}

	function changeImageForCompressFile(){

		var cnt;
		var ary_src;

		if (document.getElementById) {
			ary_src 		= window.opener.document.getElementsByName("image_src[]");

		}else{
			ary_src = new Array();
			for( cnt = 0 ; cnt < window.opener.document.images.length ; cnt++ ){
				if(window.opener.document.images[cnt].name == 'image_src[]'){
					ary_src.push(window.opener.document.images[cnt]);
				}
			}
		}

		aryArgs = changeImageForCompressFile.arguments;

		for(cnt = 0 ; cnt < aryArgs.length ; cnt++ ){
			ary_src[cnt].src = aryArgs[cnt];

			if( cnt == 0 ){
				window.opener.document.frmData.main_image_src.src = aryArgs[cnt];
			}
		}
	}

	function changeValueForCompressFile(){

		var cnt;
		var ary_value;

		if (document.getElementById) {
			ary_value 	= window.opener.document.getElementsByName("sub_image[]");

		}else{
			ary_value = new Array();
			for(cnt = 0 ; cnt < window.opener.document.frmData.elements.length ; cnt++){
				if(window.opener.document.frmData.elements[cnt].name == 'sub_image[]'){
					ary_value.push(window.opener.document.frmData.elements[cnt]);
				}
			}

		}

		aryArgs = changeValueForCompressFile.arguments;
		for(cnt = 0 ; cnt < aryArgs.length ; cnt++ ){
			ary_value[cnt].value = aryArgs[cnt];

			if( cnt == 0 ){
				window.opener.document.frmData.main_image.value = aryArgs[cnt];
			}

		}
		window.close();
	}

	function m_checkPdfFile ( file_name ){
		if(file_name.lastIndexOf(".pdf") == -1 ||
			((file_name.length) - (file_name.lastIndexOf(".pdf")) != 4)){
			return false;
		}

		return true;
	}


	function loadItemImage( sort_order , key ) {

		var filepath;
		var filename;
		var cnt;
		var image_sum;
		var pdf_sum;
		var temp_sort;
		var max_sub_images;

		var ary_file;
		var ary_src;
		var cnt_ary;

		var disp_spec;
		var disp_model;
		var disp_serial;
		var disp_year;
		var disp_hour;

		temp_sort 			= parseInt(sort_order);
		filename  			= '';
		max_sub_images 	= document.frmData.max_item_sub_images.value;
		image_sum = 0;
		pdf_sum = 0;

		if (document.getElementById) {

			ary_value 	= window.opener.document.getElementsByName("sub_image[]");
			ary_src 		= window.opener.document.getElementsByName("image_src[]");
			disp_model  = window.opener.document.getElementsByName("model[]").item(0).value;
			disp_serial = window.opener.document.getElementsByName("serial[]").item(0).value;
			disp_year   = window.opener.document.getElementsByName("year[]").item(0).value;
			disp_hour   = window.opener.document.getElementsByName("hour[]").item(0).value;

		}else{
			ary_src = new Array();
			ary_value = new Array();
			for( cnt_ary = 0 ; cnt_ary < window.opener.document.images.length ; cnt_ary++ ){
				if(window.opener.document.images[cnt_ary].name == 'image_src[]'){
					ary_src.push(window.opener.document.images[cnt_ary]);
				}
			}
			for(cnt_ary = 0 ; cnt_ary<window.opener.document.frmData.elements.length ; cnt_ary++){
				switch(window.opener.document.frmData.elements[cnt_ary].name){
					case 'sub_image[]':
						ary_value.push(window.opener.document.frmData.elements[cnt_ary]);
						break;
					case 'model[]':
						disp_model = window.opener.document.frmData.elements[cnt_ary].value;
						break;
					case 'serial[]':
						disp_serial = window.opener.document.frmData.elements[cnt_ary].value;
						break;
					case 'year[]':
						disp_year = window.opener.document.frmData.elements[cnt_ary].value;
						break;
					case 'hour[]':
						disp_hour = window.opener.document.frmData.elements[cnt_ary].value;
						break;
					default:
						break;
				}
			}
		}

		for( cnt = 0 ; cnt < parseInt( max_sub_images ) ; cnt++){
			if(typeof ary_value[cnt] == 'object'){
				if( ary_value[cnt].value != ''){
					if(m_checkPdfFile(ary_value[cnt].value) == false){
						image_sum ++;
					}
				}
			}
		}
		for( cnt = 0 ; cnt < parseInt( max_sub_images ) ; cnt++ ){

			if(temp_sort >= 0 && temp_sort < parseInt( max_sub_images ) ){

				filepath = ary_src[temp_sort].src
				filename = ary_value[temp_sort].value;
				if(filename != ''){
					if(m_checkPdfFile(filename) == false){

						if( !document.layers ){
							document.imageDisp.src = filepath;
						}
						break;
					}
				}

			}

			if( key == 'prev' ){
				if( temp_sort == 0 ){
					temp_sort = ( parseInt( max_sub_images ) - 1 );
				}else{
					temp_sort = temp_sort - 1;
				}

			}else{
				if( temp_sort == ( parseInt( max_sub_images ) - 1 )){
					temp_sort = 0;
				}else{
					temp_sort = temp_sort + 1;
				}
			}

		}

		if(filename == ''){
			window.location.href = "./ItemImage.php?sort=0&key=error";
			return false;
		}

		for(cnt=0 ; cnt <= temp_sort ; cnt ++){
			if(temp_sort >= 0 && temp_sort < parseInt( max_sub_images ) ){
				if(m_checkPdfFile(ary_value[cnt].value) == true){
					pdf_sum ++;
				}
			}
		}

		if (document.getElementById) {
			document.getElementById('imageNumber').innerHTML =
					(temp_sort - pdf_sum + 1) + ' / ' + (image_sum);
			if(disp_model == ''){
				disp_model = '&nbsp;';
			}
			if(disp_serial == ''){
				disp_serial = '&nbsp;';
			}
			if(disp_year == '' || disp_year == 'NONE' ){
				disp_year = '&nbsp;';
			}else{
				disp_year = disp_year + ' yr';
			}
			if(disp_hour == ''){
				disp_hour = '&nbsp;';
			}else{
				disp_hour = disp_hour + ' hrs';
			}
			document.getElementById('dispModel').innerHTML  = disp_model;
			document.getElementById('dispSerial').innerHTML = disp_serial;
			document.getElementById('dispYear').innerHTML   = disp_year;
			document.getElementById('dispHour').innerHTML   = disp_hour;

		} else if( document.all ) {
			document.all.imageNumber.innerHTML = temp_sort - pdf_sum + 1;
			document.all.imageNumber.innerHTML = image_sum;
		}


		if( parseInt(temp_sort) == 0 ){
			document.frmData.sort_order_prev.value = ( parseInt( max_sub_images ) - 1);
		}else{
			document.frmData.sort_order_prev.value = parseInt(temp_sort) - 1;
		}
		if( parseInt(temp_sort) == ( parseInt( max_sub_images ) - 1) ){
			document.frmData.sort_order_next.value = 0;
	 	}else{
			document.frmData.sort_order_next.value = parseInt(temp_sort) + 1;
		}

		if( document.layers ){
			var url;
			url = "./ItemImage.php?sort_next=" + document.frmData.sort_order_next.value +
					"&sort_prev=" + document.frmData.sort_order_prev.value + "&src=" + filepath +
					"&image_number=" + (temp_sort - pdf_sum + 1) + '/' + (image_sum) + "&key=nn4"+
					"&disp_model=" + disp_model + "&disp_serial=" + disp_serial +
					"&disp_year=" + disp_year +"&disp_hour=" + disp_hour ;

				window.location.href = url;

		}

	}

	function clickForwardForItemImage(){

		var url;

		if(parentWindowCheckForLoadItemImage()== false){
			return false;
		}

		if(document.layers && document.frmData.key.value != 'error'){
			loadItemImage( document.frmData.sort_order_prev.value , 'prev' );
		}else{
			url = "./ItemImage.php?sort=" + document.frmData.sort_order_prev.value +"&key=prev";
			window.location.href = url;
		}
	}

	function clickNextForItemImage(){

		var url;
		if(parentWindowCheckForLoadItemImage()== false){
			return false;
		}

		if( document.layers && document.frmData.key.value != 'error'){
			loadItemImage( document.frmData.sort_order_next.value , 'next' );
		}else{
			url = "./ItemImage.php?sort=" + document.frmData.sort_order_next.value +"&key=next";
			window.location.href = url;
		}
	}

	function parentWindowCheckForUpload(){
		if(m_is_window() == true ) {
			if( m_is_opener_object_for_upload() == true ) {

					return true;
			}
		}
		forceClose();
		return false;
	}

	function parentWindowCheckForLoadItemImage(){
		if(m_is_window() == true ) {
			if( m_is_opener_object_for_loadItemImage() == true ) {

					return true;
			}
		}
		forceClose();
		return false;
	}

	function parentWindowCheckForDownLoad( action ){
		if(m_is_window() == true ) {
			if( m_is_opener_action_object( action ) == true ) {
					return true;
			}
		}
			forceClose();
		return false;

	}

	function m_is_opener_object_for_loadItemImage(){
		if ( typeof window.opener == 'object'
			&& typeof window.opener.document == 'object'
			&& typeof window.opener.document.frmData == 'object'
			&& typeof window.opener.document.frmData.action == 'object'
			&& ( window.opener.document.frmData.action.value == 'AdminItemUpdateConf'
					||  window.opener.document.frmData.action.value == 'AdminItemDeleteConf'
					||  window.opener.document.frmData.action.value == 'AdminItemInsertConf') ){
			return true;
		} else {
			return false;
		}
	}

	function m_is_opener_object_for_upload(){
		if ( typeof window.opener == 'object'
			&& typeof window.opener.document == 'object'
			&& typeof window.opener.document.frmData == 'object'
			&& typeof window.opener.document.frmData.action == 'object'
			&& ( window.opener.document.frmData.action.value == 'AdminItemUpdateInput'
					||  window.opener.document.frmData.action.value == 'AdminItemInsertInput'
					||  window.opener.document.frmData.action.value == 'AdminTypeUpdateInput'
					||  window.opener.document.frmData.action.value == 'AdminTypeInsertInput'
					||  window.opener.document.frmData.action.value == 'AdminMessageInputBid'
					||  window.opener.document.frmData.action.value == 'AdminMessageInputInternetTender'
					||  window.opener.document.frmData.action.value == 'AdminMessageInputTender') ){
			return true;
		} else {
			return false;
		}
	}

	function m_is_opener_action_object( action ){
		if ( typeof window.opener == 'object'
			&& typeof window.opener.document == 'object'
			&& typeof window.opener.document.frmData == 'object'
			&& typeof window.opener.document.frmData.action == 'object'
			&& ( window.opener.document.frmData.action.value == action) ){
			return true;
		} else {
			return false;
		}
	}

	function checkPressKeyForUpload(key){
		var keyCode;

		if(navigator.userAgent.indexOf('Mac') >= 0) {
			return false;
		}

		if(navigator.appName.indexOf("Netscape")>=0){
			keyCode = key.which;
		}else{
			keyCode = event.keyCode;
		}
		if(keyCode == 13){
			parentWindowCheckForUpload();
			doUpload('upload');
		}
	}

	function checkPressKeyForSearchParameter(key){
		var keyCode;

		if(navigator.appName.indexOf("Netscape")>=0){
			keyCode = key.which;
		}else{
			keyCode = event.keyCode;
		}
		if(keyCode == 13){
			return true;
		}
		return false;
	}

	function doUpload( strEvent ) {
		document.frmImg.event.value = strEvent;
		document.frmImg.submit();
		return false;
	}

	function checkEvent() {
		var strEvent;

		strEvent = document.frmData.event.value
		if(strEvent != ''){
			return true;
		}
		return false;
	}

	function checkPressKeyForStockImage(key){
		var keyCode;

		if(navigator.appName.indexOf("Netscape")>=0){
			keyCode = key.which;
		}else{
			keyCode = event.keyCode;
		}

		if(navigator.appName.indexOf("Netscape")>=0 && document.layers){
			if (keyCode == 28) clickForwardForStockImage();
			if (keyCode == 29) clickNextForStockImage();
		}else{
			if (keyCode == 37) clickForwardForStockImage();
			if (keyCode == 39) clickNextForStockImage();
		}
	}

	function checkPressKeyForItemImage(key){

		var keyCode;
		if(parentWindowCheckForLoadItemImage()== false){
			return false;
		}

		if(navigator.appName.indexOf("Netscape")>=0){
			keyCode = key.which;
		}else{
			keyCode = event.keyCode;
		}
		if(navigator.appName.indexOf("Netscape")>=0 && document.layers){
			if (keyCode == 28) clickForwardForItemImage();
			if (keyCode == 29) clickNextForItemImage();
		}else{
			if (keyCode == 37) clickForwardForItemImage();
			if (keyCode == 39) clickNextForItemImage();
		}
	}

	function clickForwardForStockImage(){
		var url;
		url = "./stocklistImage.php?code=" + document.frmData.item_code.value +
				"&sort=" + document.frmData.sort_order_prev.value + "&key=prev";

		window.location.href = url;
	}

	function clickNextForStockImage(){
		var url;
		url = "./stocklistImage.php?code="+document.frmData.item_code.value +
				"&sort=" + document.frmData.sort_order_next.value + "&key=next";
		window.location.href = url;
	}

	function forceClose(){

		var obj_win;
		var timer;

		if(navigator.appName=="Netscape"){

			window.open("","_top");
			window.close();
			return true;
		}else{
			if(document.all&&(navigator.userAgent.match(/MSIE (\d\.\d)/),RegExp.$1)>=5.5){
				obj_win = window.open("","_top");
				obj_win.opener=window;
				obj_win.close();
				return true;
			}else{
				window.close();
				timer=setTimeout("forceClose()",500);
				return true;
			}
		}
	}

	function setTenderInvalidInfo( strEvent, strItemCode, strUserCode , strInvalid ) {

		document.frmData.event.value = strEvent;
		document.frmData.item_code.value = strItemCode;
		document.frmData.user_code.value = strUserCode;
		document.frmData.invalid.value = strInvalid;
		document.frmData.submit();
		return false;
	}

	function setTenderFixInfo( strEvent, strTenderFixFlg ) {

		document.frmData.event.value = strEvent;
		document.frmData.tender_fix_flg.value = strTenderFixFlg;
		document.frmData.submit();
		return false;
	}

