//--------------------------------------------------- Common Functions ----------------------------------------------------------
var timeRedirect = 20;
var iTimerID = null;

function doAutoRedirect(){
	if(timeRedirect<0){return false;}
	--timeRedirect;
	var obj = $("timeLeft");
	if(obj)obj.innerHTML = timeRedirect;
	if(timeRedirect==0){
		timeRedirect=-1;
		location.href='/';
		return false;
	}
}

function getBrowser(){
	var _str = navigator.userAgent.toLowerCase();
	var _arr = new Array("msie", "firefox", "safari", "opera", "netscape");
	for(var i=0;i<_arr.length;i++){
		if(_str.indexOf(_arr[i])!=-1)return _arr[i];
	}
	return "other";
}

var browser = getBrowser();

function clearThis(obj,init){
	var re = new RegExp(init,'gi');
	var _text = obj.value.replace(re,"").trim();
	obj.value = _text;
}

function doClear(obj,init){
	var re = new RegExp(init,'gi');
	var _text = obj.value.replace(re,"").trim();
	obj.className = "on";
	obj.value = _text;
}

String.prototype.trim = function(){ 
	return this.replace(/(^\s*)|(\s*$)/g,"");
}

function CheckFC(inText){
	if(inText=="."||inText=="-"||inText=="0"){
		return false;
	}else{
		return true;
	}
}

function gotoPage(base,totalpage){
	var page = $('gotopage').value;
	if(!checkString('Int',page)||page>totalpage){
		alert("Please specify valid number of Page!");
		return;
	}
	var url = base.replace("{p}",page);
	window.location.href = url;
}

function btnOver(obj){
	obj.src = obj.src.substring(0,obj.src.length-7) + "_on.gif";
}

function btnOut(obj){
	obj.src = obj.src.substring(0,obj.src.length-7) + "_of.gif";
}

function divOver(obj){
	obj.style.background = "#f2f2f2";
}

function divOut(obj){
	obj.style.background = "#ffffff";
}

function setCSS(obj,css){
	obj.className = css;
}

function CheckFileName(inText){											//check \/:*?"<>|,' Contain?
	if((inText.indexOf("\\")!= -1)||(inText.indexOf("/")!= -1)||(inText.indexOf(":")!= -1)||(inText.indexOf("*")!= -1)||(inText.indexOf("?")!= -1)||(inText.indexOf("\"")!= -1)||(inText.indexOf("<")!= -1)||(inText.indexOf(">")!= -1)||(inText.indexOf("|")!= -1)||(inText.indexOf(",")!= -1)||(inText.indexOf("'")!= -1))return true;
	return false;
}

function CheckFName(inText){											//check \/:*?"<>| Contain?
	if((inText.indexOf("\\")!= -1)||(inText.indexOf("/")!= -1)||(inText.indexOf(":")!= -1)||(inText.indexOf("*")!= -1)||(inText.indexOf("?")!= -1)||(inText.indexOf("\"")!= -1)||(inText.indexOf("<")!= -1)||(inText.indexOf(">")!= -1)||(inText.indexOf("|")!= -1))return true;
	return false;
}

function CheckKeyword(inText){
	var re = /^(([^\|\,\s]*)([\,]+[^\|\,\s]*)*)([\|]+([^\|\,\s]*)([\,]+[^\|\,\s]*)*)*$/i;
	var result = true;
	var chkText = inText.trim().replace(re,"");
	var tlen = inText.length-1;
	if(chkText.indexOf("|")==0||chkText.indexOf(",")==0||chkText.indexOf("||")>0||chkText.indexOf(",|")>0||chkText.indexOf("|,")>0||chkText.indexOf(",,")>0||chkText.lastIndexOf("|")==tlen||chkText.lastIndexOf(",")==tlen)
		result = false;
	return result;
}

function $(id){
	return document.getElementById(id);
}

function $obj(obj,id){
	return obj.getElementsByTagName(id).length;
}

function $n(id){
	return document.getElementsByName(id);
}

function $t(id){
	return document.getElementsByTagName(id);
}

function nbsp(c){
	return (new Array(c + 1)).join(' ');
}

//----------------------------------------------- Contact this Member -------------------------------------------------
function showDiv(_boolean){
	if(!($('divContactArea')))return;
	if(Number(getCookie("divStatus"))==1 && !!_boolean){
		closeDiv();
	}else if(Number(getCookie("divStatus"))==2 && !!_boolean){
		hideDiv();
	}else{
		$('divContactArea').style.height = 200+'px';
		$('spMaxBtn').style.display = 'none';
		$('spMinBtn').style.display = 'block';
	}
}

function hideDiv(_boolean){
	if(!($('divContactArea')))return;
	$('divContactArea').style.height = 29 + 'px';
	$('spMinBtn').style.display = 'none';
	$('spMaxBtn').style.display = 'block';
	if(!_boolean)setCookie("divStatus",2);
}

function closeDiv(_boolean){
	if(!($('divContactArea')))return;
	$('divContactArea').style.display = 'none';
	if(!_boolean)setCookie("divStatus",1);
}

function showDivContactArea(_file){
	if (_file!=null && _file.length>0){
		var str = "";
		try{
			if(document.compatMode && document.compatMode!='BackCompat'){
				str += '<div style="z-index:9;right:0;bottom:0;width:250px;height:200px;overflow:hidden;position:fixed;'+(/MSIE 7/.test(navigator.appVersion)?'':'_position:absolute;_margin-top:expression(document.documentElement.clientHeight-this.style.pixelHeight+document.documentElement.scrollTop);')+'" id="divContactArea">';
			}else {
				str += '<div style="z-index:9;right:0;bottom:0;width:250px;height:200px;overflow:hidden;position:fixed;*position:absolute;*top:expression(eval(document.body.scrollTop)+eval(document.body.clientHeight)-this.style.pixelHeight);" id="divContactArea">';
			}
		str += '<div style="z-index:9;position:absolute;width:250px;height:30px;overflow:hidden;">';
		str += '<span style="cursor:pointer;float:left;clear:none;width:123px;height:14px;overflow:hidden;margin:10px 5px;"></span>';
		str += '<span id="spCloseBtn" title="Close" onclick="closeDiv()"></span>';
		str += '<span id="spMaxBtn" title="Maximize" onclick="showDiv()"></span>';
		str += '<span id="spMinBtn" title="Minimize" onclick="hideDiv()"></span>';
		str += '</div>';
		str += '<iframe scrolling="no" frameborder="0" width="250" height="200" src="/Contact/Corner/' + _file + '">-</iframe>';
		str += '</div>';
		document.getElementById('spContact').innerHTML = str;
		setTimeout('hideDiv(true);', 1000);
		}catch(err){}
	}
	showDiv(true);
}

function doCheckMinContact(form){
	var re = new RegExp('Your message here','gi');
	var str = form.inpDetail.value.trim();
	var len = str.length;
	if(len==0||re.test(str)){
		alert("Please enter your message!");
		form.inpDetail.focus();
		return false;
	}
	
	if(len<20||len>3000){
		alert("Your message should be between 20-3000 characters!");
		form.inpDetail.focus();
		return false;
	}
	
	return false;
}
//---------------------------------------------- /Contact this Member -------------------------------------------------

function getXmlhttp(){
	var http_request;
	if(window.XMLHttpRequest){																																				// if Mozilla, IE7, Safari etc
		http_request = new XMLHttpRequest();
	}else if(window.ActiveXObject){																																		// if IE6 or below
		try{http_request = new ActiveXObject("MSXML2.XMLHTTP");}
			catch(e){
		try{http_request = new ActiveXObject("Microsoft.XMLHTTP");}
			catch(e){}
		}
	}
	if(!http_request){ 
		window.alert("can't create XMLHttpRequest object.");
		return null;
	}	
	return http_request;
}

function popupWindow(_url,_name,features){ //v2.0
	var _window = window.open(_url,_name,features);
	_window.focus();
}

function popupDefWin(url,_name,w,h){
	_window = window.open(url,_name,'top=200,left=200,status=0,scrollbars=0,width=' + w + ',height=' + h);
	_window.focus();
}
//--------------------------------------------------- /Common Functions ----------------------------------------------------------
function inputOver(_field,_str){
	var re = new RegExp(_str,'i');
	if(re.test(_field.value)){
		_field.className = "blackText";
		_field.value = "";
		_field.focus();
	}
}

function inputOut(_field,_str){
	var re = / /gi;
	var re = new RegExp(_str,'i');
	if(_field.value.replace(re,"")==""||re.test(_field.value)){
		_field.className = "grayText";
		_field.value = _str;
		_field.blur();
	}
}

function doCheckLogin(form){
	var re = / /gi;
	var re = new RegExp('UserID or Email Address','i');
	if(form.inpUserID.value.replace(re,"")==""||re.test(form.inpUserID.value)){
		alert("Please input your User ID or Email Address!");
		form.inpUserID.focus();
		return false;
	}
	
	if(form.inpPassword.value.replace(re,"")==""){
		alert("Please input your Passwords!");
		form.inpPassword.focus();
		return false;
	}
	
	return true;
}

function getObjPos(obj){
	var _left = 0;
	var _top = 0;
	if(obj.offsetParent){
		_left = obj.offsetLeft;
		_top = obj.offsetTop;
		while(obj=obj.offsetParent){
			_left += obj.offsetLeft
			_top += obj.offsetTop
		}
	}
	return{x:_left,y:_top};
}

function getMousePos(e){
	e = e || window.event;
	var D = document.documentElement;
	if(e.pageX)return {x: e.pageX, y: e.pageY};
	return{
		x: e.clientX + D.scrollLeft - D.clientLeft,
		y: e.clientY + D.scrollTop - D.clientTop
	};
}

var dragStatus = false;
function doDrag(div,id){
	var obj = $(id);
	div.onmousedown = function(e){
		if(!document.all)e.preventDefault();
		var oPos = getObjPos(obj);
		var cPos = getMousePos(e);
		dragStatus = true;
		document.onmouseup = function(e){
			dragStatus = false;
			document.onmousemove = null;
			document.onmouseup = null;
		};
		document.onmousemove = function(e){
			if(dragStatus){
				obj.style.position = 'absolute';
				var Pos = getMousePos(e);
				obj.style.left = Pos.x - cPos.x + oPos.x + 'px';
				obj.style.top = Pos.y - cPos.y + oPos.y + 'px';
			}
			return false;
		}
	}
}
//--------------------------------------------------- Cookie ----------------------------------------------------------
function setCookie(name, value, expires, path, domain, secure){
	var now = new Date();
	//now.setTime(now.getTime());
	if(expires){
		expires = expires * 1000 * 60 * 60;
		if(name!="RightCorner")expires = expires * 24;
	}
	var _expires = new Date(now.getTime() + (expires));
	document.cookie = name + '=' + escape(value) +
	((expires)? ';expires=' + _expires.toGMTString() : '' ) +
	((path)? ';path=' + path : '' ) +
	((domain) ? ';domain=' + domain : '' ) +
	((secure) ? ';secure' : '' );
}
	
