	MMID = 0;
	
	function checknull(checkobj,checkname){		
	  if (checkobj.value.length == 0 ) {    	
	  	if ( typeof(checkname) == 'undefined' ) checkname = '';  	
	    alert (checkobj.alt + " 此欄位不可空白！");
	    if (! checkobj.readOnly) {
		    //alert(checkobj.tagName);
		    //checkobj.select();
		    checkobj.focus();
		  }  
	    return false;
	  }
	  return true;
	}

	function PassGo() {					
			elementNum = document.wk_form.elements.length;
			for (_i=0; _i<elementNum; _i++){
				if (document.wk_form.elements[_i].className == "mustinputS")
		  		if(!checknull(document.wk_form.elements[_i])) return false;
		  }		  
			return true;			
	}
		
	function pointFormat(thisValue,n){	
		var arrV,tempFormat,tempInt;
		var i;
		if ((isNaN(thisValue)) && (thisValue.length != 0)) {
		    alert ("此欄位為數值型態！");
		    return false;
		}	
		//alert(thisValue);
		thisValue = Math.round(thisValue * Math.pow(10,n) ) / Math.pow(10,n);	
		
		arrV = String(thisValue).split('.');
		
		switch(arrV.length){
			case 1 :
				if (n == 0){
					tempFormat = arrV[0]
				}else{
				  tempFormat = arrV[0] + ".";
				  for(i=1;i<=n;i++) tempFormat += "0";
				}
				return tempFormat;
				break;
			case 2:
				if (n == 0){
					tempFormat = arrV[0]
				}else{
				  tempFormat = arrV[0] + "." + arrV[1];
				  pointLen = arrV[1].length;
				  for(i=pointLen+1;i<=n;i++) tempFormat += "0";
				}
				return tempFormat;
				break;
		}
	}


	function FunClass(thisObj,wk_url) {
		var wk_obj = document.all['MM'];		
		for(var i=0;i<wk_obj.length;i++) {
			wk_obj[i].className = 'Style_01';
			if (thisObj == wk_obj[i]) wk_obj[i].className = 'Style_02';
		}
		document.wk_form.method="post";
		document.wk_form.target="frmBack";
		document.wk_form.action=wk_url;
		switch(wk_url) {
			case 'M09' : 	Menu08.style.display=''; 
					 					return;
					 					break;
			case 'M09_CANCEL' : 
										Menu08.style.display='none'; 
					 					document.wk_form.wk_id_no.value='';
					 					document.wk_form.wk_password.value='';
					 					return;
					 					break;
			case 'M09_LOGIN' :
										document.wk_form.action='GoPass.php';
					 					break;			
		}				
		document.wk_form.submit();		
		if(window.event) window.event.returnValue=false;
	}
	

	function getOffsetLeft (el) {
	    var ol = el.offsetLeft;
	    while ((el = el.offsetParent) != null)
	        ol += el.offsetLeft;
	    return ol;
	}
	
	function getOffsetTop (el) {
	    var ot = el.offsetTop;
	    while((el = el.offsetParent) != null)
	        ot += el.offsetTop;
	    return ot;
	}

	function GoStep(thisObjId) {	
		document.wk_form.method="post";
		document.wk_form.target="frmBack";
	
		switch(thisObjId) {
			case 'M06' : 	document.wk_form.action="M06.php";
											break;
			case 'M09_Go' :
										Menu08.style.display='none'; 
					 					document.wk_form.wk_id_no.value='';
					 					document.wk_form.wk_password.value='';
										document.wk_form.action='M09.php';
					 					break;
		}		
		
		document.wk_form.submit();
		if(window.event) window.event.returnValue=false;		
	}

//m02.js
function M02_FunMClass(thisObjId) {	
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	
	switch(thisObjId) {		
		case 'MS01' : 	document.wk_form.action="M02_01.php";
										break;
		case 'MS02' : 	document.wk_form.action="M02_02.php";
										break;
		case 'MS03' : 	document.wk_form.action="M02_03.php";
										break;
		case 'MS04' : 	document.wk_form.action="M02_04.php";
										break;		
	}		
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

//m03.js
function M03_NextStep(thisObjId) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";

	switch(thisObjId) {		
		case '03M01' : 	document.wk_form.action="M03.php";
	}
	document.wk_form.submit();
	
	if(window.event) window.event.returnValue=false;	
}


