/*网站底部返回顶部*/ $(function(){ $('#returntop').bind('click',function(){ $('html,body').animate({scrolltop:$('.header').offset().top},500); return false; }); $(window).scroll(function(){ if ($(document).scrolltop()>=1000) { $("#casel").addclass('infadel'); $("#caser").addclass('infader'); } }) $("#submit").click(function(){ if($(".form input[name='username']").val()==''){ alert("联系人姓名不能为空!") return false } if($(".form input[name='tel']").val()==''){ alert("联系电话不能为空!") return false } if($(".form textarea[name='content']").val()==''){ alert("留言内容不能为空!") return false } }) }) /*首页留言*/ $(function(){ focus_blur_val(".search_cnt input,.main5input input,.main5text textarea"); reg("#searchform",".txt"); }) $(function(){ $("#form_do").submit(function(){ var username = $("input[name='username']").val(), tel = $("input[name='tel']").val(), texar = $(".texar").val(); if(username == "您的姓名" || $.trim(username) == ""){ $("input[name='username']").css('border-color','red'); return false; }else if (tel == "您的电话" || $.trim(tel) == ""){ $("input[name='tel']").css('border-color','red'); return false; }else if($("#form_do textarea").hasclass("texar")){ if(texar == "您的留言" || $.trim(texar) == ""){ $(".texar").css('border-color','red'); return false; } } }) }) function focus_blur_val(classname){ $(classname).bind("focus",function(){ var this_val=$(this).val(); if(this_val==this.defaultvalue){ $(this).val(""); } }).bind("blur",function(){ var this_val=$(this).val(); if(this_val==""){ $(this).val(this.defaultvalue); } }) } /*表单验证*/ function reg(ele_name,txt){ var load_name = $(txt).val(); $(ele_name).submit(function(){ var name = $(txt).val(); if($.trim(name)=='' || name == load_name){ $(txt).css('border-color','red'); $(txt).focus(); return false; } }) } /*******以下不得删除*******/ /*产品内页产品放大左右滚动效果*/ $(function(){ $(".items ul li img").hover(function(){ var img_url=$(this).attr("src"); $(this).closest(".showb_scroll").siblings(".showb_preview").children("span").children("img").attr("src",img_url); /*var img_bimg=$(this).attr("bimg"); $(this).closest(".showb_scroll").siblings(".showb_preview").children("span").children("img").attr("jqimg",img_bimg);*/ }) /*if($(".showb_preview").children(".jqzoom").length>0){ $(".jqzoom").jqueryzoom({xzoom:380,yzoom:410}); }*/ //下一张 //var templength = 0; //临时变量,当前移动的长度 $(".showb_scroll .next").bind("click",function(){ var templength = number($(this).parent(".showb_scroll").attr("bimg")) var viewnum = 1; //设置每次显示图片的个数量 var movenum = 2; //每次移动的数量 var movetime = 300; //移动速度,毫秒 var scrolldiv = $(this).siblings(".items").children("ul")//$(".showb_scroll .items ul"); //进行移动动画的容器 var scrollitems = $(this).siblings(".items").children("ul").children("li")//$(".showb_scroll .items ul li"); //移动容器里的集合 var movelength = scrollitems.eq(0).width() * movenum; //计算每次移动的长度 var countlength = (scrollitems.length - viewnum) * scrollitems.eq(0).width(); //计算总长度,总个数*单个长度 if(templength < countlength){ if((countlength - templength) > movelength){ scrolldiv.animate({left:"-=" + movelength + "px"}, movetime); templength += movelength; $(this).parent(".showb_scroll").attr("bimg",templength) }else{ scrolldiv.animate({left:"-=" + (countlength - templength) + "px"}, movetime); templength += (countlength - templength); $(this).parent(".showb_scroll").attr("bimg",templength) } } }); //上一张 $(".showb_scroll .prev").bind("click",function(){ var templength = number($(this).parent(".showb_scroll").attr("bimg")) var viewnum = 1; //设置每次显示图片的个数量 var movenum = 2; //每次移动的数量 var movetime = 300; //移动速度,毫秒 var scrolldiv = $(this).siblings(".items").children("ul")//$(".showb_scroll .items ul"); //进行移动动画的容器 var scrollitems = $(this).siblings(".items").children("ul").children("li")//$(".showb_scroll .items ul li"); //移动容器里的集合 var movelength = scrollitems.eq(0).width() * movenum; //计算每次移动的长度 var countlength = (scrollitems.length - viewnum) * scrollitems.eq(0).width(); //计算总长度,总个数*单个长度 if(templength > 0){ if(templength > movelength){ scrolldiv.animate({left: "+=" + movelength + "px"}, movetime); templength -= movelength; $(this).parent(".showb_scroll").attr("bimg",templength) }else{ scrolldiv.animate({left: "+=" + templength + "px"}, movetime); templength = 0; $(this).parent(".showb_scroll").attr("bimg",templength) } } }); }); $(function(){ $(".worklist2").caroufredsel({ direction: 'left', prev: '#case_progress_prev2', next: '#case_progress_next2', circular: true, infinite: true, items: { visible: 4, minimum: 4 }, align: false, auto: { play: true, timeoutduration: 1000 }, scroll:{ items:1, pauseonhover: true } }); //设计案例切换 $('.case_list li:first').addclass('tabon'); $('div.tabwrp:first').show(); $('.case_list li').hover(function(){ var liindex = $('.case_list li').index(this); $(this).addclass('tabon').siblings().removeclass('tabon'); $('div.tabwrp').eq(liindex).fadein(150).siblings('div.tabwrp').hide(); var liwidth = $('.case_list li').width(); }); $('div.tabwrp').eq(0).fadein(150).siblings('div.tabwrp').hide(); }); /**/ function zoompic () { this.initialize.apply(this, arguments) } zoompic.prototype = { initialize : function (id) { var _this = this; this.wrap = typeof id === "string" ? document.getelementbyid(id) : id; this.oul = this.wrap.getelementsbytagname("ul")[0]; this.ali = this.wrap.getelementsbytagname("li"); this.prev = this.wrap.getelementsbytagname("pre")[0]; this.next = this.wrap.getelementsbytagname("pre")[1]; this.timer = null; this.asort = []; this.icenter = 3; this._doprev = function () {return _this.doprev.apply(_this)}; this._donext = function () {return _this.donext.apply(_this)}; this.options = [ {width:400, height:240, top:121, left:20, zindex:1}, {width:510, height:305, top:87, left:266, zindex:2}, {width:400, height:240, top:121, left:645, zindex:1} ]; for (var i = 0; i < this.ali.length; i++) this.asort[i] = this.ali[i]; this.asort.unshift(this.asort.pop()); this.setup(); this.addevent(this.prev, "click", this._doprev); this.addevent(this.next, "click", this._donext); }, doprev : function () { this.asort.unshift(this.asort.pop()); this.setup() }, donext : function () { this.asort.push(this.asort.shift()); this.setup() }, setup : function () { var _this = this; var i = 0; for (i = 0; i < this.asort.length; i++) this.oul.appendchild(this.asort[i]); for (i = 0; i < this.asort.length; i++) { this.asort[i].index = i; if (i < 3) { this.css(this.asort[i], "display", "block"); this.domove(this.asort[i], this.options[i], function () { _this.domove(_this.asort[_this.icenter].getelementsbytagname("img")[0], /*{opacity:100},*/ function () { _this.domove(_this.asort[_this.icenter].getelementsbytagname("img")[0],/* {opacity:100},*/ function () { _this.asort[_this.icenter].onmouseover = function () { _this.domove(this.getelementsbytagname("div")[0], {bottom:0}) }; _this.asort[_this.icenter].onmouseout = function () { _this.domove(this.getelementsbytagname("div")[0], {bottom:-100}) } }) }) }); } else { this.css(this.asort[i], "display", "none"); this.css(this.asort[i], "width", 0); this.css(this.asort[i], "height", 0); this.css(this.asort[i], "top", 37); this.css(this.asort[i], "left", this.oul.offsetwidth / 2) } if (i < this.icenter || i > this.icenter) { this.css(this.asort[i].getelementsbytagname("img")[0]/*, "opacity", 30*/) this.asort[i].classname="aaa"+i; this.asort[i].onmouseover = function () { _this.domove(this.getelementsbytagname("img")[0]/*, {opacity:100}*/) }; this.asort[i].onmouseout = function () { _this.domove(this.getelementsbytagname("img")[0]/*, {opacity:35}*/) }; this.asort[i].onmouseout(); } else { this.asort[i].onmouseover = this.asort[i].onmouseout = null } } }, addevent : function (oelement, seventtype, fnhandler) { return oelement.addeventlistener ? oelement.addeventlistener(seventtype, fnhandler, false) : oelement.attachevent("on" + seventtype, fnhandler) }, css : function (oelement, attr, value) { if (arguments.length == 2) { return oelement.currentstyle ? oelement.currentstyle[attr] : getcomputedstyle(oelement, null)[attr] } else if (arguments.length == 3) { switch (attr) { case "width": case "height": case "top": case "left": case "bottom": oelement.style[attr] = value + "px"; break; /*case "opacity" : oelement.style.filter = "alpha(opacity=" + value + ")"; oelement.style.opacity = value / 100; break;*/ default : oelement.style[attr] = value; break } } }, domove : function (oelement, oattr, fncallback) { var _this = this; clearinterval(oelement.timer); oelement.timer = setinterval(function () { var bstop = true; for (var property in oattr) { var icur = parsefloat(_this.css(oelement, property)); property == "opacity" && (icur = parseint(icur.tofixed(2) * 100)); var ispeed = (oattr[property] - icur) / 5; ispeed = ispeed > 0 ? math.ceil(ispeed) : math.floor(ispeed); if (icur != oattr[property]) { bstop = false; _this.css(oelement, property, icur + ispeed) } } if (bstop) { clearinterval(oelement.timer); fncallback && fncallback.apply(_this, arguments) } }, 30) } }; window.onload = function () { new zoompic("box"); };