function deleteCookie(name, path, domain){
	if(getCookie(name))document.cookie = name + '=' +
	((path)? ';path=' + path : '') +
	((domain)? ';domain=' + domain : '' ) +	';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}

function getCookie(name){
	var prefix = name + "=";
	var cookieStartIndex = document.cookie.indexOf(prefix);
	if(cookieStartIndex == -1)return null;
	var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
	if(cookieEndIndex == -1)cookieEndIndex = document.cookie.length;
	return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}

//--------------------------------------------------- /Cookie ----------------------------------------------------------

function hideTip(){
	var tipObj = $('divTip');
	if(tipObj){
		if(tipObj.style.display=="block"){
			tipObj.style.display = "none";
			$('tipPointer').style.display = "none";
		}
	}
}

function showTip(obj,_text,_auto,_width,_offset,offY,_color){
	if(obj){
		var pos = getObjPos(obj);
		var _offsetX;
		var _offsetY = 16 + offY;
		var divTip = $('divTip');
		var tipImg = $('tipPointer');
		divTip.style.top = pos.y + 30 + offY;
		if(typeof _offset!="undefined"){
			_offsetX = _offset;
			divTip.style.left = pos.x + _offset - 16;
		}else{
			_offsetX = 8;
			divTip.style.left = pos.x - 8;
		}
		
		if(typeof _width!="undefined")divTip.style.width = _width + "px";
		if(typeof _color!="undefined" && _color!="")divTip.style.backgroundColor = _color;
		
		tipImg.style.left = pos.x + _offsetX;
		tipImg.style.top = pos.y + _offsetY;
		
		divTip.innerHTML = _text;
		tipImg.style.display = "block";
		divTip.style.display = "block";
		if(_auto)iTimerID = window.setTimeout(function (){hideTip();},4000);
	}
}
//--------------------------------------------- biz.efeedlink.com --------------------------------------------------

//-------------------------------------------- /biz.efeedlink.com --------------------------------------------------
var idxTimerID = null;

function changeMenu(thisObj,idx){
	var div = $('dlIndex');
	var dtObj,ddObj;
	dtObj = div.getElementsByTagName("dt");
	ddObj = div.getElementsByTagName("dd");
	for(var i=0;i<dtObj.length;i++){
		if(i==0){
			dtObj[i].className = "first";
		}else{
			dtObj[i].className = "";
			ddObj[i].className = "";
		}
	}
	thisObj.className = "curr";
	if($(idx).innerHTML==""){
		$(idx).className = "loading";
	}else{
		$(idx).className = "currDD";
	}
	$(idx).onmouseover=function(){clearTimeout(idxTimerID);}
	$(idx).onmouseout=function(){idxTimerID=setTimeout(function(){hids(thisObj,idx);},500)}
	thisObj.onmouseout=function(){idxTimerID=setTimeout(function(){hids(thisObj,idx);},500)}
}

function hids(thisObj,idx){
	if(idxTimerID != null)clearTimeout(idxTimerID);
	thisObj.className = "";
	$(idx).className = "";
	if(idx=="idx:a")thisObj.className = "first";
}

function viewAll(id){
	var div = document.getElementById(id);
	var ul = div.getElementsByTagName('ul')[0];
	var li = ul.getElementsByTagName('li');
	ul.className = "viewAll";
	for(var i=0;i<li.length;i++){
		if(i==4){
			li[i].style.display = "none";
		}else{
			li[i].style.display = "block";
		}
	}
}

function viewLess(id){
	var div = document.getElementById(id);
	var ul = div.getElementsByTagName('ul')[0];
	var li = ul.getElementsByTagName('li');
	ul.className = "";
	for(var i=0;i<li.length;i++){
		if(i>4){
			li[i].style.display = "none";
		}else{
			li[i].style.display = "block";
		}
	}
}

function checkString(dataType,string){
	var re = "";
	switch(dataType){
		case "Int":
			re = /^[1-9]\d*$/;
			break;
		case "Num":
			re = /^[\d]*$/;
			break;
		case "Price":
			//re = /^[0-9]+(\.[0-9]+)?$/;
			re = /^([1-9]\d*|[0])(\.[0-9]+)?$/;
			break;
		case "Email":
			re = /^(\w+([-+.]\w+)*)+@([0-9a-z][\w-]+\.)+[a-z]{2,4}$/i;
			break;
		case "UserID":
			re = /^[\w\@\_\-\.]{6,20}$/;
			break;
		case "Domain":
			//re = /^[\w\@\_\-]{4,36}$/;
			re = /^[0-9a-z\-\_]{4,36}$/i;
			break;
		case "URL":
			re = /^https?:\/\/.+$/i;
			break;
		case "Unique":
			re = /^[0-9a-f]{8}([-][0-9a-f]{4}){3}[-][0-9a-f]{12}$/i;
			break;
		default:
			//Nothing...
	}
	if(re!=""){
		return re.test(string);
	}else{
		return false;
	}
}

function doCheckSearch(form){
	var re,str;
	var ls = form.ls.value.trim();
	var sa = form.sa.value.trim();
	
	switch(sa){
		//case "Products":
		case "Companies":
			str = "Search Companies Directory";
			break;
		case "Buy":
			str = "Search Buying Offers";
			break;
		case "Sell":
			str = "Search Selling Offers";
			break;
		default:			//"Products"
			str = "Search Product Category";
	}
	re = new RegExp(str,'gi');
	var re2 = new RegExp('Search eFeedBiz','gi');
	
	var _keyword = form.keyword.value.trim();
	if(_keyword==""||re.test(_keyword)||re2.test(_keyword)){
		alert("Please enter a keyword for the search!");
		form.keyword.value = '';
		form.keyword.focus();
		return false;
	}
	
	var ss = form.inpCategories.value;
	
	form.action = '/' + sa + '/' + ls + '/m1' + ss + '-' + escape(_keyword) + '-p1.html';
	return true;
}

//---------------------------------- Company Info -------------------------------------
function tabOver(id){
	$('tab_'+id).className = 'tab_' + id + '_over';
}

function tabOut(id){
	$('tab_'+id).className = 'tab_' + id + '_of';
}

function setFocus(id){
	var _arr = new Array("Basic Information", "Contact Person", "About Company", "Company Description");
	var str = '';
	for(var i=0;i<4;i++){
		if(i==id){
			str += '<div id="tab_' + i + '" class="tab_' + i + '_on">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'block';
		}else{
			str += '<div id="tab_' + i + '" class="tab_' + i + '_of" onmousemove="tabOver(' + i + ');" onmouseout="tabOut(' + i + ');" onclick="setFocus(' + i + ');">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'none';
		}
	}
	$('CiHeader').innerHTML = str;
}

function setNpFocus(id){
	var _arr = new Array("Product Detail", "Product Detail");
	var str = '';
	for(var i=0;i<2;i++){
		if(i==id){
			str += '<div id="tab_' + i + '" class="tab_' + i + '_on">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'block';
		}else{
			str += '<div id="tab_' + i + '" class="tab_' + i + '_of" onmousemove="tabOver(' + i + ');" onmouseout="tabOut(' + i + ');" onclick="setNpFocus(' + i + ');">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'none';
		}
	}
	$('NpHeader').innerHTML = str;
}

function setNbFocus(id){
	var _arr = new Array("Tell Suppliers what you want to buy", "Product Details & Specifications");
	var str = '';
	for(var i=0;i<2;i++){
		if(i==id){
			str += '<div id="tab_' + i + '" class="tab_' + i + '_on">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'block';
		}else{
			str += '<div id="tab_' + i + '" class="tab_' + i + '_of" onmousemove="tabOver(' + i + ');" onmouseout="tabOut(' + i + ');" onclick="setNbFocus(' + i + ');">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'none';
		}
	}
	$('NbHeader').innerHTML = str;
}

function setNsFocus(id){
	var _arr = new Array("Tell Buyers what you want to sell", "Product Details & Specifications");
	var str = '';
	for(var i=0;i<2;i++){
		if(i==id){
			str += '<div id="tab_' + i + '" class="tab_' + i + '_on">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'block';
		}else{
			str += '<div id="tab_' + i + '" class="tab_' + i + '_of" onmousemove="tabOver(' + i + ');" onmouseout="tabOut(' + i + ');" onclick="setNsFocus(' + i + ');">' + _arr[i] + '</div>';
			$('div_' + i + '_tab').style.display = 'none';
		}
	}
	$('NsHeader').innerHTML = str;
}

function getGrp(tObj,label){
	var grpObj = tObj.getElementsByTagName("OPTGROUP");
	for(var i=0;i<grpObj.length;i++){
		if(label==grpObj[i].label){
			return grpObj[i];
		}
	}
	return null;
}

function getGrpOpt(tObj,value){
	var optObj = tObj.getElementsByTagName("OPTION");
	for(var i=0;i<optObj.length;i++){
		if(value==optObj[i].value){
			return optObj[i];
		}
	}
	return null;
}

function dispose(sObj,opt){
	var _parent = opt.parentNode;
	sObj.remove(opt.index);
	var opts = _parent.getElementsByTagName("OPTION");
	if(opts.length==0){
		//_parent.removeNode(true);		Firefox can not support Error
		var _top = _parent.parentNode;
		try{
			_top.removeChild(_parent);
		}catch(e){}
	}
}

function reSort(obj){
	var grps = obj.getElementsByTagName("OPTGROUP");
	var len = grps.length;
	var ary = new Array();
	var i,j,grp,opts,olen,opt,id,ol;
	
	for(i=0;i<len;i++){
		grp = grps[i];
		opts = grp.getElementsByTagName("OPTION");
		olen = opts.length;
		id = grp.id;										//IE OK
		//priority = grp.getAttribute("priority");
		label = grp.label;
		
		var sAry = new Array();
		for(j=0;j<olen;j++){
			opt = opts[j];
			//sAry[j] = new Array(opt.priority,opt.value,opt.text);		//IE OK
			sAry[j] = new Array(opt.id,opt.value,opt.text);
		}
		sAry.sort(function(x,y){return x[0].replace("pID","")-y[0].replace("pID","")});		//sory by Sector Priority
		ary[i] = new Array(id,label,sAry);
		
	}
	ary.sort(function(x,y){return x[0].replace("pID","")-y[0].replace("pID","")});			//sort by Sub Category Priority
	
	opts = obj.getElementsByTagName("OPTION");
	olen = opts.length;
	for(j=0;j<olen;j++){obj.remove(0);}					//Delete All Option(s)
	
	for(i=0;i<len;i++){
		grp = grps[i];
		grp.id = ary[i][0];
		grp.label = ary[i][1];
		opts = ary[i][2];
		for(j=0;j<opts.length;j++){
			opt = opts[j];
			ol = document.createElement("OPTION");
			ol.id = opt[0];
			ol.value = opt[1];
			ol.text = opt[2];
			ol.innerHTML = opt[2];
			grp.appendChild(ol);
		}
	}
}

function swapItems(flag){
	var i;
	var fObj = (flag==1?$('lftSel'):$('rgtSel'));
	var tObj = (flag==1?$('rgtSel'):$('lftSel'));
	var slen = fObj.options.length;
	var arySelOpts = new Array();
	var SelOptsCount = 0;
	
	for(i=0;i<slen;i++){
		if(fObj.options[i].selected)arySelOpts[SelOptsCount ++] = fObj.options[i];
	}
	
	var _opt,_parent,tGrp,bGrp,el,ol;
	if(SelOptsCount>0){
		for(i=0;i<SelOptsCount;i++){
			_opt = arySelOpts[i];
			_parent = _opt.parentNode;
			el = getGrp(tObj,_parent.label);
			
			bGrp = true;
			if(el==null){
				bGrp = false;
				el = document.createElement("OPTGROUP");
				el.id = _parent.id;
				el.label = _parent.label;
			}
			var ol = getGrpOpt(el,_opt.value);
			
			if(ol==null){
				ol = document.createElement("OPTION");
				ol.id = _opt.id;
				ol.value = _opt.value;
				ol.text = _opt.text;
				ol.innerHTML = _opt.text;
				el.appendChild(ol);
				if(!bGrp)tObj.appendChild(el);
			}
			
			dispose(fObj,_opt);			//
		} // end for
		reSort(tObj);
	}else{
		alert("Please specify at least one category.");
		fObj.focus();
		return;
	}
}

function setLocation(form,sel){
	var _name = sel.options[sel.selectedIndex].text;
	var xmlHttp = getXmlhttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status==200)showRegion(form,_name,xmlHttp.responseXML);
	}
	xmlHttp.open("GET","/xml/regions.xml",true);
	xmlHttp.send(null);
}

