// #import app/webenaliint/webenaliint.js
/*
 * 必须依赖5v\app\webenaliint\webenaliint.js
 *
 */

function logger(theUrl){
	//如果有窗口关闭，这时间必须比窗口关闭的延迟要小
	if (theUrl == null)
		return;
	window.setTimeout(function () {
		new Image().src = theUrl;
	}, 10);
}

function doIfExploreIsNotSupport(){
	alert("Only Available to Microsoft Internet Explorer and FireFox 1.5 or above.");
}

function clientNotReadyAction(fn){
	if (!ATMAPI.isPluginReady()) {
		ATMAPI.installPlugin(fn);
	} else if(ATMAPI.isNeedUpdatePlugin()) {
		ATMAPI.updatePlugin(fn);
	} else {
		typeof fn === 'function' ? fn() : ATMAPI.downloadClient(fn);
	}
}

function getWebAtmUrl(from, receiverId, pid){
	var webAtmUrl = '', referUrl = document.URL;
	webAtmUrl = 'http://webatm.alibaba.com/start_web_atm.htm?enemberId='+ encodeURIComponent(receiverId)+'&pid='+pid+'&from='+from+'&refer='+referUrl.replace(/&/ig, "$");
	return webAtmUrl;
}

function doOpenWebIM(from, memberId, id){
	var win = open(getWebAtmUrl(from, memberId, id), Math.round(Math.random() * 24 * 100), 'height=665, width=800, toolbar= no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no,top=50,left=200');
	win.focus();
}

function OnlyCheckAlitalkInstalled(){
	return ATMAPI.getClientFlag();
}

function newCheckAlitalkInstalled(){
	return ATMAPI.getClientFlag();
}

function clickAlitalk(uid){
	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			sendMessageNotEn(uid);
		} else {
			clientNotReadyAction();
		}
	} else {
		doIfExploreIsNotSupport();
	}
}

//专门用于RFQ类型的inquery
function alitalkEncryptForRfq(memberId, from, id){
	var para = "", selfpara = "", win, focusProductParam = "";

	if(from !== fromRFQ && from !== fromQuotation){
	  return false;
	}
	focusProductParam = "&gid=" + id + "&id=" + memberId;

	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
			selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time" + timestamp.getTime();
			logger(selfpara);
			sendMessage(memberId, para);
		} else {
			if (OnLine == 1) {
				// start webATM
				doOpenWebIM(from, memberId, id);
			} else {
				clientNotReadyAction();
			}
		}
	} else {
		doOpenWebIM(from, memberId, id);
	}
}

//专门应用于后台的如scrm/myalibaba的。
function alitalkEncrypt(memberId, from, id){
	var para = "", selfpara = "", win, focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id + "&id=" + memberId;
	};

	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
			selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time" + timestamp.getTime();
			logger(selfpara);
			sendMessage(memberId, para);
		} else {
			if (OnLine == 1) {
				// start webATM
				doOpenWebIM(from, memberId, id);
			} else {
				clientNotReadyAction();
			}
		}
	} else {
		doOpenWebIM(from, memberId, id);
	}
}

//主要应用在提示用户安装或登陆TM
function alitalkInstallOrLogin(dlConfirm){
	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			ATMAPI.startATM("", "", "");
		} else {
			clientNotReadyAction();
		}
	} else {
		doIfExploreIsNotSupport();
	}
}

//可以发送发馈。
function alitalkEncryptFormyalibaba(memberid, from, id, displayName, messageType){
	var para = "", selfpara = "", focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id + "&id=" + memberid;
	}

	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
			selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time=" + timestamp.getTime();
			logger(selfpara);
			sendMessage(memberid, para);
		} else {
			//发送sendMessage.
			var url = "http://us.my.alibaba.com/mcweb/sendMessage.htm?";
			url += "selectedIds=" + id + "&selectedNames=" + escape(displayName) + "&messageType=" + messageType;
			window.open(url);
		}
	} else {
		doOpenWebIM(from, memberid, id);
	}
}

function sendMessage(memberId, paras){
	ATMAPI.sendClientMsg("", "", "enaliint", memberId, 1, "&encrypt=1" + paras);
}

function sendMessageNotEn(uid, paras){
	ATMAPI.sendClientMsg("", "", "enaliint", uid, 1, "&encrypt=1" + paras);
}

