(function(){
ImportJavscript = {
url:function(url){
document.write("<script type=\"text/javascript\" src=\""+url+"\"></scr"+"ipt>");
}
}
})();
//控制投放点 暂时只在club detail投放
if(window.location.toString().match(/club\.china\.alibaba\.com\/forum\/thread\/view/)){
//javaScript中获取Cookie值
function getCookieNew( name ) {
var cookie_start = document.cookie.indexOf( name + "=" );
var cookie_end = document.cookie.indexOf( ";", cookie_start );
return unescape( cookie_start == -1?'':document.cookie.substring( cookie_start + name.length + 1, (cookie_end > cookie_start?cookie_end:document.cookie.length )) );
}
//JavaScript中设置Cookie值
function setCookieNew( name, value){
var expdate = new Date();
var argv = setCookieNew.arguments;
var argc = setCookieNew.arguments.length;
var expires = ( argc > 2 )?argv[2]:null;
var path = ( argc > 3 )?argv[3]:null;
var domain = ( argc > 4 )?argv[4]:null;
var secure = ( argc > 5 )?argv[5]:null;
if(!expires){
expdate.setTime( expdate.getTime() + expires*1000 );
}else{
expdate.setTime( expdate.getTime() + expires*24*60*60*1000 );
}
document.cookie = name + "=" + value + ((expires == null)?"":("; expires=" + expdate.toGMTString())) + (( path == null )?"":("; path=" + path )) + (( domain == null )?"":("; domain=" + domain )) + (( secure == true )?secure:"" );
}
//JavaScript中删除Cookie的值
function delCookieNew( name, path, domain ) {
if ( getCookieNew( name ) ) document.cookie = name + '=' + ( ( path ) ? ';path=' + path : '') + ( ( domain ) ? ';domain=' + domain : '' ) +';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
YAHOO.util.Event.onDOMReady(function (){
var YD = YAHOO.util.Dom;
if(!Alitalk.isInstallAltalk && !getCookieNew('wwpop')){
var tr = '';
var wd = '交商友、谈生意！';
var url = window.location.toString();
var hs = window.location.hostname;
var tmer01,tmer02;
if(hs.match(/club/)){
tr = 'alitalk_shequ_culb';
}else if(hs.match(/info/)){
tr = 'alitalk_shequ_info';
}else if(hs.match(/blog/)){
tr = 'alitalk_shequ_blog';
}else{
wd = '与百万商人在线谈生意！';
tr = 'alitalk_shichang_detail';
}
var s;
if( !(s = document.getElementById('ww-setup')) ){
s = document.createElement('div')
s.id = 'ww-setup';
s.innerHTML =
'<a id="wwclose" class="ww-clos" href="javascript:void(0)" target="_self"></a>' +
'<div class="ww-text">' +
'<span class="ww-org"><b>提醒：</b>您的电脑还没有安装阿里旺旺商务沟通软件，</span>免费下载安装，' + wd +
'</div>' +
'<a href="http://alitalk.alibaba.com.cn/index.html" class="ww-down" onmousedown="return aliclick(this,\'?tracelog='+tr+'\');" target="_blank">立即下载</a>';
//寻找插入点
var t;
if( !(t = YD.get('doc')) ){
t = document.body;
}
//插入
t.insertBefore(s,YD.getFirstChild(t));
}
//创建插入节点
YD.get('wwclose').onclick = function (){
YD.get('ww-setup').style.marginTop='-32px';
ani01.stop();
ani02.stop();
if(tmer01) clearTimeout(tmer01);
if(tmer02) clearTimeout(tmer02);
return false;
}
//动画效果弹出插入节点
var ani01 = new YAHOO.util.Anim(s,{
marginTop : { from : -32 , to : 0 }
},1)
var ani02 = new YAHOO.util.Anim(s,{
marginTop : { from : 0 , to : -32 }
},1)
tmer01 = setTimeout(function (){
ani01.animate();
},1000)
//		tmer02 = setTimeout(function (){
//			ani02.animate()
//		},7000)
setCookieNew('wwpop',1,1)
}
});
}
//获取屏幕和页面的宽高，并以数组形式返回
function getSize() {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){      // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else {      // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
if (self.innerHeight) {      // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) {      // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) {      // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
y = pageHeight;
} else {
pageHeight = yScroll;
y = pageHeight;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
//建立事件绑定
function addEvent(el,eventType,fn){
if(el.addEventListener){
el.addEventListener(eventType,fn,false);
}else if(el.attachEvent){
el.attachEvent("on" + eventType,fn);
}else{
el["on"+eventType]=fn;
}
}
//javaScript中获取Cookie值
function getCookieNew( name ) {
var cookie_start = document.cookie.indexOf( name + "=" );
var cookie_end = document.cookie.indexOf( ";", cookie_start );
return unescape( cookie_start == -1?'':document.cookie.substring( cookie_start + name.length + 1, (cookie_end > cookie_start?cookie_end:document.cookie.length )) );
}
//JavaScript中设置Cookie值
function setCookieNew( name, value){
var expdate = new Date();
var argv = setCookieNew.arguments;
var argc = setCookieNew.arguments.length;
var expires = ( argc > 2 )?argv[2]:null;
var path = ( argc > 3 )?argv[3]:null;
var domain = ( argc > 4 )?argv[4]:null;
var secure = ( argc > 5 )?argv[5]:null;
if(!expires){
expdate.setTime( expdate.getTime() + expires*1000 );
}else{
expdate.setTime( expdate.getTime() + expires*24*60*60*1000 );
}
document.cookie = name + "=" + value + ((expires == null)?"":("; expires=" + expdate.toGMTString())) + (( path == null )?"":("; path=" + path )) + (( domain == null )?"":("; domain=" + domain )) + (( secure == true )?secure:"" );
}
//JavaScript中删除Cookie的值
function delCookieNew( name, path, domain ) {
if ( getCookieNew( name ) ) document.cookie = name + '=' + ( ( path ) ? ';path=' + path : '') + ( ( domain ) ? ';domain=' + domain : '' ) +';expires=Thu, 01-Jan-1970 00:00:01 GMT';
}
function messUp(id,isrc,iwidth,iheight,theight){
var strCont = isrc.match(/^http:\/\//g) ? '<iframe id="messiframe" name="messiframe" src="'+isrc+'" frameborder="0" scrolling="no" width="'+iwidth+'" height="'+iheight+'" ></iframe>' : '<div style="width:'+iwidth+'px;height:'+iheight+'px;">'+isrc+'</div>'
this.HTML = strCont+'<div class="messbar" style="position:absolute;top:4px;right:0;margin-right:6px;"><img id="'+id+'_min" class="messmin" style="float:left;cursor:pointer;margin-right:2px;" src="http://img.china.alibaba.com/images/abc/parts/messup/messmin.gif" width="14" height="14"/><img id="'+id+'_res" class="messres" style="float:left;cursor:pointer;margin-right:2px;" src="http://img.china.alibaba.com/images/abc/parts/messup/messres.gif" width="14" height="14"/><img id="'+id+'_close" class="messclose" style="float:left;cursor:pointer;margin-right:2px;" src="http://img.china.alibaba.com/images/abc/parts/messup/messclos.gif" width="14" height="14"/></div>';
//this.obj = document.getElementById(id);
this.obj = document.createElement('div')
this.obj.id = id;
this.obj.className = id;
this.obj.style.position = 'absolute'
this.obj.style.right = '0';
this.obj.style.bottom = '0';
this.obj.style.overflow = 'hidden';
this.obj.style.width = iwidth;
this.obj.style.zIndex = 1000;
this.oheight = this.height = iheight;
this.theight = theight;
this.minspeed = 0.05;
this.steptimer = null;
var _this = this;
addEvent(window,'load',function (){
_this.init();
})
}
messUp.prototype = {
init: function (){
var _this = this;
_this.obj.innerHTML = this.HTML;
function _close(){
_this.close();
}
function _min(){
_this.minstep();
}
function _max(){
_this.maxstep();
}
_this.height = 0
_this.obj.style.height = 0 + 'px';
if(document.body){
document.body.appendChild(_this.obj)
}
document.getElementById(_this.obj.id+'_min').style.display = 'none';
document.getElementById(_this.obj.id+'_res').style.display = 'block';
document.getElementById(_this.obj.id+'_close').onclick = _close;
document.getElementById(_this.obj.id+'_min').onclick = _min;
document.getElementById(_this.obj.id+'_res').onclick = _max;
this.maxstep();
this.scrollWith();
},
close: function (){
this.obj.style.display = 'none';
},
minstep: function (){
var _this = this;
function _minstep(){
if(_this.height <= _this.theight){
window.clearTimeout(_this.steptimer);
document.getElementById(_this.obj.id+'_min').style.display = 'none';
document.getElementById(_this.obj.id+'_res').style.display = 'block';
return;
}
var nextlen = _this.minspeed * _this.height;
_this.height = _this.height < _this.theight ? _this.theight : _this.height - nextlen;
_this.obj.style.height = _this.height + 'px';
_this.steptimer = window.setTimeout(_minstep,10);
}
_minstep();
},
maxstep: function (){
var _this = this;
function _maxstep(){
if(_this.height >= _this.oheight){
window.clearTimeout(_this.steptimer);
document.getElementById(_this.obj.id+'_min').style.display = 'block';
document.getElementById(_this.obj.id+'_res').style.display = 'none';
return;
}
var tmp = _this.oheight;
var nextlen = _this.minspeed * tmp;
_this.height = _this.height + nextlen >= _this.oheight ? _this.oheight : _this.height + nextlen;
_this.obj.style.height = _this.height + 'px';
_this.steptimer = window.setTimeout(_maxstep,10);
}
_maxstep();
},
slide: function (){
var diffY
if (document.documentElement && document.documentElement.scrollTop)
diffY = document.documentElement.scrollTop;
else if (document.body)
diffY = document.body.scrollTop;
try{
this.obj.style.top = diffY + getSize()[3] - this.height + 'px';
this.obj.style.bottom = 'auto';
}catch(e){}
},
scrollWith: function (){
var _this = this;
function _slide2(){
_this.slide();
}
window.setInterval(_slide2,10);
}
}
/********************************************** 以下为打包函数 不可分割  ***************************************/
//修改置顶cookie指以便验证是否重新访问阿里巴巴网页
function SEARCHmodifyTheAliCookie(name){
name = name || SEARCHthecookie; //默认参考 alitalkpromote
//	var val = getCookieNew(name);
//	setCookieNew(name,val+'[m]');
//alert(getCookieNew(SEARCHthecookie))
delCookieNew(name,'/','alibaba.com')
//alert(getCookieNew(SEARCHthecookie))
}
//修改置顶cookie指以便验证是否重新访问阿里巴巴网页
//function resetTheAliCookie(name){
//	var val = getCookieNew(name);
//	val = val.replace('[m]','');
//	setCookieNew(name,val);
//}
//判断 用户有做第二次访问（即有二跳行为）
function SEARCHsecondVisit(name){
name = name || SEARCHthecookie; //默认参考 alitalkpromote
var cval = getCookieNew(name)
if( cval ){
return true;
}else{
return false;
}
}
//窗口关闭事件开启函数
function SEARCHcloseWindowEventHandle(url,name){
addEvent(window,'unload',function (){
if(SEARCHsecondVisit(name) || getCookieNew('searchpop') ){
//alert('不会弹出窗口！' + '//cookie：' + getCookieNew(SEARCHthecookie))
}else{
window.open(url);
aliclick(this,'?tracelog=se_noclick_guide')
setCookieNew('searchpop',1,30); //搜索弹出cookie，控制一个月内弹出一次
//alert('马上弹出窗口！' + '//cookie：' + getCookieNew(SEARCHthecookie))
}
});
}
/*****************************************************************************************/
//判断 document.referrer 如果是来自搜索引擎，返回搜索关键字
function SEARCHgetKeywordsFromSearchEngine(){
var words = '';
var hl='';
ref = document.referrer;
if(ref.indexOf('?')!=-1){
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++) {
qsip = qsa[i].split('=');
if (qsip.length > 1){
if (qsip[0] == 'q' || qsip[0] == 'p') { // q= for Google, p= for Yahoo
if(qsip[1] != ''){
words = qsip[1];
hl='utf';
break
}
}else if(qsip[0] == 'wd' || qsip[0] == 'word' || qsip[0] == 'w'  || qsip[0].match(/^q[1-3]$/ig)){
if(qsip[1] != ''){
words = qsip[1];
break
}
}
}
}
}
if(hl=='utf'){
words = decodeURI(words).replace(/\"/img,"”").replace(/\'/img,"”");
}else{
words = words.replace(/%22/img,"”").replace(/%27/img,"”")
}
return words;
}
function SEARCHset(){
SEARCHmodifyTheAliCookie(/*SEARCHthecookie*/)
SEARCHcloseWindowEventHandle('http://info.china.alibaba.com/news/pop/searchReturnPage.html'/*cookie判断，对应SEARCHmodifyTheAliCookie的name参数 ,SEARCHthecookie*/);  //主窗口关闭事件处理
}
var SEARCHthecookie = 'alitalkpromote'
