var g_intervalHandler;
var g_timeoutHandler;
var g_stayTime;
var g_tipsId;
var g_heterTips;
var g_DEFAULTSTEP = 5;
var g_INTERVAL = 18;
var g_validTipsArr = new Array();
var G_UP;
var g_oldClientHeight;//avoid continuous winresize because of set tips display style
var g_areano = -1;
		
var sUserAgent = navigator.userAgent;
var fAppVersion = parseFloat(navigator.appVersion);
var f_isUP=0;
window.onerror = function(){return true;}
function compareVersions(sVersion1, sVersion2) {

    var aVersion1 = sVersion1.split(".");
    var aVersion2 = sVersion2.split(".");
    
    if (aVersion1.length > aVersion2.length) {
        for (var i=0; i < aVersion1.length - aVersion2.length; i++) {
            aVersion2.push("0");
        }
    } else if (aVersion1.length < aVersion2.length) {
        for (var i=0; i < aVersion2.length - aVersion1.length; i++) {
            aVersion1.push("0");
        }    
    }
    
    for (var i=0; i < aVersion1.length; i++) {
 
        if (aVersion1[i] < aVersion2[i]) {
            return -1;
        } else if (aVersion1[i] > aVersion2[i]) {
            return 1;
        }    
    }
    
    return 0;

}

var isOpera = sUserAgent.indexOf("Opera") > -1;
var isMinOpera4 = isMinOpera5 = isMinOpera6 = isMinOpera7 = isMinOpera7_5 = false;

if (isOpera) {
    var fOperaVersion;
    if(navigator.appName == "Opera") {
        fOperaVersion = fAppVersion;
    } else {
        var reOperaVersion = new RegExp("Opera (\\d+\\.\\d+)");
        reOperaVersion.test(sUserAgent);
        fOperaVersion = parseFloat(RegExp["$1"]);
    }

    isMinOpera4 = fOperaVersion >= 4;
    isMinOpera5 = fOperaVersion >= 5;
    isMinOpera6 = fOperaVersion >= 6;
    isMinOpera7 = fOperaVersion >= 7;
    isMinOpera7_5 = fOperaVersion >= 7.5;
}

var isKHTML = sUserAgent.indexOf("KHTML") > -1 
              || sUserAgent.indexOf("Konqueror") > -1 
              || sUserAgent.indexOf("AppleWebKit") > -1; 
              
var isMinSafari1 = isMinSafari1_2 = false;
var isMinKonq2_2 = isMinKonq3 = isMinKonq3_1 = isMinKonq3_2 = false;

if (isKHTML) {
    isSafari = sUserAgent.indexOf("AppleWebKit") > -1;
    isKonq = sUserAgent.indexOf("Konqueror") > -1;

    if (isSafari) {
        var reAppleWebKit = new RegExp("AppleWebKit\\/(\\d+(?:\\.\\d*)?)");
        reAppleWebKit.test(sUserAgent);
        var fAppleWebKitVersion = parseFloat(RegExp["$1"]);

        isMinSafari1 = fAppleWebKitVersion >= 85;
        isMinSafari1_2 = fAppleWebKitVersion >= 124;
    } else if (isKonq) {

        var reKonq = new RegExp("Konqueror\\/(\\d+(?:\\.\\d+(?:\\.\\d)?)?)");
        reKonq.test(sUserAgent);
        isMinKonq2_2 = compareVersions(RegExp["$1"], "2.2") >= 0;
        isMinKonq3 = compareVersions(RegExp["$1"], "3.0") >= 0;
        isMinKonq3_1 = compareVersions(RegExp["$1"], "3.1") >= 0;
        isMinKonq3_2 = compareVersions(RegExp["$1"], "3.2") >= 0;
    } 
    
}

var isIE = sUserAgent.indexOf("compatible") > -1 
           && sUserAgent.indexOf("MSIE") > -1
           && !isOpera;
           
var isMinIE4 = isMinIE5 = isMinIE5_5 = isMinIE6 = false;

