/*
 * nyroModal - jQuery Plugin
 * http://nyromodal.nyrodev.com
 *
 * Copyright (c) 2008 Cedric Nirousset (nyrodev.com)
 * Licensed under the MIT license
 *
 * $Date: 2008-10-22 (Wed, 22 Oct 2008) $
 * $version: 1.3.0
 */
/*eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4X(8($){j 2t=($.2u.4Y&&43($.2u.44.4Z(0,1))<7);j 14=$(\'14\');j 3;j 1M=m;j 1y;j 21;j 4={3h:m,1a:m,15:m,O:m,1b:m,10:m,1c:m,1z:B,U:B,E:B,c:B,k:B,D:B,2v:m,v:B,2w:1N 3i()};j 1d={6:m,b:m};$.1e.16=8(f){5(!F)r m;r F.2x(8(){5(F.22.2y()==\'1m\'){$(F).51(8(e){5(F.45==\'46/1m-G\'){1n($.J(f,{o:F}));r y}e.1o();1n($.J(f,{o:F}));r m})}q{$(F).1f(8(e){e.1o();1n($.J(f,{o:F}));r m})}})};$.1e.1O=8(f){5(!F.1A)1n(f);r F.2x(8(){1n($.J(f,{o:F}))})};$.1O=8(f){1n(f)};$.52=8(f,11,1B){M(f,11,1B);5(!11&&4.1a){5(f.23)3.2z(4,3,8(){});5((4.15&&!4.O&&!4.10)&&(f.6||f.b)){2A(y);5(1M)4.k.l({12:\'\'});3.2B(4,3,8(){5(1M)4.k.l({12:\'24\'});5($.1p(3.3j))3.3j(4,3)})}}};$.53=8(){1q()};$.26=8(){j 1P=28(1);5(1P)r 1P.1O(3);r m};$.29=8(){j 1P=28(-1);5(1P)r 1P.1O(3);r m};$.1e.16.f={C:m,4:m,z:\'\',o:\'\',2a:\'\',3k:B,2C:\'54\',2D:\'16\',k:B,23:\'#55\',1r:{},1s:{56:\'57\'},6:B,b:B,47:1Q,48:49,58:y,3l:y,13:20,4a:\'[^\\.]\\.(59|5a|5b|5c|5d|5e)\\s*$\',3m:\'3n\',4b:y,4c:y,l:{U:{2E:2b,12:\'24\',2F:0,2G:0,b:\'2b%\',6:\'2b%\'},D:{2E:5f,12:\'24\',2F:\'50%\',2G:\'50%\'},2c:{},k:{1g:\'1C\'},E:{2E:5g,12:\'24\',2F:\'50%\',2G:\'50%\',K:\'-2H\',L:\'-2H\'}},2d:{n:\'<n S="D"></n>\',1r:\'<n S="D"></n>\',1m:\'<n S="D"></n>\',3o:\'<n S="D"></n>\',1t:\'<n S="4d"></n>\',V:\'<n S="4d"><a W="#" S="29">5h</a><a W="#"  S="26">5i</a></n>\',1s:\'<n S="5j"></n>\',P:\'<n S="5k"></n>\',4e:\'<n S="D"></n>\'},4f:\'<a W="#" S="2I" 1h="5l" 1D="5m">4g</a>\',3p:\'.16\',2J:\'.2I\',4h:\'<a W="#" S="2I">5n</a>\',4i:\'1c\',4j:\'5o 5p k 5q 5r 5s.<3q />5t 5u 5v 5w.<3q /><a W="#" S="2I">4g</a>\',3r:B,2K:2K,1R:1R,3s:B,2L:2L,1E:B,3t:B,2e:2e,2M:2M,2N:2N,2O:2O,2f:2f,2B:2B,3j:B,2z:2z,1u:B};8 1n(f){5(4.1b||4.10||4.O)r;C(\'1n\');4.3h=y;3u(f);4.1c=m;4.2v=m;4.15=m;4.2w=1N 3i();3.z=4k();5($.1p(3.3k))3.3k(3);o=3.o;p=3.p;5(3.z==\'1s\'){3.3v=m;M({1g:\'1v\'},\'l\',\'k\');3.k=\'<4l 5x="5y:5z-5A-5B-5C-5D" 6="\'+3.6+\'" b="\'+3.b+\'"><2P T="5E" 1S="\'+p+\'"></2P>\';j c=\'\';$.2x(3.1s,8(T,3w){3.k+=\'<2P T="\'+T+\'" 1S="\'+3w+\'"></2P>\';c+=\' \'+T+\'="\'+3w+\'"\'});3.k+=\'<4m 1F="\'+p+\'" z="5F/x-5G-5H" 6="\'+3.6+\'" b="\'+3.b+\'"\'+c+\'></4m></4l>\'}5(o){5(3.z==\'1m\'){j G=$(o).5I();G.2Q({T:3.2D,1S:1});5(3.Q)G.2Q({T:3.2C,1S:3.Q.1T(1)});$.1r($.J({},3.1r,{p:p,G:G,z:o.5J,4n:3x,1c:17}));C(\'4o 4p 2g: \'+o.2h);1i()}q 5(3.z==\'3o\'){1w();o.2R=\'3y\';o.2h=p;$(o).2S(\'<3z z="1v" T="\'+3.2D+\'" 1S="1" />\');5(3.Q)$(o).2S(\'<3z z="1v" T="\'+3.2C+\'" 1S="\'+3.Q.1T(1)+\'" />\');4.c.H(\'<P 4q="0" 4r="0" T="3y"></P>\');$(\'P\',4.c).l({6:3.6,b:3.b}).1c(17).2T(3A);C(\'4o 5K 2g: \'+o.2h);1i();18()}q 5(3.z==\'1t\'||3.z==\'V\'){j 1D=o.1D||3.3m;1w();4.c.H(\'<1U 1h="4s" />\').3B(\'1U\').1j(\'3C\',1D);C(\'3n 2g: \'+p);$(\'1U\',4.c).1c(17).2T(8(){C(\'3n 5L: \'+F.1F);$(F).3D(\'2T\');j w=4.c.6();j h=4.c.b();M({6:w,b:h,2U:w,2V:h});M({1g:\'1v\'},\'l\',\'k\');4.15=y;5(4.1b||4.10)18()}).1j(\'1F\',p);1i()}q 5(3.z==\'P\'){1w();4.c.H(\'<P 4q="0" 4r="0" 1F="\'+p+\'" T="3y"></P>\');C(\'5M 2g: \'+p);$(\'P\',4.c).2W(0).l({6:\'2b%\',b:\'2b%\'});3.3l=m;4.15=y;1i()}q 5(3.z){C(\'4t: \'+3.z);1w();4.c.H(3.k);j w=4.c.6();j h=4.c.b();j n=$(3.z);5(n.1A){M({z:\'n\'});w=n.6();h=n.b();5(1y)21=1y;1y=n;4.c.1x(n.1G())}M({6:w,b:h});5(4.c.H())4.15=y;q 17();1i();18()}q{C(\'4p 2g: \'+p);M({z:\'1r\'});j G={};5(3.Q){G=3.1r.G||{};G[3.2C]=3.Q.1T(1)}$.1r($.J({},3.1r,{p:p,4n:3x,1c:17,G:G}));1i()}}q 5(3.k){C(\'4t: \'+3.z);M({z:\'4e\'});1w();4.c.H($(\'<n/>\').H(3.k).1G());5(4.c.H())4.15=y;q 17();1i()}q{}}8 3u(f){C(\'3u\');3=$.J({},$.1e.16.f,f);3.Q=\'\';3.2X=0;3.2Y=0;3.3v=y;3E()}8 M(f,11,1B){5(4.3h){5(11&&1B){$.J(3[11][1B],f)}q 5(11){$.J(3[11],f)}q{$.J(3,f)}}q{5(11&&1B){$.J($.1e.16.f[11][1B],f)}q 5(11){$.J($.1e.16.f[11],f)}q{$.J($.1e.16.f,f)}}}8 3F(){5(2t){5(1H.3G){3.1I=1H.3G.4u;3.1J=1H.3G.2Z}q{3.1I=1H.14.4u;3.1J=1H.14.2Z}}q{3.1I=0;3.1J=0}}8 3E(){3F();3.L=-(3.6+3.2X)/2+3.1I;3.K=-(3.b+3.2Y)/2+3.1J}8 30(){3F();j 1k=1V(4.E);3.31=-(4.E.b()+1k.h.X+1k.h.13)/2+3.1J;3.32=-(4.E.6()+1k.w.X+1k.w.13)/2+3.1I}8 1w(){C(\'1w\');5(!4.1z){5(3.C)M({5N:\'5O\'},\'l\',\'U\');j 3H=\'\';5(2t){14.l({b:14.b()+\'t\',6:14.6()+\'t\',12:\'5P\',1g:\'1v\'});$(\'H\').l({1g:\'1v\'});M({12:\'3I\',b:\'4v%\',6:\'4v%\',2F:3.1J+\'t\',2G:3.1I+\'t\'},\'l\',\'U\');M({12:\'3I\'},\'l\',\'E\');M({12:\'3I\'},\'l\',\'D\');3H=$(\'<P 1h="5Q"></P>\').l($.J({},3.l.U,{1l:0,2E:50,X:\'5R\'}))}14.1x($(\'<n 1h="4w"><n 1h="4x"></n><n 1h="4y"><n 1h="4z"></n></n><n 1h="4A"></n><n 1h="4B"></n></n>\').Y());4.1z=$(\'#4w\').1K();4.U=$(\'#4x\').l($.J({33:3.23},3.l.U)).5S(3H);5(!3.4)4.U.1f(1q);4.E=$(\'#4B\').l(3.l.E).Y();4.v=$(\'#4y\').l(3.l.D).Y();4.k=$(\'#4z\');4.c=$(\'#4A\').Y();5($.1p($.1e.4C)){4.k.4C(8(e,d){j 2i=4.k.4D(0);5((d>0&&2i.2Z==0)||(d<0&&2i.5T-2i.2Z==2i.5U)){e.1o();e.5V()}})}$(1H).4E(3J);4.k.l({6:\'1C\',b:\'1C\'});4.v.l({6:\'1C\',b:\'1C\'})}}8 1i(){C(\'1i\');5(!4.1a){1w();4.O=y;3.2K(4,3,3K)}q{4.O=y;4.10=y;3.2M(4,3,8(){2j();4.O=m;18()})}}8 3J(e){5(e.2k==27){5(!3.4)1q()}q 5(3.z==\'V\'&&4.1a&&4.15&&!4.O&&!4.10){5(e.2k==39||e.2k==40){e.1o();$(\'.26\',4.k).2W(0).4F(\'1f\');r m}q 5(e.2k==37||e.2k==38){e.1o();$(\'.29\',4.k).2W(0).4F(\'1f\');r m}}}8 4k(){5(3.3L){j c=3.3L;5(!3.k)3.o=y;3.3L=B;r c}j o=3.o;j p;5(o&&o.22){3.p=p=o.22.2y()==\'1m\'?o.2h:o.W;5(o.5W==\'4\')3.4=y;5(o.2R&&o.2R.2y()==\'5X\'||(o.3M&&o.3M.3N(/:\\d*$/,\'\')!=1W.34.3M.3N(/:\\d*$/,\'\'))){r\'P\'}q 5(o.22.2y()==\'1m\'){M(3O(p));5(o.45==\'46/1m-G\')r\'3o\';r\'1m\'}}q{p=3.p;5(!3.k)3.o=y;5(!p)r B;j 4G=1N 3P("^5Y://","g");5(p.5Z(4G))r\'P\'}j 1t=1N 3P(3.4a,\'i\');5(1t.4H(p)){5(o&&o.35)r\'V\';q r\'1t\'}j 1s=1N 3P(\'[^\\.]\\.(1s)\\s*$\',\'i\');5(1s.4H(p))r\'1s\';j c=3O(p);M(c);5(!c.p)r c.Q}8 3O(p){j A={p:B,Q:B};5(p){j 2a=3Q(p);j 4I=3Q(1W.34.W);j 4J=1W.34.W.1T(0,1W.34.W.1A-4I.1A);j 3R=p.1T(0,p.1A-2a.1A);5(3R==4J){A.Q=2a}q{A.p=3R;A.Q=2a}}r A}8 17(){C(\'17\');4.1c=y;5(!4.1a)r;5($.1p(3.3r))3.3r(4,3);4.E.60(3.4i).H(3.4j);$(3.2J,4.E).1f(1q);30();4.E.l({K:3.31+\'t\',L:3.32+\'t\'})}8 36(){C(\'36\');5(!4.c.H())r;4.k.H(4.c.1G());4.c.3S();3T();5($.1p(3.3s))3.3s(4,3);4.k.1x(4.2w);j 3a=$.J({},3);5(1d.6)3a.6=B;5(1d.b)3a.b=B;$(3.2J,4.v).1f(1q);$(3.3p,4.v).16(3a)}8 3T(){C(\'3T\');j 2d=$(3.2d[3.z]);4.k.1x(2d.3U().2l());4.v.61(2d);5(3.z==\'V\'){j 3b=28(-1);5(3b){$(\'.29\',4.v).1j(\'W\',3b.1j(\'W\')).1f(8(e){e.1o();3b.1O(3);r m})}q{$(\'.29\',4.v).2l()}j 3c=28(1);5(3c){$(\'.26\',4.v).1j(\'W\',3c.1j(\'W\')).1f(8(e){e.1o();3c.1O(3);r m})}q{$(\'.26\',4.v).2l()}}2A()}8 28(3V){5(3.z==\'V\'){5(!3.4c)3V*=-1;j V=$(\'[35="\'+3.o.35+\'"]\');j 4K=V.2m(3.o);j 2m=4K+3V;5(2m>=0&&2m<V.1A)r V.2W(2m)}r m}8 2A(4L){C(\'2A\');5(!4.D)4.D=4.v.3U(\':62\');1d.6=m;1d.b=m;5(3.3l&&(!3.6||!3.b)){4.v.l({1l:0}).1K();j c={6:\'1C\',b:\'1C\'};5(3.6)c.6=3.6;5(3.b)c.b=3.b;4.k.l(c);5(!3.6){3.6=4.k.6();1d.6=y}5(!3.b){3.b=4.k.b();1d.b=y}4.v.Y().l({1l:1})}3.6=1L.4M(3.6,3.47);3.b=1L.4M(3.b,3.48);j 2n=1V(4.v);j 2o=1V(4.D);j 19=1V(4.k);j c={k:{6:3.6,b:3.b},2c:{6:3.6+19.w.R,b:3.b+19.h.R},D:{6:3.6+19.w.R+2o.w.R,b:3.b+19.h.R+2o.h.R}};5(3.3v){j 3d=$(1W).b()-3.13*2-2n.h.X-(c.D.b-3.b);j 3e=$(1W).6()-3.13*2-2n.w.X-(c.D.6-3.6);5(c.k.b>3d||c.k.6>3e){5(3.z==\'1t\'||3.z==\'V\'){j 2p=c.k.6-3.2U;j 2q=c.k.b-3.2V;5(2q<0)2q=0;5(2p<0)2p=0;j 2r=3d-2q;j 2s=3e-2p;j 3W=1L.3X(2r/3.2V,2s/3.2U);2r=1L.4N(3.2V*3W);2s=1L.4N(3.2U*3W);$(\'1U#4s\',4.k).l({b:2r+\'t\',6:2s+\'t\'});c.k.b=2r+2q;c.k.6=2s+2p}q{c.k.b=1L.3X(c.k.b,3d);c.k.6=1L.3X(c.k.6,3e)}c.2c={6:c.k.6+19.w.R,b:c.k.b+19.h.R};c.D={6:c.k.6+19.w.R+2o.w.R,b:c.k.b+19.h.R+2o.h.R}}}4.k.l($.J({},c.k,3.l.k));4.D.l($.J({},c.2c,3.l.2c));5(!4L){4.v.l($.J({},c.D,3.l.D));5(3.z==\'1t\'||3.z==\'V\'){j 1D=$(\'1U\',4.k).1j(\'3C\');$(\'1U\',4.k).4O(\'3C\');5(1D!=3.3m){j 3f=$(\'<n>\'+1D+\'</n>\');4.k.1x(3f);5(3.4b){j 4P=1V(3f);3f.l({6:(c.k.6+19.w.13-4P.w.R)+\'t\'})}}}5(!3.4)4.v.2S(3.4f)}c.D.2X=2n.w.X;c.D.2Y=2n.h.X;M(c.D);3E()}8 1q(e){C(\'1q\');5(e)e.1o();5(4.1z&&4.1a){4.1a=m;4.O=y;4.2v=y;5(4.1b||4.10){3.2f(4,3,8(){4.E.Y();4.1b=m;4.10=m;3.1R(4,3,1u)})}q{5(1M)4.k.l({12:\'\'});4.D.l({1g:\'1v\'});4.k.l({1g:\'1v\'});5($.1p(3.3t)){3.3t(4,3,8(){3.2e(4,3,8(){2j();3.1R(4,3,1u)})})}q{3.2e(4,3,8(){2j();3.1R(4,3,1u)})}}}5(e)r m}8 18(){C(\'18\');5(4.1a&&!4.O){5(4.15){5(4.c.H()){4.O=y;5(4.10){36();3.2N(4,3,8(){4.E.Y();4.10=m;4.1b=m;1E()})}q{3.2f(4,3,8(){4.E.Y();4.1b=m;36();30();3.2L(4,$.J({},3),1E)})}}}q 5(!4.1b&&!4.10){4.O=y;4.1b=y;5(4.1c)17();q 4.E.H(3.4h);$(3.2J,4.E).1f(1q);30();3.2O(4,3,8(){4.O=m;18()})}}}8 3x(G){C(\'63: \'+F.p);4.c.H(3.Q?3Y($(\'<n>\'+G+\'</n>\').3B(3.Q).1G()):3Y(G));5(4.c.H()){4.15=y;18()}q 17()}8 3A(){C(\'3A\');3.o.2h+=3.Q;3.o.2R=\'\';$(\'3z[T=\'+3.2D+\']\',3.o).2l();j P=4.c.3U(\'P\');j 4Q=P.3D(\'2T\').1G().3B(3.Q||\'14\').64(\'4R[1F]\');P.1j(\'1F\',\'65:66\');4.c.H(4Q.H());5(4.c.H()){4.15=y;18()}q 17()}8 2j(){C(\'2j\');4.O=m;5(21){21.1x(4.k.1G());21=B}q 5(1y){1y.1x(4.k.1G());1y=B}4.k.3S();4.v.3S().4O(\'67\');5(4.2v||4.10)4.v.Y();4.v.l(3.l.D).1x(4.k);18()}8 1u(){C(\'1u\');$(1H).3D(\'4E\',3J);4.O=m;4.1z.2l();4.1z=B;5(2t){14.l({b:\'\',6:\'\',12:\'\',1g:\'\'});$(\'H\').l({1g:\'\'})}5($.1p(3.1u))3.1u(4,3)}8 3K(){C(\'3K\');4.1a=y;4.O=m;18()}8 1E(){C(\'1E\');4.O=m;4.v.l({1l:\'\'});1M=$.2u.68&&69($.2u.44)<1.9&&3.z!=\'V\'&&3.z!=\'1t\';5(1M)4.k.l({12:\'24\'});5($.1p(3.1E))3.1E(4,3);5(1d.6)M({6:B});5(1d.b)M({b:B})}8 3Q(p){5(4S p==\'4T\'){j 3Z=p.6a(\'#\');5(3Z>-1)r p.1T(3Z)}r\'\'}8 3Y(G){5(4S G==\'4T\')G=G.3N(/<\\/?(H|6b|14)([^>]*)>/6c,\'\');j c=1N 3i();$.2x($.6d({0:G},F.6e),8(){5($.22(F,"4R")){5(!F.1F||$(F).1j(\'35\')==\'6f\')4.2w.2Q(F)}q c.2Q(F)});r c}8 1V(N){N=N.4D(0);j A={h:{3g:Z(N,\'K\')+Z(N,\'6g\'),X:Z(N,\'6h\')+Z(N,\'6i\'),13:Z(N,\'6j\')+Z(N,\'6k\')},w:{3g:Z(N,\'L\')+Z(N,\'6l\'),X:Z(N,\'6m\')+Z(N,\'6n\'),13:Z(N,\'6o\')+Z(N,\'6p\')}};A.h.1k=A.h.3g+A.h.X;A.w.1k=A.w.3g+A.w.X;A.h.4U=A.h.13+A.h.X;A.w.4U=A.w.13+A.w.X;A.h.R=A.h.1k+A.h.13;A.w.R=A.w.1k+A.w.13;r A}8 Z(N,T){j A=43($.6q(N,T,y));5(6r(A))A=0;r A}8 C(4V){5(3&&3.C&&4.1z)4.U.2S(4V+\'<3q />\')}8 2K(u,f,I){u.U.l({1l:0}).4W(6s,0.6t,I)}8 1R(u,f,I){u.U.41(49,I)}8 2O(u,f,I){u.E.l({K:f.31+\'t\',L:f.32+\'t\',1l:0}).1K().1X({1l:1},{1Y:I,1Z:1Q})}8 2f(u,f,I){I()}8 2L(u,f,I){u.E.l({K:f.31+\'t\',L:f.32+\'t\'}).1K().1X({6:f.6+\'t\',b:f.b+\'t\',K:(f.K)+\'t\',L:(f.L)+\'t\'},{1Z:42,1Y:8(){u.v.l({6:f.6+\'t\',b:f.b+\'t\',K:(f.K)+\'t\',L:(f.L)+\'t\'}).1K();u.E.41(6u,I)}})}8 2e(u,f,I){u.v.1X({b:\'2H\',6:\'2H\',K:(-(25+3.2Y)/2+3.1J)+\'t\',L:(-(25+3.2X)/2+3.1I)+\'t\'},{1Z:42,1Y:8(){u.v.Y();I()}})}8 2M(u,f,I){u.E.l({K:u.v.l(\'K\'),L:u.v.l(\'L\'),b:u.v.l(\'b\'),6:u.v.l(\'6\'),1l:0}).1K().4W(1Q,1,8(){u.v.Y();I()})}8 2N(u,f,I){u.v.Y().l({6:f.6+\'t\',L:f.L+\'t\',b:f.b+\'t\',K:f.K+\'t\',1l:1});u.E.1X({6:f.6+\'t\',L:f.L+\'t\',b:f.b+\'t\',K:f.K+\'t\'},{1Y:8(){u.v.1K();u.E.41(1Q,8(){u.E.Y();I()})},1Z:42})}8 2B(u,f,I){u.v.1X({6:f.6+\'t\',L:f.L+\'t\',b:f.b+\'t\',K:f.K+\'t\'},{1Y:I,1Z:1Q})}8 2z(u,f,I){5(!$.6v.6w.33){u.U.l({33:f.23});I()}q u.U.1X({33:f.23},{1Y:I,1Z:1Q})}$($.1e.16.f.3p).16()});',62,405,'|||currentSettings|modal|if|width||function|||height|tmp|||settings||||var|content|css|false|div|from|url|else|return||px|elts|contentWrapper|||true|type|ret|null|debug|wrapper|loading|this|data|html|callback|extend|marginTop|marginLeft|setCurrentSettings|elm|anim|iframe|selector|total|class|name|bg|gallery|href|border|hide|getCurCSS|transition|deep1|position|padding|body|dataReady|nyroModal|loadingError|showContentOrLoading|outerContent|ready|loadingShown|error|resized|fn|click|overflow|id|showModal|attr|outer|opacity|form|processModal|preventDefault|isFunction|removeModal|ajax|swf|image|endRemove|hidden|initModal|append|contentElt|full|length|deep2|auto|title|endShowContent|src|contents|document|marginScrollLeft|marginScrollTop|show|Math|fixFF|new|nyroModalManual|link|400|hideBackground|value|substring|img|getOuter|window|animate|complete|duration||contentEltLast|nodeName|bgColor|fixed||nyroModalNext||getGalleryLink|nyroModalPrev|hash|100|wrapper2|wrap|hideContent|hideLoading|Load|action|elt|endHideContent|keyCode|remove|index|outerWrapper|outerWrapper2|diffW|diffH|calcH|calcW|isIE6|browser|closing|scripts|each|toLowerCase|updateBgColor|calculateSize|resize|selIndicator|formIndicator|zIndex|top|left|50px|nyroModalClose|closeSelector|showBackground|showContent|showTransition|hideTransition|showLoading|param|push|target|prepend|load|imgWidth|imgHeight|eq|borderW|borderH|scrollTop|setMarginloading|marginTopLoading|marginLeftLoading|backgroundColor|location|rel|fillContent||||currentSettingsNew|linkPrev|linkNext|maxHeight|maxWidth|divTitle|margin|started|Array|endResize|processHandler|autoSizable|defaultImgAlt|Image|formData|openSelector|br|handleError|endFillContent|beforeHideContent|setDefaultCurrentSettings|resizable|val|ajaxLoaded|nyroModalIframe|input|formDataLoaded|find|alt|unbind|setMargin|setMarginScroll|documentElement|iframeHideIE|absolute|keyHandler|endBackground|forceType|hostname|replace|extractUrlSel|RegExp|getHash|req|empty|wrapContent|children|dir|ratio|min|filterScripts|hashPos||fadeOut|350|parseInt|version|enctype|multipart|minWidth|minHeight|300|regexImg|setWidthImgTitle|rtl|wrapperImg|manual|closeButton|Close|contentLoading|errorClass|contentError|fileType|object|embed|success|Form|Ajax|frameborder|hspace|nyroModalImg|Content|scrollLeft|110|nyroModalFull|nyroModalBg|nyroModalWrapper|nyroModalContent|nyrModalTmp|nyroModalLoading|mousewheel|get|keydown|trigger|reg1|test|hashLoc|curLoc|currentIndex|resizing|max|floor|removeAttr|outerDivTitle|iframeContent|script|typeof|string|inner|msg|fadeTo|jQuery|msie|substr||submit|nyroModalSettings|nyroModalRemove|nyroModalSel|000000|wmode|transparent|resizeable|jpg|jpeg|png|tiff|gif|bmp|101|102|Prev|Next|wrapperSwf|wrapperIframe|closeBut|close|Cancel|The|requested|cannot|be|loaded|Please|try|again|later|classid|clsid|D27CDB6E|AE6D|11cf|96B8|444553540000|movie|application|shockwave|flash|serializeArray|method|Data|Loaded|Iframe|color|white|static|nyroModalIframeHideIe|none|before|scrollHeight|clientHeight|stopPropagation|rev|_blank|http|match|addClass|wrapInner|first|AjaxLoaded|not|about|blank|style|mozilla|parseFloat|indexOf|head|gi|clean|ownerDocument|forceLoad|marginBottom|borderTopWidth|borderBottomWidth|paddingTop|paddingBottom|marginRight|borderLeftWidth|borderRightWidth|paddingLeft|paddingRight|curCSS|isNaN|500|75|200|fx|step'.split('|'),0,{}))*/