//m04.js

function FunBuy01() {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="Buy_01.php";	
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function FunBuy02() {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="Buy_02.php";	
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function FunBuy03() {
	
	answer = confirm('確認是否訂購?'); 
	 if (answer) {	 	
		 document.wk_form.method="post";
	   document.wk_form.target="frmBack";	
	   document.wk_form.action="Buy_03.php";
	   document.wk_form.submit();
	 } else {
		return;	
		
	}	
	
	if(window.event) window.event.returnValue=false;
}

function FunBuy04(wk_order_no) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="Buy_04.php?wk_order_no="+wk_order_no;	
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function FunBuyPrint(wk_order_no) {
	document.wk_form.method="post";
	document.wk_form.target="popwin";	
	document.wk_form.action="Buy_Print.php?wk_order_no="+wk_order_no;	
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}
						
function FunCar(wk_class,wk_book_no) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="Buy_Car.php?wk_class=" + wk_class +"&wk_book_no="+wk_book_no ;
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function ModOrderRow(wk_order_no,wk_t_key) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="M10_03_02.php";
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function DelOrderRow(thisObj)	 {
	for(var i=0; i<DelID.length;i++) {
		if (DelID[i] == thisObj) {
			document.wk_form.elements['wk_num[]'][i].value=0;
		}
	}	
}

function FunDetail(wk_t_key,wk_program_from) {
	document.wk_form.wk_t_key.value=wk_t_key;
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="M04_04_01_01.php?wk_program_from=" + wk_program_from ;		
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function M04_NextStep(thisObjId) {
  if (thisObjId != 'Buy_Car') {
    alert('西書門市 網路書局功能 , 目前施工中 暫停開放!')
    return;	
  }  
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	document.wk_form.action="M04.php?wk_menu="+thisObjId;
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function M04_Clear() {
	if (document.wk_form.wk_dkind) document.wk_form.wk_dkind.value = '';
	if (document.wk_form.wk_select_item) document.wk_form.wk_select_item.value='wk_book_code';
	if (document.wk_form.wk_input) document.wk_form.wk_input.value='';	
}

function M04_FunMClass(thisObjId,wk_param1) { 
	//  更換 左中右 版面
	//  依據 thisObjId 選則 M03 M04 菜單 , 呼叫 M04_FunSClass 顯示 右版面畫面
	switch(thisObjId) {
		case 'Buy_Car' :document.wk_form.wk_first_come.value="1";
										M04[0].innerHTML = M04[1].innerHTML;
										M03[0].innerHTML = M03[0].innerHTML;
										M04_FunSClass('Buy_Car');
										break;
		case 'MS00' : 	document.wk_form.wk_first_come.value="1";
										M04_FunSClass('00S01');
										break;
		case 'M00S01' : M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('00S01');
										break;							
													
		case 'MS01' : 	M04[0].innerHTML = M04[1].innerHTML;
										M03[0].innerHTML = M03[1].innerHTML;
										M03[0].style.color="#535399";										
										M04[0].style.background="#DFEFFF";
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('01S01',wk_param1);
										break;
		case 'MS02' : 	M04[0].innerHTML = M04[2].innerHTML;
										M03[0].innerHTML = M03[2].innerHTML;
										M03[0].style.color="green";
										M04[0].style.background="#F3FFE8";
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('02S01',wk_param1);	
										break;
		case 'MS03' : 	alert('西書門市 網路書局功能 , 目前施工中 暫停開放!')
                    return;
                    M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										M03[0].style.color="#D67F98";
										M04[0].style.background="#FFF7FF";
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S01');
										break;
		case 'MS04' : 	M04[0].innerHTML = M04[4].innerHTML;
										M03[0].innerHTML = M03[4].innerHTML;
										M03[0].style.color="#CD9C61";
										M04[0].style.background="#FFF2EC";
										document.wk_form.wk_first_come.value="1";										
										M04_FunSClass('04S01');
										break;
		case 'MS05' : 	M04[0].innerHTML = M04[5].innerHTML;
										M03[0].innerHTML = M03[5].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M03[0].style.color="#878787";
										M04[0].style.background="#EBEBEB";
										M04_FunSClass('05S01');
										break;
		case 'MS06' : 	M04[0].innerHTML = M04[6].innerHTML;
										M03[0].innerHTML = M03[6].innerHTML;
										M03[0].style.color="#000000";
										M04[0].style.background="#FFFFFF";
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('06S01');
										break;
										
		case '03S01' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S01');
										break;										
		case '03S02' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S02');
										break;
		case '03S03' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S03');
										break;
		case '03S04' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S04');
										break;
										
		case '03S05' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S05');
										break;
		case '03S06' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S06');
										break;
		case '03S07' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S07');
										break;
		case '03S08' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S08');
										break;
		case '03S09' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S09');
										break;
		case '03S10' : 	M04[0].innerHTML = M04[3].innerHTML;
										M03[0].innerHTML = M03[3].innerHTML;
										document.wk_form.wk_first_come.value="1";
										M04_FunSClass('03S10');
										break;
	}	
	return null;
}

function M04_FunSClass(thisObjId,wk_para1) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(thisObjId) {		
		case 'Buy_Car': //購物車
										document.wk_form.action="Buy_Car.php";
										break;										
										//ISBN查詢
		case '00S01' : 	document.wk_form.action="M04_00_01.php";
										break;										
										//黎明叢書
		case '01S01' : 	document.wk_form.action="M04_01_01.php?out_kind=" + wk_para1;	//總類
										break;
										//中文圖書
		case '02S01' : 	document.wk_form.action="M04_02_01.php?out_kind=" + wk_para1;	//雜誌
										break;										
										//外文圖書
		case '03S01' : 	document.wk_form.action="M04_03_01.php";	//地球科學
										break;
		case '03S02' : 	document.wk_form.action="M04_03_02.php";	//數學物理   
										break;                                      
		case '03S03' : 	document.wk_form.action="M04_03_03.php";  //環境工程        
										break;                                      
		case '03S04' : 	document.wk_form.action="M04_03_04.php";	//地科遙測   
										break;                                      
		case '03S05' : 	document.wk_form.action="M04_03_05.php";	//海洋大氣  
										break;										                  
		case '03S06' : 	document.wk_form.action="M04_03_06.php";	//電子電訊   
										break;
		case '03S07' : 	document.wk_form.action="M04_03_07.php";	//機械工程  
										break;
		case '03S08' : 	document.wk_form.action="M04_03_08.php";	//化工材料 
										break;
		case '03S09' : 	document.wk_form.action="M04_03_09.php";	//土木營建  
										break;
		case '03S10' : 	document.wk_form.action="M04_03_10.php";	//軍事航太 
										break;										
										//新進圖書
		case '04S01' : 	document.wk_form.action="M04_04_01.php";		                
		 								break;
										//暢銷圖書
		case '05S01' : 	document.wk_form.action="M04_05_01.php";		                
										break;										
										//優惠圖書										
		case '06S01' : 	document.wk_form.action="M04_06_01.php";
										break;
	}	
	document.wk_form.submit();
	return null;
}

function M04_03_FunSClass(thisObjId,wk_para1) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	switch(thisObjId) {										
		case '040301A' : 	document.wk_form.action="M04_03_01_A.php";
											break;
		case '040301B' : 	document.wk_form.action="M04_03_01_B.php";
											break;
		case '040302A' : 	document.wk_form.action="M04_03_02_A.php";
											break;
		case '040302B' : 	document.wk_form.action="M04_03_02_B.php";
											break;
		case '040303A' : 	document.wk_form.action="M04_03_03_A.php";
											break;
		case '040303B' : 	document.wk_form.action="M04_03_03_B.php";
											break;
		case '040304A' : 	document.wk_form.action="M04_03_04_A.php";
											break;
		case '040304B' : 	document.wk_form.action="M04_03_04_B.php";
											break;
		case '040305A' : 	document.wk_form.action="M04_03_05_A.php";
											break;
		case '040305B' : 	document.wk_form.action="M04_03_05_B.php";
											break;
		case '040306A' : 	document.wk_form.action="M04_03_06_A.php";
											break;
		case '040306B' : 	document.wk_form.action="M04_03_06_B.php";
											break;
		case '040306C' : 	document.wk_form.action="M04_03_06_C.php";
											break;
		case '040307A' : 	document.wk_form.action="M04_03_07_A.php";
											break;
		case '040307B' : 	document.wk_form.action="M04_03_07_B.php";
											break;
		case '040308A' : 	document.wk_form.action="M04_03_08_A.php";
											break;
		case '040308B' : 	document.wk_form.action="M04_03_08_B.php";
											break;
		case '040309A' : 	document.wk_form.action="M04_03_09_A.php";
											break;
		case '040309B' : 	document.wk_form.action="M04_03_09_B.php";
											break;
		case '040310A' : 	document.wk_form.action="M04_03_10_A.php";
											break;
		case '040310B' : 	document.wk_form.action="M04_03_10_B.php";
											break;
	}
	document.wk_form.submit();	
	if(window.event) window.event.returnValue=false;
}
//m06.js
function M06_NextStep(wk_items) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(wk_items) {
		case 1 : 	document.wk_form.action="M06_LOGIN.php";
							break;
		case 2 : 	document.wk_form.action="M06_02.php";
							break;		
	}
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

//m06_01.js
function M06_01_NextStep(wk_items) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(wk_items) {
		case 1 : 	document.wk_form.action="M06.php";
							break;
		case 2 : 	document.wk_form.action="M06_01_01.php";
							break;
		case 3 : 	document.wk_form.action="M06_01_02.php";
							break;
		case 4 : 	document.wk_form.action="M06_01_03.php";
							break;															
		case 5 : 	document.wk_form.action="M06_01_02_01.php";
							break;
		case 6 : 	document.wk_form.action="M06_LOGOUT.php";
							break;																						
	}
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}
//m06_02.js
function M06_02_NextStep(wk_items) {	
	if (!PassGo()) return false;
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(wk_items) {
		case 'M06_02_DB' : 	document.wk_form.action="M06_02_DB.php";
							break;		
		case 'M06_01' 	 : 	document.wk_form.action="M06_01.php";
							break;									
	}
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}
//m07.js
function M07_NextStep(thisObjId) {		
		
	document.wk_form.method="post";
	document.wk_form.target="frmBack";

	switch(thisObjId) {
		case 'M07'   : 	document.wk_form.action="M07.php";
										break;	
		case '01M01' : 	document.wk_form.action="M07_01_01.php";
										break;
		case '01M01DB' :if (!PassGo()) return false; 	
										document.wk_form.action="M07_01_01_DB.php";
										break;
		case '01M02' : 	document.wk_form.action="M07_01_02.php";
										break;										
		case '02M01' : 	document.wk_form.wk_class.value="關於客戶";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M07_02_01.php";
										break;
		case '02M02' : 	document.wk_form.wk_class.value="關於購書";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M07_02_01.php";
										break;
		case '02M03' : 	document.wk_form.wk_class.value="關於取書";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M07_02_01.php";
										break;
		case '02M04' : 	document.wk_form.wk_class.value="其他問題";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M07_02_01.php";
										break;
		case '02M05' : 	document.wk_form.action="M07_02_01.php";
										break;
	}		
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

//m10.js
function M10_FunMClass(thisObjId) {			
	document.wk_form.wk_first_come.value="1";
	M10_FunSClass(thisObjId);
}

function FunOrder01(wk_order_no) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="M10_03_02.php?wk_order_no="+wk_order_no;
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}
function FunOrder01S(wk_order_no) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="M10_03S_02.php?wk_order_no="+wk_order_no;
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function FunOrder0A(wk_order_no) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";	
	document.wk_form.action="M11_03_02.php?wk_order_no="+wk_order_no;
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

function M10_delete(wk_order_no) {
	
	answer = confirm('請確認是否要作廢?'); 
	 if (answer) {	 	
		 document.wk_form.method="post";
	   document.wk_form.target="frmBack";	
	   document.wk_form.action="M10_03S_03.php?wk_order_no="+wk_order_no;
	   document.wk_form.submit();
	 } else {
		return;	
		
	}	
	
	if(window.event) window.event.returnValue=false;
} 

function M10_FunSClass(thisObjId) {	
	
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(thisObjId) {
		case '10S01' : 	document.wk_form.action="M10_01_01.php";										
										break;
		case '10S02' : 	document.wk_form.action="M10_02_01.php";
										break;
		case '10S03' : 	document.wk_form.action="M10_03_01.php";
										break;
		case '10S03S' : document.wk_form.action="M10_03S_01.php";
										break;																
		case '10S0303' : answer = confirm('請確認是否要轉入台北門市估價單?'); 
										 if (answer) {	 	
		                   document.wk_form.action="M10_03_03.php";
		                 } else {
											return;	
										}	  
										 break;
		case 'NewCome': answer = confirm('請確認下列狀況,確定後才可進行異動!\n1.查詢圖書\n2.新進折扣\n3.異動對象\n4.新進狀態'); 
										if (answer) {	
											document.wk_form.action="M10_01_01_DB.php";
										} else {
											return;	
										}	
										break;
		case 'DiscCome': answer = confirm('請確認下列狀況,確定後才可進行異動!\n1.查詢圖書\n2.優惠折扣\n3.異動對象\n4.優惠狀態'); 
										if (answer) {	
											document.wk_form.action="M10_02_01_DB.php";											
										} else {
											return;	
										}	
										break;										
	}
	document.wk_form.submit();	
	if(window.event) window.event.returnValue=false;
}

function M10_01_01_Discount() {
	var pre_net_discount = document.wk_form.pre_net_discount.value;
	if (pre_net_discount.length !=0) {
		var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
		var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
		var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
		for( var i=1;i<wk_net_discount.length;i++) {
			wk_net_discount[i].value = pre_net_discount;
			wk_net_price[i].value = pointFormat( (wk_price[i].value * pre_net_discount)/100 , 0);
		}
	}	
}

function M10_01_01_discount2netprice(in_net_discount) {	
	var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
	var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
	var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
	for( var i=1;i<wk_net_discount.length;i++) if (in_net_discount == wk_net_discount[i]) break;
	wk_net_price[i].value = pointFormat( (wk_price[i].value * wk_net_discount[i].value)/100 , 0);	
}

function M10_01_01_netprice2discount(in_net_price) {	
	var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
	var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
	var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
	for( var i=1;i<wk_net_price.length;i++) if (in_net_price == wk_net_price[i]) break;	
	if (wk_price[i].value == 0) {
		wk_net_discount[i].value = 0;
	} else {
		wk_net_discount[i].value = pointFormat( (wk_net_price[i].value/wk_price[i].value) * 100 , 0);	
	}	
}

function M10_DataCheck(thisObj) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];	
	for( var i=1;i<wk_date_check.length;i++) if (thisObj == wk_date_check[i]) break;
	if (thisObj.checked) 
		wk_check[i].value = 1;
	else	
		wk_check[i].value = '';
}