if (isIE) {
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    reIE.test(sUserAgent);
    var fIEVersion = parseFloat(RegExp["$1"]);

    isMinIE4 = fIEVersion >= 4;
    isMinIE5 = fIEVersion >= 5;
    isMinIE5_5 = fIEVersion >= 5.5;
    isMinIE6 = fIEVersion >= 6.0;
}

var isMoz = sUserAgent.indexOf("Gecko") > -1
            && !isKHTML;

var isMinMoz1 = sMinMoz1_4 = isMinMoz1_5 = false;

if (isMoz) {
    var reMoz = new RegExp("rv:(\\d+\\.\\d+(?:\\.\\d+)?)");
    reMoz.test(sUserAgent);
    isMinMoz1 = compareVersions(RegExp["$1"], "1.0") >= 0;
    isMinMoz1_4 = compareVersions(RegExp["$1"], "1.4") >= 0;
    isMinMoz1_5 = compareVersions(RegExp["$1"], "1.5") >= 0;
}

var isNS4 = !isIE && !isOpera && !isMoz && !isKHTML 
            && (sUserAgent.indexOf("Mozilla") == 0) 
            && (navigator.appName == "Netscape") 
            && (fAppVersion >= 4.0 && fAppVersion < 5.0);

var isMinNS4 = isMinNS4_5 = isMinNS4_7 = isMinNS4_8 = false;

if (isNS4) {
    isMinNS4 = true;
    isMinNS4_5 = fAppVersion >= 4.5;
    isMinNS4_7 = fAppVersion >= 4.7;
    isMinNS4_8 = fAppVersion >= 4.8;
}

var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") 
            || (navigator.platform == "Macintosh");

var isUnix = (navigator.platform == "X11") && !isWin && !isMac;

var isWin95 = isWin98 = isWinNT4 = isWin2K = isWinME = isWinXP = false;
var isMac68K = isMacPPC = false;
var isSunOS = isMinSunOS4 = isMinSunOS5 = isMinSunOS5_5 = false;

if (isWin) {
    isWin95 = sUserAgent.indexOf("Win95") > -1 
              || sUserAgent.indexOf("Windows 95") > -1;
    isWin98 = sUserAgent.indexOf("Win98") > -1 
              || sUserAgent.indexOf("Windows 98") > -1;
    isWinME = sUserAgent.indexOf("Win 9x 4.90") > -1 
              || sUserAgent.indexOf("Windows ME") > -1;
    isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 
              || sUserAgent.indexOf("Windows 2000") > -1;
    isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 
              || sUserAgent.indexOf("Windows XP") > -1;
    isWinNT4 = sUserAgent.indexOf("WinNT") > -1 
              || sUserAgent.indexOf("Windows NT") > -1 
              || sUserAgent.indexOf("WinNT4.0") > -1 
              || sUserAgent.indexOf("Windows NT 4.0") > -1 
              && (!isWinME && !isWin2K && !isWinXP);
} 

if (isMac) {
    isMac68K = sUserAgent.indexOf("Mac_68000") > -1 
               || sUserAgent.indexOf("68K") > -1;
    isMacPPC = sUserAgent.indexOf("Mac_PowerPC") > -1 
               || sUserAgent.indexOf("PPC") > -1;  
}

if (isUnix) {
    isSunOS = sUserAgent.indexOf("SunOS") > -1;

    if (isSunOS) {
        var reSunOS = new RegExp("SunOS (\\d+\\.\\d+(?:\\.\\d+)?)");
        reSunOS.test(sUserAgent);
        isMinSunOS4 = compareVersions(RegExp["$1"], "4.0") >= 0;
        isMinSunOS5 = compareVersions(RegExp["$1"], "5.0") >= 0;
        isMinSunOS5_5 = compareVersions(RegExp["$1"], "5.5") >= 0;
    }
}

var EventUtil = new Object;
EventUtil.addEventHandler = function (oTarget, sEventType, fnHandler) {
    if (oTarget.addEventListener) {
        oTarget.addEventListener(sEventType, fnHandler, false);
    } else if (oTarget.attachEvent) {
        oTarget.attachEvent("on" + sEventType, fnHandler);
    } else {
        oTarget["on" + sEventType] = fnHandler;
    }
};
        
