/*
 * jQuery validation plug-in 1.6
 *
 * http://bassistance.de/jquery-plugins/jquery-plugin-validation/
 * http://docs.jquery.com/Plugins/Validation
 *
 * Copyright (c) 2006 - 2008 J�rn Zaefferer
 *
 * $Id: jquery.validate.js 6403 2009-06-17 14:27:16Z joern.zaefferer $
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 */
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}('(7($){$.H($.2O,{1d:7(d){l(!6.F){d&&d.24&&2Y.1H&&1H.52("3v 3o, 4N\'t 1d, 67 3v");8}p c=$.17(6[0],\'v\');l(c){8 c}c=2e $.v(d,6[0]);$.17(6[0],\'v\',c);l(c.q.3u){6.3r("1B, 3j").1n(".4G").3b(7(){c.3a=w});l(c.q.35){6.3r("1B, 3j").1n(":23").3b(7(){c.1V=6})}6.23(7(b){l(c.q.24)b.5N();7 2m(){l(c.q.35){l(c.1V){p a=$("<1B 1A=\'5v\'/>").1p("u",c.1V.u).2M(c.1V.Z).51(c.U)}c.q.35.11(c,c.U);l(c.1V){a.3A()}8 I}8 w}l(c.3a){c.3a=I;8 2m()}l(c.M()){l(c.1a){c.1l=w;8 I}8 2m()}16{c.2h();8 I}})}8 c},J:7(){l($(6[0]).2Z(\'M\')){8 6.1d().M()}16{p b=w;p a=$(6[0].M).1d();6.P(7(){b&=a.L(6)});8 b}},4F:7(c){p d={},$L=6;$.P(c.1O(/\\s/),7(a,b){d[b]=$L.1p(b);$L.6c(b)});8 d},1f:7(h,k){p f=6[0];l(h){p i=$.17(f.M,\'v\').q;p d=i.1f;p c=$.v.2D(f);22(h){1b"1e":$.H(c,$.v.1N(k));d[f.u]=c;l(k.G)i.G[f.u]=$.H(i.G[f.u],k.G);2K;1b"3A":l(!k){S d[f.u];8 c}p e={};$.P(k.1O(/\\s/),7(a,b){e[b]=c[b];S c[b]});8 e}}p g=$.v.42($.H({},$.v.3Y(f),$.v.3W(f),$.v.3U(f),$.v.2D(f)),f);l(g.14){p j=g.14;S g.14;g=$.H({14:j},g)}8 g}});$.H($.5s[":"],{5p:7(a){8!$.1q(""+a.Z)},5i:7(a){8!!$.1q(""+a.Z)},5f:7(a){8!a.4l}});$.v=7(b,a){6.q=$.H({},$.v.33,b);6.U=a;6.3I()};$.v.W=7(c,b){l(T.F==1)8 7(){p a=$.3D(T);a.4V(c);8 $.v.W.1Q(6,a)};l(T.F>2&&b.29!=3x){b=$.3D(T).4R(1)}l(b.29!=3x){b=[b]}$.P(b,7(i,n){c=c.1P(2e 3s("\\\\{"+i+"\\\\}","g"),n)});8 c};$.H($.v,{33:{G:{},2d:{},1f:{},19:"3p",26:"J",2C:"4Q",2h:w,3l:$([]),2A:$([]),3u:w,3i:[],3Q:I,4O:7(a){6.3e=a;l(6.q.4M&&!6.4J){6.q.1L&&6.q.1L.11(6,a,6.q.19,6.q.26);6.1K(a).2y()}},4E:7(a){l(!6.1D(a)&&(a.u V 6.1c||!6.K(a))){6.L(a)}},6b:7(a){l(a.u V 6.1c||a==6.4y){6.L(a)}},69:7(a){l(a.u V 6.1c)6.L(a);16 l(a.4v.u V 6.1c)6.L(a.4v)},38:7(a,c,b){$(a).1Y(c).2w(b)},1L:7(a,c,b){$(a).2w(c).1Y(b)}},65:7(a){$.H($.v.33,a)},G:{14:"61 4q 2Z 14.",1r:"N 2L 6 4q.",1I:"N O a J 1I 60.",1v:"N O a J 5X.",1u:"N O a J 1u.",2q:"N O a J 1u (5R).",1s:"N O a J 1s.",1U:"N O 5P 1U.",2c:"N O a J 5O 5M 1s.",2n:"N O 47 5I Z 5H.",44:"N O a Z 5C a J 5B.",18:$.v.W("N O 3X 5y 2X {0} 2W."),1z:$.v.W("N O 5x 5w {0} 2W."),2j:$.v.W("N O a Z 3V {0} 45 {1} 2W 5q."),2i:$.v.W("N O a Z 3V {0} 45 {1}."),1x:$.v.W("N O a Z 5k 2X 3L 3K 48 {0}."),1F:$.v.W("N O a Z 5d 2X 3L 3K 48 {0}.")},3J:I,5b:{3I:7(){6.2r=$(6.q.2A);6.4i=6.2r.F&&6.2r||$(6.U);6.2s=$(6.q.3l).1e(6.q.2A);6.1c={};6.55={};6.1a=0;6.1i={};6.1g={};6.21();p f=(6.2d={});$.P(6.q.2d,7(d,c){$.P(c.1O(/\\s/),7(a,b){f[b]=d})});p e=6.q.1f;$.P(e,7(b,a){e[b]=$.v.1N(a)});7 1C(a){p b=$.17(6[0].M,"v");b.q["4A"+a.1A]&&b.q["4A"+a.1A].11(b,6[0])}$(6.U).1C("3F 3E 4W",":3C, :4U, :4T, 2b, 4S",1C).1C("3b",":3B, :3z, 2b, 3y",1C);l(6.q.3w)$(6.U).2J("1g-M.1d",6.q.3w)},M:7(){6.3t();$.H(6.1c,6.1w);6.1g=$.H({},6.1w);l(!6.J())$(6.U).2H("1g-M",[6]);6.1m();8 6.J()},3t:7(){6.2G();Q(p i=0,13=(6.27=6.13());13[i];i++){6.28(13[i])}8 6.J()},L:7(a){a=6.2F(a);6.4y=a;6.2E(a);6.27=$(a);p b=6.28(a);l(b){S 6.1g[a.u]}16{6.1g[a.u]=w}l(!6.3q()){6.12=6.12.1e(6.2s)}6.1m();8 b},1m:7(b){l(b){$.H(6.1w,b);6.R=[];Q(p c V b){6.R.2a({1j:b[c],L:6.2f(c)[0]})}6.1k=$.3n(6.1k,7(a){8!(a.u V b)})}6.q.1m?6.q.1m.11(6,6.1w,6.R):6.3m()},2B:7(){l($.2O.2B)$(6.U).2B();6.1c={};6.2G();6.2T();6.13().2w(6.q.19)},3q:7(){8 6.2g(6.1g)},2g:7(a){p b=0;Q(p i V a)b++;8 b},2T:7(){6.2P(6.12).2y()},J:7(){8 6.3N()==0},3N:7(){8 6.R.F},2h:7(){l(6.q.2h){3O{$(6.3h()||6.R.F&&6.R[0].L||[]).1n(":4P").3g()}3f(e){}}},3h:7(){p a=6.3e;8 a&&$.3n(6.R,7(n){8 n.L.u==a.u}).F==1&&a},13:7(){p a=6,2U={};8 $([]).1e(6.U.13).1n(":1B").1R(":23, :21, :4L, [4K]").1R(6.q.3i).1n(7(){!6.u&&a.q.24&&2Y.1H&&1H.3p("%o 4I 3X u 4H",6);l(6.u V 2U||!a.2g($(6).1f()))8 I;2U[6.u]=w;8 w})},2F:7(a){8 $(a)[0]},2z:7(){8 $(6.q.2C+"."+6.q.19,6.4i)},21:7(){6.1k=[];6.R=[];6.1w={};6.1o=$([]);6.12=$([]);6.27=$([])},2G:7(){6.21();6.12=6.2z().1e(6.2s)},2E:7(a){6.21();6.12=6.1K(a)},28:7(d){d=6.2F(d);l(6.1D(d)){d=6.2f(d.u)[0]}p a=$(d).1f();p c=I;Q(Y V a){p b={Y:Y,2l:a[Y]};3O{p f=$.v.1T[Y].11(6,d.Z.1P(/\\r/g,""),d,b.2l);l(f=="1S-1Z"){c=w;4D}c=I;l(f=="1i"){6.12=6.12.1R(6.1K(d));8}l(!f){6.3c(d,b);8 I}}3f(e){6.q.24&&2Y.1H&&1H.4C("6g 6f 6e 6d L "+d.4z+", 28 47 \'"+b.Y+"\' Y",e);6a e;}}l(c)8;l(6.2g(a))6.1k.2a(d);8 w},4x:7(a,b){l(!$.1y)8;p c=6.q.39?$(a).1y()[6.q.39]:$(a).1y();8 c&&c.G&&c.G[b]},4w:7(a,b){p m=6.q.G[a];8 m&&(m.29==4u?m:m[b])},4t:7(){Q(p i=0;i<T.F;i++){l(T[i]!==20)8 T[i]}8 20},2x:7(a,b){8 6.4t(6.4w(a.u,b),6.4x(a,b),!6.q.3Q&&a.68||20,$.v.G[b],"<4s>66: 64 1j 63 Q "+a.u+"</4s>")},3c:7(b,a){p c=6.2x(b,a.Y),36=/\\$?\\{(\\d+)\\}/g;l(1h c=="7"){c=c.11(6,a.2l,b)}16 l(36.15(c)){c=2v.W(c.1P(36,\'{$1}\'),a.2l)}6.R.2a({1j:c,L:b});6.1w[b.u]=c;6.1c[b.u]=c},2P:7(a){l(6.q.2u)a=a.1e(a.4p(6.q.2u));8 a},3m:7(){Q(p i=0;6.R[i];i++){p a=6.R[i];6.q.38&&6.q.38.11(6,a.L,6.q.19,6.q.26);6.34(a.L,a.1j)}l(6.R.F){6.1o=6.1o.1e(6.2s)}l(6.q.1G){Q(p i=0;6.1k[i];i++){6.34(6.1k[i])}}l(6.q.1L){Q(p i=0,13=6.4o();13[i];i++){6.q.1L.11(6,13[i],6.q.19,6.q.26)}}6.12=6.12.1R(6.1o);6.2T();6.2P(6.1o).4n()},4o:7(){8 6.27.1R(6.4m())},4m:7(){8 $(6.R).3d(7(){8 6.L})},34:7(a,c){p b=6.1K(a);l(b.F){b.2w().1Y(6.q.19);b.1p("4k")&&b.4j(c)}16{b=$("<"+6.q.2C+"/>").1p({"Q":6.32(a),4k:w}).1Y(6.q.19).4j(c||"");l(6.q.2u){b=b.2y().4n().5Z("<"+6.q.2u+"/>").4p()}l(!6.2r.5Y(b).F)6.q.4h?6.q.4h(b,$(a)):b.5W(a)}l(!c&&6.q.1G){b.3C("");1h 6.q.1G=="1t"?b.1Y(6.q.1G):6.q.1G(b)}6.1o=6.1o.1e(b)},1K:7(a){p b=6.32(a);8 6.2z().1n(7(){8 $(6).1p(\'Q\')==b})},32:7(a){8 6.2d[a.u]||(6.1D(a)?a.u:a.4z||a.u)},1D:7(a){8/3B|3z/i.15(a.1A)},2f:7(d){p c=6.U;8 $(5V.5U(d)).3d(7(a,b){8 b.M==c&&b.u==d&&b||4g})},1M:7(a,b){22(b.4f.3k()){1b\'2b\':8 $("3y:3o",b).F;1b\'1B\':l(6.1D(b))8 6.2f(b.u).1n(\':4l\').F}8 a.F},4e:7(b,a){8 6.2I[1h b]?6.2I[1h b](b,a):w},2I:{"5Q":7(b,a){8 b},"1t":7(b,a){8!!$(b,a.M).F},"7":7(b,a){8 b(a)}},K:7(a){8!$.v.1T.14.11(6,$.1q(a.Z),a)&&"1S-1Z"},4d:7(a){l(!6.1i[a.u]){6.1a++;6.1i[a.u]=w}},4c:7(a,b){6.1a--;l(6.1a<0)6.1a=0;S 6.1i[a.u];l(b&&6.1a==0&&6.1l&&6.M()){$(6.U).23();6.1l=I}16 l(!b&&6.1a==0&&6.1l){$(6.U).2H("1g-M",[6]);6.1l=I}},2o:7(a){8 $.17(a,"2o")||$.17(a,"2o",{31:4g,J:w,1j:6.2x(a,"1r")})}},1J:{14:{14:w},1I:{1I:w},1v:{1v:w},1u:{1u:w},2q:{2q:w},4b:{4b:w},1s:{1s:w},4a:{4a:w},1U:{1U:w},2c:{2c:w}},49:7(a,b){a.29==4u?6.1J[a]=b:$.H(6.1J,a)},3W:7(b){p a={};p c=$(b).1p(\'5L\');c&&$.P(c.1O(\' \'),7(){l(6 V $.v.1J){$.H(a,$.v.1J[6])}});8 a},3U:7(c){p a={};p d=$(c);Q(Y V $.v.1T){p b=d.1p(Y);l(b){a[Y]=b}}l(a.18&&/-1|5K|5J/.15(a.18)){S a.18}8 a},3Y:7(a){l(!$.1y)8{};p b=$.17(a.M,\'v\').q.39;8 b?$(a).1y()[b]:$(a).1y()},2D:7(b){p a={};p c=$.17(b.M,\'v\');l(c.q.1f){a=$.v.1N(c.q.1f[b.u])||{}}8 a},42:7(d,e){$.P(d,7(c,b){l(b===I){S d[c];8}l(b.30||b.2t){p a=w;22(1h b.2t){1b"1t":a=!!$(b.2t,e.M).F;2K;1b"7":a=b.2t.11(e,e);2K}l(a){d[c]=b.30!==20?b.30:w}16{S d[c]}}});$.P(d,7(a,b){d[a]=$.46(b)?b(e):b});$.P([\'1z\',\'18\',\'1F\',\'1x\'],7(){l(d[6]){d[6]=2Q(d[6])}});$.P([\'2j\',\'2i\'],7(){l(d[6]){d[6]=[2Q(d[6][0]),2Q(d[6][1])]}});l($.v.3J){l(d.1F&&d.1x){d.2i=[d.1F,d.1x];S d.1F;S d.1x}l(d.1z&&d.18){d.2j=[d.1z,d.18];S d.1z;S d.18}}l(d.G){S d.G}8 d},1N:7(a){l(1h a=="1t"){p b={};$.P(a.1O(/\\s/),7(){b[6]=w});a=b}8 a},5G:7(c,a,b){$.v.1T[c]=a;$.v.G[c]=b!=20?b:$.v.G[c];l(a.F<3){$.v.49(c,$.v.1N(c))}},1T:{14:7(c,d,a){l(!6.4e(a,d))8"1S-1Z";22(d.4f.3k()){1b\'2b\':p b=$(d).2M();8 b&&b.F>0;1b\'1B\':l(6.1D(d))8 6.1M(c,d)>0;5F:8 $.1q(c).F>0}},1r:7(f,h,j){l(6.K(h))8"1S-1Z";p g=6.2o(h);l(!6.q.G[h.u])6.q.G[h.u]={};g.43=6.q.G[h.u].1r;6.q.G[h.u].1r=g.1j;j=1h j=="1t"&&{1v:j}||j;l(g.31!==f){g.31=f;p k=6;6.4d(h);p i={};i[h.u]=f;$.2R($.H(w,{1v:j,41:"2S",40:"1d"+h.u,5A:"5z",17:i,1G:7(d){k.q.G[h.u].1r=g.43;p b=d===w;l(b){p e=k.1l;k.2E(h);k.1l=e;k.1k.2a(h);k.1m()}16{p a={};p c=(g.1j=d||k.2x(h,"1r"));a[h.u]=$.46(c)?c(f):c;k.1m(a)}g.J=b;k.4c(h,b)}},j));8"1i"}16 l(6.1i[h.u]){8"1i"}8 g.J},1z:7(b,c,a){8 6.K(c)||6.1M($.1q(b),c)>=a},18:7(b,c,a){8 6.K(c)||6.1M($.1q(b),c)<=a},2j:7(b,d,a){p c=6.1M($.1q(b),d);8 6.K(d)||(c>=a[0]&&c<=a[1])},1F:7(b,c,a){8 6.K(c)||b>=a},1x:7(b,c,a){8 6.K(c)||b<=a},2i:7(b,c,a){8 6.K(c)||(b>=a[0]&&b<=a[1])},1I:7(a,b){8 6.K(b)||/^((([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\y-\\x\\E-\\C\\A-\\B])+(\\.([a-z]|\\d|[!#\\$%&\'\\*\\+\\-\\/=\\?\\^X`{\\|}~]|[\\y-\\x\\E-\\C\\A-\\B])+)*)|((\\3T)((((\\2k|\\1X)*(\\2V\\3S))?(\\2k|\\1X)+)?(([\\3R-\\5u\\3P\\3M\\5t-\\5r\\3Z]|\\5D|[\\5E-\\5o]|[\\5n-\\5m]|[\\y-\\x\\E-\\C\\A-\\B])|(\\\\([\\3R-\\1X\\3P\\3M\\2V-\\3Z]|[\\y-\\x\\E-\\C\\A-\\B]))))*(((\\2k|\\1X)*(\\2V\\3S))?(\\2k|\\1X)+)?(\\3T)))@((([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])))\\.)+(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|[\\y-\\x\\E-\\C\\A-\\B])))\\.?$/i.15(a)},1v:7(a,b){8 6.K(b)||/^(5l?|5j):\\/\\/(((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:)*@)?(((\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d\\d|2[0-4]\\d|25[0-5]))|((([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|\\d|[\\y-\\x\\E-\\C\\A-\\B])))\\.)+(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])|(([a-z]|[\\y-\\x\\E-\\C\\A-\\B])([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])*([a-z]|[\\y-\\x\\E-\\C\\A-\\B])))\\.?)(:\\d*)?)(\\/((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)+(\\/(([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)*)*)?)?(\\?((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|[\\5h-\\5g]|\\/|\\?)*)?(\\#((([a-z]|\\d|-|\\.|X|~|[\\y-\\x\\E-\\C\\A-\\B])|(%[\\1W-f]{2})|[!\\$&\'\\(\\)\\*\\+,;=]|:|@)|\\/|\\?)*)?$/i.15(a)},1u:7(a,b){8 6.K(b)||!/5e|5S/.15(2e 5T(a))},2q:7(a,b){8 6.K(b)||/^\\d{4}[\\/-]\\d{1,2}[\\/-]\\d{1,2}$/.15(a)},1s:7(a,b){8 6.K(b)||/^-?(?:\\d+|\\d{1,3}(?:,\\d{3})+)(?:\\.\\d+)?$/.15(a)},1U:7(a,b){8 6.K(b)||/^\\d+$/.15(a)},2c:7(b,e){l(6.K(e))8"1S-1Z";l(/[^0-9-]+/.15(b))8 I;p a=0,d=0,2p=I;b=b.1P(/\\D/g,"");Q(p n=b.F-1;n>=0;n--){p c=b.5c(n);p d=5a(c,10);l(2p){l((d*=2)>9)d-=9}a+=d;2p=!2p}8(a%10)==0},44:7(b,c,a){a=1h a=="1t"?a.1P(/,/g,\'|\'):"59|58?g|57";8 6.K(c)||b.62(2e 3s(".("+a+")$","i"))},2n:7(c,d,a){p b=$(a).56(".1d-2n").2J("4B.1d-2n",7(){$(d).J()});8 c==b.2M()}}});$.W=$.v.W})(2v);(7($){p c=$.2R;p d={};$.2R=7(a){a=$.H(a,$.H({},$.54,a));p b=a.40;l(a.41=="2S"){l(d[b]){d[b].2S()}8(d[b]=c.1Q(6,T))}8 c.1Q(6,T)}})(2v);(7($){$.P({3g:\'3F\',4B:\'3E\'},7(b,a){$.1E.37[a]={53:7(){l($.3H.4r)8 I;6.50(b,$.1E.37[a].2N,w)},4Z:7(){l($.3H.4r)8 I;6.4Y(b,$.1E.37[a].2N,w)},2N:7(e){T[0]=$.1E.2L(e);T[0].1A=a;8 $.1E.2m.1Q(6,T)}}});$.H($.2O,{1C:7(d,e,c){8 6.2J(d,7(a){p b=$(a.3G);l(b.2Z(e)){8 c.1Q(b,T)}})},4X:7(a,b){8 6.2H(a,[$.1E.2L({1A:a,3G:b})])}})})(2v);',62,389,'||||||this|function|return|||||||||||||if||||var|settings||||name|validator|true|uD7FF|u00A0||uFDF0|uFFEF|uFDCF||uF900|length|messages|extend|false|valid|optional|element|form|Please|enter|each|for|errorList|delete|arguments|currentForm|in|format|_|method|value||call|toHide|elements|required|test|else|data|maxlength|errorClass|pendingRequest|case|submitted|validate|add|rules|invalid|typeof|pending|message|successList|formSubmitted|showErrors|filter|toShow|attr|trim|remote|number|string|date|url|errorMap|max|metadata|minlength|type|input|delegate|checkable|event|min|success|console|email|classRuleSettings|errorsFor|unhighlight|getLength|normalizeRule|split|replace|apply|not|dependency|methods|digits|submitButton|da|x09|addClass|mismatch|undefined|reset|switch|submit|debug||validClass|currentElements|check|constructor|push|select|creditcard|groups|new|findByName|objectLength|focusInvalid|range|rangelength|x20|parameters|handle|equalTo|previousValue|bEven|dateISO|labelContainer|containers|depends|wrapper|jQuery|removeClass|defaultMessage|hide|errors|errorLabelContainer|resetForm|errorElement|staticRules|prepareElement|clean|prepareForm|triggerHandler|dependTypes|bind|break|fix|val|handler|fn|addWrapper|Number|ajax|abort|hideErrors|rulesCache|x0d|characters|than|window|is|param|old|idOrName|defaults|showLabel|submitHandler|theregex|special|highlight|meta|cancelSubmit|click|formatAndAdd|map|lastActive|catch|focus|findLastActive|ignore|button|toLowerCase|errorContainer|defaultShowErrors|grep|selected|error|numberOfInvalids|find|RegExp|checkForm|onsubmit|nothing|invalidHandler|Array|option|checkbox|remove|radio|text|makeArray|focusout|focusin|target|browser|init|autoCreateRanges|equal|or|x0c|size|try|x0b|ignoreTitle|x01|x0a|x22|attributeRules|between|classRules|no|metadataRules|x7f|port|mode|normalizeRules|originalMessage|accept|and|isFunction|the|to|addClassRules|numberDE|dateDE|stopRequest|startRequest|depend|nodeName|null|errorPlacement|errorContext|html|generated|checked|invalidElements|show|validElements|parent|field|msie|strong|findDefined|String|parentNode|customMessage|customMetaMessage|lastElement|id|on|blur|log|continue|onfocusout|removeAttrs|cancel|assigned|has|blockFocusCleanup|disabled|image|focusCleanup|can|onfocusin|visible|label|slice|textarea|file|password|unshift|keyup|triggerEvent|removeEventListener|teardown|addEventListener|appendTo|warn|setup|ajaxSettings|valueCache|unbind|gif|jpe|png|parseInt|prototype|charAt|greater|Invalid|unchecked|uF8FF|uE000|filled|ftp|less|https|x7e|x5d|x5b|blank|long|x1f|expr|x0e|x08|hidden|least|at|more|json|dataType|extension|with|x21|x23|default|addMethod|again|same|524288|2147483647|class|card|preventDefault|credit|only|boolean|ISO|NaN|Date|getElementsByName|document|insertAfter|URL|append|wrap|address|This|match|defined|No|setDefaults|Warning|returning|title|onclick|throw|onkeyup|removeAttr|checking|when|occured|exception'.split('|'),0,{}))

