var timespan = navigator.useragent.indexof("firefox") > 0 ? 15 : 10; var adconfig = false; 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, top, side, autoclose) { var popup = window.open("", "win" + id, "width=" + width + ", height=" + height + ", top=" + top + ", left=" + side); popup.document.write(""); popup.document.write(title); popup.document.write(""); popup.document.write(content); popup.document.write(""); } function adfloat(obj, obj2, width, height, top, side, autoclose, showbutton) { var directx = 1; var directy = 1; obj.move = function() { if (side + width >= adconfig.left + adconfig.width) { side = adconfig.left + adconfig.width - width; directx = -1; } else if (side <= adconfig.left) { side = 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; } side += directx; top += directy; obj.style.left = side + "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 (autoclose) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } if (showbutton) { obj2.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } function adhangleft(obj, obj2, top, autoclose, showbutton) { 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 (autoclose) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } if (showbutton) { obj2.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } function adhangright(obj, obj2, top, autoclose, showbutton) { 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 (autoclose) { obj.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } if (showbutton) { obj2.onclick = function() { window.clearinterval(interval); obj.style.display = "none"; } } } function adprepare(id, title, url, mode, pic, width, height, top, side, autoclose, showbutton) { if (!adconfig) adconfiginit(); var content = adcontent(url, pic, width, height); if (mode == "popup") { adpopup(id, title, content, width, height, top, side, autoclose); return; } var html = ""; if (showbutton == 1) { html = html + ""; } else if (showbutton == 2) { html = html + ""; } html = html + content + ""; document.writeln(html); var obj = document.getelementbyid("adver_" + id); var obj2 = document.getelementbyid("shut_" + id); switch(mode) { case "float": adfloat(obj, obj2, width, height, top, side, autoclose, showbutton); break; case "hangl": adhangleft(obj, obj2, top, autoclose, showbutton); break; case "hangr": adhangright(obj, obj2, top, autoclose, showbutton); break; } } function adcontent(url, pic, width, height) { var pictype = pic.substr(pic.lastindexof(".") + 1).tolowercase(); var content; if (pictype == "swf") { content = ""; if (url != "") content = "" + content; else content = "" + content; } else { content = ""; if (url != "") content = "" + content + ""; } return content; }