/* 广告js */ var timespan = navigator.useragent.indexof("firefox") > 0 ? 15 : 10; var adconfig = false; var n = 0; var h = 0; var sh = 0; var st = 0; function addevent(obj, eventtype, func) { if (obj.addeventlistener) { obj.addeventlistener(eventtype, func, false); } else if (obj.attachevent) { obj.attachevent("on" + eventtype, func); } } function adconfiginit() { adconfig = new object(); adconfig.left = 0; adconfig.top = 0; adconfig.width = 0; adconfig.height = 0; adconfig.scroll = function() { if (document.documentelement && document.documentelement.scrollleft) { adconfig.left = document.documentelement.scrollleft; } else if (document.body) { adconfig.left = document.body.scrollleft; } if (document.documentelement && document.documentelement.scrolltop) { adconfig.top = document.documentelement.scrolltop; } else if (document.body) { adconfig.top = document.body.scrolltop; } } adconfig.resize = function() { if (document.documentelement && document.documentelement.clientheight && document.body && document.body.clientheight) { adconfig.width = (document.documentelement.clientwidth > document.body.clientwidth) ? document.body.clientwidth : document.documentelement.clientwidth; adconfig.height = (document.documentelement.clientheight > document.body.clientheight) ? document.body.clientheight : document.documentelement.clientheight; } else if (document.documentelement && document.documentelement.clientheight) { adconfig.width = document.documentelement.clientwidth; adconfig.height = document.documentelement.clientheight; } else if (document.body) { adconfig.width = document.body.clientwidth; adconfig.height = document.body.clientheight; } } adconfig.scroll(); adconfig.resize(); addevent(window, "scroll", adconfig.scroll); addevent(window, "resize", adconfig.resize); } /*弹出窗口*/ function adpopup(id, title, content, width, height, autoclosed) { if (!adconfig) adconfiginit(); var popup = window.open("about:blank", "", "width=" + width + ", height=" + height); popup.document.write(""); popup.document.title = title; popup.document.body.innerhtml = content; popup.document.body.style.cursor = "pointer"; popup.document.body.style.overflow = "hidden"; if (autoclosed) { popup.document.body.onclick = function() { popup.window.close(); } } } /*浮动广告*/ function adfly(id, title, content, left, top, width, height, autoclosed) { if (!adconfig) adconfiginit(); id = "adver_" + id; document.writeln("" + content + ""); var obj = document.getelementbyid(id); obj.style.cursor = "pointer"; obj.style.position = "absolute"; obj.style.overflow = "hidden"; obj.style.left = left + "px"; obj.style.top = top + "px"; obj.style.width = width + "px"; obj.style.height = height + "px"; obj.style.zindex = "999"; var directx = 1; var directy = 1; obj.move = function() { if (left + width >= adconfig.left + adconfig.width) { left = adconfig.left + adconfig.width - width; directx = -1; } else if (left <= adconfig.left) { left = adconfig.left; directx = 1; } if (top + height >= adconfig.top + adconfig.height) { top = adconfig.top + adconfig.height - height; directy = -1; } else if (top <= adconfig.top) { top = adconfig.top; directy = 1; } left += directx; top += directy; obj.style.left = left + "px"; obj.style.top = top + "px"; } var interval = window.setinterval(obj.move, timespan); obj.onmouseover = function() { window.clearinterval(interval); } obj.onmouseout = function() { interval = window.setinterval(obj.move, timespan); } if (autoclosed) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } /*左侧门帘*/ function adlefthang(id, title, content, left, top, width, height, autoclosed) { if (!adconfig) adconfiginit(); id = "adver_" + id; document.writeln("" + content + ""); var obj = document.getelementbyid(id); obj.style.cursor = "pointer"; obj.style.position = "absolute"; obj.style.overflow = "hidden"; obj.style.left = left + "px"; obj.style.top = top + "px"; obj.style.width = width + "px"; obj.style.height = height + "px"; obj.move = function() { var t = parseint(obj.style.top, 10); if (t + 5 < adconfig.top + top) { obj.style.top = (t + 5) + "px"; } else if (t - 5 > adconfig.top + top) { obj.style.top = (t - 5) + "px"; } } var interval = window.setinterval(obj.move, timespan); if (autoclosed) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } /*右侧门帘*/ function adrighthang(id, title, content, left, top, width, height, autoclosed) { if (!adconfig) adconfiginit(); id = "adver_" + id; document.writeln("" + content + ""); var obj = document.getelementbyid(id); obj.style.cursor = "pointer"; obj.style.position = "absolute"; obj.style.overflow = "hidden"; obj.style.right = left + "px"; obj.style.top = top + "px"; obj.style.width = width + "px"; obj.style.height = height + "px"; obj.move = function() { var t = parseint(obj.style.top, 10); if (t + 5 < adconfig.top + top) { obj.style.top = (t + 5) + "px"; } else if (t - 5 > adconfig.top + top) { obj.style.top = (t - 5) + "px"; } } var interval = window.setinterval(obj.move, timespan); if (autoclosed) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } /*左右门帘*/ function adhang(id, title, content, left, right, top, width, height, autoclosed) { if (!adconfig) adconfiginit(); lid = "adver_l_" + id; rid = "adver_r_" + id; document.writeln("" + content + ""); document.writeln("" + content + ""); var obj = document.getelementbyid(lid); obj.style.cursor = "pointer"; obj.style.position = "absolute"; obj.style.overflow = "hidden"; obj.style.left = left + "px"; obj.style.top = top + "px"; obj.style.width = width + "px"; obj.style.height = height + "px"; var obj2 = document.getelementbyid(rid); obj2.style.cursor = "pointer"; obj2.style.position = "absolute"; obj2.style.overflow = "hidden"; obj2.style.right = left + "px"; obj2.style.top = top + "px"; obj2.style.width = width + "px"; obj2.style.height = height + "px"; obj.move = function() { var t = parseint(obj.style.top, 10); if (t + 5 < adconfig.top + top) { obj.style.top = (t + 5) + "px"; obj2.style.top = (t + 5) + "px"; } else if (t - 5 > adconfig.top + top) { obj.style.top = (t - 5) + "px"; obj2.style.top = (t - 5) + "px"; } } var interval = window.setinterval(obj.move, timespan); if (autoclosed) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; obj2.style.display = "none"; } obj2.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; obj2.style.display = "none"; } } } /*拉屏广告*/ function bigscreen(id, title, content, time, height, autoclosed) { if (!adconfig) adconfiginit(); var screenobj = document.getelementbyid("bigscreen"); if (!screenobj) return; screenobj.style.display = "none"; screenobj.innerhtml = content; if (autoclosed) { screenobj.onclick = function() { screenobj.style.display = "none"; } } sh = height; if (time > 0) st = time; else st = 3; //事件侦听 if(window.attachevent) { window.attachevent("onload", addheight); } if(window.addeventlistener) { window.addeventlistener("load", addheight, false); } } function backheight() { document.getelementbyid("bigscreen").style.height = h + "px"; h -= 5; stopback = settimeout("backheight()", 40) if(h < 0) { cleartimeout(stopback); h = 0; document.getelementbyid("bigscreen").style.display = "none"; } } function delaytime() { n++; stopdelay = settimeout("delaytime()", 1000); if(n == st) { cleartimeout(stopdelay); backheight(); } } function addheight() { document.getelementbyid("bigscreen").style.display = "block"; document.getelementbyid("bigscreen").style.height = h + "px"; h += 5; stopadd = settimeout("addheight()", 40); if(h > sh) { h = sh; cleartimeout(stopadd); delaytime(); } }