jQuery.validator.addMethod("zipcode", function(zipcode, element) {
    zipcode = zipcode.replace(/\s+/g, ""); 
	return this.optional(element) || zipcode.length > 4 &&
		zipcode.match(/(^\d{5}$)|(^\d{5}-\d{4}$)/);
}, "Please specify a valid zipcode");

function dirty_date_check(MM,DD,YY){
	//date check
	if( MM == "" || YY == "" || DD == ""){
		result_set = false;
	}else if( checkDate( DD, MM, YY ) === false ){
		result_set = false;
	}
	else{
	    var InputDate = new Date();
	    var CurrentDate = new Date();
	
	    InputDate.setDate(DD);
	    InputDate.setMonth(MM-1);
	    InputDate.setFullYear(YY);
	
	    if(InputDate < CurrentDate){
			result_set = false;
	    }
	    else{
	    var SixMonthsAheadDateTime = new Date();
	    SixMonthsAheadDateTime.setDate(SixMonthsAheadDateTime.getDate()+180);
	
	    if(SixMonthsAheadDateTime < InputDate){
			result_set = false;
	    }else{
			result_set = true;
	    }
		}
	}
	
	return result_set;
	//end of date check
}

function check_this_one(x,fromFinal){
	var ck_fname = /^[A-Za-z'\&\-\s.]{2,25}$/;
	var ck_lname = /^[A-Za-z'\&\-\s.]{1,25}$/;
	var ck_texts = /^[A-Za-z\s.]{3,100}$/;
	var ck_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var ck_phone = /^[0-9]{10,10}$/;
	
	if(x == 'fname' || x == 'lname'){
		fname = document.form.fname.value;
		lname = document.form.lname.value;
		y = fname + ' ' + lname;
		
		if((ck_fname.test(fname) && (fname != '' && fname.toLowerCase() != 'first')) && (ck_lname.test(lname) && (lname != '' && lname.toLowerCase() != 'last'))){
			document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
			document.form.name.value = y;
		}else{
			if(fromFinal == 'fromFinal'){
				document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_incomplete.gif') no-repeat bottom left";
			}else{			
				document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
			}
			document.form.name.value = '';
		}
	}else if(x == 'rooms'){
		y = document.form.rooms.value;
		
		if(y != ''){
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
			document.getElementById('forIE6whim').innerHTML = y;
		}else{
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
			document.getElementById('forIE6whim').innerHTML = 'Number of Rooms';
		}
	}else if(x == 'email'){
		y = document.form.email.value;
		
		if(ck_email.test(y)){
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'area_code' || x == 'first_3' || x == 'last_4'){
		area_code = new String(document.form.area_code.value);
		xxx = new String(document.form.first_3.value);
		xxxx = new String(document.form.last_4.value);

		y = area_code + xxx + xxxx;

		if(ck_phone.test(y)){
			document.getElementById('check_phone').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_phone').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'area_code_2' || x == 'xxx_2' || x == 'xxxx_2'){
		area_code = new String(document.form.area_code_2.value);
		xxx = new String(document.form.xxx_2.value);
		xxxx = new String(document.form.xxxx_2.value);

		y = area_code + xxx + xxxx;

		if(ck_phone.test(y)){
			document.getElementById('check_phone2').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_phone2').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'date'){
		month = document.form.month.value;
		day = document.form.day.value;
		year = document.form.year.value;
	
		if(dirty_date_check(month,day,year) === true){
			document.getElementById('check_date').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_date').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}
}

function know_thy_width(){
	//alert('HEY');
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	
	document.getElementById('filter').style.width = winW + 'px';
	document.getElementById('filter').style.height = winH + 'px';

	//wickedWidth();
}

function forIE6er(x){
	/*bNam = navigator.appCodeName;
	bVer = navigator.userAgent;
	alert(bNam + ' ' + bVer);*/

	//if(document.documentElement){
		if(x == 'yes'){
			document.getElementById('forIE6whim').style.display="inline";
			document.getElementById('rooms').style.display="none";
		}else if(x == 'no'){
			document.getElementById('forIE6whim').style.display="none";
			document.getElementById('rooms').style.display="inline";
		}
	//}
}

/*function wickedWidth(){
	boxHeight = document.getElementById('box').offsetHeight;
	document.getElementById('oneMomentBox').style.height = boxHeight-2 + 'px';
	document.getElementById('calendar_lightbox').style.height = boxHeight-2 + 'px';
}*/

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

function step_1_done(){

	pickup = document.zipform.pickup.value;
	delivery = document.zipform.delivery.value;
	cityNameText = document.zipform.cityName.value;
	stateNameText = document.zipform.stateName.value;
	//month = document.zipform.month.value;
	//day = document.zipform.day.value;
	//year = document.zipform.year.value;

	//document.getElementById('moving_date').innerHTML='Move Date: ' + month + '/' + day + '/' + year + '<input type="hidden" name="MM" value="' + month + '"> <input type="hidden" name="DD" value="' + day + '"> <input type="hidden" name="YY" value="' + year + '">';
	document.getElementById('moving_from').innerHTML='Moving From: ' + pickup;
	document.getElementById('moving_to').innerHTML='Moving To: ' + delivery;

	document.getElementById('replacement_moving_city').innerHTML=cityNameText;
	document.getElementById('replacement_moving_state').innerHTML=stateNameText;
	
	document.form.pzip.value = pickup;
	document.form.dzip.value = delivery;

}

function openbox(zipform, form, fadin){
	var ck_zipcode = /^[0-9-\s]{5,11}$/;
	
	pickup = document.zipform.pickup.value;
	delivery = document.zipform.delivery.value;
	//month = document.zipform.month.value;
	//day = document.zipform.day.value;
	//year = document.zipform.year.value;

	errors = [];

	if (!ck_zipcode.test(pickup)) {
		errors[errors.length] = "Please enter the ZIP Code you are moving from.";
	}

	if (!ck_zipcode.test(delivery)) {
		errors[errors.length] = "Please select a state and city you are moving to.";
	}

	/*
	if( month == "" || year == "" || day == ""){
    	errors[errors.length] = "Please enter valid Date";
	}else if( checkDate( day, month, year ) === false ){
	    errors[errors.length] = "That is not a valid Date";
	}else{
    	var InputDate = new Date();
    	var CurrentDate = new Date();

    	InputDate.setDate(day);
    	InputDate.setMonth(month-1);
    	InputDate.setFullYear(year);
	
		//alert(InputDate);

    	if(InputDate < CurrentDate){
    	    errors[errors.length] = "Date entered has already passed"
    	}else{
    		var SixMonthsAheadDateTime = new Date();
    		SixMonthsAheadDateTime.setDate(SixMonthsAheadDateTime.getDate()+180);

    		if(SixMonthsAheadDateTime < InputDate){
        		errors[errors.length] = "We only accept dates that are within 6 months"
    		}else{
        		//errors[errors.length] = InputDate;
    		}
		}
	}
	*/

	if (errors.length > 0) {
		reportErrors(errors);
		/*
		alert('Please verify that both ZIP code fields are correct to continue');
		
		if(pickup == ''){
			alert_this+= 'Pickup Zipcode';
		}
		
		if(delivery == ''){
			alert_this+= 'Delivery Zipcode';
		}
		
		if(month == ''){
			alert_this+= 'Month';
		}
		
		if(day == ''){
			alert_this+= 'Month';
		}
		*/
	}else{
		step_1_done();
	
		document.documentElement.style.overflow='hidden';
		document.body.scroll='no';
		window.scrollTo(0,0);
	
		var box = document.getElementById('box'); 
		document.getElementById('filter').style.display='block';

		var btitle = document.getElementById('boxtitle');
		btitle.innerHTML = 'Free Household Moving Quote';
  
		//form.from_zip.value = zipform.SZIP.value;
		//form.to_zip.value = zipform.RZIP.value;

		document.getElementById('zip_container_from').style.display='none';
		//document.getElementById('zip_container_to').style.display='none';

		document.getElementById('showHideMovingTo').style.display='none';
		document.getElementById('replacementMovingTo').style.display='block';
		
		if(fadin){
			gradient("box", 0);
			fadein("box");
		}else{ 	
			box.style.display='block';
		}
	}
}


// Close the lightbox

function closebox(){
	document.getElementById('showHideMovingTo').style.display='block';
	document.getElementById('replacementMovingTo').style.display='none';
	document.getElementById('box').style.display='none';
	document.getElementById('filter').style.display='none';
	document.documentElement.style.overflow='auto';
	document.body.scroll='yes';
}

///FOR PHONE
$(document).ready(function(){
	$('#phonewrite').attr('autocomplete','off');
	$('#phonewrite2').attr('autocomplete','off');
	$('#fname').attr('autocomplete','off');
	$('#lname').attr('autocomplete','off');
	$('#email').attr('autocomplete','off');
});

var ck_number = /[0-9]/;

function write_phone_2(ctrl){
	//alert(ctrl.id);
	
	//var phon = document.form.phonewrite.value;
	var phon = ctrl.value;

	phon = phon.replace(/ /g,'');

	p = phon.split('');

	pon = [];

	y = 0;
	for(i in p){
		if( ck_number.test(p[i]) ){
			pon[y] = p[i];
			y++;
		}
	}

	if(typeof pon[3] != 'undefined'){
		var str = '(';
	}else{
		var str = '';
	}

	for(x in pon){
		str+= pon[x];

		if(x == 2 && pon.length > 3){
			str+= ') ';
		}else if(x == 5 && pon.length > 6){
			str+= ' - ';
		}
	}

	var ext = document.form.ext.value;
	var phone2 = document.form.phonewrite2.value;

	if(pon.length == 10){
		if(ctrl.id == 'phonewrite'){
			document.form.area_code.value = pon[0] + '' + pon[1] + '' + pon[2];
			document.form.first_3.value = pon[3] + '' + pon[4] + '' + pon[5];
			document.form.last_4.value = pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];
			
			if(ext == ''){
				document.form.ext.value = '';
			}
			
			if(phone2 == ''){
				cancel_add_phone();
			}

			check_this_one('first_3');
		}else if(ctrl.id == 'phonewrite2'){
			document.form.area_code_2.value = pon[0] + '' + pon[1] + '' + pon[2];
			document.form.xxx_2.value = pon[3] + '' + pon[4] + '' + pon[5];
			document.form.xxxx_2.value = pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];

			check_this_one('xxx_2');
		}
	}else if(pon.length < 10 || pon.length > 10){
		if(ctrl.id == 'phonewrite'){
			document.form.area_code.value = '';
			document.form.first_3.value = '';
			document.form.last_4.value = '';

			if(ext == ''){
				document.form.ext.value = '';
			}
			
			if(phone2 == ''){
				cancel_add_phone();
			}

			check_this_one('first_3');
		}else if(ctrl.id == 'phonewrite2'){
			document.form.area_code_2.value = '';
			document.form.xxx_2.value = '';
			document.form.xxxx_2.value = '';

			check_this_one('xxx_2');
		}
	}

	if(pon.length > 10){
		ctrl.value = '(' + pon[0] + '' + pon[1] + '' + pon[2] + ') ' + pon[3] + '' + pon[4] + '' + pon[5] + ' - ' + pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];
	}else{
		ctrl.value = str;
	}
	setCaretPositionPhone(str.length,ctrl);
	
	/*
	if(ctrl.id == 'phonewrite'){
		check_this_one('xxx');
	}else if(ctrl.id == 'phonewrite2'){
		check_this_one('xxx_2');
	}
	*/
}

function doGetCaretPositionPhone(ctrl) {
	//var ctrl = document.form.phonewrite;
	
	var CaretPos = 0;	// IE Support
	if (document.selection) {
		ctrl.focus ();
		var Sel = document.selection.createRange ();
		Sel.moveStart ('character', -ctrl.value.length);
		CaretPos = Sel.text.length;
	}else if (ctrl.selectionStart || ctrl.selectionStart == '0'){
		CaretPos = ctrl.selectionStart;
	}
	
	var end = ctrl.selectionEnd;
	
	//alert(CaretPos);
	return CaretPos;
}

function onfocus_phone(ctrl){
	d = ctrl.value;

	p = d.split('');

	setCaretPositionPhone(p.length,ctrl);
}

function setCaretPositionPhone(pos,ctrl){
	//var ctrl = document.form.phonewrite;
	
	if(ctrl.setSelectionRange){
		ctrl.focus();
		ctrl.setSelectionRange(pos,pos);
	}else if (ctrl.createTextRange) {
		var range = ctrl.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}
///FOR PHONE

function phoneErrorInArray(errors,phoneError){
	for(i in errors){
		if(errors[i] == phoneError){
			return true;
		}
	}
}

function trimTrails(x) {
	return x.replace(/^\s+|\s+$/g, '');
}

/*
function repeatingLetters(x){
	y = x.split('');

	repeat = [];
	
	for(i in y){
		if(i != 0){
			if(y[i] == y[i-1]){
				if(i == 1){
					repeat[] = y[i-1];
				}
				repeat[] = y[i];
			}
		}
	}

	if(count(repeat) > 3){
		return true;
	}else{
		return false;
	}
}
*/

/*
function checkNameIfHasFoulLanguage(x,foul){
	return false;
	foul = foul.toLowerCase();
	y = x.split(' ');
	for(i in y){
		string = y[i];
		string = string.toLowerCase();
		if(foul.search(string)){
			return true;
		}
	}
}
*/

function checkEditName(){
	fname = document.form.fname.value;
	lname = document.form.lname.value;

	fnameTrim = trimTrails(fname);
	lnameTrim = trimTrails(lname);

	fl = '';

	if((fnameTrim == '' || fnameTrim == 'First' || fnameTrim == 'first') && (lnameTrim != '' && lnameTrim != 'Last' && lnameTrim != 'last')){
		fl = lnameTrim;
	}else if((fnameTrim != '' && fnameTrim != 'First' && fnameTrim != 'first') && (lnameTrim == '' || lnameTrim == 'Last' || lnameTrim == 'last')){
		fl = fnameTrim;
	}else{
		document.form.fname.value = fnameTrim;
		document.form.lname.value = lnameTrim;
		check_this_one('fname','fromFinal');
	}

	if(fl.search(' ') && fl != ''){
		flSplit1 = fl.split(' ');

		flSplit = [];

		i = 0;
		for(y in flSplit1){
			if(flSplit1[y] != '' && flSplit1[y] != ' '){
				flSplit[i] = flSplit1[y];
				i++;
			}
		}

		if(flSplit.length > 1){
			lastElem = flSplit.pop();
			firstEle = flSplit.join(' ');
	
			document.getElementById('fname').style.color = '#555';
			document.getElementById('fname').style.fontStyle = 'normal';
			document.getElementById('lname').style.color = '#555';
			document.getElementById('lname').style.fontStyle = 'normal';
				
			document.form.fname.value = firstEle;
			document.form.lname.value = lastElem;
	
			check_this_one('fname');
		}else{
			document.form.fname.value = fnameTrim;
			document.form.lname.value = lnameTrim;
			document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_incomplete.gif') no-repeat bottom left";
			document.form.name.value = '';
		}
	}
}

function nameErrorInArray(errors,nameError){
	for(i in errors){
		if(errors[i] == nameError){
			return true;
		}
	}
}

function reportErrors2(errors){
	checkEditName();

	document.getElementById('complete_fields').innerHTML = '<img src="../img/ppc/js/error.gif" style="vertical-align:-5px;"> Please correct the fields marked with red arrows:';

	if(phoneErrorInArray(errors,'phoneError')){
		document.form.area_code.value = '';
		document.form.first_3.value = '';
		document.form.last_4.value = '';
		document.form.phonewrite.value = '';
		document.form.ext.value = '';
		if(errors.length == 1){
			document.getElementById('complete_fields').innerHTML = '<img src="../img/ppc/js/error.gif" style="vertical-align:-5px;"> Please verify your phone number is correct:';
		}
	}

	document.getElementById('complete_fields').style.color = '#f00';
}

function decideSubmission(errors){
	fullName = document.form.name.value;

	if(nameErrorInArray(errors,'nameError') && fullName != '' && errors.length == 1){
		return true;
	}else{
		return false;
	}
}

function hoverOverSubmit(){
	document.getElementById('submit_quote').style.backgroundPosition = 'bottom left';
}

function hoverOutSubmit(){
	document.getElementById('submit_quote').style.backgroundPosition = 'top left';
}function dirty_date_check(MM,DD,YY){
	//date check
	if( MM == "" || YY == "" || DD == ""){
		result_set = false;
	}else if( checkDate( DD, MM, YY ) === false ){
		result_set = false;
	}
	else{
	    var InputDate = new Date();
	    var CurrentDate = new Date();
	
	    InputDate.setDate(DD);
	    InputDate.setMonth(MM-1);
	    InputDate.setFullYear(YY);
	
	    if(InputDate < CurrentDate){
			result_set = false;
	    }
	    else{
	    var SixMonthsAheadDateTime = new Date();
	    SixMonthsAheadDateTime.setDate(SixMonthsAheadDateTime.getDate()+180);
	
	    if(SixMonthsAheadDateTime < InputDate){
			result_set = false;
	    }else{
			result_set = true;
	    }
		}
	}
	
	return result_set;
	//end of date check
}

function check_this_one(x,fromFinal){
	var ck_fname = /^[A-Za-z'\&\-\s.]{2,25}$/;
	var ck_lname = /^[A-Za-z'\&\-\s.]{1,25}$/;
	var ck_texts = /^[A-Za-z\s.]{3,100}$/;
	var ck_email = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var ck_phone = /^[0-9]{10,10}$/;
	
	if(x == 'fname' || x == 'lname'){
		fname = document.form.fname.value;
		lname = document.form.lname.value;
		y = fname + ' ' + lname;
		
		if((ck_fname.test(fname) && (fname != '' && fname.toLowerCase() != 'first')) && (ck_lname.test(lname) && (lname != '' && lname.toLowerCase() != 'last'))){
			document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
			document.form.name.value = y;
		}else{
			if(fromFinal == 'fromFinal'){
				document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_incomplete.gif') no-repeat bottom left";
			}else{			
				document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
			}
			document.form.name.value = '';
		}
	}else if(x == 'rooms'){
		y = document.form.rooms.value;
		
		if(y != ''){
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
			document.getElementById('forIE6whim').innerHTML = y;
		}else{
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
			document.getElementById('forIE6whim').innerHTML = 'Number of Rooms';
		}
	}else if(x == 'email'){
		y = document.form.email.value;
		
		if(ck_email.test(y)){
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_' + x).style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'area_code' || x == 'first_3' || x == 'last_4'){
		area_code = new String(document.form.area_code.value);
		xxx = new String(document.form.first_3.value);
		xxxx = new String(document.form.last_4.value);

		y = area_code + xxx + xxxx;

		if(ck_phone.test(y)){
			document.getElementById('check_phone').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_phone').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'area_code_2' || x == 'xxx_2' || x == 'xxxx_2'){
		area_code = new String(document.form.area_code_2.value);
		xxx = new String(document.form.xxx_2.value);
		xxxx = new String(document.form.xxxx_2.value);

		y = area_code + xxx + xxxx;

		if(ck_phone.test(y)){
			document.getElementById('check_phone2').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_phone2').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}else if(x == 'date'){
		month = document.form.month.value;
		day = document.form.day.value;
		year = document.form.year.value;
	
		if(dirty_date_check(month,day,year) === true){
			document.getElementById('check_date').style.background = "url('../img/ppc/js/icon_complete.gif') no-repeat bottom left";
		}else{
			document.getElementById('check_date').style.background = "url('../img/ppc/js/icon_null.gif') no-repeat bottom left";
		}
	}
}

function know_thy_width(){
	//alert('HEY');
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		winW = window.innerWidth;
		winH = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		winW = document.documentElement.clientWidth;
		winH = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		winW = document.body.clientWidth;
		winH = document.body.clientHeight;
	}
	
	document.getElementById('filter').style.width = winW + 'px';
	document.getElementById('filter').style.height = winH + 'px';

	//wickedWidth();
}

function forIE6er(x){
	/*bNam = navigator.appCodeName;
	bVer = navigator.userAgent;
	alert(bNam + ' ' + bVer);*/

	//if(document.documentElement){
		if(x == 'yes'){
			document.getElementById('forIE6whim').style.display="inline";
			document.getElementById('rooms').style.display="none";
		}else if(x == 'no'){
			document.getElementById('forIE6whim').style.display="none";
			document.getElementById('rooms').style.display="inline";
		}
	//}
}

/*function wickedWidth(){
	boxHeight = document.getElementById('box').offsetHeight;
	document.getElementById('oneMomentBox').style.height = boxHeight-2 + 'px';
	document.getElementById('calendar_lightbox').style.height = boxHeight-2 + 'px';
}*/

function gradient(id, level)
{
	var box = document.getElementById(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}


// Open the lightbox

function step_1_done(){

	pickup = document.zipform.pickup.value;
	delivery = document.zipform.delivery.value;
	cityNameText = document.zipform.cityName.value;
	stateNameText = document.zipform.stateName.value;
	//month = document.zipform.month.value;
	//day = document.zipform.day.value;
	//year = document.zipform.year.value;

	//document.getElementById('moving_date').innerHTML='Move Date: ' + month + '/' + day + '/' + year + '<input type="hidden" name="MM" value="' + month + '"> <input type="hidden" name="DD" value="' + day + '"> <input type="hidden" name="YY" value="' + year + '">';
	document.getElementById('moving_from').innerHTML='Moving From: ' + pickup;
	document.getElementById('moving_to').innerHTML='Moving To: ' + delivery;

	document.getElementById('replacement_moving_city').innerHTML=cityNameText;
	document.getElementById('replacement_moving_state').innerHTML=stateNameText;
	
	document.form.pzip.value = pickup;
	document.form.dzip.value = delivery;

}

function openbox(zipform, form, fadin){
	var ck_zipcode = /^[0-9-\s]{5,11}$/;
	
	pickup = document.zipform.pickup.value;
	delivery = document.zipform.delivery.value;
	//month = document.zipform.month.value;
	//day = document.zipform.day.value;
	//year = document.zipform.year.value;

	errors = [];

	if (!ck_zipcode.test(pickup)) {
		errors[errors.length] = "Please enter the ZIP Code you are moving from.";
	}

	if (!ck_zipcode.test(delivery)) {
		errors[errors.length] = "Please select a state and city you are moving to.";
	}

	/*
	if( month == "" || year == "" || day == ""){
    	errors[errors.length] = "Please enter valid Date";
	}else if( checkDate( day, month, year ) === false ){
	    errors[errors.length] = "That is not a valid Date";
	}else{
    	var InputDate = new Date();
    	var CurrentDate = new Date();

    	InputDate.setDate(day);
    	InputDate.setMonth(month-1);
    	InputDate.setFullYear(year);
	
		//alert(InputDate);

    	if(InputDate < CurrentDate){
    	    errors[errors.length] = "Date entered has already passed"
    	}else{
    		var SixMonthsAheadDateTime = new Date();
    		SixMonthsAheadDateTime.setDate(SixMonthsAheadDateTime.getDate()+180);

    		if(SixMonthsAheadDateTime < InputDate){
        		errors[errors.length] = "We only accept dates that are within 6 months"
    		}else{
        		//errors[errors.length] = InputDate;
    		}
		}
	}
	*/

	if (errors.length > 0) {
		reportErrors(errors);
		/*
		alert('Please verify that both ZIP code fields are correct to continue');
		
		if(pickup == ''){
			alert_this+= 'Pickup Zipcode';
		}
		
		if(delivery == ''){
			alert_this+= 'Delivery Zipcode';
		}
		
		if(month == ''){
			alert_this+= 'Month';
		}
		
		if(day == ''){
			alert_this+= 'Month';
		}
		*/
	}else{
		step_1_done();
	
		document.documentElement.style.overflow='hidden';
		document.body.scroll='no';
		window.scrollTo(0,0);
	
		var box = document.getElementById('box'); 
		document.getElementById('filter').style.display='block';

		var btitle = document.getElementById('boxtitle');
		btitle.innerHTML = 'Free Household Moving Quote';
  
		//form.from_zip.value = zipform.SZIP.value;
		//form.to_zip.value = zipform.RZIP.value;

		document.getElementById('zip_container_from').style.display='none';
		//document.getElementById('zip_container_to').style.display='none';

		document.getElementById('showHideMovingTo').style.display='none';
		document.getElementById('replacementMovingTo').style.display='block';
		
		if(fadin){
			gradient("box", 0);
			fadein("box");
		}else{ 	
			box.style.display='block';
		}
	}
}


// Close the lightbox

function closebox(){
	document.getElementById('showHideMovingTo').style.display='block';
	document.getElementById('replacementMovingTo').style.display='none';
	document.getElementById('box').style.display='none';
	document.getElementById('filter').style.display='none';
	document.documentElement.style.overflow='auto';
	document.body.scroll='yes';
}

$('#phonewrite').live(
	'input paste',
	function(){
		write_phone_2(this);
	}
);

$('#phonewrite2').live(
	'input paste',
	function(){
		write_phone_2(this);
	}
);

///FOR PHONE
$(document).ready(function(){
	$('#phonewrite').attr('autocomplete','off');
	$('#phonewrite2').attr('autocomplete','off');
	$('#fname').attr('autocomplete','off');
	$('#lname').attr('autocomplete','off');
	$('#email').attr('autocomplete','off');
});

var ck_number = /[0-9]/;

function write_phone_2(ctrl){
	//alert(ctrl.id);
	
	//var phon = document.form.phonewrite.value;
	var phon = ctrl.value;

	phon = phon.replace(/ /g,'');

	p = phon.split('');

	pon = [];

	y = 0;
	for(i in p){
		if( ck_number.test(p[i]) ){
			pon[y] = p[i];
			y++;
		}
	}

	if(typeof pon[3] != 'undefined'){
		var str = '(';
	}else{
		var str = '';
	}

	for(x in pon){
		str+= pon[x];

		if(x == 2 && pon.length > 3){
			str+= ') ';
		}else if(x == 5 && pon.length > 6){
			str+= ' - ';
		}
	}

	var ext = document.form.ext.value;
	var phone2 = document.form.phonewrite2.value;

	if(pon.length == 10){
		if(ctrl.id == 'phonewrite'){
			document.form.area_code.value = pon[0] + '' + pon[1] + '' + pon[2];
			document.form.first_3.value = pon[3] + '' + pon[4] + '' + pon[5];
			document.form.last_4.value = pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];
			
			if(ext == ''){
				document.form.ext.value = '';
			}
			
			if(phone2 == ''){
				cancel_add_phone();
			}

			check_this_one('first_3');
		}else if(ctrl.id == 'phonewrite2'){
			document.form.area_code_2.value = pon[0] + '' + pon[1] + '' + pon[2];
			document.form.xxx_2.value = pon[3] + '' + pon[4] + '' + pon[5];
			document.form.xxxx_2.value = pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];

			check_this_one('xxx_2');
		}
	}else if(pon.length < 10 || pon.length > 10){
		if(ctrl.id == 'phonewrite'){
			document.form.area_code.value = '';
			document.form.first_3.value = '';
			document.form.last_4.value = '';

			if(ext == ''){
				document.form.ext.value = '';
			}
			
			if(phone2 == ''){
				cancel_add_phone();
			}

			check_this_one('first_3');
		}else if(ctrl.id == 'phonewrite2'){
			document.form.area_code_2.value = '';
			document.form.xxx_2.value = '';
			document.form.xxxx_2.value = '';

			check_this_one('xxx_2');
		}
	}

	if(pon.length > 10){
		ctrl.value = '(' + pon[0] + '' + pon[1] + '' + pon[2] + ') ' + pon[3] + '' + pon[4] + '' + pon[5] + ' - ' + pon[6] + '' + pon[7] + '' + pon[8] + '' + pon[9];
	}else{
		ctrl.value = str;
	}
	setCaretPositionPhone(str.length,ctrl);
	
	/*
	if(ctrl.id == 'phonewrite'){
		check_this_one('xxx');
	}else if(ctrl.id == 'phonewrite2'){
		check_this_one('xxx_2');
	}
	*/
}

function doGetCaretPositionPhone(ctrl) {
	//var ctrl = document.form.phonewrite;
	
	var CaretPos = 0;	// IE Support
	if (document.selection) {
		ctrl.focus ();
		var Sel = document.selection.createRange ();
		Sel.moveStart ('character', -ctrl.value.length);
		CaretPos = Sel.text.length;
	}else if (ctrl.selectionStart || ctrl.selectionStart == '0'){
		CaretPos = ctrl.selectionStart;
	}
	
	var end = ctrl.selectionEnd;
	
	//alert(CaretPos);
	return CaretPos;
}

function onfocus_phone(ctrl){
	d = ctrl.value;

	p = d.split('');

	setCaretPositionPhone(p.length,ctrl);
}

function setCaretPositionPhone(pos,ctrl){
	//var ctrl = document.form.phonewrite;
	
	if(ctrl.setSelectionRange){
		ctrl.focus();
		ctrl.setSelectionRange(pos,pos);
	}else if (ctrl.createTextRange) {
		var range = ctrl.createTextRange();
		range.collapse(true);
		range.moveEnd('character', pos);
		range.moveStart('character', pos);
		range.select();
	}
}
///FOR PHONE

function phoneErrorInArray(errors,phoneError){
	for(i in errors){
		if(errors[i] == phoneError){
			return true;
		}
	}
}

function trimTrails(x) {
	return x.replace(/^\s+|\s+$/g, '');
}

/*
function repeatingLetters(x){
	y = x.split('');

	repeat = [];
	
	for(i in y){
		if(i != 0){
			if(y[i] == y[i-1]){
				if(i == 1){
					repeat[] = y[i-1];
				}
				repeat[] = y[i];
			}
		}
	}

	if(count(repeat) > 3){
		return true;
	}else{
		return false;
	}
}
*/

/*
function checkNameIfHasFoulLanguage(x,foul){
	return false;
	foul = foul.toLowerCase();
	y = x.split(' ');
	for(i in y){
		string = y[i];
		string = string.toLowerCase();
		if(foul.search(string)){
			return true;
		}
	}
}
*/

function checkEditName(){
	fname = document.form.fname.value;
	lname = document.form.lname.value;

	fnameTrim = trimTrails(fname);
	lnameTrim = trimTrails(lname);

	fl = '';

	if((fnameTrim == '' || fnameTrim == 'First' || fnameTrim == 'first') && (lnameTrim != '' && lnameTrim != 'Last' && lnameTrim != 'last')){
		fl = lnameTrim;
	}else if((fnameTrim != '' && fnameTrim != 'First' && fnameTrim != 'first') && (lnameTrim == '' || lnameTrim == 'Last' || lnameTrim == 'last')){
		fl = fnameTrim;
	}else{
		document.form.fname.value = fnameTrim;
		document.form.lname.value = lnameTrim;
		check_this_one('fname','fromFinal');
	}

	if(fl.search(' ') && fl != ''){
		flSplit1 = fl.split(' ');

		flSplit = [];

		i = 0;
		for(y in flSplit1){
			if(flSplit1[y] != '' && flSplit1[y] != ' '){
				flSplit[i] = flSplit1[y];
				i++;
			}
		}

		if(flSplit.length > 1){
			lastElem = flSplit.pop();
			firstEle = flSplit.join(' ');
	
			document.getElementById('fname').style.color = '#555';
			document.getElementById('fname').style.fontStyle = 'normal';
			document.getElementById('lname').style.color = '#555';
			document.getElementById('lname').style.fontStyle = 'normal';
				
			document.form.fname.value = firstEle;
			document.form.lname.value = lastElem;
	
			check_this_one('fname');
		}else{
			document.form.fname.value = fnameTrim;
			document.form.lname.value = lnameTrim;
			document.getElementById('check_name').style.background = "url('../img/ppc/js/icon_incomplete.gif') no-repeat bottom left";
			document.form.name.value = '';
		}
	}
}

function nameErrorInArray(errors,nameError){
	for(i in errors){
		if(errors[i] == nameError){
			return true;
		}
	}
}

function reportErrors2(errors){
	checkEditName();

	document.getElementById('complete_fields').innerHTML = '<img src="../img/ppc/js/error.gif" style="vertical-align:-5px;"> Please correct the fields marked with red arrows:';

	if(phoneErrorInArray(errors,'phoneError')){
		document.form.area_code.value = '';
		document.form.first_3.value = '';
		document.form.last_4.value = '';
		document.form.phonewrite.value = '';
		document.form.ext.value = '';
		if(errors.length == 1){
			document.getElementById('complete_fields').innerHTML = '<img src="../img/ppc/js/error.gif" style="vertical-align:-5px;"> Please verify your phone number is correct:';
		}
	}

	document.getElementById('complete_fields').style.color = '#f00';
}

function decideSubmission(errors){
	fullName = document.form.name.value;

	if(nameErrorInArray(errors,'nameError') && fullName != '' && errors.length == 1){
		return true;
	}else{
		return false;
	}
}

function hoverOverSubmit(){
	document.getElementById('submit_quote').style.backgroundPosition = 'bottom left';
}

function hoverOutSubmit(){
	document.getElementById('submit_quote').style.backgroundPosition = 'top left';
}

/**
 *                                                        ____   _____
 *  Dynarch Calendar -- JSCal2, version 1.9               \  /_  /   /
 *  Built at 2011/03/13 10:28 GMT                          \  / /   /
 *                                                          \/ /_  /
 *  (c) Dynarch.com 2009                                     \  / /
 *  All rights reserved.                                       / /
 *  Visit www.dynarch.com/projects/calendar for details        \/
 *
 */
Calendar=function(){function bm(a){typeof a=="string"&&(a=document.getElementById(a));return a}function bk(a,b,c){for(c=0;c<a.length;++c)b(a[c])}function bj(){var a=document.documentElement,b=document.body;return{x:a.scrollLeft||b.scrollLeft,y:a.scrollTop||b.scrollTop,w:a.clientWidth||window.innerWidth||b.clientWidth,h:a.clientHeight||window.innerHeight||b.clientHeight}}function bi(a){var b=0,c=0,d=/^div$/i.test(a.tagName),e,f;d&&a.scrollLeft&&(b=a.scrollLeft),d&&a.scrollTop&&(c=a.scrollTop),e={x:a.offsetLeft-b,y:a.offsetTop-c},a.offsetParent&&(f=bi(a.offsetParent),e.x+=f.x,e.y+=f.y);return e}function bh(a,b){var c=e?a.clientX+document.body.scrollLeft:a.pageX,d=e?a.clientY+document.body.scrollTop:a.pageY;b&&(c-=b.x,d-=b.y);return{x:c,y:d}}function bg(a,b){var c=a.style;b!=null&&(c.display=b?"":"none");return c.display!="none"}function bf(a,b){b===""?e?a.style.filter="":a.style.opacity="":b!=null?e?a.style.filter="alpha(opacity="+b*100+")":a.style.opacity=b:e?/alpha\(opacity=([0-9.])+\)/.test(a.style.opacity)&&(b=parseFloat(RegExp.$1)/100):b=parseFloat(a.style.opacity);return b}function bd(a,b,c){function h(){var b=a.len;a.onUpdate(c/b,d),c==b&&g(),++c}function g(){b&&(clearInterval(b),b=null),a.onStop(c/a.len,d)}function f(){b&&g(),c=0,b=setInterval(h,1e3/a.fps)}function d(a,b,c,d){return d?c+a*(b-c):b+a*(c-b)}a=U(a,{fps:50,len:15,onUpdate:bl,onStop:bl}),e&&(a.len=Math.round(a.len/2)),f();return{start:f,stop:g,update:h,args:a,map:d}}function bc(a,b){if(!b(a))for(var c=a.firstChild;c;c=c.nextSibling)c.nodeType==1&&bc(c,b)}function bb(a,b){var c=ba(arguments,2);return b==undefined?function(){return a.apply(this,c.concat(ba(arguments)))}:function(){return a.apply(b,c.concat(ba(arguments)))}}function ba(a,b){b==null&&(b=0);var c,d,e;try{c=Array.prototype.slice.call(a,b)}catch(f){c=Array(a.length-b);for(d=b,e=0;d<a.length;++d,++e)c[e]=a[d]}return c}function _(a,b,c){var d=null;document.createElementNS?d=document.createElementNS("http://www.w3.org/1999/xhtml",a):d=document.createElement(a),b&&(d.className=b),c&&c.appendChild(d);return d}function $(a,b,c){if(b instanceof Array)for(var d=b.length;--d>=0;)$(a,b[d],c);else Y(b,c,a?c:null);return a}function Z(a,b){return Y(a,b,b)}function Y(a,b,c){if(a){var d=a.className.replace(/^\s+|\s+$/,"").split(/\x20/),e=[],f;for(f=d.length;f>0;)d[--f]!=b&&e.push(d[f]);c&&e.push(c),a.className=e.join(" ")}return c}function X(a){a=a||window.event,e?(a.cancelBubble=!0,a.returnValue=!1):(a.preventDefault(),a.stopPropagation());return!1}function W(a,b,c,d){if(a instanceof Array)for(var f=a.length;--f>=0;)W(a[f],b,c);else if(typeof b=="object")for(var f in b)b.hasOwnProperty(f)&&W(a,f,b[f],c);else a.removeEventListener?a.removeEventListener(b,c,e?!0:!!d):a.detachEvent?a.detachEvent("on"+b,c):a["on"+b]=null}function V(a,b,c,d){if(a instanceof Array)for(var f=a.length;--f>=0;)V(a[f],b,c,d);else if(typeof b=="object")for(var f in b)b.hasOwnProperty(f)&&V(a,f,b[f],c);else a.addEventListener?a.addEventListener(b,c,e?!0:!!d):a.attachEvent?a.attachEvent("on"+b,c):a["on"+b]=c}function U(a,b,c,d){d={};for(c in b)b.hasOwnProperty(c)&&(d[c]=b[c]);for(c in a)a.hasOwnProperty(c)&&(d[c]=a[c]);return d}function T(a){if(/\S/.test(a)){a=a.toLowerCase();function b(b){for(var c=b.length;--c>=0;)if(b[c].toLowerCase().indexOf(a)==0)return c+1}return b(L("smn"))||b(L("mn"))}}function S(a){if(a){if(typeof a=="number")return P(a);if(!(a instanceof Date)){var b=a.split(/-/);return new Date(parseInt(b[0],10),parseInt(b[1],10)-1,parseInt(b[2],10),12,0,0,0)}}return a}function R(a,b){var c=a.getMonth(),d=a.getDate(),e=a.getFullYear(),f=M(a),g=a.getDay(),h=a.getHours(),i=h>=12,j=i?h-12:h,k=N(a),l=a.getMinutes(),m=a.getSeconds(),n=/%./g,o;j===0&&(j=12),o={"%a":L("sdn")[g],"%A":L("dn")[g],"%b":L("smn")[c],"%B":L("mn")[c],"%C":1+Math.floor(e/100),"%d":d<10?"0"+d:d,"%e":d,"%H":h<10?"0"+h:h,"%I":j<10?"0"+j:j,"%j":k<10?"00"+k:k<100?"0"+k:k,"%k":h,"%l":j,"%m":c<9?"0"+(1+c):1+c,"%o":1+c,"%M":l<10?"0"+l:l,"%n":"\n","%p":i?"PM":"AM","%P":i?"pm":"am","%s":Math.floor(a.getTime()/1e3),"%S":m<10?"0"+m:m,"%t":"\t","%U":f<10?"0"+f:f,"%W":f<10?"0"+f:f,"%V":f<10?"0"+f:f,"%u":g+1,"%w":g,"%y":(""+e).substr(2,2),"%Y":e,"%%":"%"};return b.replace(n,function(a){return o.hasOwnProperty(a)?o[a]:a})}function Q(a,b,c){var d=a.getFullYear(),e=a.getMonth(),f=a.getDate(),g=b.getFullYear(),h=b.getMonth(),i=b.getDate();return d<g?-3:d>g?3:e<h?-2:e>h?2:c?0:f<i?-1:f>i?1:0}function P(a,b,c,d,e){if(!(a instanceof Date)){a=parseInt(a,10);var f=Math.floor(a/1e4);a=a%1e4;var g=Math.floor(a/100);a=a%100,a=new Date(f,g-1,a,b==null?12:b,c==null?0:c,d==null?0:d,e==null?0:e)}return a}function O(a){if(a instanceof Date)return 1e4*a.getFullYear()+100*(a.getMonth()+1)+a.getDate();if(typeof a=="string")return parseInt(a,10);return a}function N(a){a=new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0);var b=new Date(a.getFullYear(),0,1,12,0,0),c=a-b;return Math.floor(c/864e5)}function M(a){a=new Date(a.getFullYear(),a.getMonth(),a.getDate(),12,0,0);var b=a.getDay();a.setDate(a.getDate()-(b+6)%7+3);var c=a.valueOf();a.setMonth(0),a.setDate(4);return Math.round((c-a.valueOf())/6048e5)+1}function L(a,b){var c=i.__.data[a];b&&typeof c=="string"&&(c=K(c,b));return c}function K(a,b){return a.replace(/\$\{([^:\}]+)(:[^\}]+)?\}/g,function(a,c,d){var e=b[c],f;d&&(f=d.substr(1).split(/\s*\|\s*/),e=(e>=f.length?f[f.length-1]:f[e]).replace(/##?/g,function(a){return a.length==2?"#":e}));return e})}function J(b){if(!this._menuAnim){b=b||window.event;var c=b.target||b.srcElement,d=c.getAttribute("dyc-btn"),e=b.keyCode,f=b.charCode||e,g=H[e];if("year"==d&&e==13){var h=new Date(this.date);h.setDate(1),h.setFullYear(this._getInputYear()),this.moveTo(h,!0),z(this,!1);return X(b)}if(this._menuVisible){if(e==27){z(this,!1);return X(b)}}else{b.ctrlKey||(g=null),g==null&&!b.ctrlKey&&(g=I[e]),e==36&&(g=0);if(g!=null){y(this,g);return X(b)}f=String.fromCharCode(f).toLowerCase();var i=this.els.yearInput,j=this.selection;if(f==" "){z(this,!0),this.focus(),i.focus(),i.select();return X(b)}if(f>="0"&&f<="9"){z(this,!0),this.focus(),i.value=f,i.focus();return X(b)}var k=L("mn"),l=b.shiftKey?-1:this.date.getMonth(),m=0,n;while(++m<12){n=k[(l+m)%12].toLowerCase();if(n.indexOf(f)==0){var h=new Date(this.date);h.setDate(1),h.setMonth((l+m)%12),this.moveTo(h,!0);return X(b)}}if(e>=37&&e<=40){var h=this._lastHoverDate;if(!h&&!j.isEmpty()){h=e<39?j.getFirstDate():j.getLastDate();if(h<this._firstDateVisible||h>this._lastDateVisible)h=null}if(!h)h=e<39?this._lastDateVisible:this._firstDateVisible;else{var o=h;h=P(h);var l=100;while(l-->0){switch(e){case 37:h.setDate(h.getDate()-1);break;case 38:h.setDate(h.getDate()-7);break;case 39:h.setDate(h.getDate()+1);break;case 40:h.setDate(h.getDate()+7)}if(!this.isDisabled(h))break}h=O(h),(h<this._firstDateVisible||h>this._lastDateVisible)&&this.moveTo(h)}Y(this._getDateDiv(o),Z(this._getDateDiv(h),"DynarchCalendar-hover-date")),this._lastHoverDate=h;return X(b)}if(e==13&&this._lastHoverDate){j.type==a.SEL_MULTIPLE&&(b.shiftKey||b.ctrlKey)?(b.shiftKey&&this._selRangeStart&&(j.clear(!0),j.selectRange(this._selRangeStart,this._lastHoverDate)),b.ctrlKey&&j.set(this._selRangeStart=this._lastHoverDate,!0)):j.reset(this._selRangeStart=this._lastHoverDate);return X(b)}e==27&&!this.args.cont&&this.hide()}}}function G(){this.refresh();var a=this.inputField,b=this.selection;if(a){var c=b.print(this.dateFormat);/input|textarea/i.test(a.tagName)?a.value=c:a.innerHTML=c}this.callHooks("onSelect",this,b)}function F(a){a=a||window.event;var b=C(a);if(b){var c=b.getAttribute("dyc-btn"),d=b.getAttribute("dyc-type"),e=a.wheelDelta?a.wheelDelta/120:-a.detail/3;e=e<0?-1:e>0?1:0,this.args.reverseWheel&&(e=-e);if(/^(time-(hour|min))/.test(d)){switch(RegExp.$1){case"time-hour":this.setHours(this.getHours()+e);break;case"time-min":this.setMinutes(this.getMinutes()+this.args.minuteStep*e)}X(a)}else/Y/i.test(c)&&(e*=2),y(this,-e),X(a)}}function E(a,b){b=b||window.event;var c=C(b);if(c){var d=c.getAttribute("dyc-type");if(d&&!c.getAttribute("disabled"))if(!a||!this._bodyAnim||d!="date"){var e=c.getAttribute("dyc-cls");e=e?D(e,0):"DynarchCalendar-hover-"+d,(d!="date"||this.selection.type)&&$(a,c,e),d=="date"&&($(a,c.parentNode.parentNode,"DynarchCalendar-hover-week"),this._showTooltip(c.getAttribute("dyc-date"))),/^time-hour/.test(d)&&$(a,this.els.timeHour,"DynarchCalendar-hover-time"),/^time-min/.test(d)&&$(a,this.els.timeMinute,"DynarchCalendar-hover-time"),Y(this._getDateDiv(this._lastHoverDate),"DynarchCalendar-hover-date"),this._lastHoverDate=null}}a||this._showTooltip()}function D(a,b){return"DynarchCalendar-"+a.split(/,/)[b]}function C(a){var b=a.target||a.srcElement,c=b;while(b&&b.getAttribute&&!b.getAttribute("dyc-type"))b=b.parentNode;return b.getAttribute&&b||c}function B(a){a=a||window.event;var b=this.els.topCont.style,c=bh(a,this._mouseDiff);b.left=c.x+"px",b.top=c.y+"px"}function A(b,c){c=c||window.event;var d=C(c);if(d&&!d.getAttribute("disabled")){var f=d.getAttribute("dyc-btn"),g=d.getAttribute("dyc-type"),h=d.getAttribute("dyc-date"),i=this.selection,j,k={mouseover:X,mousemove:X,mouseup:function(a){var b=d.getAttribute("dyc-cls");b&&Y(d,D(b,1)),clearTimeout(j),W(document,k,!0),k=null}};if(b){setTimeout(bb(this.focus,this),1);var l=d.getAttribute("dyc-cls");l&&Z(d,D(l,1));if("menu"==f)this.toggleMenu();else if(d&&/^[+-][MY]$/.test(f))if(y(this,f)){var m=bb(function(){y(this,f,!0)?j=setTimeout(m,40):(k.mouseup(),y(this,f))},this);j=setTimeout(m,350),V(document,k,!0)}else k.mouseup();else if("year"==f)this.els.yearInput.focus(),this.els.yearInput.select();else if(g=="time-am")V(document,k,!0);else if(/^time/.test(g)){var m=bb(function(a){w.call(this,a),j=setTimeout(m,100)},this,g);w.call(this,g),j=setTimeout(m,350),V(document,k,!0)}else h&&i.type&&(i.type==a.SEL_MULTIPLE?c.shiftKey&&this._selRangeStart?i.selectRange(this._selRangeStart,h):(!c.ctrlKey&&!i.isSelected(h)&&i.clear(!0),i.set(h,!0),this._selRangeStart=h):(i.set(h),this.moveTo(P(h),2)),d=this._getDateDiv(h),E.call(this,!0,{target:d})),V(document,k,!0);e&&k&&/dbl/i.test(c.type)&&k.mouseup(),!this.args.fixed&&/^(DynarchCalendar-(topBar|bottomBar|weekend|weekNumber|menu(-sep)?))?$/.test(d.className)&&!this.args.cont&&(k.mousemove=bb(B,this),this._mouseDiff=bh(c,bi(this.els.topCont)),V(document,k,!0))}else if("today"==f)!this._menuVisible&&i.type==a.SEL_SINGLE&&i.set(new Date),this.moveTo(new Date,!0),z(this,!1);else if(/^m([0-9]+)/.test(f)){var h=new Date(this.date);h.setDate(1),h.setMonth(RegExp.$1),h.setFullYear(this._getInputYear()),this.moveTo(h,!0),z(this,!1)}else g=="time-am"&&this.setHours(this.getHours()+12);e||X(c)}}function z(a,b){a._menuVisible=b,$(b,a.els.title,"DynarchCalendar-pressed-title");var c=a.els.menu;f&&(c.style.height=a.els.main.offsetHeight+"px");if(!a.args.animation)bg(c,b),a.focused&&a.focus();else{a._menuAnim&&a._menuAnim.stop();var d=a.els.main.offsetHeight;f&&(c.style.width=a.els.topBar.offsetWidth+"px"),b&&(c.firstChild.style.marginTop=-d+"px",a.args.opacity>0&&bf(c,0),bg(c,!0)),a._menuAnim=bd({onUpdate:function(e,f){c.firstChild.style.marginTop=f(be.accel_b(e),-d,0,!b)+"px",a.args.opacity>0&&bf(c,f(be.accel_b(e),0,.85,!b))},onStop:function(){a.args.opacity>0&&bf(c,.85),c.firstChild.style.marginTop="",a._menuAnim=null,b||(bg(c,!1),a.focused&&a.focus())}})}}function y(a,b,c){this._bodyAnim&&this._bodyAnim.stop();var d;if(b!=0){d=new Date(a.date),d.setDate(1);switch(b){case"-Y":case-2:d.setFullYear(d.getFullYear()-1);break;case"+Y":case 2:d.setFullYear(d.getFullYear()+1);break;case"-M":case-1:d.setMonth(d.getMonth()-1);break;case"+M":case 1:d.setMonth(d.getMonth()+1)}}else d=new Date;return a.moveTo(d,!c)}function w(a){switch(a){case"time-hour+":this.setHours(this.getHours()+1);break;case"time-hour-":this.setHours(this.getHours()-1);break;case"time-min+":this.setMinutes(this.getMinutes()+this.args.minuteStep);break;case"time-min-":this.setMinutes(this.getMinutes()-this.args.minuteStep);break;default:return}}function v(){this._bluringTimeout=setTimeout(bb(u,this),50)}function u(){this.focused=!1,Y(this.els.main,"DynarchCalendar-focused"),this._menuVisible&&z(this,!1),this.args.cont||this.hide(),this.callHooks("onBlur",this)}function t(){this._bluringTimeout&&clearTimeout(this._bluringTimeout),this.focused=!0,Z(this.els.main,"DynarchCalendar-focused"),this.callHooks("onFocus",this)}function s(a){var b=_("div"),c=a.els={},d={mousedown:bb(A,a,!0),mouseup:bb(A,a,!1),mouseover:bb(E,a,!0),mouseout:bb(E,a,!1),keypress:bb(J,a)};a.args.noScroll||(d[g?"DOMMouseScroll":"mousewheel"]=bb(F,a)),e&&(d.dblclick=d.mousedown,d.keydown=d.keypress),b.innerHTML=m(a),bc(b.firstChild,function(a){var b=r[a.className];b&&(c[b]=a),e&&a.setAttribute("unselectable","on")}),V(c.main,d),V([c.focusLink,c.yearInput],a._focusEvents={focus:bb(t,a),blur:bb(v,a)}),a.moveTo(a.date,!1),a.setTime(null,!0);return c.topCont}function q(a){function d(){c.showTime&&(b.push("<td>"),p(a,b),b.push("</td>"))}var b=[],c=a.args;b.push("<table",j," style='width:100%'><tr>"),c.timePos=="left"&&d(),c.bottomBar&&(b.push("<td>"),b.push("<table",j,"><tr><td>","<div dyc-btn='today' dyc-cls='hover-bottomBar-today,pressed-bottomBar-today' dyc-type='bottomBar-today' ","class='DynarchCalendar-bottomBar-today_myChange'>",L(""),"</div>","</td></tr></table>"),b.push("</td>")),c.timePos=="right"&&d(),b.push("</tr></table>");return b.join("")}function p(a,b){b.push("<table class='DynarchCalendar-time'"+j+"><tr>","<td rowspan='2'><div dyc-type='time-hour' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-hour'></div></td>","<td dyc-type='time-hour+' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-up'></td>","<td rowspan='2' class='DynarchCalendar-time-sep'></td>","<td rowspan='2'><div dyc-type='time-min' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-minute'></div></td>","<td dyc-type='time-min+' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-up'></td>"),a.args.showTime==12&&b.push("<td rowspan='2' class='DynarchCalendar-time-sep'></td>","<td rowspan='2'><div class='DynarchCalendar-time-am' dyc-type='time-am' dyc-cls='hover-time,pressed-time'></div></td>"),b.push("</tr><tr>","<td dyc-type='time-hour-' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-down'></td>","<td dyc-type='time-min-' dyc-cls='hover-time,pressed-time' class='DynarchCalendar-time-down'></td>","</tr></table>")}function o(a){var b=["<table height='100%'",j,"><tr><td>","<table style='margin-top: 1.5em'",j,">","<tr><td colspan='3'><input dyc-btn='year' class='DynarchCalendar-menu-year' size='6' value='",a.date.getFullYear(),"' /></td></tr>","<tr><td><div dyc-type='menubtn' dyc-cls='hover-navBtn,pressed-navBtn' dyc-btn='today'>",L("goToday"),"</div></td></tr>","</table>","<p class='DynarchCalendar-menu-sep'>&nbsp;</p>","<table class='DynarchCalendar-menu-mtable'",j,">"],c=L("smn"),d=0,e=b.length,f;while(d<12){b[e++]="<tr>";for(f=4;--f>0;)b[e++]="<td><div dyc-type='menubtn' dyc-cls='hover-navBtn,pressed-navBtn' dyc-btn='m"+d+"' class='DynarchCalendar-menu-month'>"+c[d++]+"</div></td>";b[e++]="</tr>"}b[e++]="</table></td></tr></table>";return b.join("")}function n(a){return"<div unselectable='on'>"+R(a.date,a.args.titleFormat)+"</div>"}function m(a){var b=["<table class='DynarchCalendar-topCont'",j,"><tr><td>","<div class='DynarchCalendar'>",e?"<a class='DynarchCalendar-focusLink' href='#'></a>":"<button class='DynarchCalendar-focusLink'></button>","<div class='DynarchCalendar-topBar'>","<div dyc-type='nav' dyc-btn='-Y' dyc-cls='hover-navBtn,pressed-navBtn' ","class='DynarchCalendar-navBtn DynarchCalendar-prevYear'><div></div></div>","<div dyc-type='nav' dyc-btn='+Y' dyc-cls='hover-navBtn,pressed-navBtn' ","class='DynarchCalendar-navBtn DynarchCalendar-nextYear'><div></div></div>","<div dyc-type='nav' dyc-btn='-M' dyc-cls='hover-navBtn,pressed-navBtn' ","class='DynarchCalendar-navBtn DynarchCalendar-prevMonth'><div></div></div>","<div dyc-type='nav' dyc-btn='+M' dyc-cls='hover-navBtn,pressed-navBtn' ","class='DynarchCalendar-navBtn DynarchCalendar-nextMonth'><div></div></div>","<table class='DynarchCalendar-titleCont'",j,"><tr><td>","<div dyc-type='title' dyc-btn='menu' dyc-cls='hover-title,pressed-title' class='DynarchCalendar-title'>",n(a),"</div></td></tr></table>","<div class='DynarchCalendar-dayNames'>",k(a),"</div>","</div>","<div class='DynarchCalendar-body'></div>"];(a.args.bottomBar||a.args.showTime)&&b.push("<div class='DynarchCalendar-bottomBar'>",q(a),"</div>"),b.push("<div class='DynarchCalendar-menu' style='display: none'>",o(a),"</div>","<div class='DynarchCalendar-tooltip'></div>","</div>","</td></tr></table>");return b.join("")}function l(a,b,c){b=b||a.date,c=c||a.fdow,b=new Date(b.getFullYear(),b.getMonth(),b.getDate(),12,0,0,0);var d=b.getMonth(),e=[],f=0,g=a.args.weekNumbers;b.setDate(1);var h=(b.getDay()-c)%7;h<0&&(h+=7),b.setDate(0-h),b.setDate(b.getDate()+1);var i=new Date,k=i.getDate(),l=i.getMonth(),m=i.getFullYear();e[f++]="<table class='DynarchCalendar-bodyTable'"+j+">";for(var n=0;n<6;++n){e[f++]="<tr class='DynarchCalendar-week",n==0&&(e[f++]=" DynarchCalendar-first-row"),n==5&&(e[f++]=" DynarchCalendar-last-row"),e[f++]="'>",g&&(e[f++]="<td class='DynarchCalendar-first-col'><div class='DynarchCalendar-weekNumber'>"+M(b)+"</div></td>");for(var o=0;o<7;++o){var p=b.getDate(),q=b.getMonth(),r=b.getFullYear(),s=1e4*r+100*(q+1)+p,t=a.selection.isSelected(s),u=a.isDisabled(b);e[f++]="<td class='",o==0&&!g&&(e[f++]=" DynarchCalendar-first-col"),o==0&&n==0&&(a._firstDateVisible=s),o==6&&(e[f++]=" DynarchCalendar-last-col",n==5&&(a._lastDateVisible=s)),t&&(e[f++]=" DynarchCalendar-td-selected"),e[f++]="'><div dyc-type='date' unselectable='on' dyc-date='"+s+"' ",u&&(e[f++]="disabled='1' "),e[f++]="class='DynarchCalendar-day",L("weekend").indexOf(b.getDay())>=0&&(e[f++]=" DynarchCalendar-weekend"),q!=d&&(e[f++]=" DynarchCalendar-day-othermonth"),p==k&&q==l&&r==m&&(e[f++]=" DynarchCalendar-day-today"),u&&(e[f++]=" DynarchCalendar-day-disabled"),t&&(e[f++]=" DynarchCalendar-day-selected"),u=a.args.dateInfo(b),u&&u.klass&&(e[f++]=" "+u.klass),e[f++]="'>"+p+"</div></td>",b=new Date(r,q,p+1,12,0,0,0)}e[f++]="</tr>"}e[f++]="</table>";return e.join("")}function k(a){var b=["<table",j,"><tr>"],c=0;a.args.weekNumbers&&b.push("<td><div class='DynarchCalendar-weekNumber'>",L("wk"),"</div></td>");while(c<7){var d=(c++ +a.fdow)%7;b.push("<td><div",L("weekend").indexOf(d)>=0?" class='DynarchCalendar-weekend'>":">",L("sdn")[d],"</div></td>")}b.push("</tr></table>");return b.join("")}function a(b){b=b||{},this.args=b=U(b,{animation:!f,cont:null,bottomBar:!0,date:!0,fdow:L("fdow"),min:null,max:null,reverseWheel:!1,selection:[],selectionType:a.SEL_SINGLE,weekNumbers:!1,align:"Bl/ / /T/r",inputField:null,trigger:null,dateFormat:"%Y-%m-%d",fixed:!1,opacity:e?1:3,titleFormat:"%b %Y",showTime:!1,timePos:"right",time:!0,minuteStep:5,noScroll:!1,disabled:bl,checkRange:!1,dateInfo:bl,onChange:bl,onSelect:bl,onTimeChange:bl,onFocus:bl,onBlur:bl}),this.handlers={};var c=this,d=new Date;b.min=S(b.min),b.max=S(b.max),b.date===!0&&(b.date=d),b.time===!0&&(b.time=d.getHours()*100+Math.floor(d.getMinutes()/b.minuteStep)*b.minuteStep),this.date=S(b.date),this.time=b.time,this.fdow=b.fdow,bk("onChange onSelect onTimeChange onFocus onBlur".split(/\s+/),function(a){var d=b[a];d instanceof Array||(d=[d]),c.handlers[a]=d}),this.selection=new a.Selection(b.selection,b.selectionType,G,this);var g=s(this);b.cont&&bm(b.cont).appendChild(g),b.trigger&&this.manageFields(b.trigger,b.inputField,b.dateFormat)}var b=navigator.userAgent,c=/opera/i.test(b),d=/Konqueror|Safari|KHTML/i.test(b),e=/msie/i.test(b)&&!c&&!/mac_powerpc/i.test(b),f=e&&/msie 6/i.test(b),g=/gecko/i.test(b)&&!d&&!c&&!e,h=a.prototype,i=a.I18N={};a.SEL_NONE=0,a.SEL_SINGLE=1,a.SEL_MULTIPLE=2,a.SEL_WEEK=3,a.dateToInt=O,a.intToDate=P,a.printDate=R,a.formatString=K,a.i18n=L,a.LANG=function(a,b,c){i.__=i[a]={name:b,data:c}},a.setup=function(b){return new a(b)},h.moveTo=function(a,b){var c=this;a=S(a);var d=Q(a,c.date,!0),e,f=c.args,g=f.min&&Q(a,f.min),h=f.max&&Q(a,f.max);f.animation||(b=!1),$(g!=null&&g<=1,[c.els.navPrevMonth,c.els.navPrevYear],"DynarchCalendar-navDisabled"),$(h!=null&&h>=-1,[c.els.navNextMonth,c.els.navNextYear],"DynarchCalendar-navDisabled"),g<-1&&(a=f.min,e=1,d=0),h>1&&(a=f.max,e=2,d=0),c.date=a,c.refresh(!!b),c.callHooks("onChange",c,a,b);if(b&&(d!=0||b!=2)){c._bodyAnim&&c._bodyAnim.stop();var i=c.els.body,j=_("div","DynarchCalendar-animBody-"+x[d],i),k=i.firstChild,m=bf(k)||.7,n=e?be.brakes:d==0?be.shake:be.accel_ab2,o=d*d>4,p=o?k.offsetTop:k.offsetLeft,q=j.style,r=o?i.offsetHeight:i.offsetWidth;d<0?r+=p:d>0?r=p-r:(r=Math.round(r/7),e==2&&(r=-r));if(!e&&d!=0){var s=j.cloneNode(!0),t=s.style,u=2*r;s.appendChild(k.cloneNode(!0)),t[o?"marginTop":"marginLeft"]=r+"px",i.appendChild(s)}k.style.visibility="hidden",j.innerHTML=l(c),c._bodyAnim=bd({onUpdate:function(a,b){var f=n(a);if(s)var g=b(f,r,u)+"px";if(e)q[o?"marginTop":"marginLeft"]=b(f,r,0)+"px";else{if(o||d==0)q.marginTop=b(d==0?n(a*a):f,0,r)+"px",d!=0&&(t.marginTop=g);if(!o||d==0)q.marginLeft=b(f,0,r)+"px",d!=0&&(t.marginLeft=g)}c.args.opacity>2&&s&&(bf(s,1-f),bf(j,f))},onStop:function(b){i.innerHTML=l(c,a),c._bodyAnim=null}})}c._lastHoverDate=null;return g>=-1&&h<=1},h.isDisabled=function(a){var b=this.args;return b.min&&Q(a,b.min)<0||b.max&&Q(a,b.max)>0||b.disabled(a)},h.toggleMenu=function(){z(this,!this._menuVisible)},h.refresh=function(a){var b=this.els;a||(b.body.innerHTML=l(this)),b.title.innerHTML=n(this),b.yearInput.value=this.date.getFullYear()},h.redraw=function(){var a=this,b=a.els;a.refresh(),b.dayNames.innerHTML=k(a),b.menu.innerHTML=o(a),b.bottomBar&&(b.bottomBar.innerHTML=q(a)),bc(b.topCont,function(c){var d=r[c.className];d&&(b[d]=c),c.className=="DynarchCalendar-menu-year"?(V(c,a._focusEvents),b.yearInput=c):e&&c.setAttribute("unselectable","on")}),a.setTime(null,!0)},h.setLanguage=function(b){var c=a.setLanguage(b);c&&(this.fdow=c.data.fdow,this.redraw())},a.setLanguage=function(a){var b=i[a];b&&(i.__=b);return b},h.focus=function(){try{this.els[this._menuVisible?"yearInput":"focusLink"].focus()}catch(a){}t.call(this)},h.blur=function(){this.els.focusLink.blur(),this.els.yearInput.blur(),u.call(this)},h.showAt=function(a,b,c){this._showAnim&&this._showAnim.stop(),c=c&&this.args.animation;var d=this.els.topCont,e=this,f=this.els.body.firstChild,g=f.offsetHeight,h=d.style;h.position="absolute",h.left=a+"px",h.top=b+"px",h.zIndex=1e4,h.display="",c&&(f.style.marginTop=-g+"px",this.args.opacity>1&&bf(d,0),this._showAnim=bd({onUpdate:function(a,b){f.style.marginTop=-b(be.accel_b(a),g,0)+"px",e.args.opacity>1&&bf(d,a)},onStop:function(){e.args.opacity>1&&bf(d,""),e._showAnim=null}}))},h.hide=function(){var a=this.els.topCont,b=this,c=this.els.body.firstChild,d=c.offsetHeight,e=bi(a).y;this.args.animation?(this._showAnim&&this._showAnim.stop(),this._showAnim=bd({onUpdate:function(f,g){b.args.opacity>1&&bf(a,1-f),c.style.marginTop=-g(be.accel_b(f),0,d)+"px",a.style.top=g(be.accel_ab(f),e,e-10)+"px"},onStop:function(){a.style.display="none",c.style.marginTop="",b.args.opacity>1&&bf(a,""),b._showAnim=null}})):a.style.display="none",this.inputField=null},h.popup=function(a,b){function h(b){var c={x:i.x,y:i.y};if(!b)return c;/B/.test(b)&&(c.y+=a.offsetHeight),/b/.test(b)&&(c.y+=a.offsetHeight-f.y),/T/.test(b)&&(c.y-=f.y),/l/.test(b)&&(c.x-=f.x-a.offsetWidth),/L/.test(b)&&(c.x-=f.x),/R/.test(b)&&(c.x+=a.offsetWidth),/c/i.test(b)&&(c.x+=(a.offsetWidth-f.x)/2),/m/i.test(b)&&(c.y+=(a.offsetHeight-f.y)/2);return c}a=bm(a),b||(b=this.args.align),b=b.split(/\x2f/);var c=bi(a),d=this.els.topCont,e=d.style,f,g=bj();e.visibility="hidden",e.display="",this.showAt(0,0),document.body.appendChild(d),f={x:d.offsetWidth,y:d.offsetHeight};var i=c;i=h(b[0]),i.y<g.y&&(i.y=c.y,i=h(b[1])),i.x+f.x>g.x+g.w&&(i.x=c.x,i=h(b[2])),i.y+f.y>g.y+g.h&&(i.y=c.y,i=h(b[3])),i.x<g.x&&(i.x=c.x,i=h(b[4])),this.showAt(i.x,i.y,!0),e.visibility="",this.focus()},h.manageFields=function(b,c,d){var e=this;c=bm(c),b=bm(b),/^button$/i.test(b.tagName)&&b.setAttribute("type","button"),V(b,"click",function(){e.inputField=c,e.dateFormat=d;if(e.selection.type==a.SEL_SINGLE){var f,g,h,i;f=/input|textarea/i.test(c.tagName)?c.value:c.innerText||c.textContent,f&&(g=/(^|[^%])%[bBmo]/.exec(d),h=/(^|[^%])%[de]/.exec(d),g&&h&&(i=g.index<h.index),f=Calendar.parseDate(f,i),f&&(e.selection.set(f,!1,!0),e.args.showTime&&(e.setHours(f.getHours()),e.setMinutes(f.getMinutes())),e.moveTo(f)))}e.popup(b)})},h.callHooks=function(a){var b=ba(arguments,1),c=this.handlers[a],d=0;for(;d<c.length;++d)c[d].apply(this,b)},h.addEventListener=function(a,b){this.handlers[a].push(b)},h.removeEventListener=function(a,b){var c=this.handlers[a],d=c.length;while(--d>=0)c[d]===b&&c.splice(d,1)},h.getTime=function(){return this.time},h.setTime=function(a,b){if(this.args.showTime){a=a!=null?a:this.time,this.time=a;var c=this.getHours(),d=this.getMinutes(),e=c<12;this.args.showTime==12&&(c==0&&(c=12),c>12&&(c-=12),this.els.timeAM.innerHTML=L(e?"AM":"PM")),c<10&&(c="0"+c),d<10&&(d="0"+d),this.els.timeHour.innerHTML=c,this.els.timeMinute.innerHTML=d,b||this.callHooks("onTimeChange",this,a)}},h.getHours=function(){return Math.floor(this.time/100)},h.getMinutes=function(){return this.time%100},h.setHours=function(a){a<0&&(a+=24),this.setTime(100*(a%24)+this.time%100)},h.setMinutes=function(a){a<0&&(a+=60),a=Math.floor(a/this.args.minuteStep)*this.args.minuteStep,this.setTime(100*this.getHours()+a%60)},h._getInputYear=function(){var a=parseInt(this.els.yearInput.value,10);isNaN(a)&&(a=this.date.getFullYear());return a},h._showTooltip=function(a){var b="",c,d=this.els.tooltip;a&&(a=P(a),c=this.args.dateInfo(a),c&&c.tooltip&&(b="<div class='DynarchCalendar-tooltipCont'>"+R(a,c.tooltip)+"</div>")),d.innerHTML=b};var j=" align='center' cellspacing='0' cellpadding='0'",r={"DynarchCalendar-topCont":"topCont","DynarchCalendar-focusLink":"focusLink",DynarchCalendar:"main","DynarchCalendar-topBar":"topBar","DynarchCalendar-title":"title","DynarchCalendar-dayNames":"dayNames","DynarchCalendar-body":"body","DynarchCalendar-menu":"menu","DynarchCalendar-menu-year":"yearInput","DynarchCalendar-bottomBar":"bottomBar","DynarchCalendar-tooltip":"tooltip","DynarchCalendar-time-hour":"timeHour","DynarchCalendar-time-minute":"timeMinute","DynarchCalendar-time-am":"timeAM","DynarchCalendar-navBtn DynarchCalendar-prevYear":"navPrevYear","DynarchCalendar-navBtn DynarchCalendar-nextYear":"navNextYear","DynarchCalendar-navBtn DynarchCalendar-prevMonth":"navPrevMonth","DynarchCalendar-navBtn DynarchCalendar-nextMonth":"navNextMonth"},x={"-3":"backYear","-2":"back",0:"now",2:"fwd",3:"fwdYear"},H={37:-1,38:-2,39:1,40:2},I={33:-1,34:1};h._getDateDiv=function(a){var b=null;if(a)try{bc(this.els.body,function(c){if(c.getAttribute("dyc-date")==a)throw b=c})}catch(c){}return b},(a.Selection=function(a,b,c,d){this.type=b,this.sel=a instanceof Array?a:[a],this.onChange=bb(c,d),this.cal=d}).prototype={get:function(){return this.type==a.SEL_SINGLE?this.sel[0]:this.sel},isEmpty:function(){return this.sel.length==0},set:function(b,c,d){var e=this.type==a.SEL_SINGLE;b instanceof Array?(this.sel=b,this.normalize(),d||this.onChange(this)):(b=O(b),e||!this.isSelected(b)?(e?this.sel=[b]:this.sel.splice(this.findInsertPos(b),0,b),this.normalize(),d||this.onChange(this)):c&&this.unselect(b,d))},reset:function(){this.sel=[],this.set.apply(this,arguments)},countDays:function(){var a=0,b=this.sel,c=b.length,d,e,f;while(--c>=0)d=b[c],d instanceof Array&&(e=P(d[0]),f=P(d[1]),a+=Math.round(Math.abs(f.getTime()-e.getTime())/864e5)),++a;return a},unselect:function(a,b){a=O(a);var c=!1;for(var d=this.sel,e=d.length,f;--e>=0;){f=d[e];if(f instanceof Array){if(a>=f[0]&&a<=f[1]){var g=P(a),h=g.getDate();if(a==f[0])g.setDate(h+1),f[0]=O(g),c=!0;else if(a==f[1])g.setDate(h-1),f[1]=O(g),c=!0;else{var i=new Date(g);i.setDate(h+1),g.setDate(h-1),d.splice(e+1,0,[O(i),f[1]]),f[1]=O(g),c=!0}}}else a==f&&(d.splice(e,1),c=!0)}c&&(this.normalize(),b||this.onChange(this))},normalize:function(){this.sel=this.sel.sort(function(a,b){a instanceof Array&&(a=a[0]),b instanceof Array&&(b=b[0]);return a-b});for(var a=this.sel,b=a.length,c,d;--b>=0;){c=a[b];if(c instanceof Array){if(c[0]>c[1]){a.splice(b,1);continue}c[0]==c[1]&&(c=a[b]=c[0])}if(d){var e=d,f=c instanceof Array?c[1]:c;f=P(f),f.setDate(f.getDate()+1),f=O(f);if(f>=e){var g=a[b+1];c instanceof Array&&g instanceof Array?(c[1]=g[1],a.splice(b+1,1)):c instanceof Array?(c[1]=d,a.splice(b+1,1)):g instanceof Array?(g[0]=c,a.splice(b,1)):(a[b]=[c,g],a.splice(b+1,1))}}d=c instanceof Array?c[0]:c}},findInsertPos:function(a){for(var b=this.sel,c=b.length,d;--c>=0;){d=b[c],d instanceof Array&&(d=d[0]);if(d<=a)break}return c+1},clear:function(a){this.sel=[],a||this.onChange(this)},selectRange:function(b,c){b=O(b),c=O(c);if(b>c){var d=b;b=c,c=d}var e=this.cal.args.checkRange;if(!e)return this._do_selectRange(b,c);try{bk((new a.Selection([[b,c]],a.SEL_MULTIPLE,bl)).getDates(),bb(function(a){if(this.isDisabled(a)){e instanceof Function&&e(a,this);throw"OUT"}},this.cal)),this._do_selectRange(b,c)}catch(f){}},_do_selectRange:function(a,b){this.sel.push([a,b]),this.normalize(),this.onChange(this)},isSelected:function(a){for(var b=this.sel.length,c;--b>=0;){c=this.sel[b];if(c instanceof Array&&a>=c[0]&&a<=c[1]||a==c)return!0}return!1},getFirstDate:function(){var a=this.sel[0];a&&a instanceof Array&&(a=a[0]);return a},getLastDate:function(){if(this.sel.length>0){var a=this.sel[this.sel.length-1];a&&a instanceof Array&&(a=a[1]);return a}},print:function(a,b){var c=[],d=0,e,f=this.cal.getHours(),g=this.cal.getMinutes();b||(b=" -> ");while(d<this.sel.length)e=this.sel[d++],e instanceof Array?c.push(R(P(e[0],f,g),a)+b+R(P(e[1],f,g),a)):c.push(R(P(e,f,g),a));return c},getDates:function(a){var b=[],c=0,d,e;while(c<this.sel.length){e=this.sel[c++];if(e instanceof Array){d=P(e[0]),e=e[1];while(O(d)<e)b.push(a?R(d,a):new Date(d)),d.setDate(d.getDate()+1)}else d=P(e);b.push(a?R(d,a):d)}return b}},a.isUnicodeLetter=function(a){return a.toUpperCase()!=a.toLowerCase()},a.parseDate=function(b,c,d){if(!/\S/.test(b))return"";b=b.replace(/^\s+/,"").replace(/\s+$/,""),d=d||new Date;var e=null,f=null,g=null,h=null,i=null,j=null,k=b.match(/([0-9]{1,2}):([0-9]{1,2})(:[0-9]{1,2})?\s*(am|pm)?/i);k&&(h=parseInt(k[1],10),i=parseInt(k[2],10),j=k[3]?parseInt(k[3].substr(1),10):0,b=b.substring(0,k.index)+b.substr(k.index+k[0].length),k[4]&&(k[4].toLowerCase()=="pm"&&h<12?h+=12:k[4].toLowerCase()=="am"&&h>=12&&(h-=12)));var l=function(){function k(a){d.push(a)}function j(){var a="";while(g()&&/[0-9]/.test(g()))a+=f();if(h(g()))return i(a);return parseInt(a,10)}function i(a){while(g()&&h(g()))a+=f();return a}function g(){return b.charAt(c)}function f(){return b.charAt(c++)}var c=0,d=[],e,h=a.isUnicodeLetter;while(c<b.length)e=g(),h(e)?k(i("")):/[0-9]/.test(e)?k(j()):f();return d}(),m=[];for(var n=0;n<l.length;++n){var o=l[n];/^[0-9]{4}$/.test(o)?(e=parseInt(o,10),f==null&&g==null&&c==null&&(c=!0)):/^[0-9]{1,2}$/.test(o)?(o=parseInt(o,10),o<60?o<0||o>12?o>=1&&o<=31&&(g=o):m.push(o):e=o):f==null&&(f=T(o))}m.length<2?m.length==1&&(g==null?g=m.shift():f==null&&(f=m.shift())):c?(f==null&&(f=m.shift()),g==null&&(g=m.shift())):(g==null&&(g=m.shift()),f==null&&(f=m.shift())),e==null&&(e=m.length>0?m.shift():d.getFullYear()),e<30?e+=2e3:e<99&&(e+=1900),f==null&&(f=d.getMonth()+1);return e!=null&&f!=null&&g!=null?new Date(e,f-1,g,h,i,j):null};var be={elastic_b:function(a){return 1-Math.cos(-a*5.5*Math.PI)/Math.pow(2,7*a)},magnetic:function(a){return 1-Math.cos(a*a*a*10.5*Math.PI)/Math.exp(4*a)},accel_b:function(a){a=1-a;return 1-a*a*a*a},accel_a:function(a){return a*a*a},accel_ab:function(a){a=1-a;return 1-Math.sin(a*a*Math.PI/2)},accel_ab2:function(a){return(a/=.5)<1?.5*a*a:-0.5*(--a*(a-2)-1)},brakes:function(a){a=1-a;return 1-Math.sin(a*a*Math.PI)},shake:function(a){return a<.5?-Math.cos(a*11*Math.PI)*a*a:(a=1-a,Math.cos(a*11*Math.PI)*a*a)}},bl=new Function;return a}()

Calendar.LANG("en", "English", {

        fdow: 1,                // first day of week for this locale; 0 = Sunday, 1 = Monday, etc.

        goToday: "Go Today",

        today: "Today",         // appears in bottom bar

        wk: "wk",

        weekend: "0,6",         // 0 = Sunday, 1 = Monday, etc.

        AM: "am",

        PM: "pm",

        mn : [ "January",
               "February",
               "March",
               "April",
               "May",
               "June",
               "July",
               "August",
               "September",
               "October",
               "November",
               "December" ],

        smn : [ "Jan",
                "Feb",
                "Mar",
                "Apr",
                "May",
                "Jun",
                "Jul",
                "Aug",
                "Sep",
                "Oct",
                "Nov",
                "Dec" ],

        dn : [ "Sunday",
               "Monday",
               "Tuesday",
               "Wednesday",
               "Thursday",
               "Friday",
               "Saturday",
               "Sunday" ],

        sdn : [ "Su",
                "Mo",
                "Tu",
                "We",
                "Th",
                "Fr",
                "Sa",
                "Su" ]

});
function insertDate()
        {
        	var date = $('#move-date').val();
            $('#post-date-select').html(date);
            $('#pre-date-select').hide(500);       
            $('#post-date-select').show(500);
            $('#check_date').css('background', 'url("img/check.png") no-repeat 0px 10px');
        }
function moveOnMax(field,nextFieldID){
  if(field.value.length >= field.maxLength){
    document.getElementById(nextFieldID).focus();
  }
}

function select_zip(x,y){
	if(y=='pzip'){
		document.zipform.pickup.value=x;
		document.getElementById('zip_container_from').style.display='none';
	}else if(y=='dzip'){
		document.zipform.delivery.value=x;
		//document.getElementById('zip_container_to').style.display='none';
	}
}


var getHXO

function GetXmlHttpObject(){
	if (window.XMLHttpRequest) { return new XMLHttpRequest(); }
	if (window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP"); }
	return null;
}

function search_cities(x_x,y_y){
	getHXO=GetXmlHttpObject();
	if (getHXO==null){ 
		alert ("AJAX not supported");
  		return;
  	}
	var o_o="scripts/search_zip.php";
	o_o=o_o+"?state="+x_x;
	o_o=o_o+"&y_y="+y_y;
	o_o=o_o+"&sid="+Math.random();

	if(y_y=='pzip'){
		getHXO.onreadystatechange=cities_span_pzip;
		//document.getElementById("zipcodes_span_pzip").innerHTML='<select class="selections" disabled="disabled"> <option value=""> -Select Zip Code- </option> </select>';
	}else if(y_y=='dzip'){
		getHXO.onreadystatechange=cities_span_dzip;
		//document.getElementById("zipcodes_span_dzip").innerHTML='<select class="selections" disabled="disabled"> <option value=""> -Select Zip Code- </option> </select>';
	}
	
	getHXO.open("GET",o_o,true);
	getHXO.send(null);
}

function cities_span_pzip(){
	if (getHXO.readyState==4){
		document.getElementById("cities_span_pzip").innerHTML=getHXO.responseText;
	}
}

function cities_span_dzip(){
	if (getHXO.readyState==4){
		document.getElementById("cities_span_dzip").innerHTML=getHXO.responseText;
	}
}

function search_zipcodes(x_x,x_y,y_y){
	getHXO=GetXmlHttpObject();
	if (getHXO==null){ 
		alert ("AJAX not supported");
  		return;
  	}
	var o_o="scripts/search_zip.php";
	o_o=o_o+"?city="+x_x;
	o_o=o_o+"&state="+x_y;
	o_o=o_o+"&y_y="+y_y;
	o_o=o_o+"&sid="+Math.random();

	city = x_x.split("-");

	if(y_y=='pzip'){
		getHXO.onreadystatechange=zipcodes_span_pzip;
	}else if(y_y=='dzip'){
		getHXO.onreadystatechange=zipcodes_span_dzip;
	}

	getHXO.open("GET",o_o,true);
	getHXO.send(null);
}

function zipcodes_span_pzip(){
	if (getHXO.readyState==4){
		document.zipform.pickup.value=getHXO.responseText;
		document.getElementById('zip_container_from').style.display='none';
		//document.getElementById("zipcodes_span_pzip").innerHTML=getHXO.responseText;
	}
}

function zipcodes_span_dzip(){
	if (getHXO.readyState==4){
		document.zipform.delivery.value=getHXO.responseText;
		//document.getElementById('zip_container_to').style.display='none';
		//document.getElementById("zipcodes_span_dzip").innerHTML=getHXO.responseText;
	}
}
  	
        
        function validateName()
        {
        	if ( ($('#first-name').valid()) && ($('#last-name').valid()) )
            {
            	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px');
            }
            else
            {
            	$('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
            }
        }

		function validate_zip_code_again(){
		if ($('#zip').val() == '')
                {                   
				   jAlert('Oops! Please take a moment to enter the zip code you are moving from. ', 
				   			'MovingCost.com Alert',
							function(){ $('#zip').focus();});
				   $('#zip').css({'background-color': '#FEFA00'});	
				   return false;
                }
		else{
				var myurl =  "http://www.movingcost.com/ajax/validate-zip.php?zip="+ $('#zip').val();
							  $.get(myurl, function(result){
									if(result == false){
									jAlert('Sorry, but the zip code you provided does not correspond to any known U.S. zip codes.', 'MovingCost.com Alert');														
									}
									else{
									validateStepOne();
										}
								});
				}
				return false;
		}
	

		function validateStepOne(){
						
				if ($('#state').val() == '' )
                {
				   jAlert('Oops! Please take a moment to select the state you are moving to.', 
				   'MovingCost.com Alert', 
				   function(){ $('#state').focus();});	
				   $('#state').css({'background-color': '#FEFA00'});
				   return false;
                }
				if ( $('#service').val() == '')
                {
				   jAlert('Oops! Please take a moment to select the city you are moving to.', 
				   'MovingCost.com Alert',
				   function(){$('#service').focus();});
				   $('#service').css({'background-color': '#FEFA00'});
				   return false;
                }		
		document.getElementById("quote").submit();				
				
		}
        
        function validateStepTwo()
        {
            var count = 0;
             var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;         
			 // var phone_numberReg = /^[2-9]\d{2}-\d{3}-\d{4}$/; 
			   var phone_numberReg = /^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/;   
			  
            	if ($('#post_from').val() == 'no') {
					 jAlert('Oops! Please take a moment to select the zip code where you are moving from', 
					 'MovingCost.com Alert', 
					 function(){search_zip_from('pzip')});
					return false;
				}
				if ($('#post_to').val() == 'no') {
					 jAlert('Oops! Please take a moment to select the zip code where you are moving to', 
					 'MovingCost.com Alert', 
					 function(){search_zip_to('pzip')});
					return false;
				}
				if ($('#move-date').val() == '' ){
                	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px');
					 jAlert('Oops! Please provide us with your estimated moving date', 
					 'MovingCost.com Alert', 
					 function(){$('#click-for-cal').trigger("click")});
					return false;
				}
				if ($('#FirstName').val() != '' ){
                	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px');
                }
                else
                {
                    $('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
                    count++;
					jAlert('Oops! Please take a moment to enter your first name', 
					'MovingCost.com Alert',
					function(){$('#FirstName').focus()});
					$('#FirstName').css({'background-color': '#FEFA00'});
					return false;					
                }
				if ($('#LastName').val() != ''){
                	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px');
                }
                else
                {
                    $('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
                    count++;
					jAlert('Oops! Please take a moment to enter your last name', 
					'MovingCost.com Alert',
					function(){$('#LastName').focus()});
					$('#LastName').css({'background-color': '#FEFA00'});
					return false;
                }
				if($('#Email').val().length >2){
					if ((emailReg.test($('#Email').val())) ){
                	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px');
					}
					else
					{
						$('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
						count++;
						jAlert('Oops! Unfortunatelly, the email address provided does not appear to be valid.', 
						'MovingCost.com Alert',
						function(){$('#Email').focus()});
						$('#Email').css({'background-color': '#FEFA00'});
						return false;
					}	
				}
				else
					{
						$('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
						count++;
						jAlert('Oops! Please take a moment to enter your email address', 
						'MovingCost.com Alert',
						function(){$('#Email').focus()});
						$('#Email').css({'background-color': '#FEFA00'});
						return false;
					}				
				$('#Email').css({'background-color': '#FFFFFF'});
				if ($('#Phone_Day').val().length < 10){
                	$('#check_name').css('background', 'url("img/check.png") no-repeat 0px 10px'); 			 count++;
					jAlert('Oops! Please take a moment to enter your phone number', 
					'MovingCost.com Alert',
					function(){$('#Phone_Day').focus()});
					$('#Phone_Day').css({'background-color': '#FEFA00'});
					return false;					
                }
                else
                {		var invalid_phone = ['1111111111','2222222222', '3333333333',
				'4444444444', '5555555555', '6666666666', '7777777777', '8888888888',
						'9999999999'];
						   if( $.inArray($('#Phone_Day').val(), invalid_phone, true) >= 0  ) {
							   jAlert('Oops! Unfortunatelly, the phone number provided does not appear to be valid.', 
							   'MovingCost.com Alert',
							function(){$('#Phone_Day').focus()});
							   return false;
						   }
						   if(!phone_numberReg.test($('#Phone_Day').val())){
							jAlert('Oops! Unfortunatelly, the phone number provided does not appear to be valid.', 
							'MovingCost.com Alert',
							function(){$('#Phone_Day').focus()});
							$('#Phone_Day').css({'background-color': '#FEFA00'});
							   return false;
						   }
                    $('#check_name').css('background', 'url("img/x.png") no-repeat 0px 10px');
                }
            
        };
		function clearState(){
			 $('#state').css({'background-color': '#FFFFFF'});
		}
		function clearService(){
			 $('#service').css({'background-color': '#FFFFFF'});
		}
		
		
		$('#FirstName').live('keypress', function(e) {
			returnAlpha(e);
			$('#FirstName').css({'background-color': '#FFFFFF'});
		});
		
	
		$('#LastName').live('keypress', function(e) {
			returnAlpha(e);
			$('#LastName').css({'background-color': '#FFFFFF'});
		});
		$('#Email').live('keypress', function(e) {
			ValidateEmail(e);	
			$('#Email').css({'background-color': '#FFFFFF'});
		});
		$('#Phone_Day').live('keypress', function(e) {
			
			$('#Phone_Day').css({'background-color': '#FFFFFF'});
		});
		
		function validateZips(zip, el) {
					if (window.XMLHttpRequest) {
						xmlhttp=new XMLHttpRequest();
					} else {
						xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					}
					xmlhttp.onreadystatechange=function() {
						if (xmlhttp.readyState==4 && xmlhttp.status==200) {
							if(xmlhttp.responseText == true) {
                            	// var new_position = $('#jumpup').offset();
    							// window.scrollTo(new_position.left,new_position.top);
    							window.scrollTo(0,0);
					/*			<?php if (is_ie()) { ?> causing errors
                             	$('#mask').css('display', 'block');
                            	$('#mask').css('background-color', '#000');
                                <?php } ?>*/
                                $('body').css('overflow', 'hidden');
                                $('#mask').show();
								$('#box').show();
                                $('iframe').hide();
                                $('.video').hide();
							} else {
								alert('Invalid Moving From Zip Code');
								return false;
							}
						}
					}
					xmlhttp.open("GET","http://www.movingcost.com/ajax/validate-zip.php?zip="+zip,true);
					xmlhttp.send();
				}
				
	function ValidateZip(evt) {
			var charCode = (evt.which) ? evt.which : evt.keyCode;
			if (charCode > 31 && (charCode < 48 || charCode > 57)){
               
                $('#zip').focus();
                return false;
            }
			else if(charCode == 13  ){
						return false;
					}
			$('#from-zip').val('');
			$('#from-city').val('');
			$('#city_name').val('');
			$('#state_name').val('');
			$('#zip').css({'background-color': '#FFFFFF'});			
		   if($('#zip').val().length == 4){
		 	var arraycharcode = new Array();
			arraycharcode[48]= 0; arraycharcode[49] = 1; arraycharcode[50]= 2; 
			arraycharcode[51]=3;
			arraycharcode[52]=4; arraycharcode[53]=5; arraycharcode[54]=6; arraycharcode[55]=7;
			arraycharcode[56]=8; arraycharcode[57]=9;
			//alert(arraycharcode[charCode]);
			fullzip = $('#zip').val() + arraycharcode[charCode] ;
			var myurl =  "http://www.movingcost.com/ajax/validate-zip.php?zip="+ fullzip;
		  				  $.get(myurl, function(result){
                            if(result == false){
							jAlert('Sorry, but the zip code you provided does not correspond to any known U.S. zip codes.', 'MovingCost.com Alert');
							}
				  });
					
      		 }
	}
	
			  $('#zip').keyup(function() {
				var zipLen = $('#zip').val();
				
				if (zipLen.length == 5)
				{
					$('#stateName').focus();
				}
			});
			$('#zip').blur(function() {
				getCityStateFromZip($(this).val());
			});
		
    
  function ValidateEmail(evt){
          var charCode = (evt.which) ? evt.which : evt.keyCode;
		if (charCode == 32){
                	evt.returnValue = false;
            	if(evt.preventDefault) evt.preventDefault();
				}
                }
        function returnAlpha(evt) {
          var theEvent = evt || window.event;
          var key = theEvent.keyCode || theEvent.which;
          key = String.fromCharCode( key );
          var regex = /[a-zA-Z]|[\b]|[\t]|[\s]/;
		 
          if( !regex.test(key) ) {
            theEvent.returnValue = false;
            if(theEvent.preventDefault) theEvent.preventDefault();
          }
        }
        
        function blockShift(evt)
        {
        	var theEvent = evt || window.event, 
            	key = theEvent.keyCode || theEvent.which;

            if (theEvent.shiftKey == true && key !== 64)
            {
            	theEvent.returnValue = false;
            	if(theEvent.preventDefault) theEvent.preventDefault();
            }
        }
		
			function returnNum(evt) {
			 var charCode = (evt.which) ? evt.which : evt.keyCode
			//alert(document.activeElement.id);
			if (charCode > 31 && (charCode < 48 || charCode > 57)){
					return false;
				}
			else if(charCode == 13){
					return false;
				}
			}
		
		
			function getCitiesFromState(state, select, spinnerNum) {
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask2').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask2').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state.php?state="+state,true);
			xmlhttp.send();
		}
		function getCitiesFromState2(state, select, spinnerNum) {
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask2').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask2').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state2.php?state="+state,true);
			xmlhttp.send();
		}
		
		////// FROM SECTION ///////elements in the pop up window
			$('#from-zip').change(function() {
				getCitiesFromState($(this).val(), 'from-city', '1');	
				$('#state_name').val($(this).val());			
			});	

			$('#from-city').change(function(e) {
				if ($(this).val() !== '')
                {
                  /*  $('#pickup').val($(this).val());*/
                    hideZippers('pzip');
                    var city = $('#from-city option:selected').html(), state = $('#from-zip option:selected').val(), zip = $(this).val(), insert = '';
                    //console.log(\1);
                    /*insert = city + ', '+state+' - '+zip;
                    $('#from-location').html(insert);*/
                    $('#zip').val(zip);
                   /* $('#pickup-city').val(city);
                    $('#pickup-state').val(state);*/
                    $('#ajax-flag').attr('running', 'false');
					$('#city_name').val(city);
                }
                else
                {
                	alert('Please pick a valid city!');
                }
			});
			//MOVING TO FORM
			
			$('#state').change(function() {
				getCitiesFromState2($(this).val(), 'service', '1');				
			});
				function search_zip(x){
				if(x=='pzip'){
					document.getElementById('zip_container_from').style.display='block';
					//document.getElementById('zip_container_to').style.display='none';
				}else if(x=='dzip'){
					document.getElementById('zip_container_from').style.display='none';
					//document.getElementById('zip_container_to').style.display='block';
				}
			}
			function hideZippers(x){
			if(x=='pzip'){
				document.getElementById('zip_container_from').style.display='none';
			}else if(x=='dzip'){
				//document.getElementById('zip_container_to').style.display='none';
			}
		}
			$('#zip_code_lookup').click(function() {
				search_zip('pzip');
			});
			
                function getCitiesFromState(state, select, spinnerNum) { //free-moving-quote from location
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} 
			else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask2').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask2').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state.php?state="+state,true);
			xmlhttp.send();
		}
		function getCitiesFromState_to(state, select, spinnerNum) {
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} 
			else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask3').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask3').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state.php?state="+state,true);
			xmlhttp.send();
		}
		
				////// FROM SECTION ///////elements in the pop up window
			$('#from-zip_n').live('change', function() {
				getCitiesFromState($(this).val(), 'from-city_n', '1');
			});	
					
			$('#from-city_n').live('change', function() {
		if ($(this).val() !== '')
		{
	  /*  $('#pickup').val($(this).val());*/
		hideZippers_from('pzip');
		city = $('#from-city_n option:selected').html();
		state = $('#from-zip_n option:selected').val();
		zip = $(this).val(), insert = '';
		//console.log(\1);
		insert = city + ', '+ state +' '+zip;
		insert_edit = '<img src="includes/img/zip_help_icon.png"  title="Zip Code Locator"  class="zip_code_lookup_img"> Zip Code';
		if($('#post_from').val() == 'no'){
			$('#from-location').html(insert);
			$('#move_from_edit').html(insert_edit);
                        $('#post_from').val('yes');
		}
		else{
			$('#from-location').html(insert);
		}
		$('#move_from_city').val(city);
		$('#move_from_state').val(state);
		$('#move_from_zip').val(zip);

		$('#ajax-flag').attr('running', 'false');
	}
	else
	{
		alert('Please pick a valid city!');
	}
			});
	
	function getCitiesFromState_from_fm(state, select, spinnerNum) {
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} 
			else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask4').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask4').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state.php?state="+state,true);
			xmlhttp.send();
		}
		function getCitiesFromState_to_fm(state, select, spinnerNum) {
			if (window.XMLHttpRequest) {
				xmlhttp=new XMLHttpRequest();
			} 
			else {
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function() {
				$('#mask5').show();
				if (xmlhttp.readyState==4 && xmlhttp.status==200) {
                    $('#mask5').hide();					
                    $('#'+select).html(xmlhttp.responseText);
					}
				
			}
			xmlhttp.open("GET","http://www.movingcost.com/ajax/cities-from-state.php?state="+state,true);
			xmlhttp.send();
		}
		
			/////
			
			$('#to-zip').live('change', function() {
				getCitiesFromState_to($(this).val(), 'to-city', '1');
			});	
					
			$('#to-city').live('change', function() {	
		if ($(this).val() !== '')
		{
		  /*  $('#pickup').val($(this).val());*/
			hideZippers_to('pzip');
			city = $('#to-city option:selected').html();
			state = $('#to-zip option:selected').val();
			zip = $(this).val(), insert = '';
			//console.log(\1);
		   
			insert = city + ', '+ state +' '+ zip;
			insert_edit = '<img src="includes/img/zip_help_icon.png"  title="Zip Code Locator" class="zip_code_lookup_img"> Zip Code';
			if($('#post_to').val() == 'no'){
				$('#to-location1').html(insert);
                                $('#move_to_edit1').html(insert_edit);
                                $('#post_to').val('yes');
			}
			else{
				$('#to-location1').html(insert);
			}
	$('#move_to_city').val(city);
	$('#move_to_state').val(state);
	$('#move_to_zip').val(zip);
	
	$('#ajax-flag').attr('running', 'false');
}
else
{
	alert('Please pick a valid city!');
}
			});
			
				function search_zip_from(x){
				if(x=='pzip'){
					

document.getElementById('zip-lookup1').style.display='block';
					

//document.getElementById('zip_container_to').style.display='none';
				}else if(x=='dzip'){
					

document.getElementById('zip-lookup1').style.display='none';
					

//document.getElementById('zip_container_to').style.display='block';
				}
			}
			function hideZippers_from(x){
				if(x=='pzip'){
					

document.getElementById('zip-lookup1').style.display='none';
				}else if(x=='dzip'){
					

//document.getElementById('zip_container_to').style.display='none';
				}
				}
				
				function search_zip_to(x){
				if(x=='pzip'){
					

document.getElementById('zip-lookup2').style.display='block';
					

//document.getElementById('zip_container_to').style.display='none';
				}else if(x=='dzip'){
					

document.getElementById('zip-lookup2').style.display='none';
					

//document.getElementById('zip_container_to').style.display='block';
				}
			}
			function hideZippers_to(x){
				if(x=='pzip'){
					

document.getElementById('zip-lookup2').style.display='none';
				}else if(x=='dzip'){
					

//document.getElementById('zip_container_to').style.display='none';
				}
				}
    function validate_zip_code_again_fm(){
        if ($('#zip_code_from').val() == '' && $('#from-zip_fm').val('') && $('#from-city_fm').val(''))
        {
               jAlert('Oops! Please take a moment to enter the zip code you are moving from. ',
                        'MovingCost.com Alert',
                        function(){ $('#zip_code_from').focus();});
               $('#zip_code_from').css({'background-color': '#FEFA00'});
               return false;
        }
        else if($('#zip_code_to').val() == '' && $('#to-zip_fm').val('') && $('#to-city_fm').val('')){
             jAlert('Oops! Please take a moment to enter the zip code you are moving from. ',
                        'MovingCost.com Alert',
                        function(){ $('#zip_code_to').focus();});
               $('#zip_code_to').css({'background-color': '#FEFA00'});
               return false;
        }
        else{
              validateForm();
                }
              return false;
    }

    function validateForm()
    {
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        var phone_numberReg = /^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/;

//            if ($('#move_from_city').val() == '' || $('#move_from_state').val() == ''||
//            $('#move_from_zip_code').val() == ''){
//                     jAlert('Oops! Please provide us with the location where you are moving from',
//                     'MovingCost.com Alert',
//                    function(){search_zip_from()});
//                    return false;
//            }
//            if ($('#move_to_city').val() == '' || $('#move_to_state').val() == ''||
//            $('#move_to_zip_code').val() == ''){
//                     jAlert('Oops! Please provide us with the location where you are moving to',
//                     'MovingCost.com Alert',
//                    function(){search_zip_to()});
//                    return false;
//            }
           if ($('#move-date').val() == '' ){
                     jAlert('Oops! Please provide us with your estimated moving date',
                     'MovingCost.com Alert',
                    function(){$('#click-for-cal').trigger("click")});
                    return false;
            }
            if ($('#FirstName').val() == '' ){
                    jAlert('Oops! Please take a moment to enter your first name',
                    'MovingCost.com Alert',
                    function(){$('#FirstName').focus()});
                    $('#FirstName').css({'background-color': '#FEFA00'});
                    return false;
            }

            if ($('#LastName').val() == ''){
                   jAlert('Oops! Please take a moment to enter your last name',
                    'MovingCost.com Alert',
                    function(){$('#LastName').focus()});
                    $('#LastName').css({'background-color': '#FEFA00'});
                    return false;
            }

            if($('#Email').val().length >2){
                if (!(emailReg.test($('#Email').val())) ){
                        jAlert('Oops! Unfortunatelly, the email address provided does not appear to be valid.',
                        'MovingCost.com Alert',
                        function(){$('#Email').focus()});
                        $('#Email').css({'background-color': '#FEFA00'});
                        return false;
                        }
                }
                else
                {      jAlert('Oops! Please take a moment to enter your email address',
                        'MovingCost.com Alert',
                        function(){$('#Email').focus()});
                        $('#Email').css({'background-color': '#FEFA00'});
                        return false;
                }
                 if ($('#Phone_Day').val().length < 10){
                            jAlert('Oops! Please take a moment to enter your phone number',
                            'MovingCost.com Alert',
                            function(){$('#Phone_Day').focus()});
                            $('#Phone_Day').css({'background-color': '#FEFA00'});
                            return false;
                }
                else
                {
                    var invalid_phone = ['1111111111','2222222222', '3333333333',
                           '4444444444', '5555555555', '6666666666', '7777777777', '8888888888',
                            '9999999999'];
                       if( $.inArray($('#Phone_Day').val(), invalid_phone, true) >= 0  ) {
                               jAlert('Oops! Unfortunatelly, the phone number provided does not appear to be valid.',
                               'MovingCost.com Alert',
                            function(){$('#Phone_Day').focus()});
                               return false;
                       }
                       if(!phone_numberReg.test($('#Phone_Day').val())){
                            jAlert('Oops! Unfortunatelly, the phone number provided does not appear to be valid.',
                            'MovingCost.com Alert',
                            function(){$('#Phone_Day').focus()});
                            $('#Phone_Day').css({'background-color': '#FEFA00'});
                               return false;
                       }

            }
         document.getElementById("featured-moving-quote").submit();
    };


    //*** elements in the pop up window ***//
    $('#from-zip_fm').live('change', function() {
             getCitiesFromState_from_fm($(this).val(), 'from-city_fm', '1');
    });

    $('#from-city_fm').live('change', function() {
        if ($(this).val() !== '') {
            hideZippers_from();
            city = $('#from-city_fm option:selected').html();
            state = $('#from-zip_fm option:selected').val();
            zip = $(this).val();
                $('#move_from_city').val(city);
                $('#move_from_state').val(state);
                $('#move_from_zip_code').val(zip);
                $('#zip_code_from').val(zip);
                $('#ajax-flag').attr('running', 'false');
                }
        else
        {
          alert('Please pick a valid city!');
        }
    });

    $('#to-zip_fm').live('change', function() {
             getCitiesFromState_to_fm($(this).val(), 'to-city_fm', '1');
    });

    $('#to-city_fm').live('change', function() {
        if ($(this).val() !== '') {
            hideZippers_to();
            city = $('#to-city_fm option:selected').html();
            state = $('#to-zip_fm option:selected').val();
            zip = $(this).val();

                $('#move_to_city').val(city);
                $('#move_to_state').val(state);
                $('#move_to_zip_code').val(zip);
                $('#zip_code_to').val(zip);
                $('#ajax-flag').attr('running', 'false');
                }
        else
        {
          alert('Please pick a valid city!');
        }
    });
    //*** END OF elements in the pop up window ***//
     $(function() {
	 var referer = document.referrer;
	 setTimeout(function(){$('#keywords').val(referer)}, 200);
 });
    function ValidateZipFrom(evt) {
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57)){
                $('#zip_code_from').focus();
                return false;
                }
       else if(charCode == 13  ){
                return false;
                    }
                $('#move_from_city').val('');
                $('#move_from_state').val('');
                $('#move_from_zip_code').val('');
                $('#from-zip_fm').val('');
                $('#from-city_fm').val('');

                $('#zip_code_from').css({'background-color': '#FFFFFF'});
       if($('#zip_code_from').val().length == 4){
                var arraycharcode = new Array();
                arraycharcode[48]= 0; arraycharcode[49] = 1; arraycharcode[50]= 2;
                arraycharcode[51]=3;
                arraycharcode[52]=4; arraycharcode[53]=5; arraycharcode[54]=6; arraycharcode[55]=7;
                arraycharcode[56]=8; arraycharcode[57]=9;
                //alert(arraycharcode[charCode]);
                fullzip = $('#zip_code_from').val() + arraycharcode[charCode] ;
                var myurl =  "http://www.movingcost.com/ajax/validate-zip.php?zip="+ fullzip;
                  $.get(myurl, function(result){
                    if(result == false){
                   jAlert('Sorry, but the zip code you provided does not correspond to any known U.S. zip codes.', 'MovingCost.com Alert');
                        $('#zip_code_from').val('');
                        $('#zip_code_from').css({'background-color': '#FEFA00'});
                        $('#zip_code_from').focus();
                     }
                  });

         }
            }
       function ValidateZipTo(evt) {
        var charCode = (evt.which) ? evt.which : evt.keyCode;
        if (charCode > 31 && (charCode < 48 || charCode > 57)){
                $('#zip_code_to').focus();
                return false;
                }
       else if(charCode == 13  ){
                return false;
                    }
                $('#move_to_city').val('');
                $('#move_to_state').val('');
                $('#move_to_zip_code').val('');
                $('#to-zip_fm').val('');
                $('#to-city_fm').val('');

                $('#zip_code_to').css({'background-color': '#FFFFFF'});
       if($('#zip_code_to').val().length == 4){
                var arraycharcode = new Array();
                arraycharcode[48]= 0; arraycharcode[49] = 1; arraycharcode[50]= 2;
                arraycharcode[51]=3;
                arraycharcode[52]=4; arraycharcode[53]=5; arraycharcode[54]=6; arraycharcode[55]=7;
                arraycharcode[56]=8; arraycharcode[57]=9;
                //alert(arraycharcode[charCode]);
                fullzip = $('#zip_code_to').val() + arraycharcode[charCode] ;
                var myurl =  "http://www.movingcost.com/ajax/validate-zip.php?zip="+ fullzip;
                  $.get(myurl, function(result){
                    if(result == false){
                   jAlert('Sorry, but the zip code you provided does not correspond to any known U.S. zip codes.', 'MovingCost.com Alert');
                    $('#zip_code_to').val('');
                    $('#zip_code_to').css({'background-color': '#FEFA00'});
                    $('#zip_code_to').focus();
                  }
                  });

         }
            }
     //*** elements in the pop up window ***//
    $('#from-zip_fm').live('change', function() {
             getCitiesFromState_from_fm($(this).val(), 'from-city_fm', '1');
    });

    $('#from-city_fm').live('change', function() {
        if ($(this).val() !== '') {
            hideZippers_from();
            city = $('#from-city_fm option:selected').html();
            state = $('#from-zip_fm option:selected').val();
            zip = $(this).val();
                $('#move_from_city').val(city);
                $('#move_from_state').val(state);
                $('#move_from_zip_code').val(zip);
                $('#zip_code_from').val(zip);
                $('#ajax-flag').attr('running', 'false');
                }
        else
        {
          alert('Please pick a valid city!');
        }
    });

    $('#to-zip_fm').live('change', function() {
             getCitiesFromState_to_fm($(this).val(), 'to-city_fm', '1');
    });

    $('#to-city_fm').live('change', function() {
        if ($(this).val() !== '') {
            hideZippers_to();
            city = $('#to-city_fm option:selected').html();
            state = $('#to-zip_fm option:selected').val();
            zip = $(this).val();

                $('#move_to_city').val(city);
                $('#move_to_state').val(state);
                $('#move_to_zip_code').val(zip);
                $('#zip_code_to').val(zip);
                $('#ajax-flag').attr('running', 'false');
                }
        else
        {
          alert('Please pick a valid city!');
        }
    });
    //*** END OF elements in the pop up window ***//