function M10_CheckAll(thisObj) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];	
	for( var i=1;i<wk_date_check.length;i++) {	
		if (thisObj.value == "wk_query_book_yes") {
			wk_check[i].value = 1;
			wk_date_check[i].checked=true;
		}
		if (thisObj.value == "wk_query_book_no") {
			wk_check[i].value = '';
			wk_date_check[i].checked=false;
		}
	}
}

function M10_CheckAgain(wk_status) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];	
	var wk_all_check  	 = document.wk_form.elements['wk_all_check'];
	wk_all_check.value=wk_status;
	
	for( var i=1;i<wk_date_check.length;i++) {	
		if (wk_status == "YES") {
			wk_check[i].value = 1;
			wk_date_check[i].checked=true;			
	  }	
		if (wk_status == "NO") {
			wk_check[i].value = "";
			wk_date_check[i].checked=false;			
		}
	}
}

function M10_Select(thisObjValue) {
	if (thisObjValue == "wk_disc_range") {
		document.wk_form.method="post";
		document.wk_form.target="frmBack";		
		document.wk_form.action="M10_02_01_range.php";
		document.wk_form.submit();
	} else {
		ID_input.innerHTML='<Input name="wk_input" style="position:relative;top:0;"  type="text" size="20"  class="inputbox10"  onblur="this.className = \'inputbox10\'" onfocus="this.className = \'inputing10\'">';
	}
	if(window.event) window.event.returnValue=false;
}


