// Change History
// 08-07-2005 (Richard): online_ordering go to warehouse selection (select_whse.xsl) first
// 08-07-2005 (Richard): change online_ordering_whse to include show_whse
// 09-07-2005 (Richard): add online_other_stock_info(): show stock info of another warehouse
// 11-07-2005 (Richard): Change online_ordering_whse() parameter
// 11-07-2005 (Richard): Add show_whse parameter to back_ordering_whse()
// 11-07-2005 (Richard): Add bo_other_stock_info(): show stock info of another warehouse
// 11-07-2005 (Richard): Remove whse parameter from popup window (*_other_stock_info_win)
// 08-08-2005 (Richard): Add product search function
// 12-08-2005 (Richard): Add order analysis
// 26-08-2005 (Richard): Add customer service
// 26-08-2005 (Richard): Add non-license control
// 03-09-2005 (Richard): Remove several javascripts for online ordering

//===================================================================================
// UTILITIES FOR ECL HOMEPAGE
//===================================================================================
var charset
var win_loc = (window.location).toString()
var MONTH_NAMES = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var MONTH_VAL 	= new Array('01','02','03','04','05','06','07','08','09','10','11','12');

if (win_loc.indexOf('/wos_en/') != -1)
	charset = 'en'

if (win_loc.indexOf('/wos_b5/') != -1)
	charset = 'b5'

if (win_loc.indexOf('/wos_gb/') != -1)
	charset = 'gb'

if (win_loc.indexOf('/wos_hx/') != -1)
	charset = 'hx'

//===================================================================================
// GLOBAL VARIABLES
//===================================================================================
var login_fail  = "/wos_" + charset + "/html/session_timeout.html"

function change_admin_pwd(){
	window.location.href = "/wos_" + charset + "/html/chg_admin_pwd.html"
}

//===================================================================================
//  Jabil Pop Remark
//===================================================================================
function getLongRmk(rmk){
	if (rmk == 'YA')
		return 'Jabil part no. not found'
	else if (rmk == 'YB')
		return 'Part Number & Purchase Order Not Found'
	else if (rmk == 'YC')
		return 'Insuffiecent Purchase Order Qty.'
	else if (rmk == 'YD')
		return 'No Unit Price Found in the system'
	else if (rmk == 'YF')
		return 'No CHN Desc. of Customs Record in System'
	else if (rmk == 'YG')
		return 'No Buyer Code'
	else if (rmk == 'YH')
		return 'Hold by User'
	else if (rmk == 'YI')
		return 'No HS Code'
	else if (rmk == 'YJ')
		return 'No Unit Price'
	else if (rmk == 'YK')
		return 'Damage Found'
	else if (rmk == 'YY')
		return 'Goods from Menlo'
	else if (rmk == 'Y2')
		return 'Shortage Found'
	else if (rmk == 'Y3')
		return 'Country Origin Not Found'
	else if (rmk == 'Y4')
		return 'Without Non-Wooden Packing Cert.'
	else if (rmk == 'Y5')
		return 'No Customs Record'
	else if (rmk == 'Y6')
		return 'No CCC Cert.'
	else if (rmk == 'Y7')
		return 'DG Cargo'
	else if (rmk == 'Y8')
		return 'No Document Found'
	else if (rmk == 'Y9')
		return 'Jabil Part Number Not Found'
	else if (rmk == 'YN')
		return 'Goods without net weight'
}

//===================================================================================
// CUSTOMER SERVICE
//===================================================================================
function customer_service(){
	window.open("/wos_" + charset + "/html/cs_main.html", "CS_MAIN", "width=800, height=800, toolbar=no, resizable=yes, scrollbars=no")
}

