var owner = "init";
var ot_mess_cfg = {theme:'default',color:'',title:'请输入手机号码或固话号码进行拨号',send:' ',close:' ',copyright:'本系统由畅信达通信提供技术',mbpos:'RD'};
var ot_mess_msg = {areanumErr: '请输入正确的区号',phoneErr: '请输入正确的座机号',prefix: '',success:'',fail:'拨号失败,请重试',telErr:'请输入正确的手机号',actionErr:'拨号失败,请重试'};
var ot_mess_cols = [{type:"text",mbtype:"mbphoneno",tip:"请输入手机号(外地加0)",innertip:"请输入手机号(外地加0)",idname:"mphoneno"},{type:"text",mbtype:"areacode",tip:"请输入区号",innertip:"区号",idname:"areacode"},{type:"text",mbtype:"phoneno",tip:"请输入座机号",innertip:"请输入您的座机号",idname:"phoneno"},{type:"select",mbtype:"mselect",tip:"请选择服务部门",innertip:"请选择服务部门",idname:"dest"}/*,{type:"text",mbtype: "auth",tip: "请输入验证码",innertip: "验证码",idname: "authnum"}*/];
var ot_mess_opt_cols = [{tip:'请选择我们的部门',value:"0"}];
var ot_mess_onecol = {type:"text",mbtype:"phoneno",tip:"请输入座机号",innertip:"请输入您的座机号",idname:"phoneno"};
var webcallurl = "https://h2.ipxchina.cn:8088";var ot_mess_lib = {
//读取css文件
loadCss: function (url) {
var css = document.createElement('link');
css.setAttribute('rel', 'stylesheet');
css.setAttribute('type', 'text/css');
css.setAttribute('href', url);
document.getElementsByTagName('head')[0].appendChild(css);
},
getElement: function (id) {
return document.getElementById(id);
}
}
var ot_mess_browser = {};
//匹配IE版本
ot_mess_browser.ieVersion = /msie (\d+)/.exec(navigator.userAgent.toLowerCase());
//是否高于IE6
ot_mess_browser.higherThanIE6 = ot_mess_browser.ieVersion && parseInt(ot_mess_browser.ieVersion[1]) > 6;
//浏览器渲染模式是否为标准模式
ot_mess_browser.onQuirkMode = document.compatMode && document.compatMode.indexOf('Back') == 0;
//IE6下默认不缓存背景图片
if(ot_mess_browser.ieVersion && !(ot_mess_browser.higherThanIE6)) {
document.execCommand("BackgroundImageCache", false, true);
}
var OT_MESS_FORM_NAME = "OtMessForm";
var OT_MESS_WRAP_ID = "OtMessWrap";
var OT_MESS_HEAD_ID = "OtMessHead";
var OT_MESS_TITLE_ID = "OtMessTitle";
var OT_MESS_HEAD_ICON_ID = "OtMessHeadIcon";
var OT_MESS_BODY_ID = "OtMessBody";
var OT_MESS_BODY_TOP_ID = "OtMessBodyTop";
var OT_MESS_BODY_MID_ID = "OtMessBodyMid";
var OT_MESS_BODY_MSG_ID = "OtMessBodyMSGid";
var OT_MESS_BODY_BOTTOM_ID = "OtMessBodyBottom";
var OT_MESS_BODY_FOOT_ID = "OtMessBodyFoot"
var OT_MESS_SUBMIT_ID = "OtMessSubmit";
var OT_MESS_CLOSEBU_ID = "OtMessClosebu";
var OT_MESS_COPY_ID = "OtMessCopy";
var OT_MESS_NOTIFY_ID = "OtMessNotify";
var OT_MESS_FRAME_ID = "OtMessCopyFrame";
var OT_MESS_TIP_CLASS = "OtMessTip";
var OT_MESS_ICON_OPEN_CLASS = "OtMessIconOpen";
var OT_MESS_ICON_CLOSE_CLASS = "OtMessIconClose";
var OT_MESS_MARQUEE_ID = "OtMess_MARQUEE";
var OT_MESS_SUBMIT_TD_ID = "OtMessSubmitTd";
var OT_MESS_CLOSEBU_TD_ID = "OtMessClosebuTd";
var OT_MESS_PREFIX = "OtMess_";
var OT_MESS_POST_ACTION = webcallurl+"/webcall.php";
var OT_MESS_THEME_PATH = webcallurl;
var ot_mess_layout_mod = [];
ot_mess_layout_mod.push('
',
'
',
'
',
'
',
'
${ot_mess_cfg.copyright}
',
'
',
'
');
if (window.ot_mess_preview) OT_MESS_POST_ACTION = "";
var ot_mess_validate = {
//获取表单信息
mustValidate: function (name, defaultValue) {
var colValue = document.getElementById(OT_MESS_PREFIX + name).value.replace(/(^\s*)|(\s*$)/g, "");
//alert('colValue:'+colValue);
if (colValue.length <= 0 ||
colValue == filtInnertip(defaultValue)) {
return false;
}
return true;
},
mustSelect: function (name, defaultValue) {
var colValue = document.getElementById(OT_MESS_PREFIX + name).value;
//alert('colValue:'+colValue);
if (colValue == '0') {
return false;
}
return true;
},
telValidate: function (innertip) {
var telEl = document.getElementById(OT_MESS_PREFIX + 'mphoneno');
if (telEl) {
if (telEl.value == innertip || telEl.value.length == 0) return true;
return (/^(0)?(?:13\d|15\d|18\d)-?\d{5}(\d{3}|\*{3})/.test(document.getElementById(OT_MESS_PREFIX + 'mphoneno').value));
}
},
areanumValidate: function (innertip) {
var areanumEl = document.getElementById(OT_MESS_PREFIX + 'areacode');
if (areanumEl) {
if (areanumEl.value == innertip || areanumEl.value.length == 0) return true;
return (/0\d{2,3}/.test(document.getElementById(OT_MESS_PREFIX + 'areacode').value));
}
},
phoneValidate: function (innertip) {
var phoneEl = document.getElementById(OT_MESS_PREFIX + 'phoneno');
if (phoneEl) {
if (phoneEl.value == innertip || phoneEl.value.length == 0) return true;
return (/\d{7,8}/.test(document.getElementById(OT_MESS_PREFIX + 'phoneno').value));
}
},
init: function () {
document[OT_MESS_FORM_NAME].onsubmit = function () {
if (window.ot_mess_preview){ alert(ot_mess_msg.actionErr); return false;}
var pass = true;
var msg = [];
var intSucNum = 0;
var noContact = true;
var aetMsg = [];
var oriColumnsState = {'mbphoneno':0,'areacode':0,'phoneno':0};
var oriColumns = {};
var telInnertip = "";
var tel = document.getElementById(OT_MESS_PREFIX + 'mphoneno').value.replace(/(^\s*)|(\s*$)/g, "");
var phone = document.getElementById(OT_MESS_PREFIX + 'phoneno').value.replace(/(^\s*)|(\s*$)/g, "");
var areanum = document.getElementById(OT_MESS_PREFIX + 'areacode').value.replace(/(^\s*)|(\s*$)/g, "");
if (tel.length <= 0 || tel == filtInnertip('请输入手机号(外地加0)')) {
if (phone.length <= 0 || phone == filtInnertip('请输入您的座机号')) {
//alert('ok');
pass = false;
msg.push('请输入您的手机号或者座机号');
}else{
if (phone.length <= 0 || phone == filtInnertip('请输入您的座机号')) {
pass = false;
msg.push('请输入您的座机号');
}
}
}
if(!ot_mess_validate.mustValidate('dest','请选择服务部门')||!ot_mess_validate.mustSelect('dest','请选择服务部门')) {
pass = false;
//msg.push(ot_mess_msg.prefix + '请选择服务部门');
}
if (!ot_mess_validate.telValidate('请输入手机号(外地加0)')) {
pass = false;
msg.push(ot_mess_msg.telErr);
}
if (!ot_mess_validate.areanumValidate('区号')) {
pass = false;
msg.push(ot_mess_msg.areanumErr);
}
if (!ot_mess_validate.phoneValidate('请输入您的座机号')) {
pass = false;
msg.push(ot_mess_msg.phoneErr);
}
if(!pass) {
alert(msg.join('\n'));
} else {
for (var i = 0, l = ot_mess_cols.length; i < l; i++) {
var inputCfg = ot_mess_cols[i];
//alert('inputCfg'+inputCfg);
var hideEl = document.getElementById(OT_MESS_PREFIX + inputCfg.idname + 'hide');
document.getElementById(OT_MESS_PREFIX + inputCfg.idname).disabled = true;
if (document.getElementById(OT_MESS_PREFIX + inputCfg.idname).value == inputCfg.innertip) {
hideEl.value = '';
continue;
}
var utf8Value = encodeURIComponent(document.getElementById(OT_MESS_PREFIX + inputCfg.idname).value);
hideEl.value = utf8Value;
}
ot_mess_lib.getElement(OT_MESS_SUBMIT_ID).disabled = true;
otMessTimes = 0;
dispmsg("正在处理...");
otMessSubmitMonitor();
}
return pass;
}
}
}
var otMessTimes;
function otMessSubmitMonitor () {
try{
otMessTimes ++;
if (otMessTimes > 100) {
ot_mess_lib.getElement(OT_MESS_SUBMIT_ID).disabled = false;
for (var i = 0, l = ot_mess_cols.length; i < l; i++) {
document.getElementById(OT_MESS_PREFIX + ot_mess_cols[i].idname).disabled = false;
}
dispmsg("");
} else {
setTimeout(otMessSubmitMonitor,100);
}
} catch (e) {
ot_mess_lib.getElement(OT_MESS_SUBMIT_ID).disabled = false;
dispmsg("");
for (var i = 0, l = ot_mess_cols.length; i < l; i++) {
var inputCfg = ot_mess_cols[i];
var inputEl = document.getElementById(OT_MESS_PREFIX + inputCfg.idname);
inputEl.disabled = false;
inputEl.value = filtInnertip(inputCfg.innertip);
}
}
}
//防止乱码
function filtInnertip (str) {
return str.replace(/"/g, '"').replace(/'/g, "'").replace(/</g,'<').replace(/>/g,'>').replace(/&/g,'&');
}
function dispmsg(themsg){
var msgobject=document.getElementById(OT_MESS_BODY_MSG_ID);
msgobject.innerHTML=themsg;
}
if (!window.is_ot_mess_loaded) {
window.is_ot_mess_loaded = true;
ot_mess_lib.loadCss(OT_MESS_THEME_PATH + '/css.css');
var ot_pos_style = "right:0";
if (ot_mess_cfg.mbpos && ot_mess_cfg.mbpos.indexOf('L') == 0) {
ot_pos_style = "left:0";
}
var ot_load_build = 'normal';
if (ot_mess_cfg.theme == 'friendly') {
ot_load_build = 'friendly';
}
}
var ot_mess_tween = {
init: function () {
var mbBody = ot_mess_lib.getElement(OT_MESS_BODY_ID);
this.min = 0;
this.max = mbBody.offsetHeight;
},
initTween: function () {
/*if (!ot_mess_tween.initHeight) {
ot_mess_tween.initHeight = 1;
}*/
var mbBody = ot_mess_lib.getElement(OT_MESS_WRAP_ID);
mbBody.style.display = 'none';
//mbBody.style.height = ot_mess_tween.initHeight + 'px';
/*ot_mess_tween.initHeight += 2;*/
if (window.attachEvent && (!ot_mess_browser.higherThanIE6 || ot_mess_browser.onQuirkMode) && (!window.opera)) {
ot_mess_layout.fixMessageBoardPosition();
}else{
ot_mess_layout.fixMessageBoardPosition();
}
/*if (ot_mess_tween.initHeight > ot_mess_tween.max) {*/
ot_mess_lib.getElement(OT_MESS_HEAD_ICON_ID).onclick = function (e) {
var mbBody = ot_mess_lib.getElement(OT_MESS_WRAP_ID);
mbBody.style.display = 'none';
};
ot_mess_lib.getElement(OT_MESS_HEAD_ICON_ID).className = OT_MESS_ICON_CLOSE_CLASS;
/*} else {
setTimeout(ot_mess_tween.initTween, 0);
}*/
},
duration: 30,
easeIn: function (step, duration) {
return Math.pow(step/duration, 2);
},
easeOut: function (step, duration) {
var c = step/duration;
return -c * (c - 2);
},
doTween: function () {
var from, to;
var mbBody = ot_mess_lib.getElement(OT_MESS_BODY_ID);
if (mbBody.style.display == 'none') {
from = this.min;
to = this.max;
} else {
from = this.max;
to = this.min;
}
var step = 0, chg = to - from;
function fixPosition() {
if (window.attachEvent && (!ot_mess_browser.higherThanIE6 || ot_mess_browser.onQuirkMode) && (!window.opera)) {
ot_mess_layout.fixMessageBoardPosition();
}
}
function doTweenStep () {
var offset = ot_mess_tween.easeIn(step++, ot_mess_tween.duration);
var hei = from + Math.floor(chg * offset);
if (hei > 0) {
mbBody.style.height = hei + 'px';
mbBody.style.display = '';
} else {
mbBody.style.display = 'none';
}
if (step > ot_mess_tween.duration) {
clearInterval(interval);
ot_mess_lib.getElement(OT_MESS_HEAD_ICON_ID).className = mbBody.style.display == 'none' ? OT_MESS_ICON_OPEN_CLASS : OT_MESS_ICON_CLOSE_CLASS;
}
fixPosition();
}
var interval = setInterval(doTweenStep, 10);
}
}
var ot_mess_layout = {
module: null,
getModule: function () {
return ot_mess_layout_mod.join('');
},
createLayout: function () {
document.write(this.getModule().replace(/\$\{[.\w]+\}/g, this.__layoutVarReplacer));
//alert(this.getModule().replace(/\$\{[.\w]+\}/g, this.__layoutVarReplacer));
this.mbWrap = ot_mess_lib.getElement(OT_MESS_WRAP_ID);
},
__layoutVarReplacer: function (str) {
if (str.indexOf('$') == 0) {
try {
return eval(str.substr(2, str.length - 3));
} catch(e) {
return '';
}
}
return str;
},
createFormInputs: function () {
var mbBody = ot_mess_lib.getElement(OT_MESS_BODY_ID);
var mbBodyMid = ot_mess_lib.getElement(OT_MESS_BODY_MID_ID);
var maxLenObj = {
"mbphoneno":12,
"areacode":5,
"phoneno":9,
"auth":4
};
for (var i = 0, l = ot_mess_cols.length; i < l; i++) {
var inputCfg = ot_mess_cols[i];
if (inputCfg.tip) {
var tipEl = document.createElement('div');
if (inputCfg.mbtype == "message")tipEl.id = OT_MESS_TIP_CLASS + inputCfg.mbtype;
tipEl.className = OT_MESS_TIP_CLASS;
tipEl.innerHTML = inputCfg.tip;
mbBodyMid.appendChild(tipEl);
}
var inputWrap = document.createElement('div');
var inputEl;
if (inputCfg.type == 'text') {
inputEl = document.createElement('input');
inputEl.type = 'text';
var maxLen = maxLenObj[inputCfg.mbtype];
if (maxLen) inputEl.maxLength = maxLen;
else inputEl.maxLength = 200;
} else {
inputEl = document.createElement('select');
inputEl.disabled = false;
}
if (inputCfg.idname){
inputEl.name = inputCfg.idname;
inputEl.id = OT_MESS_PREFIX + inputCfg.idname;
}
if (inputCfg.mbtype) {
inputWrap.className = inputCfg.mbtype;
}
this.__addInputEvent(inputEl, filtInnertip(inputCfg.innertip));
//alert('id:'+document.getElementById(OT_MESS_PREFIX + inputCfg.idname));
inputWrap.appendChild(inputEl);
mbBodyMid.appendChild(inputWrap);
if(document.getElementById('OtMess_authnum')){
document.getElementById('OtMess_authnum').width = 50;
}
//create a hidden input to hold userid
inputHiddenEl = document.createElement('input');
inputHiddenEl.value = owner;//owner is hold in config.js
inputHiddenEl.type = 'hidden';
inputHiddenEl.name= inputCfg.idname + 'hide';
inputHiddenEl.id = OT_MESS_PREFIX + inputCfg.idname + 'hide';
mbBodyMid.appendChild(inputHiddenEl);
}
var inputSp = document.createTextNode(' ');
inputWrap.appendChild(inputSp);
},
__addInputEvent: function (el, text) {
if (text == '') {
return;
}
el.value = text;
el.onblur = function (event) {
if (this.value == '') {
this.value = text;
}
}
el.onfocus = function (event) {
if (this.value == text) {
this.value = '';
}
}
},
initFormStyle: function() {
ot_mess_lib.getElement(OT_MESS_CLOSEBU_ID).onclick = function (e) {
var mbBody = ot_mess_lib.getElement(OT_MESS_WRAP_ID);
mbBody.style.display = 'none';
};
var mbBody = ot_mess_lib.getElement(OT_MESS_BODY_ID);
ot_mess_tween.init();
mbBody.style.overflow = 'hidden';
mbBody.style.display = 'none';
this.mbWrap.style.top = document.documentElement.clientHeight - this.mbWrap.clientHeight + 'px';
if (window.addEventListener || ot_mess_browser.higherThanIE6 && (!ot_mess_browser.onQuirkMode)) {
this.mbWrap.style.top = '';
this.mbWrap.style.bottom = '0';
this.mbWrap.style.position = 'fixed';
} else {
window.attachEvent('onscroll', this.fixMessageBoardPosition);
window.attachEvent('onresize', this.fixMessageBoardPosition);
this.fixMessageBoardPosition();
}
ot_mess_tween.initTween();
},
fixMessageBoardPosition: function () {
var self = ot_mess_layout;
var page = document.body;
if (!ot_mess_browser.onQuirkMode) {
page = page.parentNode;
}
self.mbWrap.style.top = (parseInt(page.clientHeight) + parseInt(page.scrollTop) - self.mbWrap.offsetHeight)/3+ 'px';
self.mbWrap.style.right = (parseInt(page.clientHeight) + parseInt(page.scrollTop) - self.mbWrap.offsetHeight)/1.5 + 'px';
}
}
function showWEBCALL(){
var tiBody = ot_mess_lib.getElement(OT_MESS_WRAP_ID);
var mbBody = ot_mess_lib.getElement(OT_MESS_BODY_ID);
tiBody.style.display = 'block';
mbBody.style.display = 'block';
}
ot_mess_layout.createLayout();
ot_mess_layout.createFormInputs();
ot_mess_validate.init();
//document.getElementById('OtMessWrap').style.display = 'none'
setTimeout(function(){ot_mess_layout.initFormStyle();}, 1000);
oSelect=document.getElementById("OtMess_dest");
//oSelect.options.add(new Option('请选择服务部门','0'));
oSelect.options.add(new Option('业务咨询','1'));
oSelect.options.add(new Option('代理合作','2'));
document.getElementById("OtMess_MARQUEE").innerHTML='WEB呼叫中心功能工作日内9时-17时开放。如遇线路繁忙,请稍后再试。为避免恶意呼叫,我们会记录每次使用的ip地址。';