/*-->V1.3.0 -> V1.5.2

/*
 * nyroModal - jQuery Plugin
 * http://nyromodal.nyrodev.com
 *
 * Copyright (c) 2008 Cedric Nirousset (nyrodev.com)
 * Licensed under the MIT license
 *
 * $Date: 2009-08-14 (Fri, 14 Aug 2009) $
 * $version: 1.5.2
 */
jQuery(function($) {

	// -------------------------------------------------------
	// Private Variables
	// -------------------------------------------------------

	var userAgent = navigator.userAgent.toLowerCase();
	var browserVersion = (userAgent.match(/.+(?:rv|webkit|khtml|opera|msie)[\/: ]([\d.]+)/ ) || [0,'0'])[1];

	var isIE6 = (/msie/.test(userAgent) && !/opera/.test(userAgent) && parseInt(browserVersion) < 7 && !window.XMLHttpRequest);
	var body = $('body');

	var currentSettings;

	var shouldResize = false;

	var gallery = {};

	// To know if the fix for the Issue 10 should be applied (or has been applied)
	var fixFF = false;

	// Used for retrieve the content from an hidden div
	var contentElt;
	var contentEltLast;

	// Contains info about nyroModal state and all div references
	var modal = {
		started: false,
		ready: false,
		dataReady: false,
		anim: false,
		animContent: false,
		loadingShown: false,
		transition: false,
		resizing: false,
		closing: false,
		error: false,
		blocker: null,
		blockerVars: null,
		full: null,
		bg: null,
		loading: null,
		tmp: null,
		content: null,
		wrapper: null,
		contentWrapper: null,
		scripts: new Array(),
		scriptsShown: new Array()
	};

	// Indicate of the height or the width was resized, to reinit the currentsettings related to null
	var resized = {
		width: false,
		height: false,
		windowResizing: false
	};

	var initSettingsSize = {
		width: null,
		height: null,
		windowResizing: true
	};

	var windowResizeTimeout;


	// -------------------------------------------------------
	// Public function
	// -------------------------------------------------------

	// jQuery extension function. A paramater object could be used to overwrite the default settings
	$.fn.nyroModal = function(settings) {
		if (!this)
			return false;
		return this.each(function() {
			var me = $(this);
			if (this.nodeName.toLowerCase() == 'form') {
				me
				.unbind('submit.nyroModal')
				.bind('submit.nyroModal', function(e) {
					if(e.isDefaultPrevented())
						return false;
					if (me.data('nyroModalprocessing'))
						return true;
					if (this.enctype == 'multipart/form-data') {
						processModal($.extend(settings, {
							from: this
						}));
						return true;
					}
					e.preventDefault();
					processModal($.extend(settings, {
						from: this
					}));
					return false;
				});
			} else {
				me
				.unbind('click.nyroModal')
				.bind('click.nyroModal', function(e) {
					if(e.isDefaultPrevented())
						return false;
					e.preventDefault();
					processModal($.extend(settings, {
						from: this
					}));
					return false;
				});
			}
		});
	};

	// jQuery extension function to call manually the modal. A paramater object could be used to overwrite the default settings
	$.fn.nyroModalManual = function(settings) {
		if (!this.length)
			processModal(settings);
		return this.each(function(){
			processModal($.extend(settings, {
				from: this
			}));
		});
	};

	$.nyroModalManual = function(settings) {
		processModal(settings);
	};

	// Update the current settings
	// object settings
	// string deep1 first key where overwrite the settings
	// string deep2 second key where overwrite the settings
	$.nyroModalSettings = function(settings, deep1, deep2) {
		setCurrentSettings(settings, deep1, deep2);
		if (!deep1 && modal.started) {
			if (modal.bg && settings.bgColor)
				currentSettings.updateBgColor(modal, currentSettings, function(){});

			if (modal.contentWrapper && settings.title)
				setTitle();

			if (!modal.error && (settings.windowResizing || (!modal.resizing && (('width' in settings && settings.width == currentSettings.width) || ('height' in settings && settings.height == currentSettings.height))))) {
				modal.resizing = true;
				if (modal.contentWrapper)
					calculateSize(true);
				if (modal.contentWrapper && modal.contentWrapper.is(':visible') && !modal.animContent) {
					if (fixFF)
						modal.content.css({position: ''});
					currentSettings.resize(modal, currentSettings, function() {
						currentSettings.windowResizing = false;
						modal.resizing = false;
						if (fixFF)
							modal.content.css({position: 'fixed'});
						if ($.isFunction(currentSettings.endResize))
							currentSettings.endResize(modal, currentSettings);
					});
				}
			}
		}
	};

	// Remove the modal function
	$.nyroModalRemove = function() {
		removeModal();
	};

	// Go to the next image for a gallery
	// return false if nothing was done
	$.nyroModalNext = function() {
		var link = getGalleryLink(1);
		if (link)
			return link.nyroModalManual(getCurrentSettingsNew());
		return false;
	};

	// Go to the previous image for a gallery
	// return false if nothing was done
	$.nyroModalPrev = function() {
		var link = getGalleryLink(-1);
		if (link)
			return link.nyroModalManual(getCurrentSettingsNew());
		return false;
	};


	// -------------------------------------------------------
	// Default Settings
	// -------------------------------------------------------

	$.fn.nyroModal.settings = {
		debug: false, // Show the debug in the background

		blocker: false, // Element which will be blocked by the modal

		modal: false, // Esc key or click backgrdound enabling or not

		type: '', // nyroModal type (form, formData, iframe, image, etc...)
		forceType: null, // Used to force the type
		from: '', // Dom object where the call come from
		hash: '', // Eventual hash in the url

		processHandler: null, // Handler just before the real process

		selIndicator: 'nyroModalSel', // Value added when a form or Ajax is sent with a filter content

		formIndicator: 'nyroModal', // Value added when a form is sent

		content: null, // Raw content if type content is used

		bgColor: '#000000', // Background color

		ajax: {}, // Ajax option (url, data, type, success will be overwritten for a form, url and success only for an ajax call)

		swf: { // Swf player options if swf type is used.
			wmode: 'transparent'
		},

		width: null, // default Width If null, will be calculate automatically
		height: null, // default Height If null, will be calculate automatically

		minWidth: 400, // Minimum width
		minHeight: 300, // Minimum height

		resizable: true, // Indicate if the content is resizable. Will be set to false for swf
		autoSizable: true, // Indicate if the content is auto sizable. If not, the min size will be used

		padding: 25, // padding for the max modal size

		regexImg: '[^\.]\.(jpg|jpeg|png|tiff|gif|bmp)\s*$', // Regex to find images
		addImageDivTitle: false, // Indicate if the div title should be inserted
		defaultImgAlt: 'Image', // Default alt attribute for the images
		setWidthImgTitle: true, // Set the width to the image title
		ltr: true, // Left to Right by default. Put to false for Hebrew or Right to Left language

		gallery: null, // Gallery name if provided
		galleryLinks: '<a href="#" class="nyroModalPrev">Prev</a><a href="#"  class="nyroModalNext">Next</a>', // Use .nyroModalPrev and .nyroModalNext to set the navigation link
		galleryCounts: galleryCounts, // Callback to show the gallery count

		zIndexStart: 100,

		css: { // Default CSS option for the nyroModal Div. Some will be overwritten or updated when using IE6
			bg: {
				position: 'absolute',
				overflow: 'hidden',
				top: 0,
				left: 0,
				height: '100%',
				width: '100%'
			},
			wrapper: {
				position: 'absolute',
				top: '50%',
				left: '50%'
			},
			wrapper2: {
			},
			content: {
				overflow: 'auto'
			},
			loading: {
				position: 'absolute',
				top: '50%',
				left: '50%',
				marginTop: '-50px',
				marginLeft: '-50px'
			}
		},

		wrap: { // Wrapper div used to style the modal regarding the content type
			div: '<div class="wrapper"></div>',
			ajax: '<div class="wrapper"></div>',
			form: '<div class="wrapper"></div>',
			formData: '<div class="wrapper"></div>',
			image: '<div class="wrapperImg"></div>',
			swf: '<div class="wrapperSwf"></div>',
			iframe: '<div class="wrapperIframe"></div>',
			iframeForm: '<div class="wrapperIframe"></div>',
			manual: '<div class="wrapper"></div>'
		},

		//closeButton: '<a href="#" class="nyroModalClose" id="closeBut" title="close">Close</a>', // Adding automaticly as the first child of #nyroModalWrapper

		title: null, // Modal title
		titleFromIframe: true, // When using iframe in the same domain, try to get the title from it

		openSelector: '.nyroModal', // selector for open a new modal. will be used to parse automaticly at page loading
		closeSelector: '.nyroModalClose', // selector to close the modal

		contentLoading: '<a href="#" class="nyroModalClose">Cancel</a>', // Loading div content

		errorClass: 'error', // CSS Error class added to the loading div in case of error
		contentError: 'The requested content cannot be loaded.<br />Please try again later.<br /><a href="#" class="nyroModalClose">Close</a>', // Content placed in the loading div in case of error

		handleError: null, // Callback in case of error

		showBackground: showBackground, // Show background animation function
		hideBackground: hideBackground, // Hide background animation function

		endFillContent: null, // Will be called after filling and wraping the content, before parsing closeSelector and openSelector and showing the content
		showContent: showContent, // Show content animation function
		endShowContent: null, // Will be called once the content is shown
		beforeHideContent: null, // Will be called just before the modal closing
		hideContent: hideContent, // Hide content animation function

		showTransition: showTransition, // Show the transition animation (a modal is already shown and a new one is requested)
		hideTransition: hideTransition, // Hide the transition animation to show the content

		showLoading: showLoading, // show loading animation function
		hideLoading: hideLoading, // hide loading animation function

		resize: resize, // Resize animation function
		endResize: null, // Will be called one the content is resized

		updateBgColor: updateBgColor, // Change background color animation function

		endRemove: null // Will be called once the modal is totally gone
	};

	// -------------------------------------------------------
	// Private function
	// -------------------------------------------------------

	// Main function
	function processModal(settings) {
		if (modal.loadingShown || modal.transition || modal.anim)
			return;
		debug('processModal');
		modal.started = true;
		setDefaultCurrentSettings(settings);
		if (!modal.full)
			modal.blockerVars = modal.blocker = null;
		modal.error = false;
		modal.closing = false;
		modal.dataReady = false;
		modal.scripts = new Array();
		modal.scriptsShown = new Array();

		currentSettings.type = fileType();
		if (currentSettings.forceType) {
			if (!currentSettings.content)
				currentSettings.from = true;
			currentSettings.type = currentSettings.forceType;
			currentSettings.forceType = null;
		}

		if ($.isFunction(currentSettings.processHandler))
			currentSettings.processHandler(currentSettings);

		var from = currentSettings.from;
		var url = currentSettings.url;

		initSettingsSize.width = currentSettings.width;
		initSettingsSize.height = currentSettings.height;

		if (currentSettings.type == 'swf') {
			// Swf is transforming as a raw content
			setCurrentSettings({overflow: 'hidden'}, 'css', 'content');
			currentSettings.content = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+currentSettings.width+'" height="'+currentSettings.height+'"><param name="movie" value="'+url+'"></param>';
			var tmp = '';
			$.each(currentSettings.swf, function(name, val) {
				currentSettings.content+= '<param name="'+name+'" value="'+val+'"></param>';
				tmp+= ' '+name+'="'+val+'"';
			});
			currentSettings.content+= '<embed src="'+url+'" type="application/x-shockwave-flash" width="'+currentSettings.width+'" height="'+currentSettings.height+'"'+tmp+'></embed></object>';
		}

		if (from) {
			var jFrom = $(from).blur();
			if (currentSettings.type == 'form') {
				var data = $(from).serializeArray();
				data.push({name: currentSettings.formIndicator, value: 1});
				if (currentSettings.selector)
					data.push({name: currentSettings.selIndicator, value: currentSettings.selector.substring(1)});
				$.ajax($.extend({}, currentSettings.ajax, {
						url: url,
						data: data,
						type: jFrom.attr('method') ? jFrom.attr('method') : 'get',
						success: ajaxLoaded,
						error: loadingError
					}));
				debug('Form Ajax Load: '+jFrom.attr('action'));
				showModal();
			} else if (currentSettings.type == 'formData') {
				// Form with data. We're using a hidden iframe
				initModal();
				jFrom.attr('target', 'nyroModalIframe');
				jFrom.attr('action', url);
				jFrom.prepend('<input type="hidden" name="'+currentSettings.formIndicator+'" value="1" />');
				if (currentSettings.selector)
					jFrom.prepend('<input type="hidden" name="'+currentSettings.selIndicator+'" value="'+currentSettings.selector.substring(1)+'" />');
				modal.tmp.html('<iframe frameborder="0" hspace="0" name="nyroModalIframe" src="javascript:\'\';"></iframe>');
				$('iframe', modal.tmp)
					.css({
						width: currentSettings.width,
						height: currentSettings.height
					})
					.error(loadingError)
					.load(formDataLoaded);
				debug('Form Data Load: '+jFrom.attr('action'));
				showModal();
				showContentOrLoading();
			} else if (currentSettings.type == 'image') {
				debug('Image Load: '+url);
				var title = jFrom.attr('title') || currentSettings.defaultImgAlt;
				initModal();
				modal.tmp.html('<img id="nyroModalImg" />').find('img').attr('alt', title);
				modal.tmp.css({lineHeight: 0});
				$('img', modal.tmp)
					.error(loadingError)
					.load(function() {
						debug('Image Loaded: '+this.src);
						$(this).unbind('load');
						var w = modal.tmp.width();
						var h = modal.tmp.height();
						modal.tmp.css({lineHeight: ''});
						resized.width = w;
						resized.height = h;
						setCurrentSettings({
							width: w,
							height: h,
							imgWidth: w,
							imgHeight: h
						});
						initSettingsSize.width = w;
						initSettingsSize.height = h;
						setCurrentSettings({overflow: 'hidden'}, 'css', 'content');
						modal.dataReady = true;
						if (modal.loadingShown || modal.transition)
							showContentOrLoading();
					})
					.attr('src', url);
				showModal();
			} else if (currentSettings.type == 'iframeForm') {
				initModal();
				modal.tmp.html('<iframe frameborder="0" hspace="0" src="javascript:\'\';" name="nyroModalIframe" id="nyroModalIframe"></iframe>');
				debug('Iframe Form Load: '+url);
				$('iframe', modal.tmp).eq(0)
					.css({
						width: '100%',
						height: $.support.boxModel? '99%' : '100%'
					})
					.load(iframeLoaded);
				modal.dataReady = true;
				showModal();
			} else if (currentSettings.type == 'iframe') {
				initModal();
				modal.tmp.html('<iframe frameborder="0" hspace="0" src="javascript:\'\';" name="nyroModalIframe" id="nyroModalIframe"></iframe>');
				debug('Iframe Load: '+url);
				$('iframe', modal.tmp).eq(0)
					.css({
						width: '100%',
						height: $.support.boxModel? '99%' : '100%'
					})
					.load(iframeLoaded);
				modal.dataReady = true;
				showModal();
			} else if (currentSettings.type) {
				// Could be every other kind of type or a dom selector
				debug('Content: '+currentSettings.type);
				initModal();
				modal.tmp.html(currentSettings.content);
				var w = modal.tmp.width();
				var h = modal.tmp.height();
				var div = $(currentSettings.type);
				if (div.length) {
					setCurrentSettings({type: 'div'});
					w = div.width();
					h = div.height();
					if (contentElt)
						contentEltLast = contentElt;
					contentElt = div;
					modal.tmp.append(div.contents());
				}
				initSettingsSize.width = w;
				initSettingsSize.height = h;
				setCurrentSettings({
					width: w,
					height: h
				});
				if (modal.tmp.html())
					modal.dataReady = true;
				else
					loadingError();
				if (!modal.ready)
					showModal();
				else
					endHideContent();
			} else {
				debug('Ajax Load: '+url);
				setCurrentSettings({type: 'ajax'});
				var data = currentSettings.ajax.data || {};
				if (currentSettings.selector) {
					if (typeof data == "string") {
						data+= '&'+currentSettings.selIndicator+'='+currentSettings.selector.substring(1);
					} else {
						data[currentSettings.selIndicator] = currentSettings.selector.substring(1);
					}
				}
				$.ajax($.extend(true, currentSettings.ajax, {
					url: url,
					success: ajaxLoaded,
					error: loadingError,
					data: data
				}));
				showModal();
			}
		} else if (currentSettings.content) {
			// Raw content not from a DOM element
			debug('Content: '+currentSettings.type);
			setCurrentSettings({type: 'manual'});
			initModal();
			modal.tmp.html($('<div/>').html(currentSettings.content).contents());
			if (modal.tmp.html())
				modal.dataReady = true;
			else
				loadingError();
			showModal();
		} else {
			// What should we show here? nothing happen
		}
	}

	// Update the current settings
	// object settings
	// string deep1 first key where overwrite the settings
	// string deep2 second key where overwrite the settings
	function setDefaultCurrentSettings(settings) {
		debug('setDefaultCurrentSettings');
		currentSettings = $.extend(true, {}, $.fn.nyroModal.settings, settings);
		currentSettings.selector = '';
		currentSettings.borderW = 0;
		currentSettings.borderH = 0;
		currentSettings.resizable = true;
		setMargin();
	}

	function setCurrentSettings(settings, deep1, deep2) {
		if (modal.started) {
			if (deep1 && deep2) {
				$.extend(true, currentSettings[deep1][deep2], settings);
			} else if (deep1) {
				$.extend(true, currentSettings[deep1], settings);
			} else {
				if (modal.animContent) {
					if ('width' in settings) {
						if (!modal.resizing) {
							settings.setWidth = settings.width;
							shouldResize = true;
						}
						delete settings['width'];
					}
					if ('height' in settings) {
						if (!modal.resizing) {
							settings.setHeight = settings.height;
							shouldResize = true;
						}
						delete settings['height'];
					}
				}
				$.extend(true, currentSettings, settings);
			}
		} else {
			if (deep1 && deep2) {
				$.extend(true, $.fn.nyroModal.settings[deep1][deep2], settings);
			} else if (deep1) {
				$.extend(true, $.fn.nyroModal.settings[deep1], settings);
			} else {
				$.extend(true, $.fn.nyroModal.settings, settings);
			}
		}
	}

	// Set the margin for postionning the element. Useful for IE6
	function setMarginScroll() {
		if (isIE6 && !modal.blocker) {
			if (document.documentElement) {
				currentSettings.marginScrollLeft = document.documentElement.scrollLeft;
				currentSettings.marginScrollTop = document.documentElement.scrollTop;
			} else {
				currentSettings.marginScrollLeft = document.body.scrollLeft;
				currentSettings.marginScrollTop = document.body.scrollTop;
			}
		} else {
			currentSettings.marginScrollLeft = 0;
			currentSettings.marginScrollTop = 0;
		}
	}

	// Set the margin for the content
	function setMargin() {
		setMarginScroll();
		currentSettings.marginLeft = -(currentSettings.width+currentSettings.borderW)/2;
		currentSettings.marginTop = -(currentSettings.height+currentSettings.borderH)/2;
		if (!modal.blocker) {
			currentSettings.marginLeft+= currentSettings.marginScrollLeft;
			currentSettings.marginTop+= currentSettings.marginScrollTop;
		}
	}

	// Set the margin for the current loading
	function setMarginLoading() {
		setMarginScroll();
		var outer = getOuter(modal.loading);
		currentSettings.marginTopLoading = -(modal.loading.height() + outer.h.border + outer.h.padding)/2;
		currentSettings.marginLeftLoading = -(modal.loading.width() + outer.w.border + outer.w.padding)/2;
		if (!modal.blocker) {
			currentSettings.marginLefttLoading+= currentSettings.marginScrollLeft;
			currentSettings.marginTopLoading+= currentSettings.marginScrollTop;
		}
	}

	// Set the modal Title
	function setTitle() {
		var title = $('h1#nyroModalTitle', modal.contentWrapper);
		if (title.length)
			title.text(currentSettings.title);
		else
			modal.contentWrapper.prepend('<h1 id="nyroModalTitle">'+currentSettings.title+'</h1>');
	}

	// Init the nyroModal div by settings the CSS elements and hide needed elements
	function initModal() {
		debug('initModal');
		if (!modal.full) {
			if (currentSettings.debug)
				setCurrentSettings({color: 'white'}, 'css', 'bg');

			var full = {
				zIndex: currentSettings.zIndexStart,
				position: 'fixed',
				top: 0,
				left: 0,
				width: '100%',
				height: '100%'
			};

			var contain = body;
			var iframeHideIE = '';
			if (currentSettings.blocker) {
				modal.blocker = contain = $(currentSettings.blocker);
				var pos = modal.blocker.offset();
				var w = modal.blocker.outerWidth();
				var h = modal.blocker.outerHeight();
				if (isIE6) {
					setCurrentSettings({
						height: '100%',
						width: '100%',
						top: 0,
						left: 0
					}, 'css', 'bg');
				}
				modal.blockerVars = {
					top: pos.top,
					left: pos.left,
					width: w,
					height: h
				};
				var plusTop = (/msie/.test(userAgent) ?0:getCurCSS(body.get(0), 'borderTopWidth'));
				var plusLeft = (/msie/.test(userAgent) ?0:getCurCSS(body.get(0), 'borderLeftWidth'));
				full = {
					position: 'absolute',
					top: pos.top + plusTop,
					left: pos.left + plusLeft,
					width: w,
					height: h
				};
			} else if (isIE6) {
				body.css({
					height: '130%', //body.height()+'px',
					width: '130%', //body.width()+'px',
					position: 'static',
					overflow: 'hidden'
				});
				$('html').css({overflow: 'hidden'});
				setCurrentSettings({
					css: {
						bg: {
							position: 'absolute',
							zIndex: currentSettings.zIndexStart+1,
							height: '110%',
							width: '110%',
							top: currentSettings.marginScrollTop+'px',
							left: currentSettings.marginScrollLeft+'px'
						},
						wrapper: { zIndex: currentSettings.zIndexStart+2 },
						loading: { zIndex: currentSettings.zIndexStart+3 }
					}
				});

				iframeHideIE = $('<iframe id="nyroModalIframeHideIe" src="javascript:\'\';"></iframe>')
								.css($.extend({},
									currentSettings.css.bg, {
										opacity: 0,
										zIndex: 50,
										border: 'none'
									}));
			}

			contain.append($('<div id="nyroModalFull"><div id="nyroModalBg"></div><div id="nyroModalWrapper"><div id="nyroModalContent"></div></div><div id="nyrModalTmp"></div><div id="nyroModalLoading"></div></div>').hide());

			modal.full = $('#nyroModalFull')
				.css(full)
				.show();
			modal.bg = $('#nyroModalBg')
				.css($.extend({
						backgroundColor: currentSettings.bgColor
					}, currentSettings.css.bg))
				.before(iframeHideIE);
			if (!currentSettings.modal)
				modal.bg.click(removeModal);
			modal.loading = $('#nyroModalLoading')
				.css(currentSettings.css.loading)
				.hide();
			modal.contentWrapper = $('#nyroModalWrapper')
				.css(currentSettings.css.wrapper)
				.hide();
			modal.content = $('#nyroModalContent');
			modal.tmp = $('#nyrModalTmp').hide();

			// To stop the mousewheel if the the plugin is available
			if ($.isFunction($.fn.mousewheel)) {
				modal.content.mousewheel(function(e, d) {
					var elt = modal.content.get(0);
					if ((d > 0 && elt.scrollTop == 0) ||
							(d < 0 && elt.scrollHeight - elt.scrollTop == elt.clientHeight)) {
						e.preventDefault();
						e.stopPropagation();
					}
				});
			}

			$(document).bind('keydown.nyroModal', keyHandler);
			modal.content.css({width: 'auto', height: 'auto'});
			modal.contentWrapper.css({width: 'auto', height: 'auto'});

			if (!currentSettings.blocker) {
				$(window).bind('resize.nyroModal', function() {
					window.clearTimeout(windowResizeTimeout);
					windowResizeTimeout = window.setTimeout(windowResizeHandler, 200);
				});
			}
		}
	}

	function windowResizeHandler() {
		$.nyroModalSettings(initSettingsSize);
	}

	// Show the modal (ie: the background and then the loading if needed or the content directly)
	function showModal() {
		debug('showModal');
		if (!modal.ready) {
			initModal();
			modal.anim = true;
			currentSettings.showBackground(modal, currentSettings, endBackground);
		} else {
			modal.anim = true;
			modal.transition = true;
			currentSettings.showTransition(modal, currentSettings, function(){endHideContent();modal.anim=false;showContentOrLoading();});
		}
	}

	// Used for the escape key or the arrow in the gallery type
	function keyHandler(e) {
		if (e.keyCode == 27) {
			if (!currentSettings.modal)
				removeModal();
		} else if (currentSettings.gallery && modal.ready && modal.dataReady && !modal.anim && !modal.transition) {
			if (e.keyCode == 39 || e.keyCode == 40) {
				e.preventDefault();
				$.nyroModalNext();
				return false;
			} else if (e.keyCode == 37 || e.keyCode == 38) {
				e.preventDefault();
				$.nyroModalPrev();
				return false;
			}
		}
	}

	// Determine the filetype regarding the link DOM element
	function fileType() {
		var from = currentSettings.from;

		var url;

		if (from && from.nodeName) {
			var jFrom = $(from);

			url = jFrom.attr(from.nodeName.toLowerCase() == 'form' ? 'action' : 'href');
			if (!url)
				url = location.href.substring(window.location.host.length+7);
			currentSettings.url = url;

			if (jFrom.attr('rev') == 'modal')
				currentSettings.modal = true;

			currentSettings.title = jFrom.attr('title');

			if (from && from.rel && from.rel.toLowerCase() != 'nofollow') {
				var indexSpace = from.rel.indexOf(' ');
				currentSettings.gallery = indexSpace > 0 ? from.rel.substr(0, indexSpace) : from.rel;
			}

			var imgType = imageType(url, from);
			if (imgType)
				return imgType;

			if (isSwf(url))
				return 'swf';

			var iframe = false;
			if (from.target && from.target.toLowerCase() == '_blank' || (from.hostname && from.hostname.replace(/:\d*$/,'') != window.location.hostname.replace(/:\d*$/,''))) {
				iframe = true;
			}
			if (from.nodeName.toLowerCase() == 'form') {
				if (iframe)
					return 'iframeForm';
				setCurrentSettings(extractUrlSel(url));
				if (jFrom.attr('enctype') == 'multipart/form-data')
					return 'formData';
				return 'form';
			}
			if (iframe)
				return 'iframe';
		} else {
			url = currentSettings.url;
			if (!currentSettings.content)
				currentSettings.from = true;

			if (!url)
				return null;

			if (isSwf(url))
				return 'swf';

			var reg1 = new RegExp("^http://|https://", "g");
			if (url.match(reg1))
				return 'iframe';
		}

		var imgType = imageType(url, from);
		if (imgType)
			return imgType;

		var tmp = extractUrlSel(url);
		setCurrentSettings(tmp);

		if (!tmp.url)
			return tmp.selector;
	}

	function imageType(url, from) {
		var image = new RegExp(currentSettings.regexImg, 'i');
		if (image.test(url)) {
			return 'image';
		}
	}

	function isSwf(url) {
		var swf = new RegExp('[^\.]\.(swf)\s*$', 'i');
		return swf.test(url);
	}

	function extractUrlSel(url) {
		var ret = {
			url: null,
			selector: null
		};

		if (url) {
			var hash = getHash(url);
			var hashLoc = getHash(window.location.href);
			var curLoc = window.location.href.substring(0, window.location.href.length - hashLoc.length);
			var req = url.substring(0, url.length - hash.length);

			if (req == curLoc || req == $('base').attr('href')) {
				ret.selector = hash;
			} else {
				ret.url = req;
				ret.selector = hash;
			}
		}
		return ret;
	}

	// Called when the content cannot be loaded or tiemout reached
	function loadingError() {
		debug('loadingError');

		modal.error = true;

		if (!modal.ready)
			return;

		if ($.isFunction(currentSettings.handleError))
			currentSettings.handleError(modal, currentSettings);

		modal.loading
			.addClass(currentSettings.errorClass)
			.html(currentSettings.contentError);
		$(currentSettings.closeSelector, modal.loading)
			.unbind('click.nyroModal')
			.bind('click.nyroModal', removeModal);
		setMarginLoading();
		modal.loading
			.css({
				marginTop: currentSettings.marginTopLoading+'px',
				marginLeft: currentSettings.marginLeftLoading+'px'
			});
	}

	// Put the content from modal.tmp to modal.content
	function fillContent() {
		debug('fillContent');
		if (!modal.tmp.html())
			return;

		modal.content.html(modal.tmp.contents());
		modal.tmp.empty();
		wrapContent();

		if (currentSettings.type == 'iframeForm') {
			$(currentSettings.from)
				.attr('target', 'nyroModalIframe')
				.data('nyroModalprocessing', 1)
				.submit()
				.attr('target', '_blank')
				.removeData('nyroModalprocessing');
		}

		if (!currentSettings.modal)
			modal.wrapper.prepend(currentSettings.closeButton);

		if ($.isFunction(currentSettings.endFillContent))
			currentSettings.endFillContent(modal, currentSettings);

		modal.content.append(modal.scripts);

		$(currentSettings.closeSelector, modal.contentWrapper)
			.unbind('click.nyroModal')
			.bind('click.nyroModal', removeModal);
		$(currentSettings.openSelector, modal.contentWrapper).nyroModal(getCurrentSettingsNew());
	}

	// Get the current settings to be used in new links
	function getCurrentSettingsNew() {
		var currentSettingsNew = $.extend(true, {}, currentSettings);
		if (resized.width)
			currentSettingsNew.width = null;
		else
			currentSettingsNew.width = initSettingsSize.width;
		if (resized.height)
			currentSettingsNew.height = null;
		else
			currentSettingsNew.height = initSettingsSize.height;
		currentSettingsNew.css.content.overflow = 'auto';
		return currentSettingsNew;
	}

	// Wrap the content and update the modal size if needed
	function wrapContent() {
		debug('wrapContent');

		var wrap = $(currentSettings.wrap[currentSettings.type]);
		modal.content.append(wrap.children().remove());
		modal.contentWrapper.wrapInner(wrap);

		if (currentSettings.gallery) {
			// Set the action for the next and prev button (or remove them)
			modal.content.append(currentSettings.galleryLinks);

			gallery.links = $('[rel="'+currentSettings.gallery+'"], [rel^="'+currentSettings.gallery+' "]');
			gallery.index = gallery.links.index(currentSettings.from);

			if (currentSettings.galleryCounts && $.isFunction(currentSettings.galleryCounts))
				currentSettings.galleryCounts(gallery.index + 1, gallery.links.length, modal, currentSettings);

			var currentSettingsNew = getCurrentSettingsNew();

			var linkPrev = getGalleryLink(-1);
			if (linkPrev) {
				var prev = $('.nyroModalPrev', modal.contentWrapper)
					.attr('href', linkPrev.attr('href'))
					.click(function(e) {
						e.preventDefault();
						$.nyroModalPrev();
						return false;
					});
				if (isIE6 && currentSettings.type == 'swf') {
					prev.before($('<iframe id="nyroModalIframeHideIeGalleryPrev" src="javascript:\'\';"></iframe>').css({
											position: prev.css('position'),
											top: prev.css('top'),
											left: prev.css('left'),
											width: prev.width(),
											height: prev.height(),
											opacity: 0,
											border: 'none'
										}));
				}
			} else {
				$('.nyroModalPrev', modal.contentWrapper).remove();
			}
			var linkNext = getGalleryLink(1);
			if (linkNext) {
				var next = $('.nyroModalNext', modal.contentWrapper)
					.attr('href', linkNext.attr('href'))
					.click(function(e) {
						e.preventDefault();
						$.nyroModalNext();
						return false;
					});
				if (isIE6 && currentSettings.type == 'swf') {
					next.before($('<iframe id="nyroModalIframeHideIeGalleryNext" src="javascript:\'\';"></iframe>')
									.css($.extend({}, {
											position: next.css('position'),
											top: next.css('top'),
											left: next.css('left'),
											width: next.width(),
											height: next.height(),
											opacity: 0,
											border: 'none'
										})));
				}
			} else {
				$('.nyroModalNext', modal.contentWrapper).remove();
			}
		}

		calculateSize();
	}

	function getGalleryLink(dir) {
		if (currentSettings.gallery) {
			if (!currentSettings.ltr)
				dir *= -1;
			var index = gallery.index + dir;
			if (index >= 0 && index < gallery.links.length)
				return gallery.links.eq(index);
		}
		return false;
	}

	// Calculate the size for the contentWrapper
	function calculateSize(resizing) {
		debug('calculateSize');

		modal.wrapper = modal.contentWrapper.children('div:first');

		resized.width = false;
		resized.height = false;
		if (false && !currentSettings.windowResizing) {
			initSettingsSize.width = currentSettings.width;
			initSettingsSize.height = currentSettings.height;
		}

		if (currentSettings.autoSizable && (!currentSettings.width || !currentSettings.height)) {
			modal.contentWrapper
				.css({
					opacity: 0,
					width: 'auto',
					height: 'auto'
				})
				.show();
			var tmp = {
				width: 'auto',
				height: 'auto'
			};
			if (currentSettings.width) {
				tmp.width = currentSettings.width;
			} else if (currentSettings.type == 'iframe') {
				tmp.width = currentSettings.minWidth;
			}

			if (currentSettings.height) {
				tmp.height = currentSettings.height;
			} else if (currentSettings.type == 'iframe') {
				tmp.height = currentSettings.minHeight;
			}

			modal.content.css(tmp);
			if (!currentSettings.width) {
				currentSettings.width = modal.content.outerWidth(true);
				resized.width = true;
			}
			if (!currentSettings.height) {
				currentSettings.height = modal.content.outerHeight(true);
				resized.height = true;
			}
			modal.contentWrapper.css({opacity: 1});
			if (!resizing)
				modal.contentWrapper.hide();
		}

		if (currentSettings.type != 'image' && currentSettings.type != 'swf') {
			currentSettings.width = Math.max(currentSettings.width, currentSettings.minWidth);
			currentSettings.height = Math.max(currentSettings.height, currentSettings.minHeight);
		}

		var outerWrapper = getOuter(modal.contentWrapper);
		var outerWrapper2 = getOuter(modal.wrapper);
		var outerContent = getOuter(modal.content);

		var tmp = {
			content: {
				width: currentSettings.width,
				height: currentSettings.height
			},
			wrapper2: {
				width: currentSettings.width + outerContent.w.total,
				height: currentSettings.height + outerContent.h.total
			},
			wrapper: {
				width: currentSettings.width + outerContent.w.total + outerWrapper2.w.total,
				height: currentSettings.height + outerContent.h.total + outerWrapper2.h.total
			}
		};

		if (currentSettings.resizable) {
			var maxHeight = modal.blockerVars? modal.blockerVars.height : $(window).height()
								- outerWrapper.h.border
								- (tmp.wrapper.height - currentSettings.height);
			var maxWidth = modal.blockerVars? modal.blockerVars.width : $(window).width()
								- outerWrapper.w.border
								- (tmp.wrapper.width - currentSettings.width);
			maxHeight-= currentSettings.padding*2;
			maxWidth-= currentSettings.padding*2;

			if (tmp.content.height > maxHeight || tmp.content.width > maxWidth) {
				// We're gonna resize the modal as it will goes outside the view port
				if (currentSettings.type == 'image' || currentSettings.type == 'swf') {
					// An image is resized proportionnaly
					var useW = currentSettings.imgWidth?currentSettings.imgWidth : currentSettings.width;
					var useH = currentSettings.imgHeight?currentSettings.imgHeight : currentSettings.height;
					var diffW = tmp.content.width - useW;
					var diffH = tmp.content.height - useH;
						if (diffH < 0) diffH = 0;
						if (diffW < 0) diffW = 0;
					var calcH = maxHeight - diffH;
					var calcW = maxWidth - diffW;
					var ratio = Math.min(calcH/useH, calcW/useW);
					calcW = Math.floor(useW*ratio);
					calcH = Math.floor(useH*ratio);
					tmp.content.height = calcH + diffH;
					tmp.content.width = calcW + diffW;
				} else {
					// For an HTML content, we simply decrease the size
					tmp.content.height = Math.min(tmp.content.height, maxHeight);
					tmp.content.width = Math.min(tmp.content.width, maxWidth);
				}
				tmp.wrapper2 = {
						width: tmp.content.width + outerContent.w.total,
						height: tmp.content.height + outerContent.h.total
					};
				tmp.wrapper = {
						width: tmp.content.width + outerContent.w.total + outerWrapper2.w.total,
						height: tmp.content.height + outerContent.h.total + outerWrapper2.h.total
					};
			}
		}

		if (currentSettings.type == 'swf') {
			$('object, embed', modal.content)
				.attr('width', tmp.content.width)
				.attr('height', tmp.content.height);
		} else if (currentSettings.type == 'image') {
			$('img', modal.content).css({
				width: tmp.content.width,
				height: tmp.content.height
			});
		}

		modal.content.css($.extend({}, tmp.content, currentSettings.css.content));
		modal.wrapper.css($.extend({}, tmp.wrapper2, currentSettings.css.wrapper2));

		if (!resizing)
			modal.contentWrapper.css($.extend({}, tmp.wrapper, currentSettings.css.wrapper));

		if (currentSettings.type == 'image' && currentSettings.addImageDivTitle) {
			// Adding the title for the image
			$('img', modal.content).removeAttr('alt');
			var divTitle = $('div', modal.content);
			if (currentSettings.title != currentSettings.defaultImgAlt && currentSettings.title) {
				if (divTitle.length == 0) {
					divTitle = $('<div>'+currentSettings.title+'</div>');
					modal.content.append(divTitle);
				}
				if (currentSettings.setWidthImgTitle) {
					var outerDivTitle = getOuter(divTitle);
					divTitle.css({width: (tmp.content.width + outerContent.w.padding - outerDivTitle.w.total)+'px'});
				}
			} else if (divTitle.length = 0) {
				divTitle.remove();
			}
		}

		if (currentSettings.title)
			setTitle();

		tmp.wrapper.borderW = outerWrapper.w.border;
		tmp.wrapper.borderH = outerWrapper.h.border;

		setCurrentSettings(tmp.wrapper);
		setMargin();
	}

	function removeModal(e) {
		debug('removeModal');
		if (e)
			e.preventDefault();
		if (modal.full && modal.ready) {
			$(document).unbind('keydown.nyroModal');
			if (!currentSettings.blocker)
				$(window).unbind('resize.nyroModal');
			modal.ready = false;
			modal.anim = true;
			modal.closing = true;
			if (modal.loadingShown || modal.transition) {
				currentSettings.hideLoading(modal, currentSettings, function() {
						modal.loading.hide();
						modal.loadingShown = false;
						modal.transition = false;
						currentSettings.hideBackground(modal, currentSettings, endRemove);
					});
			} else {
				if (fixFF)
					modal.content.css({position: ''}); // Fix Issue #10, remove the attribute
				modal.wrapper.css({overflow: 'hidden'}); // Used to fix a visual issue when hiding
				modal.content.css({overflow: 'hidden'}); // Used to fix a visual issue when hiding
				if ($.isFunction(currentSettings.beforeHideContent)) {
					currentSettings.beforeHideContent(modal, currentSettings, function() {
						currentSettings.hideContent(modal, currentSettings, function() {
							endHideContent();
							currentSettings.hideBackground(modal, currentSettings, endRemove);
						});
					});
				} else {
					currentSettings.hideContent(modal, currentSettings, function() {
							endHideContent();
							currentSettings.hideBackground(modal, currentSettings, endRemove);
						});
				}
			}
		}
		if (e)
			return false;
	}

	function showContentOrLoading() {
		debug('showContentOrLoading');
		if (modal.ready && !modal.anim) {
			if (modal.dataReady) {
				if (modal.tmp.html()) {
					modal.anim = true;
					if (modal.transition) {
						fillContent();
						modal.animContent = true;
						currentSettings.hideTransition(modal, currentSettings, function() {
							modal.loading.hide();
							modal.transition = false;
							modal.loadingShown = false;
							endShowContent();
						});
					} else {
						currentSettings.hideLoading(modal, currentSettings, function() {
								modal.loading.hide();
								modal.loadingShown = false;
								fillContent();
								setMarginLoading();
								setMargin();
								modal.animContent = true;
								currentSettings.showContent(modal, currentSettings, endShowContent);
							});
					}
				}
			} else if (!modal.loadingShown && !modal.transition) {
				modal.anim = true;
				modal.loadingShown = true;
				if (modal.error)
					loadingError();
				else
					modal.loading.html(currentSettings.contentLoading);
				$(currentSettings.closeSelector, modal.loading)
					.unbind('click.nyroModal')
					.bind('click.nyroModal', removeModal);
				setMarginLoading();
				currentSettings.showLoading(modal, currentSettings, function(){modal.anim=false;showContentOrLoading();});
			}
		}
	}


	// -------------------------------------------------------
	// Private Data Loaded callback
	// -------------------------------------------------------

	function ajaxLoaded(data) {
		debug('AjaxLoaded: '+this.url);
		modal.tmp.html(currentSettings.selector
			?filterScripts($('<div>'+data+'</div>').find(currentSettings.selector).contents())
			:filterScripts(data));
		if (modal.tmp.html()) {
			modal.dataReady = true;
			showContentOrLoading();
		} else
			loadingError();
	}

	function formDataLoaded() {
		debug('formDataLoaded');
		var jFrom = $(currentSettings.from);
		jFrom.attr('action', jFrom.attr('action')+currentSettings.selector);
		jFrom.attr('target', '');
		$('input[name='+currentSettings.formIndicator+']', currentSettings.from).remove();
		var iframe = modal.tmp.children('iframe');
		var iframeContent = iframe.unbind('load').contents().find(currentSettings.selector || 'body').not('script[src]');
		iframe.attr('src', 'about:blank'); // Used to stop the loading in FF
		modal.tmp.html(iframeContent.html());
		if (modal.tmp.html()) {
			modal.dataReady = true;
			showContentOrLoading();
		} else
			loadingError();
	}
	
	function iframeLoaded() {
		if ((window.location.hostname && currentSettings.url.indexOf(window.location.hostname) > -1)
				||	currentSettings.url.indexOf('http://')) {
			var iframe = $('iframe', modal.full).contents();
			var tmp = {};
			if (currentSettings.titleFromIframe)
				tmp.title = iframe.find('title').text();
			if (!tmp.title) {
				// for IE
				try {
					tmp.title = iframe.find('title').html();
				} catch(err) {}
			}
			var body = iframe.find('body');
			if (!currentSettings.height && body.height())
				tmp.height = body.height();
			if (!currentSettings.width && body.width())
				tmp.width = body.width();
			$.extend(initSettingsSize, tmp);
			$.nyroModalSettings(tmp);
		}
	}

	function galleryCounts(nb, total, elts, settings) {
		if (total > 1)
			settings.title+= (settings.title?' - ':'') +nb+'/'+total;
	}


	// -------------------------------------------------------
	// Private Animation callback
	// -------------------------------------------------------

	function endHideContent() {
		debug('endHideContent');
		modal.anim = false;
		if (contentEltLast) {
			contentEltLast.append(modal.content.contents());
			contentEltLast = null;
		} else if (contentElt) {
			contentElt.append(modal.content.contents());
			contentElt= null;
		}
		modal.content.empty();

		gallery = {};

		modal.contentWrapper.hide().children().remove().empty().attr('style', '').hide();

		if (modal.closing || modal.transition)
			modal.contentWrapper.hide();

		modal.contentWrapper
			.css(currentSettings.css.wrapper)
			.append(modal.content);
		showContentOrLoading();
	}

	function endRemove() {
		debug('endRemove');
		$(document).unbind('keydown', keyHandler);
		modal.anim = false;
		modal.full.remove();
		modal.full = null;
		if (isIE6) {
			body.css({height: '', width: '', position: '', overflow: ''});
			$('html').css({overflow: ''});
		}
		if ($.isFunction(currentSettings.endRemove))
			currentSettings.endRemove(modal, currentSettings);
	}

	function endBackground() {
		debug('endBackground');
		modal.ready = true;
		modal.anim = false;
		showContentOrLoading();
	}

	function endShowContent() {
		debug('endShowContent');
		modal.anim = false;
		modal.animContent = false;
		modal.contentWrapper.css({opacity: ''}); // for the close button in IE
		fixFF = /mozilla/.test(userAgent) && !/(compatible|webkit)/.test(userAgent) && parseFloat(browserVersion) < 1.9 && currentSettings.type != 'image';

		if (fixFF)
			modal.content.css({position: 'fixed'}); // Fix Issue #10
		modal.content.append(modal.scriptsShown);

		if(currentSettings.type == 'iframe')
			modal.content.find('iframe').attr('src', currentSettings.url);

		if ($.isFunction(currentSettings.endShowContent))
			currentSettings.endShowContent(modal, currentSettings);

		if (shouldResize) {
			shouldResize = false;
			$.nyroModalSettings({width: currentSettings.setWidth, height: currentSettings.setHeight});
			delete currentSettings['setWidth'];
			delete currentSettings['setHeight'];
		}
		if (resized.width)
			setCurrentSettings({width: null});
		if (resized.height)
			setCurrentSettings({height: null});
	}


	// -------------------------------------------------------
	// Utilities
	// -------------------------------------------------------

	// Get the selector from an url (as string)
	function getHash(url) {
		if (typeof url == 'string') {
			var hashPos = url.indexOf('#');
			if (hashPos > -1)
				return url.substring(hashPos);
		}
		return '';
	}

	// Filter an html content to remove the script[src]
	function filterScripts(data) {
		// Removing the body, head and html tag
		if (typeof data == 'string')
			data = data.replace(/<\/?(html|head|body)([^>]*)>/gi, '');
		var tmp = new Array();
		$.each($.clean({0:data}, this.ownerDocument), function() {
			if ($.nodeName(this, "script")) {
				if (!this.src || $(this).attr('rel') == 'forceLoad') {
					if ($(this).attr('rev') == 'shown')
						modal.scriptsShown.push(this);
					else
						modal.scripts.push(this);
				}
			} else
				tmp.push(this);
		});
		return tmp;
	}

	// Get the vertical and horizontal margin, padding and border dimension
	function getOuter(elm) {
		elm = elm.get(0);
		var ret = {
			h: {
				margin: getCurCSS(elm, 'marginTop') + getCurCSS(elm, 'marginBottom'),
				border: getCurCSS(elm, 'borderTopWidth') + getCurCSS(elm, 'borderBottomWidth'),
				padding: getCurCSS(elm, 'paddingTop') + getCurCSS(elm, 'paddingBottom')
			},
			w: {
				margin: getCurCSS(elm, 'marginLeft') + getCurCSS(elm, 'marginRight'),
				border: getCurCSS(elm, 'borderLeftWidth') + getCurCSS(elm, 'borderRightWidth'),
				padding: getCurCSS(elm, 'paddingLeft') + getCurCSS(elm, 'paddingRight')
			}
		};

		ret.h.outer = ret.h.margin + ret.h.border;
		ret.w.outer = ret.w.margin + ret.w.border;

		ret.h.inner = ret.h.padding + ret.h.border;
		ret.w.inner = ret.w.padding + ret.w.border;

		ret.h.total = ret.h.outer + ret.h.padding;
		ret.w.total = ret.w.outer + ret.w.padding;

		return ret;
	}

	function getCurCSS(elm, name) {
		var ret = parseInt($.curCSS(elm, name, true));
		if (isNaN(ret))
			ret = 0;
		return ret;
	}

	// Proxy Debug function
	function debug(msg) {
		if ($.fn.nyroModal.settings.debug || currentSettings && currentSettings.debug)
			nyroModalDebug(msg, modal, currentSettings || {});
	}

	// -------------------------------------------------------
	// Default animation function
	// -------------------------------------------------------

	function showBackground(elts, settings, callback) {
		elts.bg.css({opacity:0}).fadeTo(500, 0.75, callback);
	}

	function hideBackground(elts, settings, callback) {
		elts.bg.fadeOut(300, callback);
	}

	function showLoading(elts, settings, callback) {
		elts.loading
			.css({
				marginTop: settings.marginTopLoading+'px',
				marginLeft: settings.marginLeftLoading+'px',
				opacity: 0
			})
			.show()
			.animate({
				opacity: 1
			}, {complete: callback, duration: 400});
	}

	function hideLoading(elts, settings, callback) {
		callback();
	}

	function showContent(elts, settings, callback) {
		elts.loading
			.css({
				marginTop: settings.marginTopLoading+'px',
				marginLeft: settings.marginLeftLoading+'px'
			})
			.show()
			.animate({
				width: settings.width+'px',
				height: settings.height+'px',
				marginTop: settings.marginTop+'px',
				marginLeft: settings.marginLeft+'px'
			}, {duration: 350, complete: function() {
				elts.contentWrapper
					.css({
						width: settings.width+'px',
						height: settings.height+'px',
						marginTop: settings.marginTop+'px',
						marginLeft: settings.marginLeft+'px'
					})
					.show();
					elts.loading.fadeOut(200, callback);
				}
			});
	}

	function hideContent(elts, settings, callback) {
		elts.contentWrapper
			.animate({
				height: '50px',
				width: '50px',
				marginTop: (-(25+settings.borderH)/2 + settings.marginScrollTop)+'px',
				marginLeft: (-(25+settings.borderW)/2 + settings.marginScrollLeft)+'px'
			}, {duration: 350, complete: function() {
				elts.contentWrapper.hide();
				callback();
			}});
	}

	function showTransition(elts, settings, callback) {
		// Put the loading with the same dimensions of the current content
		elts.loading
			.css({
				marginTop: elts.contentWrapper.css('marginTop'),
				marginLeft: elts.contentWrapper.css('marginLeft'),
				height: elts.contentWrapper.css('height'),
				width: elts.contentWrapper.css('width'),
				opacity: 0
			})
			.show()
			.fadeTo(400, 1, function() {
					elts.contentWrapper.hide();
					callback();
				});
	}

	function hideTransition(elts, settings, callback) {
		// Place the content wrapper underneath the the loading with the right dimensions
		elts.contentWrapper
			.hide()
			.css({
				width: settings.width+'px',
				height: settings.height+'px',
				marginLeft: settings.marginLeft+'px',
				marginTop: settings.marginTop+'px',
				opacity: 1
			});
		elts.loading
			.animate({
				width: settings.width+'px',
				height: settings.height+'px',
				marginLeft: settings.marginLeft+'px',
				marginTop: settings.marginTop+'px'
			}, {complete: function() {
					elts.contentWrapper.show();
					elts.loading.fadeOut(400, function() {
						elts.loading.hide();
						callback();
					});
				}, duration: 350});
	}

	function resize(elts, settings, callback) {
		elts.contentWrapper
			.animate({
				width: settings.width+'px',
				height: settings.height+'px',
				marginLeft: settings.marginLeft+'px',
				marginTop: settings.marginTop+'px'
			}, {complete: callback, duration: 400});
	}

	function updateBgColor(elts, settings, callback) {
		if (!$.fx.step.backgroundColor) {
			elts.bg.css({backgroundColor: settings.bgColor});
			callback();
		} else
			elts.bg
				.animate({
					backgroundColor: settings.bgColor
				}, {complete: callback, duration: 400});
	}

	// -------------------------------------------------------
	// Default initialization
	// -------------------------------------------------------

	$($.fn.nyroModal.settings.openSelector).nyroModal();

});

// Default debug function, to be overwritten if needed
//      Be aware that the settings parameter could be empty
function nyroModalDebug(msg, elts, settings) {
	if (elts.full)
		elts.bg.prepend(msg+'<br />');
}