

/*prototype.js*/

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}('C 12={5A:\'1.5.1.1\',1Z:{3X:!!(1j.3Y&&!1j.4C),5B:!!1j.4C,3r:3Z.41.3s(\'9n/\')>-1,4D:3Z.41.3s(\'4D\')>-1&&3Z.41.3s(\'6Y\')==-1},3b:{5C:!!11.25,42:!!1j.43,5D:(11.2y(\'2e\').44!==11.2y(\'5E\').44)},4E:\'<5F[^>]*>([\\\\S\\\\s]*?)<\\/5F>\',6Z:/^\\/\\*-9o-([\\s\\S]*)\\*\\/\\s*$/,2J:o(){},K:o(x){B x}};C 1C={1D:o(){B o(){7.26.2m(7,17)}}};C 1O=V N();N.M=o(a,b){J(C c 1u b){a[c]=b[c]}B a};N.M(N,{1H:o(a){1P{D(a===1l)B\'1l\';D(a===18)B\'18\';B a.1H?a.1H():a.28()}1V(e){D(e 5G 9p)B\'...\';2z e;}},1Q:o(a){C b=1m a;45(b){1I\'1l\':1I\'o\':1I\'9q\':B;1I\'9r\':B a.28()}D(a===18)B\'18\';D(a.1Q)B a.1Q();D(a.5H===11)B;C c=[];J(C d 1u a){C e=N.1Q(a[d]);D(e!==1l)c.O(d.1Q()+\': \'+e)}B\'{\'+c.1R(\', \')+\'}\'},70:o(a){C b=[];J(C c 1u a)b.O(c);B b},3t:o(a){C b=[];J(C c 1u a)b.O(a[c]);B b},2o:o(a){B N.M({},a)}});71.U.1J=o(){C a=7,2p=$A(17),47=2p.4F();B o(){B a.2m(47,2p.1v($A(17)))}};71.U.9s=o(b){C c=7,2p=$A(17),b=2p.4F();B o(a){B c.2m(b,[a||1j.9t].1v(2p))}};N.M(3u.U,{9u:o(){B 7.2K(2,16)},5I:o(){B 7+1},4G:o(a){$R(0,7,1c).1e(a);B 7},2K:o(a,b){C c=7.28(b||10);B\'0\'.4G(a-c.I)+c},1Q:o(){B 9v(7)?7.28():\'18\'}});9w.U.1Q=o(){B\'"\'+7.9x()+\'-\'+(7.9y()+1).2K(2)+\'-\'+7.9z().2K(2)+\'T\'+7.9A().2K(2)+\':\'+7.9B().2K(2)+\':\'+7.9C().2K(2)+\'"\'};C 72={73:o(){C a;J(C i=0,I=17.I;i<I;i++){C b=17[i];1P{a=b();1y}1V(e){}}B a}};C 74=1C.1D();74.U={26:o(a,b){7.3v=a;7.3c=b;7.4H=1d;7.3d()},3d:o(){7.3w=75(7.3e.1J(7),7.3c*5J)},5K:o(){D(!7.3w)B;9D(7.3w);7.3w=18},3e:o(){D(!7.4H){1P{7.4H=1c;7.3v(7)}9E{7.4H=1d}}}};N.M(1S,{5L:o(a){B a==18?\'\':1S(a)},76:{\'\\b\':\'\\\\b\',\'\\t\':\'\\\\t\',\'\\n\':\'\\\\n\',\'\\f\':\'\\\\f\',\'\\r\':\'\\\\r\',\'\\\\\':\'\\\\\\\\\'}});N.M(1S.U,{29:o(a,b){C c=\'\',2L=7,1f;b=17.5M.5N(b);1o(2L.I>0){D(1f=2L.1f(a)){c+=2L.3x(0,1f.4I);c+=1S.5L(b(1f));2L=2L.3x(1f.4I+1f[0].I)}1b{c+=2L,2L=\'\'}}B c},77:o(b,c,d){c=7.29.5N(c);d=d===1l?1:d;B 7.29(b,o(a){D(--d<0)B a[0];B c(a)})},78:o(a,b){7.29(a,b);B 7},9F:o(a,b){a=a||30;b=b===1l?\'...\':b;B 7.I>a?7.3x(0,a-b.I)+b:7},3f:o(){B 7.1q(/^\\s+/,\'\').1q(/\\s+$/,\'\')},79:o(){B 7.1q(/<\\/?[^>]+>/5O,\'\')},2q:o(){B 7.1q(V 1W(12.4E,\'7a\'),\'\')},7b:o(){C b=V 1W(12.4E,\'7a\');C c=V 1W(12.4E,\'9G\');B(7.1f(b)||[]).20(o(a){B(a.1f(c)||[\'\',\'\'])[1]})},3y:o(){B 7.7b().20(o(a){B 4J(a)})},4K:o(){C a=17.5M;a.2r.9H=7;B a.2e.2s},7c:o(){C c=11.2y(\'2e\');c.2s=7.79();B c.2a[0]?(c.2a.I>1?$A(c.2a).2A(\'\',o(a,b){B a+b.48}):c.2a[0].48):\'\'},4L:o(e){C f=7.3f().1f(/([^?#]*)(#.*)?$/);D(!f)B{};B f[1].3z(e||\'&\').2A({},o(a,b){D((b=b.3z(\'=\'))[0]){C c=7d(b.4F());C d=b.I>1?b.1R(\'=\'):b[0];D(d!=1l)d=7d(d);D(c 1u a){D(a[c].3g!=1E)a[c]=[a[c]];a[c].O(d)}1b a[c]=d}B a})},2b:o(){B 7.3z(\'\')},5I:o(){B 7.3x(0,7.I-1)+1S.9I(7.7e(7.I-1)+1)},4G:o(a){C b=\'\';J(C i=0;i<a;i++)b+=7;B b},4M:o(){C a=7.3z(\'-\'),5P=a.I;D(5P==1)B a[0];C b=7.4N(0)==\'-\'?a[0].4N(0).1X()+a[0].49(1):a[0];J(C i=1;i<5P;i++)b+=a[i].4N(0).1X()+a[i].49(1);B b},5Q:o(){B 7.4N(0).1X()+7.49(1).21()},9J:o(){B 7.29(/::/,\'/\').29(/([A-Z]+)([A-Z][a-z])/,\'#{1}4a#{2}\').29(/([a-z\\d])([A-Z])/,\'#{1}4a#{2}\').29(/-/,\'4a\').21()},9K:o(){B 7.29(/4a/,\'-\')},1H:o(c){C d=7.29(/[\\9L-\\9M\\\\]/,o(a){C b=1S.76[a[0]];B b?b:\'\\\\9N\'+a[0].7e().2K(2,16)});D(c)B\'"\'+d.1q(/"/g,\'\\\\"\')+\'"\';B"\'"+d.1q(/\'/g,\'\\\\\\\'\')+"\'"},1Q:o(){B 7.1H(1c)},5R:o(a){B 7.77(a||12.6Z,\'#{1}\')},7f:o(){C a=7.1q(/\\\\./g,\'@\').1q(/"[^"\\\\\\n\\r]*"/g,\'\');B(/^[,:{}\\[\\]0-9.\\-+9O-u \\n\\r\\t]*$/).2M(a)},4O:o(a){C b=7.5R();1P{D(!a||b.7f())B 4J(\'(\'+b+\')\')}1V(e){}2z V 9P(\'9Q 9R 7g 2B: \'+7.1H());},1p:o(a){B 7.3s(a)>-1},7h:o(a){B 7.3s(a)===0},7i:o(a){C d=7.I-a.I;B d>=0&&7.9S(a)===d},4b:o(){B 7==\'\'},7j:o(){B/^\\s*$/.2M(7)}});D(12.1Z.3r||12.1Z.3X){N.M(1S.U,{4K:o(){B 7.1q(/&/g,\'&7k;\').1q(/</g,\'&7l;\').1q(/>/g,\'&7m;\')},7c:o(){B 7.1q(/&7k;/g,\'&\').1q(/&7l;/g,\'<\').1q(/&7m;/g,\'>\')}})}1S.U.29.5N=o(b){D(1m b==\'o\')B b;C c=V 22(b);B o(a){B c.25(a)}};1S.U.9T=1S.U.4L;N.M(1S.U.4K,{2e:11.2y(\'2e\'),2r:11.9U(\'\')});7n(1S.U.4K)2e.5S(2r);C 22=1C.1D();22.7o=/(^|.|\\r|\\n)(#\\{(.*?)\\})/;22.U={26:o(a,b){7.7p=a.28();7.4P=b||22.7o},25:o(c){B 7.7p.29(7.4P,o(a){C b=a[1];D(b==\'\\\\\')B a[2];B b+1S.5L(c[a[3]])})}};C $1y={};C $2c=V 9V(\'"2z $2c" 9W 9X, 9Y "B" 9Z\');C 23={1e:o(b){C c=0;1P{7.2f(o(a){b(a,c++)})}1V(e){D(e!=$1y)2z e;}B 7},7q:o(a,b){C c=-a,5T=[],5U=7.2b();1o((c+=a)<5U.I)5T.O(5U.3x(c,c+a));B 5T.20(b)},a0:o(c){C d=1c;7.1e(o(a,b){d=d&&!!(c||12.K)(a,b);D(!d)2z $1y;});B d},a1:o(c){C d=1d;7.1e(o(a,b){D(d=!!(c||12.K)(a,b))2z $1y;});B d},7r:o(c){C d=[];7.1e(o(a,b){d.O((c||12.K)(a,b))});B d},7s:o(c){C d;7.1e(o(a,b){D(c(a,b)){d=a;2z $1y;}});B d},7t:o(c){C d=[];7.1e(o(a,b){D(c(a,b))d.O(a)});B d},a2:o(d,e){C f=[];7.1e(o(a,b){C c=a.28();D(c.1f(d))f.O((e||12.K)(a,b))});B f},1p:o(b){C c=1d;7.1e(o(a){D(a==b){c=1c;2z $1y;}});B c},a3:o(b,c){c=c===1l?18:c;B 7.7q(b,o(a){1o(a.I<b)a.O(c);B a})},2A:o(c,d){7.1e(o(a,b){c=d(c,a,b)});B c},5V:o(b){C c=$A(17).3x(1);B 7.20(o(a){B a[b].2m(a,c)})},a4:o(c){C d;7.1e(o(a,b){a=(c||12.K)(a,b);D(d==1l||a>=d)d=a});B d},a5:o(c){C d;7.1e(o(a,b){a=(c||12.K)(a,b);D(d==1l||a<d)d=a});B d},a6:o(c){C d=[],5W=[];7.1e(o(a,b){((c||12.K)(a,b)?d:5W).O(a)});B[d,5W]},4c:o(c){C d=[];7.1e(o(a,b){d.O(a[c])});B d},a7:o(c){C d=[];7.1e(o(a,b){D(!c(a,b))d.O(a)});B d},a8:o(e){B 7.20(o(a,b){B{1w:a,4d:e(a,b)}}).a9(o(c,d){C a=c.4d,b=d.4d;B a<b?-1:a>b?1:0}).4c(\'1w\')},2b:o(){B 7.20()},aa:o(){C c=12.K,2p=$A(17);D(1m 2p.1z()==\'o\')c=2p.ab();C d=[7].1v(2p).20($A);B 7.20(o(a,b){B c(d.4c(b))})},7u:o(){B 7.2b().I},1H:o(){B\'#<23:\'+7.2b().1H()+\'>\'}};N.M(23,{20:23.7r,7v:23.7s,2g:23.7t,ac:23.1p,ad:23.2b});C $A=1E.7w=o(a){D(!a)B[];D(a.2b){B a.2b()}1b{C b=[];J(C i=0,I=a.I;i<I;i++)b.O(a[i]);B b}};D(12.1Z.3r){$A=1E.7w=o(a){D(!a)B[];D(!(1m a==\'o\'&&a==\'[47 ae]\')&&a.2b){B a.2b()}1b{C b=[];J(C i=0,I=a.I;i<I;i++)b.O(a[i]);B b}}}N.M(1E.U,23);D(!1E.U.5X)1E.U.5X=1E.U.4Q;N.M(1E.U,{2f:o(a){J(C i=0,I=7.I;i<I;i++)a(7[i])},7x:o(){7.I=0;B 7},2h:o(){B 7[0]},1z:o(){B 7[7.I-1]},af:o(){B 7.2g(o(a){B a!=18})},7y:o(){B 7.2A([],o(a,b){B a.1v(b&&b.3g==1E?b.7y():[b])})},5Y:o(){C b=$A(17);B 7.2g(o(a){B!b.1p(a)})},3s:o(a){J(C i=0,I=7.I;i<I;i++)D(7[i]==a)B i;B-1},4Q:o(a){B(a!==1d?7:7.2b()).5X()},ag:o(){B 7.I>1?7:7[0]},ah:o(d){B 7.2A([],o(a,b,c){D(0==c||(d?a.1z()!=b:!a.1p(b)))a.O(b);B a})},2o:o(){B[].1v(7)},7u:o(){B 7.I},1H:o(){B\'[\'+7.20(N.1H).1R(\', \')+\']\'},1Q:o(){C c=[];7.1e(o(a){C b=N.1Q(a);D(b!==1l)c.O(b)});B\'[\'+c.1R(\', \')+\']\'}});1E.U.2b=1E.U.2o;o $w(a){a=a.3f();B a?a.3z(/\\s+/):[]}D(12.1Z.5B){1E.U.1v=o(){C a=[];J(C i=0,I=7.I;i<I;i++)a.O(7[i]);J(C i=0,I=17.I;i<I;i++){D(17[i].3g==1E){J(C j=0,7z=17[i].I;j<7z;j++)a.O(17[i][j])}1b{a.O(17[i])}}B a}}C 1F=o(a){D(a 5G 1F)7.7A(a);1b N.M(7,a||{})};N.M(1F,{3h:o(d){C e=[];e.3A=17.5M.7B;7.U.2f.5Z(d,o(b){D(!b.2i)B;C c=b.1w;D(c&&1m c==\'47\'){D(c.3g==1E)c.1e(o(a){e.3A(b.2i,a)});B}e.3A(b.2i,c)});B e.1R(\'&\')},1Q:o(c){C d=[];7.U.2f.5Z(c,o(a){C b=N.1Q(a.1w);D(b!==1l)d.O(a.2i.1Q()+\': \'+b)});B\'{\'+d.1R(\', \')+\'}\'}});1F.3h.7B=o(a,b,c){a=7C(a);D(b===1l)7.O(a);1b 7.O(a+\'=\'+(b==18?\'\':7C(b)))};N.M(1F.U,23);N.M(1F.U,{2f:o(a){J(C b 1u 7){C c=7[b];D(c&&c==1F.U[b])2c;C d=[b,c];d.2i=b;d.1w=c;a(d)}},70:o(){B 7.4c(\'2i\')},3t:o(){B 7.4c(\'1w\')},7A:o(c){B $H(c).2A(7,o(a,b){a[b.2i]=b.1w;B a})},4e:o(){C a;J(C i=0,I=17.I;i<I;i++){C b=7[17[i]];D(b!==1l){D(a===1l)a=b;1b{D(a.3g!=1E)a=[a];a.O(b)}}7D 7[17[i]]}B a},3h:o(){B 1F.3h(7)},1H:o(){B\'#<1F:{\'+7.20(o(a){B a.20(N.1H).1R(\': \')}).1R(\', \')+\'}>\'},1Q:o(){B 1F.1Q(7)}});o $H(a){D(a 5G 1F)B a;B V 1F(a)};D(o(){C i=0,60=o(a){7.2i=a};60.U.2i=\'ai\';J(C b 1u V 60(\'aj\'))i++;B i>1}())1F.U.2f=o(a){C b=[];J(C c 1u 7){C d=7[c];D((d&&d==1F.U[c])||b.1p(c))2c;b.O(c);C e=[c,d];e.2i=c;e.1w=d;a(e)}};4R=1C.1D();N.M(4R.U,23);N.M(4R.U,{26:o(a,b,c){7.4f=a;7.61=b;7.7E=c},2f:o(a){C b=7.4f;1o(7.1p(b)){a(b);b=b.5I()}},1p:o(a){D(a<7.4f)B 1d;D(7.7E)B a<7.61;B a<=7.61}});C $R=o(a,b,c){B V 4R(a,b,c)};C 1h={62:o(){B 72.73(o(){B V 7F()},o(){B V 7G(\'ak.7H\')},o(){B V 7G(\'al.7H\')})||1d},63:0};1h.3B={4g:[],2f:o(a){7.4g.2f(a)},7I:o(a){D(!7.1p(a))7.4g.O(a)},am:o(a){7.4g=7.4g.5Y(a)},4S:o(b,c,d,f){7.1e(o(a){D(1m a[b]==\'o\'){1P{a[b].2m(a,[c,d,f])}1V(e){}}})}};N.M(1h.3B,23);1h.3B.7I({4T:o(){1h.63++},2t:o(){1h.63--}});1h.4U=o(){};1h.4U.U={4V:o(a){7.14={1K:\'4h\',4W:1c,7J:\'64/x-an-5E-ao\',65:\'ap-8\',2C:\'\'};N.M(7.14,a||{});7.14.1K=7.14.1K.21();D(1m 7.14.2C==\'2B\')7.14.2C=7.14.2C.4L()}};1h.3C=1C.1D();1h.3C.7K=[\'aq\',\'ar\',\'as\',\'at\',\'66\'];1h.3C.U=N.M(V 1h.4U(),{67:1d,26:o(a,b){7.1r=1h.62();7.4V(b);7.4X(a)},4X:o(a){7.3D=a;7.1K=7.14.1K;C b=N.2o(7.14.2C);D(![\'7L\',\'4h\'].1p(7.1K)){b[\'au\']=7.1K;7.1K=\'4h\'}7.2C=b;D(b=1F.3h(b)){D(7.1K==\'7L\')7.3D+=(7.3D.1p(\'?\')?\'&\':\'?\')+b;1b D(/av|aw|6Y/.2M(3Z.41))b+=\'&4a=\'}1P{D(7.14.4T)7.14.4T(7.1r);1h.3B.4S(\'4T\',7,7.1r);7.1r.ax(7.1K.1X(),7.3D,7.14.4W);D(7.14.4W)3i(o(){7.68(1)}.1J(7),10);7.1r.7M=7.69.1J(7);7.7N();7.1T=7.1K==\'4h\'?(7.14.ay||b):18;7.1r.az(7.1T);D(!7.14.4W&&7.1r.7O)7.69()}1V(e){7.4i(e)}},69:o(){C a=7.1r.7P;D(a>1&&!((a==4)&&7.67))7.68(7.1r.7P)},7N:o(){C b={\'X-aA-aB\':\'7F\',\'X-12-5A\':12.5A,\'aC\':\'2r/aD, 2r/aE, 64/7Q, 2r/7Q, */*\'};D(7.1K==\'4h\'){b[\'7R-1g\']=7.14.7J+(7.14.65?\'; aF=\'+7.14.65:\'\');D(7.1r.7O&&(3Z.41.1f(/4D\\/(\\d{4})/)||[0,7S])[1]<7S)b[\'aG\']=\'aH\'}D(1m 7.14.7T==\'47\'){C c=7.14.7T;D(1m c.O==\'o\')J(C i=0,I=c.I;i<I;i+=2)b[c[i]]=c[i+1];1b $H(c).1e(o(a){b[a.2i]=a.1w})}J(C d 1u b)7.1r.aI(d,b[d])},2N:o(){B!7.1r.4Y||(7.1r.4Y>=aJ&&7.1r.4Y<aK)},68:o(a){C b=1h.3C.7K[a];C c=7.1r,4Z=7.4O();D(b==\'66\'){1P{7.67=1c;(7.14[\'3E\'+7.1r.4Y]||7.14[\'3E\'+(7.2N()?\'aL\':\'aM\')]||12.2J)(c,4Z)}1V(e){7.4i(e)}C d=7.6a(\'7R-1g\');D(d&&d.3f().1f(/^(2r|64)\\/(x-)?(aN|aO)5F(;.*)?$/i))7.7U()}1P{(7.14[\'3E\'+b]||12.2J)(c,4Z);1h.3B.4S(\'3E\'+b,7,c,4Z)}1V(e){7.4i(e)}D(b==\'66\'){7.1r.7M=12.2J}},6a:o(a){1P{B 7.1r.aP(a)}1V(e){B 18}},4O:o(){1P{C a=7.6a(\'X-7g\');B a?a.4O():18}1V(e){B 18}},7U:o(){1P{B 4J((7.1r.50||\'\').5R())}1V(e){7.4i(e)}},4i:o(a){(7.14.7V||12.2J)(7,a);1h.3B.4S(\'7V\',7,a)}});1h.6b=1C.1D();N.M(N.M(1h.6b.U,1h.3C.U),{26:o(c,d,e){7.51={2N:(c.2N||c),6c:(c.6c||(c.2N?18:c))};7.1r=1h.62();7.4V(e);C f=7.14.2t||12.2J;7.14.2t=(o(a,b){7.7W();f(a,b)}).1J(7);7.4X(d)},7W:o(){C a=7.51[7.2N()?\'2N\':\'6c\'];C b=7.1r.50;D(!7.14.3y)b=b.2q();D(a=$(a)){D(7.14.7X)V 7.14.7X(a,b);1b a.6d(b)}D(7.2N()){D(7.2t)3i(7.2t.1J(7),10)}}});1h.7Y=1C.1D();1h.7Y.U=N.M(V 1h.4U(),{26:o(a,b,c){7.4V(c);7.2t=7.14.2t;7.3c=(7.14.3c||2);7.3j=(7.14.3j||1);7.6e={};7.51=a;7.3D=b;7.4f()},4f:o(){7.14.2t=7.7Z.1J(7);7.3e()},5K:o(){7.6e.14.2t=1l;aQ(7.3w);(7.2t||12.2J).2m(7,17)},7Z:o(a){D(7.14.3j){7.3j=(a.50==7.80?7.3j*7.14.3j:1);7.80=a.50}7.3w=3i(7.3e.1J(7),7.3j*7.3c*5J)},3e:o(){7.6e=V 1h.6b(7.51,7.3D,7.14)}});o $(a){D(17.I>1){J(C i=0,6f=[],I=17.I;i<I;i++)6f.O($(17[i]));B 6f}D(1m a==\'2B\')a=11.aR(a);B G.M(a)}D(12.3b.5C){11.6g=o(a,b){C c=[];C d=11.25(a,$(b)||11,18,aS.aT,18);J(C i=0,I=d.aU;i<I;i++)c.O(d.aV(i));B c};11.52=o(a,b){C q=".//*[4j(1v(\' \', @6h, \' \'), \' "+a+" \')]";B 11.6g(q,b)}}1b{11.52=o(a,b){C c=($(b)||11.1T).2D(\'*\');C d=[],1i,4P=V 1W("(^|\\\\s)"+a+"(\\\\s|$)");J(C i=0,I=c.I;i<I;i++){1i=c[i];C e=1i.2j;D(e.I==0)2c;D(e==a||e.1f(4P))d.O(G.M(1i))}B d}}D(!1j.G)C G={};G.M=o(a){C F=12.3b;D(!a||!a.1k||a.2u==3||a.81||F.5D||a==1j)B a;C b={},1k=a.1k,4k=G.M.4k,T=G.19.2E;D(!F.42){N.M(b,G.19),N.M(b,G.19.53)}D(T[1k])N.M(b,T[1k]);J(C c 1u b){C d=b[c];D(1m d==\'o\'&&!(c 1u a))a[c]=4k.6i(d)}a.81=12.2J;B a};G.M.4k={6i:o(a){B 7[a]=7[a]||o(){B a.2m(18,[7].1v($A(17)))}}};G.19={6j:o(a){B $(a).Y.2F!=\'54\'},82:o(a){a=$(a);G[G.6j(a)?\'83\':\'84\'](a);B a},83:o(a){$(a).Y.2F=\'54\';B a},84:o(a){$(a).Y.2F=\'\';B a},4e:o(a){a=$(a);a.1L.6k(a);B a},6d:o(a,b){b=1m b==\'1l\'?\'\':b.28();$(a).2s=b.2q();3i(o(){b.3y()},10);B a},1q:o(a,b){a=$(a);b=1m b==\'1l\'?\'\':b.28();D(a.85){a.85=b.2q()}1b{C c=a.5H.86();c.6l(a);a.1L.aW(c.87(b.2q()),a)}3i(o(){b.3y()},10);B a},1H:o(d){d=$(d);C e=\'<\'+d.1k.21();$H({\'2O\':\'2O\',\'2j\':\'6h\'}).1e(o(a){C b=a.2h(),88=a.1z();C c=(d[b]||\'\').28();D(c)e+=\' \'+88+\'=\'+c.1H(1c)});B e+\'>\'},55:o(a,b){a=$(a);C c=[];1o(a=a[b])D(a.2u==1)c.O(G.M(a));B c},89:o(a){B $(a).55(\'1L\')},8a:o(a){B $A($(a).2D(\'*\')).1e(G.M)},8b:o(a){a=$(a).3F;1o(a&&a.2u!=1)a=a.3G;B $(a)},8c:o(a){D(!(a=$(a).3F))B[];1o(a&&a.2u!=1)a=a.3G;D(a)B[a].1v($(a).4l());B[]},6m:o(a){B $(a).55(\'8d\')},4l:o(a){B $(a).55(\'3G\')},aX:o(a){a=$(a);B a.6m().4Q().1v(a.4l())},1f:o(a,b){D(1m b==\'2B\')b=V L(b);B b.1f($(a))},aY:o(a,b,c){a=$(a);D(17.I==1)B $(a.1L);C d=a.89();B b?L.3H(d,b,c):d[c||0]},aZ:o(a,b,c){a=$(a);D(17.I==1)B a.8b();C d=a.8a();B b?L.3H(d,b,c):d[c||0]},b0:o(a,b,c){a=$(a);D(17.I==1)B $(L.1s.4m(a));C d=a.6m();B b?L.3H(d,b,c):d[c||0]},b1:o(a,b,c){a=$(a);D(17.I==1)B $(L.1s.4n(a));C d=a.4l();B b?L.3H(d,b,c):d[c||0]},b2:o(){C a=$A(17),15=$(a.4F());B L.6n(15,a)},52:o(a,b){B 11.52(b,a)},6o:o(a,b){a=$(a);D(12.1Z.3X){D(!a.8e)B 18;C t=G.56;D(t.3t[b])B t.3t[b](a,b);D(t.57[b])b=t.57[b];C c=a.8e[b];B c?c.48:18}B a.8f(b)},b3:o(a){B $(a).6p().2P},b4:o(a){B $(a).6p().2Q},58:o(a){B V G.59(a)},8g:o(a,b){D(!(a=$(a)))B;C c=a.2j;D(c.I==0)B 1d;D(c==b||c.1f(V 1W("(^|\\\\s)"+b+"(\\\\s|$)")))B 1c;B 1d},b5:o(a,b){D(!(a=$(a)))B;G.58(a).3A(b);B a},b6:o(a,b){D(!(a=$(a)))B;G.58(a).4e(b);B a},b7:o(a,b){D(!(a=$(a)))B;G.58(a)[a.8g(b)?\'4e\':\'3A\'](b);B a},3I:o(){1x.3I.2m(1x,17);B $A(17).2h()},5a:o(){1x.5a.2m(1x,17);B $A(17).2h()},b8:o(a){a=$(a);C b=a.3F;1o(b){C c=b.3G;D(b.2u==3&&!/\\S/.2M(b.48))a.6k(b);b=c}B a},4b:o(a){B $(a).2s.7j()},5b:o(a,b){a=$(a),b=$(b);1o(a=a.1L)D(a==b)B 1c;B 1d},8h:o(a){a=$(a);C b=2G.4o(a);1j.8h(b[0],b[1]);B a},1M:o(a,b){a=$(a);b=b==\'6q\'?\'5c\':b.4M();C c=a.Y[b];D(!c){C d=11.b9.ba(a,18);c=d?d[b]:18}D(b==\'2R\')B c?3J(c):1.0;B c==\'5d\'?18:c},bb:o(a){B $(a).1M(\'2R\')},bc:o(a,b,c){a=$(a);C d=a.Y;J(C e 1u b)D(e==\'2R\')a.5e(b[e]);1b d[(e==\'6q\'||e==\'5c\')?(d.6r===1l?\'5c\':\'6r\'):(c?e:e.4M())]=b[e];B a},5e:o(a,b){a=$(a);a.Y.2R=(b==1||b===\'\')?\'\':(b<0.6s)?0:b;B a},6p:o(a){a=$(a);C b=$(a).1M(\'2F\');D(b!=\'54\'&&b!=18)B{2Q:a.3K,2P:a.3L};C c=a.Y;C d=c.6t;C e=c.1A;C f=c.2F;c.6t=\'5f\';c.1A=\'3k\';c.2F=\'bd\';C g=a.8i;C h=a.8j;c.2F=f;c.1A=e;c.6t=d;B{2Q:g,2P:h}},be:o(a){a=$(a);C b=G.1M(a,\'1A\');D(b==\'6u\'||!b){a.6v=1c;a.Y.1A=\'5g\';D(1j.4C){a.Y.2S=0;a.Y.2T=0}}B a},bf:o(a){a=$(a);D(a.6v){a.6v=1l;a.Y.1A=a.Y.2S=a.Y.2T=a.Y.8k=a.Y.8l=\'\'}B a},bg:o(a){a=$(a);D(a.3M)B a;a.3M=a.Y.5h||\'5d\';D((G.1M(a,\'5h\')||\'6j\')!=\'5f\')a.Y.5h=\'5f\';B a},bh:o(a){a=$(a);D(!a.3M)B a;a.Y.5h=a.3M==\'5d\'?\'\':a.3M;a.3M=18;B a}};N.M(G.19,{bi:G.19.5b,bj:G.19.8c});D(12.1Z.5B){G.19.6w=G.19.1M;G.19.1M=o(a,b){45(b){1I\'2T\':1I\'2S\':1I\'8l\':1I\'8k\':D(G.6w(a,\'1A\')==\'6u\')B 18;6x:B G.6w(a,b)}}}1b D(12.1Z.3X){G.19.1M=o(a,b){a=$(a);b=(b==\'6q\'||b==\'5c\')?\'6r\':b.4M();C c=a.Y[b];D(!c&&a.8m)c=a.8m[b];D(b==\'2R\'){D(c=(a.1M(\'5i\')||\'\').1f(/5j\\(2R=(.*)\\)/))D(c[1])B 3J(c[1])/8n;B 1.0}D(c==\'5d\'){D((b==\'2Q\'||b==\'2P\')&&(a.1M(\'2F\')!=\'54\'))B a[\'24\'+b.5Q()]+\'2k\';B 18}B c};G.19.5e=o(a,b){a=$(a);C c=a.1M(\'5i\'),Y=a.Y;D(b==1||b===\'\'){Y.5i=c.1q(/5j\\([^\\)]*\\)/5O,\'\');B a}1b D(b<0.6s)b=0;Y.5i=c.1q(/5j\\([^\\)]*\\)/5O,\'\')+\'5j(2R=\'+(b*8n)+\')\';B a};G.19.6d=o(b,c){b=$(b);c=1m c==\'1l\'?\'\':c.28();C d=b.1k.1X();D([\'6y\',\'5k\',\'5l\',\'6z\'].1p(d)){C e=11.2y(\'2e\');45(d){1I\'6y\':1I\'5k\':e.2s=\'<2U><2V>\'+c.2q()+\'</2V></2U>\';5m=2;1y;1I\'5l\':e.2s=\'<2U><2V><5n>\'+c.2q()+\'</5n></2V></2U>\';5m=3;1y;1I\'6z\':e.2s=\'<2U><2V><5n><8o>\'+c.2q()+\'</8o></5n></2V></2U>\';5m=4}$A(b.2a).1e(o(a){b.6k(a)});5m.4G(o(){e=e.3F});$A(e.2a).1e(o(a){b.5S(a)})}1b{b.2s=c.2q()}3i(o(){c.3y()},10);B b}}1b D(12.1Z.4D){G.19.5e=o(a,b){a=$(a);a.Y.2R=(b==1)?0.bk:(b===\'\')?\'\':(b<0.6s)?0:b;B a}}G.56={57:{bl:"bm",bn:"bo",bp:"bq",br:"bs",bt:"bu",bv:"bw",bx:"by",bz:"bA",8p:"bB",bC:"bD"},3t:{5o:o(a,b){B a.8f(b,2)},4p:o(a,b){B $(a).2H(b)?b:18},Y:o(a){B a.Y.bE.21()},8q:o(a){C b=a.8r(\'8q\');B b.8s?b.48:18}}};(o(){N.M(7,{bF:7.5o,bG:7.5o,1g:7.5o,2d:7.4p,3l:7.4p,8p:7.4p,bH:7.4p})}).5Z(G.56.3t);G.19.53={2H:o(a,b){C t=G.56,E;b=t.57[b]||b;E=$(a).8r(b);B E&&E.8s}};G.19.2E={};N.M(G,G.19);D(!12.3b.42&&11.2y(\'2e\').44){1j.43={};1j.43.U=11.2y(\'2e\').44;12.3b.42=1c}G.2H=o(a,b){D(a.2H)B a.2H(b);B G.19.53.2H(a,b)};G.8t=o(g){C F=12.3b,T=G.19.2E;D(!g){N.M(1a,1a.19);N.M(1a.G,1a.G.19);N.M(G.19.2E,{"bI":N.2o(1a.19),"bJ":N.2o(1a.G.19),"bK":N.2o(1a.G.19),"8u":N.2o(1a.G.19)})}D(17.I==2){C h=g;g=17[1]}D(!h)N.M(G.19,g||{});1b{D(h.3g==1E)h.1e(M);1b M(h)}o M(a){a=a.1X();D(!G.19.2E[a])G.19.2E[a]={};N.M(G.19.2E[a],g)}o 5p(a,b,c){c=c||1d;C d=G.M.4k;J(C e 1u a){C f=a[e];D(!c||!(e 1u b))b[e]=d.6i(f)}}o 8v(a){C b;C c={"bL":"bM","8u":"bN","P":"bO","bP":"bQ","bR":"bS","bT":"bU","bV":"bW","bX":"bY","bZ":"3N","c0":"3N","c1":"3N","c2":"3N","c3":"3N","c4":"3N","Q":"c5","c6":"8w","c7":"8w","A":"c8","c9":"ca","cb":"cc","cd":"8x","ce":"8x","6y":"6A","cf":"6A","5k":"6A","5l":"cg","ch":"8y","6z":"8y","ci":"cj","ck":"cl"};D(c[a])b=\'6B\'+c[a]+\'G\';D(1j[b])B 1j[b];b=\'6B\'+a+\'G\';D(1j[b])B 1j[b];b=\'6B\'+a.5Q()+\'G\';D(1j[b])B 1j[b];1j[b]={};1j[b].U=11.2y(a).44;B 1j[b]}D(F.42){5p(G.19,43.U);5p(G.19.53,43.U,1c)}D(F.5D){J(C i 1u G.19.2E){C j=8v(i);D(1m j=="1l")2c;5p(T[i],j.U)}}N.M(G,G.19);7D G.2E};C cm={2F:G.82};1O.1U=o(a){7.6C=a};1O.1U.U={26:o(a,b){7.15=$(a);7.5q=b.2q();D(7.6C&&7.15.8z){1P{7.15.8z(7.6C,7.5q)}1V(e){C c=7.15.1k.1X();D([\'5k\',\'5l\'].1p(c)){7.3O(7.8A())}1b{2z e;}}}1b{7.2W=7.15.5H.86();D(7.3P)7.3P();7.3O([7.2W.87(7.5q)])}3i(o(){b.3y()},10)},8A:o(){C a=11.2y(\'2e\');a.2s=\'<2U><2V>\'+7.5q+\'</2V></2U>\';B $A(a.2a[0].2a[0].2a)}};C 1U=V N();1U.8B=1C.1D();1U.8B.U=N.M(V 1O.1U(\'cn\'),{3P:o(){7.2W.co(7.15)},3O:o(b){b.1e((o(a){7.15.1L.6D(a,7.15)}).1J(7))}});1U.8C=1C.1D();1U.8C.U=N.M(V 1O.1U(\'cp\'),{3P:o(){7.2W.6l(7.15);7.2W.8D(1c)},3O:o(b){b.4Q(1d).1e((o(a){7.15.6D(a,7.15.3F)}).1J(7))}});1U.8E=1C.1D();1U.8E.U=N.M(V 1O.1U(\'cq\'),{3P:o(){7.2W.6l(7.15);7.2W.8D(7.15)},3O:o(b){b.1e((o(a){7.15.5S(a)}).1J(7))}});1U.8F=1C.1D();1U.8F.U=N.M(V 1O.1U(\'cr\'),{3P:o(){7.2W.cs(7.15)},3O:o(b){b.1e((o(a){7.15.1L.6D(a,7.15.3G)}).1J(7))}});G.59=1C.1D();G.59.U={26:o(a){7.15=$(a)},2f:o(b){7.15.2j.3z(/\\s+/).2g(o(a){B a.I>0}).2f(b)},6E:o(a){7.15.2j=a},3A:o(a){D(7.1p(a))B;7.6E($A(7).1v(a).1R(\' \'))},4e:o(a){D(!7.1p(a))B;7.6E($A(7).5Y(a).1R(\' \'))},28:o(){B $A(7).1R(\' \')}};N.M(G.59.U,23);C L=1C.1D();L.U={26:o(a){7.2X=a.3f();7.8G()},8G:o(){D(12.3b.5C&&!(/\\[[\\w-]*?:/).2M(7.2X))B 7.8H();C e=7.2X,3Q=L.5r,h=L.1s,c=L.4d,2I,p,m;D(L.3m[e]){7.2l=L.3m[e];B}7.2l=["7.2l = o(8I) {","C r = 8I, h = L.1s, c = 1d, n;"];1o(e&&2I!=e&&(/\\S/).2M(e)){2I=e;J(C i 1u 3Q){p=3Q[i];D(m=e.1f(p)){7.2l.O(1m c[i]==\'o\'?c[i](m):V 22(c[i]).25(m));e=e.1q(m[0],\'\');1y}}}7.2l.O("B h.6F(n);\\n}");4J(7.2l.1R(\'\\n\'));L.3m[7.2X]=7.2l},8H:o(){C e=7.2X,3Q=L.5r,x=L.1B,2I,m;D(L.3m[e]){7.1B=L.3m[e];B}7.2l=[\'.//*\'];1o(e&&2I!=e&&(/\\S/).2M(e)){2I=e;J(C i 1u 3Q){D(m=e.1f(3Q[i])){7.2l.O(1m x[i]==\'o\'?x[i](m):V 22(x[i]).25(m));e=e.1q(m[0],\'\');1y}}}7.1B=7.2l.1R(\'\');L.3m[7.2X]=7.1B},4q:o(a){a=a||11;D(7.1B)B 11.6g(7.1B,a);B 7.2l(a)},1f:o(a){B 7.4q(11).1p(a)},28:o(){B 7.2X},1H:o(){B"#<L:"+7.2X.1H()+">"}};N.M(L,{3m:{},1B:{2Y:"//*",1i:"/*",3R:"/4r-2Z::*[1]",4s:\'/4r-2Z::*\',1k:o(m){D(m[1]==\'*\')B\'\';B"[8J-3n()=\'"+m[1].21()+"\' 6G 8J-3n()=\'"+m[1].1X()+"\']"},2j:"[4j(1v(\' \', @6h, \' \'), \' #{1} \')]",2O:"[@2O=\'#{1}\']",4t:"[@#{1}]",4u:o(m){m[3]=m[5]||m[6];B V 22(L.1B.5s[m[2]]).25(m)},4v:o(m){C h=L.1B.1t[m[1]];D(!h)B\'\';D(1m h===\'o\')B h(m);B V 22(L.1B.1t[m[1]]).25(m)},5s:{\'=\':"[@#{1}=\'#{3}\']",\'!=\':"[@#{1}!=\'#{3}\']",\'^=\':"[ct-7n(@#{1}, \'#{3}\')]",\'$=\':"[49(@#{1}, (2B-I(@#{1}) - 2B-I(\'#{3}\') + 1))=\'#{3}\']",\'*=\':"[4j(@#{1}, \'#{3}\')]",\'~=\':"[4j(1v(\' \', @#{1}, \' \'), \' #{3} \')]",\'|=\':"[4j(1v(\'-\', @#{1}, \'-\'), \'-#{3}-\')]"},1t:{\'2h-1i\':\'[31(6H-2Z::*)]\',\'1z-1i\':\'[31(4r-2Z::*)]\',\'4w-1i\':\'[31(6H-2Z::* 6G 4r-2Z::*)]\',\'4b\':"[5t(*) = 0 6I (5t(2r()) = 0 6G cu(2r(), \' \\t\\r\\n\', \'\') = \'\')]",\'3l\':"[@3l]",\'2d\':"[@2d]",\'8K\':"[31(@2d)]",\'31\':o(m){C e=m[6],p=L.5r,x=L.1B,2I,m,v;C a=[];1o(e&&2I!=e&&(/\\S/).2M(e)){2I=e;J(C i 1u p){D(m=e.1f(p[i])){v=1m x[i]==\'o\'?x[i](m):V 22(x[i]).25(m);a.O("("+v.49(1,v.I-1)+")");e=e.1q(m[0],\'\');1y}}}B"[31("+a.1R(" 6I ")+")]"},\'1n-1i\':o(m){B L.1B.1t.1n("(5t(./6H-2Z::*) + 1) ",m)},\'1n-1z-1i\':o(m){B L.1B.1t.1n("(5t(./4r-2Z::*) + 1) ",m)},\'1n-1G-1g\':o(m){B L.1B.1t.1n("1A() ",m)},\'1n-1z-1G-1g\':o(m){B L.1B.1t.1n("(1z() + 1 - 1A()) ",m)},\'2h-1G-1g\':o(m){m[6]="1";B L.1B.1t[\'1n-1G-1g\'](m)},\'1z-1G-1g\':o(m){m[6]="1";B L.1B.1t[\'1n-1z-1G-1g\'](m)},\'4w-1G-1g\':o(m){C p=L.1B.1t;B p[\'2h-1G-1g\'](m)+p[\'1z-1G-1g\'](m)},1n:o(c,m){C d,3o=m[6],6J;D(3o==\'8L\')3o=\'2n+0\';D(3o==\'8M\')3o=\'2n+1\';D(d=3o.1f(/^(\\d+)$/))B\'[\'+c+"= "+d[1]+\']\';D(d=3o.1f(/^(-?\\d*)?n(([+-])(\\d+))?/)){D(d[1]=="-")d[1]=-1;C a=d[1]?3u(d[1]):1;C b=d[2]?3u(d[2]):0;6J="[((#{6K} - #{b}) cv #{a} = 0) 6I "+"((#{6K} - #{b}) 2e #{a} >= 0)]";B V 22(6J).25({6K:c,a:a,b:b})}}}},4d:{1k:\'n = h.1k(n, r, "#{1}", c);   c = 1d;\',2j:\'n = h.2j(n, r, "#{1}", c); c = 1d;\',2O:\'n = h.2O(n, r, "#{1}", c);        c = 1d;\',4t:\'n = h.4t(n, r, "#{1}"); c = 1d;\',4u:o(m){m[3]=(m[5]||m[6]);B V 22(\'n = h.4u(n, r, "#{1}", "#{3}", "#{2}"); c = 1d;\').25(m)},4v:o(m){D(m[6])m[6]=m[6].1q(/"/g,\'\\\\"\');B V 22(\'n = h.4v(n, "#{1}", "#{6}", r, c); c = 1d;\').25(m)},2Y:\'c = "2Y";\',1i:\'c = "1i";\',3R:\'c = "3R";\',4s:\'c = "4s";\'},5r:{4s:V 1W(\'^\\\\s\'+\'*\'+\'~\\\\s*\'),1i:V 1W(\'^\\\\s\'+\'*\'+\'>\\\\s*\'),3R:V 1W(\'^\\\\s\'+\'*\'+\'\\\\+\\\\s*\'),2Y:/^\\s/,1k:V 1W(\'^\\\\s*\'+\'(\\\\\'+\'*|[\\\\w\\\\-]+)(\\\\b|$)?\'),2O:V 1W(\'^#([\\\\w\\\\-\\\\\'+\'*]+)(\\\\b|$)\'),2j:V 1W(\'^\\\\.([\\\\w\\\\-\\\\\'+\'*]+)(\\\\b|$)\'),4v:V 1W(\'^:((2h|1z|1n|1n-1z|4w)(-1i|-1G-1g)|4b|3l|(cw|cx)cy|31)(\\\\((.*?)\\\\))?(\\\\b|$|\\\\s|(?=:))\'),4t:V 1W(\'^\\\\[([\\\\w]+)\\\\]\'),4u:V 1W(\'\\\\[((?:[\\\\w-]*:)?[\\\\w-]+)\\\\s*(?:([!^$*~|]?=)\\\\s*(([\\\'"])([^\\\\]]*?)\\\\4|([^\\\'"][^\\\\]]*?)))?\\\\]\')},1s:{1v:o(a,b){J(C i=0,E;E=b[i];i++)a.O(E);B a},5u:o(a){J(C i=0,E;E=a[i];i++)E.2v=1c;B a},3S:o(a){J(C i=0,E;E=a[i];i++)E.2v=1l;B a},4I:o(a,b,c){a.2v=1c;D(b){J(C d=a.2a,i=d.I-1,j=1;i>=0;i--){E=d[i];D(E.2u==1&&(!c||E.2v))E.5v=j++}}1b{J(C i=0,j=1,d=a.2a;E=d[i];i++)D(E.2u==1&&(!c||E.2v))E.5v=j++}},6F:o(a){D(a.I==0)B a;C b=[],n;J(C i=0,l=a.I;i<l;i++)D(!(n=a[i]).2v){n.2v=1c;b.O(G.M(n))}B L.1s.3S(b)},2Y:o(a){C h=L.1s;J(C i=0,W=[],E;E=a[i];i++)h.1v(W,E.2D(\'*\'));B W},1i:o(a){C h=L.1s;J(C i=0,W=[],E;E=a[i];i++){J(C j=0,cz=[],1i;1i=E.2a[j];j++)D(1i.2u==1&&1i.1k!=\'!\')W.O(1i)}B W},3R:o(a){J(C i=0,W=[],E;E=a[i];i++){C b=7.4n(E);D(b)W.O(b)}B W},4s:o(a){C h=L.1s;J(C i=0,W=[],E;E=a[i];i++)h.1v(W,G.4l(E));B W},4n:o(a){1o(a=a.3G)D(a.2u==1)B a;B 18},4m:o(a){1o(a=a.8d)D(a.2u==1)B a;B 18},1k:o(a,b,c,d){c=c.1X();C e=[],h=L.1s;D(a){D(d){D(d=="2Y"){J(C i=0,E;E=a[i];i++)h.1v(e,E.2D(c));B e}1b a=7[d](a);D(c=="*")B a}J(C i=0,E;E=a[i];i++)D(E.1k.1X()==c)e.O(E);B e}1b B b.2D(c)},2O:o(a,b,c,d){C e=$(c),h=L.1s;D(!a&&b==11)B e?[e]:[];D(a){D(d){D(d==\'1i\'){J(C i=0,E;E=a[i];i++)D(e.1L==E)B[e]}1b D(d==\'2Y\'){J(C i=0,E;E=a[i];i++)D(G.5b(e,E))B[e]}1b D(d==\'3R\'){J(C i=0,E;E=a[i];i++)D(L.1s.4m(e)==E)B[e]}1b a=h[d](a)}J(C i=0,E;E=a[i];i++)D(E==e)B[e];B[]}B(e&&G.5b(e,b))?[e]:[]},2j:o(a,b,c,d){D(a&&d)a=7[d](a);B L.1s.8N(a,b,c)},8N:o(a,b,c){D(!a)a=L.1s.2Y([b]);C d=\' \'+c+\' \';J(C i=0,W=[],E,4x;E=a[i];i++){4x=E.2j;D(4x.I==0)2c;D(4x==c||(\' \'+4x+\' \').1p(d))W.O(E)}B W},4t:o(a,b,c){C d=[];J(C i=0,E;E=a[i];i++)D(G.2H(E,c))d.O(E);B d},4u:o(a,b,c,d,e){D(!a)a=b.2D("*");C f=L.5s[e],W=[];J(C i=0,E;E=a[i];i++){C g=G.6o(E,c);D(g===18)2c;D(f(g,d))W.O(E)}B W},4v:o(a,b,c,d,e){D(a&&e)a=7[e](a);D(!a)a=d.2D("*");B L.1t[b](a,c,d)}},1t:{\'2h-1i\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++){D(L.1s.4m(E))2c;W.O(E)}B W},\'1z-1i\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++){D(L.1s.4n(E))2c;W.O(E)}B W},\'4w-1i\':o(a,b,c){C h=L.1s;J(C i=0,W=[],E;E=a[i];i++)D(!h.4m(E)&&!h.4n(E))W.O(E);B W},\'1n-1i\':o(a,b,c){B L.1t.1n(a,b,c)},\'1n-1z-1i\':o(a,b,c){B L.1t.1n(a,b,c,1c)},\'1n-1G-1g\':o(a,b,c){B L.1t.1n(a,b,c,1d,1c)},\'1n-1z-1G-1g\':o(a,b,c){B L.1t.1n(a,b,c,1c,1c)},\'2h-1G-1g\':o(a,b,c){B L.1t.1n(a,"1",c,1d,1c)},\'1z-1G-1g\':o(a,b,c){B L.1t.1n(a,"1",c,1c,1c)},\'4w-1G-1g\':o(a,b,c){C p=L.1t;B p[\'1z-1G-1g\'](p[\'2h-1G-1g\'](a,b,c),b,c)},8O:o(a,b,d){D(a==0)B b>0?[b]:[];B $R(1,d).2A([],o(c,i){D(0==(i-b)%a&&(i-b)/a>=0)c.O(i);B c})},1n:o(c,d,e,f,g){D(c.I==0)B[];D(d==\'8L\')d=\'2n+0\';D(d==\'8M\')d=\'2n+1\';C h=L.1s,W=[],6L=[],m;h.5u(c);J(C i=0,E;E=c[i];i++){D(!E.1L.2v){h.4I(E.1L,f,g);6L.O(E.1L)}}D(d.1f(/^\\d+$/)){d=3u(d);J(C i=0,E;E=c[i];i++)D(E.5v==d)W.O(E)}1b D(m=d.1f(/^(-?\\d*)?n(([+-])(\\d+))?/)){D(m[1]=="-")m[1]=-1;C a=m[1]?3u(m[1]):1;C b=m[2]?3u(m[2]):0;C k=L.1t.8O(a,b,c.I);J(C i=0,E,l=k.I;E=c[i];i++){J(C j=0;j<l;j++)D(E.5v==k[j])W.O(E)}}h.3S(c);h.3S(6L);B W},\'4b\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++){D(E.1k==\'!\'||(E.3F&&!E.2s.1f(/^\\s*$/)))2c;W.O(E)}B W},\'31\':o(a,b,c){C h=L.1s,cA,m;C d=V L(b).4q(c);h.5u(d);J(C i=0,W=[],E;E=a[i];i++)D(!E.2v)W.O(E);h.3S(d);B W},\'8K\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++)D(!E.2d)W.O(E);B W},\'2d\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++)D(E.2d)W.O(E);B W},\'3l\':o(a,b,c){J(C i=0,W=[],E;E=a[i];i++)D(E.3l)W.O(E);B W}},5s:{\'=\':o(a,v){B a==v},\'!=\':o(a,v){B a!=v},\'^=\':o(a,v){B a.7h(v)},\'$=\':o(a,v){B a.7i(v)},\'*=\':o(a,v){B a.1p(v)},\'~=\':o(a,v){B(\' \'+a+\' \').1p(\' \'+v+\' \')},\'|=\':o(a,v){B(\'-\'+a.1X()+\'-\').1p(\'-\'+v.1X()+\'-\')}},8P:o(a,b){C c=V L(b).4q(),h=L.1s;h.5u(c);J(C i=0,W=[],15;15=a[i];i++)D(15.2v)W.O(15);h.3S(c);B W},3H:o(a,b,c){D(1m b==\'cB\'){c=b;b=1d}B L.8P(a,b||\'*\')[c||0]},6n:o(a,b){C c=b.1R(\',\'),b=[];c.78(/(([\\w#:.~>+()\\s-]+|\\*|\\[.*?\\])+)\\s*(,|$)/,o(m){b.O(m[1].3f())});C d=[],h=L.1s;J(C i=0,l=b.I,6M;i<l;i++){6M=V L(b[i].3f());h.1v(d,6M.4q(a))}B(l>1)?h.6F(d):d}});o $$(){B L.6n(11,$A(17))}C 1a={6N:o(a){$(a).6N();B a},8Q:o(d,e){C f=d.2A({},o(a,b){D(!b.2d&&b.3n){C c=b.3n,1w=$(b).1Y();D(1w!=18){D(c 1u a){D(a[c].3g!=1E)a[c]=[a[c]];a[c].O(1w)}1b a[c]=1w}}B a});B e?f:1F.3h(f)}};1a.19={4y:o(a,b){B 1a.8Q(1a.3T(a),b)},3T:o(c){B $A($(c).2D(\'*\')).2A([],o(a,b){D(1a.G.4z[b.1k.21()])a.O(G.M(b));B a})},cC:o(a,b,c){a=$(a);C d=a.2D(\'5w\');D(!b&&!c)B $A(d).20(G.M);J(C i=0,6O=[],I=d.I;i<I;i++){C e=d[i];D((b&&e.1g!=b)||(c&&e.3n!=c))2c;6O.O(G.M(e))}B 6O},6P:o(a){a=$(a);1a.3T(a).5V(\'6P\');B a},6Q:o(a){a=$(a);1a.3T(a).5V(\'6Q\');B a},8R:o(b){B $(b).3T().7v(o(a){B a.1g!=\'5f\'&&!a.2d&&[\'5w\',\'2g\',\'6R\'].1p(a.1k.21())})},cD:o(a){a=$(a);a.8R().8S();B a},4X:o(a,b){a=$(a),b=N.2o(b||{});C c=b.2C;b.2C=a.4y(1c);D(c){D(1m c==\'2B\')c=c.4L();N.M(b.2C,c)}D(a.2H(\'1K\')&&!b.1K)b.1K=a.1K;B V 1h.3C(a.6o(\'cE\'),b)}};1a.G={6S:o(a){$(a).6S();B a},2g:o(a){$(a).2g();B a}};1a.G.19={4y:o(a){a=$(a);D(!a.2d&&a.3n){C b=a.1Y();D(b!=1l){C c={};c[a.3n]=b;B 1F.3h(c)}}B\'\'},1Y:o(a){a=$(a);C b=a.1k.21();B 1a.G.4z[b](a)},7x:o(a){$(a).1w=\'\';B a},cF:o(a){B $(a).1w!=\'\'},8S:o(a){a=$(a);1P{a.6S();D(a.2g&&(a.1k.21()!=\'5w\'||![\'6T\',\'6N\',\'cG\'].1p(a.1g)))a.2g()}1V(e){}B a},6P:o(a){a=$(a);a.cH();a.2d=1c;B a},6Q:o(a){a=$(a);a.2d=1d;B a}};C cI=1a.G;C $F=1a.G.19.1Y;1a.G.4z={5w:o(a){45(a.1g.21()){1I\'8T\':1I\'8U\':B 1a.G.4z.8V(a);6x:B 1a.G.4z.6R(a)}},8V:o(a){B a.3l?a.1w:18},6R:o(a){B a.1w},2g:o(a){B 7[a.1g==\'2g-cJ\'?\'8W\':\'8X\'](a)},8W:o(a){C b=a.cK;B b>=0?7.6U(a.14[b]):18},8X:o(a){C b,I=a.I;D(!I)B 18;J(C i=0,b=[];i<I;i++){C c=a.14[i];D(c.cL)b.O(7.6U(c))}B b},6U:o(a){B G.M(a).2H(\'1w\')?a.1w:a.2r}};1O.5x=o(){};1O.5x.U={26:o(a,b,c){7.3c=b;7.15=$(a);7.3v=c;7.32=7.1Y();7.3d()},3d:o(){75(7.3e.1J(7),7.3c*5J)},3e:o(){C a=7.1Y();C b=(\'2B\'==1m 7.32&&\'2B\'==1m a?7.32!=a:1S(7.32)!=1S(a));D(b){7.3v(7.15,a);7.32=a}}};1a.G.5y=1C.1D();1a.G.5y.U=N.M(V 1O.5x(),{1Y:o(){B 1a.G.1Y(7.15)}});1a.5y=1C.1D();1a.5y.U=N.M(V 1O.5x(),{1Y:o(){B 1a.4y(7.15)}});1O.3a=o(){};1O.3a.U={26:o(a,b){7.15=$(a);7.3v=b;7.32=7.1Y();D(7.15.1k.21()==\'5E\')7.8Y();1b 7.3d(7.15)},6V:o(){C a=7.1Y();D(7.32!=a){7.3v(7.15,a);7.32=a}},8Y:o(){1a.3T(7.15).1e(7.3d.1J(7))},3d:o(a){D(a.1g){45(a.1g.21()){1I\'8T\':1I\'8U\':1x.3I(a,\'cM\',7.6V.1J(7));1y;6x:1x.3I(a,\'cN\',7.6V.1J(7));1y}}}};1a.G.3a=1C.1D();1a.G.3a.U=N.M(V 1O.3a(),{1Y:o(){B 1a.G.1Y(7.15)}});1a.3a=1C.1D();1a.3a.U=N.M(V 1O.3a(),{1Y:o(){B 1a.4y(7.15)}});D(!1j.1x){C 1x=V N()}N.M(1x,{cO:8,cP:9,cQ:13,cR:27,cS:37,cT:38,cU:39,cV:40,cW:46,cX:36,cY:35,cZ:33,d0:34,15:o(a){B $(a.d1||a.d2)},d3:o(a){B(((a.8Z)&&(a.8Z==1))||((a.6T)&&(a.6T==1)))},d4:o(a){B a.d5||(a.d6+(11.5z.3U||11.1T.3U))},d7:o(a){B a.d8||(a.d9+(11.5z.3V||11.1T.3V))},5K:o(a){D(a.90){a.90();a.da()}1b{a.db=1d;a.dc=1c}},3H:o(a,b){C c=1x.15(a);1o(c.1L&&(!c.1k||(c.1k.1X()!=b.1X())))c=c.1L;B c},2w:1d,91:o(a,b,c,d){D(!7.2w)7.2w=[];D(a.92){7.2w.O([a,b,c,d]);a.92(b,c,d)}1b D(a.3Y){7.2w.O([a,b,c,d]);a.3Y(\'3E\'+b,c)}},93:o(){D(!1x.2w)B;J(C i=0,I=1x.2w.I;i<I;i++){1x.5a.2m(7,1x.2w[i]);1x.2w[i][0]=18}1x.2w=1d},3I:o(a,b,c,d){a=$(a);d=d||1d;D(b==\'94\'&&(12.1Z.3r||a.3Y))b=\'95\';1x.91(a,b,c,d)},5a:o(a,b,c,d){a=$(a);d=d||1d;D(b==\'94\'&&(12.1Z.3r||a.3Y))b=\'95\';D(a.96){a.96(b,c,d)}1b D(a.97){1P{a.97(\'3E\'+b,c)}1V(e){}}}});D(12.1Z.3X)1x.3I(1j,\'dd\',1x.93,1d);C 2G={98:1d,6W:o(){7.99=1j.de||11.5z.3U||11.1T.3U||0;7.9a=1j.df||11.5z.3V||11.1T.3V||0},9b:o(a){C b=0,1N=0;3W{b+=a.3V||0;1N+=a.3U||0;a=a.1L}1o(a);B[1N,b]},4o:o(a){C b=0,1N=0;3W{b+=a.3p||0;1N+=a.3q||0;a=a.2x}1o(a);B[1N,b]},9c:o(a){C b=0,1N=0;3W{b+=a.3p||0;1N+=a.3q||0;a=a.2x;D(a){D(a.1k==\'9d\')1y;C p=G.1M(a,\'1A\');D(p==\'5g\'||p==\'3k\')1y}}1o(a);B[1N,b]},2x:o(a){D(a.2x)B a.2x;D(a==11.1T)B a;1o((a=a.1L)&&a!=11.1T)D(G.1M(a,\'1A\')!=\'6u\')B a;B 11.1T},dg:o(a,x,y){D(7.98)B 7.9e(a,x,y);7.4A=x;7.4B=y;7.24=7.4o(a);B(y>=7.24[1]&&y<7.24[1]+a.3L&&x>=7.24[0]&&x<7.24[0]+a.3K)},9e:o(a,x,y){C b=7.9b(a);7.4A=x+b[0]-7.99;7.4B=y+b[1]-7.9a;7.24=7.4o(a);B(7.4B>=7.24[1]&&7.4B<7.24[1]+a.3L&&7.4A>=7.24[0]&&7.4A<7.24[0]+a.3K)},dh:o(a,b){D(!a)B 0;D(a==\'di\')B((7.24[1]+b.3L)-7.4B)/b.3L;D(a==\'dj\')B((7.24[0]+b.3K)-7.4A)/b.3K},6X:o(a){C b=0,1N=0;C c=a;3W{b+=c.3p||0;1N+=c.3q||0;D(c.2x==11.1T)D(G.1M(c,\'1A\')==\'3k\')1y}1o(c=c.2x);c=a;3W{D(!1j.4C||c.1k==\'9d\'){b-=c.3V||0;1N-=c.3U||0}}1o(c=c.1L);B[1N,b]},2o:o(a,b){C c=N.M({9f:1c,9g:1c,9h:1c,9i:1c,3p:0,3q:0},17[2]||{});a=$(a);C p=2G.6X(a);b=$(b);C d=[0,0];C e=18;D(G.1M(b,\'1A\')==\'3k\'){e=2G.2x(b);d=2G.6X(e)}D(e==11.1T){d[0]-=11.1T.3q;d[1]-=11.1T.3p}D(c.9f)b.Y.2T=(p[0]-d[0]+c.3q)+\'2k\';D(c.9g)b.Y.2S=(p[1]-d[1]+c.3p)+\'2k\';D(c.9h)b.Y.2Q=a.3K+\'2k\';D(c.9i)b.Y.2P=a.3L+\'2k\'},dk:o(a){a=$(a);D(a.Y.1A==\'3k\')B;2G.6W();C b=2G.9c(a);C c=b[1];C d=b[0];C e=a.8i;C f=a.8j;a.9j=d-3J(a.Y.2T||0);a.9k=c-3J(a.Y.2S||0);a.9l=a.Y.2Q;a.9m=a.Y.2P;a.Y.1A=\'3k\';a.Y.2S=c+\'2k\';a.Y.2T=d+\'2k\';a.Y.2Q=e+\'2k\';a.Y.2P=f+\'2k\'},dl:o(a){a=$(a);D(a.Y.1A==\'5g\')B;2G.6W();a.Y.1A=\'5g\';C b=3J(a.Y.2S||0)-(a.9k||0);C c=3J(a.Y.2T||0)-(a.9j||0);a.Y.2S=b+\'2k\';a.Y.2T=c+\'2k\';a.Y.2P=a.9m;a.Y.2Q=a.9l}};D(12.1Z.3r){2G.4o=o(a){C b=0,1N=0;3W{b+=a.3p||0;1N+=a.3q||0;D(a.2x==11.1T)D(G.1M(a,\'1A\')==\'3k\')1y;a=a.2x}1o(a);B[1N,b]}}G.8t();',62,828,'|||||||this|||||||||||||||||function|||||||||||||return|var|if|node||Element||length|for||Selector|extend|Object|push||||||prototype|new|results||style|||document|Prototype||options|element||arguments|null|Methods|Form|else|true|false|each|match|type|Ajax|child|window|tagName|undefined|typeof|nth|while|include|replace|transport|handlers|pseudos|in|concat|value|Event|break|last|position|xpath|Class|create|Array|Hash|of|inspect|case|bind|method|parentNode|getStyle|valueL|Abstract|try|toJSON|join|String|body|Insertion|catch|RegExp|toUpperCase|getValue|Browser|map|toLowerCase|Template|Enumerable|offset|evaluate|initialize||toString|gsub|childNodes|toArray|continue|disabled|div|_each|select|first|key|className|px|matcher|apply||clone|args|stripScripts|text|innerHTML|onComplete|nodeType|_counted|observers|offsetParent|createElement|throw|inject|string|parameters|getElementsByTagName|ByTag|display|Position|hasAttribute|le|emptyFunction|toPaddedString|source|test|success|id|height|width|opacity|top|left|table|tbody|range|expression|descendant|sibling||not|lastValue||||||||EventObserver|BrowserFeatures|frequency|registerCallback|onTimerEvent|strip|constructor|toQueryString|setTimeout|decay|absolute|checked|_cache|name|formula|offsetTop|offsetLeft|WebKit|indexOf|values|Number|callback|timer|slice|evalScripts|split|add|Responders|Request|url|on|firstChild|nextSibling|findElement|observe|parseFloat|offsetWidth|offsetHeight|_overflow|Heading|insertContent|initializeRange|ps|adjacent|unmark|getElements|scrollLeft|scrollTop|do|IE|attachEvent|navigator||userAgent|ElementExtensions|HTMLElement|__proto__|switch||object|nodeValue|substring|_|empty|pluck|criteria|remove|start|responders|post|dispatchException|contains|cache|nextSiblings|previousElementSibling|nextElementSibling|cumulativeOffset|_flag|findElements|following|laterSibling|attrPresence|attr|pseudo|only|nodeClassName|serialize|Serializers|xcomp|ycomp|opera|Gecko|ScriptFragment|shift|times|currentlyExecuting|index|eval|escapeHTML|toQueryParams|camelize|charAt|evalJSON|pattern|reverse|ObjectRange|dispatch|onCreate|Base|setOptions|asynchronous|request|status|json|responseText|container|getElementsByClassName|Simulated|none|recursivelyCollect|_attributeTranslations|names|classNames|ClassNames|stopObserving|descendantOf|cssFloat|auto|setOpacity|hidden|relative|overflow|filter|alpha|TBODY|TR|depth|tr|_getAttr|copy|content|patterns|operators|count|mark|nodeIndex|input|TimedObserver|Observer|documentElement|Version|Opera|XPath|SpecificElementExtensions|form|script|instanceof|ownerDocument|succ|1000|stop|interpret|callee|prepareReplacement|gi|len|capitalize|unfilterJSON|appendChild|slices|array|invoke|falses|_reverse|without|call|Test|end|getTransport|activeRequestCount|application|encoding|Complete|_complete|respondToReadyState|onStateChange|getHeader|Updater|failure|update|updater|elements|_getElementsByXPath|class|findOrStore|visible|removeChild|selectNodeContents|previousSiblings|findChildElements|readAttribute|getDimensions|float|styleFloat|00001|visibility|static|_madePositioned|_getStyle|default|THEAD|TD|TableSection|HTML|adjacency|insertBefore|set|unique|or|preceding|and|predicate|fragment|indexed|selector|reset|matchingInputs|disable|enable|textarea|focus|button|optionValue|onElementEvent|prepare|page|KHTML|JSONFilter|keys|Function|Try|these|PeriodicalExecuter|setInterval|specialChar|sub|scan|stripTags|img|extractScripts|unescapeHTML|decodeURIComponent|charCodeAt|isJSON|JSON|startsWith|endsWith|blank|amp|lt|gt|with|Pattern|template|eachSlice|collect|detect|findAll|size|find|from|clear|flatten|arrayLength|merge|addPair|encodeURIComponent|delete|exclusive|XMLHttpRequest|ActiveXObject|XMLHTTP|register|contentType|Events|get|onreadystatechange|setRequestHeaders|overrideMimeType|readyState|xml|Content|2005|requestHeaders|evalResponse|onException|updateContent|insertion|PeriodicalUpdater|updateComplete|lastText|_extended|toggle|hide|show|outerHTML|createRange|createContextualFragment|attribute|ancestors|descendants|firstDescendant|immediateDescendants|previousSibling|attributes|getAttribute|hasClassName|scrollTo|clientWidth|clientHeight|bottom|right|currentStyle|100|td|readonly|title|getAttributeNode|specified|addMethods|TEXTAREA|findDOMClass|Mod|TableCol|TableCell|insertAdjacentHTML|contentFromAnonymousTable|Before|Top|collapse|Bottom|After|compileMatcher|compileXPathMatcher|root|local|enabled|even|odd|byClassName|getIndices|matchElements|serializeElements|findFirstElement|activate|checkbox|radio|inputSelector|selectOne|selectMany|registerFormCallbacks|which|preventDefault|_observeAndCache|addEventListener|unloadCache|keypress|keydown|removeEventListener|detachEvent|includeScrollOffsets|deltaX|deltaY|realOffset|positionedOffset|BODY|withinIncludingScrolloffsets|setLeft|setTop|setWidth|setHeight|_originalLeft|_originalTop|_originalWidth|_originalHeight|AppleWebKit|secure|RangeError|unknown|boolean|bindAsEventListener|event|toColorPart|isFinite|Date|getFullYear|getMonth|getDate|getHours|getMinutes|getSeconds|clearInterval|finally|truncate|im|data|fromCharCode|underscore|dasherize|x00|x1f|u00|Eaeflnr|SyntaxError|Badly|formed|lastIndexOf|parseQuery|createTextNode|Error|is|deprecated|use|instead|all|any|grep|inGroupsOf|max|min|partition|reject|sortBy|sort|zip|pop|member|entries|NodeList|compact|reduce|uniq|foo|bar|Msxml2|Microsoft|unregister|www|urlencoded|UTF|Uninitialized|Loading|Loaded|Interactive|_method|Konqueror|Safari|open|postBody|send|Requested|With|Accept|javascript|html|charset|Connection|close|setRequestHeader|200|300|Success|Failure|java|ecma|getResponseHeader|clearTimeout|getElementById|XPathResult|ORDERED_NODE_SNAPSHOT_TYPE|snapshotLength|snapshotItem|replaceChild|siblings|up|down|previous|next|getElementsBySelector|getHeight|getWidth|addClassName|removeClassName|toggleClassName|cleanWhitespace|defaultView|getComputedStyle|getOpacity|setStyle|block|makePositioned|undoPositioned|makeClipping|undoClipping|childOf|childElements|999999|colspan|colSpan|rowspan|rowSpan|valign|vAlign|datetime|dateTime|accesskey|accessKey|tabindex|tabIndex|enctype|encType|maxlength|maxLength|readOnly|longdesc|longDesc|cssText|href|src|multiple|FORM|INPUT|SELECT|OPTGROUP|OptGroup|TextArea|Paragraph|FIELDSET|FieldSet|UL|UList|OL|OList|DL|DList|DIR|Directory|H1|H2|H3|H4|H5|H6|Quote|INS|DEL|Anchor|IMG|Image|CAPTION|TableCaption|COL|COLGROUP|TFOOT|TableRow|TH|FRAMESET|FrameSet|IFRAME|IFrame|Toggle|beforeBegin|setStartBefore|afterBegin|beforeEnd|afterEnd|setStartAfter|starts|translate|mod|en|dis|abled|children|selectorType|number|getInputs|focusFirstElement|action|present|submit|blur|Field|one|selectedIndex|selected|click|change|KEY_BACKSPACE|KEY_TAB|KEY_RETURN|KEY_ESC|KEY_LEFT|KEY_UP|KEY_RIGHT|KEY_DOWN|KEY_DELETE|KEY_HOME|KEY_END|KEY_PAGEUP|KEY_PAGEDOWN|target|srcElement|isLeftClick|pointerX|pageX|clientX|pointerY|pageY|clientY|stopPropagation|returnValue|cancelBubble|unload|pageXOffset|pageYOffset|within|overlap|vertical|horizontal|absolutize|relativize'.split('|'),0,{}))

/*common.js*/

/** 
 * @fileoverview This javascript file contains the common functions. 
 * @author Hardik Shah
 * @author Pankit Bhanushali
 * @version 0.1 
 */
var goToMap = false;
var imgThmPath = "../../wt/"+bkTheme+"/images/";
var isIE = document.all?1:0;
var isIE6 = (window.XMLHttpRequest)?0:1;
var usrAgt = navigator.userAgent.toLowerCase();
var isFF = (usrAgt.indexOf('firefox')!=-1)?1:0;
var isOpera = (usrAgt.indexOf('opera')!=-1)?1:0;
var isSafari = ((usrAgt.indexOf('safari')!=-1)&&(usrAgt.indexOf('mac')!=-1))?1:0;
//enables background image cache for internet explorer 6
if (isIE6) try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};
var clientTime = new Date();
var ClientTimezoneOffset = (clientTime.getTimezoneOffset() / 60);
var month = clientTime.getMonth() + 1;
var day = clientTime.getDate();
var year = clientTime.getFullYear();
var hours = clientTime.getHours();
var min = clientTime.getMinutes();
var sec = clientTime.getSeconds();
var localTime = year + "-" + month + "-" + day+" "+hours+ ":" + min+ ":" + sec;

// Global Variables
//var leadEmailDlg1;
var maindivid	= 'middle';
var url			= '';
var queryString	= '';
var lastToggled	;
var sessid	= '';
var YAHOO;
var jsPath = '../../';
var totalImgs;
var latLong = (getCookie("latLongCk")!=null)?(eval(getCookie("latLongCk"))[0]):null;
var isCountySearchEnabled = "0";
//lmsre specific
var lmsreDshbrdBitz= '{"mortgagerates" : "50","mcalc":"24","equity":"57","weather":"19","climate":"19","demographics" : "28","localnews" : "20","marketsnapshot":"46","crimestats":"49","valuehome":"58","afford":"51","localSearch":"39","crimestats":"49"}';
//var leadEmailDlg1;
/*metrospecific*/
var agtOffDlgBox = "";
//----------
/**
 * set new session id
 *
 */
function setSessid()
{
	var queryString  = "PHPSESSID="+sessid;
	var url = jsPath+"../classes/sessionSwitch.php";
	ajaxRequest(url,queryString,setID);
};

function setID(originalRequest)
{
	sessid = originalRequest.responseText;
};
function pageReload(originalRequest)
{
	if(originalRequest==null)originalRequest="";
	window.location.href = window.location.pathname+window.location.search;
};
/**
 * This is the Ajax function that requests the url and loads the HT response to particular Div/container
 * @param {String} url The url called by the Ajax request
 * @param {String} queryString The parameter String passed to the url 
 * @param {String} inDiv The Div/Container in which the response to be set
 * @param {String} callbackfn The callback function name
 */
 
function loadToDiv(url,queryString,inDiv,callbackfn,classNm)
{

	if(classNm==null)
		classNm = false;
		
	inDiv = typeof(inDiv) != 'undefined' ? inDiv : maindivid; 
	if(queryString=='')
	{
		queryString = "PHPSESSID="+sessid;
	}
	else
	{
		queryString = "PHPSESSID="+sessid+"&"+queryString;
	}
	/*
	var callbackfn = function(myAjaxObjext)
	{
		alert(inDiv+" :: "+$(inDiv)+" :: "+$(inDiv).innerHTML);
		alert(myAjaxObjext.responseText);
	}
	*/ 
	if(callbackfn==null)
	{
		var objAjax = new Ajax.Updater({success: inDiv},url, {method: 'post', parameters: queryString, onFailure: showError,onlyLatestOfClass:classNm,evalScripts: true});
	}
	else
	{
		var objAjax = new Ajax.Updater({success: inDiv},url, {method: 'post', parameters: queryString, onFailure: showError,onlyLatestOfClass:classNm,onSuccess: callbackfn, evalScripts: true});
	}
};

/**
 * This is the Ajax function that request the particular url 
 * @param {String} url The url called by the Ajax request
 * @param {String} queryString The parameter String passed to the url 
 * @param {String} callbackfn The callback function name
 * @param {boolean} requestType The type of the request to be made should synchronous or asynchronous(default)
 */
 
function ajaxRequest(url,queryString,callbackfn,requestType,classNm)
{

	if(classNm==null)
		classNm = false;
		
	if(requestType==null)
	{
		requestType=true;
	}

	if(queryString=='')
	{
		queryString = "PHPSESSID="+sessid;
	}
	else
	{
		queryString = "PHPSESSID="+sessid+"&"+queryString;
	}
	if(typeof(callbackfn) == 'undefined')
	{
		var objAjaxReq = new Ajax.Request(url, {method: 'post',asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, evalScripts: true});
	}
	else
	{
		var objAjaxReq = new Ajax.Request(url, {method: 'post',asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, onSuccess: callbackfn, evalScripts: true});
	}
};

/**
 * This is the Ajax function that request the particular url 
 * @param {String} url The url called by the Ajax request
 * @param {String} queryString The parameter String passed to the url 
 * @param {String} callbackfn The callback function name
 * @param {boolean} requestType The type of the request to be made should synchronous or asynchronous(default)
 */
 
function ajaxRequest_methodSelect(url,queryString,callbackfn,requestType,classNm,AjaxMethod)
{
	if(AjaxMethod == '' || AjaxMethod==null || AjaxMethod=='undefined')
	{
		AjaxMethod = 'post';
	}
	
	if(classNm==null)
		classNm = false;
		
	if(requestType==null)
	{
		requestType=true;
	}

	if(queryString=='')
	{
		queryString = "PHPSESSID="+sessid;
	}
	else
	{
		queryString = "PHPSESSID="+sessid+"&"+queryString;
	}
	if(typeof(callbackfn) == 'undefined')
	{
		var objAjaxReq = new Ajax.Request(url, {method: AjaxMethod,asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, evalScripts: true});
	}
	else
	{
		var objAjaxReq = new Ajax.Request(url, {method: AjaxMethod,asynchronous:requestType, parameters: queryString, onlyLatestOfClass:classNm, onFailure: showError, onSuccess: callbackfn, evalScripts: true});
	}
};

/**
 * Display the Error message when the Ajax request fails 
 * @param {String} originalRequest the request object
 */
function showError(originalRequest)
{
	if (originalRequest.status == 999)
	{
		window.location.href = "../auth/sessionExpire.php";
	}
	else
	{
		var response = originalRequest.responseText;
		$(maindivid).innerHTML = response;
		alert(response);
	}
};


/***********************General Section********************/

/**
 * Includes the single javaScript file dynamically
 * @param {String} jsFile the javscript filename
 */

function includeJS(jsFile)
{
	var fileName = jsFile.substr(eval(jsFile.lastIndexOf('/')+1),eval(jsFile.lastIndexOf('\.')-eval(jsFile.lastIndexOf('/')+1)));
	var myScript = $(fileName+"Script");
	if(fileName+"Script" == "mlsSrc.searchPs.template.jsScript")
	{
		myScript = null;
	}	
	if(myScript==null)
	{
		var myScr = document.createElement('script');
		myScr.id= fileName+"Script";
		myScr.src = jsFile;
		document.getElementsByTagName('head')[0].appendChild(myScr);
	}
};
/**
 * Includes the single css file dynamically
 * @param {String} cssFile the css filename
 */

function includeCSS(cssFile)
{
	var fileName = cssFile.substr(eval(cssFile.lastIndexOf('/')+1),eval(cssFile.lastIndexOf('\.')-eval(cssFile.lastIndexOf('/')+1)));
	var myStyle = $(fileName+"Css");
	
	if(myStyle==null)
	{
		var myCss = document.createElement('link');
		myCss.id= fileName+"Css";
		myCss.href = cssFile;
		myCss.rel = "stylesheet";
		myCss.type = "text/css";
		document.getElementsByTagName('head')[0].appendChild(myCss);
	}
};
/**
 * Includes the multiple css files dynamically
 * @param {Array} cssFileArr the array of css filenames
 */
function includeMultiCSS(cssFileArr)
{
	var insrtCssFileArr = $A(cssFileArr);
	insrtCssFileArr.each(function(node) {
		includeCSS(node);
	});
};

/**
 * Function for flipping images on mouse over
 * (Normal images should be with suffix '_n' and hoverimages should be with suffix '_h')
 * @requires changeImgOnHover The changeImgOnHover function
 */

function revealThumbnail()
{
	imgsrc = this.src;
	newimgsrc=(imgsrc.replace("_n","_h"));
	this.src=newimgsrc;
};

/**
 * Function for flipping images on mouse out
 * (Normal images should be with suffix '_n' and hoverimages should be with suffix '_h')
 * @requires changeImgOnHover The changeImgOnHover function
 */	
function hideThumbnail()
{
	imgsrc = this.src;
	newimgsrc=(imgsrc.replace("_h","_n"));
	this.src=newimgsrc;
};
/**
 * Function for Toggle Divs using Effect for showing details
 * @param {id} id current Div id to be opened
 */
var sameFlag = false;
function menuToggle(id)
{
    if (lastToggled == null || $(lastToggled) == null) 
	{
		//Effect.toggle(id,'blind',{duration:0.2});
		lastToggled = id;
		//Element.Toggle(id);
		$(id).style.display = "block";
    }
    else if (lastToggled == id) 
	{     		       
		//Effect.toggle(id,'blind',{duration:0.2});	
		//Element.Toggle(id);
		if(sameFlag==false)
		{
			$(id).style.display = "none";
			sameFlag = true;
		}
		else
		{
			$(id).style.display = "block";
			sameFlag = false;
		}
    }  
    else
	{
	   $(lastToggled).style.display = "none";
       lastToggled = id;
       $(id).style.display = "block";
    }
    
};


/**
 * InPlace Editor function for Textbox
 * @param {TextBox Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorText(elementId,fileToCommunicate,fieldName,tableName,condition,edtBtn,validation,size)
{
	
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mandatory");	
	}
	else
	{
		
		if(validation==null){validation="";}
		
		if(edtBtn==null){edtBtn="";}
		
		if(size==null)
			var inplaceEditorTxt =new Ajax.InPlaceEditor(elementId, fileToCommunicate,{ clickToEditText : "You can Edit this by clicking on it.", callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },validate:validation,externalControl:edtBtn,highlightcolor:'#74AACF'});
		else
			var inplaceEditorTxt =new Ajax.InPlaceEditor(elementId, fileToCommunicate,{ clickToEditText : "You can Edit this by clicking on it.", size:size, callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },validate:validation,externalControl:edtBtn,highlightcolor:'#74AACF'});
	
		return inplaceEditorTxt;
	}
};

/**
 * InPlace Editor function for TextArea
 * @param {TextArea Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorTextArea(elementId,fileToCommunicate,fieldName,tableName,condition,edtBtn)
{
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mandatory");	
	}
	else
	{
		if(Ajax.InPlaceEditor == null)
		{
			alert("Please include Scriptaculous.js from vendor folder for using inplace Editor");
		}
		else
		{
			if(edtBtn==null){edtBtn="";}
			var inplaceEditorTA = new Ajax.InPlaceEditor(elementId, fileToCommunicate, { clickToEditText : "You can Edit this by clicking on it.", callback: function(form, value) { return 'value=' + escape(value)+'&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition) },externalControl:edtBtn,rows:4,cols:60,highlightcolor:'#74AACF'});
			return inplaceEditorTA;
		}
	}
};

/**
 * InPlace Editor function for ComboBox
 * @param {ComboBox Id} elementId The current element ID
 * @param {Button Id}  edtBtn The button id
 * @param {fileToCommunicate} The file that is call on click of edit button
 */
function createInplaceEditorCombo(elementId,fileToCommunicate,optionArray,fieldName,tableName,condition,edtBtn)
{
	if(elementId==null || fileToCommunicate == null || fieldName==null || tableName == null || condition == null)
	{
		alert("Parameters missing: elementId, fileToCommunicate, fieldName, tableName, and condition are mendatory");	
	}
	else
	{
		if(Ajax.InPlaceEditor == null)
		{
			alert("Please include Scriptaculous.js from vendor folder for using inplace Editor");
		}
		else
		{
			var queryString = '&combo=1&fieldName='+escape(fieldName)+'&tableName='+escape(tableName)+'&condition='+escape(condition);
			if(edtBtn==null){edtBtn=""}
			var inplaceEditorTA = new Ajax.InPlaceCollectionEditor (elementId,fileToCommunicate,{collection:optionArray, ajaxOptions: {parameters: queryString },externalControl:edtBtn,highlightcolor:'#74AACF'} );
			return inplaceEditorTA;
		}
	}
};

function StringBuffer() { this.buffer = []; }
StringBuffer.prototype.append = function(string)
{
	this.buffer.push(string);
	return this;
}

StringBuffer.prototype.toString = function()
{
	return this.buffer.join("");
}

// YUI Related Functions 
/**
 * Create the YAHOO Panel dynamically
 * @param {id} elid The div id of the Yahoo Panel
 * @return Panel object
 */
 function setDlgPos(elid)
{
	
	if(elid=="initWithMe")
		return;
	if($(elid))
	{
		var f_cw = f_clientWidth();
		var f_ch = f_clientHeight();
		var el_H = $(elid).getHeight();
		var el_W = $(elid).getWidth();
		$(elid).style.position = "static";
		$(elid).style.top = eval(Math.abs(f_ch/2) - Math.abs(el_H/2))+"px";
		$(elid).style.left = eval(Math.abs(f_cw/2) - Math.abs(el_W/2))+"px";
		var myObj = document.getElementsByClassName('underlay');
		if(myObj != null)
		{
			var myLen = myObj.length;
			for(var i=0;i<myLen;i++)
			{
				myObj[i].removeClassName('underlay');
			}
		}			
	}	
}
function createDialog(elid)
{
	var useShim;
	var ua = navigator.userAgent.toLowerCase();
	if (isIE){
		useShim = true;
	}else{
		useShim = false;
		setDlgPos(elid);
	}
	if(YAHOO==null)
	{
		alert("Please include yahoo.js");
	}
	else
	{			
		dlgBox = new YAHOO.widget.Panel(elid, {modal:true, visible:false, fixedcenter:true, constraintoviewport:true, shim:useShim, draggable:false} );
		dlgBox.render();
		if (!isIE6)
			dlgBox.beforeShowEvent.subscribe(function(){setDlgPos(elid);}, this);					
		return dlgBox;
	}
};

/**
 * Create the YAHOO TabView dynamically
 * @param {id} parentDiv The div id that will contain the Tabs
 * @param {Array} keyValArr the Key:Value paired array of Labels:Urls
 * @param {String} orientation the Tab Orientation ie. left,right,top or bottom
 * @return TabView object
 */
function loadTabs(parentDiv,keyValArr,orientation,noOfTabs)
{
	if(noOfTabs!=null)
	{
		loadTabsDynamically(parentDiv,keyValArr,orientation,noOfTabs);
		return;
	}
	orientation = typeof(orientation) != 'undefined' ? orientation : 'top';

	var hashArrLabels = $A($H(keyValArr).keys());
	var hashArrURLs   = $A($H(keyValArr).values());

    var tabView = new YAHOO.widget.TabView({id: parentDiv , orientation: orientation});
    var activate = false;
	for(i=0;i<hashArrLabels.length;i++)
	{
		if(i==0)
			activate = true;
		else
			activate = false;

		if(hashArrURLs[i]==null || hashArrURLs[i]=="")
		{
			dataSource = hashArrURLs[i];
		}
		else
		{
			if(hashArrURLs[i].search(/\?/)<0)
			{
				dataSource = hashArrURLs[i]+"?PHPSESSID="+sessid;
			}
			else
			{
				dataSource = hashArrURLs[i]+"&PHPSESSID="+sessid;
			}
		}
		tabView.addTab(new YAHOO.widget.Tab({
			label: hashArrLabels[i],
			dataSrc: dataSource,
			active: activate,
			cacheData: false /******************To be kept true in production *************/
	 	 }));
	}
    
    YAHOO.util.Event.onContentReady(parentDiv, function() {
        tabView.appendTo(parentDiv);
    });
    
  	for(i=0;i<$A($H(keyValArr)).length;i++)
	{
		tabView.getTab(i).addListener('contentChange',function (){
				this.get('content').evalScripts();
			});
	}
	return tabView;
};

var start = 1;
function addTabs(tabElem,keyValArr,enableArr)
{
	var hashArrLabels = $A($H(keyValArr).keys());
	var hashArrURLs   = $A($H(keyValArr).values());

	for(i=0;i<hashArrLabels.length;i++)
	{

		tabElem.addTab(new YAHOO.widget.Tab({
			label: hashArrLabels[i],
			dataSrc: hashArrURLs[i],
			active: true,
			disabled : enableArr[i],
			cacheData: false /******************To be kept true in production *************/
	    }));
	}
	var noOfTabs = 0;
	while(tabElem.getTab(noOfTabs))
	{
		noOfTabs = noOfTabs + 1;
	}
	for(i=1;i<noOfTabs;i++)
	{
		tabElem.getTab(i).addListener('contentChange',function (){
					this.get('content').evalScripts();
			});

	}
	return tabElem;
};
/************************************************************************/
/**
* Create Custom Confirm Dialog Box
*/
		var popupMessageBoxForm;
    function popupMessageBox (title, message, icon, buttons,wth,hgt) 
    {
    		if(!wth || wth == null)
    			wth = "300px";
    		if(!hgt || hgt == null)
    			hgt = "100px";
        // our container must exist for this to work				
        if (!YAHOO.util.Dom.inDocument('popupMessageBoxContainer'))
					return;
				
        // create the confirm dialog
        var ybuttons = [];
        for (var i=0; i<buttons.length; i++) 
        {
            ybuttons[i] = { text:buttons[i].label, handler:buttons[i].func, isDefault:(i==0?true:false) };
        }

	    	popupMessageBoxForm = new YAHOO.widget.SimpleDialog("popupMessageBoxContainer1", 
				{
	            modal: true,
	     			  width: wth+"px",
	     			  height:hgt+"px",
	            fixedcenter: true,
	            visible: false,
	            draggable: false,
	            close: true,
	            text: message,
	            icon: icon,
	            constraintoviewport: true,
	            buttons: ybuttons
	           
	      });
		    popupMessageBoxForm.setHeader(title);
		    popupMessageBoxForm.render("popupMessageBoxContainer");     
		    popupMessageBoxForm.show();

    }

    function popupMessageBoxHide() 
    {
        popupMessageBoxForm.hide();
    }

    function YAlert (title, msg, icon,button,wth,hgt) 
    {
        if (icon === undefined) icon = YAHOO.widget.SimpleDialog.ICON_ALARM;
        popupMessageBox (title, msg, icon,[{label:button,func:popupMessageBoxHide}],wth,hgt);        
    }

    function YConfirm (msg, yeshandler,nohandler,button1,button2,wth,hgt) 
    {
        popupMessageBox('Please Confirm...', msg,YAHOO.widget.SimpleDialog.ICON_HELP, [{label:button1,func:function(){popupMessageBoxHide();yeshandler();}},{label:button2,func:function(){popupMessageBoxHide();nohandler();}}],wth,hgt);
    } 
/************************************************************************/    
/** 
 * Function that returns the string in particular Language
 * @param {String} str The string to be converted in the selected language
 * @return String of the language currently set. 
 */

function getText(str) /* Returns Related Language from Language Array String */
{
	//below line, which uses Localisation variable, is commented by pratik as hardik removed line for loading of individual Language.JS file in code clean up
	//if (Localisation[str]) str = Localisation[str];
	return str;
};

/**************************Added Without Comments *******************/
function _alert(str) 
{
	alert(getText(str));
};
function _confirm(str)
{
	return confirm(getText(str));
};

/*************************Added Functions ************************/
/**
 * @author Shah Pratik
 * @date 31/01/2007
 * @param {String | Int} search string or integer
 * @return {boolean} return index of needle if needle is found in array else return false
 */
Array.prototype.in_array = function ( needle ) 
{
	var len = this.length;
	for ( var x = 0 ; x <= len ; x++ ) 
	{
		if ( this[x] == needle ) 
		{
			return x;
		}
	}
	return false;
};

/**
 * Function that sets the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} value of the cookie
 * @param {String} expires expiry time for the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @param {String} secure Secure cookie (SSL)
 */
function setCookie(name, value, expires, path, domain, secure)
{
	//alert(name+" "+value);
	if (name == "msgboxCK" || name == "msgboxCKSignin" || name == "msgboxtutorialcook" || name == "rememberIdPassword" || name == "Cpanel_rememberIdPassword" || name == "pv" || name == "strWidgetCookie")
	{
		if (expires)
		{
			expires = expires.toGMTString();
		}
	}
	else
		expires = null;

  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires : "") +
      ((path) ? "; path=" + path : "; path=/") +
      ((domain) ? "; domain=" + domain : "") +
      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
};

/**
 * Function that gets the cookie value for given name.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @return (String) returns the value for the given cookie name.
 */
function getCookie(name)
{
	var dc = document.cookie;
	var prefix = name + "=";
	var begin = dc.indexOf("; " + prefix);
	if (begin == -1)
	{
		begin = dc.indexOf(prefix);
		if (begin != 0) return null;
	} 
	else
		begin += 2;
	var end = document.cookie.indexOf(";", begin);
	if (end == -1)
		end = dc.length;
	var returnCookie = unescape(dc.substring(begin + prefix.length, end));
	if((returnCookie == null) || (returnCookie == 'null'))
	{
		returnCookie = "";
	}

	return returnCookie;
	
};

/**
 * Function that deletes the cookie.
 * @author Sanjev Dutta
 * @date 31/01/2007
 * @param {String} name of the cookie
 * @param {String} path path
 * @param {String} domain domain
 * @return (void)
 */
function deleteCookie(name, path, domain)
{
	if (getCookie(name))
	{
		document.cookie = name + "=" + ((path) ? "; path=" + path : "path=/") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
};
/********in place editor code******/


/******************************** Thanks To Scriptaculaus****************************/
// script.aculo.us effects.js v1.7.0_beta2, Mon Dec 18 23:38:56 CET 2006

// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
//  Justin Palmer (http://encytemedia.com/)
//  Mark Pilgrim (http://diveintomark.org/)
//  Martin Bialasinki
// 
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/ 

/************************** Ajax Inplace Editor ********************************/	
Ajax.InPlaceEditor = Class.create();
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
Ajax.InPlaceEditor.prototype = {
  initialize: function(element, url, options) {
    this.url = url;
    this.element = $(element);

    this.options = Object.extend({
      paramName: "value",
      okButton: true,
      okText: "save",
      cancelLink: true,
      cancelText: "cancel",
      savingText: "Saving...",
      clickToEditText: "Click to edit",
      rows: 1,
      onComplete: function(transport, element) {
        new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
      },
      onFailure: function(transport) {
        alert("Error communicating with the server: " + transport.responseText.stripTags());
      },
      callback: function(form) {
        return Form.serialize(form);
      },
      handleLineBreaks: true,
      loadingText: 'Loading...',
      savingClassName: 'inplaceeditor-saving',
      loadingClassName: 'inplaceeditor-loading',
      formClassName: 'inplaceeditor-form',
      highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
      highlightendcolor: "#E2E2DF",
      externalControl: null,
      submitOnBlur: false,
      ajaxOptions: {},
      evalScripts: false
    }, options || {});

    if(!this.options.formId && this.element.id) {
      this.options.formId = this.element.id + "-inplaceeditor";
      if ($(this.options.formId)) {
        // there's already a form with that name, don't specify an id
        this.options.formId = null;
      }
    }
    
    if (this.options.externalControl) {
      this.options.externalControl = $(this.options.externalControl);
    }
    
    this.originalBackground = Element.getStyle(this.element, 'background-color');
    if (!this.originalBackground) {
      this.originalBackground = "transparent";
    }
    
    this.element.title = this.options.clickToEditText;
    
    this.onclickListener = this.enterEditMode.bindAsEventListener(this);
    this.mouseoverListener = this.enterHover.bindAsEventListener(this);
    this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
    Event.observe(this.element, 'click', this.onclickListener);
    Event.observe(this.element, 'mouseover', this.mouseoverListener);
    Event.observe(this.element, 'mouseout', this.mouseoutListener);
    if (this.options.externalControl) {
      Event.observe(this.options.externalControl, 'click', this.onclickListener);
      Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
      Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
    }
  },
  enterEditMode: function(evt) {
    if (this.saving) return;
    if (this.editing) return;
    this.editing = true;
    this.onEnterEditMode();
    if (this.options.externalControl) {
      Element.hide(this.options.externalControl);
    }
    Element.hide(this.element);
    this.createForm();
    this.element.parentNode.insertBefore(this.form, this.element);
    // stop the event to avoid a page refresh in Safari
    
    if (evt) {
      Event.stop(evt);
    }
    return false;
  },
  createForm: function() {
    this.form = document.createElement("form");
    this.form.id = this.options.formId;
    var uid = this.options.formId;
	var arrid = uid.split('-');    
    var txtid = arrid[0];
    Element.addClassName(this.form, this.options.formClassName)
    this.form.onsubmit = this.onSubmit.bind(this,txtid);

    this.createEditField();

    if (this.options.textarea) {
      var br = document.createElement("br");
      this.form.appendChild(br);
    }

    if (this.options.okButton) {
      okButton = document.createElement("input");
      okButton.type = "submit";
      okButton.value = this.options.okText;
      okButton.className = 'editor_ok_button';
	  okButton.style.fontSize  = '13px';
	  okButton.style.height ='25px';
	  okButton.style.paddingTop = '7px' ;
	  this.form.appendChild(okButton);
    }
    if (this.options.cancelLink) {
      cancelLink = document.createElement("a");
      cancelLink.href = "#";
      cancelLink.appendChild(document.createTextNode(this.options.cancelText));
      cancelLink.onclick = this.onclickCancel.bind(this);
      cancelLink.style.fontSize  = '13px';
	  cancelLink.style.fontWeight  = 'normal';
	  cancelLink.className = 'editor_cancel';      
	  this.form.appendChild(cancelLink);
    }
  },
  hasHTMLLineBreaks: function(string) {
    if (!this.options.handleLineBreaks) return false;
    return string.match(/<br/i) || string.match(/<p>/i);
  },
  convertHTMLLineBreaks: function(string) {
    return string.replace(/<br>/gi, "\n").replace(/<br\/>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<p>/gi, "");
  },
  createEditField: function() {
    var text;
    if(this.options.loadTextURL) {
      text = this.options.loadingText;
    } else {
    	if(this.getText()=="none")
    	 	text="";
    	else
      		text = this.getText();
    }

    var obj = this;
    
    if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
      this.options.textarea = false;
      var textField = document.createElement("input");
      textField.obj = this;
      textField.type = "text";
      textField.name = this.options.paramName;
      textField.value = text;
      textField.style.backgroundColor = this.options.highlightcolor;
      textField.className = 'editor_field';
      textField.style.backgroundColor = 'white';
      var size = this.options.size || this.options.cols || 0;
      if (size != 0) textField.size = size;
      if (this.options.submitOnBlur)
        textField.onblur = this.onSubmit.bind(this);
      this.editField = textField;
    } else {
      this.options.textarea = true;
      var textArea = document.createElement("textarea");
      textArea.obj = this;
      textArea.name = this.options.paramName;
      textArea.value = this.convertHTMLLineBreaks(text);
      textArea.rows = this.options.rows;
      textArea.cols = this.options.cols || 40;
      textArea.className = 'editor_field_ta';   
      textArea.style.backgroundColor = 'white';   
      if (this.options.submitOnBlur)
        textArea.onblur = this.onSubmit.bind(this);
      this.editField = textArea;
    }
    
    if(this.options.loadTextURL) {
      this.loadExternalText();
    }
    this.form.appendChild(this.editField);
  },
  getText: function() {
    return this.element.innerHTML;
  },
  loadExternalText: function() {
    Element.addClassName(this.form, this.options.loadingClassName);
    this.editField.disabled = true;
    new Ajax.Request(
      this.options.loadTextURL,
      Object.extend({
        asynchronous: true,
        onComplete: this.onLoadedExternalText.bind(this)
      }, this.options.ajaxOptions)
    );
  },
  onLoadedExternalText: function(transport) {
    Element.removeClassName(this.form, this.options.loadingClassName);
    this.editField.disabled = false;
    this.editField.value = transport.responseText.stripTags();
    Field.scrollFreeActivate(this.editField);
  },
  onclickCancel: function() {
  	var erArr = document.getElementsByClassName("errMsg")
	$A(erArr).each(function(node){
			node.innerHTML="&nbsp;";
	});
  	if(this.editField.value=="")
  	{
  		this.editField.value=="none"
  	}
  	if ($('selTag'))
  	{
	  	if($('selTag').options[$('selTag').selectedIndex].value=="A" && $('divOH')!=null)
	  		$('divOH').style.display = "none";
  	}  	
    this.onComplete();
    this.leaveEditMode();
    return false;
  },
  onFailure: function(transport) {
    this.options.onFailure(transport);
    if (this.oldInnerHTML) {
      this.element.innerHTML = this.oldInnerHTML;
      this.oldInnerHTML = null;
    }
    return false;
  },
  onSubmit: function(id,id2) {
	var erArr;
  	if(!this.validate(id))
  	{
  		if(navigator.appName=="Microsoft Internet Explorer")
		  	this.editField.className = "textboxRedIn";
		 else
		 	this.editField.style.border = "1px solid red";
  		
  		erArr = document.getElementsByClassName("errMsg")
  		$A(erArr).each(function(node){
				node.innerHTML=alertErrorMsg;
  		});
  		
  		return false;
  	}
  	else
  	{
  		erArr = document.getElementsByClassName("errMsg")
  		$A(erArr).each(function(node){
				node.innerHTML="&nbsp;";
  		});
	    // onLoading resets these so we need to save them away for the Ajax call
	    var form = this.form;
	    var value = this.editField.value;
	    // do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
	    // which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
	    // to be displayed indefinitely
	    this.onLoading();
	    if (this.options.evalScripts) {
	    	this.options.ajaxOptions.parameters = this.options.callback(form, value);
	      new Ajax.Request(
	        this.url, Object.extend({
	          parameters: this.options.callback(form, value),
	          onComplete: this.onComplete.bind(this),
	          onFailure: this.onFailure.bind(this),
	          asynchronous:true, 
	          evalScripts:true
	        }, this.options.ajaxOptions));
	    } else  {
    	 this.options.ajaxOptions.parameters = this.options.callback(form, value);
	      new Ajax.Updater(
	        { success: this.element,
	          // don't update on failure (this could be an option)
	          failure: null }, 
	        this.url, Object.extend({
	          parameters: this.options.callback(form, value),
	          onComplete: this.onComplete.bind(this),
	          onFailure: this.onFailure.bind(this)
	        }, this.options.ajaxOptions));
	    }
	    // stop the event to avoid a page refresh in Safari
	    if (arguments.length > 1) {
	      Event.stop(arguments[0]);
	    }
	    return false;
  	}
  },
  onLoading: function() {
    this.saving = true;
    this.removeForm();
    this.leaveHover();
    this.showSaving();
  },
  showSaving: function() {
    this.oldInnerHTML = this.element.innerHTML;
    this.element.innerHTML = this.options.savingText;
    Element.addClassName(this.element, this.options.savingClassName);
    this.element.style.backgroundColor = this.originalBackground;
    Element.show(this.element);
  },
  removeForm: function() {
    if(this.form) {
      if (this.form.parentNode) Element.remove(this.form);
      this.form = null;
    }
  },
  enterHover: function() {
    if (this.saving) return;
    this.element.style.backgroundColor = this.options.highlightcolor;
    if (this.effect) {
      this.effect.cancel();
    }
    Element.addClassName(this.element, this.options.hoverClassName)
  },
  leaveHover: function() {
    if (this.options.backgroundColor) {
      this.element.style.backgroundColor = this.oldBackground;
    }
    Element.removeClassName(this.element, this.options.hoverClassName)
    if (this.saving) return;
    this.effect = new Effect.Highlight(this.element, {
      startcolor: this.options.highlightcolor,
      endcolor: this.options.highlightendcolor,
      restorecolor: this.originalBackground
    });
  },
  leaveEditMode: function() {
    Element.removeClassName(this.element, this.options.savingClassName);
    this.removeForm();
    this.leaveHover();
    this.element.style.backgroundColor = this.originalBackground;
    Element.show(this.element);
    if (this.options.externalControl) {
      Element.show(this.options.externalControl);
    }
    this.editing = false;
    this.saving = false;
    this.oldInnerHTML = null;
    this.onLeaveEditMode();
  },
  onComplete: function(transport) {
    this.leaveEditMode();
    this.options.onComplete.bind(this)(transport, this.element);
  },
  onEnterEditMode: function() {},
  onLeaveEditMode: function() {
  		onLeaveEditMd = window.onLeaveEditMd || false;
  	    if(onLeaveEditMd==false)
  	    	return;
  	    else
	    	onLeaveEditMd();
  },
  
  validate:function(id)
  {
	    validArg=this.options.validate;
		if(validArg!="" && typeof(validArg)!="undefined" && validArg!=null)
			id=validArg;
		
		switch(id)
		{
			case "ufname" : 
				return this.editField;
				break; 

			case "umname" : 
				return this.editField;
				break; 

			case "ulname" : 
				return this.editField;
				break; 

			case "name" : 
				return (isBlank(this.editField,"value"))
				break; 
				
			case "uemail":
			case "email":
				return emailIsValid(this.editField);
				break;

			case "ualtemail":
				return chkOnlyEmailIsValid(this.editField);
				break;

			case "uMobile":
			case "cell":
				return (mobileIsValid(this.editField,"Number"));
				break;

			case "uPhone":
			case "phone":
				return (phoneIsValid(this.editField,"Number"));
				break;

			case "uFax":
			case "fax":
				return (faxIsValid(this.editField,"Number"));
				break;
			case "site":
				return isValidURL(this.editField);
				break;
				
			case "uZip":
			case "zip":
				return zipIsValid(this.editField,"msg");
				break;
			
			case "uCity":
				//return isOfLength(this.editField,2);
				return albhabetIsValid(this.editField,"Only alphabets allowed.","City ");
				break;

			case "uState":
			case "state":
				//return isOfLength(this.editField,2);
				return albhabetIsValid(this.editField,"Only alphabets allowed.","State ",2,2);
				break;
			case "year":
				return isYear(this.editField);
				break;
			case "room":
				return (isOfLength(this.editField,3,"max") && numberIsValid(this.editField,"Enter valid Number",""));
				break;
			case "sqft":
				return isSqft(this.editField);
				break;
			default:
				return true;
		}
  	},  
 
  dispose: function() {
    if (this.oldInnerHTML) {
      this.element.innerHTML = this.oldInnerHTML;
    }
    this.leaveEditMode();
    Event.stopObserving(this.element, 'click', this.onclickListener);
    Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
    Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
    if (this.options.externalControl) {
      Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
      Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
      Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
    }
  }
};


/************************** Ajax Inplace Editor Ends ********************************/	
/***************************Ajax Inplace collectin Editor*******************************/

Ajax.InPlaceCollectionEditor = Class.create();
Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
createEditField: function() {
if (!this.cached_selectTag) {
var selectTag = document.createElement("select");
selectTag.id = "selTag";
var collection = this.options.collection || [];
var optionTag;
collection.each(function(e,i) {
optionTag = document.createElement("option");
optionTag.value = (e instanceof Array) ? e[0] : e;
if((typeof this.options.value == 'undefined') &&
((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
if(this.options.value==optionTag.value) optionTag.selected = true;
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
selectTag.appendChild(optionTag);
}.bind(this));
this.cached_selectTag = selectTag;
}
this.editField = this.cached_selectTag;
if(this.options.loadTextURL) this.loadExternalText();
this.form.appendChild(this.editField);

value2 = this.options.ajaxOptions.parameters;
//alert(value2);
this.options.callback = function(form, value) {
	if(value2.indexOf('value=')>=0)
	{
		value2 = value2.substr(value2.indexOf('&'),eval(value2.length-value2.indexOf('&')))
	}
	newVal = "value=" + encodeURIComponent(value)+value2;
//alert(newVal);	
	//this.options.ajaxOptions.parameters = "value=" + encodeURIComponent(value)+value2;
return newVal;
}
}
});


/*******************************Ajax Inplace collectin Editor Ends********************************/
/************************** Basic Effect For Inplace Editor *********************************/
String.prototype.parseColor = function() {  
  var color = '#';
  if(this.slice(0,4) == 'rgb(') {  
    var cols = this.slice(4,this.length-1).split(',');  
    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);  
  } else {  
    if(this.slice(0,1) == '#') {  
      if(this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase();  
      if(this.length==7) color = this.toLowerCase();  
    }  
  }  
  return(color.length==7 ? color : (arguments[0] || this));  
};

/*--------------------------------------------------------------------------*/

Element.collectTextNodes = function(element) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      (node.hasChildNodes() ? Element.collectTextNodes(node) : ''));
  }).flatten().join('');
};

Element.collectTextNodesIgnoreClass = function(element, className) {  
  return $A($(element).childNodes).collect( function(node) {
    return (node.nodeType==3 ? node.nodeValue : 
      ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? 
        Element.collectTextNodesIgnoreClass(node, className) : ''));
  }).flatten().join('');
};

Element.setContentZoom = function(element, percent) {
  element = $(element);  
  element.setStyle({fontSize: (percent/100) + 'em'});   
  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);
  return element;
};

Element.getOpacity = function(element){
  return $(element).getStyle('opacity');
};

Element.setOpacity = function(element, value){
  return $(element).setStyle({opacity:value});
} ; 
 
Element.getInlineOpacity = function(element){  
  return $(element).style.opacity || '';
};

Element.forceRerendering = function(element) {
  try {
    element = $(element);
    var n = document.createTextNode(' ');
    element.appendChild(n);
    element.removeChild(n);
  } catch(e) { }
};

/*--------------------------------------------------------------------------*/

Array.prototype.call = function() {
  var args = arguments;
  this.each(function(f){ f.apply(this, args) });
};

/*--------------------------------------------------------------------------*/

var Effect = {
  _elementDoesNotExistError: {
    name: 'ElementDoesNotExistError',
    message: 'The specified DOM element does not exist, but is required for this effect to operate'
  },
  tagifyText: function(element) {
    if(typeof Builder == 'undefined')
      throw("Effect.tagifyText requires including script.aculo.us' builder.js library");
      
    var tagifyStyle = 'position:relative';
    if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1';
    
    element = $(element);
    $A(element.childNodes).each( function(child) {
      if(child.nodeType==3) {
        child.nodeValue.toArray().each( function(character) {
          element.insertBefore(
            Builder.node('span',{style: tagifyStyle},
              character == ' ' ? String.fromCharCode(160) : character), 
              child);
        });
        Element.remove(child);
      }
    });
  },
  multiple: function(element, effect) {
    var elements;
    if(((typeof element == 'object') || 
        (typeof element == 'function')) && 
       (element.length))
      elements = element;
    else
      elements = $(element).childNodes;
      
    var options = Object.extend({
      speed: 0.1,
      delay: 0.0
    }, arguments[2] || {});
    var masterDelay = options.delay;

    $A(elements).each( function(element, index) {
      new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay }));
    });
  },
  PAIRS: {
    'slide':  ['SlideDown','SlideUp'],
    'blind':  ['BlindDown','BlindUp'],
    'appear': ['Appear','Fade']
  },
  toggle: function(element, effect) {
    element = $(element);
    effect = (effect || 'appear').toLowerCase();
    var options = Object.extend({
      queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
    }, arguments[2] || {});
    Effect[element.visible() ? 
      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
  }
};

/* ------------- core effects ------------- */

Effect.ScopedQueue = Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype, Enumerable), {
  initialize: function() {
    this.effects  = [];
    this.interval = null;
  },
  _each: function(iterator) {
    this.effects._each(iterator);
  },
  add: function(effect) {
    var timestamp = new Date().getTime();
    
    var position = (typeof effect.options.queue == 'string') ? 
      effect.options.queue : effect.options.queue.position;

    switch(position) {
      case 'front':
        // move unstarted effects after this effect  
        this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) {
            e.startOn  += effect.finishOn;
            e.finishOn += effect.finishOn;
          });
        break;
      case 'with-last':
        timestamp = this.effects.pluck('startOn').max() || timestamp;
        break;
      case 'end':
        // start effect after last queued effect has finished
        timestamp = this.effects.pluck('finishOn').max() || timestamp;
        break;
    }
    
    effect.startOn  += timestamp;
    effect.finishOn += timestamp;

    if(!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit))
      this.effects.push(effect);
    if(!this.interval) 
      this.interval = setInterval(this.loop.bind(this), 15);
  },
  remove: function(effect) {
    this.effects = this.effects.reject(function(e) { return e==effect });
    if(this.effects.length == 0) {
      clearInterval(this.interval);
      this.interval = null;
    }
  },
  loop: function() {
    var timePos = new Date().getTime();
    this.effects.invoke('loop', timePos);
  }
});

Effect.Queues = {
  instances: $H(),
  get: function(queueName) {
    if(typeof queueName != 'string') return queueName;
    
    if(!this.instances[queueName])
      this.instances[queueName] = new Effect.ScopedQueue();
      
    return this.instances[queueName];
  }
};
Effect.Queue = Effect.Queues.get('global');

Effect.DefaultOptions = {
  duration:   1.0,   // seconds
  fps:        60.0,  // max. 60fps due to Effect.Queue implementation
  sync:       false, // true for combining
  from:       0.0,
  to:         1.0,
  delay:      0.0,
  queue:      'parallel'
};



Effect.Base = function() {};
Effect.Base.prototype = {
  position: null,
  start: function(options) {
    this.options      = Object.extend(Object.extend({},Effect.DefaultOptions), options || {});
    this.currentFrame = 0;
    this.state        = 'idle';
    this.startOn      = this.options.delay*1000;
    this.finishOn     = this.startOn + (this.options.duration*1000);
    this.event('beforeStart');
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).add(this);
  },
  loop: function(timePos) {
  	  	
    if(timePos >= this.startOn) {
      if(timePos >= this.finishOn) {
        this.render(1.0);
        this.cancel();
        this.event('beforeFinish');
        if(this.finish) this.finish(); 
        this.event('afterFinish');
        return;  
      }
      var pos   = (timePos - this.startOn) / (this.finishOn - this.startOn);
      var frame = Math.round(pos * this.options.fps * this.options.duration);
      if(frame > this.currentFrame) {
        this.render(pos);
        this.currentFrame = frame;
      }
    }
  },
  render: function(pos) {
    if(this.state == 'idle') {
      this.state = 'running';
      this.event('beforeSetup');
      if(this.setup) this.setup();
      this.event('afterSetup');
    }
    if(this.state == 'running') {
      if(this.options.transition) pos = this.options.transition(pos);
      pos *= (this.options.to-this.options.from);
      pos += this.options.from;
      this.position = pos;
      this.event('beforeUpdate');
      if(this.update) this.update(pos);
      this.event('afterUpdate');
    }
  },
  cancel: function() {
    if(!this.options.sync)
      Effect.Queues.get(typeof this.options.queue == 'string' ? 
        'global' : this.options.queue.scope).remove(this);
    this.state = 'finished';
  },
  event: function(eventName) {
    if(this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this);
    if(this.options[eventName]) this.options[eventName](this);
  },
  inspect: function() {
    return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>';
  }
};

/************************** Basic Effect For Inplace Editor Ends *********************************/

Effect.Scale = Class.create();
Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), {
  initialize: function(element, percent) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({
      scaleX: true,
      scaleY: true,
      scaleContent: true,
      scaleFromCenter: false,
      scaleMode: 'box',        // 'box' or 'contents' or {} with provided values
      scaleFrom: 100.0,
      scaleTo:   percent
    }, arguments[2] || {});
    this.start(options);
  },
  setup: function() {
    this.restoreAfterFinish = this.options.restoreAfterFinish || false;
    this.elementPositioning = this.element.getStyle('position');
    
    this.originalStyle = {};
    ['top','left','width','height','fontSize'].each( function(k) {
      this.originalStyle[k] = this.element.style[k];
    }.bind(this));
      
    this.originalTop  = this.element.offsetTop;
    this.originalLeft = this.element.offsetLeft;
    
    var fontSize = this.element.getStyle('font-size') || '100%';
    ['em','px','%','pt'].each( function(fontSizeType) {
      if(fontSize.indexOf(fontSizeType)>0) {
        this.fontSize     = parseFloat(fontSize);
        this.fontSizeType = fontSizeType;
      }
    }.bind(this));
    
    this.factor = (this.options.scaleTo - this.options.scaleFrom)/100;
    
    this.dims = null;
    if(this.options.scaleMode=='box')
      this.dims = [this.element.offsetHeight, this.element.offsetWidth];
    if(/^content/.test(this.options.scaleMode))
      this.dims = [this.element.scrollHeight, this.element.scrollWidth];
    if(!this.dims)
      this.dims = [this.options.scaleMode.originalHeight,
                   this.options.scaleMode.originalWidth];
  },
  update: function(position) {
    var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position);
    if(this.options.scaleContent && this.fontSize)
      this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType });
    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale);
  },
  finish: function(position) {
  	if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle);
  },
  setDimensions: function(height, width) {
    var d = {};
    if(this.options.scaleX) d.width = Math.round(width) + 'px';
    if(this.options.scaleY) d.height = Math.round(height) + 'px';
    if(this.options.scaleFromCenter) {
      var topd  = (height - this.dims[0])/2;
      var leftd = (width  - this.dims[1])/2;
      if(this.elementPositioning == 'absolute') {
        if(this.options.scaleY) d.top = this.originalTop-topd + 'px';
        if(this.options.scaleX) d.left = this.originalLeft-leftd + 'px';
      } else {
        if(this.options.scaleY) d.top = -topd + 'px';
        if(this.options.scaleX) d.left = -leftd + 'px';
      }
    }
    this.element.setStyle(d);
  }
});


Effect.Highlight = Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), {
  initialize: function(element) {
    this.element = $(element);
    if(!this.element) throw(Effect._elementDoesNotExistError);
    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {});
    this.start(options);
  },
  setup: function() {
    // Prevent executing on elements not in the layout flow
    if(this.element.getStyle('display')=='none') { this.cancel(); return; }
    // Disable background image during the effect
    this.oldStyle = {
      backgroundImage: this.element.getStyle('background-image') };
    this.element.setStyle({backgroundImage: 'none'});
    if(!this.options.endcolor)
      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff');
    if(!this.options.restorecolor)
      this.options.restorecolor = this.element.getStyle('background-color');
    // init color calculations
    this._base  = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this));
    this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this));
  },
  update: function(position) {
    this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){
      return m+(Math.round(this._base[i]+(this._delta[i]*position)).toColorPart()); }.bind(this)) });
  },
  finish: function() {
    this.element.setStyle(Object.extend(this.oldStyle, {
      backgroundColor: this.options.restorecolor
    }));
  }
});



Effect.BlindUp = function(element) {
	
  element = $(element);
  element.makeClipping();
  return new Effect.Scale(element, 0,
    Object.extend({ scaleContent: false, 
      scaleX: false, 
      restoreAfterFinish: true,
      afterFinishInternal: function(effect) {
        effect.element.hide().undoClipping();
      } 
    }, arguments[1] || {})
  );
};

Effect.BlindDown = function(element) {
  element = $(element);
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false,
    scaleFrom: 0,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: false,
    afterSetup: function(effect) {
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
      if(effect.element.id=="toggleDiv" && isIE)
      	setTimeout(function(){effect.element.style.display="block";},200);
    },  
    afterFinishInternal: function(effect) {
      effect.element.undoClipping();
    }
  }, arguments[1] || {}));
};


Effect.SlideDown = function(element) {
  element = $(element).cleanWhitespace();
  // SlideDown need to have the content of the element wrapped in a container element with fixed height!
  var oldInnerBottom = element.down().getStyle('bottom');
  var elementDimensions = element.getDimensions();
  return new Effect.Scale(element, 100, Object.extend({ 
    scaleContent: false, 
    scaleX: false, 
    scaleFrom: window.opera ? 0 : 1,
    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width},
    restoreAfterFinish: true,
    afterSetup: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().setStyle({height: '0px'}).show(); 
    },
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' }); 
    },
    afterFinishInternal: function(effect) {
      effect.element.undoClipping().undoPositioned();
      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); }
    }, arguments[1] || {})
  );
};

Effect.SlideUp = function(element) {
  element = $(element).cleanWhitespace();
  var oldInnerBottom = element.down().getStyle('bottom');
  return new Effect.Scale(element, window.opera ? 0 : 1,
   Object.extend({ scaleContent: false, 
    scaleX: false, 
    scaleMode: 'box',
    scaleFrom: 100,
    restoreAfterFinish: true,
    beforeStartInternal: function(effect) {
      effect.element.makePositioned();
      effect.element.down().makePositioned();
      if(window.opera) effect.element.setStyle({top: ''});
      effect.element.makeClipping().show();
    },  
    afterUpdateInternal: function(effect) {
      effect.element.down().setStyle({bottom:
        (effect.dims[0] - effect.element.clientHeight) + 'px' });
    },
    afterFinishInternal: function(effect) {
      effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom});
      effect.element.down().undoPositioned();
    }
   }, arguments[1] || {})
  );
};



/************************************Slide Show Related *****************************************/



	var displayWaitMessage=true;	// Display a please wait message while images are loading?
	var activeImage = false;
	var imageGalleryLeftPos = false;
	var imageGalleryWidth = false;
	var imageGalleryObj = false;
	var maxGalleryXPos = false;
	var slideSpeed = 0;
	var imageGalleryCaptions = new Array();
	function startSlide(e)
	{
		//alert('start slide');
		slideSpeed = 0;
		if(document.all)e = event;
		var id = this.id;
		if(this.getElementsByTagName('IMG')[0].src.indexOf('Over')<0)
			this.getElementsByTagName('IMG')[0].src = this.getElementsByTagName('IMG')[0].src.replace('.gif','Over.gif');
		if(this.id=='arrowRight'){
			slideSpeed = -4;
		}else{
			slideSpeed = 6;
		}
	};
	
	function releaseSlide()
	{
		var id = this.id;
		
		this.getElementsByTagName('IMG')[0].src = this.getElementsByTagName('IMG')[0].src.replace('Over','')			
		slideSpeed=0;
	};
	function fastSlide(event)
	{

		var arrow = Event.element(event).parentNode.id;
		imageGalleryWidth = $('galleryContainer').offsetWidth - 80;
		if(arrow.search('Left') != -1)
		{
			var leftPos = imageGalleryObj.offsetLeft;
				leftPos = leftPos + imageGalleryWidth;
			if(leftPos>maxGalleryXPos)
			{				
				leftPos = maxGalleryXPos;
			}
			if(leftPos<minGalleryXPos)
			{
				leftPos = minGalleryXPos;
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		else
		{
			
			var leftPos = imageGalleryObj.offsetLeft;
				leftPos = leftPos - imageGalleryWidth;
			if(leftPos>maxGalleryXPos)
			{
				leftPos = maxGalleryXPos;
			}
			if(leftPos<minGalleryXPos)
			{
				leftPos = minGalleryXPos;
			}
			imageGalleryObj.style.left = leftPos + 'px';
		}
	}
	function gallerySlide()
	{
		
		if(slideSpeed!=0){
			var leftPos = imageGalleryObj.offsetLeft;
				
			leftPos = eval(leftPos + slideSpeed);
			
			if(leftPos>maxGalleryXPos){
				
				leftPos = maxGalleryXPos;
				slideSpeed = 0;
			}
			if(leftPos<minGalleryXPos){
				leftPos = minGalleryXPos;
				slideSpeed=0;
				//alert("here else");
			}
			
			imageGalleryObj.style.left = leftPos + 'px';
		}
		setTimeout('gallerySlide()',20);
		
	};
	
	function initSlideShow()
	{
		if($('arrowLeft')&& $('arrowRight'))
		{
			
			$('arrowLeft').onmousemove = startSlide;
			$('arrowLeft').onmouseout = releaseSlide;
			$('arrowRight').onmousemove = startSlide;
			$('arrowRight').onmouseout = releaseSlide;
			
			Event.observe($('arrowLeft'), 'click', function(event) {
				fastSlide(event);
			});
			Event.observe($('arrowRight'), 'click', function(event) {
				fastSlide(event);
			});
		}
		totalImgs = $A(document.getElementsByClassName('dashIconsDrag')).length;
		imageGalleryObj = $('theImages');
		imageGalleryLeftPos = imageGalleryObj.offsetLeft;
		imageGalleryWidth = $('galleryContainer').offsetWidth - 80;
		
		maxGalleryXPos = imageGalleryObj.offsetLeft; 
		minGalleryXPos = imageGalleryWidth - $('slideEnd').offsetLeft;		
		
		if(isIE)
		{
		
			var arrAllIcons = $('divIconCollect').getElementsByTagName('img');
			var lenAllIcons = arrAllIcons.length;
			//alert(lenAllIcons);
			var widthImages = 0;
			for(var i =0;i<lenAllIcons;i++)
			{
				var divWidth = $(arrAllIcons[i].id.replace('img','divImg')).style.width.replace('px','');
				divWidth = (isNaN(parseInt(divWidth)))?0:parseInt(divWidth); 
				widthImages = widthImages + divWidth;
			}
					//alert("widthImages : " + widthImages);	
			minGalleryXPos = imageGalleryWidth - widthImages;
			maxGalleryXPos = imageGalleryObj.offsetLeft;
			//minGalleryXPos += 1550;
		}
		
		var slideshowImages = imageGalleryObj.getElementsByTagName('IMG');
		for(var no=0;no<slideshowImages.length;no++){
			slideshowImages[no].onmouseover = revealThumbnail;
			slideshowImages[no].onmouseout = hideThumbnail;
		}
		gallerySlide();
	};
	
/***********************************************End Slide Show*********************************/







function selectAll(parentdiv,all,myObj)
{
	if(all==null)
		all = true;

	if(myObj!=null && myObj.checked)
		all = true;
	else
		all = false;
		
	chkbxArr = $A($(parentdiv).getElementsByTagName("input"));
	chkbxArr.each(
		function(node)
		{
			if(node.type=="checkbox")
				node.checked=all;
		});
};

/******************Number To Money Format******************/
function num2money(n_value,prefix,elementId,dec,retval)
{
	
	dec = (dec)?dec:false;
	retval = (retval)?true:false;
	oNval = n_value.toString();
	if(typeof(n_value) == "string")
	{
		n_value = money2num(n_value);
	}
	if(n_value=="")
	{
		if(elementId!=null)
		{
			if($(elementId).type == "text")
			{
				if(retval)
				{
					$(elementId).value = "";
				}
				else
				{
					$(elementId).value = prefix+"0";
				}
			}
		else
			$(elementId).innerHTML = prefix+"0";
		}
		return;
	}
	var pre = (!prefix)?"$":prefix;
	
	if (isNaN(Number(n_value)))
	return 'ERROR';

	var b_negative = Boolean(n_value < 0);
	n_value = Math.abs(n_value);
	
	// round to 1/100 precision, add ending zeroes if needed
	if(dec && dec>2)
	{
		dec = parseInt(oNval.substr(oNval.indexOf('.')).length-1);
		divd = parseInt(eval('1e'+dec));
		var roundPt = (Math.round(n_value*divd)%divd>9)?(Math.round(n_value*divd)%divd):('0'+Math.round(n_value*divd)%divd);
	}
	else
		var roundPt = (Math.round(n_value*1e2)%1e2>9)?(Math.round(n_value*1e2)%1e2):('0'+Math.round(n_value*1e2)%1e2);
	var s_result = String(roundPt + '00').substring(0,dec);
	// separate all orders
	var b_first = true;
	var s_subresult;
	while (n_value >= 1) 
	{
		s_subresult = (n_value >= 1e3 ? '00' : '') + Math.floor(n_value%1e3);
		s_result = s_subresult.slice(-3) + (b_first ? '.' : ',') + s_result;
		b_first = false;
		n_value = n_value/1e3;
	}
	
	// add at least one integer digit
	if (b_first)
	s_result = '0.' + s_result;

	// apply formatting and return
	if(!dec)
	{
		s_result = s_result.substring(0,s_result.indexOf("."));
	}
	if(elementId!=null)
	{
		if($(elementId).type == "text")
			$(elementId).value = b_negative ? '-'+pre + s_result + '' : pre + s_result;
		else
			$(elementId).innerHTML = b_negative ? '-'+pre + s_result + '' : pre + s_result;
	}
	
	return b_negative
	? '-'+pre + s_result + ''
	: pre + s_result;
};
/******************* String To number************/

function money2num(strMoney) 
{
	var strArr = strMoney.toArray();
	var newnum = "";
	strArr.each(function(i) {
		if(i=="-"||i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0"||i==".")
		{
			newnum += i;
		}
	});
	newnum = parseFloat(newnum);
	if(!isNaN(newnum))
		return(newnum);
	else
		return "";
};
function numTotal(strMoney)
{
	var strArr = strMoney.toArray();
	var newnum = "";
	strArr.each(function(i) {
		if(i=="1"||i=="2"||i=="3"||i=="4"||i=="5"||i=="6"||i=="7"||i=="8"||i=="9"||i=="0")
		{
			newnum += i;
		}
	});
	newnum = parseFloat(newnum);
	if(!isNaN(newnum))
		return(newnum);
	else
		return "";
}
/**
 * Function For Changing inplace Edit Link
 */
function trim(str)
{ 
	if((str == null) || ( str != null && str.length == 0))
		return "";
	else if (typeof(str) != "string")
		return "";

	return(str.replace(/^\s+|\s+$/g, ''));
};


if(typeof(tabType) == 'undefined' || tabType != 'dashboard')
{
	//This function is commented by Saloni to solve c21award dashboard tab
	Array.prototype.find = function(searchStr, from, strict) 
	{
		 if(from == undefined || from >= this.length) from = 0;
		   strict = strict == undefined ? false : strict;

		  var returnArray = false;
		  for (i=from; i<this.length; i++) 
		{
			if (typeof(searchStr) == 'function') 
			{
			  if (searchStr.test(this[i]))
				{
					if (!returnArray)
						{ returnArray = [] }
					returnArray.push(i);
				}
			} 
			else
			{
				if(strict)
				{
						if (this[i]===searchStr) 
						{
								if (!returnArray) 
									{ returnArray = [] }
								returnArray.push(i);
						}
				}
				else
				{
					if (this[i]==searchStr) 
					{
						if (!returnArray) 
							{ returnArray = [] }
						returnArray.push(i);
					}
				 }
			}
			
		  }
		  return returnArray;
	};
}
/*
a = ["0",1,2,3,4,5,'',7,"0",1,"1",1,"1",1]
	result1 = a.find ("1"); // return 1,9,10,11,12,13
	result2 = a.find ("1",3);//return 9,10,11,12,13
	result3 = a.find ("1",3,true);//return 10,12
	*/
	
function toggleSlider()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	Element.toggle('toggleDiv');
	if($('after')&&$('before'))
    {
		Element.toggle('after');
		Element.toggle('before');	
    }
    var menuDivArr = document.getElementsByClassName("widgetMenuDiv");
	$A(menuDivArr).each(function(node){
		$(node).style.display = "none";
		oldidMenu = null;
	});
	if($("tabArrow") && $("tabArrow").className.include("_up"))
	{
		$("tabArrow").className ="dashboard_tab_arrow_down";
		document.getElementsByClassName("tabCss").each(function(node){
			node.className = "tabCssCl";
		});
		if($("divSuperParent"))
			$("divSuperParent").addClassName("divSuperParentCl");
	}
	else if($("tabArrow") && $("tabArrow").className.include("_down"))
	{
		$("tabArrow").className ="dashboard_tab_arrow_up";
		document.getElementsByClassName("tabCssCl").each(function(node){
			node.className = "tabCss";
		});
		if($("divSuperParent"))
			$("divSuperParent").removeClassName("divSuperParentCl");
	}
};


function chooseChecked(parentDiv,chkd)
{
	var selectedArr = new Array();
	var selectArr = new Array();
	if($(parentDiv)==null)
	{
		return false;
	}
	parentDiv = $(parentDiv);
	chkbxArr = $A(parentDiv.getElementsByTagName("input"));
	var i=0;
	var j = 0;
	chkbxArr.each(
		function(node)
		{
			if(node.type=="checkbox" && node.id!="sel")
			{
				selectedArr[i]=node.value;
				if(chkd!=null && node.checked)
				{
					selectArr[j] = node.value;
					j++;
				}
				i++;
			}
		});
		if(chkd!=null)
			return selectArr;
		else
			return selectedArr;	
};
function getPositionLeft(element)
{
     var el = $(element);
	 var pL = 0;
     while(el)
     {
           pL += el.offsetLeft;
           el = el.offsetParent;
     }
     return pL;
};
// To find the top position, add this snippet to your code:
function getPositionTop(element)
{
     var el = $(element);var pT = 0;
     while(el)
     {
        pT += el.offsetTop;
        el = el.offsetParent;
     }
     return pT;
};
function showTooltip(tipStr,evnt,xpos)
{
	var e = evnt;
	var xpos = (xpos==null || xpos == "undefined")?50:xpos;
	var element = Event.element(e);
	var leftpos = e.clientX-xpos;
	var toppos = getPositionTop(element)+20;
	if(tipStr!=null || tipStr!="")
	{
		toppos = getPositionTop(element)+5;
		if($("titleInner"))
			$("titleInner").innerHTML = tipStr;
	}
	else
	{
		if($("titleInner"))
			$("titleInner").innerHTML = $("titleInner").title;
	}
	if($("titleDiv"))
	{
		$("titleDiv").style.width = "50px";
		$("titleDiv").style.left = leftpos+"px";
		$("titleDiv").style.top = eval(toppos+50)+"px";
		$("titleDiv").style.display = "inline";
	}
};
function hideTooltip()
{
	if($("titleDiv"))
	{
		$("titleDiv").style.display = "none";
		$("titleDiv").style.left = "0px";
		$("titleDiv").style.top = "0px";
	}
};


function getGeoAdd(lat,lng,city,state,zip,page,action,otherArgs)
{
	//alert(page);
		//alert("4"+zip);
		var myState = '';
		if(state.indexOf('|')>-1)
		{
			var arrState = state.split('|');
			myState = arrState[0];	
		}
		
		if(city.indexOf('|')>-1)
		{
			var arrCity = city.split('|');
			city = arrCity[0];	
		}
		
		var geoCodeResp = function(geoResponse)//response function for ajax call from getGeoAdd
		{
			var geoArr = eval('('+geoResponse.responseText+')');
			var geoStatus = geoArr[0].status;
			if(geoStatus!=0)
			{
				var geoCity = "";
				var geoState = "";
				var geoZip = "";
				//alert(lat+","+lng+","+city+","+state+","+zip+","+page+","+action);
				//alert('Sorry, We couldn\'t find a location for "' + geoArr[0].originaladdress + '"');
				switch(action)
				{
					case 'start':
						//alert('startNo');
						getGeoAdd(lat,lng,city,state,zip,page,'zip');
					break;
					case 'zip':
						//alert('zipNo');
						getGeoAdd(lat,lng,city,state,zip,page,'end');
					break;
				}
				return;
			}
			else
			{
				//alert('bye');
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoAddress = geoArr[0].address;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				if(geoCity=="" && geoZip=="")
				{
					alert('Please specify City or Zip');
					return;
				}
				else if((geoLat == "0" && geoLong == "0") || (geoLat == 0 && geoLong == 0))
				{
					//alert('else if');
					switch(action)
					{
						case 'start':
							//alert('startNo');
							getGeoAdd(lat,lng,city,state,zip,page,'zip');
						break;
						case 'zip':
							//alert('zipNo');
							getGeoAdd(lat,lng,city,state,zip,page,'end');
						break;
					}
					return;	
				}
				
				if(geoState == "")
					geoState = state;
				setSearchCookie("searchAddress",geoAddress);
				/*setSearchCookie("city",geoCity);
				setSearchCookie("state",geoState);
				setSearchCookie("zip",geoZip);*/
				//var cszFromCookie = setCSZValue (getSearchCookie("city"), state, getSearchCookie("zip"));
				/*if($("searchCSZ") && page != "ListMyHome")
					$("searchCSZ").value = cszFromCookie;*/
				
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var latLongStr = "[{'lat':'"+geoLat+"','lng':'"+geoLong+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
			}
			
			setSearchCookie("city",listAllCity);
			setSearchCookie("state",state);
			
			if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				if(isZip)
				{	
					if(geoZip == "")
						geoZip = zip;
				}
				else
					geoZip = '';
				//alert(state);
				//return;
				if(mapit=="mapitAddr")
				{
					var geoAddress = geoArr[0].address;
					if(listAllCity != false)
					{
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong;
					}
					else
					 	url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong;
					 //url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
				}
				else if(mapit=="mapit")
				{						
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1)
						 {
							url = "Search/"+state+"/"+geoCity;
							 if(zip != "")
								url += "/"+geoZip;
							//url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						 }
						else
						 {
							url = "Search/"+state+"/"+geoCity;
							 if(zip != "")
								url += "/"+geoZip;
							//url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						 }
					 }
					 else
					{
						 url = "Search/"+state+"/"+geoCity;
						 if(zip != "")
							url += "/"+geoZip;
					 	//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
					}
				}
				else if(mapit=="multicity")
				{
					setSearchCookie("city",listAllCity);
					setSearchCookie("state",state);
					//cszFromCookie = setCSZValue (getSearchCookie("city"), myState);
					
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
					 }
					 else
					 	url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+state+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
				}
				//alert(url);
				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				return;
			}
			else if(page.include("LMSRE"))
			{
				var address="";
				//alert(geoArr);
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				if(geoState == "")
					geoState = state;
				
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				if(Exclusiveflag==1)
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames=exclusivelisting";
				else
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+geoLat+","+geoLong+"&widgetnames=mlsCountySearch";

				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				return;			
			}	
		}
		
		if(lat != "0" || lng != "0")
		{
			//alert(lat+","+lng)
			if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2];
				var url;

				var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				if(!isZip)
					zip = '';
				
				setSearchCookie("city",listAllCity);
				setSearchCookie("state",state);
				//var	cszFromCookie = setCSZValue (getSearchCookie("city"), state);
				if(mapit=="mapitAddr")
				{
					var geoAddress;
					
					
					if($("txtAddress"))
						geoAddress = $("txtAddress").value;
					else
						geoAddress="";
						
					if(listAllCity != false)
					{
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+lat+","+lng;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+zip+",,,,"+lat+","+lng;
					}
					else
						url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+city+","+state+","+zip+",,,,"+lat+","+lng;
				
				}
				else if(mapit=="mapit")
				{					
					removeSearchCookie("city");
					removeSearchCookie("state");
					 //alert("2"+ zip+" , "+isZip);					
					 url = "Search/"+state+"/"+city;
	    			 if(zip != "")
						url += "/"+zip;
					 /*if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
					 }
					 else
					 	//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";*/
				}
				else if(mapit=="multicity")
				{
					 if(listAllCity != false)
					 {
						var tempArr = listAllCity.split('|');
						//alert(tempArr.length);
						if(tempArr.length != 1) 
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
					 }
					 else
					 	url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
				}
				//if(otherArgs!= null)
				//	url = url + otherArgs;
				location.href = url;
			}
			else if(page.include("LMSRE"))
			{
				var address="";
				var url;
//				alert("LMSRE : "+lat+","+lng);
				if(Exclusiveflag==1)
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=exclusivelisting";
				else
					url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=mlsCountySearch";
				
				setSearchCookie("city",listAllCity);
				setSearchCookie("state",state);
				var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				if(otherArgs!= null)
					url = url + otherArgs;
				location.href = url;
				//return;			
			}	
		}
		else
		{
			//alert('else');
			var geoAddress;
			var geoUrl = "/classes/getCSZ.php";
			
			if($("txtAddress"))
				geoAddress = $("txtAddress").value;
			else
				geoAddress="";
			
			var geoQueryString;
			switch(action)
			{
				case 'start':
					geoQueryString = "csz="+city+","+myState+"&address="+geoAddress;	
					//alert('start');
					ajaxRequest(geoUrl,geoQueryString,geoCodeResp);
				break;
				case 'zip':
					geoQueryString = "csz="+city+","+myState+","+zip+"&address="+geoAddress;	
					//alert('zip');
					ajaxRequest(geoUrl,geoQueryString,geoCodeResp);
				break;
				case 'end':
					//alert('Ends');
					if(page.include("METRO"))
					{
						var strFromWhere = page.split("|");
						var mapit=strFromWhere[1];
						var widgetName =strFromWhere[2];
						var url;
						if(!isZip)
							zip = '';
						if(mapit=="mapitAddr")
						{
							var geoAddress;
							if($("txtAddress"))
								geoAddress = $("txtAddress").value;
							else
								geoAddress="";
								
							 if(listAllCity != false)
							 {
								var tempArr = listAllCity.split('|');
								//alert(tempArr.length);
								if(tempArr.length != 1) 
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+",,,,,"+lat+","+lng;
								else
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+listAllCity+","+state+","+zip+",,,,"+lat+","+lng;
							 }
							 else
								 url = "app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address="+geoAddress+","+city+","+state+","+zip+",,,,"+lat+","+lng;
						}
						else if(mapit=="mapit")
						{
							 //alert("3"+ zip+" , "+isZip);
							 if(listAllCity != false)
							 {
								var tempArr = listAllCity.split('|');
								//alert(tempArr.length);
								if(tempArr.length != 1)
								{
									//alert('e');
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames="+widgetName;
								}
								else
								{
									//alert('d');
									url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address=,"+listAllCity+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;
								}
							 }
							 else
							 url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+city+","+state+","+zip+",,,,"+lat+","+lng+"&widgetnames="+widgetName;//+",jbfeaturedlistings";
						}
						if(otherArgs!= null)
							url = url + otherArgs;
						location.href = url;
					}
					else if(page.include("LMSRE"))
					{
						var address="";
						if(Exclusiveflag==1)
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=exclusivelisting";
						else
							url ="../../../app/listing/singlePropertyLanding.php?status=EXP&address="+address+","+listAllCity+","+state+",,,,,"+lat+","+lng+"&widgetnames=mlsCountySearch";
						//alert(url);
						if(otherArgs!= null)
							url = url + otherArgs;
						location.href = url;
					}
				break;
			}
			//var geoQueryString = "csz="+city+","+state+","+zip+"&address="+geoAddress;
		}
}


function getGeocodeAddress(csz,page)
{
		var geoCbFn = function(geoResponse)
		{
			var geoArr = eval('('+geoResponse.responseText+')');
			var geoStatus = geoArr[0].status;
			if(geoStatus!=0)
			{
				var geoCity = "";
				var geoState = "";
				var geoZip = "";
				alert('Sorry, We couldn\'t find a location for "' + geoArr[0].originaladdress + '"');
				if (page=="ValueMyHome")
				{
					$('btnSearchEstimateAddress').style.display = "";
					$('statusMsg').style.display = "none";
				}
				
				return;
			}
			else
			{

				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoAddress = geoArr[0].address;
				if(geoCity=="" && geoZip=="")
				{
					alert('Please specify City or Zip');
					return;
				}
				if($("searchCity"))
					$("searchCity").value = geoCity;
				if($("searchState"))
					$("searchState").value = geoState;
				if($("searchZip"))
					$("searchZip").value = geoZip;
				if($("searchAddress")  && page != "ListMyHome")
					$("searchAddress").value = geoAddress;
					
				
				setSearchCookie("searchAddress",geoAddress);
				setSearchCookie("city",geoCity);
				setSearchCookie("state",geoState);
				setSearchCookie("zip",geoZip);
				setSearchCookie("county","");
				
				var cszFromCookie = setCSZValue (getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
				if($("searchCSZ") && page != "ListMyHome")
					$("searchCSZ").value = cszFromCookie;
				
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var latLongStr = "[{'lat':'"+geoLat+"','lng':'"+geoLong+"'}]";
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
				
				
			}
			//alert(page);
			if(page != "campaign" && page != "landing" && page != "ListMyHome" && page != "snapShot" && page != "VOH" && page != "BST" && page != "FAH" && page != "FAO" && page != "VH" && !(page.include("LMSRE")) && page != "LMSRE_SmartWin" && page != "METRO_AssOff" &&!(page.include("METRO")))
			{
				if(trim($('searchAddress').value) == "")$('searchAddress').value = "optional";	

				if(document.cookie=="")
					pageReload();
			}
			if(page=="dashboard")
			{
				funQckUpdateWidgets();		
			}
			else if(page=="singleProp")
			{
				funExploreOnMapit();//alert("Please add your function call for MapIt in common.js");
			}
			else if(page=="landing")
			{
				window.location.href = './app/dashboard/dashboardIndex.php';
			}
			else if(page == "dashboardbitz")
			{
				window.location.href = '../../app/dashboard/dashboardIndex.php?setDsh=1';
			}
			else if(page=="campaign")
			{

				lat = latLong.lat;
				lng = latLong.lng;

				if (geoArr[0].city !="")
					var geoCityStr = geoArr[0].city;
				if (geoArr[0].state !="")
					geoCityStr += ", "+geoArr[0].state;
				if (geoArr[0].zip !="")
					geoCityStr += ", "+geoArr[0].zip;
				//return geoCityStr;
				if(trim(geoCityStr)=="") 
					alert("Please refine your search criteria");
				else
					sendDashboard(geoCity,geoState,geoZip,lat,lng);
			}
			else if(page=="ValueMyHome")
			{
				var url = "../feed/homeEstimate.php?pid=&address="+geoAddress+","+geoCity+","+geoState+","+geoZip;
				window.open(url,"_blank");
				$('btnSearchEstimateAddress').style.display = "";
				$('statusMsg').style.display = "none";
			}
			
			else if(page=="ExploreNeighborhood")
			{
				
				var url = './dshbrdExplore.php';
				var qryStr = 'geoAddress=1&exploreAddress='+geoAddress+'&exploreCity='+geoCity+'&exploreState='+geoState+'&exploreZip='+geoZip;
				ajaxRequest(url,qryStr,function(respObj)
				{
					if (respObj.responseText=="0")
					{
						alert("Sorry, Not Able To Resolve Address");
						$('btnSearchExplore').style.display = "";
						$('expStatusMsg').style.display = "none";
					}
					else
					{
						var url = respObj.responseText;
						window.open(url,"_blank");
						$('btnSearchExplore').style.display = "";
						$('expStatusMsg').style.display = "none";
					}
				});
			}
			
			else if(page=="ListMyHome")
			{
				$('btnGetBids').style.display = "none";
				$('statusMsgListHome').style.display = "";

				var url = './dshbrdLMH.php';
				var qryStr = 'validateAddress=1&address='+geoAddress+'&city='+geoCity+'&state='+geoState+'&zip='+geoZip+'&expt='+exptdSales+'&name='+names+'&email='+email+'&timel='+timeLine;
				var divid = $('listHome').id;
				loadToDiv(url,qryStr,divid);			
			}
			else if(page=="snapShot")
			{
				getListingSnapshots();
			}
			else if(page=="FAH")
			{
				var url = "app/dashboard/dashboardIndex.php";
				location.href = url;
			}
			else if(page=="BST")
			{
				var url = "app/dashboard/dashboardIndex.php";
				location.href = url;
			}
			else if(page=="VOH")
			{
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong;
				location.href = url;
			}
			else if (page=="VH")
			{
				var csz = geoCity+","+geoState+","+geoZip;
				var url = "app/feed/homeEstimate.php?pid=&address="+escape(geoAddress)+","+escape(csz);
				location.href = url; 				
			}
			else if(page=="FAO")
			{
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong;
				location.href = url;
			}
			else if(page=="METRO_AssOff")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames=brokeragents,brokeroffices";
				location.href = url;
			}
			else if(page=="METRO_AssAgtOff")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var qs = "";
				var wdNm = "brokeragents";
				var isOthSet = false;
				if(isBlank('txtFname','First Name'))
				{
					qs += "&fname="+$F('txtFname');
					isOthSet= true;
				}
				
				if(isBlank('txtLname','Last Name'))
				{
					qs += "&lname="+$F('txtLname');
					isOthSet= true;
				}
				
				if(isBlank('txtCityName','City'))
				{
					qs += "&cityName="+escape($F('txtCityName'));
					wdNm = wdNm + ",officeLocation";
					isOthSet= true;
				}
				
				if($F('txtOffice') != "")
				{
					//qs += "&office="+escape($F('txtOffice'));
					qs += "&office="+escape($("txtOffice").options[$("txtOffice").selectedIndex].value);
					wdNm = wdNm + ",brokeroffices";
					isOthSet= true;
				}
				
				if($F('txtOfficeLoc') != "")
				{
					//qs += "&office="+escape($F('txtOffice'));
					qs += "&officeLoc="+escape($("txtOfficeLoc").options[$("txtOfficeLoc").selectedIndex].value);
					//alert($F('txtOfficeLoc'));return;
					/*if(isOthSet)
						wdNm = wdNm + ",officeLocation";
					else
						wdNm = "officeLocation";*//*old*/
					
					if(!wdNm.include("officeLocation"))
						wdNm = wdNm + ",officeLocation";/*new*/	
				}				
				var showDialog="";
				if(wdNm != "officeLocation")
					showDialog = "&showAgentDialog=some";
				else
					showDialog = "&showAgentDialog=";
				var url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+wdNm+showDialog+qs;
				
				//var url = "./app/listing/singlePropertyLanding.php?status=EXP&address=,denver,CO,,,,,39.755092,-104.988123&widgetnames=brokeragents,brokeroffices&showAgentDialog=1";
				//alert(url);
				location.href = url;
			}
			else if(page=="LMSRE_SmartWin")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				sendAddressFldsToLMSRE(geoCity,geoState,geoLat,geoLong);
			}
			else if(page.include("LMSRE"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				var url;
				var moreWidgets="";
				moreWidgets = getCookie("strMapitCK");
				if(widgetName=="terabitzMap")
				{
					url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames=";
				}
				else if(mapit=="mapit")
				{
					var ps = "";
					if(typeof(powerSearch) != 'undefined' && powerSearch == '1' && (uRole == 'EA' || uRole == 'A'))
						var ps = "&ps=1";

					if(moreWidgets == "" || moreWidgets == null)
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+ps;
					}
					else
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+","+moreWidgets+ps;
					}
					if(uid != "")
						setCookie("strMapitCK","");
				}
				else if(mapit=="fromMapIt")
				{
					if(moreWidgets == "" || moreWidgets == null)
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName;
					}
					else
					{
						url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+","+moreWidgets;
					}
				}
				else if(mapit=="dashboard")
				{
					//url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					url = "/app/dashboard/dashboardIndex.php";
				}
				else if(mapit=="dashboardindex")
				{
					eval("var hashDshbrdBitz="+lmsreDshbrdBitz); 
					if(eval("hashDshbrdBitz['"+widgetName+"']")!=null)
	 				{	
	 					hashVal = eval("hashDshbrdBitz['"+widgetName+"']");
	 					url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=:::"+hashVal+",1,2&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
 					}
	 			}
				location.href = url;
			}
			else if(page.include("METRO"))
			{
				var strFromWhere = page.split("|");
				var mapit=strFromWhere[1];
				var widgetName =strFromWhere[2]; 
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				if(geoState!="CO")
				{
					alert("Sorry, we do not support any other state then CO.");
					return;
				}
				var url;
				var extra = "";
				if(widgetName == "exclusivecol")
				{
					extra = "&mapZoomLevel=9";
					var now = new Date();
					now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
					setCookie("mapSearchSelect","1",now);
				}

				if(mapit=="mapitAddr")
				{
					var geoAddress = geoArr[0].address;
					 widgetName = 'mlsaddrsearch';
					 url = "app/listing/singlePropertyLanding.php?status=EXP&address="+geoAddress+","+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+extra;
				}
				else if(mapit=="mapit")
				{
					//alert(3);
					var dist = "";
					var distStr = "";
					if($("distanceChk").checked)
					{
						dist = $F("distance");
						distStr = "&mapZoomLevel=" + dist;//"&distance="+dist;
					}

					if(widgetName == "exclusivecol")
					{
						distStr = "&mapZoomLevel=9";
					}

					//url = "app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+distStr;//+",jbfeaturedlistings";
					url = "Search/"+geoState+"/"+geoCity;
					if(geoZip != "")
						url += "/"+geoZip;
					
					removeSearchCookie("city");
					removeSearchCookie("state");
				}
				else if(mapit=="fromMapIt")
				{
					url = "/app/listing/singlePropertyLanding.php?status=EXP&address=,"+geoCity+","+geoState+","+geoZip+",,,,"+geoLat+","+geoLong+"&widgetnames="+widgetName+extra;
				}
				else if(mapit=="dashboard")
				{
					url = "/app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
				}
				else if(mapit=="dashboardindex")
				{
					if(widgetName=="demographics")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=28,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					if(widgetName=="climate")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=searchAddress=:::city="+geoCity+":::state="+geoState+":::county=:::neighborhood=:::minPrice=:::maxPrice=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::zip=&id=19,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
					if(widgetName=="mortgage rates")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=city="+geoCity+":::state="+geoState+":::county=:::minsqft=:::maxsqft=:::minSize=:::maxSize=:::searchType=:::searchAddress=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=:::zip=&id=50,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;;
					if(widgetName=="mcalc")
						url = "app/dashboard/dashboardIndex.php?loadnow=1&code=city="+geoCity+":::state="+geoState+":::county=:::minsqft=:::maxsqft=:::minSize=:::maxSize=:::searchType=:::searchAddress=:::searchSortType=ph:::ckLFDate=:::ckLTDate=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=:::zip=&id=24,1,1:::&fe=&f=1&propLatitude="+geoLat+"&propLongitude="+geoLong;
				}
				location.href = url;
			}
			else if(page == "METRO_GOTLL")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoZip = geoArr[0].zip;
				sendAddressForLatLong(geoCity,geoState,geoZip);
			}
			else if(page=="METRO_SmartWin")
			{
				var geoCity = geoArr[0].city;
				var geoState = geoArr[0].state;
				var geoLat = geoArr[0].latitude;
				var geoLong = geoArr[0].longitude;
				sendAddressFldsToMETRO(geoCity,geoState,geoLat,geoLong);
			}
			else
			{
				submitSearchForm();
			}
		}
		
		if (page == 'ValueMyHome')
		{
			var geoAddress = $("valueHomeAddress").value;
		}
		else if (page == 'ExploreNeighborhood')
		{
			var geoAddress = $("exploreAddress").value;
		}
		else if (page == 'ListMyHome')
		{
			var geoAddress = $("listHomeAddress").value;
			var exptdSales = $("expectedSale").value;
			var names = $("listHomeName").value;
			var email = $("listHomeEmail").value;						
			var timeLine = $("timeLine").value;									
		}
		else if (page == 'landing')
		{
			if ($('searchAddress').value == "optional")
			{
				var geoAddress = "";
			}
			else
			{
				var geoAddress = $("searchAddress").value;
			}

			if  ($('searchCSZ').value == "required")
			{
				alert ('Please enter a location.');
				return;
			}
		}
		else if(page == 'campaign')
		{
			var geoAddress ="";
		}
		else if(page == "FAH" || page == "BST" || page == "VOH" || page == "VH" || page == "FAO")
		{
			if ($('searchAddress').value == "optional")
			{
				var geoAddress = "";
			}
			else
			{
				var geoAddress = $("searchAddress").value;
			}
		}
		else if(page.include("LMSRE") || page=="LMSRE_SmartWin" || page.include("METRO") || page=="METRO_SmartWin" || page == 'Metro')
		{
			var geoAddress; 
			if($("txtAddress"))
				geoAddress = $("txtAddress").value;
			else
				geoAddress="";
		}
		else
		{
			var geoAddress = $("searchAddress").value;
		}
		
	
		var geoUrl = "/classes/getCSZ.php";
		var geoQueryString = "csz="+csz+"&address="+geoAddress;
		if (page == 'METRO')
		{
			ajaxRequest(geoUrl,geoQueryString,geoCbFn,false);
		}
		else
		{
			ajaxRequest(geoUrl,geoQueryString,geoCbFn);
		}

}


//--------------------------- Search Funtions -----------------------------//

function isNumeric(strValue)
{
	var objRegExp  = /(^-?\d\d*$)/;
	return objRegExp.test(strValue);
};

function submitSearchForm()
{
	if (($F('searchCity') == "") && ($F('searchZip') == ""))
	{
		alert ("Atleast one of 'City' or 'Zip' is requied");
		return false;
	}

	if(!zipValid('searchZip'))
	{
		alert("Zip is invalid");
		return false;
	}
	if(!numberIsValid('yearFrom',"Please enter valid year value","Year From",null,null))
	{
		alert ("Please enter valid year value");
		return false;
	}
	else
	{
		 if($('yearFrom').value!="" && $('yearFrom').value!=" ")
		 {
			 if($('yearFrom').value.length < 4)
			 {
				alert ("Year From should be 4 charcters long.");
				return false;
			 }
		}
	}
	
	if(!numberIsValid('yearTo',"Please enter valid year value","Year To",null,null))
	{
		alert ("Please enter valid year value");
		return false;
	}
	else
	{
		if($('yearTo').value!="" && $('yearTo').value!=" ")
		{
			 if($('yearTo').value.length < 4)
			 {
				alert ("Year To should be 4 charcters long.");
				return false;
			 }
		}
	}
	var contextArray = new Array("onSale","openHouse","newHomes","allHomes");
	var searchAddress = $F('searchAddress');
	if($('srchPopInDiv'))
		Element.toggle('srchPopInDiv');

	var saleable = "3";
	var userContext = "allHomes";
	var queryString = "address=" + escape(searchAddress);
		queryString = queryString + "&city=" + escape(trim($F("searchCity")));
		queryString = queryString + "&state=" + escape(trim($F("searchState")));
		queryString = queryString + "&zip=" + escape(trim($F("searchZip")));
		queryString = queryString + "&minprice=" + escape(money2num($F("minPrice")));
		queryString = queryString + "&maxprice=" + escape(money2num($F("maxPrice")));
		queryString = queryString + "&minsqft=" + escape($F("minSize"));
		queryString = queryString + "&maxsqft=" + escape($F("maxSize"));
		queryString = queryString + "&beds=" + escape($F("searchBeds"));
		queryString = queryString + "&baths=" + escape($F("searchBaths"));
		queryString = queryString + "&searchType=" + escape($F("searchType"));
		queryString = queryString + "&saleable=" + escape(saleable);
		queryString = queryString + "&usercontext=" + escape(userContext);
		setCookie("checkedType",saleable,now);
		
	//-------------------setting client side cookies--------------------//
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	setAllToCookie();
	url = "../listing/checkRecords.php";
	if ($('signInDiv')) Element.toggle('signInDiv');
	if ($('srchDiv')) Element.toggle('srchDiv');
	ajaxRequest(url,queryString,evalResponce);	
};

function evalResponce(originalRequest)
{
	var recCount = parseInt(originalRequest.responseText);
	if (recCount < 0)
	{
		if ($('srchDiv')) Element.toggle('srchDiv');
		if ($('signInDiv')) Element.toggle('signInDiv');
		alert("Sorry cannot connect to server");
	}	
	else if (recCount == 0)
	{
		if ($('srchDiv')) Element.toggle('srchDiv');
		if ($('signInDiv')) Element.toggle('signInDiv');
		alert("Sorry no records found");
		if($('srchPopInDiv'))
			Element.toggle('srchPopInDiv');
	}	
	else
	{
		window.location.href = "../listing/searchResult.php?PHPSESSID="+sessid;
	}
};

//--------------------------- Search Funtions -----------------------------//
function contactUs(type)
{
	alert ("For technical issues, please contact us at support@terabitz.com"+'\n'+"Broker-Agents contact us at brokeragentsupport@terabitz.com"+'\n'+"For all other inquiries, please contact us at info@terabitz.com");
}
/*********************************************************************************
 * Getting window size and scroll bars position in JavaScript/DHTML
 * http://www.softcomplex.com/docs/get_window_size_and_scrollbar_position.html
 * author : Hi Pratik!
 * Date	: 15th May 2007
 * 
 ********************************************************************************** 
 */

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function Querystring(qs) { 
	this.qs = qs;
	this.params = new Object();
	this.get=Querystring_get;
	this.set = Querystring_set;
	if (this.qs == null)
		this.qs=location.search.substring(1,location.search.length)

	if (this.qs.length == 0) return

	this.qs = this.qs.replace(/\+/g, ' ')
	var args = this.qs.split('&') // parse out name/value pairs separated via &
	
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0]);
        if(i==0)
		{
			name = name.substr(eval(name.indexOf('?')+1),name.length);
		}
		if (pair.length == 2)
			value = unescape(pair[1]);
		else
			value = name;
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) 
{
	if (default_ == null) default_ = null;
	
	var value=this.params[key];
	if (value==null) value=default_;
	return value;
}
function Querystring_set(key,value)
{
	if(key == null)
		return;
	if(value == null)
		value = "";	
	this.params[key] = unescape(value);
	var paramKeys = Object.keys(this.params);
	var myQS = "";
	for(var i=0;i<paramKeys.length;i++)
	{
		myQS = myQS + "&" + paramKeys[i] + "=" + escape(this.params[paramKeys[i]]);
	}
	myQS = myQS.substr(1,myQS.length);
	this.qs = myQS;
}
Element.addMethods({
  hasAttributeValue: function(element, attrName, attrVal, separator) {
    element = $(element);
    attrName = trim(attrName);
    separator = (separator)?(separator):" ";
    var attr = element.readAttribute(attrName);
    if(attr==null || attr =="")
    	return false;
    attrVal = trim(attrVal);
    if(attr!="" || trim(attr)!="")
    {
    	attr = attr.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
    	var attrArr = attr.split(separator);
    	var retVal = attrArr.find(attrVal);
    	if(retVal===false)
    		return false;
    	else
    		return true;
    }
    return false;
  }
});
  
document.getElementsByAttributeVal = function(attrName,attrVal, parentElement) {
  if (Prototype.BrowserFeatures.XPath) {
    var q = ".//*[contains(concat(' ', @"+ attrName +", ' '), ' " + attrVal + " ')]";
    return document._getElementsByXPath(q, parentElement);
  } else {
    var children = ($(parentElement) || document.body).getElementsByTagName('*');
    var elements = [], child;
    for (var i = 0, length = children.length; i < length; i++) {
      child = children[i];
      if ($(child).hasAttributeValue(attrName, attrVal))
      {
        elements.push(Element.extend(child));
      }
    }
    return elements;
  }
};
//("groupid","3","galleryContainer")
var lastArrow = false;
function searchAddressFormat(event,defaultText)
{
	if(typeof(event)!="string")
	{
		var element = Event.element(event);
			if(event.type=="blur")
	{
		var srchVal = element.value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
		if(srchVal == '')
		{
			element.value=defaultText;
			element.className = element.className.gsub("N","");
		}
		else
		{
			element.value=srchVal;
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}
	if(event.type=="focus")
	{
		if(element.value==defaultText)
		{
			element.value='';
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}
		
	}
	else
	{
		var element = $(event);
		var srchVal = element.value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
		if(srchVal == '')
		{
			element.value=defaultText;
			element.className = element.className.gsub("N","");
		}
		else
		{
			element.value=srchVal;
			if(element.className.indexOf("N")==-1)
				element.className = String(element.className+"N");
		}
	}	
}
function findBitFormat()
{
	if(trim($("findBitTxt").value) == "")
	{
		$("findBitTxt").value = "Find Bit";
		$("findBitTxt").className = "textboxstyle";
	}
	else if(trim($("findBitTxt").value) == "Find Bit")
	{
		$("findBitTxt").value = "";
		$("findBitTxt").className = "textboxstyleN";
	}
	else
	{
		$("findBitTxt").className = "textboxstyleN";
		findBit();
	}
}
var arrLoadedTabs = new Array();
function showWidgetGrp(gid)
{
	if(gid==null || typeof(gid)=='undefined')
		return;
	if($("toggleDiv").style.display=="none")
	{
		toggleSlider();
	}
	
	$A(document.getElementsByClassName("dashIconsDrag","galleryContainer")).each(Element.hide);
	if(gid=="All")
	{
		var gidArr = document.getElementsByClassName("dashIconsDrag","galleryContainer");
		gidArr.each(function(nd)
		{
			$(nd).style.display = "inline";
		});
		$('theImages').style.left = 25 + 'px';
		if($("arrowLeft"))
		{
			$("arrowLeft").show();
			$("arrowRight").show();
			$("arrowLeftDis").hide();
			$("arrowRightDis").hide();
		}
		initSlideShow();
		return;
	}
	gid = gid.toString();
	var gidArr = document.getElementsByAttributeVal("groupid",gid,"galleryContainer");
	var len = gidArr.length;
	for(var i=0;i<len;i++)
	{
		if((arrLoadedTabs.in_array(gid) === false) && ($(gidArr[i]) != null))
		{
			var divImgId = $(gidArr[i]).id;
			var widgetName = divImgId.gsub('divImg_','');
			var imgId =  'img_'+widgetName;
			$(imgId).src = $(imgId).src.gsub('spacer.gif',eval('widgetsData.'+widgetName+'.img_n'));
		}	
		if($(gidArr[i]))
			$(gidArr[i]).style.display = "inline";
	}
	if(arrLoadedTabs.in_array(gid) === false)
		arrLoadedTabs[arrLoadedTabs.length] = parseInt(gid);
	
	if(len>=9)
	{
		lastArrow = true;
		if($("arrowLeft"))
		{
			$("arrowLeft").show();
			$("arrowRight").show();
			$("arrowLeftDis").hide();
			$("arrowRightDis").hide();
		}
	}
	else
	{
		lastArrow = false;
		if($("arrowLeft"))
		{
			$("arrowLeft").hide();
			$("arrowRight").hide();
			$("arrowLeftDis").style.display = "inline";
			$("arrowRightDis").style.display = "inline";
		}
	}
	$('theImages').style.left = 25 + 'px';
	if(!isIE)
		initSlideShow();
}

function findHash(myObjFind,key)
{
	var h  = $H(myObjFind);
	var arrKeys = h.keys().sort();
	
	key = trim(key).toLowerCase();
	var keyLen = key.length;
	
	var arrRes = Array();
	for(var i=0;i<arrKeys.length;i++)
	{
		//if(key==((arrKeys[i].toLowerCase().substring(0,keyLen)).toLowerCase()))
		if((arrKeys[i].toLowerCase()).include(key))
			arrRes.push(h[arrKeys[i]]);
	}
	return arrRes;
}
function findBit()
{
	var gidArr = document.getElementsByClassName("dashIconsDrag","galleryContainer");
	var key=$("findBitTxt").value;
	if(trim(key)!="")
	{
		gidArr.each(function(nd)
		{
			$(nd).style.display = "none";
		});
		var findArr = findHash(myObjFind[0],key);
		$A(findArr).each(
			function(node)
			{
				if($("divImg_"+node) && node!="mapit")
					$("divImg_"+node).show();
			}
		);
	}
	else
	{
		gidArr.each(function(nd)
		{
			if(nd!="divImg_mapit")
				$(nd).style.display = "inline";
		});
	}
}

function changeTabCls(type,event)
{
	var gidArr = document.getElementsByClassName("tabTdCls",event);
	if(type=="over")
	{
		gidArr.each(function(nd)
		{
			if(!(nd.className.include("_blue_h")))
				nd.className = nd.className.gsub("_blue_n","_blue_h");
		});
	}
	else if(type=="out")
	{
		gidArr.each(function(nd)
		{
			if((nd.className.include("_blue_h")))
				nd.className = nd.className.gsub("_blue_h","_blue_n");
		});
	}
	else
	{
		var gidArrAll = document.getElementsByClassName("tabTdCls","grpDiv");
		gidArrAll.each(function(nd)
		{
			if((nd.className.include("_blue_cl")))
			{
				nd.className = nd.className.gsub("_blue_cl","_blue_n");
			}
		});
		gidArr.each(function(nd)
		{
			if(!(nd.className.include("_blue_cl")))
			{
				nd.className = nd.className.gsub("_blue_h","_blue_cl");
				nd.className = nd.className.gsub("_blue_n","_blue_cl");
			}
		});
	}
	
}

function trimToRect(w, h, str, strApp, strClass, bTrimToWords, bAlwaysAppend,id)
{
	h=parseInt(h);
	str=str.replace(/<=>/g,"'");
	str=str.replace(/<==>/g,'"');
// element with id "ruler" must exist in the document, e.g.:
// <div id=ruler style="position:absolute; left:-5000px;"><!-- --></div>
	elR = document.getElementById(id);
	elR.className = strClass;
	elR.style.width = w;
	
	if(bAlwaysAppend)
		strResult = str + strApp;
	else
		strResult = str;

	// fits already? opt out early
	elR.innerHTML = strResult;
	if(elR.clientHeight <= h)
		return strResult;

	with(Math) position = nextOffset = pow(2,floor(log(str.length) / LN2));

	do
	{
		nextOffset = nextOffset / 2;
		elR.innerHTML = str.substr(0, position) + strApp;
		position = position + (elR.clientHeight > h? -nextOffset:nextOffset);
	} while(nextOffset!= 1);

	elR.innerHTML = str.substr(0, position) + strApp;
	if(elR.clientHeight > h)
		position--;

	if(bTrimToWords)
		while(str.substr(--position, 1)!= " ");

	return str.substr(0, position) + strApp;
}

function highlightMapTypeBtn(maparg)
{
	if (maparg)
		mapType = maparg.getCurrentMapType().getName(true);
	if(mapType=="Map")
	{
		document.getElementById("btnMap").className="mapTypeButtonSelect";
		document.getElementById("btnSat").className="mapTypeButton";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButton";
	}
	else if(mapType=="Sat")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButtonSelect";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButton";
	}
/*	else if(mapType=="Hyb")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButton";
		document.getElementById("btnHyb").className="mapTypeButtonSelect";
		document.getElementById("btnTer").className="mapTypeButton";
	}
*/
	else if(mapType=="Ter")
	{
		document.getElementById("btnMap").className="mapTypeButton";
		document.getElementById("btnSat").className="mapTypeButton";
//		document.getElementById("btnHyb").className="mapTypeButton";
		document.getElementById("btnTer").className="mapTypeButtonSelect";
	};
}
//Funtions for getting the all the MapIT bits that are currently loaded on the dashboard

function getMapItBitsLoadedOnDashboard(expURL,uid)
{
	if (typeof(uid) != "undefined")
	{
		var url = "/app/dashboard/dshbrdProcess.php";
		var qryStr = "fetchdata=1";
		ajaxRequest(url,qryStr,function(objRequest){

			var response = trim(objRequest.responseText);
			if(response == '{}')
			{
				return;
			}
			else
			{
				var responseArr = eval(response);
				widgetNames = '';
				for(var i=0;i<responseArr.length;i++)
				{
					var rowNo = responseArr[i].rowNo;
					var colNo = responseArr[i].colNo;
					var widgetName = responseArr[i].widgetName;
					var divChildId = "divChild"+rowNo+"X"+colNo; 
					widgetNames = widgetNames + widgetName + ',';	
				}
				widgetNames = widgetNames.substr(0, widgetNames.length - 1);
				window.open(expURL+"&widgetnames=" + widgetNames,"_self");
			}
		});
	}
	else
	{
		widgetNames = '';
		for (var i=1 ; i<=3 ; i++)
		{
			for (var j=1 ; j<=3 ; j++)
			{
				if(getCookie("widget"+i+"X"+j))
				{
					var widgetName;
					widgetName = getCookie("widget"+i+"X"+j).split(':::')[0];
					if (widgetName != "undefined")
					{
						widgetNames = widgetNames + widgetName + ',';
					}
				}
				
			}
		}		
		widgetNames = widgetNames.substr(0, widgetNames.length - 1);
		window.open(expURL+"&widgetnames=" + widgetNames,"_self");
	}
}

function getMapItBits(objRequest,expURL)
{
	var MapitBitzName = trim(objRequest.responseText);
	MapitBitzName = MapitBitzName.substr(0, MapitBitzName.length - 1);
	window.open(expURL+"&widgetnames=" + MapitBitzName,"_self");
}

var timeDiff  =  {
    setStartTime:function (){
        d = new Date();
        time  = d.getTime();
    },

    getDiff:function (){
        d = new Date();
        return (d.getTime()-time);
    }
}
var bitzTabPrev="";
var bitzTabNew="";
function changeTabImg(newTabVal)
{
	if(bitzTabNew!="")
	{
		bitzTabPrev = bitzTabNew;
		bitzTabNew = newTabVal;
	}
	else
	{
		var dgidArrAll = document.getElementsByClassName("tabSelected","tabDiv");
		dgidArrAll.each(function(nd)
		{
		   bitzTabPrev = nd.id;
		});
		bitzTabNew = newTabVal;
	}
	$(bitzTabPrev).className = "tabs";	
	$(bitzTabNew).className = "tabSelected";
	/*
		var dgidArrAll = document.getElementsByClassName("tabSelected");
		dgidArrAll.each(function(nd)
		{
				$(nd.id).className = "tabs";
			
		});
		var gidArrAll = document.getElementsByClassName("tabs");
		gidArrAll.each(function(nd)
		{
			if((nd.id==event))
			{
				$(nd.id).className = "tabSelected";
			}
		});
	*/ 
}
function funMakeChatWindow(userType,toChatType)
{
	if(typeof(flagB)!=='undefined' && flagB)
		document.getElementById('tooltipMainB').style.display = 'none';
	if(typeof(flag)!=='undefined' && flag)
		document.getElementById('tooltipMain').style.display = 'none';
	initResizePanel("widgetPanel");
	$('widgetPanel_h').style.display='none';
	if(typeof(initResizePanel)!='undefined')
	{
		/*if(userType=="C")
		{
			$('msgerDiv').style.display="none";
			$('loginDiv').style.display="none";
			$('registerDiv').style.display="block";
		}
		else*/ if(userType=="SP")
		{
			location.href = "../../app/ajaxim/support.php";
		}
		else
		{
			pingTimer = setInterval(ping, pingFrequency);
			$('msgerDiv').style.display="block";
			/*$('loginDiv').style.display="none";
			$('registerDiv').style.display="none";*/
		}
	}
	else
	{
		alert("include Chat Window");
	}
		
}

// function for view a singleproperty landing page from the index page on go button, buyers and renters click
function callMapIt(callValue)
 {
	 if (callValue == "openhouse")
	 {
		if ($("houseCSZ") && ($("houseCSZ").value == "" || $F("houseCSZ").toLowerCase() == "required"))
		{
			alert ("Please enter a location.");
			return;
		}
	 }
	 else
	 {
 		if ( $("searchCSZ") && ($("searchCSZ").value == "" || $F("searchCSZ").toLowerCase() == "required"))
		{
			alert ("Please enter a location.");
			return;
		}
	 }

	if( $("searchCSZ") && (checkMultiCity() && (bkTheme == 'jonathan' || bkTheme == 'century21ah' || bkTheme == 'patrick') ) )
	{
		if (callValue == 'lSearch') {
			alert ('Please select single city location for Local Search.');
			return;
		}
		else if (callValue == 'rSearch') {
			alert ('Please select single city location for Recent Sales.');
			return;
		}
	}

	var strSearchCookie = getCookie("strSearchCookie");
	var latLong = eval(getCookie("latLongCk"))[0];
	var latitude = latLong.lat;
	var	longitude = latLong.lng;
	var addressVar = '';
	var cityVar = '';
	var stateVar = '';
	var zipVar = '';
	var priceVar = '';
	var bedVar = '';
	var bathVar = '';

	searchQueryString = 'status=EXP&address=';

	if(getSearchCookie("searchAddress") && getSearchCookie("searchAddress") != "")
		addressVar = escape(getSearchCookie("searchAddress").replace(/[,]/g, " "));

	if(getSearchCookie("city") && getSearchCookie("city") != "")
		cityVar = escape(getSearchCookie("city").replace(/[,]/g, " "))

	if(getSearchCookie("state") && getSearchCookie("state") != "")
		stateVar = escape(getSearchCookie("state").replace(/[,]/g, " "));

	if(getSearchCookie("zip") && getSearchCookie("zip") != "")
		zipVar = escape(getSearchCookie("zip").replace(/[,]/g, " "));

	searchQueryString = searchQueryString + addressVar + "," + cityVar + "," + stateVar + "," + zipVar + "," + priceVar + "," + bedVar + "," + bathVar+ "," + latitude+ "," + longitude;

	if (addressVar!="optional" && addressVar!="" && (!callValue) )
	{
		widgetNames = "mlsaddrsearch";
	}
	else
	{
		if(bkTheme == 'terabitz')
		{
			if(callValue == 'buyers')
				widgetNames = "forsalelisting,fsbo";
			else if(callValue == 'renters')
				widgetNames = "craiglistRental,apartments";
			else if(callValue == 'localsearch')
				widgetNames = "yelp,panoramio";	
			else if(callValue == 'foreclosures')
				widgetNames = "foreclosures";		
			else
			{
				// Check MLS access
				/* COMMENTED AS PER NEW INSTRUCTIONS
				var redirectRes = "";
				var redirectUrl = '/app/dashboard/findMlsAccess.php';
				var redirectQs = "city=" + cityVar + "&state=" + stateVar + "&zip=" + zipVar + "&propLat=" + latitude + "&propLong=" + longitude; 
				ajaxRequest(redirectUrl, redirectQs, function getPartnerRedirectUrl(originalRequest)
					{
						redirectRes = originalRequest.responseText;
						if (redirectRes != "0")
						{
							window.location.href = redirectRes;
							return;
						}
					}, false
				)
				*/
				var redirectRes = 0;
				// We dont have MLS access in this city
				if (redirectRes == "0")
				{
					var url = '/app/feed/selectDefaultBitz.php';
					var queryString = "";
					ajaxRequest(url,queryString,function resDefaultBitz(originalRequest)
						{
							 var response = originalRequest.responseText;
							 if(response!=0)
							 {
								widgetNames = response;
							 }
							 else
								widgetNames = "googlebase";
						},false
					);
				}
				else
				{
					// We already have MLS access, so dont execute next code
					return;
				}
			}
		}
		else if (bkTheme == 'jonathan' || bkTheme == 'century21ah' || bkTheme == 'patrick' || bkTheme == 'remax' || bkTheme == 'moneyworld' || bkTheme == 'ajcre' || bkTheme == 'ibr')
		{
			if(callValue == 'aSearch'){
				widgetNames = "brokeragents";
			}
			else if(callValue == 'lSearch' && bkTheme == 'moneyworld'){
				widgetNames = "panoramio";
			}
			else if(callValue == 'lSearch'){
				widgetNames = "yelp,panoramio";
			}
			else if(callValue == 'pSearch'){
				widgetNames = "mlsSearch,jbfeaturedlistings";
				if(bkTheme == 'remax' || bkTheme == 'moneyworld' || bkTheme == 'ibr')
				{
					widgetNames = "mlsCountySearch";
				}
			}
			else if(callValue == 'rSearch'){
				widgetNames = "recentsales";
			}
			else if (bkTheme == 'moneyworld' && callValue == 'fHome')
				widgetNames = "jbfeaturedlistings";
			else if(callValue == 'fHome'){
				widgetNames = "mlsfeatured";
			}
			else if(callValue == 'lServices' && bkTheme == 'patrick'){
				widgetNames = "contractors,mortgagecompanies,lshomeinspector,titleCompanies,moving";
			}
			else if(callValue == 'lServices' && bkTheme == 'jonathan'){
				widgetNames = "appraiser,attorney";
			}
			else if(callValue == 'lServices' && bkTheme == 'remax'){
				widgetNames = "appraiser,inspection";
			}
			else if(callValue == 'lServices'){
				widgetNames = "appraiser,attorney,inspection";
			}
			else if(callValue == 'baSearch'){
				widgetNames = "brokeragents";
			}
			else
			{
				var url = '/app/feed/selectDefaultBitz.php';
				var queryString = "";
				ajaxRequest(url,queryString,function resDefaultBitz(originalRequest)
					{
						var response = originalRequest.responseText;
						if(response!=0)
						{
							widgetNames = response;
						}
						else
						{
							widgetNames = "mlsSearch";
							if (bkTheme == 'remax')
							{
								widgetNames = "mlsCountySearch&mapZoomLevel=14";
							}
							else if(bkTheme == 'moneyworld' || bkTheme == 'ajcre')
							{
								widgetNames = "mlsCountySearch";
							}
						}
					},false
				);
			}
		}
		else if(bkTheme == 'lmsre')
		{
			if(callValue == 'airports')
				widgetNames = "airports";
			if(callValue == 'colleges')
				widgetNames = "colleges";
		}
		else
		{
			var url = '/app/feed/selectDefaultBitz.php';
			var queryString = "";
			ajaxRequest(url,queryString,function resDefaultBitz(originalRequest)
				{
					 var response = originalRequest.responseText;
					 if(response!=0)
					 {
						widgetNames = response;
					 }
					 else
					 {
						 if (bkTheme=='intero')
							widgetNames = "mlsCountySearch,jbfeaturedlistings&mapZoomLevel=14";
						 else if (bkTheme == "acbre" || bkTheme == "remax" || bkTheme == "moneyworld")
							 widgetNames = "mlsCountySearch&mapZoomLevel=14";
						 else
							widgetNames = "mlsSearch";
					}
				},false
			);		
		}
		
		//condition for intero from landing page to open homes in two pane
		if(callValue == "openhouse")
			widgetNames = "mlsopenhomes";
		
		//condition for acbre reo search
		if(callValue == "reolisting")
			widgetNames = "reolistings&valChkMapSearchSelect=0";

		if (widgetNames != '')
			widgetNames = widgetNames.substr(0, widgetNames.length);
	}
	
	if ( $('hdnOuid') ) 
	{
		ouid = $('hdnOuid').value;
		widgetNames = widgetNames + '&frm=frch&ouid='+ouid;
	}	
	location.href = '../../app/listing/singlePropertyLanding.php?' + searchQueryString + "&widgetnames=" + widgetNames;
 };

 //remove value of advance option value


//function for searching by mlsno from index page header//

function funReloadAdvertise()
{
	//if(window.frames['iframeAdvertise'])
	//{
	//	window.frames['iframeAdvertise'].location.href = "/getAdvertise.php";
	//}
}

function setSearchCookie(ckName,ckValue)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
			arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
		}	
	}
	if(arrNameSearchCookie.find(ckName) !== false )
	{
		var ckIndex = arrNameSearchCookie.find(trim(ckName));
		arrValueSearchCookie[ckIndex] = escape(ckValue);
	}	
	else
	{
		arrNameSearchCookie[arrNameSearchCookie.length] = trim(ckName);
		arrValueSearchCookie[arrValueSearchCookie.length] = trim(escape(ckValue));
	}
	
	var strSearchCookie = "";
	for(var j=0;j<arrNameSearchCookie.length;j++)
	{
		if(j==0)
			strSearchCookie = strSearchCookie + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]); 
		else
			strSearchCookie = strSearchCookie + ':::' + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]);
	}
	
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	
	setCookie("strSearchCookie",strSearchCookie,now);
}

function getSearchCookie(ckName)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
			arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
		}	
	}
	
	var returnCKValue = "";
	if(arrNameSearchCookie.find(trim(ckName)) !== false)
	{
		var ckIndex = arrNameSearchCookie.find(ckName);
		returnCKValue = trim(unescape(arrValueSearchCookie[ckIndex]));
	}
	return returnCKValue;
	
}

function removeSearchCookie(ckName)
{
	var strSearchCookie = getCookie("strSearchCookie");
	var arrSearchCookie = new Array();
	if(strSearchCookie != null && strSearchCookie != "")
	{
		arrSearchCookie = strSearchCookie.split(':::');
	}
	
	var arrNameSearchCookie = new Array();
	var arrValueSearchCookie = new Array();
	
	if(arrSearchCookie.length > 0)
	{
		for(var i=0;i<arrSearchCookie.length;i++)
		{
			var arrKeyVal = arrSearchCookie[i].split('=');
			if(arrKeyVal[0] != ckName)
			{
				arrNameSearchCookie[arrNameSearchCookie.length] = trim(arrKeyVal[0]);
				arrValueSearchCookie[arrValueSearchCookie.length] = trim(arrKeyVal[1]);
			}	
		}
		var strSearchCookie = "";
		for(var j=0;j<arrNameSearchCookie.length;j++)
		{
			if(j==0)
				strSearchCookie = strSearchCookie + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]); 
			else
				strSearchCookie = strSearchCookie + ':::' + trim(arrNameSearchCookie[j]) + '=' + trim(arrValueSearchCookie[j]);
		}
	
		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		setCookie("strSearchCookie",strSearchCookie,now);
	}
}
function funClrQckLocSrchCookies()
{
	removeSearchCookie("searchAddress");
	removeSearchCookie("city");
	removeSearchCookie("state");
	removeSearchCookie("zip");
	removeSearchCookie("county");
	removeSearchCookie("neighborhood");
}
function funClrQckSrchCookies()
{
	// CLEAR COOKIE RELATED TO MLSSource 
	if(typeof(clr_MLSSRC_Cookie) == 'function')	
		clr_MLSSRC_Cookie();
	if(typeof(clr_MLSSRC_Html) == 'function')	
		clr_MLSSRC_Html();	
	//UI Template Related Code
	if(typeof(clearSearchTemplateParam) == 'function' )
		clearSearchTemplateParam();

	removeSearchCookie("pool");
	removeSearchCookie("fire");
	removeSearchCookie("photo");
	removeSearchCookie("listType");
	removeSearchCookie("garage");
	removeSearchCookie("stories");
	removeSearchCookie("fromYear");

	removeSearchCookie("spanHTML");
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("searchAddress");
	removeSearchCookie("city");
 	removeSearchCookie("state");
	removeSearchCookie("zip");
	removeSearchCookie("county");
	removeSearchCookie("neighborhood");
	removeSearchCookie("minPrice");
	removeSearchCookie("maxPrice");
	removeSearchCookie("searchBeds");
	removeSearchCookie("minSize");
	removeSearchCookie("maxSize");
	removeSearchCookie("searchBaths");
	removeSearchCookie("searchType");
	removeSearchCookie("searchSortType");
	removeSearchCookie("ckLFDate");
	removeSearchCookie("ckLTDate");
	removeSearchCookie("propStyle");
	removeSearchCookie("neighborhood");
	//removeSearchCookie("parkingType");
	
	// for power search
	removeSearchCookie("mlsSource");
	removeSearchCookie("propType");
	removeSearchCookie("propStatus");
	removeSearchCookie("area");
	removeSearchCookie("polygon");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("minPSize");
	removeSearchCookie("maxPSize");
	removeSearchCookie("ckPLFDate");
	removeSearchCookie("ckPLTDate");
	removeSearchCookie("listAgentFnm");
	removeSearchCookie("listAgentLnm");
	removeSearchCookie("minLotSize");
	removeSearchCookie("maxLotSize");
	removeSearchCookie("fromAge");
	removeSearchCookie("toAge");
	removeSearchCookie("fromYear");
	removeSearchCookie("toYear");
	removeSearchCookie("marketDaysFrom");
	removeSearchCookie("marketDaysTo");
	removeSearchCookie("garage");
	removeSearchCookie("stories");
	removeSearchCookie("eleSchool");
	removeSearchCookie("midSchool");
	removeSearchCookie("highSchool");
	removeSearchCookie("saleDateFrom");
	removeSearchCookie("saleDateTo");
	removeSearchCookie("saleAgentFnm");
	removeSearchCookie("saleAgentLnm");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("powerradial");
	removeSearchCookie("listagtid");
	removeSearchCookie("saleagtid");
	removeSearchCookie("listoff");
	removeSearchCookie("saleoff");
	removeSearchCookie("fire");
	removeSearchCookie("pool");
	removeSearchCookie("roof");
	
	setAllCookieValue("mlssource");
	setAllCookieValue("proptype");
	setAllCookieValue("propstatus");
	setAllCookieValue("sqftp");
	setAllCookieValue("listdatep");
	setAllCookieValue("listagent");
	setAllCookieValue("lotsize");
	setAllCookieValue("age");
	setAllCookieValue("yearbuilt");
	setAllCookieValue("daysonmarket");
	setAllCookieValue("garage");
	setAllCookieValue("stories");
	setAllCookieValue("eleschool");
	setAllCookieValue("midschool");
	setAllCookieValue("highschool");
	setAllCookieValue("saledate");
	setAllCookieValue("saleprice");
	setAllCookieValue("saleagent");
	setAllCookieValue("area");
	setAllCookieValue("polygon");
	setAllCookieValue("listagtid");
	setAllCookieValue("listoff");
	setAllCookieValue("saleagtid");
	setAllCookieValue("saleoff");
	setAllCookieValue("roof");
	setAllCookieValue("fire");
	setAllCookieValue("pool");
	//---------------------------------

	setAllCookieValue(null);
	headerContent(null);
	funCloseAdvanceSearch();
	
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("propStyle")
	if($('prpStyleText')) $('prpStyleText').innerHTML = "";

	if(typeof(srTabs) != "undefined" && srTabs.getTab(0).get("active"))
	{
		srTabs.set('activeTab',srTabs.getTab(0),true);
		srTabs.getTab(0).refresh();
	}
}

/**
 * add and remove the MapIt cookie
 * @param bitzNm = BitName
 * @param oprn = 'add' to add cookie 'del' to remove cookie 
 */
function setMapItCookie(bitzNm,oprn)
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = getCookie("strMapitCK");
	var ckAr = new Array();
	if(strMapitCK == null || trim(strMapitCK) == "")
	{
		strMapitCK = "";
		ckAr.length = 0;
	}
	else
	{
		ckAr = strMapitCK.split(',').compact();
	}
	if(oprn == "add")
	{
		var isBitz = ckAr.in_array(bitzNm);
		if(isBitz === false)
		{
			ckAr[ckAr.length] = bitzNm;
			strMapitCK = "";
			for(var i=0;i<ckAr.length;i++)
			{
				if(strMapitCK != "")
				{
					strMapitCK = strMapitCK + ',';
				}
				strMapitCK = strMapitCK + ckAr[i]; 
			}
			if ( (bitzNm == "brokeragents" || bitzNm == "brokeroffices" ) && ( bkTheme == "intero" || bkTheme == "garygreene" || bkTheme == "raveis") );
			else
				setCookie("strMapitCK",strMapitCK,now);
		}
	}
	else if (oprn == "del")
	{
		var isBitz = ckAr.in_array(bitzNm);
		if(isBitz === false)
		{
			return;
		}
		else
		{
			ckAr.splice(isBitz,1);
		}
		strMapitCK = "";
		for(var i=0;i<ckAr.length;i++)
		{
			if(strMapitCK != "")
			{
				strMapitCK = strMapitCK + ',';
			}
			strMapitCK = strMapitCK + ckAr[i]; 
		}
		setCookie("strMapitCK",strMapitCK,now);
	}
}

/**
 * returns all the mapable bits in form of an array
 */
function getAllMapItCookie()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = getCookie("strMapitCK");
	var ckAr = new Array();
	if(strMapitCK == null || trim(strMapitCK) == "")
	{
		strMapitCK = "";
		ckAr.length = 0;
	}
	else
	{
		ckAr = strMapitCK.split(',').compact();
	}
	return ckAr;
}

/**
 * set the mapit cookie to the list of mapable bits passed as an array
 */
function setAllMapItCookie(mapitBitsArray)
{
	for(i=0;i<mapitBitsArray.length;i++)
		setMapItCookie(mapitBitsArray[i],"add");
}

/**
 * set the mapit cookie to the list of mapable bits passed as an array
 */
function removeAllMapItCookie()
{
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	var strMapitCK = "";
	setCookie("strMapitCK",strMapitCK,now);
}


function setCSZValue(city, state, zip)
{
	var geoCSZStr = "";
	var multiCity = false;
	if ((city  == null) || (city =="") || (city  =="undefined"))
	{
		// Do nothing
	}
	else
	{
		if (city.indexOf('|') != -1)
			multiCity = true;
	}

	if (!multiCity && (zip  == null) || (zip =="") || (zip  =="undefined"))
	{
		// Do nothing
	}
	else
	{
		if (zip.indexOf('|') != -1)
			multiCity = true;
	}
	
	if (multiCity)
	{
		var cityArr = new Array();
		var stateArr = new Array();
		var zipArr = new Array();
		if ((city  == null) || (city =="") || (city  =="undefined"))
		{}
		else
		{
			cityArr = city.split('|');
		}
		if (state  =="" || state  =="undefined" || state  == null)
		{}
		else
		{
			stateArr = state.split('|');
		}
		if (zip =="" || zip  =="undefined" || zip  == null)
		{}
		else
		{
			zipArr = zip.split('|');
		}
		
		for (var i=0; i<cityArr.length; i++)
		{
			var currentCsz = "";
			if (cityArr[i]  == null || cityArr[i] == "")
			{}
			else
			{
				currentCsz += cityArr[i] + ", ";
			}
			if (stateArr[i]  == null || stateArr[i] == "")
			{}
			else
			{
				currentCsz += stateArr[i] + " ";
			}
			if (zipArr[i]  == null || zipArr[i] == "")
			{}
			else
			{
				currentCsz += zipArr[i];
			}
			
			if (currentCsz != "")
				geoCSZStr += trim(currentCsz) + ";";
				
			var geoCity 	= cityArr[i];
			var geoState 	= stateArr[i];
			var geoZip 		= zipArr[i];
			var geoCSZ 		= setCSZValue(geoCity, geoState,geoZip);
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if($(idTxtObj) != null)
				$(idTxtObj).value = trim(geoCSZ).replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
		}
		if (geoCSZStr != "")
			geoCSZStr = geoCSZStr.substr(0, geoCSZStr.length-1);
	}
	else
	{
	 	if(city!=null)
	 	{
			if ((city  == null) || (city =="") || (city  =="undefined"))
			{
				
			}
			else
			{
				geoCSZStr = city + ", ";
			}
	 	}
	 	if(state!=null)
	 	{
			if (state  =="" || state  =="undefined" || state  == null)
			{
				
			}
			else
			{
				geoCSZStr += state +" ";
			}
	 	}
	 	if(zip!=null)
	 	{
			if (zip =="" || zip  =="undefined" || zip  == null)
			{
				
			}
			else
			{
				geoCSZStr += zip;
			}
	 	}
	}
	
 	if(trim(geoCSZStr) == "" )
 	{
 		geoCSZStr = "required";
 	}
 	return trim(geoCSZStr);
}
function funWrapText(str,len)
{
	if(str.length > len)
	{
		str = str.substr(0,len)+' ...';
	}
	return str;
}

function explore(page)
{	

	/* */
	// IF NEW LISTING THEN LAST 15 DAYS DATE DURATION WOULD BE SET
	if($('bit_select_box') && $F('bit_select_box') == 'newListing')
	{
		$("RStxtLFDate").value = listDate1;
		$("RStxtLTDate").value = listDate2;
		setSearchCookie("listType",$F('bit_select_box'));
	}
	else if($('bit_select_box') && $F('bit_select_box') != 'newListing')
	{
		lfDate = ''; ltDate = '';
		$("RStxtLFDate").value = '';
		$("RStxtLTDate").value = '';
		setSearchCookie("listType",$F('bit_select_box'));
	}
	setSearchCookie("ckLFDate",($("RStxtLFDate"))?($F("RStxtLFDate")):"");
	setSearchCookie("ckLTDate",($("RStxtLTDate"))?($F("RStxtLTDate")):"");



	if (countySearchEnabled == "0" && checkMultiCity() == false && trim(getSearchCookie("neighborhood")) != "")
	{
		setSearchCookie("county", "");
	}
	if ( bkTheme != "terabitz" && trim($("searchMLS").value) != "")
	{
		var allBitz = getAllMapItCookie().toString();
		allBitz = allBitz.split(",");

		if(allBitz.length >= 10)
		{	
			alert("Please close atleast one bit, then enter MLS Number.");
			return;
		}

		if (page=="agentSiteListing")
			searchByMlsNoAgentSite();
		else if(page == "singlePropPower")
		{
			if(typeof(powerSearch) != 'undefined' && powerSearch == "1" && (uRole == "EA" || uRole == "A"))
			{
				var mlsurl = "../../app/dashboard/mlsSearch.php";
			    var mlsstr = "mlsno="+trim($("searchMLS").value)+ "&forAlert=1&mlsSource="+getSearchCookie('mlsSource')+"&ignorestatus=1&idb=1&theme="+bkTheme+"&aid="+uid;
				
				ajaxRequest(mlsurl,mlsstr,function(r){
					response = trim(r.responseText);
					if(response == '0')	           
					{
						alert('MLS NO. not found.');
						return;
					}
					else
					{
						dataArr = response.split("&")[1].split("=")[1].split(",");
						var city = dataArr[1];
						var state = dataArr[2];
						var zip = dataArr[3];
						var lat = dataArr[7];
						var lng = dataArr[8];

						setSearchCookie("city",city);
						setSearchCookie("state",state);
						setSearchCookie("zip",zip);

						var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
						var now = new Date();
						now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
						setCookie("latLongCk",latLongStr,now);

						setSearchCookie("mlsno",trim($("searchMLS").value));
						setSearchCookie("area","");
						setSearchCookie("polygon","");
						funExplorePowerSearch();
					}
				});
			}
		}
		else
			searchByMlsNo();
		return;
	}
	else if($("searchMLS").value != "" && ($("searchCSZ").value == "" || $F("searchCSZ").toLowerCase() == "required"))
	{
		alert("Please enter City or Zip along with MLS Number.");
		return;
	}
	else if($("searchMLS").value != "")
	{
		var myStatus = funCheckContradict();
		if(myStatus != null && myStatus != 0)
		{
			if (page=="agentSiteListing")
				searchByMlsNoAgentSite();
			else
				searchByMlsNo();
		}
		return;
	}
	var csz = $("searchCSZ").value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
	var addr= $("searchAddress").value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
	/*if (trim(csz) == "")
	{
		alert ("Please specify either City or Zip");
		return false;
	}
	else */
	if (trim(csz) == "" || trim(csz).toLowerCase() == "required")
	{
		if(page == "singlePropPower")
		{
			if($("txtArea") && $("txtArea").value == "")
			{
				alert ("Please specify either City or Zip");
				return false;
			}
			else
			{				
				var status = funSaveAdvanceSearch("power","singlePropPower");
				
				if(status == true)
				{
					if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "")
						setSearchCookie("mlsno","");
					funExplorePowerSearch();
				}
			}
		}
		else
		{
			alert ("Please specify either City or Zip");
			return false;
		}
	}
	else if ( addr!="optional" && addr!="")
	{
		var contradict = funCheckContradict();
		if(contradict != null && contradict != 0)
		{
			var contradict = funReloadAdvertise();

			if(typeof(powerSearch) != 'undefined' && powerSearch == "1" && (uRole == "EA" || uRole == "A"))
			{		
				/*
				[{"status":"0","originaladdress":"4214 E Arch Rd, Stockton, CA ","statuscode":"200","country":"US","accuracy":"8","address":"4214 E Arch Rd","state":"CA","city":"Stockton","zip":"95215","latitude":"37.905234","longitude":"-121.214809"}]
				*/
				var url = "../../classes/getCSZ.php";
			    var qs = "csz="+trim($("searchCSZ").value)+"&address="+addr;
				
				ajaxRequest(url,qs,function(r){
					response = eval('(' + trim(r.responseText) + ')');

					if(response[0].status == "0")
					{
						var addr = response[0].address;
						var city = response[0].city;
						var state = response[0].state;
						var zip = response[0].zip;
						var lat = response[0].latitude;
						var lng = response[0].longitude;

						setSearchCookie("searchAddress",addr);
						setSearchCookie("city",city);
						setSearchCookie("state",state);
						setSearchCookie("zip",zip);

						var latLongStr = "[{'lat':'"+lat+"','lng':'"+lng+"'}]";
						var now = new Date();
						now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
						setCookie("latLongCk",latLongStr,now);
							
						funExplorePowerSearch();
					}
				});
			}
			else
			{
				var allBitz = getAllMapItCookie().toString();
				allBitz = allBitz.split(",");

				if(allBitz.length >= 10)
				{	
					alert("Please close atleast one bit, then enter Address.");
					return;
				}
				funExploreMlsAddrMap();
			}
			
			return;
		}
	}
	else
	{
		var cszFromCk = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
		var contradict = funCheckContradict();
		if(contradict != null && contradict != 0)
		{
			var contradict = funReloadAdvertise();
			if(page == "index")
			{
				gotoDashBrd();
			}	
			else if(page=="dashboard")
			{
				funQckUpdateWidgets();		
			}
			else if(page=="singleProp")
			{
				funExploreOnMapit();
			}
			else if(page=="singlePropPower")
			{
				var status = funSaveAdvanceSearch("power","singlePropPower");
				
				if(status == true)
				{
					if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "" && $("searchCSZ").value != "")
					{
						setSearchCookie("mlsno","");
					}
					else
					{
						if($('searchCSZ') != null)
						{
							$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
							if (trim(cszFromCk).toUpperCase() != trim($('searchCSZ').value).toUpperCase())
							{
								if(getSearchCookie("area") && getSearchCookie("area") == $("txtArea").value)
								{
									setSearchCookie("area","");
									setSearchCookie("polygon","");
								}
							}
						}	
					}
					funExplorePowerSearch();
				} 
			}
			else if(page=="agentSiteListing")
			{
				funAgentSiteSearch();
			}
		}	
	}	
}
function funAgentSiteSearch(page,valOrderBy,typeOrderBy,searchByMlsNo)
{
	var cbfnAgentSite = function(reqObj)
	{
		var response = trim(reqObj.responseText);
		var arrResponseCount = response.split('|==|');
		var responseCount = arrResponseCount[0];
		var responseHTML = arrResponseCount[1];
		$('listDiv').innerHTML = responseHTML;
		if(parseInt(responseCount) > 0)
		{
			$('propSortBar').style.display = 'block';
		}
	}
	var url = "./getListing.php";
	var qs = funGetSearchQueryString();

	var objQS = new Querystring();
	var aid = objQS.get('aid');
	
	qs = qs + "&aid="+aid;

	if(page != null)
	{
		qs = qs + "&page="+page;
	}
	else
	{
		qs = qs + "&page=1";
	}
	if(valOrderBy != null)
	{
		qs = qs + "&valOrderBy="+valOrderBy;
	}
	else
	{
		qs = qs + "&valOrderBy=price";
	}
	if(typeOrderBy != null)
	{
		qs = qs + "&typeOrderBy="+typeOrderBy;
	}
	else
	{
		qs = qs + "&typeOrderBy=asc";
	}
	if(searchByMlsNo != null)
	{
		qs = qs + "&MlsSearch="+searchByMlsNo;
	}
	else
	{
		qs = qs + "&MlsSearch=0";
	}
	$('listDiv').innerHTML = '';
	ajaxRequest(url,qs,cbfnAgentSite);
}

function searchByMlsNoAgentSite()
{
	var cbfnAgentSite = function(reqObj)
	{
		var response = trim(reqObj.responseText);
		var arrResponseCount = response.split('|==|');
		var responseCount = arrResponseCount[0];
		var responseHTML = arrResponseCount[1];
		$('listDiv').innerHTML = responseHTML;
		if(parseInt(responseCount) > 0)
		{
			$('propSortBar').style.display = 'block';
		}
	}
	var url = "./getListing.php";
	var qs = "";
        var objQS = new Querystring();
        var aid = objQS.get('aid');
        qs = qs + "&aid="+aid;


	var mlsNo = objQS.get('mlsno');
	if(mlsNo!=null && mlsNo!='')
	{
		qs = qs + "&MlsSearch="+mlsNo;
	}
	else
	{
		qs = qs + "&MlsSearch="+trim($("searchMLS").value);
	}

	//qs = qs + "&MlsSearch=1";
    qs = qs + "&valOrderBy=price";
    qs = qs + "&typeOrderBy=asc";

	$('listDiv').innerHTML = '';
	ajaxRequest(url,qs,cbfnAgentSite);
}

var	recordDialogBox = "";
var	agtOffDlgBox = "";
function searchByMlsNo()
{
	if ($("searchMLS").value == "")
	{
		alert("Please input MLS number to search.");
		$("searchMLS").value = "";
		$("searchMLS").focus();
		return;
	}
	var mlsno = trim($("searchMLS").value);
	var qStr = "mlsno="+escape(mlsno);
	qStr += "&city="	+ trim(getSearchCookie("city"));
	qStr += "&state="	+ trim(getSearchCookie("state"));
	qStr += "&zip="		+ trim(getSearchCookie("zip"));
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	var ouid = myQs.get("ouid");
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			qStr = qStr + "&mlsSource="	+ 	escape((trim(strAgtMlsSrc)));
		else
			qStr = qStr + "&mlsSource=";
		qStr = qStr + "&aid="+	escape((trim(aid)));

		//agentsite statistics
		var city = getSearchCookie("city");
		var ad = getSearchCookie("searchAddress");
		var beds = getSearchCookie("searchBeds");
		var baths = getSearchCookie("searchBaths");
		var type = getSearchCookie("searchType");
		var minprice = getSearchCookie("minPrice");
		var maxprice = getSearchCookie("maxPrice");

		var url = "../../classes/emailStats.php";
		var qs = "from=search&aid="+aid+"&city="+city+"&type="+type+"&beds="+beds+"&baths="+baths+"&price="+minprice+"-"+maxprice+"&addr="+ad+"&mlsno="+mlsno;

		ajaxRequest(url,qs);
		//statistics done
	}
	else if (frm != null && trim(frm) == 'frch' && ouid != null && trim(ouid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			qStr = qStr + "&mlsSource="	+ 	escape((trim(strAgtMlsSrc)));
		else
			qStr = qStr + "&mlsSource=";
		qStr = qStr + "&ouid="		+ 	escape((trim(ouid)));

		//agentsite statistics
		var city = getSearchCookie("city");
		var ad = getSearchCookie("searchAddress");
		var beds = getSearchCookie("searchBeds");
		var baths = getSearchCookie("searchBaths");
		var type = getSearchCookie("searchType");
		var minprice = getSearchCookie("minPrice");
		var maxprice = getSearchCookie("maxPrice");

		var url = "../../classes/emailStats.php";
		var qs = "from=search&ouid="+ouid+"&city="+city+"&type="+type+"&beds="+beds+"&baths="+baths+"&price="+minprice+"-"+maxprice+"&addr="+ad+"&mlsno="+mlsno;

		ajaxRequest(url,qs);
		//statistics done
	}
	var url  = "/app/dashboard/mlsSearch.php";
	ajaxRequest(url,qStr,cbfnSearchByMlsNo);
}

function funRedirectToMLS(urlMLS)
{
	funClrQckLocSrchCookies();
	removeAllMapItCookie();	
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	var	ouid = '';
	if ( $('hdnOuid') ) 
		ouid = $('hdnOuid').value;
	
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		urlMLS = urlMLS + '&frm=agt&aid='+aid;
	}
	else if(ouid != null && trim(ouid) != "")
	{
		urlMLS = urlMLS + '&frm=frch&ouid='+ouid;
	}
	
	window.location.href = unescape(urlMLS);
}

function cbfnSearchByMlsNo(originalRequest)
{
	var response = originalRequest.responseText;
	if (response == 0)
	{
		alert("MLS Number Not found.");
		$("searchMLS").value = "";
		$("searchMLS").focus();
		return;
	}
	else
	{
		if(response.include("|^|"))
		{
			var arrResponse = response.split("|^|");
			var strIH = new StringBuffer();
			strIH.append(' <div id="divMLSConfirmBox" style="background-color:#B0B0B0;display: none;border: 0px solid rgb(0, 0, 0); padding: 20px; height: 150px; width: 530px; position: fixed; top: 225px; left: 255px; visibility: inherit;" >');
			strIH.append(' 	<table cellspacing="0" cellpadding="0" bordercolor="red" border="0" style="width: 100%; height: 100%;">');
			strIH.append(' 		<tr style="height: 8px;">');
			strIH.append(' 			<td valign="bottom" class="crvTopLeft"></td>');
			strIH.append(' 			<td valign="bottom" class="crvTopMid" style="width: 500px;"></td>');
			strIH.append(' 			<td valign="bottom" class="crvTopRight"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 		<tr style="height: 90%;width:520px;">');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);" class="crvLeftMid"></td>');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);">');

			strIH.append('<table style="width:100%;height:100%">');
			strIH.append('<tr>');
			strIH.append('<td>');
			strIH.append('<img src="../../wt/'+bkTheme+'/images/common/imgConfirm.gif" alt="conform" />');
			strIH.append('</td>');
			strIH.append('<td  class="moduleDescText">');
			strIH.append('<div style="position: relative;font-size:11px;width: 79%;float: left;display: inline;padding-left: 5px;height:100%;vertical-align: middle;" align="left" id="divMLSConfirmMessageText">');
			strIH.append('&nbsp;');
			strIH.append('</div>');
			strIH.append('</td>');
			strIH.append('<tr>');
			strIH.append('<td colspan="2" align="center" valign="top">');
			strIH.append('<button style="width:50px;" onclick="javascript:myPopup();" class="lang" type="button" name="btnOK" id="btnOK">Yes</button>');
			strIH.append('&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button class="lang" type="button" name="btnCancel" id="btnCancel" onclick="dlgMLSConfirmBox.hide();" style="width:50px;">No</button>');
			strIH.append('</td>');
			strIH.append('</tr>');
			strIH.append('</table>');

			strIH.append(' 			</td>');
			strIH.append(' 			<td style="background-color: rgb(255, 255, 255);" class="crvRightMid"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 		<tr style="height: 8px;">');
			strIH.append(' 			<td class="crvBotLeft"></td>');
			strIH.append(' 			<td class="crvBotMid"></td>');
			strIH.append(' 			<td class="crvBotRight"></td>');
			strIH.append(' 		</tr>');
			strIH.append(' 	</table>');
			strIH.append(' </div><style type="text/css">.closeMy{background-image:url(../../wt/'+bkTheme+'/images/common/close_dlgLog.gif);}</style>');
			
			myPopup = function()
			{
				response = arrResponse[1];
				dlgMLSConfirmBox.hide();
				loadMlsNumberProp(response);
				
			}

			function funRedirectToOther()
			{
				response = arrResponse[1];
				loadMlsNumberProp(response);
			}

			function funCnfrmRedirectToOther()
			{
				var closeBox = document.getElementsByClassName("close","divMLSConfirmBox")[0];
				if(closeBox)
				{
					closeBox.removeClassName("nonsecure");
					closeBox.addClassName("closeMy");
				}
				$('divMLSConfirmMessageText').innerHTML = "Redirecting to our Partners Site: <b>"+arrResponse[0]+"</b>";
				$("divMLSConfirmBox").style.display="block";	
				dlgMLSConfirmBox.show();
			}
			if($("divMLSConfirmBox") == null)
			{
				var myIH = strIH.toString();var myDiv = document.createElement("div");myDiv.innerHTML = myIH;document.body.appendChild(myDiv);							
				dlgMLSConfirmBox = createDialog('divMLSConfirmBox');
				
			}
			//funCnfrmRedirectToOther();				
			funRedirectToOther();
			//alert("Redirecting to our Partner's site '" + arrResponse[0] +"'");
			
		}
		else
		{
			loadMlsNumberProp(response);
		}
	}
}

function loadMlsNumberProp(response)
{
	var arrMlsRecords = new Array();	
	var arrRecords = new Array();	
	arrMlsRecords = response.split('\n');

	if(arrMlsRecords.length == 1)
	{
		arrRecords = arrMlsRecords[0].split('|');
		funRedirectToMLS(arrRecords[8]);
	}
	else
	{
		var mlsNumber;
		var detailRecords="";
		var startRecords;
		var recLen = arrMlsRecords.length;
		// Build table for div
		
		for(var i=0;i<recLen;i++)
		{
			arrRecords = arrMlsRecords[i].split('|');
			mlsNumber  = arrRecords[0];
			detailRecords += "<tr style=\"height:25px\"><td width=\"60%\" class=\"mlsLightBoxDescText\" align=\"left\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+arrRecords[1]+", "+arrRecords[2]+", "+arrRecords[3]+", "+arrRecords[4]+"</span></b></a></td><td width=\"15%\" class=\"mlsLightBoxDescText\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+num2money(arrRecords[5])+"</span></b></a></td><td width=\"15%\" class=\"mlsLightBoxDescText\" valign=\"top\">&nbsp;<a class=\"mlsHeadDis\" href=\"javascript:void(0);\" onclick=\"javascript:funRedirectToMLS(\'"+arrRecords[8]+"\');\"><b><span class=\"crsr\">"+arrRecords[6]+"-Br/"+arrRecords[7]+"-Ba</span></b></a></td></tr>";
		}			
		
		startRecords = "<table width=\"100%\" height=\"98%\" class=\"mlsLightBoxLableText\">";
		startRecords += "<tr style=\"height:25px\"><td class=\"mlsLightBoxTopLableText\" colspan=\"3\" align=\"left\" style=\"height:20px\">Total "+recLen+" listings were found. For more details, click on below link.</td></tr>";
		startRecords += "<tr><td height=\"5px\" colspan=\"3\"></td></tr>";
		startRecords = startRecords+detailRecords;
		startRecords += "</table>";
		
		if(typeof(recordDialogBox) == "string")
		{
			recordDialogBox = createDialog("recordsDialog");	
		}
		
		var ht = (recLen+1)*25;
		if(recLen>3)
			ht = "100%";
		else
		{
			if(isIE)
				ht = "85%";//ht+"px";
			else
				ht = "80%";//ht+"px";
		}
		$("recordsDialog").getElementsByClassName("bd")[0].style.height = ht;
		$("recordsDialog").getElementsByClassName("bd")[0].innerHTML = startRecords;
		$("recordsDialog").getElementsByClassName("hd")[0].innerHTML = "Listing Of MLS Number : "+mlsNumber;			
		$("recordsDialog").style.display="block";
		recordDialogBox.show();			
	}
}
function setAllToCookie(srchcrt,from)
{
	if(srchcrt == null)
	{
		if ($F("searchAddress").toLowerCase() == "optional" || $F("searchAddress") == "undefined" || $F("searchAddress") == null)
		{
			setSearchCookie("searchAddress","");
		}
		else
		{
			setSearchCookie("searchAddress",($("searchAddress"))?$F("searchAddress"):"");
		}
	}
	if(srchcrt == "neighborhood")
	{			
		if(typeof(from)!="undefined")
		{
			divId = "divNHood";
			chkAllId = "chbRSNHAll";
		}
		else
		{
			divId = "divSHDataNeighborHood";
			chkAllId = "chbSHNHAll";
		}
		if($(divId))
		{
			var arrChkBox = $(divId).getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var strCKNH = "";
			for(var i=0;i<lenArrChkBox;i++)
			{
				if(arrChkBox[i].id == chkAllId && arrChkBox[i].checked == true)
				{
					strCKNH = 'all';
					break;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strCKNH = strCKNH + valChkBox + ",";  	
				}
			}
			if(strCKNH.charAt(strCKNH.length-1) == ',')
			{
				strCKNH = strCKNH.substr(0,eval(strCKNH.length-1));
			}
			setSearchCookie("neighborhood",strCKNH);
			if(srchcrt != null)
			{
				return;
			}
		}
	}
	if(srchcrt == "county")
	{		
		var dv = "";
		if(typeof(from) != "undefined")
			dv = "divRSCounty";
		else
			dv = "divSHDataCounty";

		if($(dv))
		{
			var arrChkBox = $(dv).getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var strCKCounty = "";
			for(var i=0;i<lenArrChkBox;i++)
			{
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strCKCounty = strCKCounty + valChkBox + ",";  	
				}
			}
			
			if(strCKCounty.charAt(strCKCounty.length-1) == ',')
			{
				strCKCounty = strCKCounty.substr(0,eval(strCKCounty.length-1));
			}

			if(trim(strCKCounty) != "")
			{
				setSearchCookie("county",strCKCounty);
				removeSearchCookie("neighborhood");
				headerContent("neighborhood");
			}
			else
			{
				// If no County selected then just remove county from cookie
				removeSearchCookie("county");
			}
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "price")
	{			
		setSearchCookie("minPrice",($("minPrice"))?(money2num($F("minPrice"))):"");
		setSearchCookie("maxPrice",($("maxPrice"))?(money2num($F("maxPrice"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "beds")
	{			
		var srchBds = "";
		var minBeds = ($("searchBedsMin"))?($F("searchBedsMin")):"";
		if(minBeds == "0") minBeds = "";
		if(minBeds != "" && minBeds.indexOf(".") == (minBeds.length-1)) minBeds = minBeds+"0";
		if(minBeds != "" && minBeds.indexOf(".") == 0) minBeds = "0"+minBeds;

		var maxBeds = ($("searchBedsMax"))?($F("searchBedsMax")):"";
		if(maxBeds == "0") maxBeds = "";
		if(maxBeds != "" && maxBeds.indexOf(".") == (maxBeds.length-1)) maxBeds = maxBeds+"0";
		if(maxBeds != "" && maxBeds.indexOf(".") == 0) maxBeds = "0"+maxBeds;

		srchBds = minBeds+"-"+maxBeds;
		if(trim(srchBds) == "-")
			srchBds = "";
		setSearchCookie("searchBeds",srchBds);

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{			
		setSearchCookie("minSize",($("minSize"))?$F("minSize")==0?"":$F("minSize"):"");
		setSearchCookie("maxSize",($("maxSize"))?$F("maxSize")==0?"":$F("maxSize"):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "baths")
	{			
		var srchBths = "";
		var minBath = ($("searchBathsMin"))?($F("searchBathsMin")):"";
		if(minBath == "0") minBath = "";
		if(minBath != "" && minBath.indexOf(".") == (minBath.length-1)) minBath = minBath+"0";
		if(minBath != "" && minBath.indexOf(".") == 0) minBath = "0"+minBath;

		var maxBath = ($("searchBathsMax"))?($F("searchBathsMax")):"";
		if(maxBath == "0") maxBath = "";
		if(maxBath != "" && maxBath.indexOf(".") == (maxBath.length-1)) maxBath = maxBath+"0";
		if(maxBath != "" && maxBath.indexOf(".") == 0) maxBath = "0"+maxBath;

		srchBths = minBath+"-"+maxBath;
		if(trim(srchBths) == "-")
			srchBths = "";
		setSearchCookie("searchBaths",srchBths);

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		if(typeof(from)!="undefined")
		{
			divId = "divRSType";
			chkAllId = "RSchbSHTypeAll";
		}
		else
		{
			divId = "divPopUpSHType";
			chkAllId = "chbSHTypeAll";
		}
		var arrChkBox = $(divId)?$(divId).getElementsByTagName("input"):"";
		var lenChkBox = arrChkBox.length;		
		var strChkBox = "";
		var allChked = true;		
		for(var i=0;i<lenChkBox;i++)
		{			
	    	if(arrChkBox[i].id == chkAllId)
	    	{
	    		continue;
	    	}
	    	if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
	    	    var valChkBox = arrChkBox[i].value;
	    	    strChkBox = strChkBox + valChkBox + ':';				
	    	}
	    	else if(arrChkBox[i].type == "checkbox")
	    	{
	    	    allChked = false;    
	    	}
		}
		if(allChked == true && bkTheme != "emerge")
		{
	    	strChkBox = "";
		}
		else if(strChkBox.charAt(strChkBox.length-1) == ':')
		{
			strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
		}		
		setSearchCookie("searchType",strChkBox);		
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{			
		setSearchCookie("searchSortType",($("searchSortType"))?$F("searchSortType"):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{			
		setSearchCookie("ckLFDate",($("txtLFDate"))?($F("txtLFDate")):"");
		setSearchCookie("ckLTDate",($("txtLTDate"))?($F("txtLTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "mlssource")
	{
		setSearchCookie("mlsSource",($("mlsSource"))?($F("mlsSource")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "proptype" && $("divPType"))
	{			
		//setSearchCookie("propType",($("propTypes"))?($F("propTypes")):"");			
		var arrChkBox = $("divPType").getElementsByTagName("input");
		var strChkd = "";

		for(i=0;i<arrChkBox.length;i++)
		{
			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
				strChkd += arrChkBox[i].value + ':';
			}
		}
		
		if(strChkd.charAt(strChkd.length-1) == ':')
			strChkd = strChkd.substr(0,eval(strChkd.length-1));

		setSearchCookie("propType",strChkd);

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "propstatus" && $("divPStatus"))
	{
		/*setSearchCookie("propStatus",($("propStatus"))?($F("propStatus")):"");
		if(srchcrt != null)
		{
			return;
		}*/

		var arrChkBox = $("divPStatus").getElementsByTagName("input");
		var strChkd = "";

		for(i=0;i<arrChkBox.length;i++)
		{
			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
	    	{
				strChkd += arrChkBox[i].value + ':';
			}
		}
		
		if(strChkd.charAt(strChkd.length-1) == ':')
			strChkd = strChkd.substr(0,eval(strChkd.length-1));

		setSearchCookie("propStatus",strChkd);

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "sqftp")
	{
		setSearchCookie("minPSize",($("minPSize"))?$F("minPSize")==0?"":$F("minPSize"):"");
		setSearchCookie("maxPSize",($("maxPSize"))?$F("maxPSize")==0?"":$F("maxPSize"):"");
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "listagent")
	{
		if($('txtAgtFName').value != 'First Name')
			setSearchCookie("listAgentFnm",($("txtAgtFName"))?($F("txtAgtFName")):"");
		else
			setSearchCookie("listAgentFnm","");

		if($('txtAgtLName').value != 'Last Name')				
			setSearchCookie("listAgentLnm",($("txtAgtLName"))?($F("txtAgtLName")):"");
		else
			setSearchCookie("listAgentLnm","");

		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "listdatep")
	{			
		setSearchCookie("ckPLFDate",($("txtPLFDate"))?($F("txtPLFDate")):"");
		setSearchCookie("ckPLTDate",($("txtPLTDate"))?($F("txtPLTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "lotsize")
	{
		setSearchCookie("minLotSize",($("minLotSize"))?$F("minLotSize")==0?"":$F("minLotSize"):"");
		setSearchCookie("maxLotSize",($("maxLotSize"))?$F("maxLotSize")==0?"":$F("maxLotSize"):"");
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "age")
	{			
		setSearchCookie("fromAge",($("txtAgeFrom"))?(money2num($F("txtAgeFrom"))):"");
		setSearchCookie("toAge",($("txtAgeTo"))?(money2num($F("txtAgeTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "yearbuilt")
	{			
		setSearchCookie("fromYear",($("txtYearBuiltFrom"))?(money2num($F("txtYearBuiltFrom"))):"");
		setSearchCookie("toYear",($("txtYearBuiltTo"))?(money2num($F("txtYearBuiltTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "daysonmarket")
	{			
		setSearchCookie("marketDaysFrom",($("txtDaysMarketFrom"))?(money2num($F("txtDaysMarketFrom"))):"");
		setSearchCookie("marketDaysTo",($("txtDaysMarketTo"))?(money2num($F("txtDaysMarketTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "garage")
	{			
		if(typeof(from)!="undefined")
			var cmbId = "RScmbGarage";
		else
			var cmbId = "cmbGarage";

		setSearchCookie("garage",($(cmbId))?$F(cmbId)==0?"":$F(cmbId):"");

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "stories")
	{			
		setSearchCookie("stories",($("txtStories"))?($F("txtStories")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "bankowned")
	{			
		setSearchCookie("bankowned",$("chkBankOwned").checked);
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "shortsales")
	{			
		setSearchCookie("shortsales",$("chkShortSales").checked);
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "schooldist")
	{			
		setSearchCookie("schooldist",($("txtSchoolDist"))?($F("txtSchoolDist")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "eleschool")
	{			
		setSearchCookie("eleSchool",($("txtEleSchool"))?($F("txtEleSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "midschool")
	{			
		setSearchCookie("midSchool",($("txtMidSchool"))?($F("txtMidSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "highschool")
	{			
		setSearchCookie("highSchool",($("txtHighSchool"))?($F("txtHighSchool")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saledate")
	{			
		setSearchCookie("saleDateFrom",($("txtSFDate"))?($F("txtSFDate")):"");
		setSearchCookie("saleDateTo",($("txtSTDate"))?($F("txtSTDate")):"");
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleprice")
	{			
		setSearchCookie("salePriceFrom",($("txtSalePriceFrom"))?(money2num($F("txtSalePriceFrom"))):"");
		setSearchCookie("salePriceTo",($("txtSalePriceTo"))?(money2num($F("txtSalePriceTo"))):"");
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "saleagent")
	{
		if($('txtSaleAgentFname').value != 'First Name')
			setSearchCookie("saleAgentFnm",($("txtSaleAgentFname"))?($F("txtSaleAgentFname")):"");
		else
			setSearchCookie("saleAgentFnm","");

		if($('txtSaleAgentLname').value != 'Last Name')				
			setSearchCookie("saleAgentLnm",($("txtSaleAgentLname"))?($F("txtSaleAgentLname")):"");
		else
			setSearchCookie("saleAgentLnm","");

		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "area")
	{			
		setSearchCookie("area",($("txtArea"))?($F("txtArea")):"");		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "polygon")
	{			
		setSearchCookie("polygon",($("txtPolygon"))?($F("txtPolygon")):"");		
		//alert(getSearchCookie("polygon"))
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "powerradial")
	{			
		setSearchCookie("powerradial",$F("cmbradial"));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listagtid")
	{			
		setSearchCookie("listagtid",trim($F("txtListAgtId")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listoff")
	{			
		setSearchCookie("listoff",trim($F("txtListOff")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleagtid")
	{			
		setSearchCookie("saleagtid",trim($F("txtSaleAgtId")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleoff")
	{			
		setSearchCookie("saleoff",trim($F("txtSaleOff")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "roof")
	{			
		setSearchCookie("roof",trim($F("txtRoof")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "fire")
	{			
		setSearchCookie("fire",trim($F("cmbFire")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "pool")
	{			
		setSearchCookie("pool",trim($F("cmbPool")));

		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "propstyle")
	{		
		if(typeof(from)!="undefined")
		{
			divId = "RSpropStyleDv";
			chkAllId = "RSchkStyleAll";
		}
		else
		{
			divId = "propStyleDv";
			chkAllId = "chkStyleAll";
		}

		if($(divId))
		{
			var arrChkBox = $(divId).getElementsByTagName("input");
			var lenChkBox = arrChkBox.length;
			var strChkBox = "";
			var allChked = true;
			for(var i=0;i<lenChkBox;i++)
			{
				if(arrChkBox[i].id == chkAllId)
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strChkBox = strChkBox + valChkBox + ':';
				}
				else if(arrChkBox[i].type == "checkbox")
				{
					allChked = false;    
				}
			}
			if(allChked == true)
			{
				strChkBox = "";
			}
			else if(strChkBox.charAt(strChkBox.length-1) == ':')
			{
				strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
			}
			setSearchCookie("propStyle",strChkBox);
		}
		else
			setSearchCookie("propStyle","");

		if(srchcrt != null)
		{
			return;
		}
	}
	/*if(srchcrt == null || srchcrt == "parkingtype")
	{
		if($("parkingStyleDv"))
		{
			var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
			var lenChkBox = arrChkBox.length;
			var strChkBox = "";
			var allChked = true;
			for(var i=0;i<lenChkBox;i++)
			{
				if(arrChkBox[i].id == "chkParkingStyleAll")
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					var valChkBox = arrChkBox[i].value;
					strChkBox = strChkBox + valChkBox + ':';
				}
				else if(arrChkBox[i].type == "checkbox")
				{
					allChked = false;    
				}
			}
			if(allChked == true)
			{
				strChkBox = "";
			}
			else if(strChkBox.charAt(strChkBox.length-1) == ':')
			{
				strChkBox = strChkBox.substr(0,eval(strChkBox.length-1));
			}
			setSearchCookie("parkingType",strChkBox);
		}
		else
			setSearchCookie("parkingType","");

		if(srchcrt != null)
		{
			return;
		}
	}*/
}
function setAllCookieValue(srchcrt)
{
	
	if(srchcrt == null)
	{
		if($("searchAddress"))
		{
			
			$("searchAddress").value = (trim(getSearchCookie("searchAddress")) == "")?"optional":trim(getSearchCookie("searchAddress"));
			$("searchAddress").className = "textboxDashHdN";
		}
		if($('searchCSZ'))
		{
			var cszFromCookie = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
			$('searchCSZ').value = trim(cszFromCookie).replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
			if(trim(getSearchCookie('city')) == "" && trim(getSearchCookie('zip')) == "")
			{
				for(var i=0;i<20;i++)
				{
					var idTxtObj = 'searchCSZ'+ eval(i+1);
					if($(idTxtObj) != null)
						$(idTxtObj).value = "";
				}
			}	
		}
		if($('searchMLS'))
		{
			$('searchMLS').value = "";
		}
	}	
	if(srchcrt == null || srchcrt == "price")
	{
		if($("minPrice"))
		{
			if(getSearchCookie("minPrice") != 0)
				$("minPrice").value = addCommas(getSearchCookie("minPrice"));
			else 
				$("minPrice").value = '';
		}
		if($("maxPrice"))
		{
			if(getSearchCookie("maxPrice") != 0)
				$("maxPrice").value = addCommas(getSearchCookie("maxPrice"));
			else 
				$("maxPrice").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "beds")
	{
		if(getSearchCookie("searchBeds") && $("searchBedsMin") && $("searchBedsMax"))
		{
			var beds = getSearchCookie("searchBeds");
			if(trim(beds) == "")
			{
				$("searchBedsMin").value = "";
				$("searchBedsMax").value = "";
			}
			else
			{
				var bdArr = beds.split("-");
				$("searchBedsMin").value = bdArr[0];
				$("searchBedsMax").value = bdArr[1];
			}
		}
		else
		{
			if($("searchBedsMin") && $("searchBedsMax"))
			{
				$("searchBedsMin").value = "";
				$("searchBedsMax").value = "";
			}
		}		
		
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{
		if(getSearchCookie("minSize") && $("minSize"))
		{
			$("minSize").value = getSearchCookie("minSize");
		}
		else if($("minSize"))
		{
			$("minSize").selectedIndex = 0;
		}
		if(getSearchCookie("maxSize") && $("maxSize"))
		{
			$("maxSize").value = getSearchCookie("maxSize");
		}
		else if($("maxSize"))
		{
			$("maxSize").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "baths")
	{
		if(getSearchCookie("searchBaths") && $("searchBathsMin") && $("searchBathsMax"))
		{
			var baths = getSearchCookie("searchBaths");
			if(trim(baths) == "")
			{
				$("searchBathsMin").value = "";
				$("searchBathsMax").value = "";
			}
			else
			{
				var bthArr = baths.split("-");
				$("searchBathsMin").value = bthArr[0];
				$("searchBathsMax").value = bthArr[1];
			}
		}
		else
		{
			if($("searchBathsMin") && $("searchBathsMax"))
			{
				$("searchBathsMin").value = "";
				$("searchBathsMax").value = "";
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		if(getSearchCookie("searchType") || trim(getSearchCookie("searchType")) == "")
		{
			if($("divPopUpSHType"))
			{
				var arrChkBox = $("divPopUpSHType").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("searchType");
				if(trim(strChkBox) == "")
				{
					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chbSHTypeAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chbSHTypeAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if(arrStrChkBox.in_array(valChkBox) !== false)
		    				{
		    					arrChkBox[i].checked = true;
		    				}
							else
							{
								arrChkBox[i].checked = false;
							}
		    			}
					}	
				}
			}
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{
		if(getSearchCookie("searchSortType") && $("searchSortType"))
		{
			$("searchSortType").value = getSearchCookie("searchSortType");
		}
		else if($("searchSortType"))
		{
			$("searchSortType").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{
		if(getSearchCookie("ckLFDate") && $("txtLFDate"))
		{
			$("txtLFDate").value = getSearchCookie("ckLFDate");
		}
		else if($("txtLFDate"))
		{
			$("txtLFDate").value = '';
		}
		if(getSearchCookie("ckLTDate") && $("txtLTDate"))
		{
			$("txtLTDate").value = getSearchCookie("ckLTDate");
		}
		else if($("txtLTDate"))
		{
			$("txtLTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "propstyle")
	{
		if(getSearchCookie("propStyle") || trim(getSearchCookie("propStyle")) == "")
		{
			if($("propStyleDv"))
			{
				var arrChkBox = $("propStyleDv").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("propStyle");
				if(trim(strChkBox) == "")
				{					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if((arrStrChkBox.in_array(valChkBox) !== false) && (arrChkBox[i].checked == false))
		    				{
		    					arrChkBox[i].checked = true;
		    				}
		    			}
					}	
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	/*if(srchcrt == null || srchcrt == "parkingtype")
	{
		if(getSearchCookie("parkingType") || trim(getSearchCookie("parkingType")) == "")
		{
			if($("parkingStyleDv"))
			{
				var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
				var lenChkBox = arrChkBox.length;
				var strChkBox = getSearchCookie("parkingType");
				if(trim(strChkBox) == "")
				{					
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkParkingStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}	
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkParkingStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox")
		    			{
		    				var valChkBox = arrChkBox[i].value;
		    				if((arrStrChkBox.in_array(valChkBox) !== false) && (arrChkBox[i].checked == false))
		    				{
		    					arrChkBox[i].checked = true;
		    				}
		    			}
					}	
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}*/
	
	if(srchcrt != null && srchcrt == "mlssource")
	{
		if(getSearchCookie("mlsSource") && $("mlsSource"))
		{
			$("mlsSource").value = getSearchCookie("mlsSource").replace(/[+]/g, ' ');
		}
		else if($("mlsSource"))
		{
			$("mlsSource").selectedIndex = 0;
		}
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "propstatus")
	{
		/*if(getSearchCookie("propStatus") && $("propStatus"))
		{
			$("propStatus").value = getSearchCookie("propStatus");
		}
		else if($("propStatus"))
		{
			//$("propStatus").selectedIndex = 0;
			len = $("propStatus").options.length;
			var j;
			var status = 0;
			var defaultStatus = "";
			if(len>0)
			{
				for(j=0;j<len;j++)
				{
					if($("propStatus").options[j].value == 'Active')
					{
						defaultStatus = $("propStatus").options[j].value;
						status = 1;
					}
					else if(status==0)
					{
						defaultStatus = $("propStatus").options[0].value;
					}
				}
			}
			$("propStatus").value = defaultStatus;
		}
		if(srchcrt != null)
		{
			return;
		}*/

		var status = getSearchCookie("propStatus");

		if(status != '')
		{
			if($('divPStatus'))
			{				
				var dataArr = status.split(":");
				chkbxArr = $A($('divPStatus').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{				
						if(node.type == "checkbox" && node.checked == true)
							node.checked = false;

						if(node.type == "checkbox" && dataArr.indexOf(node.value) != -1)
							node.checked = true;
					});			
			}
		}
		else
		{
			if($('divPStatus'))
			{
				var stat = 0;
				chkbxArr = $A($('divPStatus').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{
						if(node.type=="checkbox" && (node.id == 'Active'))
						{
							node.checked = true;
							stat = 1;
						}
						else
							node.checked = false;
					});
					
				if(stat == 0)
				{
					var unstat = 0;
					$A($('divPStatus').getElementsByTagName("input")).each(function(node)
					{
						if(node.type=="checkbox" && unstat == 0)
						{
							node.checked = true;
							unstat = 1;
						}
					});
				}
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "proptype")
	{		
		var types = getSearchCookie("propType");	

		if(types != '')
		{
			if($('divPType'))
			{
				var dataArr = types.split(":");
				chkbxArr = $A($('divPType').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{				
						if(node.type == "checkbox" && node.checked == true)
							node.checked = false;

						if(node.type == "checkbox" && dataArr.indexOf(node.value) != -1)
							node.checked = true;
					});			
			}
		}
		else
		{
			if($('divPType'))
			{
				chkbxArr = $A($('divPType').getElementsByTagName("input"));
				chkbxArr.each(
					function(node)
					{
						if(node.type=="checkbox" && (node.id == 'Single Family Residential' || node.id == 'Residential' || node.id == 'Single Family' || node.id == 'Single Family Homes'))
							node.checked = true;
						else
							node.checked = false;
					});			
			}
		}

		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "sqftp")
	{
		if(getSearchCookie("minPSize") && $("minPSize"))
		{
			$("minPSize").value = getSearchCookie("minPSize");
		}
		else if($("minPSize"))
		{
			$("minPSize").value = "";
		}
		if(getSearchCookie("maxPSize") && $("maxPSize"))
		{
			$("maxPSize").value = getSearchCookie("maxPSize");
		}
		else if($("maxPSize"))
		{
			$("maxPSize").value = "";
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "listdatep")
	{
		if(getSearchCookie("ckPLFDate") && $("txtPLFDate"))
		{
			$("txtPLFDate").value = getSearchCookie("ckPLFDate");
		}
		else if($("txtPLFDate"))
		{
			$("txtPLFDate").value = '';
		}
		if(getSearchCookie("ckPLTDate") && $("txtPLTDate"))
		{
			$("txtPLTDate").value = getSearchCookie("ckPLTDate");
		}
		else if($("txtPLTDate"))
		{
			$("txtPLTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	
	if(srchcrt != null && srchcrt == "listagent")
	{
		if(getSearchCookie("listAgentFnm") && $("txtAgtFName"))
		{
			$("txtAgtFName").value = getSearchCookie("listAgentFnm");
		}
		else if($("txtAgtFName"))
		{
			$("txtAgtFName").value = 'First Name';
		}
		
		if(getSearchCookie("listAgentLnm") && $("txtAgtLName"))
		{
			$("txtAgtLName").value = getSearchCookie("listAgentLnm");
		}
		else if($("txtAgtLName"))
		{
			$("txtAgtLName").value = 'Last Name';
		}
		if(srchcrt != null)
		{
			return;
		}		
	}	
	
	if(srchcrt != null && srchcrt == "lotsize")
	{		
		if(getSearchCookie("minLotSize") && $("minLotSize"))
		{
			$("minLotSize").value = getSearchCookie("minLotSize");
		}
		else if($("minLotSize"))
		{
			$("minLotSize").value = "";
		}
		
		if($("minLotSize") && $("minLotSize").value == "")
			$("minLotSize").selectedIndex = 0;
		
		if(getSearchCookie("maxLotSize") && $("maxLotSize"))
		{
			$("maxLotSize").value = getSearchCookie("maxLotSize");
		}
		else if($("maxLotSize"))
		{
			$("maxLotSize").value = "";
		}

		if($("maxLotSize") && $("maxLotSize").value == "")
			$("maxLotSize").selectedIndex = 0;
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	
	if(srchcrt != null && srchcrt == "age")
	{			
		if(getSearchCookie("fromAge") && $("txtAgeFrom"))
		{
			$("txtAgeFrom").value = getSearchCookie("fromAge");
		}
		else if($("txtAgeFrom"))
		{
			$("txtAgeFrom").value = '';
		}
		
		if(getSearchCookie("toAge") && $("txtAgeTo"))
		{
			$("txtAgeTo").value = getSearchCookie("toAge");
		}
		else if($("txtAgeTo"))
		{
			$("txtAgeTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "yearbuilt")
	{			
		if(getSearchCookie("fromYear") && $("txtYearBuiltFrom"))
		{
			$("txtYearBuiltFrom").value = getSearchCookie("fromYear");
		}
		else if($("txtYearBuiltFrom"))
		{
			$("txtYearBuiltFrom").value = '';
		}
		
		if(getSearchCookie("toYear") && $("txtYearBuiltTo"))
		{
			$("txtYearBuiltTo").value = getSearchCookie("toYear");
		}
		else if($("txtYearBuiltTo"))
		{
			$("txtYearBuiltTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}	
	
	if(srchcrt != null && srchcrt == "daysonmarket")
	{			
		if(getSearchCookie("marketDaysFrom") && $("txtDaysMarketFrom"))
		{
			$("txtDaysMarketFrom").value = getSearchCookie("marketDaysFrom");
		}
		else if($("txtDaysMarketFrom"))
		{
			$("txtDaysMarketFrom").value = '';
		}
		if(getSearchCookie("marketDaysTo") && $("txtDaysMarketTo"))
		{
			$("txtDaysMarketTo").value = getSearchCookie("marketDaysTo");
		}
		else if($("txtDaysMarketTo"))
		{
			$("txtDaysMarketTo").value = '';
		}
		
		if(srchcrt != null)
		{
			return;
		}
	}
			
	if(srchcrt != null && srchcrt == "garage")
	{	
		if(getSearchCookie("garage") && $("cmbGarage"))
		{
			$("cmbGarage").value = getSearchCookie("garage").replace(/[+]/g, ' ');
		}
		else if($("cmbGarage"))
		{
			$("cmbGarage").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}	

	if(srchcrt != null && srchcrt == "stories")
	{			
		if(getSearchCookie("stories") && $("txtStories"))
		{
			$("txtStories").value = getSearchCookie("stories");
		}
		else if($("txtStories"))
		{
			$("txtStories").value = '';
		}	
		if(srchcrt != null)
		{
			return;
		}
	}
	
	if(srchcrt != null && srchcrt == "schooldist")
	{			
		if(getSearchCookie("schooldist") && $("txtSchoolDist"))
		{
			$("txtSchoolDist").value = getSearchCookie("schooldist").replace(/[+]/g, ' ');
		}
		else if($("txtSchoolDist"))
		{
			$("txtSchoolDist").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "eleschool")
	{			
		if(getSearchCookie("eleSchool") && $("txtEleSchool"))
		{
			$("txtEleSchool").value = getSearchCookie("eleSchool").replace(/[+]/g, ' ');
		}
		else if($("txtEleSchool"))
		{
			$("txtEleSchool").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "midschool")
	{			
		if(getSearchCookie("midSchool") && $("txtMidSchool"))
		{
			$("txtMidSchool").value = getSearchCookie("midSchool").replace(/[+]/g, ' ');
		}
		else if($("txtMidSchool"))
		{
			$("txtMidSchool").value = '';	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "highschool")
	{			
		if(getSearchCookie("highSchool") && $("txtHighSchool"))
		{
			$("txtHighSchool").value = getSearchCookie("highSchool").replace(/[+]/g, ' ');
		}
		else if($("txtHighSchool"))
		{
			$("txtHighSchool").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "bankowned")
	{			
		if(getSearchCookie("bankowned") && $("chkBankOwned"))
		{
			if(getSearchCookie("bankowned") == "true")
				$("chkBankOwned").checked = true;
			else
				$("chkBankOwned").checked = false;
		}
		else if($("chkBankOwned"))
		{
			$("chkBankOwned").checked = false;	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "shortsales")
	{			
		if(getSearchCookie("shortsales") && $("chkShortSales"))
		{
			if(getSearchCookie("shortsales") == "true")
				$("chkShortSales").checked = true;
			else
				$("chkShortSales").checked = false;
		}
		else if($("chkShortSales"))
		{
			$("chkShortSales").checked = false;	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "listagtid")
	{			
		if(getSearchCookie("listagtid") && $("txtListAgtId"))
		{
			$("txtListAgtId").value = getSearchCookie("listagtid");
		}
		else if($("txtListAgtId"))
		{
			$("txtListAgtId").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "listoff")
	{			
		if(getSearchCookie("listoff") && $("txtListOff"))
		{
			$("txtListOff").value = getSearchCookie("listoff").replace(/[+]/g, ' ').replace("__",'#');
		}
		else if($("txtListOff"))
		{
			$("txtListOff").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleagtid")
	{			
		if(getSearchCookie("saleagtid") && $("txtSaleAgtId"))
		{
			$("txtSaleAgtId").value = getSearchCookie("saleagtid");
		}
		else if($("txtSaleAgtId"))
		{
			$("txtSaleAgtId").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleoff")
	{			
		if(getSearchCookie("saleoff") && $("txtSaleOff"))
		{
			$("txtSaleOff").value = getSearchCookie("saleoff").replace(/[+]/g, ' ');
		}
		else if($("txtSaleOff"))
		{
			$("txtSaleOff").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "roof")
	{			
		if(getSearchCookie("roof") && $("txtRoof"))
		{
			$("txtRoof").value = getSearchCookie("roof").replace(/[+]/g, ' ');
		}
		else if($("txtRoof"))
		{
			$("txtRoof").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "fire")
	{	
		if(getSearchCookie("fire") && $("cmbFire"))
		{
			$("cmbFire").value = getSearchCookie("fire");
		}
		else if($("cmbFire"))
		{
			$("cmbFire").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "pool")
	{	
		if(getSearchCookie("pool") && $("cmbPool"))
		{
			$("cmbPool").value = getSearchCookie("pool");
		}
		else if($("cmbPool"))
		{
			$("cmbPool").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
	
	if(srchcrt != null && srchcrt == "saledate")
	{			
		if(getSearchCookie("saleDateFrom") && $("txtSFDate"))
		{
			$("txtSFDate").value = getSearchCookie("saleDateFrom");
		}
		else if($("txtSFDate"))
		{
			$("txtSFDate").value = '';
		}
		if(getSearchCookie("saleDateTo") && $("txtSTDate"))
		{
			$("txtSTDate").value = getSearchCookie("saleDateTo");
		}
		else if($("txtSTDate"))
		{
			$("txtSTDate").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "saleprice")
	{			
		if(getSearchCookie("salePriceFrom") && $("txtSalePriceFrom"))
		{
			$("txtSalePriceFrom").value = getSearchCookie("salePriceFrom");
		}
		else if($("txtSalePriceFrom"))
		{
			$("txtSalePriceFrom").value = '';
		}
		if(getSearchCookie("salePriceTo") && $("txtSalePriceTo"))
		{
			$("txtSalePriceTo").value = getSearchCookie("salePriceTo");
		}
		else if($("txtSalePriceTo"))
		{
			$("txtSalePriceTo").value = '';
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt != null && srchcrt == "saleagent")
	{
		if(getSearchCookie("saleAgentFnm") && $("txtSaleAgentFname"))
		{
			$("txtSaleAgentFname").value = getSearchCookie("saleAgentFnm");
		}
		else if($("txtSaleAgentFname"))
		{
			$("txtSaleAgentFname").value = 'First Name';
		}
		if(getSearchCookie("saleAgentLnm") && $("txtSaleAgentLname"))
		{
			$("txtSaleAgentLname").value = getSearchCookie("saleAgentLnm");
		}
		else if($("txtSaleAgentLname"))
		{
			$("txtSaleAgentLname").value = 'Last Name';
		}
		if(srchcrt != null)
		{
			return;
		}		
	}
	if(srchcrt != null && srchcrt == "area")
	{			
		if(getSearchCookie("area") && $("txtArea"))
		{
			$("txtArea").value = getSearchCookie("area");
		}
		else if($("txtArea"))
		{
			$("txtArea").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt != null && srchcrt == "polygon")
	{			
		if(getSearchCookie("polygon") && $("txtPolygon"))
		{
			$("txtPolygon").value = getSearchCookie("polygon").replace(/\+/g, " ");
		}
		else if($("txtPolygon"))
		{
			$("txtPolygon").value = '';	
		}		
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt != null && srchcrt == "powerradial")
	{	
		if(getSearchCookie("powerradial") && $("cmbradial"))
		{
			$("cmbradial").value = getSearchCookie("powerradial");
		}
		else if($("cmbradial"))
		{
			$("cmbradial").selectedIndex = 0;
		}
		
		if(srchcrt != null)
		{
			return;
		}		
	}
}

function funGetSearchQueryString()
{
	var lfDate = "";
	var ltDate = "";

	var tempDate = escape(trim(getSearchCookie("ckLFDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		lfDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	var tempDate = escape(trim(getSearchCookie("ckLTDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		ltDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	searchQueryString = "";
	searchQueryString = searchQueryString + "qckWidgetUpdate=1";
	searchQueryString = searchQueryString + "&address=" 		+ 	escape(getSearchCookie("searchAddress"));
	if(getSearchCookie("city") && getSearchCookie("city") != "")
	{
		searchQueryString = searchQueryString + "&city=" 			+ 	escape(getSearchCookie("city"));
	}
	if(getSearchCookie("state") && getSearchCookie("state") != "")
	{
		searchQueryString = searchQueryString + "&state=" 			+ 	escape(getSearchCookie("state"));
	}
	if(getSearchCookie("zip") && getSearchCookie("zip") != "")
	{
		searchQueryString = searchQueryString + "&zip=" 			+ 	escape(getSearchCookie("zip"));
	}
	searchQueryString = searchQueryString + "&minprice=" 		+ 	escape(money2num(getSearchCookie("minPrice")));
	searchQueryString = searchQueryString + "&maxprice=" 		+ 	escape(money2num(getSearchCookie("maxPrice")));
	searchQueryString = searchQueryString + "&beds=" 			+ 	escape(getSearchCookie("searchBeds"));
	searchQueryString = searchQueryString + "&minsqft=" 		+ 	escape(getSearchCookie("minSize"));
	searchQueryString = searchQueryString + "&maxsqft=" 		+ 	escape(getSearchCookie("maxSize"));
	searchQueryString = searchQueryString + "&baths=" 			+ 	escape(getSearchCookie("searchBaths"));
	searchQueryString = searchQueryString + "&searchType=" 		+ 	escape(getSearchCookie("searchType"));
	searchQueryString = searchQueryString + "&searchSortType=" 	+ 	escape(trim(getSearchCookie("searchSortType"))==""?"ph":trim(getSearchCookie("searchSortType")));
	searchQueryString = searchQueryString + "&lfDate="			+ 	escape(lfDate);
	searchQueryString = searchQueryString + "&ltDate="			+ 	escape(ltDate);
	searchQueryString = searchQueryString + "&county="			+ 	escape(trim(getSearchCookie("county")));
	
	var setPropStyle  = getSearchCookie("propStyle");
	setPropStyle 	  = setPropStyle.replace(":",",");
	searchQueryString = searchQueryString + "&propStyle="		+ 	escape(trim(setPropStyle));
	
	if(trim(getSearchCookie("garage")) == 'All')
		searchQueryString = searchQueryString + "&garage=";
	else
		searchQueryString = searchQueryString + "&garage="		+ 	escape(trim(getSearchCookie("garage")));
		
	if(trim(getSearchCookie("neighborhood")) == 'all')
		searchQueryString = searchQueryString + "&neighborhood=";
	else
		searchQueryString = searchQueryString + "&neighborhood="	+ 	escape((trim(getSearchCookie("neighborhood"))));
	
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");

	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			searchQueryString = searchQueryString + "&mlsSource="	+ 	escape((trim(strAgtMlsSrc)));
		else
			searchQueryString = searchQueryString + "&mlsSource=";
		searchQueryString = searchQueryString + "&aid="			+ 	escape((trim(aid)));
	}	
	if(latLong)
		searchQueryString = searchQueryString+"&propLatitude="+latLong.lat+"&propLongitude="+latLong.lng;
	return searchQueryString;
}

function funGetAdvSearchQueryString()
{
	var lfDate = "";
	var ltDate = "";

	var tempDate = escape(trim(getSearchCookie("ckLFDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		lfDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	var tempDate = escape(trim(getSearchCookie("ckLTDate")));
	if (tempDate != "")
	{
		var arrTempDate = tempDate.split ("-");
		ltDate = arrTempDate[2] + "-" + arrTempDate[0] + "-" + arrTempDate[1];
	}

	searchQueryString = new StringBuffer();
	searchQueryString.append("qckWidgetUpdate=1");
	searchQueryString.append("&minprice=" 		+ 	escape(money2num(getSearchCookie("minPrice"))));
	searchQueryString.append("&maxprice=" 		+ 	escape(money2num(getSearchCookie("maxPrice"))));
	searchQueryString.append("&beds=" 			+ 	escape(getSearchCookie("searchBeds")));
	searchQueryString.append("&minsqft=" 		+ 	escape(getSearchCookie("minSize")));
	searchQueryString.append("&maxsqft=" 		+ 	escape(getSearchCookie("maxSize")));
	searchQueryString.append("&baths=" 			+ 	escape(getSearchCookie("searchBaths")));
	searchQueryString.append("&searchType=" 		+ 	escape(getSearchCookie("searchType")));
	searchQueryString.append("&searchSortType=" 	+ 	escape(trim(getSearchCookie("searchSortType"))==""?"ph":trim(getSearchCookie("searchSortType"))));
	searchQueryString.append("&lfDate="			+ 	escape(lfDate));
	searchQueryString.append("&ltDate="			+ 	escape(ltDate));
	searchQueryString.append("&county="			+ 	escape(trim(getSearchCookie("county"))));
		
	if(trim(getSearchCookie("neighborhood")) == 'all')
		searchQueryString.append("&neighborhood=");
	else
		searchQueryString.append("&neighborhood="	+ 	escape((trim(getSearchCookie("neighborhood")))));

	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	var ouid = myQs.get("ouid");
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			searchQueryString.append("&mlsSource="	+ 	escape((trim(strAgtMlsSrc))));
		else
			searchQueryString.append("&mlsSource=");
		searchQueryString.append("&aid="			+ 	escape((trim(aid))));
	}	
	else if(frm != null && trim(frm) == 'frch' && ouid != null && trim(ouid) != "")
	{
		if(typeof(strAgtMlsSrc) != 'undefined' && strAgtMlsSrc != null && strAgtMlsSrc.length > 0)
			searchQueryString.append("&mlsSource="	+ 	escape((trim(strAgtMlsSrc))));
		else
			searchQueryString.append("&mlsSource=");
		searchQueryString.append("&ouid="			+ 	escape((trim(ouid))));
	}	
	
	return searchQueryString.toString();
}

function funCompareSearchCookie()
{
	if($('searchCSZ') != null)
	{
		var cszFromCookie = setCSZValue(getSearchCookie("city"), getSearchCookie("state"), getSearchCookie("zip"));
		$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, "").replace (/\s+$/g, "").replace (/\s+/g, " ");
		if (trim(cszFromCookie).toUpperCase() != trim($('searchCSZ').value).toUpperCase())
		{
			return 1;		
		}
	}		
	if(($("searchAddress") != null) && (getSearchCookie("searchAddress") != $F("searchAddress").replace('optional','')))
	{
		return 1;
	}
	if($("minPrice") && (getSearchCookie("minPrice") != money2num($F("minPrice"))))
	{
		return true;
	}
	if($("maxPrice") && (getSearchCookie("maxPrice") != money2num($F("maxPrice"))))
	{
		return true;
	}
	if($("searchBedsMin") && $("searchBedsMax") && trim(getSearchCookie("searchBeds")) != "" && (trim(getSearchCookie("searchBeds")) != trim($F("searchBedsMin"))+"-"+trim($F("searchBedsMax"))))
	{
		return true;
	}
	if($("minSize") && ((trim(getSearchCookie("minSize")) == "" && $F("minSize") != 0) || ((trim(getSearchCookie("minSize")) != "") && (trim(getSearchCookie("minSize")) != $F("minSize")))))
	{
		return true;
	}
	if($("maxSize") && ((trim(getSearchCookie("maxSize")) == "" && $F("maxSize") != 0) || ((trim(getSearchCookie("maxSize")) != "") && (trim(getSearchCookie("maxSize")) != $F("maxSize")))))
	{
		return true;
	}
	if($("searchBathsMin") && $("searchBathsMax") && trim(getSearchCookie("searchBaths")) != "" && (trim(getSearchCookie("searchBaths")) != trim($F("searchBathsMin"))+"-"+trim($F("searchBathsMax"))))
	{
		return true;
	}
	if($("divPopUpSHType") != null)
	{
		var arrChkBox = $("divPopUpSHType").getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;
		var strChkBox = getSearchCookie("searchType");
		if(trim(strChkBox) == "")
		{
			for(var i=0;i<lenChkBox;i++)
			{
		    	if(arrChkBox[i].id == "chbSHTypeAll")
		    	{
		    		continue;
		    	}
		    	if((arrChkBox[i].type == "checkbox") && (arrChkBox[i].checked === false))
		    	{
		    		return true;
		    	}
			}	
		}
		else
		{
			var arrStrChkBox = strChkBox.split(":");
			for(var i=0;i<lenChkBox;i++)
			{
		    	if(arrChkBox[i].type == "checkbox")
		    	{
		    		var valChkBox = arrChkBox[i].value;
		    		if(arrStrChkBox.in_array(valChkBox) != false && arrChkBox[i].checked == false)
		    		{
		    			return true;
		    		}
		    	}
			}	
		}
	}
	if($("searchSortType") && (((trim(getSearchCookie("searchSortType"))!= "") && (getSearchCookie("searchSortType") !== $F("searchSortType"))) || (((trim(getSearchCookie("searchSortType")) == "") && ($F("searchSortType") != "ph")))))
	{
		return true;
	}
	return false;
}

function funCheckContradict()
{
	var retValue;
	var geoCbFn = function(reqObj)
	{
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if($(idTxtObj) != null)
				$(idTxtObj).value = "";
		}
		var geoResponse = reqObj.responseText;
		var allCity = "";
		var allState = "";
		var allZip = "";
		var geoArrResponse = eval(geoResponse);
		var boolGetSingleCity = false;
		for(var i=0;i<geoArrResponse.length;i++)
		{
			if(geoArrResponse[i].status == 0)
			{	
				boolGetSingleCity = true;
				var geoCity = geoArrResponse[i].city;
				allCity += geoCity + '|';
				var geoState = geoArrResponse[i].state;
				allState += geoState + '|';
				var geoZip = geoArrResponse[i].zip;
				allZip += geoZip + '|';
				var geoAddress = geoArrResponse[i].address;
				setSearchCookie("searchAddress",geoAddress);
				$("searchAddress").value = geoAddress;
				
				
				setSearchCookie("county","");
				setSearchCookie("neighborhood","");
				arrDataCounty.length = 0;
				arrDataNeighborHood.length = 0;
				headerContent("county");
				headerContent("neighborhood");
				
				var now = new Date();
				now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
				var latLongStr = "[{'lat':'"+geoArrResponse[i].latitude+"','lng':'"+geoArrResponse[i].longitude+"'}]";
				setCookie("latLongCk",latLongStr,now);
				latLong = eval(getCookie("latLongCk"))[0];
				if(trim(getCookie("lpid")) != "" && isContradict === 1)
				{
					setCookie("lpid","");
					if(window.location.pathname.indexOf("dashboard") > 0)
					{
						funCloseWidget("divChild1X2");
						funCloseWidget("divChild1X3");
						funCloseWidget("divChild2X1");
						funCloseWidget("divChild2X2");
						funCloseWidget("divChild2X3");
						funCloseWidget("divChild3X1");
						funCloseWidget("divChild3X2");
						funCloseWidget("divChild3X3");
					}	
				}
			}
		}
		if(boolGetSingleCity == false)
		{			
			if(geoArrResponse.length > 1)
			{
				alert('Sorry, We couldn\'t find any location from "' + $('searchCSZ').value + '"');
			}
			else
			{				
				alert('Sorry, We couldn\'t find a location for "' + geoArrResponse[0].originaladdress + '"');
				setSearchCookie("searchAddress","");
				if($("searchAddress")) $("searchAddress").value = "optional";
				if(typeof(srTabs) != "undefined" && srTabs.getTab(0).get("active"))
				{
					srTabs.set('activeTab',srTabs.getTab(0),true);
					srTabs.getTab(0).refresh();
				}
			}
			retValue = "0";
			return;
		}
		else
		{
			if (allCity != "")
			{
				setSearchCookie ("city", allCity.substr(0, allCity.length-1));			
			}
			if (allState != "")
			{
				setSearchCookie ("state", allState.substr(0, allState.length-1));			
			}
			if (allZip != "")
			{
				setSearchCookie ("zip", allZip.substr(0, allZip.length-1));			
			}
			$('searchCSZ').value = setCSZValue(getSearchCookie('city'),getSearchCookie('state'),getSearchCookie('zip'));
			retValue = "2";
			return;
		}	
	}
	var isContradict = funCompareSearchCookie();
	if(isContradict === 1)
	{
		var geoUrl = "/classes/getCSZ.php";
		var geoAddress = "";
		if((trim($("searchAddress").value).toLowerCase() != "optional") && (trim($('searchCSZ').value).search(';') === -1))
		{
			geoAddress = $("searchAddress").value;
		}
		var geoQueryString = "csz="+escape($('searchCSZ').value)+"&address="+escape(geoAddress);
		ajaxRequest(geoUrl,geoQueryString,geoCbFn,false);
		return retValue;
	}
	else
	{
		return "1";
	}	
}

function CompareMinMax(srchcrt)
{
	if(srchcrt == null || srchcrt == "price")
	{
		var minP = Number(money2num($('minPrice').value));	
		var maxP = Number(money2num($('maxPrice').value));	
	
		if(minP<0 || maxP<0)
		{
			alert("Please enter valid price range");
			$('minPrice').value = '';
			$('maxPrice').value = '';
			return false;
		}
		if((minP>maxP) && (minP != "" && maxP != ""))
		{
			alert("Please enter valid price range");
			$('minPrice').value = '';
			$('maxPrice').value = '';
			return false;
		}
		if(srchcrt != null)
		{
			return;
		}
	}

	if(srchcrt == null || srchcrt == "beds")
	{
		var minbd = trim($('searchBedsMin').value);
		var maxbd = trim($('searchBedsMax').value);

		if(isNaN(minbd))
		{
			alert("Please enter numeric value for min beds");
			$('searchBedsMin').value = '';
			return false;
		}

		if(isNaN(maxbd))
		{
			alert("Please enter numeric value for max beds");
			$('searchBedsMax').value = '';
			return false;
		}

		if(minbd.include("."))
		{
			var ptLen = minbd.substr(minbd.indexOf(".")+1,minbd.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for min beds");
				$('searchBedsMin').value = '';
				return false;
			}
		}

		if(maxbd.include("."))
		{
			var ptLen = maxbd.substr(maxbd.indexOf(".")+1,maxbd.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for max beds");
				$('searchBedsMax').value = '';
				return false;
			}
		}

		minbd = Number(minbd);
		maxbd = Number(maxbd);

		if(minbd<0 || maxbd<0)
		{
			alert("Please enter valid beds range");
			$('searchBedsMin').value = '';
			$('searchBedsMax').value = '';
			return false;
		}
		if((minbd>maxbd) && (minbd != "" && maxbd != ""))
		{
			alert("Please enter valid beds range");
			$('searchBedsMin').value = '';
			$('searchBedsMax').value = '';
			return false;
		}
	}

	if(srchcrt == null || srchcrt == "baths")
	{
		var minbth = trim($('searchBathsMin').value);
		var maxbth = trim($('searchBathsMax').value);

		if(isNaN(minbth))
		{
			alert("Please enter numeric value for min baths");
			$('searchBathsMin').value = '';
			return false;
		}

		if(isNaN(maxbth))
		{
			alert("Please enter numeric value for max baths");
			$('searchBathsMax').value = '';
			return false;
		}

		if(minbth.include("."))
		{
			var ptLen = minbth.substr(minbth.indexOf(".")+1,minbth.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for min baths");
				$('searchBathsMin').value = '';
				return false;
			}
		}

		if(maxbth.include("."))
		{
			var ptLen = maxbth.substr(maxbth.indexOf(".")+1,maxbth.length).length;
			if(ptLen>2)
			{
				alert("Only 2 digits allowed after decimal point for max baths");
				$('searchBathsMax').value = '';
				return false;
			}
		}

		minbth = Number(minbth);
		maxbth = Number(maxbth);

		if(minbth<0 || maxbth<0)
		{
			alert("Please enter valid baths range");
			$('searchBathsMin').value = '';
			$('searchBathsMax').value = '';
			return false;
		}
		if((minbth>maxbth) && (minbth != "" && maxbth != ""))
		{
			alert("Please enter valid baths range");
			$('searchBathsMin').value = '';
			$('searchBathsMax').value = '';
			return false;
		}
	}

	if(srchcrt == null || srchcrt == "sqft")	
	{
		var sqftMin = Number($("minSize").value);
		var sqftMax = Number($("maxSize").value);
		if(sqftMin>sqftMax && sqftMax != 0)
		{
			alert("Please select valid range for square feet");
			return false;
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "listdate")
	{
		if(trim($("txtLFDate").value) != "" && trim($("txtLTDate").value) != "")
		{
			var valLFDate = $("txtLFDate").value;
			var arrLFDate = valLFDate.split("-");		
			var objLFDate = new Date();
			objLFDate.setYear(arrLFDate[2]);
			objLFDate.setMonth(arrLFDate[0]);
			objLFDate.setDate(arrLFDate[1]);
			var tsLFDate = objLFDate.getTime()
			var valLTDate = $("txtLTDate").value;
			var arrLTDate = valLTDate.split("-");		
			var objLTDate = new Date();
			objLTDate.setYear(arrLTDate[2]);
			objLTDate.setMonth(arrLTDate[0]);
			objLTDate.setDate(arrLTDate[1]);
			var tsLTDate = objLTDate.getTime()
			if(tsLFDate > tsLTDate)
			{
				alert("To date should not be less than From date.");
				$('txtLFDate').value = '';
				$('txtLTDate').value = '';
				return false;
			}
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	return true;
}

function headerContent(srchcrt)
{
	if(srchcrt != null && srchcrt == "mls")
	{
		var ihMLSLabel = "MLS # ";
		var ihMLSValue = "";
		if(trim(getSearchCookie('mlsno')) != "")
		{
			var ihMLSValue = getSearchCookie('mlsno'); 
		}
		if($("divSHMLS") != null)
		{
			if($("divSHMLS").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHMLS").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihMLSLabel;
				}
				var objSpanValue = $("divSHMLS").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihMLSValue) != ""))
				{
					objSpanValue.innerHTML = ihMLSValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "county")
	{
		var ihCountyLabel = "County: ";
		var ihCountyValue = "";
		if((getSearchCookie("county") != null) && (trim(getSearchCookie("county")) != ""))
		{
			ihCountyValue = getSearchCookie("county"); 
		}
		else
		{
			ihCountyValue = 'any';
		}
		if($("divSHCounty") != null)
		{
			if($("divSHCounty").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHCounty").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihCountyLabel;
				}
				var objSpanValue = $("divSHCounty").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihCountyValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihCountyValue,20);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "neighborhood")
	{
		var ihNeighborhoodLabel = "Neighborhood: ";
		var ihNeighborhoodValue = new StringBuffer();
		if((getSearchCookie("neighborhood") != null) && (trim(getSearchCookie("neighborhood")) != ""))
		{
			var strCKNH = getSearchCookie("neighborhood");
			var arrCKNH = strCKNH.split(',');
			var lenArrCKNH = arrCKNH.length;
			for(var i=0;i<lenArrCKNH;i++)
			{
				ihNeighborhoodValue.append(arrCKNH[i] + ',');
			}
			ihNeighborhoodValue = ihNeighborhoodValue.toString();
			if(ihNeighborhoodValue.charAt(ihNeighborhoodValue.length-1) == ',')
			{
				ihNeighborhoodValue = ihNeighborhoodValue.substr(0,eval(ihNeighborhoodValue.length-1));
			}
		}
		else
		{
			ihNeighborhoodValue =  ihNeighborhoodValue + 'any';
		}
		if($("divSHNeighborHood") != null)
		{
			if($("divSHNeighborHood").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHNeighborHood").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihNeighborhoodLabel;
				}
				var objSpanValue = $("divSHNeighborHood").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihNeighborhoodValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihNeighborhoodValue,15);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if((srchcrt == null || srchcrt == "price") && $('minPrice') && $('maxPrice'))
	{	
		var ihPriceLabel = "Price: ";
		var ihPriceValue = "";
		var minP = Number(money2num(getSearchCookie("minPrice")));
		var maxP = Number(money2num(getSearchCookie("maxPrice")));	
		if(minP != 0 || maxP != 0)
		{
			if(minP != 0)
			{
				minP = num2money($('minPrice').value,'$','minPrice',false);
				ihPriceValue = ihPriceValue + minP+" to ";
			}
			else
			{
				ihPriceValue = ihPriceValue + "No Min to ";
			}
			if(maxP != 0)
			{
				maxP = num2money($('maxPrice').value,'$','maxPrice',false);
				ihPriceValue = ihPriceValue + maxP;
			}
			else
			{
				ihPriceValue = ihPriceValue + "No Max";
			}
		}
		else
		{
			ihPriceValue = ihPriceValue + "any";
		}
		if($("divSHPrice") != null)
		{
			if($("divSHPrice").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHPrice").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihPriceLabel;
				}
				var objSpanValue = $("divSHPrice").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihPriceValue) != ""))
				{
					objSpanValue.innerHTML = ihPriceValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}
	if(srchcrt == null || srchcrt == "beds")
	{
		var ihBedsLabel = "Beds: ";
		var ihBedsValue = "";
		var searchBeds = getSearchCookie("searchBeds");
		if(trim(searchBeds) == "")
			ihBedsValue = ihBedsValue + "any";
		else
		{
			var bdArr = searchBeds.split("-");

			if(bdArr[0] != "" && bdArr[1] != "")
				ihBedsValue = bdArr[0] + " to " + bdArr[1];
			else if(bdArr[0] != "")
				ihBedsValue = bdArr[0] + " to No Max";
			else
				ihBedsValue = "No Min to " + bdArr[1];
		}
		if($("divSHBeds") != null)
		{
			if($("divSHBeds").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHBeds").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihBedsLabel;
				}
				var objSpanValue = $("divSHBeds").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihBedsValue) != ""))
				{
					objSpanValue.innerHTML = ihBedsValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}		
	if(srchcrt == null || srchcrt == "baths")
	{
		var ihBathsLabel = "Baths: ";
		var ihBathsValue = "";
		var searchBaths = getSearchCookie("searchBaths");
		if(trim(searchBaths) == "")
			ihBathsValue = ihBathsValue + "any";
		else
		{
			var bthArr = searchBaths.split("-");

			if(bthArr[0] != "" && bthArr[1] != "")
				ihBathsValue = bthArr[0] + " to " + bthArr[1];
			else if(bthArr[0] != "")
				ihBathsValue = bthArr[0] + " to No Max";
			else
				ihBathsValue = "No Min to " + bthArr[1];
		}

		if($("divSHBaths") != null)
		{
			if($("divSHBaths").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHBaths").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihBathsLabel;
				}
				var objSpanValue = $("divSHBaths").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihBathsValue) != ""))
				{
					objSpanValue.innerHTML = ihBathsValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sqft")
	{
		var ihSqftLabel = "Sqft: ";
		var ihSqftValue = "";
		var sqftMin = Number(getSearchCookie("minSize"));
		var sqftMax = Number(getSearchCookie("maxSize"));
		if((sqftMax != "0") || (sqftMin > 0 && sqftMax == 0))
		{
			if (sqftMin > 0 || (sqftMax > 0 && sqftMin == 0))
				ihSqftValue = ihSqftValue + sqftMin + ' - ';
			if (sqftMax > 0)
				ihSqftValue = ihSqftValue + sqftMax;
			if (sqftMax == 0)
				ihSqftValue = ihSqftValue + 'No Max';
		}
		else
		{
			ihSqftValue = ihSqftValue +  "any";
		}
		if($("divSHSqft") != null)
		{
			if($("divSHSqft").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHSqft").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihSqftLabel;
				}
				var objSpanValue = $("divSHSqft").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihSqftValue) != ""))
				{
					objSpanValue.innerHTML = ihSqftValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "listdate")
	{
		var ihListDateLabel = "List Date: ";
		var ihListDateValue = "";
		var valLFDate = getSearchCookie("ckLFDate");
		var valLTDate = getSearchCookie("ckLTDate");
		if(trim(valLFDate) != "" || trim(valLTDate) != "")
		{
			if(trim(valLFDate) != "")
			{
				ihListDateValue = ihListDateValue + "From "+valLFDate;
			}
			if(trim(valLFDate) != "" && trim(valLTDate) != "")
			{
				ihListDateValue = ihListDateValue + " To "+valLTDate;
			}
			else if(trim(valLTDate) != "")
			{
				ihListDateValue = ihListDateValue + " : UpTo "+valLTDate;
			}
		}
		else
		{
			ihListDateValue = ihListDateValue + "any";
		}
		if($("divSHListDate") != null)
		{
			if($("divSHListDate").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHListDate").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihListDateLabel;
				}
				var objSpanValue = $("divSHListDate").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihListDateValue) != ""))
				{
					objSpanValue.innerHTML = ihListDateValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "type")
	{
		var ihTypeLabel = "Type: ";
		var ihTypeValue = "";
		var valSearchType = getSearchCookie("searchType");
		if(trim(valSearchType) != "")
		{
			var arrValSearchType = valSearchType.split(':');
			var lenValSearchType = arrValSearchType.length;
			for(var i=0;i<lenValSearchType;i++)
			{
				var keySearchTypeVal = arrValSearchType[i];
				if(trim(keySearchTypeVal) != "")
				{
					ihTypeValue = ihTypeValue + arrValSearchType[keySearchTypeVal]+',';
				}	
			}
			if(ihTypeValue.charAt(ihTypeValue.length-1) == ',')
			{
				ihTypeValue = ihTypeValue.substr(0,eval(ihTypeValue.length-1));
			}
		}
		else
		{
			ihTypeValue = ihTypeValue + "all";
		}
		if($("divSHType") != null)
		{
			if($("divSHType").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHType").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihTypeLabel;
				}
				var objSpanValue = $("divSHType").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihTypeValue) != ""))
				{
					objSpanValue.innerHTML = funWrapText(ihTypeValue,15);
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}	
	if(srchcrt == null || srchcrt == "sortby")
	{
		var ihSortTypeLabel = "Sort By: ";
		var ihSortTypeValue = "";
		var sortType = getSearchCookie("searchSortType");
		if(trim(sortType) == "" || sortType == "ph")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Price High to Low";
		}		
		else if(sortType == "pl")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Price Low to High";
		}	
		else if(sortType == "brh")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Beds High to Low";
		}		
		if(sortType == "brl")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Beds Low to High";
		}	
		else if(sortType == "bah")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Baths High to Low";
		}		
		else if(sortType == "bal")
		{ 
			ihSortTypeValue = ihSortTypeValue + "Baths Low to High";
		}
		if($("divSHSortBy") != null)
		{
			if($("divSHSortBy").getElementsByTagName('a')[0] != null)
			{
				var objSpanLabel = $("divSHSortBy").getElementsByTagName('a')[0].getElementsByTagName('span')[0];
				if(objSpanLabel != null)
				{
					objSpanLabel.innerHTML = ihSortTypeLabel;
				}
				var objSpanValue = $("divSHSortBy").getElementsByTagName('a')[0].getElementsByTagName('span')[1];
				if((objSpanValue != null) && (trim(ihSortTypeValue) != ""))
				{
					objSpanValue.innerHTML = ihSortTypeValue;
				}
			}	
		}
		if(srchcrt != null)
		{
			return;
		}
	}		
}
function funUnchkAllChkBox(objChkBox) 
{
	if(($('chbSHNHAll').checked == true) && (objChkBox.checked == false))
	{
		$('chbSHNHAll').checked = false;
	}
}
function funSetSHNHAll(from)
{
	if(typeof(from)!="undefined")
	{
		divId = "divNHood";
		chkAllId = "chbRSNHAll";
	}
	else
	{
		divId = "divSHDataNeighborHood";
		chkAllId = "chbSHNHAll";
	}
	var arrChkBox = $(divId).getElementsByTagName("input");
	var lenChkBox = arrChkBox.length;
	for(var i=0;i<lenChkBox;i++)
	{
		if(arrChkBox[i].id == chkAllId)
		{
		 	continue;
		}
	    if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
	    {
	    	arrChkBox[i].checked = true;
	    }
	    else if(arrChkBox[i].type == "checkbox")
	    {
    		arrChkBox[i].checked = false;
	    }
	}
}
function funSetSHTypeAll(type)
{
	if(typeof(type)!="undefined")
	{
		divId = "divRSType";
		chkAllId = "RSchbSHTypeAll";
	}
	else
	{
		divId = "divPopUpSHType";
		chkAllId = "chbSHTypeAll";
	}
	if($(divId))
	{
		var	arrChkBox  = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;
		for(var i=0;i<lenChkBox;i++)
		{
			if(arrChkBox[i].id == chkAllId)
			{
				continue;
			}
			if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = true;
			}
			else if(($(chkAllId).checked == false) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = false;
			}
		}
	}
}

function funCloseAdvanceSearch(srchcrt,page)
{	
	if($("divSHCounty")==null)
	{
		return;
	}
	
	Element.removeClassName($("divSHCounty").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHCounty").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHCounty").style.display = "none";

	Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHNeighborHood").style.display 	= "none";
	
	if($("divPopUpSHPrice"))
	{
		Element.removeClassName($("divSHPrice").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHPrice").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHPrice").style.display = "none";
	}

	if($("divSHMultiCity") != null)
	{
		Element.removeClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHMultiCity").style.display = "none";
	}
	
	if($("divPopUpSHBeds"))
	{
		Element.removeClassName($("divSHBeds").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHBeds").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHBeds").style.display = "none";
	}
	
	if($("divPopUpSHBaths"))
	{
		Element.removeClassName($("divSHBaths").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHBaths").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHBaths").style.display = "none";
	}
	
	if($("divPopUpSHSqft"))
	{
		Element.removeClassName($("divSHSqft").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHSqft").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divPopUpSHSqft").style.display = "none";
	}
	
	Element.removeClassName($("divSHListDate").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHListDate").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHListDate").style.display = "none";
	
	Element.removeClassName($("divSHType").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHType").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHType").style.display = "none";
	
	Element.removeClassName($("divSHMLS").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHMLS").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHMLS").style.display = "none";
	
	Element.removeClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
	Element.addClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
	$("divPopUpSHSortBy").style.display = "none";

	if($("divSaveSearch"))
	{
		Element.removeClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkAdvanceSearch');
		$("divSaveSearch").style.display = "none";
	}

	if($("divSHPowerSortBy"))
	{
		Element.removeClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
		Element.addClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
	}
	
	if($("divPopUpSHPower"))
		$("divPopUpSHPower").style.display = "none";
	
	if($("divPopUpSHPropStyle")) $("divPopUpSHPropStyle").style.display = "none";
	if($("divPopUpSHGarage")) $("divPopUpSHGarage").style.display = "none";
	
	$("divPopUpSHMLSInfo").style.visibility = "hidden";
	$("divPopUpSHControls").style.display = "none";
	
	$("divContainerAdvanceSearch").style.display = "none";
	$("divContainerAdvanceSearch").style.left = "-100px";
	$("divContainerAdvanceSearch").style.top = "-100px";
	
	if(srchcrt != null)
	{
		setAllCookieValue(srchcrt);
	}
}
function funSaveAdvanceSearch(srchcrt,page)
{
	if(srchcrt == "multicity")
	{
		var boolAllCityBlank = true;
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) != "")
			{
				boolAllCityBlank = false;
				break;
			}
		}
		if (boolAllCityBlank == true)
		{
			alert("Please specify either City & State or Zip for atleast one.");
			return false;
		}
		var allCSZ = "";
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) == "")
			{
				continue;
			}
			else
			{
				allCSZ += trim($(idTxtObj).value.replace(/;/g,'')) + ';';
			}
		}
		$('searchCSZ').value = allCSZ.substr(0, allCSZ.length-1);
		funCloseAdvanceSearch();
		return true;
	}
	if(srchcrt == "mls")
	{
		if(trim($("searchMLS").value) == "")
		{
			alert("Please input MLS number to search.");
			return false;
		}
		searchByMlsNo();
		return true;
	}
	if(srchcrt == "more")
	{
		if(CompareMinMax(null) === false)
		{
			return false;
		}
		setAllToCookie("sqft");
		setAllToCookie("listdate");
		setAllToCookie("county");
		if(bkTheme == 'metrobrokers')
		{
			setAllToCookie("propstyle");
			//setAllToCookie("parkingtype");
			setAllToCookie("garage");
		}
		funCloseAdvanceSearch();
		if(bkTheme == 'metrobrokers'){
			//fromSubmit();
			//alert('more');
			}		
		return true;
	}	
	
	if((srchcrt == 'price') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if((srchcrt == 'beds') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if((srchcrt == 'baths') && (CompareMinMax(srchcrt) === false))
	{
		return false;
	}
	if(srchcrt == 'power')
	{		
		var validate = validatePower();
		if(validate === false)
			return false;

		if($("txtArea") && $("txtArea").value != "")
		{
			setSearchCookie("neighborhood","");
			headerContent("neighborhood");
		}
		setAllToCookie("mlssource");
		setAllToCookie("proptype");
		setAllToCookie("propstatus");
		setAllToCookie("sqftp");
		setAllToCookie("listdatep");
		setAllToCookie("listagent");
		setAllToCookie("lotsize");
		setAllToCookie("age");
		setAllToCookie("yearbuilt");
		setAllToCookie("daysonmarket");
		setAllToCookie("garage");
		setAllToCookie("stories");
		setAllToCookie("eleschool");
		setAllToCookie("midschool");
		setAllToCookie("highschool");
		setAllToCookie("saledate");
		setAllToCookie("saleprice");
		setAllToCookie("saleagent");
		setAllToCookie("area");
		setAllToCookie("polygon");
		setAllToCookie("powerradial");
		setAllToCookie("listagtid");
		setAllToCookie("listoff");
		setAllToCookie("saleagtid");
		setAllToCookie("saleoff");
		setAllToCookie("fire");
		setAllToCookie("pool");
		setAllToCookie("roof");
		funCloseAdvanceSearch();
		return true;
	}

	setAllToCookie(srchcrt);
	headerContent(srchcrt);
	funCloseAdvanceSearch();
	if(bkTheme == 'metrobrokers'){
		//alert('others');
		//fromSubmit();		
	}
	return true;
}

function validatePower()
{
	/* Prop Type */
	if(chooseChecked('divPType',true) == '')
	{
		alert("Please select atleast one property type");
		return false;
	}

	/* Prop Status */
	if(chooseChecked('divPStatus',true) == '')
	{
		alert("Please select atleast one property status");
		return false;
	}

	/* Sales Price */
	var minSalesP = Number(money2num($('txtSalePriceFrom').value));	
	var maxSalesP = Number(money2num($('txtSalePriceTo').value));	
	if(minSalesP<0 || maxSalesP<0)
	{
		alert("Please enter valid price range");
		$('txtSalePriceFrom').value = '';
		$('txtSalePriceTo').value = '';
		return false;
	}
	if((minSalesP>maxSalesP) && (minSalesP != "" && maxSalesP != ""))
	{
		alert("Please enter valid price range");
		$('txtSalePriceFrom').value = '';
		$('txtSalePriceTo').value = '';
		return false;
	}
	 
	/* Sqft */
	/*var sqftMin = Number($("minPSize").value);
	var sqftMax = Number($("maxPSize").value);
	if(sqftMin>sqftMax && sqftMax != 0)
	{
		alert("Please enter valid range for square feet");
		$("minPSize").selectedIndex=0;
		$("maxPSize").selectedIndex=0;
		return false;
	}*/

	var sqftMin = Number($F('minPSize'));
	var sqftMax = Number($F('maxPSize'));
	if(isNaN(sqftMin))
	{
		alert("Please enter numerical values only for min sqft.");
		$('minPSize').value = '';
		$('minPSize').focus();
		return false;
	}

	if(isNaN(sqftMax))
	{
		alert("Please enter numerical values only for max sqft.");
		$('maxPSize').value = '';
		$('maxPSize').focus();
		return false;
	}

	if(sqftMin<0 || sqftMax<0)
	{
		alert("Please enter valid square feet range.");
		$('minPSize').value = '';
		$('maxPSize').value = '';
		$('minPSize').focus();
		return false;
	}

	if(sqftMin>sqftMax && (sqftMin != "" && sqftMax != ""))
	{
		alert("Please enter valid square feet range.");
		//$("minPSize").value='';
		//$("maxPSize").value='';
		return false;
	}
	
	/* Lot Sqft */
	/*var sqftLotMin = Number($("minLotSize").value);
	var sqftLotMax = Number($("maxLotSize").value);
	if(sqftLotMin>sqftLotMax && sqftLotMax != 0)
	{
		alert("Please enter valid range for lot size");
		$("minLotSize").selectedIndex=0;
		$("maxLotSize").selectedIndex=0;
		return false;
	}*/
	var sqftLotMin = Number($F('minLotSize'));
	var sqftLotMax = Number($F('maxLotSize'));
	if(isNaN(sqftLotMin))
	{
		alert("Please enter numerical values only for min lot size.");
		$('minLotSize').value = '';
		$('minLotSize').focus();
		return false;
	}

	if(isNaN(sqftLotMax))
	{
		alert("Please enter numerical values only for max lot size.");		
		$('maxLotSize').value = '';
		$('maxLotSize').focus();
		return false;
	}

	if(sqftLotMin<0 || sqftLotMax<0)
	{
		alert("Please enter valid lot size range.");
		$('minLotSize').value = '';
		$('maxLotSize').value = '';
		$('minLotSize').focus();
		return false;
	}

	if(sqftLotMin>sqftLotMax && (sqftLotMin != "" && sqftLotMax != ""))
	{
		alert("Please enter valid lot size range.");
		//$("minLotSize").value='';
		//$("maxLotSize").value='';
		return false;
	}

	/* List Date */
	if($("txtPLFDate").value != "")
	{
		if(!validDate("txtPLFDate","Please select from list date less than current date"))
			return false;
	}

	if($("txtPLTDate").value != "")
	{
		if(!validDate("txtPLTDate","Please select to list date less than current date"))
			return false;
	}

	if(trim($("txtPLFDate").value) != "" && trim($("txtPLTDate").value) != "")
	{
		var valLFDate = $("txtPLFDate").value;
		var arrLFDate = valLFDate.split("-");		
		var objLFDate = new Date();
		objLFDate.setYear(arrLFDate[2]);
		objLFDate.setMonth(arrLFDate[0]);
		objLFDate.setDate(arrLFDate[1]);
		var tsLFDate = objLFDate.getTime()
		var valLTDate = $("txtPLTDate").value;
		var arrLTDate = valLTDate.split("-");		
		var objLTDate = new Date();
		objLTDate.setYear(arrLTDate[2]);
		objLTDate.setMonth(arrLTDate[0]);
		objLTDate.setDate(arrLTDate[1]);
		var tsLTDate = objLTDate.getTime()
		if(tsLFDate > tsLTDate)
		{
			alert("To date should not be less than From date.");
			$('txtPLFDate').value = '';
			$('txtPLTDate').value = '';
			return false;
		}
	}
	
	/* Sale Date */
	if($("txtSFDate").value != "")
	{
		if(!validDate("txtSFDate","Please select from sale date less than current date"))
			return false;
	}

	if($("txtSTDate").value != "")
	{
		if(!validDate("txtSTDate","Please select to sale date less than current date"))
			return false;
	}
	if(trim($("txtSFDate").value) != "" && trim($("txtSTDate").value) != "")
	{
		var valLFDate = $("txtSFDate").value;
		var arrLFDate = valLFDate.split("-");		
		var objLFDate = new Date();
		objLFDate.setYear(arrLFDate[2]);
		objLFDate.setMonth(arrLFDate[0]);
		objLFDate.setDate(arrLFDate[1]);
		var tsLFDate = objLFDate.getTime()
		var valLTDate = $("txtSTDate").value;
		var arrLTDate = valLTDate.split("-");		
		var objLTDate = new Date();
		objLTDate.setYear(arrLTDate[2]);
		objLTDate.setMonth(arrLTDate[0]);
		objLTDate.setDate(arrLTDate[1]);
		var tsLTDate = objLTDate.getTime()
		if(tsLFDate > tsLTDate)
		{
			alert("To date should not be less than From date.");
			$('txtSFDate').value = '';
			$('txtSTDate').value = '';
			return false;
		}
	}
	
	/* Age */
	var minAge = Number($('txtAgeFrom').value);
	var maxAge = Number($('txtAgeTo').value);
	if(isNaN(minAge))
	{
		alert("Please enter numerical values only.");
		$('txtAgeFrom').value = '';
		$('txtAgeTo').value = '';
		return false;
	}
	else if(isNaN(maxAge))
	{
		alert("Please enter numerical values only.");
		$('txtAgeFrom').value = '';
		$('txtAgeTo').value = '';
		return false;
	}
	else if(minAge>maxAge && (minAge != "" && maxAge != ""))
	{
		alert("Please enter valid range for age.");
		//$('txtAgeFrom').value = '';
		//$('txtAgeTo').value = '';
		return false;
	}
	
	/* Year Build */
	var minYr = Number($F('txtYearBuiltFrom'));
	var maxYr = Number($F('txtYearBuiltTo'));
	if(isNaN(minYr))
	{
		alert("Please enter numerical values only.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if(isNaN(maxYr))
	{
		alert("Please enter numerical values only.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if($F('txtYearBuiltFrom') != '' && $F('txtYearBuiltFrom').length != 4 )
	{
		alert("Please enter 4 digit year value.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if($F('txtYearBuiltTo') != '' && $F('txtYearBuiltTo').length != 4)
	{
		alert("Please enter 4 digit year value.");
		$('txtYearBuiltFrom').value = '';
		$('txtYearBuiltTo').value = '';
		return false;
	}
	else if(minYr>maxYr && (minYr != "" && maxYr != ""))
	{
		alert("Please enter valid range for year build.");
		//$('txtYearBuiltFrom').value = '';
		//$('txtYearBuiltTo').value = '';
		return false;
	}
	
	/* Days on Market */
	var minMkt = Number($F('txtDaysMarketFrom'));
	var maxMkt = Number($F('txtDaysMarketTo'));
	if(isNaN(minMkt))
	{
		alert("Please enter numerical values only.");
		$('txtDaysMarketFrom').value = '';
		$('txtDaysMarketTo').value = '';
		return false;
	}
	else if(isNaN(maxMkt))
	{
		alert("Please enter numerical values only.");
		$('txtDaysMarketFrom').value = '';
		$('txtDaysMarketTo').value = '';
		return false;
	}
	else if(minMkt>maxMkt && (minMkt != "" && maxMkt != ""))
	{
		alert("Please enter valid range for days on market.");
		//$('txtDaysMarketFrom').value = '';
		//$('txtDaysMarketTo').value = '';
		return false;
	}
	
	/* Stories */
	var stories = Number($F('txtStories'));
	if(isNaN(stories))
	{
		alert("Please enter numerical values only.");
		$('txtStories').value = '';
		return false;
	}
	
	/* Listing Agt Id*/
	if($("txtListAgtId").value != "")
	{
		var listAgtId = trim($("txtListAgtId").value);
		var tstRegex = /^([a-zA-Z0-9_-]+)$/;
		if(!tstRegex.test(listAgtId))
		{
			alert("Listing Agent Id should not contain special characters.");
		    $('txtListAgtId').value = '';
		    return false;
		}
	}

	/* Selling Agt Id*/
	if($("txtSaleAgtId").value != "")
	{
		var saleAgtId = trim($("txtSaleAgtId").value);
		var tstRegex = /^([a-zA-Z0-9_-]+)$/;
		if(!tstRegex.test(saleAgtId))
		{
			alert("Selling Agent Id should not contain special characters.");		    
		    $('txtSaleAgtId').value = '';
		    return false;
		}
	}
	
	return true;
}

function funGoAdvanceSearch(srchcrt,page)
{
	if(srchcrt == "multicity")
	{
		var boolAllCityBlank = true;
		for(var i=0;i<20;i++)
		{
			var idTxtObj = 'searchCSZ'+ eval(i+1);
			if(trim($(idTxtObj).value) != "")
			{
				boolAllCityBlank = false;
				break;
			}
		}
		if (boolAllCityBlank == true)
		{
			alert("Please specify either City & State or Zip for atleast one.");
			return;
		}
	}	
	var boolSaveAdvanceSearch = funSaveAdvanceSearch(srchcrt,page);
	if(boolSaveAdvanceSearch == true)
	{
		if($('chkmapSearchSelect') != null && $('chkmapSearchSelect').checked == true && typeof(reloadDragZoomAll) != 'undefined') 
		{
			reloadDragZoomAll();
		}
		else
		{
			explore(page);
		}	
	}	
}
function funGetNeighborHood(srchcrt,page)
{
	var cbfnGetNeighborHood = function(reqObj)
	{
		var response = reqObj.responseText;
		if(response.toString() != 'null')
		{
			arrDataNeighborHood = eval(response);
			if(arrDataNeighborHood.length > 0)
			{
				$('divPopUpSHNeighborHood').style.height = "150px";
				var strCKNH = getSearchCookie("neighborhood");
				var arrCKNH = strCKNH.split(',');
				var ihNeighborHood = new StringBuffer();
				var lenArrDataNeighborHood = arrDataNeighborHood.length;
				ihNeighborHood.append('<table cellpadding="0" cellspacing="0" style="width:250px; height:100%;" border="0">');
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:10%;">'); 
							ihNeighborHood.append('<input type="checkbox" value=""  id="chbSHNHAll" name="chbSHNHAll" onclick="javscript:funSetSHNHAll();"/>');
						ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('<td style="width:80%;">'); 
							ihNeighborHood.append('<span class="contentSHPopup lang">all</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				for(var i=0;i<lenArrDataNeighborHood;i++)
				{
					if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined" && trim(arrDataNeighborHood[i]['neighborhood'])!="")
					{
						ihNeighborHood.append('<tr>'); 
							ihNeighborHood.append('<td style="width:10%;">'); 
								if((arrCKNH.in_array(arrDataNeighborHood[i]['neighborhood']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							ihNeighborHood.append('</td>'); 
							ihNeighborHood.append('<td style="width:80%;">'); 
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['neighborhood']+'</span>');
							ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('</tr>'); 
					}
					else if(typeof(arrDataNeighborHood[i]['area']) != "undefined" && trim(arrDataNeighborHood[i]['area'])!="")
					{
						ihNeighborHood.append('<tr>'); 
							ihNeighborHood.append('<td style="width:10%;">'); 
								if((arrCKNH.in_array(arrDataNeighborHood[i]['area']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							ihNeighborHood.append('</td>'); 
							ihNeighborHood.append('<td style="width:80%;">'); 
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['code']+" - "+arrDataNeighborHood[i]['area']+'</span>');
							ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('</tr>'); 
					}
				}	
				ihNeighborHood.append('</table>');
				$("divSHDataNeighborHood").innerHTML = ihNeighborHood.toString();
				var arrChkBox = $('divSHDataNeighborHood').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
			    	if((arrChkBox[i].id == "chbSHNHAll") || (arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true))
			    	{
			    		continue;
			    	}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chbSHNHAll").checked = true;
				}
				Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
			}
			else
			{
				$('divPopUpSHNeighborHood').style.height = "55px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Neighborhood information not available for &nbsp;\"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\".</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("county");
			}
		}
		else
		{
			$('divPopUpSHNeighborHood').style.height = "50px";
			$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
			$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Neighborhood information for \"' + getSearchCookie("city") + '", ' + getSearchCookie("state") + '\" is coming soon.</span>';
			$("divPopUpSHMLSInfo").style.visibility = "hidden";
			$("divPopUpSHControls").style.display = "inline";
			$("divPopUpSHNeighborHood").style.display = "inline";
			headerContent("county");
		}		
	}
	var url = "../../getCountyNeighborHood.php";
	var qs = "getDataNeighborHood=1&city="+getSearchCookie('city')+"&state="+getSearchCookie("state")+"&zip="+getSearchCookie("zip");

	if($("mlsSource"))
		qs +="&ds="+$F("mlsSource");
	else if(getSearchCookie('mlsSource'))
		qs +="&ds="+escape(getSearchCookie('mlsSource'));

	$("divSHDataNeighborHood").innerHTML = "";
	ajaxRequest(url,qs,cbfnGetNeighborHood);
}
function funGetCounty(srchcrt,page)
{
	var cbfnGetCounty = function(reqObj)
	{
		var response = reqObj.responseText;
		if(response.toString() != 'null')
		{
			arrDataCounty = eval(trim(response));
			if(arrDataCounty.length > 0)
			{
				var strCKCounty = getSearchCookie("county");
				var arrCKCounty = strCKCounty.split(',');
				var ihCounty = new StringBuffer();
				var lenArrDataCounty = arrDataCounty.length;
				ihCounty.append('<table cellpadding="0" cellspacing="0" style="width:320px;*width:100%;height:100%;">');
				for(var i=0;i<lenArrDataCounty;i++)
				{
					var countyName = arrDataCounty[i]['county'];
					ihCounty.append('<tr>'); 
						ihCounty.append('<td style="width:6%;">'); 
							if(arrCKCounty.in_array(countyName) !== false)
							{
								ihCounty.append('<input type="checkbox" value="'+countyName+'" checked="checked" />');
							}
							else
							{
								ihCounty.append('<input type="checkbox" value="'+countyName+'"  />');
							}	
						ihCounty.append('</td>'); 
						ihCounty.append('<td style="width:94%;">'); 
							ihCounty.append('<span class="contentSHPopup lang">'+countyName+'</span>');
						ihCounty.append('</td>'); 
					ihCounty.append('</tr>'); 
				}	
				ihCounty.append('</table>');
				
				$("divSHDataCounty").innerHTML = ihCounty.toString();
				$("divPopUpSHCounty").style.display = "inline";
			}
			else
			{
				$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">County information for \"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\" is coming soon.</span>';
				if(bkTheme == 'realestateone' || bkTheme == 'maxbroock' || bkTheme == 'jensenwhite')
				{
					$("divPopUpSHCounty").style.display = "none";
				}
				else
				{
					$("divPopUpSHCounty").style.display = "inline";
				}
			}
		}
		else
		{
			
			$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">County information for \"' + getSearchCookie("city") + ', ' + getSearchCookie("state") + '\" is coming soon.</span>';
			if(bkTheme == 'realestateone' || bkTheme == 'maxbroock' || bkTheme == 'jensenwhite')
			{
			$("divPopUpSHCounty").style.display = "none";
			}
			else
			{
				$("divPopUpSHCounty").style.display = "inline";
			}
		}
	}
	if ($('searchCSZ').value.search(/;/) > -1)
	{
		$("divSHDataCounty").innerHTML = '<span class="contentSHPopup">Please select single city to enable county search.</span>';
		$("divPopUpSHCounty").style.display = "inline";
		return;
	}
	var isContradict = funCheckContradict();
	if((isContradict != null) && (isContradict != 0))
	{
		var url = "../../getCountyNeighborHood.php";
		var qs = "getDataCounty=1&city="+getSearchCookie('city')+"&state="+getSearchCookie("state")+"&zip="+getSearchCookie("zip");
		$("divSHDataCounty").innerHTML = "";
		ajaxRequest(url,qs,cbfnGetCounty);
	}
	else
	{
		return;
	}	
}

/*function funShowMultiCity()
{
if($('divPopUpMultiCity') == null)
	{
		var ihMultiCity = "";
		ihMultiCity += '<table align="center" style="border:3px double #192046;display:block;position:relative;border-collapse: separate;border-spacing: 3px;width:100%;*width:93%;" >';
		ihMultiCity += '<tr>';
		ihMultiCity += '<td valign="middle" >';
		ihMultiCity += '<div id="divDataMultiCity" name="divDataMultiCity" style="width:290px;height:270px;position:relative;float:left;display:inline;vertical-align:middle;overflow:auto" align="left">';
			ihMultiCity += '<table align="center" border="0" width="100%" style="display:block;position:relative;border-collapse: separate;border-spacing: 3px;" >';
				ihMultiCity += '<tr>';
					ihMultiCity += '<td align="left" colspan="2">';
						ihMultiCity += '<span id="multiErr"></span>';
					ihMultiCity += '</td>';													
				ihMultiCity += '</tr>';
				for(var i=1;i<=50;i++)
				{
					ihMultiCity += '<tr>';
						ihMultiCity += '<td align="left">';
							ihMultiCity += '<span class="contentSHPopupNew lang" align="left">City, State</span>';
						ihMultiCity += '</td>';													
						ihMultiCity += '<td align="left">';
							ihMultiCity += '<input type="textbox" id="searchCSZ'+i+'" size="18" name="searchCSZ'+i+'" class="textboxBlue" value=""  readonly  />';
						ihMultiCity += '</td>';													
					ihMultiCity += '</tr>';
				}
			ihMultiCity += '</table>';									
		ihMultiCity += '</div>';
		ihMultiCity += '</td>';													
		ihMultiCity += '</tr>';
		
		ihMultiCity += '<tr>';
					ihMultiCity += '<td align="right" colspan="2" width="100%" class="borderTop">';
						ihMultiCity += '<a href="javascript:gotoSingPropMulti();" class="linkOkCancleSH">Go</a>&nbsp;&nbsp;';
						ihMultiCity += '<a href="javascript:clearMulti();" class="linkOkCancleSH">Clear All</a>&nbsp;&nbsp;';
						ihMultiCity += '<a href="javascript:closePopUpMultiCity();" class="linkOkCancleSH">Close</a>&nbsp;';
					ihMultiCity += '</td>';													
				ihMultiCity += '</tr>';
		ihMultiCity += '</table><input type="hidden" id="lat"><input type="hidden" id="longi">';									
		
		var myDiv = document.createElement('div');
		myDiv.id = "divPopUpMultiCity";
		myDiv.name = "divPopUpMultiCity";
		myDiv.style.display = "none";
		myDiv.style.position = "absolute";
		myDiv.className = "divContainerAdvannceSearchMulti";
		if(isIE)
		{
			myDiv.style.width = "290px";
			myDiv.style.styleFloat = "left";
		}
		else
		{
			myDiv.style.width = "290px";
			myDiv.style.cssFloat = "left";
		}
		myDiv.style.height = "300px";
		//myDiv.style.overflow = "auto";
		myDiv.innerHTML = ihMultiCity;
		document.body.appendChild(myDiv);
	}
	return $('divPopUpMultiCity');
}

function clearMulti()
{
	for(var i=1;i<=50;i++)
	{
		$('searchCSZ'+i).value = '';
	}
	//clearHash
	cityList = new Hash();

}

function closePopUpMultiCity()
{
	$('divPopUpMultiCity').style.display = "none";
}

function gotoSingPropMulti()
{
	var lat = "";
	var lng = "";
	lat = $("lat").value;
	lng = $("longi").value;
	//alert(2 +" "+lat+","+lng);
	var state="";
	var city="";
	for(i=1;i<=50;i++)
	{
		if($("searchCSZ"+i).value!="")
		{
			var arrCityState = (trim($("searchCSZ"+i).value)).split(",");
			city += trim(arrCityState[0]) + "|";
			state += trim(arrCityState[1]) + "|";
		}	
	}
	if(city.length == 0)
	{
		alert("Please select atleast one city");
		return;
	}
	city = city.substring(0,city.length-1);
	state = state.substring(0,state.length-1);
	listAllCity = city;
	var zip="";	var page=""; var action="start";var otherArgs="";

	if(bkTheme=="metrobrokers")
		page="METRO|multicity|mlsCountySearch";
	else
		page=bkTheme.toUpperCase();
		
	getGeoAdd(lat,lng,city,state,zip,page,action,otherArgs)
}*/


function funShowMultiCity()
{
	if($('divPopUpMultiCity') == null)
	{
		var ihMultiCity = new StringBuffer();
		ihMultiCity.append('<table align="center" style="border:3px double #192046;display:block;position:relative;border-collapse: separate;border-spacing: 3px;width:100%;*width:93%;" >');
		ihMultiCity.append('<tr>');
		ihMultiCity.append('<td valign="middle" >');
		ihMultiCity.append('<div id="divDataMultiCity" name="divDataMultiCity" style="width:290px;height:270px;position:relative;float:left;display:inline;vertical-align:middle;overflow:auto" align="left">');
			ihMultiCity.append('<table  id="multiCTFirst" align="center" border="0" width="100%" style="display:block;position:relative;border-collapse: separate;border-spacing: 3px;" >');
				ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="left" colspan="2">');
						ihMultiCity.append('<span id="multiErr"></span>');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
				ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="left" colspan="2">');
						ihMultiCity.append('<span class="contentSHPopupNew lang" align="left">City, State</span>');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
			ihMultiCity.append('</table>');									
		ihMultiCity.append('</div>');
		ihMultiCity.append('</td>');													
		ihMultiCity.append('</tr>');
		
		ihMultiCity.append('<tr>');
					ihMultiCity.append('<td align="right" colspan="2" width="100%" class="borderTop">');
						ihMultiCity.append('<a href="javascript:gotoSingPropMulti();" class="linkOkCancleSH">Go</a>&nbsp;&nbsp;');
						ihMultiCity.append('<a href="javascript:clearMulti();" class="linkOkCancleSH">Clear All</a>&nbsp;&nbsp;');
						ihMultiCity.append('<a href="javascript:closePopUpMultiCity();" class="linkOkCancleSH">Close</a>&nbsp;');
					ihMultiCity.append('</td>');													
				ihMultiCity.append('</tr>');
		ihMultiCity.append('</table><input type="hidden" id="lat"><input type="hidden" id="longi">');									
		
		var myDiv = document.createElement('div');
		myDiv.id = "divPopUpMultiCity";
		myDiv.name = "divPopUpMultiCity";
		myDiv.style.display = "none";
		myDiv.style.position = "absolute";
		myDiv.className = "divContainerAdvannceSearchMulti";
		if(isIE)
		{
			myDiv.style.width = "290px";
			myDiv.style.styleFloat = "left";
		}
		else
		{
			myDiv.style.width = "290px";
			myDiv.style.cssFloat = "left";
		}
		myDiv.style.height = "300px";
		myDiv.innerHTML = ihMultiCity.toString();
		document.body.appendChild(myDiv);
	}
	return $('divPopUpMultiCity');
}

function clearMulti()
{
	if(isIE)
	{
		var tbl = document.getElementById('multiCTFirst');
		var lastRow = tbl.rows.length;
		while(lastRow != 2)
		{
			tbl.deleteRow(lastRow-1);
			lastRow--;
		}
	}
	else
	{
		ihMultiCity = "";
		ihMultiCity += '<tr>';
			ihMultiCity += '<td align="left" colspan="2">';
				ihMultiCity += '<span id="multiErr"></span>';
			ihMultiCity += '</td>';													
		ihMultiCity += '</tr>';
		ihMultiCity += '<tr>';
			ihMultiCity += '<td align="left" colspan="2">';
				ihMultiCity += '<span class="contentSHPopupNew lang" align="left">City, State</span>';
			ihMultiCity += '</td>';													
		ihMultiCity += '</tr>';
		if($("multiCTFirst"))
			$("multiCTFirst").innerHTML = ihMultiCity;
	}
	
	cityList = new Hash();
}

function closePopUpMultiCity()
{
	$('divPopUpMultiCity').style.display = "none";
}

function gotoSingPropMulti()
{
	var lat = "";
	var lng = "";
	lat = $("lat").value;
	lng = $("longi").value;
	//alert(2 +" "+lat+","+lng);
	var state="";
	var city="";
	if(bkTheme=="lmsre")
	{
		var typeIncookie = "";
		typeInCookie = getSearchCookie("searchType");
		if(typeInCookie=="'non mls'")
			setSearchCookie("searchType","");
	}
	var cityLst = $('multiCTFirst').getElementsByTagName("input");
	for(i=0;i<=cityLst.length;i++)
	{
		if($(cityLst[i]) && $(cityLst[i]).value!="")
		{
			var arrCityState = (trim($(cityLst[i]).value)).split(",");
			city += trim(arrCityState[0]) + "|";
			state += trim(arrCityState[1]) + "|";
		}	
	}
	if(city.length==0)
	{
		alert("Please select atleast one city");
		return;
	}
	city = city.substring(0,city.length-1);
	state = state.substring(0,state.length-1);
	listAllCity = city;
	var zip="";	var page=""; var action="start";var otherArgs="";

	if(bkTheme=="metrobrokers")
		page="METRO|multicity|mlsCountySearch";
	else
		page=bkTheme.toUpperCase();
		
	getGeoAdd(lat,lng,city,state,zip,page,action,otherArgs)
}

var arrDataCounty = new Array();
var arrDataNeighborHood = new Array();
function funShowAdvanceSearch(srchcrt,page,e)
{	
	funCloseAdvanceSearch();
	if($("divContainerAdvannceSearch"))
		$("divContainerAdvannceSearch").style.display="";
	if($("divPopUpSHPower"))
		$("divPopUpSHPower").style.display="";	

	$("divContainerAdvanceSearch").style.width = "290px";
	switch(srchcrt)
	{
		case "multicity":
			$("divContainerAdvanceSearch").style.width = "250px";
			Element.removeClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHMultiCity").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHMultiCity").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
			break;
		case "more":
			setAllCookieValue('sqft');
     		setAllCookieValue('listdate');
			$("divContainerAdvanceSearch").style.width = "400px";
			$("divPopUpSHSqft").style.display = "inline";
			$("divPopUpSHListDate").style.display = "inline";
			
			//for property styles
			if($("divPopUpSHPropStyle"))
			{
				var arrChkBox = $('propStyleDv').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				var strChkBox = getSearchCookie("propStyle");

				if(strChkBox == "" || strChkBox == null)
				{
					for(var i=0;i<lenArrChkBox;i++)
					{
				    	if(arrChkBox[i].id == "chkStyleAll")
				    	{
				    		continue;
				    	}
		    			if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == false)
		    			{
		    				arrChkBox[i].checked = true;
		    			}
					}
				}
				else
				{
					var arrStrChkBox = strChkBox.split(":");
					for(var i=0;i<lenArrChkBox;i++)
					{
						if (arrChkBox[i].id == "chkStyleAll")
						{
							continue;
						}
						if(arrChkBox[i].type == "checkbox")
						{
							var valChkBox = arrChkBox[i].value;
		    				if(arrStrChkBox.in_array(valChkBox) !== false)
		    				{
		    					arrChkBox[i].checked = true;
		    				}
							else
							{
								allChked = false;
								arrChkBox[i].checked = false;
							}
						}						
					}
				}

				if(allChked == true)
				{
					$("chkStyleAll").checked = true;
				}
				else
				{
					var confAllChked = true;
					for(var i=0;i<lenArrChkBox;i++)
					{
						if (arrChkBox[i].id == "chkStyleAll")
						{
							continue;
						}
						if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
						{
							confAllChked = false;
							break;
						}
					}
					
					if(confAllChked == true)
					{
						for(var i=0;i<lenArrChkBox;i++)
						{
							if(arrChkBox[i].type == "checkbox")
								arrChkBox[i].checked = true;
						}
					}
					else
						$("chkStyleAll").checked = false;
				}
				$("divPopUpSHPropStyle").style.display = "inline";
			}

			//for parking styles
			if($("divPopUpSHGarage"))
			{
				setAllCookieValue("garage");
				/*var arrChkBox = $('parkingStyleDv').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
					if (arrChkBox[i].id == "chkParkingStyleAll")
					{
						continue;
					}
					if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
					{
						continue;
					}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chkParkingStyleAll").checked = true;
				}
				else
				{
					$("chkParkingStyleAll").checked = false;
				}*/
				$("divPopUpSHGarage").style.display = "inline";
			}

			$("divPopUpSHMLSInfo").style.visibility = "hidden";
			$('searchCSZ').value = $('searchCSZ').value.replace (/^\s+/g, '').replace (/\s+$/g, '').replace (/\s+/g, ' ');
			if(countySearchEnabled == 1)
			{
				if((trim($('searchCSZ').value) == "")||(trim($('searchCSZ').value).toLowerCase () == "required"))
				{
					var ihCounty = "";
					ihCounty = ihCounty + '<a href="javascript:void(0);" onclick="javascript:funGetCounty(\'county\',\''+page+'\');" class="linkOkCancleSH lang">Get County Information</a>'; 
					$("divSHDataCounty").innerHTML = ihCounty;
					$("divPopUpSHCounty").style.display = "inline";
				}
				else
				{
					var isCompare = funCompareSearchCookie();
					if(isCompare === 1)
					{
						var ihCounty = "";
						ihCounty = ihCounty + '<a href="javascript:void(0);" onclick="javascript:funGetCounty(\'county\',\''+page+'\');" class="linkOkCancleSH lang">Get County Information</a>'; 
						$("divSHDataCounty").innerHTML = ihCounty;
						$("divPopUpSHCounty").style.display = "inline";
					}
					else
					{
						if(arrDataCounty.length == 0)
						{
							funGetCounty(srchcrt,page);
						}
						else
						{
							var strCKCounty = getSearchCookie("county");
							var arrCKCounty = strCKCounty.split(',');
							var ihCounty = "";
							var lenArrDataCounty = arrDataCounty.length;
							ihCounty = ihCounty + '<table cellpadding="0" cellspacing="0" style="width:100%;height:100%;">';
							for(var i=0;i<lenArrDataCounty;i++)
							{
								var countyName = arrDataCounty[i]['county'];
								ihCounty = ihCounty + '<tr>'; 
									ihCounty = ihCounty + '<td style="width:20%;">'; 
										if(arrCKCounty.in_array(countyName) !== false)
										{
											ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'" checked="checked" />';
										}
										else
										{
											ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'"  />';
										}	
									ihCounty = ihCounty + '</td>'; 
									ihCounty = ihCounty + '<td style="width:80%;">'; 
										ihCounty = ihCounty + '<span class="contentSHPopup lang">'+countyName+'</span>';
									ihCounty = ihCounty + '</td>'; 
								ihCounty = ihCounty + '</tr>'; 
							}	
							ihCounty = ihCounty + '</table>';
							
							$("divSHDataCounty").innerHTML = ihCounty;
							$("divPopUpSHCounty").style.display = "inline";
						}
					}
				}
			}
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "county":
			var isContradict = funCheckContradict();
			if(isContradict == null || isContradict == 0)
			{
				return;
			}
			if(arrDataCounty.length == 0)
			{
				funGetCounty(srchcrt,page);
			}
			else
			{
				var strCKCounty = getSearchCookie("county");
				var arrCKCounty = strCKCounty.split(',');
				var ihCounty = "";
				var lenArrDataCounty = arrDataCounty.length;
				ihCounty = ihCounty + '<table cellpadding="0" cellspacing="0" style="width:100%;height:100%;">';
				for(var i=0;i<lenArrDataCounty;i++)
				{
					var countyName = arrDataCounty[i]['county'];
					ihCounty = ihCounty + '<tr>'; 
						ihCounty = ihCounty + '<td style="width:20%;">'; 
							if(arrCKCounty.in_array(countyName) !== false)
							{
								ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'" checked="checked" />';
							}
							else
							{
								ihCounty = ihCounty + '<input type="checkbox" value="'+countyName+'"  />';
							}	
						ihCounty = ihCounty + '</td>'; 
						ihCounty = ihCounty + '<td style="width:80%;">'; 
							ihCounty = ihCounty + '<span class="contentSHPopup lang">'+countyName+'</span>';
						ihCounty = ihCounty + '</td>'; 
					ihCounty = ihCounty + '</tr>'; 
				}	
				ihCounty = ihCounty + '</table>';
				
				$("divSHDataCounty").innerHTML = ihCounty;
				Element.removeClassName($("divSHCounty").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHCounty").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHCounty").style.display = "inline";
			}
			break;
		case "neighborhood":
			if ($('searchCSZ').value.search(/;/) > -1)
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please select single city to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if($('chkmapSearchSelect') != null && $('chkmapSearchSelect').checked == true) 			
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please disable Map Search to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if(trim(getSearchCookie("county")) != "" && countySearchEnabled == "1")	
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please deselect county to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			if($("txtArea") && $("txtArea").value != "")
			{
				$('divPopUpSHNeighborHood').style.height = "50px";
				$("divPopUpSHControls").innerHTML = '&nbsp<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';
				$("divSHDataNeighborHood").innerHTML = '<span class="contentSHPopup">Please disable Area Search to enable neighborhood search.</span>';
				$("divPopUpSHMLSInfo").style.visibility = "hidden";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
				headerContent("neighborhood");
				break;
			}
			
			var isContradict = funCheckContradict();
			if(isContradict == null || isContradict == 0)  
			{
				return;
			}
			if(arrDataNeighborHood.length == 0)
			{
				funGetNeighborHood(srchcrt,page);
			}
			else
			{
				$('divPopUpSHNeighborHood').style.height = "150px";
				var strCKNH = getSearchCookie("neighborhood");
				var arrCKNH = strCKNH.split(',');
				var ihNeighborHood = new StringBuffer();
				var lenArrDataNeighborHood= arrDataNeighborHood.length;
				ihNeighborHood.append('<table cellpadding="0" cellspacing="0" style="width:250px; height:100%;" border="0">');
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:30px;">'); 
							ihNeighborHood.append('<input type="checkbox" value=""  id="chbSHNHAll" name="chbSHNHAll" onclick="javscript:funSetSHNHAll();"/>');
						ihNeighborHood.append('</td>'); 
						ihNeighborHood.append('<td style="width:220px;">'); 
							ihNeighborHood.append('<span class="contentSHPopup lang">all</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				for(var i=0;i<lenArrDataNeighborHood;i++)
				{
					ihNeighborHood.append('<tr>'); 
						ihNeighborHood.append('<td style="width:30px;">'); 
							if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined")
							{
								if((arrCKNH.in_array(arrDataNeighborHood[i]['neighborhood']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['neighborhood']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}	
							}
							else if(typeof(arrDataNeighborHood[i]['area']) != "undefined")
							{
								if((arrCKNH.in_array(arrDataNeighborHood[i]['area']) !== false) || (trim(strCKNH) == 'all'))
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" checked="checked" />');
								}
								else
								{
									ihNeighborHood.append('<input type="checkbox" value="'+arrDataNeighborHood[i]['area']+'" onclick="javascript:funUnchkAllChkBox(this);" />');
								}
							}
						ihNeighborHood.append('</td>');
						ihNeighborHood.append('<td style="width:220px;">');
							if(typeof(arrDataNeighborHood[i]['neighborhood']) != "undefined")
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['neighborhood']+'</span>');
							else if(typeof(arrDataNeighborHood[i]['area']) != "undefined")
								ihNeighborHood.append('<span class="contentSHPopup lang">'+arrDataNeighborHood[i]['code']+" - "+arrDataNeighborHood[i]['area']+'</span>');
						ihNeighborHood.append('</td>'); 
					ihNeighborHood.append('</tr>'); 
				}	
				ihNeighborHood.append('</table>');
				$("divSHDataNeighborHood").innerHTML = ihNeighborHood.toString();
				var arrChkBox = $('divSHDataNeighborHood').getElementsByTagName("input");
				var lenArrChkBox = arrChkBox.length;
				var allChked = true;
				for(var i=0;i<lenArrChkBox;i++)
				{
			    	if((arrChkBox[i].id == "chbSHNHAll") || (arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true))
			    	{
			    		continue;
			    	}
					else
					{
						allChked = false;
						break;
					}
				}
				if(allChked == true)
				{
					$("chbSHNHAll").checked = true;
				}
				Element.removeClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHNeighborHood").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
				$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
				$("divPopUpSHMLSInfo").style.visibility = "visible";
				$("divPopUpSHControls").style.display = "inline";
				$("divPopUpSHNeighborHood").style.display = "inline";
			}
			break;
		case "price":
			Element.removeClassName($("divSHPrice").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHPrice").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHPrice").style.display = "inline";
			if($("minPrice") && getSearchCookie("minPrice")!='0' && getSearchCookie("minPrice")!='') $("minPrice").value = addCommas(getSearchCookie("minPrice"));
			if($("maxPrice") && getSearchCookie("maxPrice")!='0' && getSearchCookie("maxPrice")!='') $("maxPrice").value = addCommas(getSearchCookie("maxPrice"));
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "beds":
			setAllCookieValue('beds');
			Element.removeClassName($("divSHBeds").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHBeds").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHBeds").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "baths":
			setAllCookieValue('baths');
			Element.removeClassName($("divSHBaths").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHBaths").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHBaths").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "sqft":
			Element.removeClassName($("divSHSqft").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHSqft").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHSqft").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "listdate":
			Element.removeClassName($("divSHListDate").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHListDate").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHListDate").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "type":
			var arrChkBox = $('divPopUpSHType').getElementsByTagName("input");
			var lenArrChkBox = arrChkBox.length;
			var allChked = true;
			for(var i=0;i<lenArrChkBox;i++)
			{
				if (arrChkBox[i].id == "chbSHTypeAll")
				{
					continue;
				}
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					continue;
				}
				else
				{
					allChked = false;
					break;
				}
			}
			if(allChked == true)
			{
				$("chbSHTypeAll").checked = true;
			}
			else
			{
				$("chbSHTypeAll").checked = false;
			}

			Element.removeClassName($("divSHType").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHType").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHType").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "mls":
			Element.removeClassName($("divSHMLS").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHMLS").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			if(trim(getSearchCookie('mlsno')) != "")
			{
				$("searchMLS").value = trim(getSearchCookie('mlsno'));
			}
			else
			{
				$("searchMLS").value = "";
			}
			$("divPopUpSHMLS").style.display = "inline";
			$("divPopUpSHMLSInfo").style.visibility = "visible";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "sortby":
			Element.removeClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSHSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divPopUpSHSortBy").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;		
		case "power":
			$("divContainerAdvanceSearch").style.width = "456px";
			if($("divSHPowerSortBy"))
			{
				Element.removeClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkAdvanceSearch');
				Element.addClassName($("divSHPowerSortBy").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			}
			$("divPopUpSHPower").style.display = "inline";
			$("divPopUpSHControls").innerHTML = '<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchOK" name="anchorAdvanceSearchOK" onclick="javascript:funSaveAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">save</a>&nbsp;&nbsp;<a href="#" class="linkOkCancleSH lang"  id="anchorAdvanceSearchGo" name="anchorAdvanceSearchGo" onclick="javascript:funGoAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">go</a>&nbsp;&nbsp;<a href="javascript:void(0);" class="linkOkCancleSH lang"  id="anchorAdvanceSearchClose" name="anchorAdvanceSearchClose" onclick="javascript:funCloseAdvanceSearch(\''+srchcrt+'\',\''+page+'\');">close</a>';	
			$("divPopUpSHControls").style.display = "inline";
			break;
		case "saveSearch":
			Element.removeClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkAdvanceSearch');
			Element.addClassName($("divSaveSearch").getElementsByTagName('a')[0],'linkSelAdvanceSearch');
			$("divSaveSearch").style.display = "inline";
			if($("errDivP")) $("errDivP").innerHTML = "";
			if($("txtSrchNm"))
			{
				$("txtSrchNm").value = "";
				$("txtSrchNm").className = 'lang';
			}
			if($("txtClient")) $("txtClient").value = "";
			if($("txtEmails"))
			{
				$("txtEmails").value = "";
				$("txtEmails").className = 'lang';
			}
			break;
		default: 
			return;
	}
	
	var element = Event.element(e);
	var objDiv = element.parentNode;
	var posLeft = getPositionLeft(objDiv);
	if(srchcrt=="power")
		posLeft -=7; 
	var posTop = getPositionTop(objDiv);
	$("divContainerAdvanceSearch").style.left = posLeft + "px";
	$("divContainerAdvanceSearch").style.top = eval(posTop + 15) + "px";
	if(!isIE && srchcrt=="more")	
			$("divContainerAdvanceSearch").style.top = eval(posTop + 9) + "px";
	$("divContainerAdvanceSearch").style.display = "block";
	
}

//====================================================
//LMSRE specific:
//it will check on two pan map..if multicity then give
//alert else allow to go and perform other action
//====================================================
function checkMultiCity()
{
		var cityPipeList = getSearchCookie("city");
		var stateMy = getSearchCookie("state");
		if($("searchCSZ"))
			var csz = $("searchCSZ").value;
		var flag = false;
		if(cityPipeList.indexOf("|") > -1)
		{
			flag=true;
		}
		else
		{
			flag=false;
		}
		return flag;
}
//====================================================
//LMSRE specific:
//called while dragging any bit,and onclik of 
//dashboard tab.
//====================================================
function callMultiCityCheck_Dashboard(fromWhere,bitzName)
{

	var cityPipeList = getSearchCookie("city");
	var csz = $("searchCSZ").value;	
	if(cityPipeList.indexOf("|") > -1  || csz=="required" || csz=="")
	{
		if(fromWhere == 'dashboard')
		{	
			bitzName = "dashboard";
			showPopupDivforMenu(bitzName,'mapit');
		}
		if(fromWhere == 'mapit')
		{
			bitzName = "mapit";
			showPopupDivforMenu(bitzName,'dashboard');
		}
		return false;
	}
	else if(fromWhere == "dashboard")
	{
		var qs = new Querystring();
		var isNoSearch = qs.get('noSearch');
		if(isNoSearch != null && trim(isNoSearch) == 1)
		{
			location.href="../dashboard/dashboardIndex.php?noSearch=1";
		}
		else if (bkTheme == 'reotexashomes') //to load reo bit as default on dashboard of reotexashomes
		{
			var now = new Date();
			now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
			var myObject = new Object();
			myObject.widget1X1="bankowned";
			setCookie("strWidgetCookie",$H(myObject).toJSON(),now);

			location.href="../dashboard/dashboardIndex.php";
		}
		else
		{
			location.href="../dashboard/dashboardIndex.php";
		}
	}
	else if(fromWhere == "mapit")
	{
		callExploreNeighbourhood(); 
	}
}
function callMultiCityCheck_Dashboard_Metro(fromWhere,bitzName)
{
	var cityPipeList = getSearchCookie("city");
	
	if(cityPipeList.indexOf("|") > -1)
	{
		if(fromWhere == "dragbit")
		{
			//DO NOTHING
		}
		else
		{
			if(fromWhere == 'dashboard')
				bitzName = "dashboard";
			showPopupDivforMenu(bitzName,'mapit');
			return false;
		}
	}
	if(fromWhere == "dashboard")
	{
		location.href="../dashboard/dashboardIndex.php";
	}
}
/**
 * Extra useful functions to the standard javascript prototypes.
 * Added By: Pankit Bhanushali
 */
Array.prototype.intersection = function( value ) {

	var result = new Array();
	
	if( typeof value != "object" ) {
		value = new Array(value);
	}
	
    for( var tc = 0; tc<this.length; tc++) {
		for( var vc = 0; vc < value.length; vc++ ) {
	        if( this[tc] == value[vc] ) {
				result.push_back(value[vc]);
			}
		}
    }
    return result;
}
Array.prototype.push_back = function( value ) {
	if( typeof value == "object" && value.length ) {
		for( var count = 0; count < value.length; count++ ) {
			this[this.length] = value[count];
		}
	} else {
		this[this.length] = value;
	}
}

/** code for brokeragent light box to get all office list **/
function getOffice(type)
{
	var queryString="type=off";
	if(type != null)
		queryString="type=offLoc";
	var url="/app/listing/getOffice.php";
	ajaxRequest(url,queryString,officeCallBack);	
}

//Callback for Assign Lead
function officeCallBack(originalResponse)
{
	var responce = originalResponse.responseText;
	
	
	/*****************sanju, this code can u used if company name depends on office location****************************/
	
	/*
	var respArr = responce.split('<!sep!>');
	if(respArr[0] == 'offLoc')
	{
		$('allOfficeLoc').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOfficeLoc').disabled= false;
		else
			$('txtOfficeLoc').disabled= true;
	}
	else if(respArr[0] == 'offM')
	{
		$('allOffice').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOffice').disabled= false;
		else
			$('txtOffice').disabled= true;
	}
	else if(respArr[0] == 'off')
	{
		$('allOffice').innerHTML = respArr[1];
		if($('radioOffice').checked)
			$('txtOffice').disabled= false;
		else
			$('txtOffice').disabled= true;
	}
	* 
	********************************************/
	
	/********************sanju, code that will load both company name and office loc simultanously*************************************/
	
	if (bkTheme == "metrobrokers")
	{
		var respArr = responce.split('<!sep!>');
		$('allOffice').innerHTML = respArr[0];
		$('allOfficeLoc').innerHTML = respArr[1];
		if($('radioOffice').checked)
		{
			$('txtOffice').disabled= false;
			$('txtOfficeLoc').disabled= false;
		}
		else
		{
			$('txtOffice').disabled= true;
			$('txtOfficeLoc').disabled= true;
		}
	}
	else
	{
		$('allOffice').innerHTML = responce;
		if($('radioOffice').checked)
			$('txtOffice').disabled= false;
		else
			$('txtOffice').disabled= true;
	}
	
	/***************************************************************/
}

function offLocChanged()
{
	var offLocId = escape($("txtOfficeLoc").options[$("txtOfficeLoc").selectedIndex].value);
	var queryString="olid="+offLocId;
	var url="/app/listing/getOffice.php";
	ajaxRequest(url,queryString,officeCallBack);	
}

function funExploreMlsAddrMap()
{
	showDetail=1;
	latp = latLong.lat;
	lngp = latLong.lng;

	var city = getSearchCookie("city");
	var zip = getSearchCookie("zip");
	var state = getSearchCookie("state");
	var ad = getSearchCookie("searchAddress");	
	/*var mapLoadedBits = getCookie("strMapitCK");
	
	if (mapLoadedBits != "")
	{
		mapLoadedBits = mapLoadedBits + ",mlsaddrsearch";
	}
	else
	{
		mapLoadedBits = "mlsaddrsearch";
	}*/

	if(mapToShow == "")
	{
		setMapItCookie("mlsaddrsearch","add");
		newUrl = "/app/listing/singlePropertyLanding.php?PHPSESSID=&status=EXP&address=" + ad + "," + city + "," + state + "," + zip + ",,,," + latp + "," + lngp;
	}
	else
	{
		setMapItCookie("mlsNHoodMode","add");
		newUrl = "/app/listing/singlePropertyLanding.php?status=N&code=propView=1:::searchAddress="+ad+":::city="+city+":::state="+state+":::zip="+zip+":::neighborhood=:::county=:::minPrice="+getSearchCookie("minPrice")+":::maxPrice="+getSearchCookie("maxPrice")+":::searchBeds="+getSearchCookie("searchBeds")+":::searchBaths="+getSearchCookie("searchBaths")+":::id=355&mapCenter=("+latp+","+lngp+")&valChkMapSearchSelect=1&fe=&f=1&propLatitude="+latp+"&propLongitude="+lngp+"&mapZoom=13";
	}
	var myQs = new Querystring();
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");
	if(frm != null && trim(frm) == 'agt' && aid != null && trim(aid) != "")
	{
		newUrl = newUrl + "&frm=agt&aid="+aid;

		//agentsite statistics
		var beds = getSearchCookie("searchBeds");
		var baths = getSearchCookie("searchBaths");
		var type = getSearchCookie("searchType");
		var minprice = getSearchCookie("minPrice");
		var maxprice = getSearchCookie("maxPrice");

		var url = "../../classes/emailStats.php";
		var qs = "from=search&aid="+aid+"&city="+city+"&type="+type+"&beds="+beds+"&baths="+baths+"&price="+minprice+"-"+maxprice+"&addr="+ad+"&mlsno=";

		ajaxRequest(url,qs);
		//statistics done
	}
	window.location.href = newUrl;
	return;
}

function gotoSellDshbrd(uid)
{
	if (uid != 1)
	{
		var myObject = new Object();
		myObject.widget1X1="recentsales";
		myObject.widget1X2="marketsnapshot";
		myObject.widget1X3="equity";
		myObject.widget2X1="valuehome";
		myObject.widget2X2="";
		myObject.widget2X3="";
		myObject.widget3X1="";
		myObject.widget3X2="";
		myObject.widget3X3="";

		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		setCookie("strWidgetCookie",$H(myObject).toJSON(),now);

		location.href = "http://" + location.hostname + "/app/dashboard/dashboardIndex.php";
	}
	else
	{
		var queryStr="widgetsConf=1,1,25|1,2,46|1,3,57|2,1,58|2,2,|2,3,|3,1,|3,2,|3,3,&setUserPref=1";
		var url ="/app/dashboard/dshbrdProcess.php";
		ajaxRequest(url,queryStr,loadDecDash);
	}
}
function loadDecDash(response)
{
	location.href = "http://" + location.hostname + "/app/dashboard/dashboard.php";
}

function gotoDashBrdFoot(call)
{
	if(call == '1' || call == '0' )
		location.href = "http://" + location.hostname + "/terabitzApi/finance/index.php";
	else if(call == 'openhouse')
	{
		setSearchCookie("listType","openHome");		
		setSearchCookie("ohflag","1");		
		url = 	'/Search/'+getSearchCookie("state")+'/'+getSearchCookie("city");
		location.href = url;
	}
	else
	{
		ClrQckSrchCookies();
		location.href = "http://" + location.hostname + "/app/listing/singlePropertyLandingNew.php";
	}
}

function gotoDashBrdFoot_org(call)
{
	var city = getSearchCookie("city");
	var state= getSearchCookie("state");

	if(trim(city) == '' && city != null)
	{
		var now = new Date();
		now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
		city = "San Jose";
		state = "CA";
		latLongStr = "[{'lat':'37.316466','lng':'-121.873881'}]";
		setCookie("latLongCk",latLongStr, now);
		latLong = eval(getCookie("latLongCk"))[0];
		setSearchCookie("city", city);			
		setSearchCookie ("state", state);
	}

	if (call == 'openhouse')
		callMapIt(call);
	else if (call == 1 || call == 0)
		gotoSellDshbrd(call);
	else
		callMapIt();
}

startStack=function() { };  // A stack of functions to run onload/domready

registerOnLoad = function(func) 
{
   var orgOnLoad = startStack;
   startStack = function () {
      orgOnLoad();
      func();
      return;
   }
}

var ranOnload=false; // Flag to determine if we've ran the starting stack already.

if (document.addEventListener) 
{
  // Mozilla actually has a DOM READY event.
   document.addEventListener("DOMContentLoaded", function(){if (!ranOnload) {ranOnload=true; startStack();}}, false);
}
else if (document.all && !window.opera)
{
  // This is the IE style which exploits a property of the (standards defined) defer attribute
  document.write("<scr" + "ipt id='DOMReady' defer=true " + "src=//:><\/scr" + "ipt>");  
  document.getElementById("DOMReady").onreadystatechange=function(){
    if (this.readyState=="complete"&&(!ranOnload)){
      ranOnload=true;
      startStack();
    }
  }
}

var orgOnLoad=window.onload;
window.onload=function() 
{
	if (typeof(orgOnLoad)=='function') 
	{
		orgOnLoad();
	}
	if (!ranOnload) 
	{
		ranOnload=true;
		startStack();
	}
}

var funRplcImgBitzBar = function()
{
	if($('divIconCollect'))
	{
		var dashIcons = $('divIconCollect').getElementsByClassName('dashIconsDrag');
		for(var i=0;i<dashIcons.length;i++)
		{
			var divImgId = dashIcons[i].id;
			var widgetName = divImgId.gsub('divImg_','');
			var imgId =  'img_'+widgetName;
			$(imgId).src = $(imgId).src.gsub('blankImg.gif',eval('widgetsData.'+widgetName+'.img_n'));
		}
	}
	
}
/*
registerOnLoad(funRplcImgBitzBar);

var startup1 = function() {
   alert("I'm the first function!")
}

registerOnLoad(startup1);
registerOnLoad(function () {
   alert("I'm the second function!")
});
*/

function funMakeBitClickable(bitName,page,from)
{
	var ihBitz = new StringBuffer();
		ihBitz.append('<table border="0" style="font-size:0.7em;width:100%;height:100%;border-spacing:0px;">');
			ihBitz.append('<tr>');
				if(page != null && trim(page) == 'dashboard')
				{
					var innerTitleText = "Click to load on dashboard";
				}
				else
				{
					var innerTitleText = "Click to load on map";
				}	
				if(from=="API")
				{
					var innerTitleText = "Click on the bit to load.";
				}
				ihBitz.append('<td align="center" valign="top"  onmouseover="try{showTooltip(\''+innerTitleText.stripTags()+'\',event);}catch(e){}" onmouseout="try{hideTooltip();}catch(e){}">');
					try
					{
						var bitImg = eval('widgetsData.'+bitName+'.img_n');
						var bitTitle = eval('widgetsData.'+bitName+'.title');
					}
					catch(e)
					{
						var bitImg = "";
						var bitTitle = "";
						
					}
				if(page != null && trim(page) == 'dashboard')
					{
						ihBitz.append('<img id="img_'+bitName+'" style="cursor:pointer;" class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadOnDashboard(\''+bitName+'\');" />');
					}
					else
					{
						ihBitz.append('<img id="img_'+bitName+'" style="cursor:pointer;" class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadOnMap(\''+bitName+'\');" />');
					}	
				ihBitz.append('</td>');
			ihBitz.append('</tr>');
		ihBitz.append('</table>');
		if($('divImg_'+bitName))
		{
            $('divImg_'+bitName).innerHTML = ihBitz.toString();
            $('img_'+bitName).onmouseover = revealThumbnail;
            $('img_'+bitName).onmouseout = hideThumbnail;
        }
}
function funLoadedOnMap(bitName,page)
{
	//alert('This bit is already loaded on map.'); 
	if(bitName == "wikipedia")
	{
		mapItCtrl.removeIcon_(mapItCtrl.getContainer_(),bitName);
		map.removeOverlay(wikiLayer);
		funMakeBitClickable(bitName);
		
		var currUrl = location.href;
		if(!currUrl.include("singlePropertyLanding.php"))
			unfillLoaded(bitName);
		return;
	}
	if(typeof(unfillLoaded)!="undefined")
	{
		unfillLoaded(bitName);
	}
	closeMapBit (bitName);
	funMakeBitClickable (bitName);
	return;
}
function funLoadedOnDashboard(bitName,page)
{
	//alert('This bit is already loaded on Dashboard.'); 
	funCloseWidget(null,bitName);
	return;
}
function funMakeBitNonClickable(bitName,page)
{
	var ihBitz = new StringBuffer();
		ihBitz.append('<table border="0" style="font-size:0.7em;width:100%;height:100%;border-spacing:0px;">');
			ihBitz.append('<tr>');
				if(page != null && trim(page) == 'dashboard')
				{
					var innerTitleText = "Click on the bit to remove.";
				}
				else
				{
					var innerTitleText = "Click on the bit to remove.";
				}	
				ihBitz.append('<td align="center" valign="top"  class="maskNonClickableBit" onmouseover="try{showTooltip(\''+innerTitleText.stripTags()+'\',event);}catch(e){}" onmouseout="try{hideTooltip();}catch(e){}">');
					var bitImg = eval('widgetsData.'+bitName+'.img_n');
					var bitTitle = eval('widgetsData.'+bitName+'.title');
					if(page != null && trim(page) == 'dashboard')
					{
						ihBitz.append('<img  id="img_'+bitName+'"  class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadedOnDashboard(\''+bitName+'\');" />');
					}
					else
					{
						ihBitz.append('<img  id="img_'+bitName+'"  class="crsr" src="../../wt/'+bkTheme+'/images/dashboard/toolbarIcons/'+bitImg+'"  title="" alt="'+bitTitle+'" onclick="javascript:funLoadedOnMap(\''+bitName+'\');" />');
					}	
				ihBitz.append('</td>');
			ihBitz.append('</tr>');
		ihBitz.append('</table>');
	$('divImg_'+bitName).innerHTML = ihBitz.toString();
	$('img_'+bitName).onmouseover = hideThumbnail;
	$('img_'+bitName).onmouseout = hideThumbnail;
//	$('divImg_'+bitName).style.display = 'none';
}
function funMakeSummaryHeader(page)
{
	/*var ihSummaryHeader = new StringBuffer();
	if(page != null && trim(page) == 'dashboard')
		ihSummaryHeader = ihSummaryHeader + '<table style="width:180px;height:17px;" cellspacin="0" cellpadding="0" id="tblSummaryHeader">';
	else
		ihSummaryHeader = ihSummaryHeader + '<table style="width:178px;height:17px;" cellspacin="0" cellpadding="0" id="tblSummaryHeader">';
        ihSummaryHeader = ihSummaryHeader + '<tr>';
			ihSummaryHeader = ihSummaryHeader + '<td class="bgLeftSummaryHeader">&nbsp;</td>';
			if(page != null && trim(page) == 'dashboard')
				ihSummaryHeader = ihSummaryHeader + '<td class="bgMiddleSummaryHeader" align="center" valign="middle" id="tdSummaryHeader" style="width:164px;">';
			else
				ihSummaryHeader = ihSummaryHeader + '<td class="bgMiddleSummaryHeader" align="center" valign="middle" id="tdSummaryHeader" style="width:164px;">';
				
					ihSummaryHeader = ihSummaryHeader + '<span class="textSummaryHeader" id="spanSummaryHeader" >';
					if(page != null && trim(page) == 'dashboard')
						ihSummaryHeader = ihSummaryHeader + 'Currently active on dashboard';
					else
						ihSummaryHeader = ihSummaryHeader + 'Currently active on map';
					ihSummaryHeader = ihSummaryHeader + '</span>';
					
			ihSummaryHeader = ihSummaryHeader + '</td>';
			ihSummaryHeader = ihSummaryHeader + '<td class="bgRightSummaryHeader">&nbsp;</td>';
		ihSummaryHeader = ihSummaryHeader + '</tr>';
		
	ihSummaryHeader = ihSummaryHeader + '</table>';
	
	var myDiv = document.createElement('div');
	if(page != null && trim(page) == 'dashboard')
		myDiv.style.width = '180px';
	else
		myDiv.style.width = '170px';
	myDiv.style.position = 'absolute';
	if(page != null && trim(page) == 'dashboard')
	{
		var objSummaryArea = document.getElementById('divSummaryArea');
		var posLeft = getPositionLeft(objSummaryArea);
		var posTop = getPositionTop(objSummaryArea);
		myDiv.style.left = posLeft+'px';
		myDiv.style.top = (posTop-17)+'px';
	}
	else
	{
		var objIconContaner = document.getElementById('myIconContainer');
		var posLeft = getPositionLeft(objIconContaner);
		var posTop = getPositionTop(objIconContaner);
		myDiv.style.left = posLeft+'px';
		myDiv.style.top = (posTop-17)+'px';
	}	
	myDiv.innerHTML = ihSummaryHeader;
	document.body.appendChild(myDiv);*/
}
function funMakeSummaryArea(page)
{
	/*var objBitzBarHeader = document.getElementsByClassName('menuTrTb')[0];
	var posLeft = getPositionLeft(objBitzBarHeader);
	var posTop = getPositionTop(objBitzBarHeader);
	
	var divSummaryArea = document.createElement("div");
	divSummaryArea.id="divSummaryArea";
	divSummaryArea.className = "containerClass";
	
	if(page != null && trim(page) == 'dashboard')
		divSummaryArea.style.width = "178px";
	else
		divSummaryArea.style.width = "168px";
	divSummaryArea.style.cursor = 'default';	
	divSummaryArea.style.height = "50px";
	divSummaryArea.style.position = "absolute";
	divSummaryArea.style.left = eval(posLeft-190)+'px';
	divSummaryArea.style.top = eval(posTop+35)+'px';
	if(page != null && trim(page) == 'dashboard')
	{
		divSummaryArea.innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
	}
	else
	{
		divSummaryArea.innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate map.</td></tr></table>';
	}
	//document.body.appendChild(divSummaryArea);
	funMakeSummaryHeader(page);*/
}
function funShowCrossedImage(objImg)
{
	var imgSrc = objImg.src;
	var newSrc = imgSrc.replace('.gif','Crossed.gif');
	objImg.src = newSrc;
}
function funHideCrossedImage(objImg)
{
	var imgSrc = objImg.src;
	var newSrc = imgSrc.replace('Crossed.gif','.gif');
	objImg.src = newSrc;
}
var cntLoadedBitz = 0;
function funAddBitToSummaryArea(bitName,page)
{
	if(page != null && trim(page) == 'dashboard')
	{
		if(cntLoadedBitz == 0)
		{
			//$('divSummaryArea').innerHTML = '';
		}
		var objDiv = document.createElement('div');
		objDiv.id = 'divSumBit_'+bitName;
		if(isIE)
			objDiv.style.styleFloat = 'left';
		else
			objDiv.style.cssFloat = 'left';
		objDiv.style.position = 'relative';
		objDiv.style.display = 'inline';
		objDiv.style.width = '29px';
		objDiv.style.height = '25px';
		objDiv.innerHTML = '<img src="/wt/'+bkTheme+'/images/common/'+bitName+'.gif" title="Remove '+unescape(widgetsData[bitName]['title']).stripTags()+'" alt="'+unescape(widgetsData[bitName]['title']).stripTags()+'" style="cursor:pointer" onmouseover="javascript:funShowCrossedImage(this);" onmouseout="javascript:funHideCrossedImage(this);" onclick="javascript:funRemoveBit(\''+bitName+'\',\''+page+'\');">';		
		//$('divSummaryArea').appendChild(objDiv);
		cntLoadedBitz = cntLoadedBitz + 1;
	}	
}
function funRemoveBit(bitName,page)
{
	if(page != null && trim(page) == 'dashboard')
	{
		funCloseWidget(null,bitName);
	}
}
function funRemoveImageFromSummaryArea(bitName,page,removeAll)
{
	if(removeAll != null && removeAll == true)
	{
		cntLoadedBitz = 0;
		//$('divSummaryArea').innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
		return;
	}
	if(page != null && trim(page) == 'dashboard')
	{
		//if(($('divSummaryArea') != null) && ($('divSumBit_'+bitName) != null))
		//	$('divSummaryArea').removeChild($('divSumBit_'+bitName));
		cntLoadedBitz = cntLoadedBitz - 1;
		if(cntLoadedBitz == 0)
		{
		//	$('divSummaryArea').innerHTML = '<table cellspacing="0" cellpadding="0" style="cursor:default;width:100%;height:100%;"><tr><td style="width:100%;height:100%;" align="center" valign="middle" class="infoSummaryHeader">Click icons on right to populate dashboard.</td></tr></table>';
		}
	}
}

function openChatPage()
{
	var url = '/help/interoContactUs.php?hCity=' + getSearchCookie("city") + '&hState=' + getSearchCookie("state");
	window.open (url, '', '');
}

function setMapItckBlank(dshbrdUsrId)
{
	if(typeof(dshbrdUsrId) != "undefined" && dshbrdUsrId != "")
		setCookie('strMapitCK','');
}

function addCommas(num)
{
	var nStr = new String(num);
	if(nStr.indexOf(',') > 0)
	{					
		nStr = nStr.replace(/\,/g,'');
	}
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function numFormat(txtPrice)
{
	if($(txtPrice).value != '')
	{
		var price = $(txtPrice).value;
	
		if(price.indexOf(',') > 0)
		{					
			price = price.replace(/\,/g,'');
		}
		$(txtPrice).value = addCommas(price);
	}
}

function keyDown(e,txtprice)
{
	var keycode = e.keyCode;
	if(keycode!=37&& keycode!=38 &&keycode!=39&&keycode!=40)
	{
		numFormat(txtprice);
	}
}

function roundPrice(txtPrice)
{
	if($(txtPrice).value != '')
	{
		var valPrice = $(txtPrice).value;
		
		if(valPrice.indexOf(',') >= 0)
		{			
			valPrice = valPrice.replace(/\,/g,'');
		}
		if (!isNaN(valPrice))
		{
		   //$(txtPrice).value=addCommas(Math.round(valPrice));
		   $(txtPrice).value=addCommas(Math.round(valPrice));
		}
	}
}

function setAllCheckedStyle(from)
{
	if(typeof(from)!="undefined")
	{
		divId = "RSpropStyleDv";
		chkAllId = "RSchkStyleAll";
	}
	else
	{
		divId = "propStyleDv";
		chkAllId = "chkStyleAll";
	}

	if($(divId))
	{
		var arrChkBox = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;

		for(var i=0;i<lenChkBox;i++)
		{	
			if(arrChkBox[i].id == chkAllId)
				continue;
			if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
				arrChkBox[i].checked = true;
			else if(arrChkBox[i].type == "checkbox")
				arrChkBox[i].checked = false;
		}
	}
}

/*function setAllCheckedParkingStyle()
{
	if($("parkingStyleDv"))
	{
		var arrChkBox = $("parkingStyleDv").getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;

		for(var i=0;i<lenChkBox;i++)
		{	
			if(arrChkBox[i].id == "chkParkingStyleAll")
				continue;
			if(($('chkParkingStyleAll').checked == true) && (arrChkBox[i].type == "checkbox"))
				arrChkBox[i].checked = true;
			else if(arrChkBox[i].type == "checkbox")
				arrChkBox[i].checked = false;
		}
	}
}*/

function chkAllOpt(chkAllID,divId)
{
   if($(divId))
	{
   var arrChkBox = $(divId).getElementsByTagName("input");
   lenOptWA = arrChkBox.length;
   lenOpt = arrChkBox.length - 1;
   chkCnt = 0;
   for(i=0;i<lenOptWA;i++)
   {
     if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
     {
       if(arrChkBox[i].id == chkAllID)
        continue;
       else
        chkCnt++; 
     }
   }
   if(chkCnt == lenOpt)
       $(chkAllID).checked = true;
   else
       $(chkAllID).checked = false; 
	}
}

function chkAllUnderDiv(divId,val)
{
	if($(divId)) {
		var arrChkBox = $(divId).getElementsByTagName("input");
		lenOptWA = arrChkBox.length;
		for(i=0;i<lenOptWA;i++)
		{
			if(arrChkBox[i].type == "checkbox" && val)		
				arrChkBox[i].checked = true;
			else
				arrChkBox[i].checked = false;
		}
	}
}

/*************** START ******************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/
function ClrQckSrchCookies()
{	
	if(typeof(localBitArr) != 'undefined') localBitArr = [];	
	if(typeof(map2) != 'undefined') {  map2.clearOverlays(); map2 = undefined; }
	if(typeof(ignoreCSZValidation) != "undefined" ) ignoreCSZValidation = 0;
	
	funClrQckSrchCookies();	
	if($("aSavSearch")) $('aSavSearch').show();
	if($("limitBar1")) $("limitBar1").style.display = "none";
	if($("paginationTd")) $("paginationTd").style.display = "none";	
	totalRecords = 0;	
	//TO CLEAR POWER SEARCH NEIGHBORHOOD
	if(typeof(clearNbr) == 'function' )
		clearNbr();
	if(typeof(clearGarage) == 'function' )
		clearGarage();
	if($("hdnNbrSrchType")) $("hdnNbrSrchType").value = "2";
	if(typeof(nbrSrchType) != "undefined") nbrSrchType = "";
	if($('proListingDiv')) $('proListingDiv').className="";
	if($('limitBar')) $('limitBar').innerHTML ='';
	if($('divAutoComp')) $('divAutoComp').hide();
	if($('divLocalSearch')) $('divLocalSearch').hide();
	tmpSpanMCTCookie = '';
	tmpSpanNBRCookie = '';
	if($('searchAddress')) $('searchAddress').disabled = false;
	if($('RSsearchAddress')) $('RSsearchAddress').disabled = false;	
	
	chkAllUnderDiv('divLocalSearch',false);
	removeSearchCookie("multicity");	
	removeSearchCookie("multizip");
	removeSearchCookie("mctSpanHTML");
	if($('showMultiCity')) $('showMultiCity').innerHTML = "";
	if($('showMultiZip')) $('showMultiZip').innerHTML = "";
	
	removeSearchCookie("County");
	removeSearchCookie("minPrice");
	removeSearchCookie("maxPrice");
	removeSearchCookie("listType");
	if(bkTheme == "reotexashomes")
	{ setSearchCookie("listType","bankOwned"); }
	removeSearchCookie("propDesc");
	removeSearchCookie("ckLFDate");
	removeSearchCookie("ckLTDate");
	removeSearchCookie("mlsno");
	removeSearchCookie("nbrSpanHTML");
	//removeSearchCookie("spanHTML");
	removeSearchCookie("lat");
	removeSearchCookie("lng");	
	removeSearchCookie("polygon");
	removeSearchCookie("area");		
	removeSearchCookie("keywordSrch");		
	if($('clrSerArea')) $('clrSerArea').style.display='none';
	if($('drawSerArea')) $('drawSerArea').style.display='';	
	lfDate = ''; ltDate = ''; mlsno = '';
	if($("RStxtLFDate"))  $("RStxtLFDate").value = '';
	if($("RStxtLTDate"))  $("RStxtLTDate").value = '';
	if($("RSsearchMLS")) $("RSsearchMLS").value = '';
	if($('frmAdvanceSearch')) $('frmAdvanceSearch').reset();
	if($('rsNHoodCntr')) $('rsNHoodCntr').style.display='none';	
	if($('shoNbhood')) $('shoNbhood').innerHTML= '';
	if($('keySerDiv'))  $('keySerDiv').innerHTML= '';
	//Added by surya for clearing the data from  temp string
	unChkstr  = "";
	chkdDat   = "";
	alwdCnt = 0 ;
	if (typeof(alwdCntMCT) != "undefined") alwdCntMCT = 0;
	if($('RSchbSHTypeAll')) $('RSchbSHTypeAll').checked = true;
	if($('polygonDiv')) $('polygonDiv').style.display='';	
	if($('serByNbrhood')) $('serByNbrhood').style.display='';		
	if($('searchMLS')) $('searchMLS').value = '';
	if($('pStatusList')) $('pStatusList').innerHTML = "";
	if($('pTypeList')) $('pTypeList').innerHTML = "";	
	if ($('crawlerNotificationArea'))
		$('crawlerNotificationArea').innerHTML = '';

	try 
	{
		funSetSHTypeAll('RS'); 
	} 
	catch (err)
	{ 
	}
	if($('RSsearchMLS')) $('RSsearchMLS').value = '';	
	if(typeof(initPower) != 'undefined' && !initPower) 
	{
		try {
				savePrpType(); 
			}
		catch(err)
		{
		
		}
	}
	if($('bit_select_box')) $('bit_select_box').value = "";
	if($('sub_rentals_selection')) $('sub_rentals_selection').hide();
	totalRecords = 0;	
	if(typeof(initPower) != 'undefined' && initPower)
	{
		var noRMsg = 'Select search criteria and Click "Agent View" Or "Consumer View".';
	}
	else
	{
		var noRMsg = 'Select search criteria and Click "Go".';
	}
	var noRecTblMsg = '<table align="center" id="noRecTbl" height="100%" cellspacing="0" cellpadding="0" style="width:450px;display:;"><tbody><tr><td valign="top" style="padding-top: 170px;"><table align="center" style="width: 490px;" valign="middle"><tbody><tr><td valign="top"><table cellspacing="0" cellpadding="0" border="0" align="center" style="width: 450px; height: 60px;" valign="middle"><tbody><tr style="height: 7px;"><td valign="bottom" class="msgTableTopleft"/><td valign="bottom" class="msgTableTopmid"/><td valign="bottom" class="msgTableTopright"/></tr><tr style="height: 44px;"><td class="msgTableCenleft"/><td class="msgTableCenmid"><font color="#666666"><span class="lang">'+noRMsg+'</span></font></td><td class="msgTableCenright"/></tr><tr style="height: 8px;"><td class="msgTableBotleft"/><td class="msgTableBotmid"/><td class="msgTableBotright"/></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table>';
	if($('proListingDiv')) { $('proListingDiv').innerHTML = noRecTblMsg; $('proListingDiv').show(); }
	if(!goToMap)
	{
		if($('SortPageTbl')) { $('SortPageTbl').hide(); }
		if($("picdivImg_0") && totalRecords > 0)
		{
			if($('favRoloDiv')) $('favRoloDiv').style.display = '';
		}
		else
		{
			if($('favRoloDiv')) $('favRoloDiv').style.display = 'none';
		}
		if( $('miniMapContainer') ) { $('miniMapContainer').style.display = 'none'; }
		if( $("mapDiv") ) { $("mapDiv").style.display = 'none'; }
		if( $("drawsearchinfobar") ) { $("drawsearchinfobar").style.display = 'none'; }		
		if($('impMapShow'))
		{
			$('impMapShow').hide(); 
			$('impMapShow').innerHTML='View On Map'; 
		}
	}
	clearChkBoxInDiv("prpTyp");
    clearChkBoxInDiv("prpStat");
	if($("searchAddress")) $("searchAddress").className = "textboxSH";
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("propStyle")
	if($('prpStyleText')) $('prpStyleText').innerHTML = "";
	if(typeof(showMultiCityRelated) != "undefined" && typeof(showMultiCityRelated) == "function") 
	{
		showMultiCityRelated();
	}
	if($('mlsSource') && $F('mlsSource') != "")
	{	
		$("mlsSrc.searchPs.template.jsScript").remove();
		var MlsSrcJsPath = "/js/mlsSrc.searchPs.template.js.php?mlsSrc="+$F('mlsSource');					
		includeJS(MlsSrcJsPath);
	}
	if(bkTheme == "emerge")
	{
		setSearchCookie("searchType","'Single Family','Residential'");
		if($("prpTypeText")) $("prpTypeText").innerHTML = "Residential";
	}	
}

/************************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/

/************************************* Lead Management For Ezee Doc Function Starts Here ***************************/

function createHomeValuePopUp()
{			
		if($('errLeadPro'))$('errLeadPro').innerHTML = "";
		if($('txtConsName')) $('txtConsName').className = "";
		if($('txtConsEmail')){$('txtConsEmail').className = "";$('txtConsEmail').value="";}
		if($('txtConsAddress'))$('txtConsAddress').className = "";
		if($('txtConsPhone'))$('txtConsPhone').className = "";
		if($('txtConsCity'))$('txtConsCity').className = "";
		if($('txtConsState'))$('txtConsState').className = "";
		if($('txtConsZip'))$('txtConsZip').className = "";
		
		//added for emerge
		if($('txtBeds')) $('txtBeds').className = "";
		if($('txtBaths')) $('txtBaths').className = "";
		if($('txtSqft')) $('txtSqft').className = "";
		if($('txtLotsize')) $('txtLotsize').className = "";
		if($('txtYearBuilt')) $('txtYearBuilt').className = "";
		if($('txtNeighborhood')) $('txtNeighborhood').className = "";

				flg=false;	
				
					if(($("txtAddress") && $("txtCSZ")) && ($("txtAddress") != null && $("txtCSZ")!= null))
					{
						var adr = escape($("txtAddress").value + "," + $("txtCSZ").value);
						var url = "/agentsite/processAgent.php";
						var qs = "process=validateAddress&address="+adr;
						ajaxRequest(url,qs,function(reqobj){ 
							var varResponse = trim(reqobj.responseText);
								if(varResponse != "")
								{
									flg = true;
									var arr = varResponse.split("|");
									
									if($("txtAddress"))$("txtAddress").value = arr[0];
									if($("txtCSZ"))$("txtCSZ").value = arr[1] + ", " + arr[2] + " " + arr[3];
									city=arr[1];
									state=arr[2];
									zip= arr[3];
								}
								else
								{
									alert("Invalid Address");
								}
						},false);

						if(flg)
						{
							if(top.$('leadFrmHomePopUp_c')) top.$('leadFrmHomePopUp_c').style.zIndex='27';
							if(top.$('leadFrmHomePopUp_mask')) top.$('leadFrmHomePopUp_mask').style.zIndex='26';
							if(top.$('leadFrmHomePopUp')) top.$('leadFrmHomePopUp').style.zIndex='25';

							if(top.$('leadFrmHomePopUp')) top.$('leadFrmHomePopUp').style.display= "block";
							top.$('txtConsAddress').value=$('txtAddress').value;
							top.$('txtConsCity').value=city;
							top.$('txtConsState').value=state;
							top.$('txtConsZip').value=zip;
							if(top.$('errEmailPro')) top.$('errEmailPro').innerHTML="&nbsp;";
							
							top.$('txtBeds').value = $('beds').value;
							top.$('txtBaths').value = $('baths').value;
							top.$('txtSqft').value = $('sqft').value;
							top.$('txtLotsize').value = $('lotsize').value;
							top.$('txtYearBuilt').value = $('yearbuilt').value;
							top.$('txtNeighborhood').value = "";
							
							top.leadEmailDlg1.show();
							if(top.$('txtConsName'))top.$('txtConsName').focus();	
						}
					}
					else
						{							
							if(typeof(estimateAddress) != "undefined"  && (typeof(estimateCity)!= "undefined" && typeof(estimateState)!= "undefined" && typeof(estimateZip)!= "undefined" ))
								{

										if($('leadFrmHomePopUp1')) $('leadFrmHomePopUp1').style.display= "block";	
										if($('txtConsName') != null)$('txtConsName').value = "";
										if($('txtConsAddress') != null){$('txtConsAddress').className=""; $('txtConsAddress').value=estimateAddress ; }
										if($('txtConsCity') != null){$('txtConsCity').className="" ; $('txtConsCity').value=estimateCity ;}
										if($('txtConsState') != null){$('txtConsState').className="" ; $('txtConsState').value=estimateState ;}
										if($('txtConsZip') != null){$('txtConsZip').className=""; $('txtConsZip').value=estimateZip ;}
										if(document.saleform.sale)
											document.saleform.sale[0].checked = true ;
										if($("txtConsComments") != null)$("txtConsComments").value = "";
										if($('errEmailPro')) $('errEmailPro').innerHTML="&nbsp;";		
										if(leadEmailDlg1 != "undefined") leadEmailDlg1.show();
										if($('leadFrmHomePopUp1_c')) $('leadFrmHomePopUp1_c').style.zIndex='17';
										if($('leadFrmHomePopUp1_mask')) $('leadFrmHomePopUp1_mask').style.zIndex='16';
								
										if($('txtBeds')) $('txtBeds').value = $('beds').value;
										if($('txtBaths')) $('txtBaths').value = $('baths').value;
										if($('txtSqft')) $('txtSqft').value = $('sqft').value;
										if($('txtLotsize')) $('txtLotsize').value = $('lotsize').value;
										if($('txtYearBuilt')) $('txtYearBuilt').value = $('yearbuilt').value;
										if($('txtNeighborhood')) $('txtNeighborhood').value = "";
								}
						}

			
				
				
			
}
	
/************************* Lead Management For Ezee Doc Function Ends Here *********************/

/*********************** USED FOR NEW POWER SEARCH AND LIST SEARCH CODE **********************/

function goToListSearch()
{
	//url = 	'/app/listing/singlePropertyLandingNew.php?city='+getSearchCookie("city")+'&state='+getSearchCookie("state");
	url = 	'/Search/'+getSearchCookie("state")+'/'+getSearchCookie("city");
	var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'frch' && qs.get("ouid") != null)
	{
		url += "?frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
	}
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "?frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	if(qs.get("ps") != null )
	{
		url += "?ps="+trim(qs.get("ps"));
	}
	location.href=url;
}
function goToTools()
{
	if(getSearchCookie("city")!="" && getSearchCookie("city").indexOf("|") > -1) // in case of multi city...jahnvi
	{
		var arrMulCity = getSearchCookie("city").split("|");
		var arrMulState = getSearchCookie("state").split("|");
		setSearchCookie("city",arrMulCity[0]);
		setSearchCookie("state",arrMulState[0]);
		setSearchCookie("multicity","");
	}
	url = 	'/terabitzApi/finance/index.php?city='+getSearchCookie("city")+'&state='+getSearchCookie("state");
	var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'frch' && qs.get("ouid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
	}
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	if(qs.get("ps") != null )
	{
		url += "&ps="+trim(qs.get("ps"));
	}

	location.href=url;
}


function clearChkBoxInDiv(divId)
{
        if($(divId))
		{			
			var arrChkBox = $(divId).getElementsByTagName("input");
			for(i=0;i<arrChkBox.length;i++)
			{
				if(arrChkBox[i].type == "checkbox" && arrChkBox[i].checked == true)
				{
					arrChkBox[i].checked = false;
				}
			}
        }
}

function clearCityStateMLS()
{
	removeSearchCookie("city");	
	removeSearchCookie("state");
	removeSearchCookie("mlsno");
}

// Added For Giving Alert To Registered User When It Clicks On Vendor Login Page

function redirectUser()
{
  var confirmation = confirm("All your current sessions will expire if you navigate to this page. Do u wish to continue. !!")
	if(confirmation == true)
	{
	    location.href = 'http://'+document.location.host+'/app/vendor/login.php';
	}
	else
		return false;
}

function checkInArray(fStr,serArr)
{
    for (key in serArr)
    {
        if(serArr[key] == fStr)
        return true;
    }
    return false;
}

function cmImplodeArr(arr,sep)
{
	var arrStr="";
	for(i=0;i<arr.length;i++)
	{	
		arrStr += arr[i];
		if(i<((arr.length) - 1)){arrStr += sep;}
	}
	return arrStr;
}

function cmExplodeArr(arrStr,sep)
{
	var arrSplt=Array();
	arrSplt=arrStr.split(sep);
	return arrSplt;
}

function goToToolsWithBit(bit, chkVar)
{
	url = 	'/terabitzApi/finance/index.php?city='+getSearchCookie("city")+'&state='+getSearchCookie("state");
	var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'frch' && qs.get("ouid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
	}
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "&frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	if(qs.get("ps") != null )
	{
		url += "&ps="+trim(qs.get("ps"));
	}
	if(bit != '')
		url += "&bit="+bit+"&chkVar=" + chkVar;
	location.href=url;
}

// To set value of list box
// used on list search and property alert
function setListBoxValue (listId, listVal)
{
	if ($(listId))
	{
		for (i=0; i<$(listId).length; i++)
		{
			if ($(listId)[i].value == listVal)
			{
				$(listId).selectedIndex = i;
				break;
			}
		}	
	}
}

function setMultiselectListBoxValue (listId, listVal, separator)
{
	if (separator == null)
		separator = ",";

	if ($(listId))
	{
		listVal = separator + listVal + separator;

		for (i=0; i<$(listId).length; i++)
		{
			if (listVal.indexOf (separator + $(listId)[i].value + separator) != -1)
			{
				$(listId)[i].selected = true;
			}
		}	
	}
}

function goToMapSearchEmerge()
{
	if(getSearchCookie("polygon"))
		removePolyRelated();
	if(getSearchCookie("neighborhood") && bkTheme != 'pruone')
		removeSearchCookie("neighborhood");

	if(getSearchCookie("city") == "")
	{
		if(typeof(defCity) == "undefined")
		{
			defCity = "Baton Rouge";
			defState = "LA";
			defLat = 30.46788;
			defLng = -91.129604;
		}

		defCity = defCity.replace('%20',' ');
		setSearchCookie("city",defCity);
		setSearchCookie("state",defState);
		setSearchCookie("lat",defLat);
		setSearchCookie("lng",defLng);
	}

	if(getSearchCookie("mlsno") && getSearchCookie("mlsno") != "")
		setSearchCookie("mlsno","");

	flgPoly = true;	
	if(flgPoly)
	{
		if(getSearchCookie("lat") && getSearchCookie("lat") != "")
		{
			//DO NOTHING
		}
		else if(getCookie("latLongCk") && getCookie("latLongCk") != "")
		{
			var mainLatLng = eval(getCookie("latLongCk"))[0];
			if(mainLatLng.lat == "")
				setSearchCookie("lat",defLat);
			else
				setSearchCookie("lat",mainLatLng.lat);

			if(mainLatLng.lng == "")
				setSearchCookie("lng",defLng);
			else
				setSearchCookie("lng",mainLatLng.lng);
		}
		else
			setSearchCookie("lat",defLat);

		if(getSearchCookie("lng") && getSearchCookie("lng") != "")
		{
			//DO NOTHING
		}
		else
			setSearchCookie("lng",defLng);
			
		setSearchCookie("searchAddress","");
		var url = "";
        if(typeof(mapToShow) != "undefined" && mapToShow == "")
			url='/app/listing/singlePropertyLanding.php?status=EXP&address=,'+getSearchCookie("city")+','+getSearchCookie("state")+','+getSearchCookie("zip")+',,,,'+getSearchCookie("lat")+','+getSearchCookie("lng")+'&widgetnames=';
		else
			url='/app/listing/singlePropertyLanding.php?status=N&code=propView=1:::searchAddress='+getSearchCookie("searchAddress")+':::city='+getSearchCookie("city")+':::state='+getSearchCookie("state")+':::zip='+getSearchCookie("zip")+':::neighborhood=:::county=:::minPrice=:::maxPrice=:::searchBeds=:::searchBaths=&mapCenter=('+getSearchCookie("lat")+','+getSearchCookie("lng")+')&valChkMapSearchSelect=1&fe=&f=1&propLatitude='+getSearchCookie("lat")+'&propLongitude='+getSearchCookie("lng")+'&clrbitz=1&mapZoom=13';
  		 
		 var qs = new Querystring();
		 var ct = getSearchCookie("city");
 		 var st = getSearchCookie("state");
		 if(qs.get("frm") != null && trim(qs.get("frm")) == 'frch' && qs.get("ouid") != null)
		{
			if(mapToShow == "")
			{
				url='/app/listing/singlePropertyLanding.php?status=EXP&address=,'+getSearchCookie("city")+','+getSearchCookie("state")+','+getSearchCookie("zip")+',,,,'+getSearchCookie("lat")+','+getSearchCookie("lng")+'&widgetnames=';
				url += "&frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
			}
			else
			{
				var shareURL = '&code=searchAddress='+getSearchCookie("searchAddress")+':::city='+getSearchCookie("city")+':::state='+getSearchCookie("state")+':::minPrice=:::maxPrice=:::minRent=:::maxRent=:::searchBeds=:::minSize=:::maxSize=:::searchBaths=:::searchType=:::searchSortType=:::yearFrom=:::yearTo=:::zip='+getSearchCookie("zip")+':::propView=1';
				url = 	'/app/listing/singlePropertyLanding.php?status=N' + shareURL + 'mapCenter=(' + getSearchCookie("lat") +',' +getSearchCookie("lng")+ ')&valChkMapSearchSelect=1&fe=&f=1&propLatitude=' +getSearchCookie("lat")+'&propLongitude='+getSearchCookie("lng") + '&clrbitz=1&mapZoom=13';
				url += "&frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
			}
		}
		 else if(typeof(agentSiteRendering) != 'undefined' && agentSiteRendering == true)
			 url += "&frm=agt&aid="+agentId;

	
		goToMap = true;
		//ClrQckSrchCookies(); commented by dhaval
		
		setSearchCookie("city",ct);
		setSearchCookie("state",st);
		
		location.href=url;
	}
}

function goToFCLSearch()
{
	url = 	'/app/listing/foreclosureListing.php';
	/*var qs = new Querystring();
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'frch' && qs.get("ouid") != null)
	{
		url += "?frm="+trim(qs.get("frm"))+"&ouid="+trim(qs.get("ouid"));
	}
	if(qs.get("frm") != null && trim(qs.get("frm")) == 'agt' && qs.get("aid") != null)
	{
		url += "?frm="+trim(qs.get("frm"))+"&aid="+trim(qs.get("aid"));
	}
	if(qs.get("ps") != null )
	{
		url += "?ps="+trim(qs.get("ps"));
	}*/
	location.href=url;
}
function mortgageApproval(from,agtid)
{	
	var url = "";
	if(typeof(from) == "undefined")
		url = '/app/listing/mortgageApproval.php';
	else if(typeof(from) != "undefined" && from == "")
		url = '/app/listing/mortgageApproval.php';
	else if(from == "agentsite")
		url = '/agentsite/mortgageApproval.php';

	var qs = '';
	
	var myQs = new Querystring(top.window.location.search.substring(1));
	var frm = myQs.get("frm");
	var aid = myQs.get("aid");

	if(frm != null && frm == "agt" && aid != null)
		qs += "frm=agt&aid="+aid;
	else if(typeof(agtid) != "undefined" && agtid != "")
		qs += "frm=agt&aid="+agtid;

	var cbfnLoadMortApprPopup = function(reqObj)
	{
		var response = trim(reqObj.responseText);
		$("divCalcBottomLine").innerHTML = response;
	} 	
	ajaxRequest(url,qs,cbfnLoadMortApprPopup,false);	
}

function clearAllObjMortAppr()
{
	$("txtName").value = "";
	$("txtNumber").value = "";
	$("txtEmail").value = "";
	$("txtTimeToCall").value = "";
	$("cmbTimeFrame").selectedIndex = 0;
	$("txtComments").value = "";
	if($("selectRealtor")) $("selectRealtor").selectedIndex = 0;
}

function validateFieldsMortAppr()
{
	var filter=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	var phonenumber = trim($("txtNumber").value);

	if(phonenumber == "")
	{
		alert("Please enter phone no.");
		$("txtNumber").focus();
		return false;
	}
	else if(phonenumber.match(/^[ ]*[(]{0,1}[ ]*[0-9]{3,3}[ ]*[)]{0,1}[-]{0,1}[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/) == null && phonenumber.match(/^[ ]*[0-9]{3,3}[ ]*[-]{0,1}[ ]*[0-9]{4,4}[ ]*$/) == null)
	{
		alert("Enter valid phone no.");
		$("txtNumber").value = "";
		$("txtNumber").focus();
		return false; 
	}
	
	if(trim($("txtEmail").value) == "")
	{
		alert("Please enter email address.");
		$("txtEmail").focus();
		return false;
	}
	else if (!filter.test(trim($("txtEmail").value)))
	{			
		alert("Enter valid email address.");
		$("txtEmail").value = "";
		$("txtEmail").focus();
		return false;
	}
	return true;
}

function sendMortAppr(aid)
{
	if(validateFieldsMortAppr())
	{
		var name = escape(trim($("txtName").value));
		var no = escape(trim($("txtNumber").value));
		var email = trim($("txtEmail").value);
		var timeToCall = escape(trim($("txtTimeToCall").value));
		var timeFrame = $("cmbTimeFrame").value;
		var comments = escape(trim($("txtComments").value));
		var realtor = "";

		if($("selectRealtor"))
			realtor = escape($("selectRealtor").value);		
		
		var qs = "op=mortgagrApproval";
		qs += "&name="+name+"&no="+no+"&email="+email+"&timeToCall="+timeToCall+"&timeFrame="+timeFrame+"&comments="+comments+"&realtor="+realtor;

		if(typeof(aid) != "undefined" && aid != "")
			qs += "&aid="+aid;

		var url = "/help/"+bkTheme+"/sendInfo.php";
		
		ajaxRequest(url,qs,function (req){
			var res = trim(req.responseText);

			if(res == "1")
				alert("Mail sent successfully.");
		},false);
		clearAllObjMortAppr();
	}
}

function isValidNumber(val){
	  if(val==null){return false;}
	  if (val.length==0){return false;}
	  var DecimalFound = false;
	  for (var i = 0; i < val.length; i++) {
			var ch = val.charAt(i);
			if (i == 0 && ch == "-") {
				  continue;
			}
			if (ch == "." && !DecimalFound) {
				  DecimalFound = true;
				  continue;
			}
			if (ch < "0" || ch > "9") {
				  return false;
			}
	  }
	  return true;
}

function funChklAllInDiv(divId,chkAllId)
{
	if($(divId))
	{
		var	arrChkBox  = $(divId).getElementsByTagName("input");
		var lenChkBox = arrChkBox.length;
		for(var i=0;i<lenChkBox;i++)
		{
			if(arrChkBox[i].id == chkAllId)
			{
				continue;
			}
			if(($(chkAllId).checked == true) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = true;
			}
			else if(($(chkAllId).checked == false) && (arrChkBox[i].type == "checkbox"))
			{
				arrChkBox[i].checked = false;
			}
		}
	}
}

//ANIL - start
function openQuickSearchLink(link) {
	ClrQckSrchCookiesReloaded();
	clearDrawnMap();
	window.location.href = link;
}

function clearDrawnMap() {
	removeSearchCookie("polygon");
	removeSearchCookie("area");
}

function ClrQckSrchCookiesReloaded()
{	
	removeSearchCookie("pool");
	removeSearchCookie("fire");
	removeSearchCookie("photo");
	removeSearchCookie("garage");
	removeSearchCookie("stories");
	removeSearchCookie("fromYear");
	removeSearchCookie("spanHTML");
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("searchAddress");
	removeSearchCookie("city");
 	removeSearchCookie("state");
	removeSearchCookie("zip");
	removeSearchCookie("county");
	removeSearchCookie("neighborhood");
	removeSearchCookie("searchBeds");
	removeSearchCookie("minSize");
	removeSearchCookie("maxSize");
	removeSearchCookie("searchBaths");
	removeSearchCookie("searchType");
	removeSearchCookie("searchSortType");
	removeSearchCookie("neighborhood");
	
	// for power search
	removeSearchCookie("mlsSource");
	removeSearchCookie("propType");
	removeSearchCookie("propStatus");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("minPSize");
	removeSearchCookie("maxPSize");
	removeSearchCookie("ckPLFDate");
	removeSearchCookie("ckPLTDate");
	removeSearchCookie("listAgentFnm");
	removeSearchCookie("listAgentLnm");
	removeSearchCookie("minLotSize");
	removeSearchCookie("maxLotSize");
	removeSearchCookie("fromAge");
	removeSearchCookie("toAge");
	removeSearchCookie("fromYear");
	removeSearchCookie("toYear");
	removeSearchCookie("marketDaysFrom");
	removeSearchCookie("marketDaysTo");
	removeSearchCookie("garage");
	removeSearchCookie("stories");
	removeSearchCookie("eleSchool");
	removeSearchCookie("midSchool");
	removeSearchCookie("highSchool");
	removeSearchCookie("saleDateFrom");
	removeSearchCookie("saleDateTo");
	removeSearchCookie("saleAgentFnm");
	removeSearchCookie("saleAgentLnm");
	removeSearchCookie("salePriceFrom");
	removeSearchCookie("salePriceTo");
	removeSearchCookie("powerradial");
	removeSearchCookie("listagtid");
	removeSearchCookie("saleagtid");
	removeSearchCookie("listoff");
	removeSearchCookie("saleoff");
	removeSearchCookie("fire");
	removeSearchCookie("pool");
	removeSearchCookie("roof");

	removeSearchCookie("multicity");	
	removeSearchCookie("mctSpanHTML");
	removeSearchCookie("minPrice");
	removeSearchCookie("maxPrice");
	removeSearchCookie("listType");
	removeSearchCookie("propDesc");
	removeSearchCookie("ckLFDate");
	removeSearchCookie("ckLTDate");
	removeSearchCookie("mlsno");
	removeSearchCookie("nbrSpanHTML");
	removeSearchCookie("lat");
	removeSearchCookie("lng");	
	removeSearchCookie("polygon");
	removeSearchCookie("area");		
	removeSearchCookie("spanStyleHTML");
	removeSearchCookie("propStyle")
}
//Added by Kashyap on 09-12-09
function openURL(url,target)
{
	if(target == "blank")
		window.open (url);
	else
		location.href = url;
}
//End
// -- end
function getApiData(map2, city, state, nhood, lat, lng, aid)
{
	if($("apiLoading")) $("apiLoading").show();
	if(city == null || city == 'undefined') {
		city = '';
		state = '';
	}
	else if(nhood == null || nhood == 'undefined') {
		nhood = '';
	}

	if (map2 != null && typeof(map2) != 'undefined')
	{
		glatlng = map2.getCenter();

		minx = glatlng.lng()-0.05;
		miny = glatlng.lat()-0.05;
		maxx = glatlng.lng()+0.05;
		maxy = glatlng.lat()+0.05;

		lat = glatlng.lat();
		lng = glatlng.lng();
	}
	else if (typeof(lat) != 'undefined' && typeof(lng) != 'undefined')
	{
		minx = lng-0.05;
		miny = lat-0.05;
		maxx = lng+0.05;
		maxy = lat+0.05;
	}
	else
	{
		minx = 0;
		miny = 0;
		maxx = 0;
		maxy = 0;

		lat = 0;
		lng = 0;
	}

    var url = "/getApiData.php?lat="+lat+"&lng="+lng+'&minx='+minx+'&miny='+miny+'&maxx='+maxx+'&maxy='+maxy + '&city=' + city + '&state=' + state + '&nhood=' + nhood + '&aid=' + aid;
    if($("schoolratingsdiv")) $("schoolratingsdiv").innerHTML = '';
    if($("areaphotosdiv")) $("areaphotosdiv").innerHTML = '';


	new Ajax.Request(url,{onCreate: function()
		{
			if($("apiLoading")) $("apiLoading").show();
		},method:"get",
		onComplete: function(){
			if($("apiLoading")) $("apiLoading").hide();
		},
		onSuccess:function(r) {
			if($("apiDiv")) $("apiDiv").show();
			apiresp = r.responseText.evalJSON(true);
            if($("schoolratingsdiv"))  $("schoolratingsdiv").innerHTML = apiresp.schools;
            if($("areaphotosdiv"))  $("areaphotosdiv").innerHTML = apiresp.areaphotos;
	}});
}
function doGeoCode(csz,addr)
{
	var url = "/classes/getCSZ.php";
	var qs = "csz="+trim(csz)+"&address="+addr;	
    var err = false;            
    var retArray = new $H();

	ajaxRequest(url,qs,function(r)
	{      
		response = eval('(' + trim(r.responseText) + ')');
		if(response[0].status == "0")
		{			
			retArray['addr'] = response[0].address;
			retArray['city'] = response[0].city;
			retArray['state'] = response[0].state;
			retArray['zip'] = response[0].zip;
			retArray['lat'] = response[0].latitude;
			retArray['lng']= response[0].longitude;
			var latLongStr = "[{'lat':'"+retArray['lat']+"','lng':'"+retArray['lng']+"'}]";
			var now = new Date();
			now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
			setCookie("latLongCk",latLongStr,now);	
		}
		else
		{			
			if(addr != "")
				alert("Sorry, We couldn't find a location for '"+ addr+ " " +csz+"'");			
			else
				alert("Sorry, We couldn't find a location for '"+csz+"'");
                        err = true; 
		}               
	},false);
	 
	 if(err)               
		  return false;
	  else 
		return retArray;
}

function getAllChkValues(id)
{
	var table = document.getElementById(id);
	var rows = table.getElementsByTagName("input");
	var noofcomp = rows.length;
	var num = noofcomp;
	var getChkedData = "";
	for (var i=0 ; i<num ; i++ )
	{
		if(rows[i].type == 'checkbox' && rows[i].checked)
		{
			if(getChkedData)
				getChkedData += ',';
			getChkedData += rows[i].value;
		}
	}
	return getChkedData;
}

function insertGmapCall(page)
{
	var url = "/gmap_track.php";
	var qs = "ref="+page;
	ajaxRequest(url,qs,function(res) 
	{	
	},false);
}

/*validation.js*/

var alertErrorMsg="";

function isYear(id)
{
	var dt = new Date();
	dt = dt.getFullYear();
	var yr = Number($(id).value);
	if(isNaN(yr))
	{
		alertErrorMsg = "Please Enter valid Year.";
		return false;
	}
	if(yr<1000 || yr>3000)
	{
		alertErrorMsg = "Please Enter valid Year.";
		return false;
	}
/*	if($(id).value.length != oflength)
	{
		alertErrorMsg = "Only "+oflength+" characters alllowed."
		return false;
	}*/
	return true;
}
function isSqft(id)
{
	var sqft = $(id).value;
	sqft = sqft.gsub(",","");
	if(isNaN(Number(sqft)))
	{
		alertErrorMsg = "Enter valid value.";
		return false;
	}
	return true;
}
function isOfLength(id,oflength,limit)
{
	if(limit==null)
	{
		if($(id).value.length != oflength)
		{
			alertErrorMsg = "Only "+oflength+" characters alllowed."
			return false;
		}
	}
	else
	if($(id).value.length > oflength)
	{
		alertErrorMsg = "Maximum "+oflength+" characters alllowed."
		return false;
	}
	return true;
}

function isOverMaxLength(id,maxlength)
{
	return $(id).value.length > maxlength;
}

function isUnderMinLength(id,minlength)
{
	return $(id).value.length < minlength;
}

function regExTest(id,expression)
{
	return $(id).value.match(expression) != null;
}

function isDecimal(val)
{
	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	return val.match(decimalRE) != null;
}

function isNonDecimal(number)
{
	numRegExp = /^[0-9]+$/
  	return numRegExp.test(number);
}

function isNonNegDecimal(element)
{
	var nonnegdecimalRE = "^[0-9][0-9]*(\\.[0-9]*)?$";
	return regExTest(element,nonnegdecimalRE);
}

function isProperMoney(id)
{
	if($(id).value<=0)
		return null;
	var nonnegdecimalRE = "^[0-9][0-9]*(\\.[0-9]*)?$";
	var num=String(money2num($(id).value));
	return num.match(nonnegdecimalRE) != null;
	
}

function usernameIsValid(id,min,max)
{
	if (!isBlank(id,'Username')) 
	{
		return false;
	}
	if (isOverMaxLength(id,max) || isUnderMinLength(id,min))
	{
		alertErrorMsg = "Username should between "+min+" - "+max+" characters";
		return false;
	}
	var uName = $(id).value;
	var iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
	for (var i = 0; i < uName.length; i++) 
	{
  		if (iChars.indexOf(uName.charAt(i)) != -1)
  		{
  			alertErrorMsg = "Username should not contain special characters";
  			return false;
  		}
  	}
	return true;
}

function passwordIsValid(id,reid,min,max)
{
	if ($F(id) != $F(reid))
	{
		alertErrorMsg = "Password do not match";
		return false;
	}
	if (!isBlank(id,'Password')) //|| (IsDecimal('txtName'))
	{
		return false;
	}
	if (isOverMaxLength(id,max) || isUnderMinLength(id,min))
	{
		alertErrorMsg = "Password should be between "+min+" - "+max+" characters";
		return false;
	}
	return true;
}

function emailIsValid(id)
{
	var testresults;
	if (!isBlank(id,"E-mail Address")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter E-mail.";
		return false;
	}
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid email address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

function emailIsValidByVal(email)
{
	var testresults;
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	if (filter.test(email))
	{
		testresults=true;
	}
	else
	{
		testresults=false;
	}
	return (testresults)
}

function chkOnlyEmailIsValid(id)
{
	var testresults;
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	
	if (filter.test(str) || str == "")
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid email address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

function isValidURL(id,newRegEx){

	var flag=0;
	if (!isBlank(id,"URL")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter URL.";
		return false;
	}
	var url=$F(id);

	if (url.indexOf ('http://') == -1)
	{
		if (url.indexOf ('https://') == -1)
		{
			$(id).focus();
			alertErrorMsg = "URL must start with http:// or https://";
			return false;
		}
		else
			flag=1;
	}
	else
		flag=1;

	if(flag==1)
	{
		if(url.substring(0,7)=="http://" || url.substring(0,8)=="https://" )
		{	//nothing 	
		}
		else
		{
			$(id).focus();
			alertErrorMsg = "URL must start with http:// or https://";
			return false;
		}

	}  
	var newRegCheck = false;
	if(newRegEx)
	{
		if(newRegEx != '' || newRegEx == '1')
			newRegCheck = true;
	}

	if(newRegCheck)
	{
		var RegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	}
	else
	{
		var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
	}

    if(RegExp.test(url))
	{
        return true;
    }
	else
	{
    	$(id).value="";
		$(id).focus();
		alertErrorMsg = "Please Enter valid URL.";		
        return false;
    }
} 

function validURL(id){
	if (!isBlank(id,"URL")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter URL.";
		return false;
	}
	var url=$F(id);
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url))
	{
        return true;
    }	
	else
	{
    	$(id).value="";
		$(id).focus();
		alertErrorMsg = "Please Enter valid URL.";		
        return false;
    }
}


function phoneIsValid(id,disp)
{
	var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;
	if(trim($(id).value)=="")
		return true;
//	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	if(numTotal($(id).value)==0)
	{
		alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		alertErrorMsg = "Phone is not Valid.\nPlease input in format like 306-954-2548";
		return false;
	}
	return true;
}


function validatePhone1(id,disp)
{
	var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;

	if(numTotal($(id).value)==0)
	{
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		return false;
	}
	return true;
}
function zipIsValid(id,how)
{
	(how==null)?"alert":"";
	var valid = "0123456789-";
	var hyphencount = 0;

	if($F(id) != "" && $F(id) != " ")
	{
		//alert("val = "+document.getElementById(id).value+"ens");
		if ($(id).value.length!=5 && $(id).value.length!=10)
		{
			if(how=="alert")
				_alert("Please enter your 5 digit or 5 digit+4 zip code.");
			else
				alertErrorMsg = "Please enter your 5 digit or 5 digit+4 zip code.";
			$(id).value="";
			$(id).focus();
			return false;
		}
		for (var i=0; i < $(id).value.length; i++)
		{
			temp = "" + $(id).value.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1")
			{
				if(how=="alert")
					_alert("Invalid characters in your zip code.  Please try again.");
				else
					alertErrorMsg = "Invalid characters in your zip code.";
				$(id).value="";
				$(id).focus();
				return false;
			}
			if ((hyphencount > 1) || (($(id).value.length==10) && ""+$(id).value.charAt(5)!="-"))
			{
				if(how=="alert")
					_alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
				else
					alertErrorMsg = "The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.";
				
				$(id).value="";
				$(id).focus();
				return false;
			}
		}
	}
	return true;
}

function zipValid(id)
{
	var valid = "0123456789-";
	var hyphencount = 0;

	if($F(id) != "" && $F(id) != " ")
	{
		//alert("val = "+document.getElementById(id).value+"ens");
		if ($(id).value.length!=5 && $(id).value.length!=10)
		{
			alertErrorMsg = "Please enter your 5 digit or 5 digit+4 zip code.";
			$(id).value="";
			$(id).focus();
			return false;
		}
		for (var i=0; i < $(id).value.length; i++)
		{
			temp = "" + $(id).value.substring(i, i+1);
			if (temp == "-") hyphencount++;
			if (valid.indexOf(temp) == "-1")
			{
				alertErrorMsg = "Invalid characters in your zip code.";
				$(id).value="";
				$(id).focus();
				return false;
			}
			if ((hyphencount > 1) || (($(id).value.length==10) && ""+$(id).value.charAt(5)!="-"))
			{
				alertErrorMsg = "The hyphen character should be used formatted properly.";
				$(id).value="";
				$(id).focus();
				return false;
			}
		}
	}
	return true;
}


function numberIsValid(id,msg,disp,min,max)
{
	if (($F(id) != "") && ($F(id) != " ") && (isNaN($F(id))))
	{
		alertErrorMsg=msg;
		//alert(msg);
		$(id).value="";
		$(id).focus();
		return false;
	}
	if (min !=null && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		alertErrorMsg=disp+" should be more than "+min+" characters";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if (max !=null && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		alertErrorMsg=disp+" should be less than "+max+" characters";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}

function albhabetIsValid(id,msg,disp,min,max)
{
	if(($F(id) != "") && ($F(id) != " ") && $F(id).match(/^[A-Za-z\s]+$/g) == null)
	{
		alertErrorMsg=msg;
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((min != null) && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+" should have atleast "+min+" characters.")
		alertErrorMsg="Value of "+disp+" should have atleast "+min+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((max != null) && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+"allows only "+max+" characters.")
		alertErrorMsg="Value of "+disp+"allows only "+max+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}

function alphaNumericIsValid(id,msg,disp,min,max)
{
	if(($F(id) != "") && ($F(id) != " ") && $F(id).match(/^[A-Za-z0-9_\s]+$/g) == null)
	{
		alertErrorMsg=msg;
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((min != null) && isUnderMinLength(id,min) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+" should have atleast "+min+" characters.")
		alertErrorMsg="Value of "+disp+" should have atleast "+min+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	if((max != null) && isOverMaxLength(id,max) && ($F(id) != "") && ($F(id) != " "))
	{
		//alert("Value of "+disp+"allows only "+max+" characters.")
		alertErrorMsg="Value of "+disp+"allows only "+max+" characters.";
		$(id).value="";
		$(id).focus();
		return false;
	}
	return true;
}


function isBlank(id,disp)
{
	if(trim($F(id)) == "")
	{
		alertErrorMsg="Please enter "+disp;
		$(id).focus();
		return false;
	}
	return true;
}
function isBlank_withoutfocus(id,disp)
{
	if(trim($F(id)) == "")
	{
		alertErrorMsg="Please enter "+disp;
		return false;
	}
	return true;
}
function IsNumeric(sText)

{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
function mobileIsValid(id,disp)
{
	var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;
	if(trim($(id).value)=="")
		return true;
//	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	if(numTotal($(id).value)==0)
	{
		alertErrorMsg = "Mobile number is not Valid.\nPlease input in format like 306-954-2548";
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		alertErrorMsg = "Mobile number is not Valid.\nPlease input in format like 306-954-2548";
		return false;
	}
	return true;
}
function faxIsValid(id,disp)
{
	var decimalRE = /^\s*(\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;
	if(trim($(id).value)=="")
		return true;
//	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	if(numTotal($(id).value)==0)
	{
		alertErrorMsg = "Fax number is not Valid.\nPlease input in format like 306-954-2548";
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		alertErrorMsg = "Fax number is not Valid.\nPlease input in format like 306-954-2548";
		return false;
	}
	return true;
}

function percentageIsValid(id)
{
	var testresults;
	var filter = /^\d{1,2}(\.\d{1,2})?$/;
	var str=$F(id);
	if (!isBlank(id,"Percentage")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter Percentage.";
		return false;
	}
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid Percentage value!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return testresults;
}


function siteIsValid(id)
{
	var testresults;
	if (!isBlank(id,"E-mail Address")) //|| (IsDecimal('txtName'))
	{
		alertErrorMsg = "Please Enter E-mail.";
		return false;
	}
	var str=$F(id);
	var filter=/^([\w-]+(?:\.[\w-]+)*)\.((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
	//var filter = /(\w+):\/\/([\w\.]+)\/([\w\/]+)/;
	if (filter.test(str))
	{
		testresults=true;
	}
	else
	{
		alertErrorMsg = "Please input a valid site address!";
		$(id).value="";
		$(id).focus();
		testresults=false;
	}
	return (testresults)
}

// Date Validation Javascript
// copyright 30th October 2004, by Stephen Chapman
// http://javascript.about.com

// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.

function valDateFmt(datefmt) {myOption = -1;
for (i=0; i<datefmt.length; i++) {if (datefmt[i].checked) {myOption = i;}}
if (myOption == -1) {_alert("You must select a date format");return ' ';}
return datefmt[myOption].value;}
function valDateRng(daterng) {myOption = -1;
for (i=0; i<daterng.length; i++) {if (daterng[i].checked) {myOption = i;}}
if (myOption == -1) {_alert("You must select a date range");return ' ';}
return daterng[myOption].value;}
function stripBlanks(fld) {var result = "";for (i=0; i<fld.length; i++) {
if (fld.charAt(i) != " " || c > 0) {result += fld.charAt(i);
if (fld.charAt(i) != " ") c = result.length;}}return result.substr(0,c);}
var numb = '0123456789';
function isValid(parm,val) {if (parm == "") return true;
for (i=0; i<parm.length; i++) {if (val.indexOf(parm.charAt(i),0) == -1)
return false;}return true;}
function isNum(parm) {return isValid(parm,numb);}
var mth = new Array(' ','january','february','march','april','may','june','july','august','september','october','november','december');
var day = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
function validateDate(fld,fmt,rng)
{
	var dd, mm, yy;
	var today = new Date;
	var t = new Date;
	fld = stripBlanks(fld);
	if (fld == '') return false;
	var d1 = fld.split('\/');
	if (d1.length != 3) d1 = fld.split(' ');
	if (d1.length != 3) return false;
	if (fmt == 'u' || fmt == 'U')
	{
	 	dd = d1[1];
	 	mm = d1[0];
	 	yy = d1[2];
	 }
	else if (fmt == 'j' || fmt == 'J') {
	  dd = d1[2]; mm = d1[1]; yy = d1[0];}
	else if (fmt == 'w' || fmt == 'W'){
	  dd = d1[0]; mm = d1[1]; yy = d1[2];}
	else return false;
	var n = dd.lastIndexOf('st');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('nd');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('rd');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf('th');
	if (n > -1) dd = dd.substr(0,n);
	n = dd.lastIndexOf(',');
	if (n > -1) dd = dd.substr(0,n);
	n = mm.lastIndexOf(',');
	if (n > -1) mm = mm.substr(0,n);
	if (!isNum(dd)) return false;
	if (!isNum(yy)) return false;
	if (!isNum(mm)) {
	  var nn = mm.toLowerCase();
	  for (var i=1; i < 13; i++) {
	    if (nn == mth[i] ||
	        nn == mth[i].substr(0,3)) {mm = i; i = 13;}
	  }
}
if (!isNum(mm)) return false;
dd = parseFloat(dd); mm = parseFloat(mm); yy = parseFloat(yy);
if (yy < 100) yy += 2000;
if (yy < 1582 || yy > 4881) return false;
if (mm == 2 && (yy%400 == 0 || (yy%4 == 0 && yy%100 != 0))) day[mm-1]++;
if (mm < 1 || mm > 12) return false;
if (dd < 1 || dd > day[mm-1]) return false;
t.setDate(dd); t.setMonth(mm-1); t.setFullYear(yy);
if (rng == 'p' || rng == 'P') {
if (t > today) return false;
}
else if (rng == 'f' || rng == 'F') {
if (t < today) return false;
}
else if (rng != 'a' && rng != 'A') return false;
return true;
}

/*Function to check phone validation in format 306-954-2548 or 3-306-954-2548 */
function validatePhone(id,disp)
{
	var title = '';
	if(trim(disp)!='')
		title = disp;
	else
		title = 'Phone';

	var decimalRE = /^\s*(\d{1}-\d{3}-\d{3}-\d{4}|\d{3}-\d{3}-\d{4}|\(\d{3}\) \d{3}-\d{4})\s*$/;
	//var decimalRE = /^\s*(\d{1}-\d{3}-\d{3}-\d{4}|\(\d{1}\-\d{3}\) \d{3}-\d{4})\s*$/;
	if(trim($(id).value)=="")
		return true;
//	var decimalRE = "^(\\+|-)?[0-9][0-9]*(\\.[0-9]*)?$";
	if(numTotal($(id).value)==0)
	{
		alertErrorMsg = title + " is not Valid. \nPlease input in format like 306-954-2548 or 3-306-954-2548";
		return false;
		
	}
	if (trim($F(id)) != "" && $(id).value.match(decimalRE) == null)
	{
		alertErrorMsg = title + " is not Valid. \nPlease input in format like 306-954-2548 or 3-306-954-2548";
		return false;
	}
	return true;
}
	/*----------------------------------SUGGESTION EMAIL POPUP VALIDATION START--------------------------------- */
	var sugEmailPopup;
	function showSuggestionPopup()
	{	
		if($('emailPopupSuggestion'))
		{
			sugEmailPopup = createDialog('emailPopupSuggestion');		
			$('emailPopupSuggestion').style.display='block';
			if($('emailPopupSuggestion_c')) $('emailPopupSuggestion_c').style.zIndex='17';
			if($('emailPopupSuggestion_mask')) $('emailPopupSuggestion_mask').style.zIndex='16';
			if($('divContainerAdvanceSearch')) $('divContainerAdvanceSearch').style.zIndex='15';
			sugEmailPopup.show();			
			$('errEmailPro').innerHTML = '';
			$('txtComments').className = ''; $('txtComments').value = '';
			$('txtEmail').className = ''; $('txtEmail').value = '';
			$('txtName').className = ''; $('txtName').value = '';
			$('errEmailPro').innerHTML = '';
			$('sent').value = '0';

			//hide all related zindex specific div related to BUG# 10875
			if($("powerAdvSearch")) $("powerAdvSearch").style.display = "none";
			if($("divSaveSearch")) $("divSaveSearch").style.display = "none";
			if($("prpTyp")) $("prpTyp").style.display = "none";
			if($("prpStat")) $("prpStat").style.display = "none";
			if($("trSaleDate")) $("trSaleDate").style.display = "none";

			if(typeof(spl)!= "undefined")
			{	if(!spl)
				{
					hideMapList();	
					hidePwrsrchrel();
				}
			}
			
			//related to the bug specific to suggestion box;
			//Hide ProListing DIV
			if($('mapDiv') && $('mapDiv').style.display!='none')
			{
				if($("proListingDiv")){$("proListingDiv").style.display="none";}
			}
			//hide all related zindex specific div
		}
	}
	function sendSuggestion()
	{
		if($('sent').value == '0')
		{
			$('errEmailPro').innerHTML = '';
			$('txtComments').className = '';
			$('txtEmail').className = '';
			$('txtName').className = '';
			$('errEmailPro').innerHTML = '';			
			var sent = false;
			var comments = trim($('txtComments').value);
			var name = trim($('txtName').value);
			var email = trim($('txtEmail').value);
			var specialchars = "!@#$%^&*()+=-[]\\\';,/{}|\":<>?``";


			if(name)
			{
				var fName = name;
				for (var charNo = 0; charNo < fName.length; charNo++) 
				{
					if (specialchars.indexOf(fName.charAt(charNo)) != -1)
					{
						errorMsg = "Name should not contain special characters.";
						$('errEmailPro').innerHTML = errorMsg;
						$('txtName').className 	= "textboxRed";
						$('txtName').focus();
						return false ;	  				
					}
				}
			}
			
			if(email != '' && !emailIsValid("txtEmail"))
			{
				$('errEmailPro').innerHTML = "Please specify valid email.";
				$('txtEmail').focus();
				$('txtEmail').className="textboxRed";
				return false;
			}
			if(comments == '')
			{
				$('errEmailPro').innerHTML = "Please specify suggestions.";
				$('txtComments').focus();
				$('txtComments').className="textboxRed";
				return false;
			}
			if(comments)
			{			
				var specialchars = "#%^()+=[]\\\'/{}|\"<>``";
				for (var charNo = 0; charNo < comments.length; charNo++) 
				{
					if (specialchars.indexOf(comments.charAt(charNo)) != -1)
					{
						errorMsg = "Suggestions should not contain special characters.";
						$('errEmailPro').innerHTML = errorMsg;
						$('txtComments').className 	= "textboxRed";
						$('txtComments').focus();
						return false ;	  				
					}
				}
			}
			$('sent').value = '1';
			var url = "/app/listing/singlePropertyLandingNew.php";
			var qs = "action=suggestion&name="+name+"&email="+email+"&comments="+encodeURI(comments);
			ajaxRequest(url,qs,function(reqobj)
			{ 
				var varResponse = trim(reqobj.responseText);	
				if(varResponse == '1')
				{
					$('errEmailPro').innerHTML = "Your suggestions have been sent successfully.";
					$('txtComments').value = '';
					$('txtName').value = '';
					$('txtEmail').value = '';
					$('sent').value = '0';
				}
				else
				{
					$('errEmailPro').innerHTML = "Problem in email sending.";					
					$('sent').value = '0';
				}
				setTimeout('sugEmailPopup.hide();',800);
			});
		}
	}
 /*----------------------------------SUGGESTION EMAIL POPUP VALIDATION END--------------------------------- */
 function validateMultiZip(id,how)
 {
	(how==null)?"alert":"";	
	var valid="0123456789,";
	if ($(id).value=="")
	{
		alert("Please enter zip code.");
		$(id).value="";
		$(id).focus();
		return false;

	}
	else
	{
		for (var i=0; i < $(id).value.length; i++)
		{
			temp = "" + $(id).value.substring(i, i+1);
			if (valid.indexOf(temp) == "-1")
			{
				if(how=="alert")
					alert("Invalid characters in your zip code.  Please try again.");
				else
					alertErrorMsg = "Invalid characters in your zip code.";
				$(id).value="";
				$(id).focus();
				return false;
			}
		}
	}
 }

/*brokerAdminLogin.js*/

function getEvent(event)
{
	if (event.keyCode==13)
	{
		if($("loginDiv").visible())
		{
			validateBrokerAdmin();
		}
		else if($("fPassDiv").visible())
		{
			validateForgetPass();
		}
		else
		{
			return;
		}
	}
	
}

function validateBrokerAdmin()
{
	/*if(!alphaNumericIsValid('userName',"Username should not contain special characters.","Username",null,null))
	{
		$('errSysLogin').innerHTML=alertErrorMsg;
		$('userName').focus();
		$('userName').value = "";
		$('userName').className="textboxRed";
		$('userPwd').className="textbox";
		return false;
	}*/
	$('errSysLogin').innerHTML = '';

	if(!isBlank('userName',"User Name"))
	{
		$('errSysLogin').innerHTML=alertErrorMsg;
		$('userName').focus();
		$('userName').className="bkaLoginTxtBoxRed";
		$('userPwd').className="bkaLoginTxtBox";
		return false;
	}
	if(!isBlank('userPwd',"Password"))
	{
		$('errSysLogin').innerHTML=alertErrorMsg;
		$('userPwd').focus();
		$('userName').className="bkaLoginTxtBox";
		$('userPwd').className="bkaLoginTxtBoxRed";
		return false;
	}
	var url = './validateBrokerAdmin.php';
	var queryString = "uid=" + $('userName').value + "&pass=" + escape($('userPwd').value);
	ajaxRequest(url,queryString,
	responseLogin = function(originalRequest)
	{
		var response = originalRequest.responseText;
		if(response==0)
		{
			$('userName').focus();
			$('userName').value = "";
			$('userPwd').value = "";
			$('userName').className="bkaLoginTxtBox";
			$('userPwd').className="bkaLoginTxtBox";
			alert('Incorrect login information');
		}
		else
		{	
			rememberIdPassword($('userName').value,$('userPwd').value);
			if($('hiddenCmpId') && $('hiddenCmpId').value != '')
			{
				if($('hiddendlp') && $('hiddendlp').value == 'dlp')
				{
					location.href ='./DLP/viewC1.php?from=dlp&cmp_id=' + $('hiddenCmpId').value + '&cid=' + $('hiddenCid').value;	
				}
				else
				{
					location.href ='./CMP/viewC1.php?cmp_id=' + $('hiddenCmpId').value + '&cid=' + $('hiddenCid').value;
				}
			}
			else if(backurl!="")
			{	
				location.href =backurl;		
			}
			else
			{
				location.href ='/brokerAdmin/brokerAdmin.php';
			}
			//location.href ='./offAgtListing.php?PHPSESSID='+sessid;		
		}
	});


}



function validateForgetPass()
{
	if(!isBlank('fUserName','User Name'))
	{
		$('errForgotLogin').innerHTML = alertErrorMsg;
		$('fUserName').className = 'bkaLoginTxtBoxRed';
		return false;	
	}
	$('errSysLogin').innerHTML = '&nbsp;';
	$('userName').className = 'bkaLoginTxtBox';
	var url = './validateBrokerAdmin.php';
	var qs = "from=forgetPass";
	qs = qs + "&username="+$('fUserName').value;
	ajaxRequest(url,qs,responseFPass);
}
function responseFPass(originalRequest)
{
	var res = originalRequest.responseText;
	if(res==1)
	{
		alert('Email has been sent to you.');
		$('fPassDiv').style.display = 'none';
		$('loginDiv').style.display = 'block';
		$('userName').focus();
	}
	else
	{
		alert('You are not registered with the system or\n Your account is not active with system !!');	
		$('fPassDiv').style.display = 'none';
		$('loginDiv').style.display = 'block';
		$('achForgotLink').style.display = 'block';		
		$('userName').focus();
	}
		
}
/*----------------------------------------------------/
if remember id,password checkbox is selected on login
cookie will b set or unset.....Jahnvi Thaker
/----------------------------------------------------*/
function rememberIdPassword(uname,password)
{
	strCookie = uname+";"+password;
	var now = new Date();
	now.setTime(now.getTime() + 3650 * 24 * 60 * 60 * 1000);
	if($("chkRemember").checked == true)
	{
		setCookie("rememberIdPassword",strCookie,now);
	}
	else
	{
		setCookie("rememberIdPassword","");
	}
}
function chkCookieRemember()
{
	var strck = "";
	strck = getCookie("rememberIdPassword");
	if(strck=="" || strck==null )
	{}
	else
	{
		var strcksplit = strck.split(";");
		$("userName").value = strcksplit[0];
		$("userPwd").value = strcksplit[1];
		$("chkRemember").checked = true
	}

}

function loadDiv()
{
	$('formDiv').show();
	logRegFrm = createDialog('formDiv');
	logRegFrm.beforeHideEvent.subscribe(backToHistory, this);
	logRegFrm.show();
	$('userName').focus();

	chkCookieRemember();
}

function backToHistory()
{
	//location.href = "../../index.php";
	if ( trim(fromPage) != "" && trim(fromPage) == "signOut" || trim(fromPage) == 'guestLeadMail' || (fromPage.indexOf("indexLeadDetails")>-1) ) 
		location.href = "/index.php";
	else
	{
		if(document.referrer !="")
			location.href = document.referrer;
	}

}