﻿var un="undefined",glideImgCount=3,parentDiv="",glideDivId="glideDiv",plDivW=0,plDivH=0,imgW=0,imgH=0,imgIndex=1,imgLength=1,plDivId="pl_c",imgId="p",plCss="p_list",tn=0,imgArr=[],imgArrB=[],imgArrUrl=[],imgArrFont=[],imgTempArr=[imgArr,imgArrB,imgArrUrl,imgArrFont],photoSlide={preload:function(){$("#caseimageurl").html("<img id='caseimage' src='' alt=''>");$.each(itemList,function(a,b){imgTempArr[tn].push(b);tn++;if(tn==4)tn=0});move_length=imgW=plDivW=parseFloat($("#casethumbnail").css("width"))/glideImgCount;imgH=plDivH=parseFloat($("#casethumbnail").css("height"));
parentDiv=photoSlide.getEle(glideDivId);if(imgArr.length<glideImgCount)glideImgCount=imgArr.length;photoSlide.appendImg(0,glideImgCount);photoSlide.m.changeMoveSpeed();photoSlide.imgOnload(photoSlide.getEle("0"+imgId))},fillArr:function(a,b){$("#"+a+" li").each(function(){typeof $(this).html()=="string"&&b.push($(this).html())})},getEle:function(a){return $("#"+a)},imgShow:function(a){$("#loadingbar").css("display","none");$("#caseimageurl").attr("href",imgArrUrl[parseInt(a.attr("id"))]);$("#viewdetail").attr("href",imgArrUrl[parseInt(a.attr("id"))]);photoSlide.getEle("caseimage").attr("src",
imgArrB[parseInt(a.attr("id"))]);$("#caseimage").css("display","block");photoSlide.m.autoMove()},appendImg:function(a,b){if(!(b>imgArr.length)){if(typeof a!=un&&typeof b==un){imgLength++;photoSlide.createImg(a)}if(typeof a!=un&&typeof b!=un){imgLength=b;for(a=a;a<b;a++)photoSlide.createImg(a)}parentDiv.css("width",plDivW*imgLength+"px")}},createImg:function(a){var b=document.createElement("div");b.setAttribute("id",plDivId+a);var c=document.createElement("img");c.setAttribute("id",a+imgId);b.appendChild(c);
parentDiv.append(b);photoSlide.setAttr(a)},setAttr:function(a){var b=$("#"+plDivId+a),c=$("#"+a+imgId);b.attr("class",plCss);b.css("width",plDivW+"px");b.css("height",plDivH+"px");b.css("float","left");b.css("textAlign","center");c.attr("src",imgArr[a]);c.click(function(){photoSlide.imgOnload(c)});c.css("width",imgW-4+"px");c.css("height",imgH+"px")},imgOnload:function(a){clearTimeout(auto_move_t);$("#loadingbar").css("display","block");$("#caseimage").css("display","none");$("#casename").html(imgArrFont[parseInt(a.attr("id"))]);
var b=$("<img>");b.attr("src",imgArrB[parseInt(a.attr("id"))]);b[0].complete?photoSlide.imgShow(a):b.load(function(){photoSlide.imgShow(a)})}},move_count=1,move_speed=3,move_time=1,move_length=plDivW,click_bool=true,auto_move_time=5E3,auto_move_bool=true,auto_move_count=0,auto_move_t;
photoSlide.m={changeMoveSpeed:function(){var a=navigator.userAgent.toLowerCase(),b=0;if(window.ActiveXObject)b=parseInt(a.match(/msie ([\d.]+)/)[1]);if(b==8){move_time=3;move_speed=10}},move:function(a){var b=parseFloat(parentDiv.css("marginLeft"))+a;parentDiv.css("marginLeft",b+"px");move_count+=Math.abs(a);if(photoSlide.m.checkMoveLength(a))if(move_count<move_length){click_bool=false;setTimeout("photoSlide.m.move("+a+")",move_time)}else click_bool=true;else click_bool=true},checkMoveLength:function(a){var b=
move_length%move_speed==0?0:move_length%move_speed;if(move_count+b>=move_length){a=a/Math.abs(a);parentDiv.css("marginLeft",parseFloat(parentDiv.css("marginLeft"))+a*b+"px");move_length*(imgIndex-1)-Math.abs(parseFloat(parentDiv.css("marginLeft")))>=1&&parentDiv.css("marginLeft",parseFloat(parentDiv.css("marginLeft"))+a+"px");return false}else return true},autoMove:function(){if(imgArr.length!=1){auto_move_t=setTimeout(function(){if(auto_move_bool){if(auto_move_count==imgArr.length-1){auto_move_bool=
false;auto_move_count-=1}else auto_move_count++;photoSlide.imgOnload(photoSlide.getEle(auto_move_count+imgId));moveto_Right()}else{if(auto_move_count==0){auto_move_bool=true;auto_move_count+=1}else auto_move_count--;photoSlide.imgOnload(photoSlide.getEle(auto_move_count+imgId));moveto_Left()}},auto_move_time);var a=$("<img>");a.attr("src",imgArrB[parseInt(photoSlide.getEle(auto_move_count+1+imgId).attr("id"))]);a.complete||a.load()}}};
function toRight(){if(click_bool){clearTimeout(auto_move_t);auto_move_bool=true;auto_move_count=imgIndex;moveto_Right();photoSlide.m.autoMove()}}function toLeft(){if(click_bool){clearTimeout(auto_move_t);auto_move_bool=false;auto_move_count=imgIndex;moveto_Left();photoSlide.m.autoMove()}}function moveto_Right(){move_count=1;imgLength<imgArr.length&&photoSlide.appendImg(imgLength);if(imgIndex+(glideImgCount-1)!=imgArr.length){photoSlide.m.move(move_speed-move_speed*2);imgIndex++}}
function moveto_Left(){move_count=1;if(imgIndex!=1){photoSlide.m.move(move_speed);imgIndex--}};