EventUtil.removeEventHandler = function (oTarget, sEventType, fnHandler) {
    if (oTarget.removeEventListener) {
        oTarget.removeEventListener(sEventType, fnHandler, false);
    } else if (oTarget.detachEvent) {
        oTarget.detachEvent("on" + sEventType, fnHandler);
    } else { 
        oTarget["on" + sEventType] = null;
    }
};

var ScriptUtil = new Object;
ScriptUtil.get = function (url,fnHandler,parent){
	//当页面没有onload取不到body时,必须指定parent.
	var scriptParent = parent?parent:document.body;
	var dynamicScript = document.createElement('script');
	
	dynamicScript.src=url;

	if(scriptParent){scriptParent.appendChild(dynamicScript);}
		
	else {debug('script \'s parent is null');}
	EventUtil.addEventHandler(dynamicScript,"readystatechange",function(){//for IE
		if(dynamicScript.readyState == 'loaded' || dynamicScript.readyState == 'complete'){
					fnHandler();	
		}	
		
	});
	
	EventUtil.addEventHandler(dynamicScript,"load",function(){//for FF
		fnHandler();	
	});
}

var CookieUtil = new Object;

	CookieUtil.setCookie = function (sName, sValue, iHour, sPath, sDomain, bSecure) {
	if((typeof(G_BUILD_VERSION) != 'undefined') && (G_BUILD_VERSION>165)){
        ioCtrlWriter(sName,sValue,iHour||null);
		return;
    }

      var sCookie = sName + "=" + encodeURIComponent(sValue);
  
      if (iHour) {
      		var oExpires = new Date( new Date().getTime() + iHour * 3600000);
       		sCookie += "; expires=" + oExpires.toGMTString();
      }
  
      if (sPath) {
          sCookie += "; path=" + sPath;
      }
  
      if (sDomain) {
          sCookie += "; domain=" + sDomain;
      }
  
      if (bSecure) {
          sCookie += "; secure";
      }
  
      document.cookie = sCookie;
  }
                  
  CookieUtil.getCookie = function (sName) {
	if((typeof(G_BUILD_VERSION) != 'undefined') && (G_BUILD_VERSION>165)){
		return ioCtrlReader(sName);
	}

      var sRE = "(?:; )?" + sName + "=([^;]*);?";
      var oRE = new RegExp(sRE);
      
      if (oRE.test(document.cookie)) {
          return decodeURIComponent(RegExp["$1"]);
      } else {
          return '';
      }
  
  }                

  CookieUtil.deleteCookie = function (sName, sPath, sDomain) {
      var sCookie = sName + "=; expires=" + (new Date(0)).toGMTString();
      if (sPath) {
          sCookie += "; path=" + sPath;
      }
  
      if (sDomain) {
          sCookie += "; domain=" + sDomain;
      }
      
      document.cookie = sCookie;
  }

var hiddenIfr = null;
function RequestIframe(u,parent) {
	if(hiddenIfr == null){
		var ifrParent = parent?parent:document.body;
		var hiddenIfr=document.createElement('iframe');
		hiddenIfr.name = 'hiddenIframe';
		hiddenIfr.id = 'hiddenIframe';
		hiddenIfr.width = 0;
		hiddenIfr.height = 0;
		hiddenIfr.style.position = 'absolute';
		hiddenIfr.style.top = '-1000px';
		ifrParent.appendChild(hiddenIfr);
		
	}
	
	setTimeout(function(){
		frames['hiddenIframe'].location.href = u;
	},20);
}

function ioCtrlWriter(key, value, expires){
    var player = new ActiveXObject("DapCtrl.DapCtrl");
    var iExpire = expires || 720;
    player.Put("sCookieFileName", key+".dat");
    player.Put("sCookie", value+"～"+((new Date().getTime()) + iExpire * 3600000));
    player = null;
}
function ioCtrlReader(key){
    var player = new ActiveXObject("DapCtrl.DapCtrl");
    var sCookie = null;
    var value = null;
    player.Put("sCookieFileName", key+".dat");
    sCookie = player.Get("sCookie")||null;
    if(null != sCookie){
        value = ioCtrlCheck(sCookie);
    }
    player = null;
    return value || "";
    function ioCtrlCheck(sCookie){
        var items = sCookie.split("～");
        var curDate = expires = 0;
        var value = null;
        if(items.length != 2){return null;}
        value = ""==items[0]?null:items[0];
        expires = parseInt(items[1], 10);
        curDate = new Date().getTime();
        if(curDate > expires){
            return null;
        }else{
            return value;
        }
    }
}