function change_supplier() {
	url = "/wos_" + charset + "/stockinfo?cmd=change_supplier&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// UPLOAD PHOTO
//===================================================================================
function init_photo_upload(){
	url = "/wos_" + charset + "/stockinfo?cmd=init_photo_upload&stylesheet=init_photo_upload.xsl&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// CHANGE PASSWORD
//===================================================================================
function change_password(){
	window.location.href = "/wos_" + charset + "/html/chg_pwd.html"
}

//===================================================================================
// MEMBER CONTROL
// - ADD MEMBER
// - DELETE MEMBER
// - EDIT MEMBER
//===================================================================================
function add_member(){
	//window.location.href = "/wos_" + charset + "/html/add_member.html"
	cmd_txt 	= "init_add_member"
	stylesheet  = "init_add_member.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function delete_member(){
	//window.location.href = "/wos_" + charset + "/html/locate_member.html?txt=delete"
	cmd_txt 	= "list_all_member"
	stylesheet  = "list_member.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&txt=delete"
	window.location.href = url
}

function edit_member(){
	//window.location.href = "/wos_" + charset + "/html/locate_member.html?txt=edit"
	cmd_txt 	= "list_all_member"
	stylesheet  = "list_member.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&txt=edit"
	window.location.href = url
}

//===================================================================================
// ORDER STATUS
//===================================================================================
function order_status(){
	cmd_txt 	= "ord_status"
	stylesheet  = "order_status.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// ORDER ANALYSIS
//===================================================================================
function order_analysis_init(){
	cmd_txt		= "order_analysis_init"
	stylesheet	= "order_analysis.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// PRODUCT TRANSACTION
// - SHOW PRODUCT TRANSACTION MAIN PAGE
// - LAST 3 MONTHS OF PRODUCT TRANSACTION
// - SPECIFIED PRODUCT'S TRANSACTION
// - PRODUCT TRANSACTION IN SPECIFIED DAY RANGE
//===================================================================================
function ptMain(){
	cmd_txt = "init_prod_txn"
	stylesheet = "init_prod_txn.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function ptL3M(sortType){
	cmd_txt 	= "show_l3m"
	whse		= util_get_url_param('whse')
	stylesheet  = "prod_transaction.xsl"

	if (sortType == null || sortType == "")
		sortType = "PROD"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=" + sortType + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
	document.body.style.cursor = 'wait'
}

function ptProduct(sortType){
	cmd_txt 	= "show_ind_trs"
	whse		= util_get_url_param('whse')
	prod		= util_get_url_param('prod')
	fromd		= util_get_url_param('fromd')
	tod			= util_get_url_param('tod')
	stylesheet  = "prod_transaction.xsl"

	if (sortType == null || sortType == "")
		sortType = "DATE"

	var url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=" + sortType + "&fromd=" + fromd + "&tod=" + tod + "&prod=" + prod + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
	document.body.style.cursor = 'wait'
}

function ptDayRange(sortType) {
	cmd_txt 	= "show_drpt"
	whse		= util_get_url_param('whse')
	fromd		= util_get_url_param('fromd')
	tod			= util_get_url_param('tod')
	stylesheet  = "prod_transaction.xsl"

	if (sortType == null || sortType == "")
		sortType = "PROD"

	var url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=" + sortType + "&fromd=" + fromd + "&tod=" + tod + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
		window.location.href = url
}

//===================================================================================
//  ONLINE STOCK INFO
// - ONLINE STOCK INFO WITH SPECIFIED WAREHOUSE
// - ONLINE READONLY STOCK INFO OF ANOTHER WAREHOUSE
// - DOWNLOAD STOCK INFO IN CSV
// - DOWNLOAD STOCK INFO IN XLS
//===================================================================================
function online_stock_info(type){
	cmd_txt 	= "stock_info"
	stylesheet  = "stock_info.xsl"

	// show the "No stock" item or not
	if (type == null || type.length <= 0)
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=AVA&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	if (util_get_url_param('whse'))
		this.url += "&whse=" + util_get_url_param('whse')

	if (util_get_url_param('sortby'))
		this.url += "&sortby=" + util_get_url_param('sortby')

	window.location.href = this.url
}

function online_stock_info_whse(type, whseId){
	cmd_txt 	= "stock_info"
	stylesheet  = "stock_info.xsl"

	// show the "No stock" item or not
	if (type == null || type.length <= 0)
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=AVA&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId
	else
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId

	window.location.href = this.url
}

function download_stk_csv(){
	cmd_txt 	= "dl_stock_csv"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail

  if (util_get_url_param('whse'))
  	url += "&whse=" + util_get_url_param('whse')

	//window.open(url, "STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

function download_stk_xls(){
	cmd_txt 	= "dl_stock_xls"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail

  if (util_get_url_param('whse'))
  	url += "&whse=" + util_get_url_param('whse')

	//window.open(url, "STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

//===================================================================================
//  WAREHOUSE ONLINE STOCK INFO
// - DOWNLOAD WAREHOUSE STOCK INFO IN CSV FORMAT
// - DOWNLOAD WAREHOUSE STOCK INFO IN XLS FORMAT
//===================================================================================
function online_whse_stk_info(){
	cmd_txt 	= "whse_stock_info"
	stylesheet  = "whse_stock_info.xsl"

	this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=ALL&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = this.url
}

function download_whse_stk_csv(){
	cmd_txt 	= "dl_whse_stock_csv"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	//window.open(url, "WHSE_STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

function download_whse_stk_xls(){
	cmd_txt 	= "dl_whse_stock_xls"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	//window.open(url, "WHSE_STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

//===================================================================================
// ONLINE STOCK INFO WITH STOCK COST
// - DOWNLOAD STOCK COST STOCK INFO IN CSV FORMAT
// - DOWNLOAD STOCK COST STOCK INFO IN XLS FORMAT
//===================================================================================
function online_scstk_info(){
	cmd_txt 	= "sc_stock_info"
	stylesheet  = "sc_stock_info.xsl"

	this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = this.url
}

function download_scstk_csv(){
	cmd_txt 	= "dl_sc_stock_csv"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	window.location.href = url
}

function download_scstk_xls(){
	cmd_txt 	= "dl_sc_stock_xls"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	window.location.href = url
}

function sc_online_stock_info_whse(whseId){
	cmd_txt 	= "sc_stock_info"
	stylesheet  = "sc_stock_info.xsl"

	this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=ALL&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId

	window.location.href = this.url
}

//===================================================================================
// SPECIAL STOCK INFO
// - DOWNLOAD SPECIAL STOCK INFO IN CSV FORMAT
// - DOWNLOAD SPECIAL STOCK INFO IN XLS FORMAT
//===================================================================================
/*
function online_eestk_info(type){
	cmd_txt 	= "ee_stock_info"
	stylesheet  = "ee_stock_info.xsl"

	alert('1' + type)

	if (type == null || type.length <= 0)
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&show=ALL&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&show=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = this.url
}
*/

function online_eestk_info(whse, type){
	cmd_txt 	= "ee_stock_info"
	stylesheet  = "ee_stock_info.xsl"

	if(!whse && !type)
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&show=AVA&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		this.url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&show=" + type + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = this.url
}

function download_eestk_csv(){
	cmd_txt 	= "dl_ee_stock_csv"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + util_get_url_param('whse') + "&login_failure=" + login_fail
	//window.open(url, "EE_STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

function download_eestk_xls(){
	cmd_txt 	= "dl_ee_stock_xls"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + util_get_url_param('whse') + "&login_failure=" + login_fail
	//window.open(url, "EE_STOCK", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

//===================================================================================
// ONLINE ORDERING
// - ONLINE ORDERING WITH SPECIFIED WAREHOUSE
//===================================================================================
// 08-07-2005 (Richard): online_ordering go to warehouse selection (select_whse.xsl) first
function online_ordering(type, clear_order){
	cmd_txt = "", stylesheet = ""

	cmd_txt		= "select_whse"
	stylesheet	= 'select_whse.xsl'

	// show the "No stock" item or not
	if (type == null || type.length <= 0)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	if (clear_order != null && clear_order == 'TRUE')
		url += "&clear_order=TRUE"

	window.location.href = url
}

// 08-07-2005 (Richard): add show_whse parameter
// 11-07-2005 (Richard); Remove showWhseId: use whseId for both whse & show_whse parameters
function online_ordering_whse(type, whseId){
	cmd_txt 	= "stock_info"
	stylesheet = 'online_order.xsl'

	// show the "No stock" item or not
	if (type == null || type.length <= 0)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId + "&show_whse=" + whseId
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId + "&show_whse=" + whseId

	window.location.href = url
}

//===================================================================================
// BACK ORDER
// - BACK ORDER WITH SPECIFIED WAREHOUSE
// - LIST WAITING BACK ORDER
//===================================================================================

// 11-07-2005 (Richard): back_order() go to warehouse selection (select_whse_bo.xsl) first
function back_order(clear_order){
	cmd_txt		= "select_whse"
	stylesheet	= 'select_whse_bo.xsl'
	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=ALL&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	if (clear_order != null && clear_order == 'TRUE')
		url += "&clear_order=TRUE"

	window.location.href = url
}

// 11-07-2005 (Richard): Add show_whse parameter
function back_order_whse(whseId){
	cmd_txt 	= "stock_info"
	stylesheet = 'back_order.xsl'

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&show=ALL&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&whse=" + whseId + "&show_whse=" + whseId
	window.location.href = url
}

function list_waiting_bo(){
	cmd_txt 	= "list_wbo"
	stylesheet  = "waiting_bo.xsl"
	admin_fail  = "html/admin_login.html"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&admin_login_failure=" + admin_fail
	window.location.href = url
}

//===================================================================================
// LIST RETURN ORDER'S ORDER STATUS
//===================================================================================
function list_osRo(){
	cmd_txt 	= "list_osro"
	stylesheet  = "osro_status.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// SELECT VERSION OF CARGO RECEIPT AND COLLECTION ORDER
// CARGO RECEIPT
// COLLECTION ORDER
//===================================================================================
function select_version(type){
	if (type == 'CR')
		window.location.href = "/wos_" + charset + "/html/select_version.html?type=CR"

	if (type == 'CO')
		window.location.href = "/wos_" + charset + "/html/select_version.html?type=CO"
}

function cargo_receipt(ver){
	cmd_txt		= "carrep_init"

	if (ver == 0)
		stylesheet	= "carrep_init.xsl"

	if (ver == 1)
		stylesheet	= "carrep_init_custom.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&type=CR"
	window.location.href = url
}

function collection_order(ver){
	cmd_txt		= "colorder_init"

	if (ver == 0)
		stylesheet	= "colorder_init.xsl"

	if (ver == 1)
		stylesheet	= "colorder_init_custom.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&type=CO"
	window.location.href = url
}

function get_archive_cr(){
	window.location.href = "/wos_" + charset + "/html/request_archive_cr.html"
}

function get_archive_co(){
	window.location.href = "/wos_" + charset + "/html/request_archive_co.html"
}

function cargo_status(){
	url = "/wos_" + charset + "/stockinfo?cmd=get_cc_status&stylesheet=cargo_status.xsl&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// PRODUCT REGISTRATION
//===================================================================================

function product_registration(){
	cmd_txt 	= "reg_init"
	stylesheet  = "reg_init.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// PENDING ORDER LISTING
//===================================================================================
function get_orderList(){
	cmd_txt 	= "list_pending"
	stylesheet  = "list_orders.xsl"
	admin_fail  = "/wos_" + charset + "/html/admin_login.html"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&admin_login_failure=" + admin_fail
	window.location.href = url
}

function get_nsorderList(){
	cmd_txt 	= "ns_list_pending"
	stylesheet  = "list_orders.xsl"
	admin_fail  = "/wos_" + charset + "/html/admin_login.html"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&admin_login_failure=" + admin_fail
	window.location.href = url
}

//===================================================================================
// ADMIN LOGIN SHOW PENDING ORDERS
//===================================================================================
function head_office_login(){
	cmd_txt 	= "list_pending"
	stylesheet  = "pending_orders.xsl"
	admin_fail  = "/wos_" + charset + "/html/admin_login.html"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&admin_login_failure=" + admin_fail
	window.location.href = url
}

//===================================================================================
// PRODUCT SEARCH
//===================================================================================
function product_search_init(){
	cmd_txt 	= "product_search_init"
	stylesheet  = "product_search_init.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// ADDRESS BOOK
// - UPDATE ADDRESS BOOK
// - ADD ADDRESS
// - DOWNLOAD ADDRESS IN CSV FORMAT
// - DOWNLOAD ADDRESS IN XLS FORMAT
//===================================================================================
function update_add_bk(){
	cmd_txt 	= "get_info"
	stylesheet 	= "edit_address.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function add_address(){
	window.location.href = "/wos_" + charset + "/html/add_address.html"
}

function download_addr_csv(){
	cmd_txt 	= "dl_addr_csv"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	//window.open(url, "ADDR", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

function download_addr_xls(){
	cmd_txt 	= "dl_addr_xls"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&login_failure=" + login_fail
	//window.open(url, "ADDR", "menubar=yes, scrollbars=yes, status=yes, resizable=yes")
	window.location.href = url
}

//===================================================================================
// POST MESSAGE TO FORUM
// - SHOW REPLY MESSAGE
//===================================================================================
function shout(){
	cmd_txt 	= "get_msg"
	stylesheet 	= "forum.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet

	window.location.href = url
}

function show_ro(){
	cmd_txt 	= "list_cmpted_ord"
	stylesheet  = "ro_order_status.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// CREDIT CONTROL
// - SHOW CREDIT HISTORY
//===================================================================================
function ccMain(){
	cmd_txt 	= "get_credit_info"
	stylesheet  = "credit_control_main.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function creditHistory(){
	cmd_txt 	= "get_credit_history"
	stylesheet  = "credit_history.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// LOT ORDERING FUNCTION
// - INIT LOT ORDERING FUNCTION
//===================================================================================
function init_lot_order(){
	cmd_txt 	= "list_all_lot"
	stylesheet  = "list_lot.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// SALES HISTORY
//===================================================================================
function sales_history(){
	url = "/wos_" + charset + "/html/get_sales_history.html"
	window.location.href = url
}

function getSalesHt(frmVal, toVal){
	if (frmVal != '' && toVal != ''){
		cmd_txt = "cmd=sales_enquiry"
		fromd = "&fromd=" + frmVal
		tod = "&tod=" + toVal
		action    = "/wos_" + charset + "/stockinfo?"
		sortType  = "&sortby=DATE"
		stylesheet= "&stylesheet=sales_history.xsl"

		url = action + cmd_txt + fromd + tod + sortType + stylesheet
		window.location.href = url
		document.body.style.cursor = 'wait'
	}
	else{
		alert(msg_bDate)
	}
}

function search_sales_his(trg, shType, frmVal, toVal){
	if (trg != ''){
		if (frmVal != '' && toVal != ''){
			url = "/wos_" + charset + "/stockinfo?cmd=search_sales_enq&type=" + shType + "&target=" + trg + "&fromd=" + frmVal + "&tod=" + toVal + "&stylesheet=sales_history.xsl&login_failure=html/session_timeout.html"
			window.location.href = url
		}
		else
			alert(msg_bDate)
	}
}

//===================================================================================
// KOLIN DRIVER INFORMATION
// - LIST DRIVER INFORMATION
// - INIT GET DRIVER INFO PAGE
// - INIT GET DRIVER INFO PAGE VERSION 2
// - LIST KOLIN PENDING ORDERS
//===================================================================================
function list_driver_info(){
	cmd_txt 	= "list_driver_info"
	stylesheet  = "list_driver_info.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function init_get_driver_info(){
	url = "/wos_" + charset + "/html/get_driver_info.html"
	window.location.href = url
}

function list_driver_info_v2(){
	cmd_txt 	= "list_driver_info_v2"
	stylesheet  = "list_driver_info.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function init_get_driver_info_v2(){
	url = "/wos_" + charset + "/html/get_driver_info_v2.html"
	window.location.href = url
}

function list_kl_pending_ord(){
	cmd_txt 	= "list_kl_po"
	stylesheet  = "kl_pending_orders.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

//===================================================================================
// JABIL FUNCTIONS
//===================================================================================
function jb_order_status(){
	cmd_txt 	= "jb_ord_status"
	stylesheet  = "jb_order_status.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function jb_online_order(whse){
	cmd_txt 	= "jb_stock_info"
	stylesheet  = "online_order_jb.xsl"

	if(!whse)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function jb_hold_list(whse){
	cmd_txt 	= "jb_get_holdlist"
	stylesheet  = "jb_hold_request.xsl"

	if(!whse)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function jb_hold_request(whse){
	cmd_txt 	= "access_jb_huh_prod"
	stylesheet  = "jb_hold_request.xsl"

	if(!whse)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&url_failure=html/jb_access_expired.html"
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&whse=" + whse + "&sortby=CODE&stylesheet=" + stylesheet + "&login_failure=" + login_fail + "&url_failure=html/jb_access_expired.html"

	window.location.href = url
}

function jb_chg_ctry(){
	/*
	url = "/wos_" + charset + "/stockinfo?cmd=access_jb_chg_coo&url_success=html/jb_chg_ctry.html&url_failure=html/jb_access_expired.html"

	window.location.href = url
	*/

	cmd_txt = "jb_list_na_ctry"
	stylesheet = "jb_ctn_detail.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	window.location.href = url
}

function init_jb_txnHist(){
	cmd_txt 	= "jb_list_file"
	stylesheet  = "jb_file_list.xsl"

	url = "/wos_" + charset + "/html/init_jb_txnhist.html"
	window.location.href = url
}

function list_jb_files(str, type){
	cmd_txt 	= "jb_list_file"
	stylesheet  = "jb_file_list.xsl"

	if (str == null && type == null)
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail
	else
		url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&target=" + str + "&type=" + type + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function jb_today_rec(){
	cmd_txt 	= "jb_get_today_rec"
	stylesheet  = "jb_today_rec.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function init_jb_enquiry(){
	url = "/wos_" + charset + "/html/jb_enquiry.html"
	window.location.href = url
}

function list_rctrl(){
	cmd_txt 	= "jb_list_rctl"
	stylesheet  = "jb_rec_ctrl.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&ref=0&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

function list_nlc(){
	cmd_txt 	= "jb_list_nlc"
	stylesheet  = "jb_nlc.xsl"

	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&ref=0&stylesheet=" + stylesheet + "&login_failure=" + login_fail

	window.location.href = url
}

//===================================================================================
// LOGOUT FUNCTION
//===================================================================================
function logout(){
	cmd_txt = "logout"
	url = "/wos_" + charset + "/stockinfo?cmd=" + cmd_txt + "&url_success=html/logout.html"

	window.location.href = url
}

//===================================================================================
// HELP MENU FUNCTION
//===================================================================================
function jb_help(){
	var fn = 'adm'
	var usr_role = (util_get_cookie('ROLE')).toLowerCase()

	if (usr_role == 'ADM' || usr_role == 'JNM')
		fn = 'adm'
	else if (usr_role == 'ASS')
		fn = 'ass'
	else if (usr_role == 'ORD' || usr_role == 'SAL')
		fn = 'ord'

	url = "/wos_" + charset + "/guide/jb_wos_" + fn + "_guide_en.pdf"
	window.open(url, 'ONLINE_HELP')
}

//===================================================================================
// HELP MENU FUNCTION
//===================================================================================
function help(){
	var fn = 'adm'
	var usr_role = (util_get_cookie('ROLE')).toLowerCase()

	if (usr_role == 'ADM')
		fn = 'adm'
	else if (usr_role == 'ASS')
		fn = 'ass'
	else if (usr_role == 'ORD' || usr_role == 'SAL')
		fn = 'ord'
	else if (usr_role == 'ENQ')
		fn = 'enq'

	url = "/wos_" + charset + "/guide/wos_" + fn + "_guide_" + charset + ".pdf"
	window.open(url, 'ONLINE_HELP')
}

//===================================================================================
// UTILITIES
//===================================================================================
function util_get_url_param(name) {
	var strParam = window.location.search

	idx1 = strParam.indexOf(name + "=")
	if (idx1 == -1)	return ""

	idx1 = idx1 + name.length + 1
	idx2 = strParam.indexOf("&", idx1)

	if (idx2 != -1)
		len = idx2 - idx1
	else
		len = strParam.length

	return unescape(strParam.substr(idx1, len))
}

_COOKIE_DELIMITER = "\f\n~\t\r"
_COOKIE_DELIMITER_ESCAPED = "\\f\\n~\\t\\r"

function util_del_all_cookies(){
	cookieStr = document.cookie.toString()
	arrayOfCookie = cookieStr.split(";")

	for (i = 0; i < arrayOfCookie.length; i++){
		token = arrayOfCookie[i]
		util_del_cookie(token.substring(0, token.indexOf("=")))
	}
}

function util_get_cookie(name) {
    var start = document.cookie.indexOf(name+"=");

    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return "";

    if (start == -1) return "";
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function util_set_cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : ";path=/") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}

function util_del_cookie(name,path,domain) {
    if (util_get_cookie(name)) document.cookie = name + "=" +
        ( (path) ? ";path=" + path : ";path=/") +
        ( (domain) ? ";domain=" + domain : "") +
        ";expires=Tue, 01-Jan-1980 00:00:01 GMT";
}

function setDelimitedCookie(cookie_nm, token_nm, token_val, expires) {

	re = new RegExp(token_nm + "=" + "[^" + _COOKIE_DELIMITER_ESCAPED + "]*");
	cookie_val = util_get_cookie(cookie_nm)
	token = token_nm + "=" + token_val;

	if (cookie_val.search(re) != -1) {
		cookie_val = cookie_val.replace(re, token);
	} else {
		cookie_val = cookie_val + token + _COOKIE_DELIMITER;
	}

	if (expires)
		util_set_cookie(cookie_nm, cookie_val, expires)
	else
		util_set_cookie(cookie_nm, cookie_val)
}

function getDelimitedCookie(cookie_nm, token_nm) {

	re = new RegExp(token_nm + "=" + "[^" + _COOKIE_DELIMITER_ESCAPED + "]*");
	cookie_val = util_get_cookie(cookie_nm)

	if (cookie_val.search(re) != -1) {
		token = cookie_val.match(re)[0]
		len1 = token_nm.length
		len2 = token.length
		token_val = token.substring(len1+1, len2)
	} else {
		token_val = ""
	}

	return token_val;
}

function util_get_url_param(name) {
	var strParam = window.location.search

	idx1 = strParam.indexOf(name + "=")
	if (idx1 == -1)	return ""

	idx1 = idx1 + name.length + 1
	idx2 = strParam.indexOf("&", idx1)

	if (idx2 != -1)
		len = idx2 - idx1
	else
		len = strParam.length

	return unescape(strParam.substr(idx1, len))
}

function util_validate_empty_field(fld, txtFldName) {
	val = fld.value

	if (val.length == 0 || val.search(/^\s+$/) != -1) {
		if (charset == 'en') alert('Please enter value in the "' + txtFldName + '"');
		if (charset == 'b5') alert('請在' + txtFldName + '輸入資料')
		if (charset == 'gb' || charset == 'hx') alert('③婓' + txtFldName + '怀?鄶岏?')

		fld.focus();
		return false;
	}

	return true;
}

function util_validate_email(fld_email) {

	if (fld_email.value.search(/^[^@]+@[^\.]+\.[a-zA-Z\.]+/) == -1 || fld_email.value.search(/\s/) != -1) {
		if (charset == 'en') alert('Please enter a valid "Email address"');
		if (charset == 'b5') alert('請輸入正確的電郵地址')
		if (charset == 'gb' || charset == 'hx') alert('③怀?鄳??殿警觬妗寎?')

		fld_email.focus();
		return false;
	}

	if (fld_email.value.search(/[^A-Za-z0-9_\-@.&!]/) != -1) {
		if (charset == 'en') alert('Please enter a valid "Email address"');
		if (charset == 'b5') alert('請輸入正確的電郵地址')
		if (charset == 'gb' || charset == 'hx') alert('③怀?鄳??殿警觬妗寎?')

		fld_email.focus();
		return false;
	}
	return true;
}

function util_validate_integer(fld, txtFldName) {
	val = fld.value;

	if (val.length == 0 || val.search(/[^0-9]/) != -1) {
		if (charset == 'en') alert('Please enter integer in the "' + txtFldName + '"')
		if (charset == 'b5') alert(txtFldName + '只可輸入整數')
		if (charset == 'gb' || charset == 'hx') alert(txtFldName + '硐褫怀?鄳?杅')

		fld.focus();
		fld.select();
		return false;
	}

	return true;
}

function util_validate_phone_number(fld, txtFldName) {
	val = fld.value;

	if (val.length < 6 || val.search(/[^0-9\s]/) != -1) {
		if (charset == 'en') alert('Please enter a valid telephone number in the "' + txtFldName + '"')
		if (charset == 'b5') alert('請輸入正確的電話號碼於 "' + txtFldName + '"')
		//if (charset == 'gb' || charset == 'hx') alert('③怀?鄳??殿警蝏偕鷓邆? "' + txtFldName + '"')

		fld.focus();
		fld.select();
		return false;
	}

	return true;
}

function util_validate_float(fld, txtFldName){
	val = fld.value;

	if (val.length == 0 || val.search(/[^0-9.]/) != -1 || val.search(/.{2,}/) > 0 ) {
		if (charset == 'en') alert('Please enter number in the "' + txtFldName + '"')
		if (charset == 'b5') alert(txtFldName + '只可輸入數字')
		if (charset == 'gb' || charset == 'hx') alert(txtFldName + '硐褫怀?輮?趼')

		fld.focus();
		fld.select();
		return false;
	}

	return true;
}
// Link tip
function showtip(current,e,text){
	if (document.all&&document.readyState=="complete"){
    	document.all.tooltip2.innerHTML='<marquee style="border:1px solid black"><font class="txtSubject" color="#000099">'+text+'</font></marquee>'
	    document.all.tooltip2.style.pixelLeft=event.clientX+document.body.scrollLeft+10
    	document.all.tooltip2.style.pixelTop=event.clientY+document.body.scrollTop+10
	    document.all.tooltip2.style.visibility="visible"
	}
	else
		if (document.layers){
		    document.tooltip2.document.nstip.document.write('<font class="txtSubject">' + text + '</font>')
		    document.tooltip2.document.nstip.document.close()
		    document.tooltip2.document.nstip.left=0
		    currentscroll=setInterval("scrolltip()",100)
		    document.tooltip2.left=e.pageX+10
		    document.tooltip2.top=e.pageY+10
		    document.tooltip2.visibility="show"
		}
}

function hidetip(){
	if (document.all)
    	document.all.tooltip2.style.visibility="hidden"
    else
		if (document.layers){
		    clearInterval(currentscroll)
		    document.tooltip2.visibility="hidden"
		}
}

// Get mouse x, y coordinates
var IE = document.all?true:false;

if (!IE)
	document.captureEvents(Event.MOUSEMOVE)

document.onmousemove = getMouseXY;
var mouseX = 0;
var mouseY = 0;

function getMouseXY(e){
	mouseX = event.clientX + document.body.scrollLeft;
	mouseY = event.clientY + document.body.scrollTop;

	if (mouseX < 0){mouseX = 0;}
	if (mouseY < 0){mouseY = 0;}
	return true;
}
// ---------------------------------------------------------------
