var babyzone = function() { function id(name) {return document.getelementbyid(name);} //遍历函数 function each(arr, callback) { if (arr.foreach) {arr.foreach(callback);} else { for (var i = 0, len = arr.length; i < len; i++) callback.call(this, arr[i], i, arr);} } function fadein(elem) { setopacity(elem, 0) for ( var i = 0; i < 20; i++) { (function() { var pos = i * 5; settimeout(function() { setopacity(elem, pos) }, i * 25); })(i); } } function fadeout(elem) { for ( var i = 0; i <= 20; i++) { (function() { var pos = 100 - i * 5; settimeout(function() { setopacity(elem, pos) }, i * 25); })(i); } } // 设置透明度 function setopacity(elem, level) { if (elem.filters) { elem.style.filter = "alpha(opacity=" + level + ")"; } else { elem.style.opacity = level / 100; } } return { //count:图片数量,wrapid:包裹图片的div,ulid:按钮div, infoid:信息栏 scroll : function(count,wrapid,ulid,infoid) { var self=this; var targetidx=0; //目标图片序号 var curindex=0; //现在图片序号 //添加li按钮 var frag=document.createdocumentfragment(); this.num=[]; //存储各个li的应用,为下面的添加事件做准备 this.info=id(infoid); for(var i=0;i