function finishUp(){
	finishUp.time = new Date().getTime();
	if(g_stayTime != -1){
		g_timeoutHandler = setTimeout(autoDown,g_stayTime);		
	}
}
function autoDown(){downTip(2);}
function finishDown(){
	hideTip();
	EventUtil.removeEventHandler(window,"resize",winResize);
  EventUtil.removeEventHandler(window,"scroll",winScroll);
}
function upPixel(y){
		var tip_box = document.getElementById("tip_box");
		var maxUp = g_heterTips?g_heterTips.height:160;
		if(!upPixel.up){upPixel.up = 0; }
		if(Math.abs(upPixel.up) >= maxUp){
			clearInterval(g_intervalHandler);
			if(y>0){
				finishUp();
			}
			if(y<0){
				finishDown()	
			}
			upPixel.up = 0;
			return;
		}
		if(isMinIE5){
			var top = tip_box.currentStyle.top.split("px")[0];
		}
		else if(isMoz){
			var top = document.defaultView.getComputedStyle(tip_box,null).top.split("px")[0];
		}
		top = top-y;
		tip_box.style.top = top+"px";
		
		upPixel.up += y;
	}
	
	function getPeerid()
	{
		var peeridobj;
		try
		{
			peeridobj = new ActiveXObject("MediaAddin.MediaComm");
		}
		catch (e)
		{}
	
		var peerId;
		if (peeridobj != null && typeof(peeridobj) != "undefined")
		{
			peerId = peeridobj.peerid;
		}
	
		return peerId;
	}
	
	function upTip(step,interval){
		var stp = (step)?step:g_DEFAULTSTEP;
		var itv = (interval)?interval:g_INTERVAL;
		locateTip(0);
		showTip();
		g_intervalHandler = setInterval("upPixel("+stp+")",itv);
	}
	function getAliveTime(){
		if(finishUp.time){
			var ct = new Date().getTime();
			return Math.round((ct - finishUp.time)/1000);
		}
		return 0;
	}
	function downTip(dt,step,interval){
		//1为点X关闭；2为自动滑落；'positionId':点内容关闭(统计按3发) 没有传dt按2自动滑落
		clearTimeout(g_timeoutHandler);
		
		var dt = dt?dt:2;
		var stp = (step)?step:-g_DEFAULTSTEP;
		var itv = (interval)?interval:g_INTERVAL;
		var aliveTime = getAliveTime();
		g_intervalHandler = setInterval("upPixel("+stp+")",itv);
		
		var peerid='none';
		var pos='none';
		if(parseInt(dt,10) > 1000){
			pos = parseInt(dt,10);
			dt = 3;
		}
		peerid = getPeerid();
		RequestIframe("http://mediapv.sandai.net/commstat/webtips?itemid=3&peerid="+peerid+"&pos="+pos+"&tipsid="+g_tipsId+"&tm="+aliveTime+"&tp="+dt);
		f_isUP=0;
	}
	
	function showTip(){
		var tip_box = document.getElementById("tip_box");
		if(tip_box){tip_box.style.display = "";}
	}
	function hideTip(){
		var tip_box = document.getElementById("tip_box");
		if(tip_box){tip_box.style.display = "none";}
	}
	

	function getClientSize(){
	    return {width:document.documentElement.clientWidth,height:document.documentElement.clientHeight};
	}

	function locateTip(i){//i==0初始定位。i==1窗口变化的新定位.i==2滚动变化的新定位
		var width = getClientSize().width;
		var height = getClientSize().height;
		var srollTop = document.documentElement.scrollTop;
		var srollLeft = document.documentElement.scrollLeft;
		
		var tip_box = document.getElementById("tip_box");	
		
		if(isMinIE5){
			var tipWidth =  tip_box.currentStyle.width.split("px")[0];
			var tipHeight =  tip_box.currentStyle.height.split("px")[0];
		}
		else if(isMoz){
			var tipWidth = document.defaultView.getComputedStyle(tip_box,null).width.split("px")[0];
			var tipHeight =  document.defaultView.getComputedStyle(tip_box,null).height.split("px")[0];
		}
		
		tipWidth = (g_heterTips)?g_heterTips.width:tipWidth;
		tipHeight = (g_heterTips)?g_heterTips.height:tipHeight;
		
		var top;
		var left;
		switch(i){
			case 0:
				top = (height + srollTop - 2) + "px";
				left = (width-tipWidth-2)+"px";
				break;
			case 1:
			case 2:
				top = (height - (finishUp.time?tipHeight:0) + srollTop - 2) + "px";
				left = (width - tipWidth + srollLeft - 2)+"px";
				break;
		}
		tip_box.style.top = top;
		tip_box.style.left = left;
		
	}
	

	
