document.write('<script language="JavaScript" src="http://cop.my.xunlei.com/webgame/js/AC_RunActiveContent.js"></script>');
/**
 * start defined cookie
 */
	function Cookie(document, name, hours, path, domain, secure)
	{
	    this.$document = document;
	    this.$name = name;
	    if (hours)
	        this.$expiration = new Date((new Date()).getTime() + hours*3600000);
	    else this.$expiration = null;
	    if (path) this.$path = path; else this.$path = null;
	    if (domain) this.$domain = domain; else this.$domain = null;
	    if (secure) this.$secure = true; else this.$secure = false;
	}
	
	Cookie.prototype.store = function (val) {
	    var cookieval = "";
	    if(val && val!=""){
			cookieval = val;
		}else{
			for(var prop in this) {
	        // Ignore properties with names that begin with '$' and also methods.
	        if ((prop.charAt(0) == '$') || ((typeof this[prop]) == 'function')) 
	            continue;
	        if (cookieval != "") cookieval += '&';
	        cookieval += prop + ':' + escape(this[prop]);
	    }
		}
	    var cookie = this.$name + '=' + cookieval;
	    if (this.$expiration)
	        cookie += '; expires=' + this.$expiration.toGMTString();
	    if (this.$path) cookie += '; path=' + this.$path;
	    if (this.$domain) cookie += '; domain=' + this.$domain;
	    if (this.$secure) cookie += '; secure';
	    this.$document.cookie = cookie;
	}
	
	Cookie.prototype.load = function() { 
	    var allcookies = this.$document.cookie;
	    if (allcookies == "") return false;
	    var start = allcookies.indexOf(this.$name + '=');
	    if (start == -1) return false;   // Cookie not defined for this page.
	    start += this.$name.length + 1;  // Skip name and equals sign.
	    var end = allcookies.indexOf(';', start);
	    if (end == -1) end = allcookies.length;
	    var cookieval = allcookies.substring(start, end);
	    var a = cookieval.split('&');    // Break it into array of name/value pairs.
	    for(var i=0; i < a.length; i++)  // Break each pair into an array.
	        a[i] = a[i].split(':');
	    for(var i = 0; i < a.length; i++) {
	        this[a[i][0]] = unescape(a[i][1]);
	    }
	    return true;
	}
	
	Cookie.prototype.remove = function() {
	    var cookie;
	    cookie = this.$name + '=';
	    if (this.$path) cookie += '; path=' + this.$path;
	    if (this.$domain) cookie += '; domain=' + this.$domain;
	    cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';
	
	    this.$document.cookie = cookie;
	}
