$(document).ready(function(){ var idocwidth = $(document).width(); //收藏本站 function addfavorite(title, url) { try { window.external.addfavorite(url, title); } catch (e) { try { window.sidebar.addpanel(title, url, ""); } catch (e) { alert("抱歉,您所使用的浏览器无法完成此操作。\n\n加入收藏失败,请使用ctrl+d进行添加"); } } } // 搜索 var osearchbtn = $("#search-btn"); var smodules = $("#smodules").val(); osearchbtn.click(function(){ keywords = $("#keywords").val(); if(!keywords){ alert('请输入查询关键字'); return false; } location.href = 'index.php?r='+smodules+'/search/index&keywords='+keywords; }); // 回车按键 $('#keywords').keydown(function(e){ if(e.keycode==13){ keywords = $("#keywords").val(); if(!keywords){ alert('请输入查询关键字'); return false; } location.href = 'index.php?r='+smodules+'/search/index&keywords='+keywords; return false; } }); // 高级搜索 var ohighsearchbtn = $("#high-search-btn"); ohighsearchbtn.click(function(){ highkeywords = $("#high-keywords").val(); searchtype = $("#searchtype").val(); if(!highkeywords){ alert('请输入查询关键字'); return false; } location.href = 'index.php?r='+smodules+'/search/highsearch&keywords='+highkeywords+'&searchtype='+searchtype; }); // 语言选择 var oselectlang = $("#lang"); var smodules = oselectlang.find("option:selected").val(); var alang = ['index','en','jap','kor']; oselectlang.change(function(){ var slang = $(this).val(); /* if(alang.indexof(slang)==-1){ // 如果语言选择不在给定数组中,则为中文 slang = 'index'; } */ if(jquery.inarray(slang,alang)==-1){ // 如果语言选择不在给定数组中,则为中文 slang = 'index'; } location.href = 'index.php?r='+slang+'/index/index'; }); // nav导航 $(".nav-item").each(function(idx){ var inavitem = idx; inavitem += 1; $(this).mouseover(function(){ $(".child-nav-"+inavitem).css('display','block'); }); $(this).mouseout(function(){ if($(".child-nav-"+inavitem).css('display')=='block'){ $(".child-nav-"+inavitem).css('display','none'); }else{ $(".child-nav-"+inavitem).css('display','block'); } }); $(".child-nav-"+inavitem).mouseover(function(){ $(".child-nav-"+inavitem).css('display','block'); }); $(".child-nav-"+inavitem).mouseout(function(){ $(".child-nav-"+inavitem).css('display','none'); }); }); // nav导航底部line移动 var iactivenav = 0; $(".nav .nav-div").each(function(idx){ if($(this).hasclass('active')){ iactivenav = idx; } $(this).mouseover(function(){ //$("#nav-line").animate({'left':idx*114},'normal'); }); $(this).mouseout(function(){ //$("#nav-line").animate({'left':iactivenav*114},'normal'); }); }); $("#nav-line").animate({'left':iactivenav*114},'normal'); // 首页产品切换 clickarrow1('prod-left-arrow','index-product-container','index-product-content-box',0,1,'-1','',1); clickarrow1('prod-right-arrow','index-product-container','index-product-content-box',0,1,'1','',1); /** * 点击箭头切换图片 * @param clkid id 点击id * @param movecontainer class 移动的整个外容器 * @param movebox class 移动的小容器 * @param moveboxmargin num 移动小容器的margin值 * @param margintype num 移动小容器margin类型 1-marginright -1-marginleft * @param mtype num 移动方向 1-右移 -1-左移 * @param smallbox 小图盒子 * @param ipernum 每次移动的盒子个数 * * */ // 移动到的盒子索引值 var amovecounter = []; amovecounter['index-news-box'] = 0; amovecounter['index-product-content-box'] = 0; amovecounter['big-img-box'] = 0; function clickarrow1(clkid,movecontainer,movebox,moveboxmargin,margintype,mtype,smallbox,ipernum){ // 移动的盒子个数 var imoveboxlen = $("."+movecontainer).find("."+movebox).length; // 每个移动的box的宽度 var imoveboxwidth = parseint($("."+movebox).width()); $("#"+clkid).click(function(){ if(mtype==1){ // 右移 // 整个盒子当前的marginleft var imarginleft = parseint($("."+movecontainer).css('marginleft')); amovecounter[movebox]++; if((!ipernum && amovecounter[movebox]>=imoveboxlen) || (ipernum && amovecounter[movebox]>=imoveboxlen-ipernum+1)){ // 如果盒子移动到最右 amovecounter[movebox]--; return false; }else{ imarginleft = imarginleft - imoveboxwidth - moveboxmargin; $("."+movecontainer).animate({'marginleft':imarginleft},'slow'); } }else{ // 左移 // 整个盒子当前的marginleft var imarginleft = parseint($("."+movecontainer).css('marginleft')); amovecounter[movebox]--; if(amovecounter[movebox]<0){ // 如果盒子移动到最左 amovecounter[movebox] = 0; return false; }else{ imarginleft = imarginleft + imoveboxwidth + moveboxmargin; $("."+movecontainer).animate({'marginleft':imarginleft},'slow'); } } // 如果有小图 或者切换point if(smallbox) { var asmallboxli = $("."+smallbox).find("li"); changepointclass(amovecounter[movebox]); } });// click end if(smallbox){ var asmallboxli = $("."+smallbox).find("li"); // 整个盒子当前的marginleft asmallboxli.each(function(idx){ // 点击小图 $(this).click(function(){ var imarginleft = parseint($("."+movecontainer).css('marginleft')); if(amovecounter[movebox]>idx){ // 如果点击的小图在当前显示的图的前面,则右移 imarginleft = imarginleft + (amovecounter[movebox]-idx)*imoveboxwidth; $("."+movecontainer).animate({'marginleft':imarginleft},'slow'); // 修改当前显示图的索引值 amovecounter[movebox] = idx; // 为当前li添加active类 changepointclass(idx); return ; }else if(amovecounter[movebox]