function winResize(){
	if (g_oldClientHeight != document.documentElement.clientHeight) {
    var tip_box = document.getElementById("tip_box");	
    if(tip_box && (tip_box.style.display != "none")){
			locateTip(1);
		}	
   }
  g_oldClientHeight = document.documentElement.clientHeight;
}

function winScroll(){
	var tip_box = document.getElementById("tip_box");	
	if(tip_box && (tip_box.style.display != "none")){
		locateTip(2);		
	}
	
}
function checkArea(tipsArea){
	if(tipsArea == -1) {
		return true;
		
	}
	var temp_arr = tipsArea.split("|");
	for(var i = 0; i < temp_arr.length; i++) {
		if (g_areano == 60026 || g_areano == 60009) {  //深圳，广州 特例
			if (g_areano == temp_arr[i]) {
				return true;
			}
		} else {
			if (g_areano - (g_areano % 10000) == temp_arr[i]) {
				return true;
			}
		}
		
	}
	return false;


}

function debug(s,t){
	return;
	if(t) return;
	alert(s);
}
function judgeInterval(tipPlatformId){
	var interval = CookieUtil.getCookie('xltips_'+tipPlatformId+'_interval');
	var lastup = CookieUtil.getCookie('xltips_'+tipPlatformId+'_lastup');
	if ((interval === '') || (lastup === '')){
		debug('debuginfo:Cookie中的interval 或者lastup 为 空');
		return true;
	}else{
		var ct = new Date().getTime();
		debug('是否超过最小时间间隔:'+((ct-lastup) > interval));
		if((ct-lastup) > interval) return true;
		else return false;
	}
}