function alitalkFeedback(memberId, from, id){
	var para = "", focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id + "&id=" + memberId;
	}

	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK#from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
			sendMessageNotEn(memberId, para);
		} else {
			clientNotReadyAction();
		}
	} else {
		doOpenWebIM(from, memberId, id);
	}
}

function SetCookie(sName, sValue){
	var life = new Date();
	life.setTime(life.getTime() + 365 * 24 * 60 * 60 * 1000);
	document.cookie = sName + "=" + escape(sValue) + "; expires=" + life.toGMTString();
	;
}

function GetCookie(sName){
	var aCookie = document.cookie.split("; ");
	for (var i = 0; i < aCookie.length; i++) {

		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0])
			return unescape(aCrumb[1]);
	}
}

function DelCookie(sName){
	var sValue = "false";
	document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}

function clickSave(box){
	if (box.checked) {
		SetCookie("notShowMsg", "true");
	} else {
		DelCookie("notShowMsg");
	}
}

//from
var fromSellLeads = "0";
var fromProduct = "1";
var fromCompany = "2";
var fromBuyLead = "10";
var fromQcInspection = "100";
var fromFreeFeedBack = "20";
var fromGScontact = "30";
var fromGSFeedBack = "40";
var fromRFQ = "50";
var fromQuotation = "60";
var wwwServer = "http://www.alibaba.com";
var imageServer = globalImgServer;

function alitalkEncryptNew(enemberId, from, id, type, iSearchVer){
	/*询盘拦截*/
	if (window.supplierBlackList && supplierBlackList[enemberId]) {	/*在黑名单中*/
		win = open(getFeedBackUrl(from, id, type), 'blFeedback', 'location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
		win.focus();
		return;
	}
	//wholesale: type = 1; default: type = 0
	var para = "", selfpara = "", nextUrl = "", win, focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id  + "&id=" + enemberId;
	};

	// 按照iSearch方式解析在线状态码 : true， 按亮灯服务器方式解析在线状态码 : false
	iSearchVer = iSearchVer ? true : false;
	//加密后的memberId的可能存在一些"+"等需要encode的字符
	if (ATMAPI.isBrowserSupport) {
		if (fromBuyLead == from) {
			buyingLeadsCheckRight(enemberId, from, id)
			return;
		}
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			if (OnLine == -1 || (!iSearchVer && OnLine == 2)) {
				//对方没有安装或者安装了但从未登陆过
				para = focusProductParam + "url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
				selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time=" + timestamp.getTime();
				logger(selfpara);
				//这里只是登陆,发验证消息由后面逻辑处理
				//系统检查Browser是否已登录Alibaba,未登陆，系统直接打开反馈页面,已经登陆已经登录，系统弹出窗口跳转至添.
				win = open(getFeedBackUrl(from, id), 'feedBack', 'location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
				win.focus();
			} else {
				//对方曾经登陆过
				para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
				selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time=" + timestamp.getTime();
				logger(selfpara);
				sendMessage(enemberId, para);
			}

		} else {
			clientNotReadyAction(function(){
				// 未安装对方已登陆(OnLine or Away) - 打开webatm
				if (iSearchVer && (OnLine == 1 || OnLine == 3 || OnLine == 5)) {
					doOpenWebIM(from, enemberId, id);
				}
				else if (!iSearchVer && (OnLine == 1 || OnLine == 8)) {
					doOpenWebIM(from, enemberId, id);
				}
				else {
					//对方没有安装TM或者对方安装TM但未登陆,全屏打开
					win = open(getFeedBackUrl(from, id, type), 'feedBack', 'location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
					win.focus();
				}
			});
		}
	} else {
		doOpenWebIM(from, enemberId, id);
	}
}

function alitalkEncryptForEscrow(enemberId, from, id){
	alitalkEncryptNew(enemberId, from, id, null);
}

function targetToWebMessage(enemberId, from, id){
	var iframe = document.getElementById("webmessagehelpframe")
	if (iframe == null) {
		iframe = document.createElement("iframe");
		iframe.id = "webmessagehelpframe"
		iframe.width = 0;
		iframe.height = 0;
		document.body.appendChild(iframe);
	}
	iframe.src = "http://www.alibaba.com/alitalk/innerie/webMessageCheckPage.htm?needEncypt=true&targetid=" + encodeURIComponent(enemberId) + "&from=" + from + "&id=" + id;

}

function alitalkEncryptLiveInput(url){
	var para = "", selfpara = "", nextUrl = "", win;
	//加密后的memberId的可能存在一些"+"等需要encode的字符
	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			//浏览者已经安装TM.则直接打开alibaba.com Help 窗口.
			ATMAPI.startATM("", "", "");
		} else {
			//提示浏览者安装TM
			nextUrl = wwwServer + url;
			win = open(nextUrl, 'liveinput', 'width=600,height=500,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
			win.focus();
		}
	} else {
		doIfExploreIsNotSupport();
	}
}