//m11.js
function M11_FunMClass(thisObjId) {			
	document.wk_form.wk_first_come.value="1";
	M11_FunSClass(thisObjId);
}

function M11_FunSClass(thisObjId) {	
	document.wk_form.method="post";
	document.wk_form.target="frmBack";
	switch(thisObjId) {
		case '11S01' : 	document.wk_form.action="M11_01_01.php";
										break;
		case '11S02' : 	document.wk_form.action="M11_02_01.php";
										break;
		case '11S03' : 	document.wk_form.action="M11_03_01.php";
										break;
		case '11S0303' : 	document.wk_form.action="M11_03_03.php";
										break;
		case 'NewCome': answer = confirm('請確認下列狀況,確定後才可進行異動!\n1.查詢圖書\n2.新進折扣\n3.異動對象\n4.新進狀態'); 
										if (answer) {	
											document.wk_form.action="M11_01_01_DB.php";
										} else {
											return;	
										}	
										break;
		case 'DiscCome': answer = confirm('請確認下列狀況,確定後才可進行異動!\n1.查詢圖書\n2.優惠折扣\n3.異動對象\n4.優惠狀態'); 
										if (answer) {	
											document.wk_form.action="M11_02_01_DB.php";
										} else {
											return;	
										}	
										break;										
	}
	document.wk_form.submit();	
	if(window.event) window.event.returnValue=false;
}