function initTips(tipPlatformId){
	g_oldClientHeight = document.documentElement.clientHeight;
	if(judgeInterval(tipPlatformId) === false) return;
	ScriptUtil.get("http://areainfo.xunlei.com:81/zoneinfo.js", function(){
		g_areano = areano;
	});
	getTipsConfig(tipPlatformId);

}
function getTipsConfig(tipPlatformId){
	setTimeout(function(){
		ScriptUtil.get("http://mtips.xunlei.com/tips/web/"+tipPlatformId+".config.js",function(){
			handleConfig(tipPlatformId);
		});
	},"400");
	
}
function test(){
}
function checkAreaValue(tipsArea){
	
	for(var i = 0; g_areano == -1 && i < 20; i++){
		setTimeout('test()',400);
	}
	
	return checkArea(tipsArea);
	


}
function getValidTipsArr(tarr){
	var tArr = new Array();
	for(var i=0; i<tarr.length; i++){
		if(checkAreaValue(tarr[i].TipsArea) && checkValidDate(tarr[i].TipsStartTime,tarr[i].TipsEndTime)){
			tArr.push(tarr[i]);
		}
	}
	return tArr;
}
 function handleConfig(tipPlatformId){
 	g_validTipsArr = getValidTipsArr(Config.TipsArr);
	g_validTipsArr.sort(_sortByPriority);
  	CookieUtil.setCookie('xltips_'+tipPlatformId+'_interval',Config.TipsInterval,24);
	var upids = CookieUtil.getCookie('xltips_'+tipPlatformId+'_upids');

	debug("debuginfo:已经弹出过的ID:-"+upids);
	if(upids === null){
		genTipContentFrom(tipPlatformId,g_validTipsArr);
	}
	else{
		var tipsArr = getNotShowedTips(g_validTipsArr,upids);
		if(tipsArr.allNoShowed){CookieUtil.deleteCookie('xltips_'+tipPlatformId+'_upids');}
		genTipContentFrom(tipPlatformId,tipsArr);
	}


	function _sortByPriority(a,b)
	{
		if(a.TipsPriority<b.TipsPriority) return -1;
		if(a.TipsPriority>b.TipsPriority) return 1;
		if(Math.random()<0.5) return 1;
		else return -1;
	}
	
 }
 
 function setAutoDown(dauto,dtime){
 	if(dauto == 1) {g_stayTime = dtime}
 	else g_stayTime = -1;
 	
}
function getNotShowedTips(allTipsArr,upids){
	var arr = new Array();
	var upTidArr = upids.split("|");
	var allNoShowed = true;
	for(var i=0; i<allTipsArr.length; i++){
		var noShowed = true;
		for(var j=0; j<upTidArr.length; j++){
			if(allTipsArr[i].TipsId == upTidArr[j]){
				noShowed = false;
				allNoShowed = false;
				break;
			}
		}
		if(noShowed){
			var tipsContentObj = new Object();
			tipsContentObj.TipsId = allTipsArr[i].TipsId;
			tipsContentObj.TipsContent = allTipsArr[i].TipsContent;
			tipsContentObj.TipsArea = allTipsArr[i].TipsArea;
			tipsContentObj.TipsStartTime = allTipsArr[i].TipsStartTime;
			tipsContentObj.TipsEndTime = allTipsArr[i].TipsEndTime;
			tipsContentObj.TipsAutoDown = allTipsArr[i].TipsAutoDown;
			tipsContentObj.TipsStayTime = allTipsArr[i].TipsStayTime;
			tipsContentObj.TipsAllText = allTipsArr[i].TipsAllText;
			tipsContentObj.TipsPriority = allTipsArr[i].TipsPriority;
			tipsContentObj.TipsDelay = allTipsArr[i].TipsDelay;
					
			arr.push(tipsContentObj);
		}
	}
	if(allNoShowed){
			debug('配置文件中有效轮均未弹出过.清空cookie中已经弹出的tipsid');
			arr.allNoShowed = true;
		}
	debug('debuginfo:notSHowed tips : '+arr.length);
	return arr;
}
function posClick(pos){
	var peerid = getPeerid();
	RequestIframe("http://mediapv.sandai.net/commstat/webtips?itemid=3&peerid="+peerid+"&pos="+pos+"&tipsid="+g_tipsId+"&tm=none&tp=17");
}
function genTipContentFrom(tipPlatformId,arr){
	if(arr.length == 0) return;
	
	var rn = 0; 
	var tipsDelay = arr[rn].TipsDelay;
	setTimeout(function(){
		var dd = document.createElement("div");
		dd.innerHTML = arr[rn].TipsContent;
		g_tipsId = arr[rn].TipsId;
		document.body.appendChild(dd);
		g_heterTips = document.getElementById("heterTips");
		if(arr[rn].TipsAllText == 1) G_UP();
	},tipsDelay);
	
	G_UP = function(o){
		if(f_isUP==0){
		var peerid = getPeerid();
		upTip();
		setAutoDown(arr[rn].TipsAutoDown,arr[rn].TipsStayTime);
		RequestIframe("http://mediapv.sandai.net/commstat/webtips?itemid=3&peerid="+peerid+"&pos=none&tipsid="+g_tipsId+"&tm=none&tp=12");
		_writeCookies();
		
		EventUtil.addEventHandler(window,"resize",winResize);
		EventUtil.addEventHandler(window,"scroll",winScroll);
		if(o){o.onload = null;}
		f_isUP=1;
	}
	};
	
  function _writeCookies(){
		var upids = CookieUtil.getCookie('xltips_'+tipPlatformId+'_upids');
		upids = (upids == null)?arr[rn].TipsId:(upids+"|"+arr[rn].TipsId);
		CookieUtil.setCookie('xltips_'+tipPlatformId+'_upids',upids,24);
		var lastup = new Date().getTime();
		CookieUtil.setCookie('xltips_'+tipPlatformId+'_lastup',lastup,24);
		debug('debuginfo:已设置此次弹出时----间入cookie:'+lastup);
	}

}

