function imgzoomer(imgobj, canvas_width, canvas_height) { var obj = imgobj; var src_width = getimagewidth(obj); var src_height = getimageheight(obj); var widthscale = src_width / canvas_width; var heightscale = src_height / canvas_height; if (widthscale >= 1 || heightscale >= 1) { if (widthscale < heightscale) { obj.width = src_width / heightscale; obj.height = canvas_height; } else { obj.width = canvas_width; obj.height = src_height / widthscale; } } else { obj.width = src_width; obj.height = src_height; } }; function getimagewidth(oimage) { var originimage = new image(); originimage.src = oimage.src; return originimage.width; }; function getimageheight(oimage) { var originimage = new image(); originimage.src = oimage.src; return originimage.height; }; function imageviewer(obj, dir) { buildimageviewer(obj, { showtype: 'direct' }); }; function buildimageviewer(obj, option) { if (!$.fn.ospodviewer) { $.ajax({ type: "get", cache: true, url: _contextpath + "/ec/lib/plugins/viewer/viewer.js", datatype: "script", success: function() { $(obj).ospodviewer(option); } }); } else { $(obj).ospodviewer(option); } }; function marquee(elm, width, height, spd, type, wspace) { if (arguments.length < 1) { alert(i18n.marqueeidempty); return false; }; var element = elm; var scrollwidth = width ? width: 800; var scrollheight = height ? height: 200; scrollwidth = parseint(scrollwidth); scrollheight = parseint(scrollheight); var scrollwspace = wspace ? wspace: 5; var scrolltype = type ? type: 3; var speed = spd ? spd: 30; var scrolltext = new array(); var obj1 = document.getelementbyid(element); if (!obj1) { alert(i18n.marqueeillegalparameter); return false; }; obj1.style.height = scrollheight + 'px'; obj1.style.width = scrollwidth + 'px'; obj1.style.border = '0px solid #000'; var obj2 = document.createelement("div"); obj2.id = element + 'obj2'; var obj3 = document.createelement("div"); obj3.id = element + "obj3"; obj2.style.border = '0px solid #000'; var objtab = document.createelement('table'); var objtr = document.createelement('tr'); var objtd = document.createelement('td'); objtd.innerhtml = obj1.innerhtml; obj1.innerhtml = ""; objtab.style.display = "inline"; objtab.cellpadding = "0"; objtab.cellspacing = "0"; objtab.id = element + 'tab'; objtab.style.border = "0px solid #ff0000"; objtd.style.whitespace = "nowrap"; objtr.appendchild(objtd); objtab.appendchild(objtr); obj2.innerhtml = objtab.outerhtml; obj1.appendchild(obj2); obj1.appendchild(obj3); obj3.style.width = obj2.style.width = scrollwidth + 'px'; if (scrolltype == 1 || scrolltype == 2) { if (obj2.offsetheight < scrollheight) { var tabheight = scrollheight - obj2.offsetheight; var tabmarginleft = (obj2.offsetwidth > scrollwidth) ? scrollwidth: (obj2.offsetwidth + scrollwidth) / 2; if (tabheight < 0) { tabheight = 0; } else { obj2.innerhtml += "
"; } } }; document.write(""); if (scrolltype == 3 || scrolltype == 4) { obj1.style.whitespace = "nowrap"; obj2.style.display = ospod.browser.ischrome ? "inline-table": "inline"; var tabwidth = scrollwidth - obj2.offsetwidth; var tabmargintop = (obj2.offsetheight > scrollheight) ? scrollheight: (obj2.offsetheight + scrollheight) / 2; if (tabwidth < 0) { tabwidth = 0; } else { obj2.innerhtml += "
"; } }; obj3.innerhtml = obj2.innerhtml; marquee.prototype.marqueescrolltop = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj1 = document.getelementbyid(element); var obj2 = document.getelementbyid(element + "obj2"); var obj3 = document.getelementbyid(element + "obj3"); if (obj2.offsetheight > scrollheight) if (obj3.offsettop - obj1.scrolltop <= 0) { obj1.scrolltop -= obj3.offsettop; } else { var oldscrolltop = obj1.scrolltop; obj1.scrolltop++; if (oldscrolltop == obj1.scrolltop) { obj1.scrolltop = 0; } } else { if (scrollheight - obj1.scrolltop <= 0) { obj1.scrolltop -= scrollheight; } else { obj1.scrolltop++; } } }; marquee.prototype.marqueescrolldown = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj1 = document.getelementbyid(element); var obj2 = document.getelementbyid(element + "obj2"); var obj3 = document.getelementbyid(element + "obj3"); if (document.all) { if (obj2.offsettop - obj1.scrolltop >= 0) { obj1.scrolltop += obj3.offsetheight; } else { obj1.scrolltop--; } } else { if (obj2.offsettop - obj1.scrolltop - obj2.offsettop >= 0) { obj1.scrolltop += obj3.offsetheight; } else { obj1.scrolltop--; } } }; marquee.prototype.marqueescrollleft = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj1 = document.getelementbyid(element); var obj2 = document.getelementbyid(element + "obj2"); var obj3 = document.getelementbyid(element + "obj3"); if (obj3.offsetwidth - obj1.scrollleft <= 0) { obj1.scrollleft -= obj2.offsetwidth; } else { obj1.scrollleft++; } }; marquee.prototype.marqueescrollright = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj1 = document.getelementbyid(element); var obj2 = document.getelementbyid(element + "obj2"); var obj3 = document.getelementbyid(element + "obj3"); if (obj1.scrollleft <= 0) { obj1.scrollleft += obj3.offsetwidth; } else { obj1.scrollleft--; } }; var count; marquee.prototype.marqueestart = function(element, scrolltype, scrollwidth, scrollheight, speed) { switch (scrolltype) { case 1: if (marquee.prototype.scrolltopordown(element, scrolltype, scrollwidth, scrollheight, speed)) { marquee.prototype.clearinterval(element); count = window.setinterval(marquee.prototype.marqueescrolltop.bind(this, element, scrolltype, scrollwidth, scrollheight, speed), speed); marqueeinterval[element] = count; }; break; case 2: if (marquee.prototype.scrolltopordown(element, scrolltype, scrollwidth, scrollheight, speed)) { marquee.prototype.clearinterval(element); count = window.setinterval(marquee.prototype.marqueescrolldown.bind(this, element, scrolltype, scrollwidth, scrollheight, speed), speed); marqueeinterval[element] = count; }; break; case 3: marquee.prototype.scrollleftorright(element, scrolltype, scrollwidth, scrollheight, speed); marquee.prototype.clearinterval(element); count = window.setinterval(marquee.prototype.marqueescrollleft.bind(this, element, scrolltype, scrollwidth, scrollheight, speed), speed); marqueeinterval[element] = count; break; case 4: marquee.prototype.scrollleftorright(element, scrolltype, scrollwidth, scrollheight, speed); marquee.prototype.clearinterval(element); count = window.setinterval(marquee.prototype.marqueescrollright.bind(this, element, scrolltype, scrollwidth, scrollheight, speed), speed); marqueeinterval[element] = count; break; } }; marquee.prototype.scrollleftorright = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj3 = document.getelementbyid(element + "obj3"); obj3.style.display = ospod.browser.ischrome ? "inline-table": "inline"; }; marquee.prototype.scrolltopordown = function(element, scrolltype, scrollwidth, scrollheight, speed) { var obj2 = document.getelementbyid(element + "obj2"); if (scrollwidth - obj2.offsetwidth < 0) { return true; } else { obj2.style.display = "block"; return true; } }; marquee.prototype.clearinterval = function(element) { var interval; for (var key in marqueeinterval) { if (key == element) { interval = marqueeinterval[key]; break; } }; window.clearinterval(interval); }; obj1.onmouseover = function() { marquee.prototype.clearinterval(element); }; obj1.onmouseout = function() { marquee.prototype.marqueestart(element, scrolltype, scrollwidth, scrollheight, speed); }; marquee.prototype.marqueestart(element, scrolltype, scrollwidth, scrollheight, speed); }; var marqueeinterval = new object(); function addfavorite(surl, stitle) { try { window.external.addfavorite(surl, stitle); } catch (e) { try { window.sidebar.addpanel(stitle, surl, ""); } catch (e) { alert("加入收藏失败,请使用ctrl+d进行添加"); } } }