function M11_01_01_Discount() {
	var pre_net_discount = document.wk_form.pre_net_discount.value;
	if (pre_net_discount.length !=0) {
		var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
		var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
		var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
		for( var i=1;i<wk_net_discount.length;i++) {
			wk_net_discount[i].value = pre_net_discount;
			wk_net_price[i].value = pointFormat( (wk_price[i].value * pre_net_discount)/100 , 0);
		}
	}	
}

function M11_01_01_discount2netprice(in_net_discount) {	
	var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
	var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
	var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
	for( var i=1;i<wk_net_discount.length;i++) if (in_net_discount == wk_net_discount[i]) break;
	wk_net_price[i].value = pointFormat( (wk_price[i].value * wk_net_discount[i].value)/100 , 0);	
}

function M11_01_01_netprice2discount(in_net_price) {	
	var wk_net_discount  = document.wk_form.elements['wk_net_discount[]'];
	var wk_net_price  	 = document.wk_form.elements['wk_net_price[]'];
	var wk_price  	 		 = document.wk_form.elements['wk_price[]'];
	for( var i=1;i<wk_net_price.length;i++) if (in_net_price == wk_net_price[i]) break;
	if (wk_price[i].value == 0) {
		wk_net_discount[i].value = 0;
	} else {
		wk_net_discount[i].value = pointFormat( (wk_net_price[i].value/wk_price[i].value) * 100 , 0);	
	}	
	
}

