function overall(root){ var root = root || document; var re = /j_([\w_]+)/; var funcs = {}; $(".js",root).each(function(i) { var m = re.exec(this.classname); if (m) { var f = funcs[m[1]]; if (!f) { f = eval('cf.' + m[1].replace(/\_/gi,'.')); funcs[m[1]] = f; } f && f(this); } }); } var cf = new object(); cf.common = { //tabs切换 tabs: function(obj) { $('>ul', obj).tabs(); }, //下拉菜单 dropmenu: function(obj) { $('li', obj).hover(function() { $('ul', this).fadein(); }, function() { $('ul', this).hide(); }); }, productsaleclick: function(obj) { var next = $(obj).parent().next(); $(obj).click(function() { next.show(); cf.common.productsale(next); return false; }); $('#product-sale-close').click(function() { next.hide(); }); }, productsale: function(obj) { $('dd:eq(0)>ul>li', obj).hover(function() { $(this).addclass('current'); }, function() { $(this).removeclass('current'); }); }, //插入圆角 corner: function(obj) { if ($.browser.msie && $.browser.version == '6.0') { var obj = $(obj); var height = obj.height(); var outerheight = obj.outerheight(); if (outerheight % 2 != 0) { obj.height(height + 1); } } $('
').appendto(obj); }, //用户面板显隐 userpannel: { insertiframe: function() { if ($.browser.msie && $.browser.version == '6.0') { var siframe = ''; $('#userpannel').append(siframe); $('#userpannel-pop .module-popbox').append(''); } }, showprompt: function(elem) { var obj = $(elem); obj.show(); $('a.close', obj).click(function() { $(obj).hide(); if (elem == "#userpannel-prompt") setiecookie('userpannel', 'close'); if (elem == "#userpannel-userinfo")setiecookie('userinfo','close'); return false }); }, click: function(obj) { var obj = $(obj); var href = obj.attr('href').tostring().match(/#(.*)/)[1]; var popid = $('#' + href); obj.click(function() { popid.show() return false; }); $('a.close', popid).click(function() { popid.hide(); return false }); }, //mouseover hover: function(obj) { var obj = $(obj); var href = obj.attr('href').tostring().match(/#(.*)/)[1]; var popid = $('#' + href); obj.hover(function() { popid.show(); }, function() { popid.hide(); }); }, //pop mouseover pophover: function(obj) { $('div[id][id!="userpannel-prompt"][id!="userpannel-userinfo"][id!="userpannel-userlogin"]', obj).hover(function() { $(this).show(); }, function() { $(this).hide(); }); } }, //hover行变色(公用) linehovercolor: function(obj) { $(obj).children().hover(function() { $(this).addclass('current'); }, function() { $(this).removeclass('current'); }); }, linehovercurrent: function(obj) { $(obj).children().click(function() { $(this).parent().find('.current').removeclass(); $(this).addclass('current'); }); } } //首页 cf.index = { //促销产品跑马灯 carouseproduct: function(obj){ var obj = $(obj); var prevchild = obj.prev(); var visible = 3; var linums = $('li', obj).length; var pagenum = math.ceil( linums/visible ); var pagestr = ''; prevchild.append(''); var jcarouselitenav = $('>ul.jcarouselitenav', prevchild); for(var i = 0; i < pagenum; i++){ pagestr += '
  • ' + (i + 1) + '
  • '; } jcarouselitenav.prepend('' + pagestr + ' '); $('>li .1', jcarouselitenav).parent().addclass('current'); if(linums <=visible){ jcarouselitenav.hide(); } obj.jcarousellite({ btnnext: $('>li.next ', jcarouselitenav), btnprev: $('>li.prev a', jcarouselitenav), visible: visible, scroll: visible, speed: 1000, afterend: function(a){ $('>li.current', jcarouselitenav).removeclass('current'); var currli = $(a[0]).attr("class").split('order')[1]; $('>li:eq(' + currli + ')', jcarouselitenav).addclass('current'); }, btngo: $('>li:not([class*=previous]):not([class*=next]) a', jcarouselitenav) }) var width = obj.width(); obj.width( width - 3 ); }, //最新卖场和省心生活跑马灯 carouseother: function(obj){ var obj = $(obj); var prevchild = obj.prev(); var pagenum = 3; var pagestr = ''; prevchild.append(''); var jcarouselitenav = $('>ul.jcarouselitenav', prevchild); for(var i = 0; i < pagenum; i++){ pagestr += '
  • ' + (i + 1) + '
  • '; } jcarouselitenav.prepend('' + pagestr + ' '); $('>li .1', jcarouselitenav).parent().addclass('current'); obj.jcarousellite({ btnnext: $('>li.next ', jcarouselitenav), btnprev: $('>li.prev a', jcarouselitenav), visible: 1, scroll: 1, speed: 1000, afterend: function(a){ $('>li.current', jcarouselitenav).removeclass('current'); var currli = $(a[0]).attr("class").split('order')[1]; $('>li:eq(' + currli + ')', jcarouselitenav).addclass('current'); }, btngo: $('>li:not([class*=previous]):not([class*=next]) a', jcarouselitenav) }) } } cf.other = { picchange: function(obj){ $(obj).before('
    ').find('ul').cycle({ fx:'fade', timeout: 3000, next:obj, pager:'#project-pic-nav', pageevent:null }) } } function getcookie(name) { var arr = document.cookie.match(new regexp("(^| )"+name+"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; } //写cookies函数 function setiecookie(name,value)//两个参数,一个是cookie的名子,一个是值 { document.cookie = name + "="+ escape (value) + ";path=/;"; } function setuserpannel() { var cookie = getcookie('userpannel'); if(cookie != 'close') { cf.common.userpannel.showprompt('#userpannel-prompt'); } } function setuseruserinfopannel() { var cookie = getcookie('userinfo'); if (cookie != 'close') { cf.common.userpannel.showprompt('#userpannel-userinfo'); } } $(function() { overall(); setuserpannel(); setuseruserinfopannel(); })