// Document Js var ldd = {}; ldd.tool = {}; ldd.tool.getByClass = function (oParent, sClass) { if (oParent.getElementsByClassName) { return oParent.getElementsByClassName(sClass); } else { var aEle = oParent.getElementsByTagName('*'); var re = new RegExp('(^|\\s)' + sClass + '($|\\s)', 'i'); var aRes = []; for(var i = 0; i < aEle.length; i++){ if(re.test(aEle[i].className)){ aRes.push(aEle[i]); } } return aRes; } }; ldd.tool.getStyle = function (obj, attr) { if (obj.currentStyle) { return obj.currentStyle[attr]; } else { return getComputedStyle(obj, false)[attr]; } }; ldd.ui = {}; ldd.ui.move = function(obj,json,endFn) { clearInterval(obj.timer); obj.timer = setInterval(function(){ var bBtn = true; for(var attr in json){ var iCur = 0; if(attr == 'opacity'){ if(Math.round(parseFloat(ldd.tool.getStyle(obj,attr))*100)==0){ iCur = Math.round(parseFloat(ldd.tool.getStyle(obj,attr))*100); }else{ iCur = Math.round(parseFloat(ldd.tool.getStyle(obj,attr))*100) || 100; } }else{ iCur = parseInt(ldd.tool.getStyle(obj,attr)) || 0; } var iSpeed = (json[attr] - iCur)/8; iSpeed = iSpeed >0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); if(iCur!=json[attr]){ bBtn = false; } if(attr == 'opacity'){ obj.style.filter = 'alpha(opacity=' +(iCur + iSpeed)+ ')'; obj.style.opacity = (iCur + iSpeed)/100; }else{ obj.style[attr] = iCur + iSpeed + 'px'; } } if(bBtn){ clearInterval(obj.timer); if(endFn){ endFn.call(obj); } } },30); }; ldd.app = {}; ldd.app.noticePlay = function () { var oNotice = ldd.tool.getByClass(document,'notice')[0]; var oUl = oNotice.getElementsByTagName('ul')[0]; var aLi = oUl.getElementsByTagName('li'); var iNow = 0; var timer = null; oUl.innerHTML += oUl.innerHTML; oUl.style.height = aLi.length * aLi[0].offsetHeight + 'px'; timer = setInterval(autoPlay, 3000); oUl.onmouseover = function () { clearInterval(timer); }; oUl.onmouseout = function () { timer = setInterval(autoPlay, 3000); }; function autoPlay () { if (iNow == aLi.length/2) { iNow = 0; oUl.style.top = 0; } iNow++; ldd.ui.move(oUl, {top:-iNow * aLi[0].offsetHeight}); } }; ldd.app.searchTip = function () { var oSearch = ldd.tool.getByClass(document, 'search')[0]; var oText = ldd.tool.getByClass(oSearch, 'sea_v')[0]; var str = '关键词'; oText.onfocus = function () { if (oText.value == str) { oText.value = ''; } }; oText.onblur = function () { if (oText.value == '') { oText.value = str; } }; }; ldd.app.bannerBtn = function () { var oWrap = ldd.tool.getByClass(document,'flexslider')[0]; var oBtn = ldd.tool.getByClass(oWrap,'flex-direction-nav')[0]; oWrap.onmouseover = function () { oBtn.style.display = 'block'; }; oWrap.onmouseout = function () { oBtn.style.display = 'none'; }; };