/**
 * end defined cookie
 */		
		
		var thunder_pos;
        var thunder_vpos;
        var thunder_topos;
        var thunder_height; 
		var xlun_action;
		var browserClientHeight;
		var cookie = new Cookie(document, "xlunfloater_cookie", 0.5, "/");
		
		function _xlwebgamepv2(copid,stype){try{vhref="http://analytics-union.xunlei.com/PV?peerid=0&uri=http://webgamepv.union.xunlei.com&src="+top.document.domain+"&screensize="+copid+"*"+stype+"*0*0";image1=new Image(1,1);image1.src=vhref}catch(e){}}
		function initXlunHref(copid, stype){
			var arr = document.getElementsByName("xlun_a_href");
			for(var i = 0; i < arr.length; i++) {
				link = arr[i].href + "?gid=" + copid + "&cflag=" + stype;
				arr[i].href = "http://analytics-union.xunlei.com/Click?uri=http://webgameclick2.union.xunlei.com&linkid=" + copid + "," + stype + ",0,0," + top.document.domain + "&location=" + encodeURIComponent(link);
			}			
		}

		function XlunFloater(){
            if (IE || FF) {
                diffY = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
                diffX = document.body.scrollLeft;
            }
            if (NS) {
                diffY = self.pageYOffset;
                diffX = self.pageXOffset;
            }
            if (diffY != lastScrollY) {
                percent = .1 * (diffY - lastScrollY);
                if (percent > 0) 
                    percent = Math.ceil(percent);
                else 
                    percent = Math.floor(percent);
                if (FF) 
                    document.getElementById('xlun_floater').style.top = initScrollY + lastScrollY;
                if (IE) 
                    document.getElementById('xlun_floater').style.pixelTop += percent;
                if (NS) 
                    document.xlun_floater.top += percent;
                lastScrollY = lastScrollY + percent;
            }
            if (diffX != lastScrollX) {
                percent = .1 * (diffX - lastScrollX);
                if (percent > 0) 
                    percent = Math.ceil(percent);
                else 
                    percent = Math.floor(percent);
                if (IE || FF) 
                    document.getElementById('xlun_floater').style.pixelLeft += percent;
                if (NS) 
                    document.xlun_floater.left += percent;
                lastScrollX = lastScrollX + percent;
            }
        }
        
        function resetPos(){
            if (thunder_vpos.toLowerCase() == "middle") {
                thunder_topos = (browserClientHeight - thunder_height) / 2;
            }
            else {
                if (thunder_vpos.toLowerCase() == "bottom") {
                    thunder_topos = browserClientHeight - thunder_height;
                }
                else {
                    if (thunder_vpos.match(/^[\d]{1,2}[%]?$/)) {
                        thunder_topos = thunder_vpos;
                    }
                    else {
                        thunder_topos = 5;
                    }
                }
            }
            initScrollY = thunder_topos - 5;
            document.getElementById('xlun_floater').style.top = thunder_topos + lastScrollY - 5;
        }

		
		function closeXlunFloater(callback) {
			if(xlun_action) {
				window.clearInterval(xlun_action);
			}
			setXlunFloaterIsClosed();
			if(typeof callback == "function") {
				callback();
			}
			document.getElementById("xlun_floater").style.display = "none";
		}
		
		function setXlunFloaterIsClosed() {
			cookie.closedStatus = "true";
			cookie.store();
		}
        
        function initXlunFloater(xlunParams){
			if(cookie.load() && cookie.closedStatus == "true") {
				return false;
			}
			if(xlunParams.style){document.write(xlunParams.style);} // css write here
            document.write('<div id="xlun_floater" class="xlun_floater" style="display:none;" >');
            document.write(xlunParams.content);// contents write here
            document.write('</div>');
            initScrollY = parseInt(document.getElementById('xlun_floater').style.top.slice(0, -2)) - 40;
            initScrollX = parseInt(document.getElementById('xlun_floater').style.left.slice(0, -2));
            if(xlunParams.x) {lastScrollX = xlunParams.x} else lastScrollX = 0;
			if(xlunParams.y) {lastScrollY = xlunParams.y} else lastScrollY = 0;
        }

		function locateXlunFloater(xlunParams) {
			if(cookie.load() && cookie.closedStatus == "true") {
				return false;
			}
			browserClientHeight = document.body.clientHeight < window.screen.availHeight ? document.body.clientHeight : window.screen.availHeight*0.8;
			thunder_pos = xlunParams.pos;
			thunder_vpos = xlunParams.vpos;
			thunder_topos = xlunParams.topos;
			thunder_height = xlunParams.height; 
			if (thunder_pos.toLowerCase() == "right") {} else thunder_pos = "left";
	        if (thunder_vpos.toLowerCase() == "middle") thunder_topos = (browserClientHeight - thunder_height) / 2;
	        else if (thunder_vpos.toLowerCase() == "bottom") thunder_topos = browserClientHeight - thunder_height;
			else if (thunder_vpos.match(/^[\d]{1,2}[%]?$/)) thunder_topos = thunder_vpos;
			else thunder_topos = 5;
			var floatDiv = document.getElementById("xlun_floater");
			floatDiv.style.display = "";
			if (thunder_pos.toLowerCase() == "right") {
				floatDiv.style.right = "5px";
			} else {
				floatDiv.style.left = "5px";
			}
			floatDiv.style.position = "absolute";
			floatDiv.style.top = thunder_topos;

			FF = (navigator.userAgent.indexOf("Firefox") >= 0 || navigator.userAgent.indexOf("Opera") >= 0) ? 1 : 0;
            IE = (document.all) ? 1 : 0;
            NS = (document.layers) ? 1 : 0;
            thunder_height = document.getElementById('xlun_floater').clientHeight;
            if (NS || IE || FF) 
                xlun_action = window.setInterval("XlunFloater()", 20);
			if(FF) resetPos();
            window.onresize = resetPos;
			_xlwebgamepv2(xlunParams.copid, xlunParams.stype); // for pv
			initXlunHref(xlunParams.copid, xlunParams.stype); // for click
		}