
var $div=null;var Value=null;var imgWidth=null;var imgHeight=null;var $targetImg=$('#target');var placeMsg={};jQuery(function($){var b=$("#d1897_ExampleImgUrl_hid");$div=b.prev();imgWidth=$div.attr("imgWidth");imgHeight=$div.attr("imgHeight");if(!isNaN(imgWidth))imgWidth=parseInt(imgWidth,10);else imgWidth=200;if(!isNaN(imgHeight))imgHeight=parseInt(imgHeight,10);else imgHeight=200;Value="/UpLoadFiles/common/blank.png";var c=1897;var d="AjaxF_";var e=false;var f=false;$div.find(":file").each(function(){var a=this;$(a).unbind("click").bind("click",function(){sjg(a,c,d,e,true)}).unbind("change").bind("change",function(){eor(a,c,d,e,true)})});sye()});function sye(){var d;var e;var f;var g=$('#divImg1');var i=$('#divImg2');var k=$('#divImg3');var l=$('#allImgs');var m=g.find("img[imgsize=1]");var n=i.find("img[imgsize=2]");var o=k.find("img[imgsize=3]");var p=g.children('.preview-container').width();var q=g.children('.preview-container').height();var r=i.children('.preview-container').width();var s=i.children('.preview-container').height();var t=k.children('.preview-container').width();var u=k.children('.preview-container').height();$targetImg=$('#target');$targetImg.Jcrop({onChange:edp,gbt:edp,aspectRatio:p/q},function(){var a=this.getBounds();e=a[0];f=a[1];d=this;d.setOptions({bgColor:'white',bgOpacity:0.5});g.appendTo(d.ui.holder);i.appendTo(d.ui.holder);k.appendTo(d.ui.holder);d.animateTo([10,10,$targetImg.width()-10,$targetImg.height()-10])});function edp(c){placeMsg={"x1":c.x,"y1":c.y,"x2":c.x2,"y2":c.y2,"w":c.w,"h":c.h,sw:e,sh:f};if(parseInt(c.w)>0){var a=p/c.w;var b=q/c.h;var j={width:Math.round(a*e)+'px',height:Math.round(b*f)+'px',marginLeft:'-'+Math.round(a*c.x)+'px',marginTop:'-'+Math.round(b*c.y)+'px'};m.css(j);var a=r/c.w;var b=s/c.h;var j={width:Math.round(a*e)+'px',height:Math.round(b*f)+'px',marginLeft:'-'+Math.round(a*c.x)+'px',marginTop:'-'+Math.round(b*c.y)+'px'};n.css(j);var a=t/c.w;var b=u/c.h;var j={width:Math.round(a*e)+'px',height:Math.round(b*f)+'px',marginLeft:'-'+Math.round(a*c.x)+'px',marginTop:'-'+Math.round(b*c.y)+'px'};o.css(j)}};$.qju({id:"#"+$div.attr("id"),container:$div,nas:imgWidth,mode:"remote",maxHeight:imgHeight,width:imgWidth,height:imgHeight,imgPath:Value,onShow:function(){d.setImage($(this.img).attr("src"));m.attr("src",$(this.img).attr("src"));n.attr("src",$(this.img).attr("src"));o.attr("src",$(this.img).attr("src"));e=$(this.img).width();f=$(this.img).height();var x=10;var y=10;var w=e;var h=f;if(w>h){y=5;h=h-5;w=h;x=(e-f)/2;if(x<10)x=10}else{x=5;w=w-5;h=w;y=(f-e)/2;if(y<10)y=10}
d.animateTo([x,y,w,h]);d.setOptions({bgOpacity:.6})}})}
function tjb(a){rotate("pImg1",'left')}
function fom(a){rotate("target",'right')}
function rotate(o,p){var a=document.getElementById(o);Dcx.Rotate(a,p)}
function rux(c){var d=1897;var f="AjaxF_";var g=new Array();var h={EntId:d,RowIndex:1,Items:[]};h.Items=new Array();g.push(h);var v=$("#d1897_ExampleImgUrl_hid").val();var i=$("#d1897_ExampleImgUrl_file");var j={"FId":336,"FN":"ExampleImgUrl","Value":v,"NewFile":null,"OldValue":null,"Obj":i,Other:placeMsg};g[0].Items.push(j);var k=false;var l=false;$.bpd(g,{url:'/Ajax/UploadAvatar.ashx',secureuri:false,fileElementId:'fileToUpload',dataType:'text',success:function(a){a=hmy(a);k=true;if(a.indexOf("ChangeIsOk")>=0)art.VLdialog.tips("保存成功",1.8);else art.VLdialog.tips("保存失败，请重试。",1.8)},error:function(a,b,e){l=true;if(b=='error'){alert(e)}},complete:function(a,b){l=true}})}