var Debug=function(a,b){$("#Debug")||$("body").append("<div id='Debug'></div>"),b?$("#Debug").html($("#Debug").html()+"<br/>"+a):$("#Debug").html($("#Debug").html()+a)},max_ImageSwitch_Effect_ID=0;(function(a){a.fn.ImageSwitch=function(b,c){var d={Type:"FadeIn",NewImage:"",EffectOriginal:!0,Speed:1e3,StartLeft:50,StartTop:0,StartOpacity:0,EndLeft:-50,EndTop:0,EndOpacity:0,Direction:"RightLeft",Door1:"",Door2:""},e=a.extend(d,b),f=this,g=0,h,i,j,k=function(){f.data("imageswitch",-1)};a.isFunction(c)&&(k=function(){c(),f.data(f,-1)});var l=function(){f.parent().append("<img class='GrpEffectImg' id='"+h.replace("#","")+"'/>"),a(h).attr("src",f.attr("src")),a(h).css("position","absolute"),a(h).css("top",f.position().top),a(h).css("left",f.position().left),a(h).css("opacity",1),f.attr("src",e.NewImage),e.EffectOriginal&&(f.css("opacity",e.StartOpacity),f.animate({opacity:1},e.Speed)),a(h).animate({opacity:0},e.Speed,function(){a(h).remove(),k()})},m=function(b){a("body").append("<img class='GrpEffectImg' id='"+h.replace("#","")+"'/>"),a(h).css("position","absolute"),b?(a(h).attr("src",e.NewImage),a(h).css("top",f.offset().top+e.StartTop),a(h).css("left",f.offset().left+e.StartLeft),a(h).css("opacity",e.StartOpacity),EndTop=f.offset().top,EndLeft=f.offset().left,EndOpacity=1):(a(h).attr("src",f.attr("src")),f.attr("src",e.NewImage),a(h).css("top",f.offset().top),a(h).css("left",f.offset().left),a(h).css("opacity",1),EndTop=f.offset().top+e.EndTop,EndLeft=f.offset().left+e.EndLeft,EndOpacity=e.EndOpacity),a(h).animate({opacity:EndOpacity,top:EndTop,left:EndLeft},e.Speed,function(){f.attr("src",e.NewImage),a(h).remove(),k()})},n=function(b){var c=f.clone(!0);f.wrap("<div id='GrpViewport-"+g+"'></div>"),a("#GrpViewport-"+g).css("overflow","hidden"),a("#GrpViewport-"+g).width(f.width()),a("#GrpViewport-"+g).height(f.height()),a("#GrpViewport-"+g).append("<img class='GrpEffectImg' id='"+h.replace("#","")+"'/>"),a(h).css("position","absolute");var d=0,i=0;switch(e.Direction){case"RightLeft":i=-f.width();break;case"LeftRight":i=f.width();break;case"TopDown":d=-f.height();break;case"DownTop":d=f.height()}b?(a(h).attr("src",e.NewImage),a(h).css("top",d),a(h).css("left",i),a(h).css("opacity",e.StartOpacity),EndTop=0,EndLeft=0,EndOpacity=1):(a(h).attr("src",f.attr("src")),a(h).css("left",0),a(h).css("top",0),f.attr("src",e.NewImage),EndTop=d,EndLeft=i,EndOpacity=e.EndOpacity),f.css("position")!="absolute"?(a("#GrpViewport-"+g).css("position","relative"),f.css("position","absolute")):(a("#GrpViewport-"+g).css("position","absolute"),a("#GrpViewport-"+g).css("left",f.css("left")),a("#GrpViewport-"+g).css("top",f.css("top")),f.css("top",0),f.css("left",0)),e.EffectOriginal&&b&&f.animate({top:-d,left:-i},e.Speed),a(h).animate({opacity:EndOpacity,top:EndTop,left:EndLeft},e.Speed,function(){c.attr("src",e.NewImage),c.removeAttr("imageswitch"),a("#GrpViewport-"+g).replaceWith(c),k()})},o=function(){var b=f.clone(!0);f.wrap("<div id='GrpViewport'></div>"),a("#GrpViewport").css("overflow","hidden"),a("#GrpViewport").width(f.width()),a("#GrpViewport").height(f.height()),a("#GrpViewport").append("<div class='GrpEffectDiv' id='"+i.replace("#","")+"'/>"),a(i).attr("src",e.NewImage),a(i).css("position","absolute"),a(i).css("background-color","#FFF"),e.Door1.length>0&&a(i).css("background",e.Door1),a(i).width(f.width()),a(i).height(f.height());var c=0,d=0;switch(e.Direction){case"RightLeft":d=-f.width();break;case"LeftRight":d=f.width();break;case"TopDown":c=-f.height();break;case"DownTop":c=f.height()}a(i).css("top",c),a(i).css("left",d),f.css("position")!="absolute"?(a("#GrpViewport").css("position","relative"),f.css("position","absolute")):(a("#GrpViewport").css("position","absolute"),a("#GrpViewport").css("left",f.css("left")),a("#GrpViewport").css("top",f.css("top")),f.css("top",0),f.css("left",0)),a(i).animate({top:0,left:0},e.Speed,function(){f.attr("src",e.NewImage),a(i).animate({top:c,left:d},e.Speed,function(){b.attr("src",e.NewImage),b.removeAttr("imageswitch"),a("#GrpViewport").replaceWith(b),k()})})},p=function(){var b=f.css("position"),c=f.css("left"),d=f.css("top");f.wrap("<div id='GrpViewport'></div>"),a("#GrpViewport").css("overflow","hidden"),a("#GrpViewport").width(f.width()),a("#GrpViewport").height(f.height()),a("#GrpViewport").append("<div class='GrpEffectDiv' id='"+i.replace("#","")+"'/>"),a(i).css("position","absolute"),a(i).css("background-color","#FFF"),e.Door1.length>0&&a(i).css("background",e.Door1),a(i).width(f.width()),a(i).height(f.height()),a("#GrpViewport").append("<div class='GrpEffectDiv1' id='"+j.replace("#","")+"'/>"),a(j).css("position","absolute"),a(j).css("background-color","#FFF"),e.Door2.length>0&&a(j).css("background",e.Door2),a(j).width(f.width()),a(j).height(f.height());var g=0,h=0;switch(e.Direction){case"RightLeft":h=-f.width();break;case"LeftRight":h=f.width();break;case"TopDown":g=-f.height();break;case"DownTop":g=f.height()}a(i).css("top",g),a(i).css("left",h),a(j).css("top",-g),a(j).css("left",-h),e.EffectOriginal||(a(i).css("background","#FFF url("+e.NewImage+") no-repeat "+ -h/2+"px "+ -g/2+"px"),a(j).css("background","#FFF url("+e.NewImage+") no-repeat "+h/2+"px "+g/2+"px")),f.css("position")!="absolute"?(a("#GrpViewport").css("position","relative"),f.css("position","absolute")):(a("#GrpViewport").css("position","absolute"),a("#GrpViewport").css("left",c),a("#GrpViewport").css("top",d),f.css("position","absolute"),f.css("top",0),f.css("left",0)),a(i).animate({top:g/2,left:h/2},e.Speed,function(){f.attr("src",e.NewImage),e.EffectOriginal?a(i).animate({top:g,left:h},e.Speed,function(){f.css("position",b),f.css("top",d),f.css("left",c),a("#GrpViewport").replaceWith(f)}):(f.css("position",b),f.css("top",d),f.css("left",c),a("#GrpViewport").replaceWith(f))}),a(j).animate({top:-g/2,left:-h/2},e.Speed,function(){f.attr("src",e.NewImage),e.EffectOriginal?a(j).animate({top:-g,left:-h},e.Speed,function(){k()}):k()})},q=function(b){var c=f.clone(!0);f.css("z-index")=="auto"&&f.css("z-index",100),f.css("position")!="absolute"&&f.css("position","relative"),a("body").append("<img class='GrpEffectImg'  id='"+h.replace("#","")+"'/>"),a(h).css("position","absolute"),a(h).css("top",f.offset().top),a(h).css("left",f.offset().left),b?(a(h).css("opacity",e.StartOpacity),a(h).css("z-index",f.css("z-index")-1),a(h).attr("src",e.NewImage)):(a(h).css("opacity",1),a(h).css("z-index",f.css("z-index")+1),a(h).attr("src",f.attr("src")),f.attr("src",e.NewImage)),Math.abs(e.EndTop)<f.height()&&Math.abs(e.EndLeft)<f.width()?(EndTop=f.offset().top,EndLeft=f.offset().left+f.width()):(EndTop=f.offset().top+e.EndTop,EndLeft=f.offset().left+e.EndLeft),EndOpacity=1,a(h).animate({opacity:EndOpacity,top:EndTop,left:EndLeft},e.Speed,function(){b?a(h).css("z-index",101):(EndOpacity=e.EndOpacity,a(h).css("z-index",2)),a(h).animate({opacity:EndOpacity,top:f.offset().top,left:f.offset().left},e.Speed,function(){c.attr("src",e.NewImage),c.removeAttr("imageswitch"),f.replaceWith(c),a(h).remove(),k()})})};return this.each(function(){f=a(this);if(!f.ImageAnimating()){g=max_ImageSwitch_Effect_ID,max_ImageSwitch_Effect_ID+=1,f.data(f,g),h="#GrpEffectImg-"+g,i="#GrpEffectDiv1-"+g,j="#GrpEffectDiv2-"+g;var b=new Image;b.src=e.NewImage,a.ImagePreload(e.NewImage,function(){switch(e.Type){case"FadeIn":l();break;case"FlyIn":m(!0);break;case"FlyOut":m(!1);break;case"FlipIn":q(!0);break;case"FlipOut":q(!1);break;case"ScrollIn":n(!0);break;case"ScrollOut":n(!1);break;case"SingleDoor":o();break;case"DoubleDoor":p()}})}})}})(jQuery),function(a){a.fn.ImageAnimating=function(){return this.data("imageswitch")>0?!0:!1}}(jQuery),function(a){a.fn.ImageStop=function(b,c,d){return this.each(function(){if(a(this).ImageAnimating()){var e=a.data(this,"imageswitch");a("#GrpEffectImg-"+e).stop(b,c),a("#GrpEffectDiv-"+e).stop(b,c),a("#GrpEffectDiv1-"+e).stop(b,c),a(this).stop(b,c),a("#GrpEffectImg-"+e).remove(),a("#GrpEffectDiv-"+e).remove(),a("#GrpEffectDiv1-"+e).remove(),a.isFunction(d)&&d()}})}}(jQuery),function(a){a.ImageStopAll=function(b,c,d){a(".GrpEffectImg").stop(b,c),a(".GrpEffectDiv").stop(b,c),a(".GrpEffectDiv1").stop(b,c),a(this).stop(b,c),a(".GrpEffectImg").remove(),a(".GrpEffectDiv").remove(),a(".GrpEffectDiv1").remove(),a.data(this,"imageswitch",-1),a.isFunction(d)&&d()}}(jQuery),function(a){a.ImagePreload=function(b,c){var d=new Image;d.src=b,a.isFunction(c)&&a(d).load(c())}}(jQuery)