function showRegion(form,sel,xmlDoc){
	var row = xmlDoc.getElementsByTagName("country");
	var node,country,regions,region,_selected;
	var _input = form.inpState.value;
	var _class = "txtw400px";
	var sHTML = "";
	for(var i=0;i<row.length;i++){
		node = row[i];
		country = node.getAttribute("name");
		if(sel==country){
			_class = "txtw200px";
			regions = node.getElementsByTagName("region");
			sHTML = '<Select name="inpRegion" style="width:195px;height:19px;margin-right:5px;" onChange="setRegion(' + form.name + ',this);">';
			for(var j=0;j<regions.length;j++){
				region = regions[j].getAttribute("name");
				_selected = "";
				if(region==_input)_selected = " selected";
				sHTML += '<option value="' + j + '"' + _selected + '>' + region + '</option>';
			}
			sHTML += '</Select>';
			break;
		}
	}
	form.inpState.className = _class;
	$('spanRegion').innerHTML = sHTML;
}

function setRegion(form,sel){
	var _index = sel.selectedIndex;
	if(_index>0)form.inpState.value = sel.options[_index].text;
}

function chkEmail(form,userid){
	var obj,val,url;
	obj = form.inpEmail;
	val = obj.value.trim();
	
	if(val==""){
		alert("Please specify your email address.");
		obj.focus();
		return;
	}

	if(!checkString('Email',val)){
		alert("You have entered a wrong email format.\nPlease enter again.");
		obj.focus();
		return;
	}
	
	url = '/xml/chkExist.asp?email=' + val + '&userid=' + userid;
	var xmlHttp = getXmlhttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status==200){
			var row = xmlHttp.responseXML.getElementsByTagName("Row");
			var exist = row[0].childNodes[0].nodeValue;
			if(exist=="True"){
				obj.focus();
				showAlert('alert','The email address you indicated has already been used.<br>Please use a different email address of yours.',380,98,true);
				return;
			}else{
				showAlert('info','You can use the Email Address indicated.',380,98,true);
				return;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function chkDomain(form,comid){
	var obj,val,url;
	obj = form.inpURLHeader;
	val = obj.value.trim();
	
	if(val==""){
		alert("Please specify your sub domain header.");
		obj.focus();
		return;
	}

	if(!checkString('Domain',val)){
		alert("You have entered a wrong domain format.\nPlease enter again.");
		obj.focus();
		return;
	}
	
	url = '/xml/chkDomain.asp?domain=' + val + '&comid=' + comid;
	var xmlHttp = getXmlhttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status==200){
			var row = xmlHttp.responseXML.getElementsByTagName("Row");
			var exist = row[0].childNodes[0].nodeValue;
			if(exist=="True"){
				obj.focus();
				showAlert('alert','The domain you indicated has already been used.<br>Please use a different domain of yours.',380,98,true);
				return;
			}else{
				showAlert('info','You can use the domain indicated.',380,98,true);
				return;
			}
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function showAlert(_type,_text,_width,_height,_auto){
	var _header = "System Alert";
	var _class = "red14pxArialBoldText";
	var _textclass = "redArial12pxText";
	var _icon = "/images/icon_stop.gif";
	var _bg,_divleft,_divtop;
	if(_type=="info"){
		_header = "System Information";
		_class = "darkGreen14pxBoldArial";
		_textclass = "blackArial12pxText";
		_icon = "/images/icon_info.gif";
	}
	if(_height > 400){
		_bg = "/images/bg_restrictedaccess_600.jpg";
	}else if(_height > 200){
		_bg = "/images/bg_restrictedaccess_400.jpg";
	}else{
		_bg = "/images/bg_restrictedaccess_200.jpg";
	}
	
	var sHTML = '<iframe style="position:absolute;z-index:-1;width:90%;height:100%;margin:0;padding:0;" frameborder="0" src="about:blank"></iframe>';
	sHTML += '<b class="b1"></b><b class="b2 d1" style="background:url(' + _bg + ') no-repeat left -1px;"></b><b class="b3 d1" style="background:url(' + _bg + ') no-repeat left -2px;"></b><b class="b4 d1" style="background:url(' + _bg + ') no-repeat left -3px;"></b>';
	sHTML += '<div class="b d1" style="text-align:center;height:' + (_height-10) + 'px;vertical-align:top;background:url(' + _bg + ') no-repeat left -5px;">';
	sHTML += '<table width="' + (_width-2) + '" border="0" cellspacing="4" cellpadding="0">';
	sHTML += '<tr>';
	sHTML += '<td width="43"><img src="' + _icon + '" width="33" height="46"></td>';
	sHTML += '<td class="' + _class + '" style="text-align:left;vertical-align:middle;">' + _header + '</td>';
	sHTML += '<td style="text-align:right;vertical-align:top;"><img src="/images/btn_div_close_of.gif" width="21" height="21" style="cursor:pointer;" onMouseOver="btnOver(this);" onMouseOut="btnOut(this);" onClick="doHideDiv(\'divAlert\');"></td>';
	sHTML += '</tr>';
	sHTML += '<tr>';
	sHTML += '<td>&nbsp;</td>';
	sHTML += '<td colspan="2" class="' + _textclass + '" style="text-align:left;">' + _text + '</td>';
	sHTML += '</tr>';
	sHTML += '</table>';
	sHTML += '</div>';
	sHTML += '<b class="b4 d1" style="background:url(' + _bg + ') no-repeat left -' + (_height-5) + 'px;"></b><b class="b3 d1" style="background:url(' + _bg + ') no-repeat left -' + (_height-4) + 'px;"></b><b class="b2 d1" style="background:url(' + _bg + ') no-repeat left -' + (_height-2) + 'px;"></b><b class="b1b"></b>';
	
	if(!$('divAlert')){
		div = document.createElement('div');
		div.id = 'divAlert';
		div.style.display = 'none';
		div.style.position = 'absolute';
		div.style.zIndex = 999;
		document.body.appendChild(div);
	}
	var divAlert = $('divAlert');

	divAlert.style.width = _width + "px";
	divAlert.style.height = _height + "px";
	
	var D = document.documentElement;
	
	if(D.clientWidth<_width){
		_divleft = (10 + D.scrollLeft) + 'px';
	}else{
		_divleft = ((D.clientWidth-_width)/2+D.scrollLeft) + 'px';
	}

	if(D.clientHeight<_height){
		_divtop = (10 + D.scrollTop) + 'px';
	}else{
		_divtop = ((D.clientHeight-_height)/2+D.scrollTop) + 'px';
	}
	divAlert.style.left = _divleft;
	divAlert.style.top = _divtop;
	
	divAlert.innerHTML = sHTML;
	divAlert.style.display = "block";
	if(_auto)iTimerID = window.setTimeout(function (){doHideDiv('divAlert');},5000);
}

function doHideDiv(id){
	var div = $(id);
	if(div){
		iTimerID = null;
		div.style.display = "none";
	}
}

function doRemove(t){
	switch(t){
		case "Logo":
			document.forms["FormCI"].inpCompanyLogo.value = "";
			$('imgCoLogo').src = '/images/logo_190x60.gif';
			break;
		case "Photo":
			document.forms["FormCI"].inpUserPhoto.value = "";
			$('imgPhotograph').src = '/images/photo_120x120.gif';
			break;
		case "Product":
			document.forms["FormNP"].inpRelatedPhoto.value = "";
			$('imgRelatedphoto').src = '/images/img_no_photo.gif';
			break;
		case "PrAtt":
			document.forms["FormNP"].inpAttachFile.value = "";
			$('divAttach').innerHTML = 'No Attached File';
			break;
		case "Relatedphoto":
			document.forms["FormNB"].inpRelatedPhoto.value = "";
			$('imgRelatedphoto').src = '/images/img_no_photo.gif';
			break;
		case "BoAtt":
			document.forms["FormNB"].inpAttachFile.value = "";
			$('divAttach').innerHTML = 'No Attached File';
			break;
		case "SoRelatedphoto":
			document.forms["FormNS"].inpRelatedPhoto.value = "";
			$('imgRelatedphoto').src = '/images/img_no_photo.gif';
			break;
		case "SoAtt":
			document.forms["FormNS"].inpAttachFile.value = "";
			$('divAttach').innerHTML = 'No Attached File';
			break;
		default:
			//Nothing ...
	}
}

function doDelete(obj,t,page,id){
	var _parent = obj.parentNode.parentNode;
	var eles = _parent.getElementsByTagName("div");
	var itemName = "";
	var act;
	switch(t){
		case "AB":																	//Address Book Item
			itemName = eles[0].innerHTML;
			act = '/BizCentre/delAB.asp';
			break;
		case "PR":																	//Product Item
			itemName = eles[2].innerHTML;
			act = '/BizCentre/delPR.asp';
			break;
		case "BO":																	//Buying Offer Item
			itemName = eles[2].innerHTML;
			act = '/BizCentre/delBO.asp';
			break;
		case "SO":																	//Selling Offer Item
			itemName = eles[2].innerHTML;
			act = '/BizCentre/delSO.asp';
			break;
		case "MI":																	//Inbox Item
			itemName = eles[1].innerHTML;
			act = '/BizCentre/delMI.asp';
			break;
		case "MO":																	//Outbox Item
			itemName = eles[1].innerHTML;
			act = '/BizCentre/delMO.asp';
			break;
		case "SI":																	//Sent Item
			itemName = eles[1].innerHTML;
			act = '/BizCentre/delSI.asp';
			break;
		case "DI":																	//Deleted Item
			itemName = eles[1].innerHTML;
			act = '/BizCentre/delDI.asp';
			break;
		case "MD":																	//Drafts Item
			itemName = eles[1].innerHTML;
			act = '/BizCentre/delMD.asp';
			break;
		default:
			//Nothing ...
	}
	if(itemName==""){
		return;
	}else{
		var form = document.forms["FormSystem"];
		form.id.value = id;
		form.page.value = page;
		form.action = act;
		if(t=="AB"||t=="PR"||t=="BO"||t=="SO"||t=="DI"){
			itemName = itemName.replace(/\'/g,"\'");
			if(confirm('Are you sure want to delete below item?\n\"' + itemName + '"')){
				form.submit();
			}
		}else{
			form.submit();
		}
	}
}

function delMSG(t,page,id){
	var act;
	switch(t){
		case "MI":																	//Inbox Item
			act = '/BizCentre/delMI.asp';
			break;
		case "MO":																	//Outbox Item
			act = '/BizCentre/delMO.asp';
			break;
		case "SI":																	//Sent Item
			act = '/BizCentre/delSI.asp';
			break;
		case "DI":
			act = '/BizCentre/delDI.asp';
			break;
		case "MD":
			act = '/BizCentre/delMD.asp';
			break;
		default:
			//Nothing ...
	}
	var form = document.forms["FormSystem"];
	form.id.value = id;
	form.page.value = page;
	form.action = act;
	if(t=="DI"){
		if(confirm('Are you sure want to delete message?')){
			form.submit();
		}
	}else{
		form.submit();
	}
}

function showDivUpload(obj,t){
	var div,pos,strUpTitle,ftype,nftype;
	if(iTimerID != null)clearTimeout(iTimerID);
	if(!$('divUpload')){
		div = document.createElement('div');
		div.id = 'divUpload';
		
		div.style.display = 'none';
		document.body.appendChild(div);
	}
	div = $('divUpload');
	pos = getObjPos(obj);
	
	var _width = 320;
	var _height = 128;
	var _left = pos.x;
	
	if((_left+_width)>=document.body.clientWidth)_left = document.body.clientWidth-_width-5;
	div.style.position = 'absolute';
	
	div.style.width = _width + 'px';
	div.style.height = _height + 'px';
	
	div.style.left = _left + 'px';
	div.style.top = pos.y + 'px';
	
	ftype = "gif,jpg,png,bmp";
	nftype = "";
	switch(t){
		case "Logo" :
			strUpTitle = "Upolad Company Logo (*.gif,*.jpg,*.png,*.bmp)";
			break;
		case "Photo":
			strUpTitle = "Upload Photograph (*.gif,*.jpg,*.png,*.bmp)";
			break;
		case "Product":
			strUpTitle = "Upolad Product Image (*.gif,*.jpg,*.png,*.bmp)";
			break;
		case "PrAtt":
			ftype = "";
			nftype = "vbs,aspx,html,php,jsp,cgi";
			strUpTitle = "Upload Product Detail Attachment";
			break;
		case "Relatedphoto":
			strUpTitle = "Upolad Related Photo (*.gif,*.jpg,*.png,*.bmp)";
			break;
		case "BoAtt":
			ftype = "";
			nftype = "vbs,aspx,html,php,jsp,cgi";
			strUpTitle = "Upload Requirement Detail Attach File";
			break;
		case "SoRelatedphoto":
			strUpTitle = "Upolad Related Photo (*.gif,*.jpg,*.png,*.bmp)";
			break;
		case "SoAtt":
			ftype = "";
			nftype = "vbs,aspx,html,php,jsp,cgi";
			strUpTitle = "Upload Product Detail Attach File";
			break;
		case "MailAttach":
			ftype = "";
			nftype = "vbs,aspx,html,php,jsp,cgi";
			strUpTitle = "Upload Attach";
			break;
		default:
			return;
	}
	
	var sHTML = '<form name="FormUpload" method="post" style="margin:0px;padding:0px;" target="SystemProcess" ENCTYPE="multipart/form-data">';
	sHTML += '  <input type="hidden" name="inpUploadType" value="' + t + '">';
	sHTML += '  <input type="hidden" name="inpFileType" value="' + ftype + '">';
	sHTML += '  <input type="hidden" name="inpNotFileType" value="' + nftype + '">';
	sHTML += '  <div class="Type" onmouseover="doDrag(this,\'divUpload\');">';
	sHTML += '    <div id="upFileHeader">' + strUpTitle + '</div>';
	sHTML += '    <div id="upFileClose"><img src="/images/upload/btn_close_on.gif" width="16" height="16" onClick="doCancel();"></div>';
	sHTML += '  </div>';
	sHTML += '  <div class="divUpFile"><input type="file" name="inpFile" class="fileUp"></div>';
	sHTML += '  <div id="ProcessBar"><div id="PercentDone" style="width:0%;"></div></div>';
	sHTML += '  <div class="divUpAction"><input type="image" src="/images/upload/btn_upload_of.gif" width="59" height="19" onmouseover="btnOver(this);" onmouseout="btnOut(this);" onClick="doUploadFile(FormUpload);"><img src="/images/upload/btn_cancel_of.gif" width="59" height="19" onmouseover="btnOver(this);" onmouseout="btnOut(this);" onClick="doCancel();" style="margin-left:10px;cursor:pointer;"></div>';
	sHTML += '</form>';
	
	div.innerHTML = sHTML;
	div.style.display = "block";
}

var iUpFileTimerID = null;																												// This Variable is Timer ID

function doUploadFile(form){
	var obj,val,ft,nft,ut;
	obj = form.inpFile;
	val = obj.value.trim().toLowerCase();
	
	if(val==""){
		alert("Please specify the file.");
		obj.focus();
		return;
	}
	
	ft = form.inpFileType.value;
	nft = form.inpNotFileType.value;
	ut = form.inpUploadType.value;
	var ok = true;
	
	if(val.lastIndexOf('.')!=-1){
		var len = val.length;
		var ext = val.substring(val.lastIndexOf(".")+1,len)
		
		if(ft!=""){
			if(ft.indexOf(ext)==-1)ok = false;
		}else{
			if(nft.indexOf(ext)!=-1)ok = false;
		}
	}
	
	if(ok){
		if($('upFileClose')){
			var UniqueID = (new Date()).getTime() % 1000000000;
			$('PercentDone').style.width = "0%";
			form.action = "/upload/upload.asp?Type=" + ut + "&ProgressID=" + UniqueID;  // This the Program for Upload Data
			form.submit();
			ProgressBar(UniqueID);																											// Call the Upload Function
		}
	}else{
		alert("Can not upload the file.");
		obj.focus();
		return;
	}
}

function doUploadUA(form){
	var obj,val,ft,nft,ut;
	obj = form.inpFile;
	val = obj.value.trim().toLowerCase();
	
	if(val==""){
		alert("Please specify the file.");
		obj.focus();
		return;
	}
	
	ft = form.inpFileType.value;
	nft = form.inpNotFileType.value;
	ut = form.inpUploadType.value;
	var ok = true;
	
	if(val.lastIndexOf('.')!=-1){
		var len = val.length;
		var ext = val.substring(val.lastIndexOf(".")+1,len)
		
		if(ft!=""){
			if(ft.indexOf(ext)==-1)ok = false;
		}else{
			if(nft.indexOf(ext)!=-1)ok = false;
		}
	}
	if(ok){
		if($('divClose')){
			$('divClose').innerHTML = '<img src="/images/upload/btn_close_of.gif" width="16" height="16">';
			var UniqueID = (new Date()).getTime() % 1000000000;
			$('PercentDone').style.width = "0%";
			form.action = "/Dialog/upload.asp?Type=" + ut + "&ProgressID=" + UniqueID;  // This the Program for Upload Data
			form.submit();
			ProgressBar(UniqueID);																											// Call the Upload Function
		}
	}else{
		if($('divClose'))$('divClose').innerHTML = '<img src="/images/upload/btn_close_on.gif" width="16" height="16" onClick="hideDialog();">';
		alert("Can not upload the file.");
		obj.focus();
		return;
	}
}

function ProgressBar(UniqueID){
	var sURL = "/xml/ProgressXML.asp?ProgressID=" + UniqueID;														// Get Upload Data Address
	var oXMLDoc = getXmlhttp();
	oXMLDoc.onreadystatechange = function(){
		if(oXMLDoc.readyState == 4 && oXMLDoc.status==200)fnLoadComplete(UniqueID,oXMLDoc.responseXML);
	}
	oXMLDoc.open("GET",sURL,true);
	oXMLDoc.send(null);
}

function fnLoadComplete(UniqueID,xmlDoc){
	var ErrorMessage = xmlDoc.getElementsByTagName("ErrorMessage");
	if(ErrorMessage.length == 0){
		var readyState = xmlDoc.getElementsByTagName("ReadyState")[0].childNodes[0].nodeValue;
		
		if(readyState == "uninitialized"){
			iUpFileTimerID = setTimeout(function(){ProgressBar(UniqueID);}, 1000);
		}else if(readyState == "loading"){																																		// clear Timer when Upload done
			$('PercentDone').style.width = xmlDoc.getElementsByTagName("Percentage")[0].childNodes[0].nodeValue;			// Progress Bar Rate%
			iUpFileTimerID = setTimeout(function(){ProgressBar(UniqueID);}, 100);																	// Here Setting the display every 0.5s
		}else if(readyState == "loaded"){
			$('PercentDone').style.width = "100%";																																// setting the Progress Bar Rate%
			if (iUpFileTimerID != null)clearTimeout(iUpFileTimerID);
			iUpFileTimerID = null;
		}else{																																																	// Upload Done
			$('PercentDone').style.width = "100%";																																// setting the Progress Bar Rate%
			if (iUpFileTimerID != null)clearTimeout(iUpFileTimerID);
			iUpFileTimerID = null;
		}
	}else{
		alert(ErrorMessage[0].childNodes[0].nodeValue);
		SystemProcess.location.href = "about:blank";
	}
}

function doCancel(){
	SystemProcess.location.href = "about:blank";
	if($('PercentDone'))$('PercentDone').style.width = "0%";
	if(iUpFileTimerID != null)clearTimeout(iUpFileTimerID);
	iUpFileTimerID = null;
	hideDialog();
	//if($('divUpload'))$('divUpload').style.display = "none";
}

function doUpdatePi(form){								//-----------------------------------------------------ok
	var str = form.inpPassword.value.trim();
	if(str==""){
		alert("Please specify your password.");
		form.inpPassword.focus();
		return false;
	}
	
	if(str.length<6 || str.indexOf(' ')!=-1){
		alert("Your chosen password must at lease 6 characters and no spacing.");
		form.inpPassword.focus();
		return false;
	}
	
	if(form.inpFirstName.value.trim()==""){
		alert("Please specify your First Name.");
		form.inpFirstName.focus();
		return false;
	}
		
	if(form.inpLastName.value.trim()==""){
		alert("Please specify your Last Name.");
		form.inpLastName.focus();
		return false;
	}
	
	if(form.inpScreenName.value.trim()==""){
		alert("Please specify your Screen Name.");
		form.inpScreenName.focus();
		return false;
	}
	
	if(form.inpQualification.selectedIndex==0){
		alert("Please specify Minimum Education.");
		form.inpQualification.focus();
		return false;
	}
	
	if(form.inpJobFunction.selectedIndex==0){
		alert("Please specify the nature of your job function.");
		form.inpJobFunction.focus();
		return false;
	}
	
	if(form.inpJobTitle.value.trim()==""){
		alert("Please specify your job title.");
		form.inpJobTitle.focus();
		return false;
	}
	
	if(form.inpEmail.value.trim()==""){
		alert("Please specify your email address.");
		form.inpEmail.focus();
		return false;
	}
	
	if(!checkString('Email',form.inpEmail.value.trim())){
		alert("You have entered a wrong Email format.\nPlease enter again.");
		form.inpEmail.focus();
		return false;
	}
	
	if(form.inpBizCategories.selectedIndex==0){
		alert("Please specify the Business Category of your company.");
		form.inpBizCategories.focus();
		return false;
	}
	
	if(form.inpCountry.selectedIndex==0){
		alert("Please specify your Country of Residence.");
		form.inpCountry.focus();
		return false;
	}
	
	if(form.inpState.value.trim()==""){
		alert("Please specify the State or Province you reside in.");
		form.inpState.focus();
		return false;
	}
	
	if(form.inpCity.value.trim()==""){
		alert("Please specify Town or City of address entered.");
		form.inpCity.focus();
		return false;
	}
	
	if(form.inpAddress.value.trim()==""){
		alert("Please specify your Address.");
		form.inpAddress.focus();
		return false;
	}
	
	if(form.inpZip.value.trim()==""){
		alert("Please specify Zip or Postal Code for your place of residence.");
		form.inpZip.focus();
		return false;
	}
	
	var obj;
	//check Tel country code
	obj = form.inpTelCCode;
	if(obj.value.trim()==""){
		alert("Please specify Country Code of telephone number you have indicated.");
		obj.focus();
		return false;
	}
	if(!checkString('Num',obj.value.trim())){
		alert("Please indicate a numeric value for the Country Code of your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel Area code
	obj = form.inpTelACode;
	if(obj.value.trim()!=""&&!checkString('Num',obj.value.trim())){
		alert("Please indicate a numeric value for the Area Code of your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel number
	obj = form.inpTelNo;
	if(obj.value.trim()==""){
		alert("Please specify Telephone Number.");
		obj.focus();
		return false;
	}
	if(!checkString('Int',obj.value.trim())){
		alert("Please indicate a numeric value for your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel Extension code
	obj = form.inpTelEXT;
	if(obj.value.trim()!=""&&!checkString('Int',obj.value.trim())){
		alert("Please indicate a numeric value for the Extension of your telephone number.");
		obj.focus();
		return false;
	}
	
	var b_C = b_A = b_N = false;

	obj = form.inpFaxCCode;
	if(obj.value.trim()!=""){
		b_C = true;
		if(!checkString('Num',obj.value.trim())){
			alert("Please indicate a numeric value for the Country Code of your fax number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpFaxACode;
	if(obj.value.trim()!=""){
		b_A = true;
		if(!checkString('Num',obj.value.trim())){
			alert("Please indicate a numeric value for the Area Code of your fax number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpFaxNo;
	if(obj.value.trim()!=""){
		b_N = true;
		if(!checkString('Int',obj.value.trim())){
			alert("Please indicate a numeric value for your fax number.");
			obj.focus();
			return false;
		}
	}
	
	if((b_C||b_A||b_N)&&!(b_C&&b_N)){
		alert("Please complete your fax number.");
		form.inpFaxCCode.focus();
		return false;
	}
	
	b_C = b_A = b_N = false;
	
	obj = form.inpMobileCCode;
	if(obj.value.trim()!=""){
		b_C = true;
		if(!checkString('Num',obj.value.trim())){
			alert("Please indicate a numeric value for the Country Code of your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpMobileACode;
	if(obj.value.trim()!=""){
		b_A = true;
		if(!checkString('Num',obj.value.trim())){
			alert("Please indicate a numeric value for the Area Code of your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpMobileNo;
	if(obj.value.trim()!=""){
		b_N = true;
		if(!checkString('Int',obj.value.trim())){
			alert("Please indicate a numeric value for your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	if((b_C||b_A||b_N)&&!(b_C&&b_N)){
		alert("Please complete your mobile number.");
		form.inpMobileCCode.focus();
		return false;
	}
	
	return true;
}

function doUpdateCi(form){
	if(form.inpCOM_Name.value.trim()==""){
		setFocus(0);
		alert("Please specify Company Name.");
		form.inpCOM_Name.focus();
		return false;
	}
	
	if(form.inpBTID.selectedIndex==0){
		setFocus(0);
		alert("Please specify Business Type.");
		form.inpBTID.focus();
		return false;
	}
	
	if(form.inpBCID.selectedIndex==0){
		setFocus(0);
		alert("Please specify Business Category.");
		form.inpBCID.focus();
		return false;
	}
	
	if(form.inpCountry.selectedIndex==0){
		setFocus(0);
		alert("Please specify Country.");
		form.inpCountry.focus();
		return false;
	}
	
	if(form.inpCity.value.trim()==""){
		setFocus(0);
		alert("Please specify City.");
		form.inpCity.focus();
		return false;
	}
	
	if(form.inpAddress.value.trim()==""){
		setFocus(0);
		alert("Please specify Address.");
		form.inpAddress.focus();
		return false;
	}
	
	if(form.inpZip.value.trim()==""){
		setFocus(0);
		alert("Please specify Zip or Postal.");
		form.inpZip.focus();
		return false;
	}
	
	if(form.inpURLHeader.value.trim()!=""){
		if(!checkString('Domain',form.inpURLHeader.value.trim())){
			setFocus(0);
			alert("You have entered a wrong Biz Website format.\nPlease enter again.");
			form.inpURLHeader.focus();
			return false;
		}
	}
	
	if(form.inpWebSite.value.trim().toLowerCase()!=""){
		if(!checkString('URL',form.inpWebSite.value.trim())){
			setFocus(0);
			alert("You have entered a wrong Website format.\nPlease enter again.");
			form.inpWebSite.focus();
			return false;
		}
	}
	
	var i;
	var bMEM = false;
	for(i=0;i<form.inpMEM.length;i++){
		if(form.inpMEM[i].checked){
			bMEM = true;
			break;
		}
	}
	if(!bMEM){
		setFocus(0);
		alert("Please select at lease one Main Export Markets.");
		form.inpMEM[0].focus();
		return false;
	}
	
	if(form.inpCateSelected.length==0){
		setFocus(0);
		alert("Please select at lease one Company Product Categories .");
		form.inpCate.focus();
		return false;
	}else{
		for(i=0;i<form.inpCateSelected.length;i++){
			form.inpCateSelected.options[i].selected = true;
		}
	}
	
	if(form.inpFirstName.value.trim()==""){
		setFocus(1);
		alert("Please specify First Name.");
		form.inpFirstName.focus();
		return false;
	}
	
	if(form.inpLastName.value.trim()==""){
		setFocus(1);
		alert("Please specify Last Name.");
		form.inpLastName.focus();
		return false;
	}
	
	if(form.inpGender.selectedIndex==0){
		setFocus(1);
		alert("Please specify Gender.");
		form.inpGender.focus();
		return false;
	}
	
	var obj;
	//check Tel country code
	obj = form.inpTelCCode;
	if(obj.value.trim()==""){
		setFocus(1);
		alert("Please specify Country Code of telephone number you have indicated.");
		obj.focus();
		return false;
	}
	if(!checkString('Num',obj.value.trim())){
		setFocus(1);
		alert("Please indicate a numeric value for the Country Code of your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel Area code
	obj = form.inpTelACode;
	if(obj.value.trim()!=""&&!checkString('Num',obj.value.trim())){
		setFocus(1);
		alert("Please indicate a numeric value for the Area Code of your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel number
	obj = form.inpTelNo;
	if(obj.value.trim()==""){
		setFocus(1);
		alert("Please specify Telephone Number.");
		obj.focus();
		return false;
	}
	if(!checkString('Int',obj.value.trim())){
		setFocus(1);
		alert("Please indicate a numeric value for your telephone number.");
		obj.focus();
		return false;
	}
	
	//check Tel Extension code
	obj = form.inpTelEXT;
	if(obj.value.trim()!=""&&!checkString('Int',obj.value.trim())){
		setFocus(1);
		alert("Please indicate a numeric value for the Extension of your telephone number.");
		obj.focus();
		return false;
	}
	
	var b_C = b_A = b_N = false;

	obj = form.inpFaxCCode;
	if(obj.value.trim()!=""){
		b_C = true;
		if(!checkString('Num',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for the Country Code of your fax number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpFaxACode;
	if(obj.value.trim()!=""){
		b_A = true;
		if(!checkString('Num',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for the Area Code of your fax number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpFaxNo;
	if(obj.value.trim()!=""){
		b_N = true;
		if(!checkString('Int',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for your fax number.");
			obj.focus();
			return false;
		}
	}
	
	if((b_C||b_A||b_N)&&!(b_C&&b_N)){
		setFocus(1);
		alert("Please complete your fax number.");
		form.inpFaxCCode.focus();
		return false;
	}
	
	b_C = b_A = b_N = false;
	
	obj = form.inpMobileCCode;
	if(obj.value.trim()!=""){
		b_C = true;
		if(!checkString('Num',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for the Country Code of your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpMobileACode;
	if(obj.value.trim()!=""){
		b_A = true;
		if(!checkString('Num',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for the Area Code of your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpMobileNo;
	if(obj.value.trim()!=""){
		b_N = true;
		if(!checkString('Int',obj.value.trim())){
			setFocus(1);
			alert("Please indicate a numeric value for your mobile number.");
			obj.focus();
			return false;
		}
	}
	
	if((b_C||b_A||b_N)&&!(b_C&&b_N)){
		setFocus(1);
		alert("Please complete your mobile number.");
		form.inpMobileCCode.focus();
		return false;
	}
	
	return true;
}

function doUpdateNm(form){
	form.action = "?update";
	if(form.inpReceivers.value.trim()==""){
		alert("Please specify at least one receiver.");
		form.inpReceivers.focus();
		return false;
	}
	
	if(form.inpSubject.value.trim()==""){
		alert("Please specify the message subject.");
		form.inpSubject.focus();
		return false;
	}
	
	if($('divGuestFrom')){
		if($('divGuestFrom').style.display!="none"){
			if(form.inpSenderName.value.trim()==""){
				alert("Please specify you name.");
				form.inpSenderName.focus();
				return false;
			}
			if(form.inpSenderEmail.value.trim()==""){
				alert("Please specify you email address.");
				form.inpSenderEmail.focus();
				return false;
			}
			if(!checkString('Email',form.inpSenderEmail.value.trim())){
				alert("You have entered a wrong email format.\nPlease enter again.");
				form.inpSenderEmail.focus();
				return false;
			}
		}
	}
	
	if(form.inpValidateCode.value.trim()==""){
		alert("Please enter verification code shown.");
		form.inpValidateCode.focus();
		return false;
	}
	
	if(!checkString('Int',form.inpValidateCode.value.trim())){
		alert("Please enter valid verification code shown.");
		form.inpValidateCode.focus();
		return false;
	}
	
	var obj = FCKeditorAPI.GetInstance("inpMessageContents");
	var str = obj.GetXHTML();
	str = str.replace(/((<p>)|(<\/p>)|(\&nbsp\;)|(\&lt\;p\&gt\;)|(\&lt\;\/p\&gt\;)|(\s))/gi,"");
	if(str==""){
		alert("Please input the content.");
		obj.Focus();
		return false;
	}

	return true;
}

function saveDrafts(form){
	if(form.inpReceivers.value.trim()==""){
		alert("Please specify at least one receiver.");
		form.inpReceivers.focus();
		return false;
	}
	
	if(form.inpSubject.value.trim()==""){
		alert("Please specify the message subject.");
		form.inpSubject.focus();
		return false;
	}
	
	if(form.inpValidateCode.value.trim()==""){
		alert("Please enter verification code shown.");
		form.inpValidateCode.focus();
		return false;
	}
	
	if(!checkString('Int',form.inpValidateCode.value.trim())){
		alert("Please enter valid verification code shown.");
		form.inpValidateCode.focus();
		return false;
	}
	
	var obj = FCKeditorAPI.GetInstance("inpMessageContents");
	var str = obj.GetXHTML();
	str = str.replace(/((<p>)|(<\/p>)|(\&nbsp\;)|(\&lt\;p\&gt\;)|(\&lt\;\/p\&gt\;)|(\s))/gi,"");
	if(str==""){
		alert("Please input the content.");
		obj.Focus();
		return false;
	}
	
	form.action = "?drafts";
	form.submit();
}

function doSend(dialog,page,id){
	var form = document.forms["FormSystem"];
	form.id.value = id;
	form.page.value = page;
	form.action = '/BizCentre/doSend.asp';
	form.submit();
}

function doMoveDraft(obj,dialog,page,id){
	var form = document.forms["FormSystem"];
	form.id.value = id;
	form.page.value = page;
	form.action = '/BizCentre/doMoveDraft.asp';
	form.submit();
}

function blinkOn(id){
	var div = $(id);
	if(div){
		var cc = div.className;
		var nc;
		if(cc=="ny"){
			nc = "ny_blink";
		}else if(cc=="ny_blink"){
			nc = "ny";
		}else if(cc=="hy"){
			nc = "hy_blink";
		}else{
			nc = "hy";
		}
		div.className = nc;
		iTimerID = window.setTimeout(function (){blinkOn(id);},500);
	}
}

function blinkOf(id){
	if(iTimerID != null)clearTimeout(iTimerID);
	var div = $(id);
	if(div){
		var cc = div.className;
		var nc;
		if(cc=="ny_blink"){
			nc = "ny";
		}else if(cc=="hy_blink"){
			nc = "hy";
		}else{
			nc = cc;
		}
		div.className = nc;
	}
}

function doUpdateNp(form){
	if(form.inpProductName.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Product Name.");
		form.inpProductName.focus();
		return false;
	}
	
	if(form.inpCountry.selectedIndex==0){
		setNpFocus(0);
		alert("Please specify the Product Origin.");
		form.inpCountry.focus();
		return false;
	}
	
	if(form.inpPackaging.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Unit Size.");
		form.inpPackaging.focus();
		return false;
	}else if(!checkString('Price',form.inpPackaging.value.trim())){
		setNpFocus(0);
		alert("Please indicate a numeric value for Unit Size.");
		form.inpPackaging.focus();
		return false;
	}else if(form.inpPackaging.value.trim()==0){
		setNpFocus(0);
		alert("Please indicate a numeric value for Unit Size over zero.");
		form.inpPackaging.focus();
		return false;
	}
	
	if(form.inpUnit.selectedIndex==0){
		setNpFocus(0);
		alert("Please specify the Unit Size.");
		form.inpUnit.focus();
		return false;
	}
	
	if(form.inpPackageType.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Packaging Type.");
		form.inpPackageType.focus();
		return false;
	}
	
	if(form.inpSCID.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Product Category.");
		blinkOn('divSC');
		return false;
	}
	
	if(form.inpPSID.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Product Sector.");
		blinkOn('divPS');
		return false;
	}
	
	if(form.inpKeyword.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Product Keyword.");
		form.inpKeyword.focus();
		return false;
	}
	
	if(form.inpBriefIntro.value.trim()==""){
		setNpFocus(0);
		alert("Please specify the Brief Introduction.");
		form.inpBriefIntro.focus();
		return false;
	}
	
	if(form.inpHyperLink.value.trim().toLowerCase()!=""){
		if(!checkString('URL',form.inpHyperLink.value.trim())){
			setNpFocus(0);
			alert("You have entered a wrong Website format.\nPlease enter again.");
			form.inpHyperLink.focus();
			return false;
		}
	}
	
	return true;
}

function doUpdateNb(form){
	if(form.inpSubject.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Buying Lead Subject.");
		form.inpSubject.focus();
		return false;
	}
	
	if(form.inpSCID.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Product Category.");
		blinkOn('divSC');
		return false;
	}
	
	if(form.inpPSID.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Product Sector.");
		blinkOn('divPS');
		return false;
	}
	
	if(form.inpKeyword.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Product Keyword.");
		form.inpKeyword.focus();
		return false;
	}
	
	if(form.inpBriefIntro.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Brief Introduction.");
		form.inpBriefIntro.focus();
		return false;
	}

	var obj;
	var b_W = b_S = b_B = b_E = false;
	
	obj = form.inpMinOrder;
	if(obj.value.trim()!=""){
		b_W = true;
		if(!checkString('Price',obj.value.trim())){
			setNbFocus(0);
			alert("Please indicate a numeric value for Minimum Order Quantity.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNbFocus(0);
			alert("Please indicate a numeric value for Minimum Order Quantity over zero.");
			obj.focus();
			return false;
		}
	}
	
	if(form.inpOrderUnit.selectedIndex>0)b_S = true;
	
	if((b_W||b_S)&&!(b_W&&b_S)){
		setNbFocus(0);
		alert("Please complete Minimum Order Quantity.");
		obj.focus();
		return false;
	}

	b_S = false;
	if(form.inpCurrency.selectedIndex>0)b_S = true;
	
	obj = form.inpPriceFrom;
	if(obj.value.trim()!=""){
		b_B = true;
		if(!checkString('Price',obj.value.trim())){
			setNbFocus(0);
			alert("Please indicate a numeric value for Price Range.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNbFocus(0);
			alert("Please indicate a numeric value for Price Range over zero.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpPriceTo;
	if(obj.value.trim()!=""){
		b_E = true;
		if(!checkString('Price',obj.value.trim())){
			setNbFocus(0);
			alert("Please indicate a numeric value for Price Range.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNbFocus(0);
			alert("Please indicate a numeric value for Price Range over zero.");
			obj.focus();
			return false;
		}
	}
	
	if((b_S||b_B||b_E)&&!(b_S&&b_B&&b_E)){
		setNbFocus(0);
		alert("Please complete Price Range.");
		obj.focus();
		return false;
	}
	
	if(form.inpExpiryDateCal.value.trim()==""){
		setNbFocus(0);
		alert("Please specify the Expiry Date.");
		form.selSetDate.focus();
		return false;
	}
	
	return true;
}

function doUpdateNs(form){
	if(form.inpSubject.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Selling Lead Subject.");
		form.inpSubject.focus();
		return false;
	}
	
	if(form.inpCountry.selectedIndex==0){
		setNsFocus(0);
		alert("Please specify the Product Origin.");
		form.inpCountry.focus();
		return false;
	}
	
	if(form.inpPackaging.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Unit Size.");
		form.inpPackaging.focus();
		return false;
	}else if(!checkString('Price',form.inpPackaging.value.trim())){
		setNsFocus(0);
		alert("Please indicate a numeric value for Unit Size.");
		form.inpPackaging.focus();
		return false;
	}else if(form.inpPackaging.value.trim()==0){
		setNsFocus(0);
		alert("Please indicate a numeric value for Unit Size over zero.");
		form.inpPackaging.focus();
		return false;
	}
	
	if(form.inpUnit.selectedIndex==0){
		setNsFocus(0);
		alert("Please specify the Unit Size.");
		form.inpUnit.focus();
		return false;
	}
	
	if(form.inpPackageType.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Packaging Type.");
		form.inpPackageType.focus();
		return false;
	}
	
	if(form.inpKeyword.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Product Keyword.");
		form.inpKeyword.focus();
		return false;
	}
	
	if(form.inpBriefIntro.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Brief Introduction.");
		form.inpBriefIntro.focus();
		return false;
	}
	
	var obj;
	var b_W = b_S = b_B = b_E = false;
	
	obj = form.inpStockQty;
	if(obj.value.trim()!=""){
		b_W = true;
		if(!checkString('Price',obj.value.trim())){
			setNsFocus(0);
			alert("Please indicate a numeric value for Stock Quantity.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNsFocus(0);
			alert("Please indicate a numeric value for Stock Quantity over zero.");
			obj.focus();
			return false;
		}
	}
	
	if(form.inpStockUnit.selectedIndex>0)b_S = true;
	
	if((b_W||b_S)&&!(b_W&&b_S)){
		setNsFocus(0);
		alert("Please complete Stock Quantity.");
		obj.focus();
		return false;
	}
	
	b_W = b_S = b_B = b_E = false;
	obj = form.inpMinOrder;
	if(obj.value.trim()!=""){
		b_W = true;
		if(!checkString('Price',obj.value.trim())){
			setNsFocus(0);
			alert("Please indicate a numeric value for Minimum Order Quantity.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNsFocus(0);
			alert("Please indicate a numeric value for Minimum Order Quantity over zero.");
			obj.focus();
			return false;
		}
	}
	
	if(form.inpOrderUnit.selectedIndex>0)b_S = true;
	
	if((b_W||b_S)&&!(b_W&&b_S)){
		setNsFocus(0);
		alert("Please complete Minimum Order Quantity.");
		obj.focus();
		return false;
	}

	b_S = false;
	if(form.inpCurrency.selectedIndex>0)b_S = true;
	
	obj = form.inpPriceFrom;
	if(obj.value.trim()!=""){
		b_B = true;
		if(!checkString('Price',obj.value.trim())){
			setNsFocus(0);
			alert("Please indicate a numeric value for Price Range.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNsFocus(0);
			alert("Please indicate a numeric value for Price Range over zero.");
			obj.focus();
			return false;
		}
	}
	
	obj = form.inpPriceTo;
	if(obj.value.trim()!=""){
		b_E = true;
		if(!checkString('Price',obj.value.trim())){
			setNsFocus(0);
			alert("Please indicate a numeric value for Price Range.");
			obj.focus();
			return false;
		}else if(obj.value.trim()==0){
			setNsFocus(0);
			alert("Please indicate a numeric value for Price Range over zero.");
			obj.focus();
			return false;
		}
	}
	
	if((b_S||b_B||b_E)&&!(b_S&&b_B&&b_E)){
		setNsFocus(0);
		alert("Please complete Price Range.");
		obj.focus();
		return false;
	}
	
	if(form.inpExpiryDateCal.value.trim()==""){
		setNsFocus(0);
		alert("Please specify the Expiry Date.");
		form.selSetDate.focus();
		return false;
	}
	
	return true;
}
//---------------------------------- /Company Info ------------------------------------
function listPS(obj,formid,id){
	blinkOf('divSC');
	var form = document.forms[formid];
	var pid = form.inpSCID.value;				//Previous Set
	if(pid!=id){								//Clear form.inpPSID.value and options in $('divPS')
		form.inpSCID.value = id;
		form.inpPSID.value = "";
		
		var sDiv = $('divSC');
		var tDiv = $('divPS');
		var psObj = $('prSector');
		var opts = psObj.getElementsByTagName("option");
		var len = 0;
		var sHTML = '';
		var i,sc,ps,_name;
		
		var sDivEle = sDiv.getElementsByTagName("div");
		for(i=0;i<sDivEle.length;i++){
			sDivEle[i].className = '';
		}
		obj.className = "select";
		
		for(i=0;i<opts.length;i++){
			sc = opts[i].getAttribute("sc");
			ps = opts[i].getAttribute("value");
			_name = opts[i].childNodes[0].nodeValue;
			if(sc==id){
				len ++;
				sHTML += '<div onclick="setPS(this,\'' + formid + '\',' + ps + ');" ps="' + ps + '">' + _name + '</div>';
			}
		}
		if(len>4){
			tDiv.className = 'hy';
		}else{
			tDiv.className = 'ny';
		}
		tDiv.innerHTML = sHTML;
	}
}

function setPS(obj,formid,id){
	blinkOf('divPS');
	var form = document.forms[formid];
	var pid = form.inpPSID.value;				//Previous Set
	if(pid!=id){								//set form.inpPSID.value = id
		form.inpPSID.value = id;
		var sDiv = $('divPS');
		var sDivEle = sDiv.getElementsByTagName("div");
		for(i=0;i<sDivEle.length;i++){
			sDivEle[i].className = '';
		}
		obj.className = "select";
	}
}

function summCount(num,obj,show){
	var summ = obj.value.trim().replace(/[^\x00-\xff]/g,"aa");
	if(summ.length <= num){
		if(show!='')$(show).innerHTML = num - summ.length;
	} else {
		obj.value = obj.value.trim().toString().substr(0,num);
	}
}

function setDate(form,idx){
	if(idx>0){
		url = '/xml/getDate.asp?idx=' + idx;
		var xmlHttp = getXmlhttp();
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status==200){
				var row = xmlHttp.responseXML.getElementsByTagName("Row");
				var _date = row[0].childNodes[0].nodeValue;
				if(_date!="Error"){
					form.inpExpiryDate.value = _date;
					form.inpExpiryDateCal.value = _date;
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function autoFill(form,sel){
	var idx = sel.selectedIndex;
	if(idx>0){
		var id = sel[idx].value;
		url = '/xml/get_PR_XML.asp?id=' + id;
		var xmlHttp = getXmlhttp();
		xmlHttp.onreadystatechange = function(){
			if(xmlHttp.readyState == 4 && xmlHttp.status==200){
				var obj,icon,i;																			//Form Ele
				var xmlDoc = xmlHttp.responseXML;
				var Valid = xmlDoc.getElementsByTagName("Valid")[0].childNodes[0].nodeValue;
				if(Valid=="True"){
					var COMFolder = xmlDoc.getElementsByTagName("COMFolder")[0].childNodes[0].nodeValue;
					var SCID = xmlDoc.getElementsByTagName("SCID")[0].childNodes[0].nodeValue;
					var PSID = xmlDoc.getElementsByTagName("PSID")[0].childNodes[0].nodeValue;
					var PR_Name = xmlDoc.getElementsByTagName("PR_Name")[0].childNodes[0].nodeValue;
					var PR_Image = xmlDoc.getElementsByTagName("PR_Image")[0].childNodes[0].nodeValue;
					var PR_File = xmlDoc.getElementsByTagName("PR_File")[0].childNodes[0].nodeValue;
					var sAttach = xmlDoc.getElementsByTagName("sAttach")[0].childNodes[0].nodeValue;
					var PR_Keyword = xmlDoc.getElementsByTagName("PR_Keyword")[0].childNodes[0].nodeValue;
					var PR_Country = xmlDoc.getElementsByTagName("PR_Country")[0].childNodes[0].nodeValue;
					var PR_Package = xmlDoc.getElementsByTagName("PR_Package")[0].childNodes[0].nodeValue;
					var PR_PackageUnit = xmlDoc.getElementsByTagName("PR_PackageUnit")[0].childNodes[0].nodeValue;
					var PR_PackageType = xmlDoc.getElementsByTagName("PR_PackageType")[0].childNodes[0].nodeValue;
					var PR_Cert = xmlDoc.getElementsByTagName("PR_Cert")[0].childNodes[0].nodeValue;
					var PR_BriefIntro = xmlDoc.getElementsByTagName("PR_BriefIntro")[0].childNodes[0].nodeValue;
					var PR_Price = xmlDoc.getElementsByTagName("PR_Price")[0].childNodes[0].nodeValue;
					
					obj = form.inpProductName;
					if(obj)obj.value = PR_Name;
					
					obj = form.inpSubject;
					if(obj)obj.value = PR_Name;
					
					if(PR_Image!="NA"){
						obj = form.inpRelatedPhoto;
						if(obj)obj.value = PR_Image;
						
						form.inpPhotoF.value = 'library';
						if($('imgRelatedphoto'))$('imgRelatedphoto').src = '/media/products/' + COMFolder + '/' + PR_Image;
					}
					
					if(PR_File!="NA"){
						obj = form.inpAttachFile;
						if(obj)obj.value = PR_File;
						
						form.inpAttachF.value = 'library';
						if($('divAttach'))$('divAttach').innerHTML = sAttach;
					}
					
					if(PR_Keyword!="NA"){
						obj = form.inpKeyword;
						obj.value = PR_Keyword;
						summCount(255,obj,'countKeyword');
					}
					
					obj = form.inpCountry;
					for(i=0;i<obj.length;i++){
						if(obj[i].value==PR_Country){
							obj[i].selected = true;
							break;
						}
					}
					
					form.inpPackaging.value = PR_Package;
					
					obj = form.inpUnit;
					for(i=0;i<obj.length;i++){
						if(obj[i].value==PR_PackageUnit){
							obj[i].selected = true;
							break;
						}
					}
					
					form.inpPackageType.value = PR_PackageType;
					
					if(PR_Cert!="NA"){
						obj = form.inpCertification;
						obj.value = PR_Cert;
						summCount(512,obj,'countCert');
					}
					
					if(PR_BriefIntro!="NA"){
						obj = form.inpBriefIntro;
						obj.value = PR_BriefIntro;
						summCount(255,obj,'countBriefIntro');
					}
					
					if(PR_Price!="NA"){
						obj = form.inpListPrice;
						if(obj)obj.value = PR_Price;
					}
					
					var div = $('divSC').getElementsByTagName("div");
					for(i=0;i<div.length;i++){
						if(div[i].getAttribute("sc")==SCID){
							listPS(div[i],form.name,SCID);
							break;
						}
					}
					
					div = $('divPS').getElementsByTagName("div");
					for(i=0;i<div.length;i++){
						if(div[i].getAttribute("ps")==PSID){
							setPS(div[i],form.name,PSID);
							break;
						}
					}
					
				}else{
					alert("Product Data Error.");
					return;
				}
			}
		}
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
}

function doUpdateRs(form){
	var obj;
	
	if(form.inpFirstName.value.trim()==""){
		alert("Please specify First Name.");
		form.inpFirstName.focus();
		return false;
	}
	
	if(form.inpLastName.value.trim()==""){
		alert("Please specify Last Name.");
		form.inpLastName.focus();
		return false;
	}
	
	if(form.chkPR.checked){
		obj = form.inpPrKeyword;
		if(obj.value.trim()==""){
			alert("Please specify Product Keyword.");
			obj.focus();
			return false;
		}
		
		if(!CheckKeyword(obj.value)){
			alert("You have entered a wrong Product Keyword format.\nPlease correct it first.");
			obj.focus();
			return false;
		}
	}
	
	if(form.chkCO.checked){
		obj = form.inpCoKeyword;
		if(obj.value.trim()==""){
			alert("Please specify Company Keyword.");
			obj.focus();
			return false;
		}
		
		if(!CheckKeyword(obj.value)){
			alert("You have entered a wrong Company Keyword format.\nPlease correct it first.");
			obj.focus();
			return false;
		}
	}
	
	if(form.chkBO.checked){
		obj = form.inpBoKeyword;
		if(obj.value.trim()==""){
			alert("Please specify Buying Offer Keyword.");
			obj.focus();
			return false;
		}
		
		if(!CheckKeyword(obj.value)){
			alert("You have entered a wrong Buying Offer Keyword format.\nPlease correct it first.");
			obj.focus();
			return false;
		}
	}
	
	if(form.chkSO.checked){
		obj = form.inpSoKeyword;
		if(obj.value.trim()==""){
			alert("Please specify Selling Offer Keyword.");
			obj.focus();
			return false;
		}
		
		if(!CheckKeyword(obj.value)){
			alert("You have entered a wrong Selling Offer Keyword format.\nPlease correct it first.");
			obj.focus();
			return false;
		}
	}
	
	return true;
}

function showAB(obj,tar,ky,page){
	var div,pos,sHTML,_width,_height,_left,url;
	if(iTimerID != null)clearTimeout(iTimerID);
	if(!$('divPopupAB')){
		div = document.createElement('div');
		div.id = 'divPopupAB';
		div.style.display = 'none';
		document.body.appendChild(div);
	}
	div = $('divPopupAB');
	if(div.style.display=="none"){
		pos = getObjPos(obj);
		
		_width = 450;
		_height = 269;
		_left = pos.x;
		
		if((_left+_width)>=document.body.clientWidth)_left = document.body.clientWidth-_width-5;
		div.style.position = 'absolute';
		
		div.style.width = _width + 'px';
		div.style.height = _height + 'px';
		
		div.style.left = _left + 'px';
		div.style.top = pos.y + 'px';
	}
	
	sHTML  = '<div class="Header" onmouseover="doDrag(this,\'divPopupAB\');">';
	sHTML += '  <div id="abHeader">My Address Book</div>';
	sHTML += '  <div id="abClose"><img src="/images/upload/btn_close_on.gif" width="16" height="16" onClick="doHideDiv(\'divPopupAB\');"></div>';
	sHTML += '</div>';
	sHTML += '<div class="abTitle">';
	sHTML += '  <div class="txtname">Name</div>';
	sHTML += '  <div class="email">eFeedLink ID/Email Address</div>';
	sHTML += '</div>';
	sHTML += '<div id="divAB_Box">';
	sHTML += '  <div class="loading"><img src="/images/loading_32x32.gif" width="32" height="32"><br>Loading...</div>';
	sHTML += '</div>';

	sHTML += '<div id="div_AB_Navi">';
	sHTML += '  <div class="divky"><input type="text" id="search_AB_Keyword" maxlength="50" value="' + ky + '"></div>';
	sHTML += '  <div class="btnky"><img src="/images/btn_go_21x17_of.gif" width="21" height="17" onmousemove="btnOver(this);" onmouseout="btnOut(this);" onClick="searchAB(\'' + tar + '\');"></div>';
	sHTML += '  <div id="AB_Page_Navi"><img src="/images/msg/btn_first_disabled.gif" width="42" height="15"><img src="/images/msg/btn_previous_disabled.gif" width="59" height="15"><img src="/images/msg/btn_next_disabled.gif" width="41" height="15"><img src="/images/msg/btn_last_disabled.gif" width="41" height="15"></div>';
	sHTML += '</div>';
	div.innerHTML = sHTML;
	div.style.display = "block";
	doAB(tar,ky,page);
}

function doAB(tar,ky,page){
	$('divAB_Box').innerHTML = '<div class="loading"><img src="/images/loading_32x32.gif" width="32" height="32"><br>Loading...</div>';
	ky = escape(ky.trim());
	url = '/xml/get_AB_XML.asp?ky=' + ky + '&page=' + page;
	var xmlHttp = getXmlhttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status==200){
			var xmlDoc = xmlHttp.responseXML;
			var Valid = xmlDoc.getElementsByTagName("Valid")[0].childNodes[0].nodeValue;
			var sList = '<div class="loading">Load XML Error!</div>';							//Load XML Error
			if(Valid=="True"){
				var row = xmlDoc.getElementsByTagName("Row");
				var len = row.length;
				sList = '<div class="loading">No matches were found.</div>';
				if(len>0){
					var sNavi = xmlDoc.getElementsByTagName("Navi")[0].childNodes[0].nodeValue;
					sList = '';
					var _name,_email;
					for(var i=0;i<len;i++){
						_name = row[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue;
						_email = row[i].getElementsByTagName("Email")[0].childNodes[0].nodeValue;
						sList += '<div class="abItemOf" onclick="addReceivers(this,\'' + tar + '\');" onmouseover="setCSS(this,\'abItemOn\');" onmouseout="setCSS(this,\'abItemOf\');">';
						sList += '  <div class="name">' + _name + '</div>';
						sList += '  <div class="email">' + _email + '</div>';
						sList += '</div>';
					}
					$('AB_Page_Navi').innerHTML = sNavi;
				}
			}
			$('divAB_Box').innerHTML = sList;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function searchAB(tar){
	var obj = $('search_AB_Keyword');
	var ky = obj.value.trim();
	if(ky==""){
		alert("Please enter a keyword for the search!");
		obj.focus();
		return;
	}else{
		doAB(tar,escape(ky),1);
	}
}

function addReceivers(obj,tar){
	var form = document.forms["FormMessage"];
	var objRec,sRE,sCC,sALL,pre,div,val;
	sRE = form.inpReceivers.value.trim();
	sCC = form.inpCC.value.trim();
	sALL = sRE + ';' + sCC;
	//alert(sALL);
	if(tar=="re"){
		objRec = form.inpReceivers;
	}else{
		objRec = form.inpCC;
	}
	pre = objRec.value.trim();
	div = obj.getElementsByTagName("div");
	val = div[0].innerHTML;
	if(pre==""){
		if(sALL.indexOf(val)==-1)objRec.value = val;
	}else{
		if(sALL.indexOf(val)==-1)objRec.value = pre + ';' + val;
	}
}

function stepMask(c){
	if($('divDialog')){
		var opacity = c * 5;
		$('div_layer_background').style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ',finishOpacity=100,style=0)';
		$('div_layer_background').style.opacity = opacity / 100;
		c++;
		if(c <= 10){
			setTimeout('stepMask(' + c + ')', 5);
		}else{
			$('div_layer_background').style.display = 'block';
			$('divDialog').style.display = 'block';
		}
	}
}

function createMask(b){																			//createDiv(obj){
	if(b){
		if($('div_layer_background')){
			var div = $('div_layer_background');
			div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=100,style=0)';
			div.style.opacity = 0;
		}else{
			div = document.createElement('div');
			div.id = 'div_layer_background';
			div.style.position = 'absolute';
			div.style.left = div.style.top = '0px';
			div.style.width = document.body.scrollWidth + 'px';
			div.style.height = document.body.scrollHeight + 'px';
			div.style.backgroundColor = '#000000';
			div.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0,finishOpacity=100,style=0)';
			div.style.opacity = 0;
			div.style.zIndex = 0;
			document.body.appendChild(div);
		}
		$('div_layer_background').style.display = 'block';
		setTimeout('stepMask(1)', 5);
	}else{
		return;
	}
}

function EFLDialog(obj,dialog,id,page){
	var url = "/Dialog/"
	var rand = (new Date()).getTime();
	var b_center = false;
	var b_mask = true;
	var DialogTitle,_width,_height;
	var sMargin = "margin:65px auto;"
	switch(dialog){
		case "AB":						//from address book
			//b_mask = false;
			//b_center = true;
			DialogTitle = 'Add New Address';
			if(id!="")DialogTitle = 'Edit Address Item';
			url += 'AB.asp?id=' + id + '&page=' + page + '&Rand=' + rand;
			_width = 450;
			_height = 232;
			break;
		case "addAB":					//from Website
		  DialogTitle = 'Add New Address';
			url += 'addAB.asp?id=' + id + '&Rand=' + rand;			//User UniqueID
			_width = 450;
			_height = 232;
		  break;
		case "CC":							//Append Contact Person
			b_mask = false;
			DialogTitle = 'My Address Book';
			url += 'ABL.asp?ky=' + id + '&page=' + page + '&Rand=' + rand;
			_width = 450;
			_height = 269;
			break;
		case "UA":							//Upload Attach
			b_mask = false;
			sMargin = "margin:25px auto;"
			DialogTitle = 'Upload Attach';
			url += 'UA.asp?Rand=' + rand;
			_width = 450;
			_height = 142;
			break;
		case "MI":							//Read Inbox Item Message
		case "MO":							//Read Outbox Item Message
		case "SI":							//Read Sent Item Message
		case "DI":							//Read Deleted Item Message
		case "MD":							//Read Drafts Item Message
			b_mask = true;
			b_center = true;
			sMargin = "margin:255px auto;"
			DialogTitle = 'Message Details';
			url += 'MD.asp?Dialog=' + dialog + '&id=' + id + '&page=' + page + '&Rand=' + rand;
			_width = 768;
			_height = 568;
			
			if(obj.parentNode.className == "divDiRow"){
				obj.parentNode.className = "divDiRow_R";
			}else if(obj.parentNode.className == "divDiRow_L"){
				obj.parentNode.className = "divDiRow_LR";
			}
			break;
		default:
			//Nothing ...
	}
	if($('div_layer_background')){
		if($('div_layer_background').style.display == "block")b_mask = false;
	}
	if(url=="/Dialog/"){
		return;
	}else{
		if(b_mask)createMask(b_mask);
		var div,pos,sHTML,_width,_height,_top,_left;
		if(iTimerID != null)clearTimeout(iTimerID);
		if(!$('divDialog')){
			div = document.createElement('div');
			div.id = 'divDialog';
			div.style.display = 'none';
			document.body.appendChild(div);
		}
		div = $('divDialog');
		if(div.style.display=="none"){
			div.style.position = 'absolute';
			div.style.width = _width + 'px';
			div.style.height = _height + 'px';
			if(b_center){
				var D = document.documentElement;
				var OffsetX = D.scrollLeft || window.pageXOffset;
				if(OffsetX==undefined)OffsetX = 0;
				if(D.clientWidth<_width){
					_left = 10 + OffsetX;
				}else{
					_left = (D.clientWidth-_width)/2 + OffsetX;
				}
				var OffsetY = D.scrollTop || window.pageYOffset;
				if(OffsetY==undefined)OffsetY = 0;
				if(D.clientHeight<_height){
					_top = 10 + OffsetY;
				}else{
					_top = (D.clientHeight-_height)/2 + OffsetY;
				}
				
				div.style.left = _left + 'px';
				div.style.top = _top + 'px';
			}else{
				pos = getObjPos(obj);
				_left = pos.x;
				_top = pos.y
				if((_left+_width)>=document.body.clientWidth)_left = document.body.clientWidth-_width-5;
				div.style.left = _left + 'px';
				div.style.top = _top + 'px';
			}
		}else{
			if(div.style.width.replace('px','')!=_width||div.style.height.replace('px','')!=_height){
				div.style.position = 'absolute';
				div.style.width = _width + 'px';
				div.style.height = _height + 'px';
				if(b_center){
					var D = document.documentElement;
					var OffsetX = D.scrollLeft || window.pageXOffset;
					if(OffsetX==undefined)OffsetX = 0;
					if(D.clientWidth<_width){
						_left = 10 + OffsetX;
					}else{
						_left = (D.clientWidth-_width)/2 + OffsetX;
					}
					var OffsetY = D.scrollTop || window.pageYOffset;
					if(OffsetY==undefined)OffsetY = 0;
					if(D.clientHeight<_height){
						_top = 10 + OffsetY;
					}else{
						_top = (D.clientHeight-_height)/2 + OffsetY;
					}
					
					div.style.left = _left + 'px';
					div.style.top = _top + 'px';
				}else{
					pos = getObjPos(obj);
					_left = pos.x;
					_top = pos.y;
					if((_left+_width)>=document.body.clientWidth)_left = document.body.clientWidth-_width-5;
					div.style.left = _left + 'px';
					div.style.top = _top + 'px';
				}
			}
		}
		
		var w = _width - 16;
    var h = _height - 16;
    var b_w = _width - 18;
    var b_h = _height - 37;
		
		sHTML = '<div class="box" style="width:' + _width + 'px;height:' + _height + 'px;">';
		sHTML += '  <div class="luc"></div>';
		sHTML += '  <div class="ub" style="width:' + w + 'px;"></div>';
		sHTML += '  <div class="ruc"></div>';
		sHTML += '  <div class="lb" style="height:' + h + 'px;"></div>';
		sHTML += '  <div style="float:left;width:' + w + 'px; height:' + h + 'px;">';
		sHTML += '    <div class="Header" onmouseover="doDrag(this,\'divDialog\');">';
		sHTML += '      <div class="DialogTitle">' + DialogTitle + '</div>';
		sHTML += '      <div id="divClose" class="Close"><img src="/images/upload/btn_close_on.gif" width="16" height="16" onClick="hideDialog();"></div>';
		sHTML += '    </div>';
		sHTML += '    <div id="DialogBody" style="width:' + b_w + 'px;height:' + b_h + 'px;">';
		sHTML += '      <div class="loading" style="' + sMargin + '"><img src="/images/loading_32x32.gif" width="32" height="32"><br>Loading...</div>';
		sHTML += '    </div>';
		sHTML += '  </div>';
		sHTML += '  <div class="rb" style="height:' + h + 'px;"></div>';
		sHTML += '  <div class="ldc"></div>';
		sHTML += '  <div class="db" style="width:' + w + 'px;"></div>';
		sHTML += '  <div class="rdc"></div>';
		sHTML += '</div>';
		
		div.innerHTML = sHTML;
		if(!b_mask)div.style.display = "block";
		loadFile(url);
	}
}

function hideDialog(){
	if(iTimerID != null)clearTimeout(iTimerID);
	if($('divDialog'))$('divDialog').style.display = 'none';
	if($('divUpload'))$('divUpload').style.display = "none";
	if($('div_layer_background'))$('div_layer_background').style.display = 'none';
}

function loadFile(url){
	var xmlHttp = getXmlhttp();
	xmlHttp.onreadystatechange = function(){
		if(xmlHttp.readyState == 4 && xmlHttp.status==200){
			$('DialogBody').innerHTML = xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function doUpdateAb(form){
	if(form.inpName.value.trim()==""){
		alert("Please specify the User Name.");
		form.inpName.focus();
		return false;
	}
	
	if(form.inpEmail.value.trim()==""){
		alert("Please specify the Email Address.");
		form.inpEmail.focus();
		return false;
	}
	
	var isEmail = form.realEmail.value.trim();
	
	if(isEmail=="True" && !(checkString('Email',form.inpEmail.value.trim()))){
		alert("You have entered a wrong Email format.\nPlease enter again.");
		form.inpEmail.focus();
		return false;
	}
	
	return true;
}