function M11_DataCheck(thisObj) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];	
	for( var i=1;i<wk_date_check.length;i++) if (thisObj == wk_date_check[i]) break;
	if (thisObj.checked) 
		wk_check[i].value = 1;
	else	
		wk_check[i].value = '';
}

function M11_CheckAll(thisObj) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];	
	for( var i=1;i<wk_date_check.length;i++) {	
		if (thisObj.value == "wk_query_book_yes") {
			wk_check[i].value = 1;
			wk_date_check[i].checked=true;
		}
		if (thisObj.value == "wk_query_book_no") {
			wk_check[i].value = '';
			wk_date_check[i].checked=false;
		}
	}
}

function M11_CheckAgain(wk_status) {
	var wk_date_check  	 = document.wk_form.elements['wk_date_check[]'];
	var wk_check  	 		 = document.wk_form.elements['wk_check[]'];		
	var wk_all_check  	 = document.wk_form.elements['wk_all_check'];
	wk_all_check.value=wk_status;
	
	for( var i=1;i<wk_date_check.length;i++) {	
		if (wk_status == "YES") {
			wk_check[i].value = 1;
			wk_date_check[i].checked=true;			
	  }	
		if (wk_status == "NO") {
			wk_check[i].value = "";
			wk_date_check[i].checked=false;			
		}
	}
}