function alitalkEncryptGetLive(){
	alitalkEncryptLiveInput('/others/popup/errorMsg_Browser_Installnow_For_LiveHelp.vhtml');
}

/*
 Inquire Quotation url
 Url
 */
function getFeedBackUrl(from, id, type){
	var feedBackUrl = "";
	if (fromSellLeads == from) {
		feedBackUrl = "http://message.alibaba.com/msgsend/contact.htm?action=contact_action&req_page=feedback.init&domain=0&id=" + id;
	}else if(fromQcInspection == from) {
	  feedBackUrl = "http://message.alibaba.com/msgsend/contact.htm?action=contact_action&chkContactIds=" + id;
	} else {
		if (type === 1) {
			feedBackUrl = "http://message.alibaba.com/msgsend/contact.htm?action=contact_action&req_page=feedback.init&domain=" + from + "&id=" + id + '&isWholesale=1';
		} else {
			feedBackUrl = "http://message.alibaba.com/msgsend/contact.htm?action=contact_action&req_page=feedback.init&domain=" + from + "&id=" + id;
		}
	}
	return feedBackUrl;
}

/*
 Url
 */
function urlAddQueryString(baseUrl, queryString){
	if (baseUrl != null) {
		if (baseUrl.indexOf("?") == -1) {
			return baseUrl + "?" + queryString;
		}
		return baseUrl + "&" + queryString;
	}
	return baseUrl;
}

/*
 Inquire Quotation??url
 */
function makeFeedBackElement(elementId, from, id, openStyle){
	var fbElement = document.getElementById(elementId);
	if (fbElement == null)
		return;
	feedbackUrl = getFeedBackUrl(from, id);
	if (openStyle == "0") {
		fbElement.href = feedbackUrl;
	} else {
		var winUrl = feedbackUrl;
		fbElement.href = "javascript:openMaxWin('" + winUrl + "'" + ",'');";
	}
}

function makeFeedBackButton(elementId, from){
	var fbElement = document.getElementById(elementId);
	if (fbElement == null)
		return;
	if (fromSellLeads == from || fromProduct == from || fromCompany == from) {
		fbElement.src = imageServer + "/images/eng/style/button/inquire_now.gif";
		fbElement.alt = "Inquire Now";
	} else {
		fbElement.src = imageServer + "/images/eng/style/button/send_quotation.gif";
		fbElement.alt = "Quotation Now";
	}
}

function openMaxWin(winUrl, name){
	if (winUrl == null)
		return;
	var win = open(winUrl, name, 'menubar=no,toolbar=no,directories=no,location=no,status=no,scrollbars=yes,resizable=yes');
	win.focus();
}

/*
 TM
 */
function startTM(from, id){
	ATMAPI.startATM("", "", "");
}

/*
 url
 */
function validateTM(enemberId, from, id){
	var referUrl = document.URL;
	var timestamp = new Date();
  var focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id + "&id=" + enemberId;
	};

	para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
	sendMessage(enemberId, para);
}