function checkValidDate(st,et){
	var st_y = parseInt(st.split("-")[0],10);
	var st_m = parseInt(st.split("-")[1],10)-1;
	var st_d = parseInt(st.split("-")[2],10);
	var st_h = parseInt(st.split("-")[3],10);
	var st_n = parseInt(st.split("-")[4],10);
	var st_s = parseInt(st.split("-")[5],10);
	
	var et_y = parseInt(et.split("-")[0],10);
	var et_m = parseInt(et.split("-")[1],10)-1;
	var et_d = parseInt(et.split("-")[2],10);
	var et_h = parseInt(et.split("-")[3],10);
	var et_n = parseInt(et.split("-")[4],10);
	var et_s = parseInt(et.split("-")[5],10);
	
	var ctMilli = new Date().getTime();
	var stMilli = new Date(st_y,st_m,st_d,st_h,st_n,st_s).getTime();
	var etMilli = new Date(et_y,et_m,et_d,et_h,et_n,et_s).getTime();
	
	if((ctMilli>stMilli) && (ctMilli<etMilli)){
		return true;
	}else{
		debug('始终时间为'+st+'~'+et+'的tips　已经过期');
		return false;
	}
}
            
function writeTipsCss(){
	var cssStr = '\
	#tip_box {position:absolute;top:-1000px;left:-1000px;width:258px;height:158px;font:normal 12px/1.5em simsun, Verdana,Lucida, Arial, Helvetica, sans-serif;color:#5B6D91;border:1px solid #509DDB;}\
	.tip-box-b {width:auto !important;height:auto !important;overflow:hidden;border:0 !important;}\
	#tip_box * {margin:0;padding:0;}\
	#tip_box h1 {height:23px;padding-right:27px;overflow:hidden;line-height:23px;text-indent:9px;text-align:left;font-size:12px;color:#FFFFFF;background:url("http://mtips.xunlei.com/tips/title_bg.png") 0 0 no-repeat;}\
	#tip_box .content-box {position:relative;width:258px;height:135px;margin:0px;overflow:hidden;background:#BFD4EF url("http://mtips.xunlei.com/tips/content_bg.png") repeat-x 0 0;}\
	#tip_box .content-box img.mov-pic {float:left;width:98px;height:131px;margin-right:12px;display:block;overflow:hidden;border:1px solid #6C98A5;}\
	#tip_box .content-box img.tip-pic {width:256px;height:133px;display:block;overflow:hidden;border:0;}\
	#tip_box .content-box h2 {float:left;width:140px;height:30px;line-height:34px;font-size:12px;color:#0065CF;}\
	#tip_box .content-box h2 a {text-decoration:none;color:#0065CF;}\
	#tip_box .content-box h2 a:hover {color:#000000;}\
	#tip_box .content-box h2.mov-title-b {float:none;width:240px;text-align:center;}\
	#tip_box .content-box .content {float:left;width:140px;height:100px;overflow:hidden;text-align:left;}\
	#tip_box .content-box .content a {text-decoration:none;color:#5B6D91;}\
	#tip_box .content-box .content a:hover {color:#000000;}\
	#tip_box .content-box .content-b {float:none;width:240px;height:100px;overflow:hidden;margin:0 auto;}\
	#tip_box .total {position:absolute;top:0;left:0;width:256px;height:133px;}\
	#tip_box .total img {display:block;overflow:hidden;width:256px;height:133px;border:0;}\
	#tip_box .close {display:block;position:absolute;top:3px;right:6px;width:16px;height:16px;line-height:500px;content:"";overflow:hidden;}\
	';
	var style = document.createElement("style");
    style.type = "text/css";
    style.rel = "stylesheet";
    document.getElementsByTagName("head")[0].appendChild(style);
	style.styleSheet.cssText = cssStr;
	
}
writeTipsCss()