function M11_Select(thisObjValue) {
	if (thisObjValue == "wk_disc_range") {
		document.wk_form.method="post";
		document.wk_form.target="frmBack";		
		document.wk_form.action="M11_02_01_range.php";
		document.wk_form.submit();
	} else {
		ID_input.innerHTML='<Input name="wk_input" style="position:relative;top:0;"  type="text" size="20"  class="inputbox10"  onblur="this.className = \'inputbox10\'" onfocus="this.className = \'inputing10\'">';
	}
	if(window.event) window.event.returnValue=false;
}

//m12.js
function M12_NextStep(thisObjId) {
	document.wk_form.method="post";
	document.wk_form.target="frmBack";

	switch(thisObjId) {		
		case '12M01' : 	document.wk_form.action="M12_DB.php";
										break;		
		case '12M02' : 	document.wk_form.action="M12.php";
										break;												
		case '12M03' : 	document.wk_form.action="M12_01.php";
										break;																						
	}
	document.wk_form.submit();
	
	if(window.event) window.event.returnValue=false;	
}

//m13.js
function M13_NextStep(thisObjId) {		
	document.wk_form.method="post";
	document.wk_form.target="frmBack";

	switch(thisObjId) {
		case 'M13' : 	document.wk_form.action="M13.php";
										break;
		case '13M01' : 	document.wk_form.wk_class.value="關於客戶";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M13_02_01.php";
										break;
		case '13M02' : 	document.wk_form.wk_class.value="關於購書";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M13_02_01.php";
										break;
		case '13M03' : 	document.wk_form.wk_class.value="關於取書";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M13_02_01.php";
										break;
		case '13M04' : 	document.wk_form.wk_class.value="其他問題";
										document.wk_form.wk_page.value=1;
										document.wk_form.action="M13_02_01.php";
										break;
		case '13M05' : 	document.wk_form.action="M13_01_01.php";
										break;
		case '13M06' : 	document.wk_form.action="M13_01_01_DB.php";
										break;
		case '13M07' : 	document.wk_form.action="M13_02_01.php";
										break;										
	}		
	document.wk_form.submit();
	if(window.event) window.event.returnValue=false;
}