function buyingLeadsCheckRight(enemberId, from, id){
	checkUrl = wwwServer + "/others/popup/TmBuyingLeadsStepAfterSignIn.html" + "?offerid=" + id + "&fm=" + from + "&md=" + encodeURIComponent(enemberId);
	var win = open(checkUrl, 'checkRight' + Math.round(Math.random() * 24 * 100), 'width=800,height=550,location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
	win.focus();
}

function alitalkEncryptNewBuyingLeads(enemberId, from, id){
	var para = "", selfpara = "", nextUrl = "", win, focusProductParam = "";

	// 如果是from属于产品(fromProduct = 1)
	if(from == fromProduct){
	  focusProductParam = "&gid=" + id + "&id=" + enemberId;
	};

	if (ATMAPI.isBrowserSupport) {
		if (ATMAPI.isClientReady()) {
			var referUrl = document.URL;
			var timestamp = new Date();
			if (OnLine == 2) {
				para = focusProductParam + "url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
				selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time=" + timestamp.getTime();
				logger(selfpara);
				win = open(getFeedBackUrl(from, id), 'feedBack', 'location=no,toolbar=no,status=no,resizable=yes,scrollbars=yes');
				win.focus();
			} else {
				para = focusProductParam + "&url2=http://dmtracking2.alibaba.com/feedbackfromalitalk.html?from=" + from + "#id=" + id + "#refer=" + referUrl.replace(/&/ig, "$") + "#time=" + timestamp.getTime();
				selfpara = "http://dmtracking2.alibaba.com/feedbackfromalitalk.html?type=client&STEP=CLICK&from=" + from + "&id=" + id + "&refer=" + referUrl.replace(/&/ig, "$") + "&time=" + timestamp.getTime();
				logger(selfpara);
				sendMessage(enemberId, para);
				window.setTimeout("window.close()", 1000);
			}
		} else {
			clientNotReadyAction(function(){
				if (OnLine == 1) {
					doOpenWebIM(from, enemberId, id);
				} else {
					window.location = getFeedBackUrl(from, id)
					window.moveTo(0, 0);
					window.resizeTo(screen.availWidth, screen.availHeight);
				}
			});
		}
	} else {
		doOpenWebIM(from, enemberId, id);
	}

}

function startorInstallTM(){
	alitalkInstallOrLogin(true);
}

//just start ATM,nothing else to do
function startAlitalk(){
	alitalkInstallOrLogin(false);
}

function multiImg(maxLen){
	atmMultiImg(maxLen, 'atm32', true);
}


function multiImgById(maxLen, css, needInner){
	if (css == undefined || css == null)
		return;
	css = (needInner == 1) ? "atm32" : "atm";
	atmMultiImg(maxLen, css, needInner);
}


function singleUserImgById(css, needInner){
	showVirtualATMIcon('talkId32', css, OnLine, needInner);
}

// used in myalibaba only
function singleUserImgSmall(alitalkId){
	if (typeof getOnline == 'function') {
		showVirtualATMIcon(alitalkId, 'atm32', OnLine, true);
	}
	else {
		// 为可能已经废弃掉的模板做兼容处理
		showVirtualATMIcon(alitalkId, 'atm', online[0], true);
	}
}

function multiImgSmall(maxLen){
	atmMultiImg(maxLen, 'atm32', true);
}

function singleUserImg16(){
	showVirtualATMIcon('talkId16', 'atm32', OnLine, true);
}

function userDefineATM(objId, css, needInner){
	showVirtualATMIcon(objId, css, OnLine, needInner);
}

function singleUserImg24(talkId){
	var id = talkId || 'talkId24', css = 'atm24', txt = ['I\'m online<br />Chat now!', 'Offline'];
	switch (id) {
		case 'talkId16':
			css = 'atm16';
			txt = ['Chat now!', 'Offline'];
			break;
		case 'talkId24':
			css = 'atm24';
			break;
		case 'talkId32':
			css = 'atm32';
			break;
		case 'talkId48':
			css = 'atm48';
	}
	showVirtualATMIcon(id, css, OnLine, true, txt);
}

// used in minisite only
function newSingleUserImg(alitalkId){
	showVirtualATMIcon(alitalkId, 'atm', online[0], true);
}

function singleUserImg32(alitalkId){
	var alitId = alitalkId || "talkId32";
	showVirtualATMIcon(alitalkId, 'atm32', OnLine, true);
}

function singleUserImg48(talkId){
	var id = talkId || 'talkId48';
	YAHOO.util.Event.on(window, "load", function(){
		showVirtualATMIcon(id, 'atm48', OnLine, true);
	});
}

/**
 * 显示ATM图标
 * @param id {string} ATM图标ID
 * @param css {string} ATM图标CSS定义
 * @param online {number} 服务器返回的在线状态标识
 * @param isShowTxt {boolean} 是否显示文本,若为false则只显示图标
 * @param usrTxt {array} 自定义文本['online text', 'offline text']
 * @param iSearchVer {boolean} 指定按照亮灯服务器方式还是按照iSearch方式来解析在线状态码
 * @return void
 */
function showVirtualATMIcon(id, css, online, isShowTxt, usrTxt, iSearchVer) {
	// 按照iSearch方式解析在线状态码 : true， 按亮灯服务器方式解析在线状态码 : false
	iSearchVer = iSearchVer ? true : false;

	var status = iSearchVer ? {
		'0': 'OFFLINE',
		'1': 'LEISURE',
		'2': 'BUSY',
		'3': 'LEAVE',
		'4': 'BUSY',
		'5': 'LEAVE',
		'6': 'BUSY',
		'30': 'LEISURE',
		'33': 'LEISURE',
		'34': 'BUSY',
		'35': 'LEAVE',
		'36': 'BUSY',
		'37': 'LEAVE',
		'38': 'BUSY',
		'40': 'OFFLINE',
		'41': 'OFFLINE',
		'125': 'OFFLINE',
		'126': 'OFFLINE',
		'127': 'OFFLINE'
	} : {
		'0': 'OFFLINE',
		'1': 'LEISURE',
		'6': 'OFFLINE',
		'7': 'BUSY',
		'8': 'LEAVE'
	};

	var onlineHref = '1';
	var offlineHref = '0';
	id = id || 'talkId32';
	css = css || 'atm32';
	usrTxt = usrTxt || ['I\'m Online<br />Chat Now!', 'Offline', 'I\'m Away', 'I\'m Busy'];
	var noPng = YAHOO.env.ua.ie === 6 || YAHOO.env.ua.ie === 7 || /\d/.test(css);
	var alit = YAHOO.util.Dom.get(id);
	if (alit != null) {
		alit.className = css + 'grey' + (noPng ? '' : ' ' + css + 'PngGrey');
		alit.innerHTML = !!isShowTxt ? usrTxt[1] : '';
		alit.href = alit.href.replace('isOnline', offlineHref);
		alit.title = 'Please Leave a Message';
		switch (status[online]) {
		case 'OFFLINE':
			// 离线状态
			alit.className = css + 'grey' + (noPng ? '' : ' ' + css + 'PngGrey');
			alit.innerHTML = !!isShowTxt ? usrTxt[1] : '';
			alit.href = alit.href.replace('isOnline', offlineHref);
			alit.title = 'Please Leave a Message';
			break;
		case 'LEISURE':
			// 空闲状态
			alit.className = css + 'online' + (noPng ? '' : ' ' + css + 'PngOnline');
			alit.innerHTML = !!isShowTxt ? usrTxt[0] : '';
			alit.href = alit.href.replace('isOnline', onlineHref);
			alit.title = 'Chat with me';
			break;
		case 'BUSY':
			// 忙碌状态
			alit.className = css + 'busy' + (noPng ? '' : ' ' + css + 'PngBusy');
			alit.innerHTML = !!isShowTxt ? usrTxt[3] : '';
			alit.href = alit.href.replace('isOnline', offlineHref);
			alit.title = 'Please Leave a Message';
			break;
		case 'LEAVE':
			// 离开状态
			alit.className = css + 'away' + (noPng ? '' : ' ' + css + 'PngAway');
			alit.innerHTML = !!isShowTxt ? usrTxt[2] : '';
			alit.href = alit.href.replace('isOnline', offlineHref);
			alit.title = 'Please Leave a Message';
			break;
		}
	}
}

/**
 * 根据页面默认输出批量显示ATM在线图标
 * @param maxLen {number} 需要显示ATM图标数量
 * @param atmClass {string} ATM图标CSS定义
 * @param needInner {boolean} 是否显示文本,若为false则只显示图标
 * @param textAry {array} 自定义文本['online text', 'offline text']
 * @param iSearchVer {boolean} 指定按照亮灯服务器方式还是按照iSearch方式来显示旺旺图标
 * @return void
 */
function atmMultiImg(maxLen, atmClass, needInner, textAry, iSearchVer){
	for (var i = 0; i < maxLen; i++) {
		var j = i + 1;
		showVirtualATMIcon("talkId" + j, atmClass, online[i], needInner, textAry, iSearchVer);
	}
}

/**
 * 显示单个ATM图标
 * @param atmId {number} ATM图标ID
 * @param atmClass {string} ATM图标CSS定义
 * @param needInner {boolean} 是否显示文本,若为false则只显示图标
 * @param userText {array} 自定义文本['online text', 'offline text']
 * @return void
 */
function atmSingleImg(atmId, atmClass, needInner, userText){
	showVirtualATMIcon(atmId, atmClass, online[0], needInner, userText);
}

/*若用于询盘拦载的黑名单尚未加载，则请求*/
AE.defer(function() {
	if (!window.supplierBlackList) {
		setTimeout(function() {
			if (!window.supplierBlackList) { /*延时后再一次试探*/
				YAHOO.util.Get.script(globalImgServer + '/js/5v/run/pool/supplier_blacklist.js?v=20110410');
			}
		}, 200);
	}
});