// 程式呼叫使用
	// 使用者不常會異動 的功能項
	function NextPressKey(thisObj) { // 輸入區按鍵順序
		var	G_prev_g_len, G_prev_g_r_m, G_prev_g_r_M, G_prev_g_c_m, G_prev_g_c_M
		var G_last_g_len, G_last_g_r_m, G_last_g_r_M, G_last_g_c_m, G_last_g_c_M 
		var G_g_len 		, G_g_r_m			, G_g_r_M			, G_g_c_m			, G_g_c_M			 
	  var G, G_n, G_prev, G_last	  	
			var Ckey = window.event.keyCode;				
			
			//alert(Ckey)
			var wk_obj = document.wk_form.elements[thisObj.name];		
			//決定　元素　深度
			G_g_r_M = wk_obj.length-1;
			for(var G_g_r=1;G_g_r<G_g_r_M;G_g_r++) if (wk_obj[G_g_r] == thisObj) break;
			
			//決定　群組　元素　名稱
			G_n = PressKey.length-1;
			for(var G=0,G_g_c=-1;G<=G_n;G++)	{
					for(var i=0;i<PressKey[G].length;i++)
						if (PressKey[G][i] == thisObj.name) {G_g_c=i;break;}
					if(G_g_c != -1) break;
			}
			
			//群組順序
			G_prev = G-1;
			G_last = G+1;
			if (G == 0  ) G_prev = G_n;
			if (G == G_n) G_last = 0;
			
			//元素順序
			G_prev_g_len = PressKey[G_prev].length-1;
			G_prev_g_r_m = 1;
			G_prev_g_r_M = document.wk_form.elements[ PressKey[G_prev][0] ].length-1;
			G_prev_g_c_m = 0;
			G_prev_g_c_M = PressKey[G_prev].length-1;
			
			G_last_g_len = PressKey[G_last].length-1;
			G_last_g_r_m = 1;
			G_last_g_r_M = document.wk_form.elements[ PressKey[G_last][0] ].length-1;
			G_last_g_c_m = 0;
			G_last_g_c_M = PressKey[G_last].length-1;
			
			G_g_len 		 = PressKey[G].length-1;   //右邊界長度
			G_g_r_m			 = 1;
			G_g_r_M			 = document.wk_form.elements[ PressKey[G][0] ].length-1;
			G_g_c_m			 = 0;
			G_g_c_M			 = PressKey[G].length-1;
					
			G_prev = G_last = G;		
			G_g_prev_c = G_g_c - 1;
			G_g_last_c = G_g_c + 1;
			
			G_g_prev_r = G_g_r;
			G_g_last_r = G_g_r;
			
			if (G_g_c == G_g_c_m) { G_g_prev_c = G_g_c_M; G_g_prev_r = G_g_r - 1; }
			if (G_g_c == G_g_c_M) { G_g_last_c = G_g_c_m; G_g_last_r = G_g_r + 1; }
			
			if ((G_g_c == G_g_c_m) && (G_g_r == G_g_r_m)) { 			
				G_g_prev_c = G_prev_g_c_M;	
				G_g_prev_r = G_prev_g_r_M; 
				G_prev = G-1;
				if (G == 0  ) G_prev = G_n;
			}
			
			if ((G_g_c == G_g_c_M) && (G_g_r == G_g_r_M)) { 			
				G_g_last_c = G_last_g_c_m;	
				G_g_last_r = G_last_g_r_m;
				G_last = G+1;
				if (G == G_n) G_last = 0;
			}
			
			switch(Ckey){
				case 38:				
					if (thisObj.type == 'textarea') return; 
					wk_obj = document.wk_form.elements[ PressKey[G_prev][G_g_prev_c] ][G_g_prev_r];
					wk_obj.focus();
					break;
				case 40:				
					if (thisObj.type == 'textarea') return; 
					wk_obj = document.wk_form.elements[ PressKey[G_last][G_g_last_c] ][G_g_last_r];
					wk_obj.focus();
					break;
				case 9:			
					wk_obj = document.wk_form.elements[ PressKey[G_last][G_g_last_c] ][G_g_last_r];
					wk_obj.focus();
					break;
			}		
	}
	
	function DelRow(thisObj)	 {
		for(var i=0; i<DelID.length;i++) {
			if (DelID[i] == thisObj) {
				document.wk_form.elements['wk_num[]'][i].value=0;
			}
		}
		FunCar('','');
	}

	// 使用者不常異動
	// 設定瀏覽器 停用相關 按鍵功能
	function keyFunction() {		
		if (event.keyCode==27) {
			//alert("Esc 的內建功能已被取消！");
			//return false;
		} else if (event.keyCode==8) {
			//alert("Backspace 的內建功能已被取消！");
			//return false;
		} else if (event.keyCode==9) {
			//alert("Tab 的內建功能已被取消！");
			return false;
		}		
	}
	
	document.onkeydown=keyFunction;
