/*
 * jQuery JavaScript Library v1.3.2
 * http://jquery.com/
 *
 * Copyright (c) 2009 John Resig
 * Dual licensed under the MIT and GPL licenses.
 * http://docs.jquery.com/License
 *
 * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009)
 * Revision: 6246
 */
(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F<J;F++){var G=M[F];if(G.selected){K=o(G).val();if(H){return K}L.push(K)}}return L}return(E.value||"").replace(/\r/g,"")}return g}if(typeof K==="number"){K+=""}return this.each(function(){if(this.nodeType!=1){return}if(o.isArray(K)&&/radio|checkbox/.test(this.type)){this.checked=(o.inArray(this.value,K)>=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G<E;G++){L.call(K(this[G],H),this.length>1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H<I;H++){if((G=arguments[H])!=null){for(var F in G){var K=J[F],L=G[F];if(J===L){continue}if(E&&L&&typeof L==="object"&&!L.nodeType){J[F]=o.extend(E,K||(L.length!=null?[]:{}),L)}else{if(L!==g){J[F]=L}}}}}return J};var b=/z-?index|font-?weight|opacity|zoom|line-?height/i,q=document.defaultView||{},s=Object.prototype.toString;o.extend({noConflict:function(E){l.$=p;if(E){l.jQuery=y}return o},isFunction:function(E){return s.call(E)==="[object Function]"},isArray:function(E){return s.call(E)==="[object Array]"},isXMLDoc:function(E){return E.nodeType===9&&E.documentElement.nodeName!=="HTML"||!!E.ownerDocument&&o.isXMLDoc(E.ownerDocument)},globalEval:function(G){if(G&&/\S/.test(G)){var F=document.getElementsByTagName("head")[0]||document.documentElement,E=document.createElement("script");E.type="text/javascript";if(o.support.scriptEval){E.appendChild(document.createTextNode(G))}else{E.text=G}F.insertBefore(E,F.firstChild);F.removeChild(E)}},nodeName:function(F,E){return F.nodeName&&F.nodeName.toUpperCase()==E.toUpperCase()},each:function(G,K,F){var E,H=0,I=G.length;if(F){if(I===g){for(E in G){if(K.apply(G[E],F)===false){break}}}else{for(;H<I;){if(K.apply(G[H++],F)===false){break}}}}else{if(I===g){for(E in G){if(K.call(G[E],E,G[E])===false){break}}}else{for(var J=G[0];H<I&&K.call(J,H,J)!==false;J=G[++H]){}}}return G},prop:function(H,I,G,F,E){if(o.isFunction(I)){I=I.call(H,F)}return typeof I==="number"&&G=="curCSS"&&!b.test(E)?I+"px":I},className:{add:function(E,F){o.each((F||"").split(/\s+/),function(G,H){if(E.nodeType==1&&!o.className.has(E.className,H)){E.className+=(E.className?" ":"")+H}})},remove:function(E,F){if(E.nodeType==1){E.className=F!==g?o.grep(E.className.split(/\s+/),function(G){return !o.className.has(F,G)}).join(" "):""}},has:function(F,E){return F&&o.inArray(E,(F.className||F).toString().split(/\s+/))>-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+"></"+T+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("<opt")&&[1,"<select multiple='multiple'>","</select>"]||!O.indexOf("<leg")&&[1,"<fieldset>","</fieldset>"]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"<table>","</table>"]||!O.indexOf("<tr")&&[2,"<table><tbody>","</tbody></table>"]||(!O.indexOf("<td")||!O.indexOf("<th"))&&[3,"<table><tbody><tr>","</tr></tbody></table>"]||!O.indexOf("<col")&&[2,"<table><tbody></tbody><colgroup>","</colgroup></table>"]||!o.support.htmlSerialize&&[1,"div<div>","</div>"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/<tbody/i.test(S),N=!O.indexOf("<table")&&!R?L.firstChild&&L.firstChild.childNodes:Q[1]=="<table>"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E<F;E++){if(H[E]===G){return E}}return -1},merge:function(H,E){var F=0,G,I=H.length;if(!o.support.getAll){while((G=E[F++])!=null){if(G.nodeType!=8){H[I++]=G}}}else{while((G=E[F++])!=null){H[I++]=G}}return H},unique:function(K){var F=[],E={};try{for(var G=0,H=K.length;G<H;G++){var J=o.data(K[G]);if(!E[J]){E[J]=true;F.push(K[G])}}}catch(I){F=K}return F},grep:function(F,J,E){var G=[];for(var H=0,I=F.length;H<I;H++){if(!E!=!J(F[H],H)){G.push(F[H])}}return G},map:function(E,J){var F=[];for(var G=0,H=E.length;G<H;G++){var I=J(E[G],G);if(I!=null){F[F.length]=I}}return F.concat.apply([],F)}});var C=navigator.userAgent.toLowerCase();o.browser={version:(C.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[0,"0"])[1],safari:/webkit/.test(C),opera:/opera/.test(C),msie:/msie/.test(C)&&!/opera/.test(C),mozilla:/mozilla/.test(C)&&!/(compatible|webkit)/.test(C)};o.each({parent:function(E){return E.parentNode},parents:function(E){return o.dir(E,"parentNode")},next:function(E){return o.nth(E,2,"nextSibling")},prev:function(E){return o.nth(E,2,"previousSibling")},nextAll:function(E){return o.dir(E,"nextSibling")},prevAll:function(E){return o.dir(E,"previousSibling")},siblings:function(E){return o.sibling(E.parentNode.firstChild,E)},children:function(E){return o.sibling(E.firstChild)},contents:function(E){return o.nodeName(E,"iframe")?E.contentDocument||E.contentWindow.document:o.makeArray(E.childNodes)}},function(E,F){o.fn[E]=function(G){var H=o.map(this,F);if(G&&typeof G=="string"){H=o.multiFilter(G,H)}return this.pushStack(o.unique(H),E,G)}});o.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(E,F){o.fn[E]=function(G){var J=[],L=o(G);for(var K=0,H=L.length;K<H;K++){var I=(K>0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}});
/*
 * Sizzle CSS Selector Engine - v0.9.3
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa<ab.length;aa++){if(ab[aa]===ab[aa-1]){ab.splice(aa--,1)}}}}}return ab};F.matches=function(T,U){return F(T,null,null,U)};F.find=function(aa,T,ab){var Z,X;if(!aa){return[]}for(var W=0,V=I.order.length;W<V;W++){var Y=I.order[W],X;if((X=I.match[Y].exec(aa))){var U=RegExp.leftContext;if(U.substr(U.length-1)!=="\\"){X[1]=(X[1]||"").replace(/\\/g,"");Z=I.find[Y](X,T,ab);if(Z!=null){aa=aa.replace(I.match[Y],"");break}}}}if(!Z){Z=T.getElementsByTagName("*")}return{set:Z,expr:aa}};F.filter=function(ad,ac,ag,W){var V=ad,ai=[],aa=ac,Y,T,Z=ac&&ac[0]&&Q(ac[0]);while(ad&&ac.length){for(var ab in I.filter){if((Y=I.match[ab].exec(ad))!=null){var U=I.filter[ab],ah,af;T=false;if(aa==ai){ai=[]}if(I.preFilter[ab]){Y=I.preFilter[ab](Y,aa,ag,ai,W,Z);if(!Y){T=ah=true}else{if(Y===true){continue}}}if(Y){for(var X=0;(af=aa[X])!=null;X++){if(af){ah=U(af,Y,X,aa);var ae=W^!!ah;if(ag&&ah!=null){if(ae){T=true}else{aa[X]=false}}else{if(ae){ai.push(af);T=true}}}}}if(ah!==g){if(!ag){aa=ai}ad=ad.replace(I.match[ab],"");if(!T){return[]}break}}}if(ad==V){if(T==null){throw"Syntax error, unrecognized expression: "+ad}else{break}}V=ad}return aa};var I=F.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(T){return T.getAttribute("href")}},relative:{"+":function(aa,T,Z){var X=typeof T==="string",ab=X&&!/\W/.test(T),Y=X&&!ab;if(ab&&!Z){T=T.toUpperCase()}for(var W=0,V=aa.length,U;W<V;W++){if((U=aa[W])){while((U=U.previousSibling)&&U.nodeType!==1){}aa[W]=Y||U&&U.nodeName===T?U||false:U===T}}if(Y){F.filter(T,aa,true)}},">":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){var W=Y.parentNode;Z[V]=W.nodeName===U?W:false}}}else{for(var V=0,T=Z.length;V<T;V++){var Y=Z[V];if(Y){Z[V]=X?Y.parentNode:Y.parentNode===U}}if(X){F.filter(U,Z,true)}}},"":function(W,U,Y){var V=L++,T=S;if(!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("parentNode",U,V,W,X,Y)},"~":function(W,U,Y){var V=L++,T=S;if(typeof U==="string"&&!U.match(/\W/)){var X=U=Y?U:U.toUpperCase();T=P}T("previousSibling",U,V,W,X,Y)}},find:{ID:function(U,V,W){if(typeof V.getElementById!=="undefined"&&!W){var T=V.getElementById(U[1]);return T?[T]:[]}},NAME:function(V,Y,Z){if(typeof Y.getElementsByName!=="undefined"){var U=[],X=Y.getElementsByName(V[1]);for(var W=0,T=X.length;W<T;W++){if(X[W].getAttribute("name")===V[1]){U.push(X[W])}}return U.length===0?null:U}},TAG:function(T,U){return U.getElementsByTagName(T[1])}},preFilter:{CLASS:function(W,U,V,T,Z,aa){W=" "+W[1].replace(/\\/g,"")+" ";if(aa){return W}for(var X=0,Y;(Y=U[X])!=null;X++){if(Y){if(Z^(Y.className&&(" "+Y.className+" ").indexOf(W)>=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return U<T[3]-0},gt:function(V,U,T){return U>T[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W<T;W++){if(Y[W]===Z){return false}}return true}}}},CHILD:function(T,W){var Z=W[1],U=T;switch(Z){case"only":case"first":while(U=U.previousSibling){if(U.nodeType===1){return false}}if(Z=="first"){return true}U=T;case"last":while(U=U.nextSibling){if(U.nodeType===1){return false}}return true;case"nth":var V=W[2],ac=W[3];if(V==1&&ac==0){return true}var Y=W[0],ab=T.parentNode;if(ab&&(ab.sizcache!==Y||!T.nodeIndex)){var X=0;for(U=ab.firstChild;U;U=U.nextSibling){if(U.nodeType===1){U.nodeIndex=++X}}ab.sizcache=Y}var aa=T.nodeIndex-ac;if(V==0){return aa==0}else{return(aa%V==0&&aa/V>=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V<T;V++){U.push(X[V])}}else{for(var V=0;X[V];V++){U.push(X[V])}}}return U}}var G;if(document.documentElement.compareDocumentPosition){G=function(U,T){var V=U.compareDocumentPosition(T)&4?-1:U===T?0:1;if(V===0){hasDuplicate=true}return V}}else{if("sourceIndex" in document.documentElement){G=function(U,T){var V=U.sourceIndex-T.sourceIndex;if(V===0){hasDuplicate=true}return V}}else{if(document.createRange){G=function(W,U){var V=W.ownerDocument.createRange(),T=U.ownerDocument.createRange();V.selectNode(W);V.collapse(true);T.selectNode(U);T.collapse(true);var X=V.compareBoundaryPoints(Range.START_TO_END,T);if(X===0){hasDuplicate=true}return X}}}}(function(){var U=document.createElement("form"),V="script"+(new Date).getTime();U.innerHTML="<input name='"+V+"'/>";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="<a href='#'></a>";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="<p class='TEST'></p>";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="<div class='test e'></div><div class='test'></div>";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1&&!ac){T.sizcache=Y;T.sizset=W}if(T.nodeName===Z){X=T;break}T=T[U]}ad[W]=X}}}function S(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W<V;W++){var T=ad[W];if(T){if(ab&&T.nodeType===1){T.sizcache=Y;T.sizset=W}T=T[U];var X=false;while(T){if(T.sizcache===Y){X=ad[T.sizset];break}if(T.nodeType===1){if(!ac){T.sizcache=Y;T.sizset=W}if(typeof Z!=="string"){if(T===Z){X=true;break}}else{if(F.filter(Z,[T]).length>0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z<U;Z++){F(T,V[Z],W)}return F.filter(X,W)};o.find=F;o.filter=F.filter;o.expr=F.selectors;o.expr[":"]=o.expr.filters;F.selectors.filters.hidden=function(T){return T.offsetWidth===0||T.offsetHeight===0};F.selectors.filters.visible=function(T){return T.offsetWidth>0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F<E.length){o.event.proxy(G,E[F++])}return this.click(o.event.proxy(G,function(H){this.lastToggle=(this.lastToggle||0)%F;H.preventDefault();return E[this.lastToggle++].apply(this,arguments)||false}))},hover:function(E,F){return this.mouseenter(E).mouseleave(F)},ready:function(E){B();if(o.isReady){E.call(document,o)}else{o.readyList.push(E)}return this},live:function(G,F){var E=o.event.proxy(F);E.guid+=this.selector+G;o(document).bind(i(G,this.selector),this.selector,E);return this},die:function(F,E){o(document).unbind(i(F,this.selector),E?{guid:E.guid+this.selector+F}:null);return this}});function c(H){var E=RegExp("(^|\\.)"+H.type+"(\\.|$)"),G=true,F=[];o.each(o.data(this,"events").live||[],function(I,J){if(E.test(J.type)){var K=o(H.target).closest(J.data)[0];if(K){F.push({elem:K,fn:J})}}});F.sort(function(J,I){return o.data(J.elem,"closest")-o.data(I.elem,"closest")});o.each(F,function(){if(this.fn.call(this.elem,H,this.fn.data)===false){return(G=false)}});return G}function i(F,E){return["live",F,E.replace(/\./g,"`").replace(/ /g,"|")].join(".")}o.extend({isReady:false,readyList:[],ready:function(){if(!o.isReady){o.isReady=true;if(o.readyList){o.each(o.readyList,function(){this.call(document,o)});o.readyList=null}o(document).triggerHandler("ready")}}});var x=false;function B(){if(x){return}x=true;if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);o.ready()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);o.ready()}});if(document.documentElement.doScroll&&l==l.top){(function(){if(o.isReady){return}try{document.documentElement.doScroll("left")}catch(E){setTimeout(arguments.callee,0);return}o.ready()})()}}}o.event.add(l,"load",o.ready)}o.each(("blur,focus,load,resize,scroll,unload,click,dblclick,mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave,change,select,submit,keydown,keypress,keyup,error").split(","),function(F,E){o.fn[E]=function(G){return G?this.bind(E,G):this.trigger(E)}});o(l).bind("unload",function(){for(var E in o.cache){if(E!=1&&o.cache[E].handle){o.event.remove(o.cache[E].handle.elem)}}});(function(){o.support={};var F=document.documentElement,G=document.createElement("script"),K=document.createElement("div"),J="script"+(new Date).getTime();K.style.display="none";K.innerHTML='   <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select><object><param/></object>';var H=K.getElementsByTagName("*"),E=K.getElementsByTagName("a")[0];if(!H||!H.length||!E){return}o.support={leadingWhitespace:K.firstChild.nodeType==3,tbody:!K.getElementsByTagName("tbody").length,objectAll:!!K.getElementsByTagName("object")[0].getElementsByTagName("*").length,htmlSerialize:!!K.getElementsByTagName("link").length,style:/red/.test(E.getAttribute("style")),hrefNormalized:E.getAttribute("href")==="/a",opacity:E.style.opacity==="0.5",cssFloat:!!E.style.cssFloat,scriptEval:false,noCloneEvent:true,boxModel:null};G.type="text/javascript";try{G.appendChild(document.createTextNode("window."+J+"=1;"))}catch(I){}F.insertBefore(G,F.firstChild);if(l[J]){o.support.scriptEval=true;delete l[J]}F.removeChild(G);if(K.attachEvent&&K.fireEvent){K.attachEvent("onclick",function(){o.support.noCloneEvent=false;K.detachEvent("onclick",arguments.callee)});K.cloneNode(true).fireEvent("onclick")}o(function(){var L=document.createElement("div");L.style.width=L.style.paddingLeft="1px";document.body.appendChild(L);o.boxModel=o.support.boxModel=L.offsetWidth===2;document.body.removeChild(L).style.display="none"})})();var w=o.support.cssFloat?"cssFloat":"styleFloat";o.props={"for":"htmlFor","class":"className","float":w,cssFloat:w,styleFloat:w,readonly:"readOnly",maxlength:"maxLength",cellspacing:"cellSpacing",rowspan:"rowSpan",tabindex:"tabIndex"};o.fn.extend({_load:o.fn.load,load:function(G,J,K){if(typeof G!=="string"){return this._load(G)}var I=G.indexOf(" ");if(I>=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("<div/>").append(M.responseText.replace(/<script(.|\s)*?\/script>/g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H<F;H++){var E=o.data(this[H],"olddisplay");this[H].style.display=E||"";if(o.css(this[H],"display")==="none"){var G=this[H].tagName,K;if(m[G]){K=m[G]}else{var I=o("<"+G+" />").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H<F;H++){this[H].style.display=o.data(this[H],"olddisplay")||""}return this}},hide:function(H,I){if(H){return this.animate(t("hide",3),H,I)}else{for(var G=0,F=this.length;G<F;G++){var E=o.data(this[G],"olddisplay");if(!E&&E!=="none"){o.data(this[G],"olddisplay",o.css(this[G],"display"))}}for(var G=0,F=this.length;G<F;G++){this[G].style.display="none"}return this}},_toggle:o.fn.toggle,toggle:function(G,F){var E=typeof G==="boolean";return o.isFunction(G)&&o.isFunction(F)?this._toggle.apply(this,arguments):G==null||E?this.each(function(){var H=E?G:o(this).is(":hidden");o(this)[H?"show":"hide"]()}):this.animate(t("toggle",3),G,F)},fadeTo:function(E,G,F){return this.animate({opacity:G},E,F)},animate:function(I,F,H,G){var E=o.speed(F,H,G);return this[E.queue===false?"each":"queue"](function(){var K=o.extend({},E),M,L=this.nodeType==1&&o(this).is(":hidden"),J=this;for(M in I){if(I[M]=="hide"&&L||I[M]=="show"&&!L){return K.complete.call(this)}if((M=="height"||M=="width")&&this.style){K.display=o.css(this,"display");K.overflow=this.style.overflow}}if(K.overflow!=null){this.style.overflow="hidden"}K.curAnim=o.extend({},I);o.each(I,function(O,S){var R=new o.fx(J,K,O);if(/toggle|show|hide/.test(S)){R[S=="toggle"?L?"show":"hide":S](I)}else{var Q=S.toString().match(/^([+-]=)?([\d+-.]+)(.*)$/),T=R.cur(true)||0;if(Q){var N=parseFloat(Q[2]),P=Q[3]||"px";if(P!="px"){J.style[O]=(N||1)+P;T=((N||1)/R.cur(true))*T;J.style[O]=T+P}if(Q[1]){N=((Q[1]=="-="?-1:1)*N)+T}R.custom(T,N,P)}else{R.custom(T,S,"")}}});return true})},stop:function(F,E){var G=o.timers;if(F){this.queue([])}this.each(function(){for(var H=G.length-1;H>=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J<K.length;J++){if(!K[J]()){K.splice(J--,1)}}if(!K.length){clearInterval(n);n=g}},13)}},show:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.show=true;this.custom(this.prop=="width"||this.prop=="height"?1:0,this.cur());o(this.elem).show()},hide:function(){this.options.orig[this.prop]=o.attr(this.elem.style,this.prop);this.options.hide=true;this.custom(this.cur(),0)},step:function(H){var G=e();if(H||G>=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})();

function scrollY() {
  if ($.browser.msie) {
     scrolly=document.body.scrollTop;
  } else {
    scrolly=window.pageYOffset;
  }
  return scrolly;
}

var fl_check_notify = true;
var fl_blink_notify = false;
var id_notify = -1;
var mem_title='';
var prev_title='';
var _tec_mail='mail_cl2cl_all';
var _cou_unread=0;

function doMailView(j, sp, f_cl, f_mess) {
  if (j!='') {_tec_mail=j;} else {j=_tec_mail;}
  if (typeof(f_cl)=='undefined') f_cl=-1;
  if (typeof(f_mess)=='undefined') f_mess=-1;
  if (!sp) sp=0;
  f_mess=escape(f_mess);
  window.scrollTo(0,0); 
  $('div#id_body').html('');
  $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
  $.post('?',{jajax:j, sp:sp, f_cl:f_cl,_st_f_mess:f_mess},
     function(xml) {
        $.unblockUI();
        window.scrollTo(0,0); 
        $('div#id_body').html($("html",xml).text());
     }
  );
}

function doMailCl2Cl(id, id_p) {
  var memxy=mousexy;
  if (!id_p) id_p=0;
  $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
  $.post('?',{jajax:"mail_cl2cl_reply",id:id,id_p:id_p},
     function(xml) {  
         login=$("html",xml).text();
         $.unblockUI();
         if (login!='') {
             $('#id_mail_login').html(login);
             $('textarea#id_mail_mess').val($("mess_quote",xml).text());
             $('textarea#id_mail_mess').css({height:150});
             $('textarea#id_mail_mess').Autoexpand([0,300]);
             if (memxy.x+450<$(window).width()) {x=memxy.x-50;} else {x=memxy.x-450;}
             if (memxy.y+150<$(window).height()) {y=memxy.y+5;} else {y=memxy.y-150;}
             $('div#id_mail').css({top:y, left:x});
             $('div#id_mail').slideDown('slow',function() {$('textarea#id_mail_mess').focus();});
//alert(x+' '+y);
         } 
     }
  );
}

function doMailSend() {
   login=$('#id_mail_login').html();
   mess=escape($('textarea#id_mail_mess').val());
   if (login!='') {
      $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
      $.post('?',{jajax:"mail_cl2cl_send",_st_to_login:login,_st_mess:mess},
          function(xml) {  
              $.unblockUI();
              if ($("html",xml).text()=='ok') {
//                   alert('Ваше сообщение успешно доставлено адресату');
                   doNotifyClose(id_notify);
                   doMailClose();
              } else {
                   alert('Ошибка доставки сообщения. Возможно отсутствует текст?');
              }  
          }
      );
   }
}

function doMailClose() {
   $('div#id_mail').slideUp('slow');
   $('#id_mail_login').html('');
   id_notify=-1;
}

function doNotifyClose(id_n) {
   if (id_n>0) {
   $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
   $.post('?',{jajax:"mail_cl2cl_set_read",id:id_n},
     function(xml) {  
         $.unblockUI();
         html=$("html",xml).text();
         if (html=='ok') {
            $('#id_notify').slideUp('slow');
            $('#id_notify').html(''); 
            fl_check_notify=true;
            id_notify=-1;
            fl_blink_notify=false;
            document.title=mem_title;
            _cou_unread--;
            checkMailIN();
         }
     }
  );
  }
}

function doMailCl2Clnotify(id_from, id_n) {
   id_notify=id_n;
   doMailCl2Cl(id_from, id_n);
}

function titleBlinkNotify() {
  if (fl_blink_notify) {
     s1='/// ВАМ СООБЩЕНИЕ /// ';
     s2='--- ВАМ СООБЩЕНИЕ --- ';
     s3='\\\\\\ ВАМ СООБЩЕНИЕ \\\\\ ';
     if (prev_title==s1+mem_title) {
        prev_title=s2+mem_title; 
     } else {
        if (prev_title==s2+mem_title) {
           prev_title=s3+mem_title; 
        } else {
           prev_title=s1+mem_title;
        } 
     }
     document.title=prev_title;
     setTimeout('titleBlinkNotify();',800);  
  }
}

function checkMailIN() {
   $.ajax({
type: "POST",
url: "/?",
data:({jajax:"mail_cl2cl_check"}),
dataType: "xml",
success: function(xml) {
         html=$("html",xml).text();
         if (html!='') {
            if ($.browser.msie) {
               $('div#id_notify').css({width:'99%'});
            }
            $('#id_notify').html(html); 
            $('#id_notify').slideDown('slow');
            fl_check_notify=false;
            $('div#id_bt_notify_reply').html('<input type="button" value="ОТВЕТИТЬ" onclick="doMailCl2Clnotify('+$("id_from",xml).text()+','+$("id_mess",xml).text()+');"/>'); 
            $('div#id_bt_notify_close').html('<input type="button" value="ЗАКРЫТЬ" onclick="doNotifyClose('+$("id_mess",xml).text()+');"/>'); 
            mem_title=document.title;
            fl_blink_notify=true;
            playNotify($("cou_unread",xml).text());
            titleBlinkNotify();
         } else {
            $('#id_notify').slideUp('slow');
            $('#id_notify').html(''); 
            fl_check_notify=true;
         }
}
     });
}

function checkMailINTimeOut() {
   if (fl_check_notify) checkMailIN();
   setTimeout('checkMailINTimeOut();',30000);  
}

function checkMailINCount() {
   $.post('?',{jajax:"mail_cl2cl_check_count"},
     function(xml) {  
         html=$("html",xml).text();
         if (html!='') {
            $('#id_notify_count').html(html); 
            $('#id_notify_count').slideDown('slow');
            playNotify($("cou_unread",xml).text());
         }
     }
  );
}

function checkMailINCountTimeOut() {
   if (!fl_check_notify) checkMailINCount();
   setTimeout('checkMailINCountTimeOut();',15000);  
}

function doMailFilterClient() {
   var memxy=mousexy;
   $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
   $.post('?',{jajax:"mail_cl2cl_f_cl"},
     function(xml) {  
         $.unblockUI();
         html=$("html",xml).text();
         if (html!='') {
            $('div#id_mail_filter').css({top:memxy.y+5, left:memxy.x+5});
            $('div#id_mail_filter').html(html); 
            $('div#id_mail_filter').slideDown('slow');
         }
     }
  );
}

function doMailFilterClientSel(idcl) {
  doMailView('',0,idcl);
  $('div#id_mail_filter').slideUp('slow');
}

function doMailFilterMess() {
  f_mess=$('input#id_mail_f_mess').val();
  doMailView('',0,-1,f_mess);
}


function _doMailFMKU() {
   $('img#id_img_mfm_alert').show(); 
}

function playNotify(cou) {
   if (_cou_unread!=cou) {
      $('div#id_mail_notify_wma').html('<a id="id_media_mn" class="media" href="images/mail_notify.wma"></a>');
      $('a#id_media_mn').media({autoplay: true, width:0, height:0});
   }
   _cou_unread=cou;
 }

/*
 * Metadata - jQuery plugin for parsing metadata from elements
 *
 * Copyright (c) 2006 John Resig, Yehuda Katz, JяПНУЖrn Zaefferer, Paul McLanahan
 *
 * Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 *
 * Revision: $Id$
 *
 */

/**
 * Sets the type of metadata to use. Metadata is encoded in JSON, and each property
 * in the JSON will become a property of the element itself.
 *
 * There are three supported types of metadata storage:
 *
 *   attr:  Inside an attribute. The name parameter indicates *which* attribute.
 *          
 *   class: Inside the class attribute, wrapped in curly braces: { }
 *   
 *   elem:  Inside a child element (e.g. a script tag). The
 *          name parameter indicates *which* element.
 *          
 * The metadata for an element is loaded the first time the element is accessed via jQuery.
 *
 * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements
 * matched by expr, then redefine the metadata type and run another $(expr) for other elements.
 * 
 * @name $.metadata.setType
 *
 * @example <p id="one" class="some_class {item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("class")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from the class attribute
 * 
 * @example <p id="one" class="some_class" data="{item_id: 1, item_label: 'Label'}">This is a p</p>
 * @before $.metadata.setType("attr", "data")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a "data" attribute
 * 
 * @example <p id="one" class="some_class"><script>{item_id: 1, item_label: 'Label'}</script>This is a p</p>
 * @before $.metadata.setType("elem", "script")
 * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label"
 * @desc Reads metadata from a nested script element
 * 
 * @param String type The encoding type
 * @param String name The name of the attribute to be used to get metadata (optional)
 * @cat Plugins/Metadata
 * @descr Sets the type of encoding to be used when loading metadata for the first time
 * @type undefined
 * @see metadata()
 */

(function($) {

$.extend({
	metadata : {
		defaults : {
			type: 'class',
			name: 'metadata',
			cre: /({.*})/,
			single: 'metadata'
		},
		setType: function( type, name ){
			this.defaults.type = type;
			this.defaults.name = name;
		},
		get: function( elem, opts ){
			var settings = $.extend({},this.defaults,opts);
			// check for empty string in single property
			if ( !settings.single.length ) settings.single = 'metadata';
			
			var data = $.data(elem, settings.single);
			// returned cached data if it already exists
			if ( data ) return data;
			
			data = "{}";
			
			if ( settings.type == "class" ) {
				var m = settings.cre.exec( elem.className );
				if ( m )
					data = m[1];
			} else if ( settings.type == "elem" ) {
				if( !elem.getElementsByTagName )
					return undefined;
				var e = elem.getElementsByTagName(settings.name);
				if ( e.length )
					data = $.trim(e[0].innerHTML);
			} else if ( elem.getAttribute != undefined ) {
				var attr = elem.getAttribute( settings.name );
				if ( attr )
					data = attr;
			}
			
			if ( data.indexOf( '{' ) <0 )
			data = "{" + data + "}";
			
			data = eval("(" + data + ")");
			
			$.data( elem, settings.single, data );
			return data;
		}
	}
});

/**
 * Returns the metadata object for the first member of the jQuery object.
 *
 * @name metadata
 * @descr Returns element's metadata object
 * @param Object opts An object contianing settings to override the defaults
 * @type jQuery
 * @cat Plugins/Metadata
 */
$.fn.metadata = function( opts ){
	return $.metadata.get( this[0], opts );
};

})(jQuery);

/*
 * jQuery Media Plugin for converting elements into rich media content.
 *
 * Examples and documentation at: http://malsup.com/jquery/media/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * @author: M. Alsup
 * @version: 0.81 (06/05/2008)
 * @requires jQuery v1.1.2 or later
 * $Id: jquery.media.js 2460 2007-07-23 02:53:15Z malsup $
 *
 * Supported Media Players:
 *    - Flash
 *    - Quicktime
 *    - Real Player
 *    - Silverlight
 *    - Windows Media Player
 *    - iframe
 *
 * Supported Media Formats:
 *   Any types supported by the above players, such as:
 *     Video: asf, avi, flv, mov, mpg, mpeg, mp4, qt, smil, swf, wmv, 3g2, 3gp
 *     Audio: aif, aac, au, gsm, mid, midi, mov, mp3, m4a, snd, rm, wav, wma
 *     Other: bmp, html, pdf, psd, qif, qtif, qti, tif, tiff, xaml
 *
 * Thanks to Mark Hicken and Brent Pedersen for helping me debug this on the Mac!
 * Thanks to Dan Rossi for numerous bug reports and code bits!
 */
;(function($) {

/**
 * Chainable method for converting elements into rich media.
 *
 * @param options
 * @param callback fn invoked for each matched element before conversion
 * @param callback fn invoked for each matched element after conversion
 */
$.fn.media = function(options, f1, f2) {
    return this.each(function() {
        if (typeof options == 'function') {
            f2 = f1;
            f1 = options;
            options = {};
        }
        var o = getSettings(this, options);
        // pre-conversion callback, passes original element and fully populated options
        if (typeof f1 == 'function') f1(this, o);
        
        var r = getTypesRegExp();
        var m = r.exec(o.src) || [''];
        o.type ? m[0] = o.type : m.shift();
        for (var i=0; i < m.length; i++) {
            fn1 = m[i].toLowerCase();
            if (isDigit(fn1[0])) fn1 = 'fn' + fn1; // fns can't begin with numbers
            if (!$.fn.media[fn1]) 
                continue;  // unrecognized media type
            // normalize autoplay settings
            var player = $.fn.media[fn1+'_player'];
            if (!o.params) o.params = {};
            if (player) {
                var num = player.autoplayAttr == 'autostart';
                o.params[player.autoplayAttr || 'autoplay'] = num ? (o.autoplay ? 1 : 0) : o.autoplay ? true : false;
            }
            var $div = $.fn.media[fn1](this, o);

            $div.css('backgroundColor', o.bgColor).width(o.width);
            // post-conversion callback, passes original element, new div element and fully populated options
            if (typeof f2 == 'function') f2(this, $div[0], o, player.name);
            break;
        }
    });
};

/**
 * Non-chainable method for adding or changing file format / player mapping
 * @name mapFormat
 * @param String format File format extension (ie: mov, wav, mp3)
 * @param String player Player name to use for the format (one of: flash, quicktime, realplayer, winmedia, silverlight or iframe
 */
$.fn.media.mapFormat = function(format, player) {
    if (!format || !player || !$.fn.media.defaults.players[player]) return; // invalid
    format = format.toLowerCase();
    if (isDigit(format[0])) format = 'fn' + format;
    $.fn.media[format] = $.fn.media[player];
    $.fn.media[format+'_player'] = $.fn.media.defaults.players[player];
};

// global defautls; override as needed
$.fn.media.defaults = {
    width:         400,
    height:        400,
    autoplay:      0,         // normalized cross-player setting
    bgColor:       '#ffffff', // background color
    params:        { wmode: 'transparent'},  // added to object element as param elements; added to embed element as attrs
    attrs:         {},        // added to object and embed elements as attrs
    flashvars:     {},        // added to flash content as flashvars param/attr
    flashVersion:  '7',       // required flash version
    expressInstaller: null,   // src for express installer
    
    // default flash video and mp3 player (@see: http://jeroenwijering.com/?item=Flash_Media_Player)
    flvPlayer:     'mediaplayer.swf',
    mp3Player:     'mediaplayer.swf',
    
    // @see http://msdn2.microsoft.com/en-us/library/bb412401.aspx
    silverlight: {
        inplaceInstallPrompt: 'true', // display in-place install prompt?
        isWindowless:         'true', // windowless mode (false for wrapping markup)
        framerate:            '24',   // maximum framerate
        version:              '0.9',  // Silverlight version
        onError:              null,   // onError callback
        onLoad:               null,   // onLoad callback
        initParams:           null,   // object init params
        userContext:          null    // callback arg passed to the load callback
    }
};

// Media Players; think twice before overriding
$.fn.media.defaults.players = {
    flash: {
        name:         'flash',
        types:        'flv,mp3,swf',
        oAttrs:   {
            classid:  'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000',
            type:     'application/x-oleobject',
            codebase: 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + $.fn.media.defaults.flashVersion
        },
        eAttrs: {
            type:         'application/x-shockwave-flash',
            pluginspage:  'http://www.adobe.com/go/getflashplayer'
        }        
    },
    quicktime: {
        name:         'quicktime',
        types:        'aif,aiff,aac,au,bmp,gsm,mov,mid,midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,qif,qti,snd,tif,tiff,wav,3g2,3gp',
        oAttrs:   {
            classid:  'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
            codebase: 'http://www.apple.com/qtactivex/qtplugin.cab'
        },
        eAttrs: {
            pluginspage:  'http://www.apple.com/quicktime/download/'
        }
    },
    realplayer: {
        name:         'real',
        types:        'ra,ram,rm,rpm,rv,smi,smil',
        autoplayAttr: 'autostart',
        oAttrs:   {
            classid:  'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'
        },
        eAttrs: {
            type:         'audio/x-pn-realaudio-plugin',
            pluginspage:  'http://www.real.com/player/'
        }
    },
    winmedia: {
        name:         'winmedia',
        types:        'asf,avi,wma,wmv',
        autoplayAttr: 'autostart',
        oUrl:         'url',
        oAttrs:   {
            classid:  'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6',
            type:     'application/x-oleobject'
        },
        eAttrs: {
            type:         $.browser.mozilla && isFirefoxWMPPluginInstalled() ? 'application/x-ms-wmp' : 'application/x-mplayer2',
            pluginspage:  'http://www.microsoft.com/Windows/MediaPlayer/'
        }        
    },
    // special cases
    iframe: {
        name:  'iframe',
        types: 'html,pdf'
    },
    silverlight: {
        name:  'silverlight',
        types: 'xaml'
    }
};

//
//  everything below here is private
//


// detection script for FF WMP plugin (http://www.therossman.org/experiments/wmp_play.html)
// (hat tip to Mark Ross for this script)
function isFirefoxWMPPluginInstalled() {
    var plugs = navigator.plugins;
    for (i = 0; i < plugs.length; i++) {
        var plugin = plugs[i];
        if (plugin['filename'] == 'np-mswmp.dll')
            return true;
    }
    return false;
}

var counter = 1;

for (var player in $.fn.media.defaults.players) {
    var types = $.fn.media.defaults.players[player].types;
    $.each(types.split(','), function(i,o) {
        if (isDigit(o[0])) o = 'fn' + o;
        $.fn.media[o] = $.fn.media[player] = getGenerator(player);
        $.fn.media[o+'_player'] = $.fn.media.defaults.players[player];
    });
};

function getTypesRegExp() {
    var types = '';
    for (var player in $.fn.media.defaults.players) {
        if (types.length) types += ',';
        types += $.fn.media.defaults.players[player].types;
    };
    return new RegExp('\\.(' + types.replace(/,/g,'|') + ')\\b');
};

function getGenerator(player) {
    return function(el, options) {
        return generate(el, options, player);
    };
};

function isDigit(c) {
    return '0123456789'.indexOf(c) > -1;
};

// flatten all possible options: global defaults, meta, option obj
function getSettings(el, options) {
    options = options || {};
    var $el = $(el);
    var cls = el.className || '';
    // support metadata plugin (v1.0 and v2.0)
    var meta = $.metadata ? $el.metadata() : $.meta ? $el.data() : {};
    meta = meta || {};
    var w = meta.width  || parseInt(((cls.match(/w:(\d+)/)||[])[1]||0));
    var h = meta.height || parseInt(((cls.match(/h:(\d+)/)||[])[1]||0));
    
    if (w) meta.width  = w;
    if (h) meta.height = h;
    if (cls) meta.cls = cls;

    var a = $.fn.media.defaults;
    var b = options;
    var c = meta;

    var p = { params: { bgColor: options.bgColor || $.fn.media.defaults.bgColor } };
    var opts = $.extend({}, a, b, c);
    $.each(['attrs','params','flashvars','silverlight'], function(i,o) {
        opts[o] = $.extend({}, p[o] || {}, a[o] || {}, b[o] || {}, c[o] || {});
    });

    if (typeof opts.caption == 'undefined') opts.caption = $el.text();

    // make sure we have a source!
    opts.src = opts.src || $el.attr('href') || $el.attr('src') || 'unknown';
    return opts;
};

//
//  Flash Player
//

// generate flash using SWFObject library if possible
$.fn.media.swf = function(el, opts) {
    if (!window.SWFObject && !window.swfobject) {
        // roll our own
        if (opts.flashvars) {
            var a = [];
            for (var f in opts.flashvars)
                a.push(f + '=' + opts.flashvars[f]);
            if (!opts.params) opts.params = {};
            opts.params.flashvars = a.join('&');
        }
        return generate(el, opts, 'flash');
    }

    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');

    // swfobject v2+
    if (window.swfobject) {
        $(el).after($div).appendTo($div);
        if (!el.id) el.id = 'movie_player_' + counter++;

        // replace el with swfobject content
        swfobject.embedSWF(opts.src, el.id, opts.width, opts.height, opts.flashVersion, 
            opts.expressInstaller, opts.flashvars, opts.params, opts.attrs);
    }
    // swfobject < v2
    else {
        $(el).after($div).remove();
        var so = new SWFObject(opts.src, 'movie_player_' + counter++, opts.width, opts.height, opts.flashVersion, opts.bgColor);
        if (opts.expressInstaller) so.useExpressInstall(opts.expressInstaller);    

        for (var p in opts.params)
            if (p != 'bgColor') so.addParam(p, opts.params[p]);
        for (var f in opts.flashvars)
            so.addVariable(f, opts.flashvars[f]);
        so.write($div[0]);
    }

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

// map flv and mp3 files to the swf player by default
$.fn.media.flv = $.fn.media.mp3 = function(el, opts) {
    var src = opts.src;
    var player = /\.mp3\b/i.test(src) ? $.fn.media.defaults.mp3Player : $.fn.media.defaults.flvPlayer;
    opts.src = player;
    opts.src = opts.src + '?file=' + src;
    opts.flashvars = $.extend({}, { file: src }, opts.flashvars );
    return $.fn.media.swf(el, opts);
};

//
//  Silverlight
//
$.fn.media.xaml = function(el, opts) {
    if (!window.Sys || !window.Sys.Silverlight) {
        if ($.fn.media.xaml.warning) return;
        $.fn.media.xaml.warning = 1;
        alert('You must include the Silverlight.js script.');
        return;
    }

    var props = {
        width: opts.width,
        height: opts.height,
        background: opts.bgColor,
        inplaceInstallPrompt: opts.silverlight.inplaceInstallPrompt,
        isWindowless: opts.silverlight.isWindowless,
        framerate: opts.silverlight.framerate,
        version: opts.silverlight.version
    };
    var events = {
        onError: opts.silverlight.onError,
        onLoad: opts.silverlight.onLoad
    };

    var id1 = el.id ? (' id="'+el.id+'"') : '';
    var id2 = opts.id || 'AG' + counter++;
    // convert element to div
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id1 + cls + '>');
    $(el).after($div).remove();
    
    Sys.Silverlight.createObjectEx({


        source: opts.src,
        initParams: opts.silverlight.initParams,
        userContext: opts.silverlight.userContext,
        id: id2,
        parentElement: $div[0],
        properties: props,
        events: events
    });

    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};

//
// generate object/embed markup
//
function generate(el, opts, player) {
    var $el = $(el);
    var o = $.fn.media.defaults.players[player];
    
    if (player == 'iframe') {
        var o = $('<iframe' + ' width="' + opts.width + '" height="' + opts.height + '" >');
        o.attr('src', opts.src);
        o.css('backgroundColor', o.bgColor);
    }
    else if ($.browser.msie) {
        var a = ['<object width="' + opts.width + '" height="' + opts.height + '" '];
        for (var key in opts.attrs)
            a.push(key + '="'+opts.attrs[key]+'" ');
        for (var key in o.oAttrs || {})
            a.push(key + '="'+o.oAttrs[key]+'" ');
        a.push('></ob'+'ject'+'>');
        var p = ['<param name="' + (o.oUrl || 'src') +'" value="' + opts.src + '">'];
        for (var key in opts.params)
            p.push('<param name="'+ key +'" value="' + opts.params[key] + '">');
        var o = document.createElement(a.join(''));
        for (var i=0; i < p.length; i++)
            o.appendChild(document.createElement(p[i]));
    }
    else {
        var a = ['<embed width="' + opts.width + '" height="' + opts.height + '" style="display:block"'];
        if (opts.src) a.push(' src="' + opts.src + '" ');
        for (var key in opts.attrs)
            a.push(key + '="'+opts.attrs[key]+'" ');
        for (var key in o.eAttrs || {})
            a.push(key + '="'+o.eAttrs[key]+'" ');
        for (var key in opts.params)
            a.push(key + '="'+opts.params[key]+'" ');
        a.push('></em'+'bed'+'>');
    }
    // convert element to div
    var id = el.id ? (' id="'+el.id+'"') : '';
    var cls = opts.cls ? (' class="' + opts.cls + '"') : '';
    var $div = $('<div' + id + cls + '>');
    $el.after($div).remove();
    ($.browser.msie || player == 'iframe') ? $div.append(o) : $div.html(a.join(''));
    if (opts.caption) $('<div>').appendTo($div).html(opts.caption);
    return $div;
};


})(jQuery);

var stc = 1;
var fl_first = true; 
var id_bet=-1;

function onCalc() {
  ii=_checkRB_I();
  i=_checkRB();
  if (i>0 && ii>0) {
    eval('aahs=document.fbet.aah'+ii+'.value;');
    if (confirm("Вы рассчитываете спор.\n Выбран вариант: "+ii+'. '+aahs+".\n Вы уверены в правильном указании исхода события?")) {
      location.href="?ta=bet_calc&redirect=/bet"+__id_bet+"/&id_bet="+__id_bet+"&id_answer="+i+"&";
    }
  } else {alert ('Не выбран вариант исхода события!');}
}

function onStake() {
   if (stc==1) {
     s=document.fbet.sm.value;
     ii=_checkRB_I();
     if (ii>0) {
       eval('aahs=document.fbet.aah'+ii+'.value;');
       if (confirm('Вы делаете ставку на сумму $'+s+' на вариант исхода '+ii+'. '+aahs+".\n Вы уверены?")) {return true;} else {return false;}
     }
     alert ('Не выбран вариант исхода события!');
     return false;
  }
  if (stc==2) {if (document.fbet.comment_txt.value=='') {alert('Ошибка! Комментарий отсутствует!'); return false;} else {return true;}}
}

function doCommDenounce(ids,id) {
  if (confirm('Отправить жалобу модератору на недостойный комментарий?')) {
     location.href="?redirect=/bet="+__id_bet+"/&ta=comm_denounce&id_stake="+ids+"&id_comm="+id+"&id_bet="+__id_bet+"&";
  }
}

function drawGraph() {
  if (sm_summa>0) {
    for (i=0; i<ar_sm.length; i++) {
       if (document.all) {obj=document.all['draw'+i];} else {obj=document.getElementById('draw'+i);}
       if (obj) {
         if (ar_sm[i]>0) {
//           wmy=Math.round(100*ar_sm_my[i]/sm_max); 
//           w=Math.round(100*ar_sm[i]/sm_max)-wmy; 
           wmy=100*ar_sm_my[i]/sm_max; 
           w=100*ar_sm[i]/sm_max-wmy; 
           s=String(ar_sm[i]); l=s.length*5; 
           if (l<w) {
             txt='<table align="right" border="0" cellpadding="0" cellspacing="0"><tr>';
             if (wmy>0) {
                if (w>0) {txt=txt+'<td width="'+Math.round(w)+'" class="bg_sm">'+ar_sm[i]+'</td>';}
                txt=txt+'<td class="bg_smmy" width="'+Math.round(wmy)+'">&nbsp;</td>';
             } else {
               txt=txt+'<td width="'+Math.round(w)+'" class="bg_sm_one">'+ar_sm[i]+'</td>';
             }
             txt=txt+'</tr></table>';
           } else {
             txt='<table align="right" border="0" cellpadding="0" cellspacing="0"><tr>';
             if (wmy>0) {
                txt=txt+'<td width="'+Math.round(100-w-wmy)+'" class="bg_ll">'+ar_sm[i]+'</td>';
                if (w>0) {
                   txt=txt+'<td width="'+Math.round(w)+'" class="bg_sm_nbsp">&nbsp;</td>';
                   txt=txt+'<td class="bg_smmy" width="'+Math.round(wmy)+'">&nbsp;</td>';
                } else {
                  txt=txt+'<td class="bg_smmy_nbsp" width="'+Math.round(wmy)+'">&nbsp;</td>';
                } 
             } else {
                txt=txt+'<td width="'+Math.round(100-w)+'" class="bg_ll">'+ar_sm[i]+'</td><td width="'+Math.round(w)+'" class="bg_sm_nbsp_one">&nbsp;</td>';
             }
             txt=txt+'</tr></table>';
           }
//alert(txt);
           obj.innerHTML=txt;
         } else {obj.innerHTML='&nbsp;';}
       }
    }
  }
}

function calcProbablyWin() {
  s=document.fbet.sm.value; s1=s; s=s.replace(/,/,'.');  s=s.replace(/ю/,'.');  s=s.replace(/б/,'.'); 
  if (s!=s1) {document.fbet.sm.value=s;}
  plus=parseFloat(s);
  if ((sm_summa>0) && (plus>0)) {
    for (ii=0; ii<ar_sm.length; ii++) {
       if (document.all) {obj=document.all['pw'+ii];} else {obj=document.getElementById('pw'+ii);}
       if (obj) {
//alert(ii+':'+ar_sm.length+':'+ar_sm[ii]);
         win=sm_summa-ar_sm[ii];
         win=win-win*(perc_sys+perc_owner)/100;
         win=win*plus/(ar_sm[ii]+plus);
         obj.innerHTML='$'+Math.round(win*100)/100;
         obj.className='show pw';
       }
    }
  }
}

var sc_to;
    function doLoadSC() {
        set_wait();
        obj=document.all?document.all['st_and_comm']:document.getElementById('st_and_comm');
        if (obj) {obj.innerHTML='<span class="sc_info">Подождите немного. Подгружается информация о ставках и комментариях...</span>';}
        scfi=ar_id_answ.join(',');
        if (scfi_comm) {s2='1';} else {s2='0';}
        if (scfi_tc) {tc='1';} else {tc='0';}
        if (scfi_my) {my='1';} else {my='0';}
        $.post('?',{jajax:'betstc',id_bet:__id_bet,scfi:scfi,comm:s2,tc:tc,my:my},function(xml) {
            $("#st_and_comm").html($("html",xml).text());
                  fl_click=true; 
                  if (fl_first) {
                    objt=document.all?document.all['tbl_add_title']:document.getElementById('tbl_add_title');  if (objt) {objt.className='show';}
                    objf=document.all?document.all['tbl_filter']:document.getElementById('tbl_filter');  if (objf) {objf.className='show';}
                    doTBL(3); doTBL(2); doTBL(1); fl_first=false;
                  }
                  set_state();
             parseAClients();
        });
    }

function set_wait() {
    fl_click=false;
    obj=document.all?document.all['sc_comm']:document.getElementById('sc_comm');    if (obj) {obj.className='sc_wait';}
    obj=document.all?document.all['sc0']:document.getElementById('sc0');    if (obj) {obj.className='sc_wait';}
    obj=document.all?document.all['sc_tc']:document.getElementById('sc_tc');    if (obj) {obj.className='sc_wait';}
    obj=document.all?document.all['sc_my']:document.getElementById('sc_my');    if (obj) {obj.className='sc_wait';}
    for (i=0; i<ar_id_answ.length; i++) {
       obj=document.all?document.all['sc'+Math.abs(ar_id_answ[i])]:document.getElementById('sc'+Math.abs(ar_id_answ[i]));
       if (obj) {obj.className='sc_wait';}
    }
}
function set_state() {
  if (fl_click) {
    obj=document.all?document.all['sc_comm']:document.getElementById('sc_comm');
    if (obj) {if (scfi_comm) {obj.className='sc_view';} else {obj.className='sc_hide';}}
    obj=document.all?document.all['sc_tc']:document.getElementById('sc_tc');
    if (obj) {if (scfi_tc) {obj.className='sc_view';} else {obj.className='sc_hide';}}
    obj=document.all?document.all['sc0']:document.getElementById('sc0');
    if (obj) {if (scfi_all) {obj.className='sc_view';} else {obj.className='sc_hide';}}
    for (i=0; i<ar_id_answ.length; i++) {
         obj=document.all?document.all['sc'+Math.abs(ar_id_answ[i])]:document.getElementById('sc'+Math.abs(ar_id_answ[i]));
         if (obj) {if (ar_id_answ[i]>0) {obj.className='sc_view';} else {obj.className='sc_hide';}}
    }
    obj=document.all?document.all['sc_my']:document.getElementById('sc_my');
    if (obj) {if (scfi_my) {obj.className='sc_only_my'; obj.innerHTML='<nobr>Только мои</nobr>';} else {obj.className='sc_my_all'; obj.innerHTML='<nobr>Все участники</nobr>';}}
  }
}

function doSCFi(ida) {
  if (fl_click) {
    obj=document.all?document.all['sc'+ida]:document.getElementById('sc'+ida);
    if (ida=='_my') {scfi_my=!scfi_my;} else {
    if (ida=='_tc') {scfi_tc=!scfi_tc;} else {
    if (ida=='_comm') {scfi_comm=!scfi_comm;} else {
        if (ida==0) {
           scfi_all=!scfi_all;
           for (i=0; i<ar_id_answ.length; i++) {if (((scfi_all) && (ar_id_answ[i]<0)) || ((!scfi_all) && (ar_id_answ[i]>0))) {ar_id_answ[i]*=-1;}}
        } else {
          cou_p=0;
          for (i=0; i<ar_id_answ.length; i++) {
            if (ida==Math.abs(ar_id_answ[i])) {ar_id_answ[i]*=-1;}
            if (ar_id_answ[i]>0) {cou_p++;}
          }
          if (cou_p==ar_id_answ.length) {scfi_all=true;} else {scfi_all=false;}
        }
    }}}
  sp=0;
  doLoadSC();
  }
}

function doSP(spn) {sp=spn;  doLoadSC();}

function doTBL(v) {
  obj1=document.all?document.all['tbl_add_stake']:document.getElementById('tbl_add_stake');
  obj2=document.all?document.all['tbl_add_comm']:document.getElementById('tbl_add_comm');
  obj3=document.all?document.all['tbl_add_subs']:document.getElementById('tbl_add_subs');
  if (v==1) { if (obj1) {obj1.className='show tbl_add_sc'; stc=1; if (obj2) {obj2.className='hide';} if (obj3) {obj3.className='hide';}}}
  if (v==2) {if (obj2) {obj2.className='show tbl_add_sc'; stc=2; if (obj1) {obj1.className='hide';} if (obj3) {obj3.className='hide';}   }}
  if (v==3) {if (obj3) {obj3.className='show tbl_add_sc'; stc=3; if (obj1) {obj1.className='hide';} if (obj2) {obj2.className='hide';}  }}

  obj11=document.all?document.all['st_add_td_stake']:document.getElementById('st_add_td_stake');
  obj22=document.all?document.all['st_add_td_comm']:document.getElementById('st_add_td_comm');
  obj33=document.all?document.all['st_add_td_subs']:document.getElementById('st_add_td_subs');

  if (v==1) {
    if (obj11 && obj1) {obj11.className='st_add_td_active'; if (obj22 && obj2) {obj22.className='st_add_td_noactive';} if (obj33 && obj3) {obj33.className='st_add_td_noactive';} } 
    if (document.fbet.comment_txt && document.fbet.comment) {document.fbet.comment.value=document.fbet.comment_txt.value;}
  }
  if (v==2) {
    if (obj22 && obj2) {obj22.className='st_add_td_active'; if (obj11 && obj1) {obj11.className='st_add_td_noactive';} if (obj33 && obj3) {obj33.className='st_add_td_noactive';} }
    if (document.fbet.comment_txt && document.fbet.comment) {document.fbet.comment_txt.value=document.fbet.comment.value;}
  }
  if (v==3) {
    if (obj33 && obj3) {obj33.className='st_add_td_active'; if (obj11 && obj1) {obj11.className='st_add_td_noactive';} if (obj22 && obj2) {obj22.className='st_add_td_noactive';} }
  }
}

function doCommCitation(id) {
  obj0=document.all?document.all['ta_'+id]:document.getElementById('ta_'+id);
  obj1=document.all?document.all['comm_'+id]:document.getElementById('comm_'+id);
  obj2=document.all?document.all['login_'+id]:document.getElementById('login_'+id);
  if ((obj1) && (obj2) && (obj0)) {
//alert(obj1.innerHTML+obj2.innerHTML);
    l=obj2.innerHTML;
//    s="[q][l]"+l+"[/l]\n"+obj1.innerHTML+"[/q]\n";
    s="[q][l]"+l+"[/l]\n"+obj0.value+"[/q]\n";
    s=s.replace(/<span.*?>/gi,"[l]");    s=s.replace(/<\/span.*?>/gi,"[/l]");  s=s.replace(/<div.*?>/gi,"[q]");    s=s.replace(/<\/div.*?>/gi,"[/q]");
    s=s.replace(/<.*?>/gi," ");  s=s.replace(/&amp;/gi,"&");  s=s.replace(/&quot;/gi,"\"");  s=s.replace(/&#039;/gi,"'");
    s=s.replace(/&lt;/gi,"<");  s=s.replace(/&gt;/gi,">");  s=s.replace(/\<br\>/gi,"\n");  s=s.replace(/\[\/q\]/gi,"[/q]\n");
    if (document.fbet.comment_txt) {
       document.fbet.comment_txt.value=document.fbet.comment_txt.value+s;
       if (isMSIE) {document.fbet.comment_txt.rows=document.fbet.comment_txt.rows+1;}
    }
    if (document.fbet.comment) {
       document.fbet.comment.value=document.fbet.comment.value+s;
       if (isMSIE) {document.fbet.comment.rows=document.fbet.comment.rows+1;}
    }
    doTBL(2);
    s=location.href; i=s.indexOf('#');   if (i>0) {s=s.substring(0,i);}
    location.href=s+"#l_sc";
    if (document.fbet.comment_txt && isMSIE) {document.fbet.comment_txt.rows=document.fbet.comment_txt.rows-1;}
    if (document.fbet.comment && isMSIE) {document.fbet.comment.rows=document.fbet.comment.rows-1;}
  }
}

function doOpCommentUpdate(fbs,id) {
  obj1=document.all?document.all['ta_'+id]:document.getElementById('ta_'+id);
  obj2=document.all?document.all['comm_'+id]:document.getElementById('comm_'+id);
  if(obj1) {
    if (obj1.className=='show') {
      if (confirm("Изменить комментарий?\nВы уверены?")) {
        eval('nc=document.fbet.comment'+fbs+id+'.value;');
        nc=nc.replace(/\n/gi,"<br>");
        location.href='?redirect=/bet'+__id_bet+'/&id_bet='+__id_bet+'&ta=op_comment_update&id_comment='+id+'&fbs='+fbs+'&new_comment='+nc+'&';
      }
    } else {
       obj2.className='hide';    obj1.className='show';
    }
  }
}


function doAddComm() {
    set_wait();
    obj=document.all?document.all['st_and_comm']:document.getElementById('st_and_comm');
    if (obj) {obj.innerHTML='<span class="sc_info">Подождите немного. Подгружается информация о ставках и комментариях...</span>';}
    comm=escape(document.fbet.comment_txt.value);
//  ml=100;
//  if (comm.length>ml) {
//     count=Math.floor(comm.length/ml);
//     setCookieNV('tmp_add_comm_count',count);
//     for (i=0; i<=count; i++) {s1=comm.substring(i*ml,i*ml+ml);   setCookieNV('tmp_add_comm_'+i,s1);}
//     comm='[from_cookie]';
//  } else {comm=escape(comm);}
    $.post('?',{jajax:'add_comm',id_bet:__id_bet,comm:comm},function(xml) {
       document.fbet.comment_txt.value='';
       doLoadSC();
    });   
}

function drawSubs(tp,html) {
  obj=document.all?document.all['subs_'+tp]:document.getElementById('subs_'+tp);
  lc='';  switch (tp) {case 1:lc='о новых ставках в этом споре';break; case 2:lc='о новых комментариях в этом споре';break; case 3:lc='об изменении статуса этого спора';break;}
  if (obj) {if (html=='1') {
    obj.className='subs_sel'; obj.innerHTML='отписаться'; alert('Теперь вы будете получать уведомления '+lc+'.');
  } else {
    obj.className='';  obj.innerHTML='подписаться'; alert('Теперь вы НЕ будете получать уведомления '+lc+'.');}
  }
}

function doSubs(tp) {
  obj=document.all?document.all['subs_'+tp]:document.getElementById('subs_'+tp);
  if (obj) {if (obj.innerHTML!='?') {
        obj.innerHTML='?'; 
        $.post('?',{jajax:'subscribetp',id_bet:__id_bet,tp:tp},function(xml) {
            drawSubs($("tp",xml).text(),$("html",xml).text()); 
        });
  }}
}

function drawShed(shed,html) {
  for (i=1; i<=3; i++) {
    obj=document.all?document.all['shed_'+i]:document.getElementById('shed_'+i);
    if (obj) {
      obj.href='javascript:doShed('+i+');'; 
      if (shed==i) {obj.className='subs_sel';} else {obj.className='';}
    }
  }
}

function doShed(shed) {
  if (shed>0) {
    for (i=1; i<=3; i++) {
      obj=document.all?document.all['shed_'+i]:document.getElementById('shed_'+i);
      if (obj) {obj.href='javascript:doShed(0);';}
    }
    $.post('?',{jajax:'subscribesh',id_bet:__id_bet,shed:shed},function(xml) {
        drawShed($("shed",xml).text(),$("html",xml).text()); 
        alert('Расписание отправок писем по спору изменено.');
    });
  }
}

/* из bet_class */

function _checkRB() {
   nc=document.getElementsByName('id_answer');
   if(nc){for (i=0; i<nc.length; i++) {if (nc.item(i).checked) {return nc.item(i).value;}}}
   return 0;
}
function _checkRB_I() {
   nc=document.getElementsByName('id_answer');
   if(nc){for (i=0; i<nc.length; i++) {if (nc.item(i).checked) {return (i+1);}}}
   return 0;
}

function doStakeCancel(ids) {
  if (confirm("Отменить ставку?\nВы уверены?")) {
  location.href="?redirect=/bet"+__id_bet+"/&id_bet="+__id_bet+"&ta=stake_cancel&id_stake="+ids+"&";
  }
}

function doReferee(ii) {
  if (ii==1) {s='Согласиться на арбитраж спора';} else {s='Отказаться от арбитража спора';}
  if (confirm(s+"`"+__bet_name+"`?\nВы уверены?")) {
    location.href="?redirect=/bet"+__id_bet+"/&ta=bet_referee_accept&accept="+ii+"&id_bet="+__id_bet+"&";
  }
}

$(document).ready(function() {
  if  (__id_bet>0) {
      doLoadSC();
      if (fl_bvb_drawgraph) {drawGraph();}
      if (fl_bvb_calcprobablywin) {calcProbablyWin();}
  }
});

//var obj_js_clock;
var tid_clock =  null;
function i02(i) {if (i<10) {return "0"+i;} else {return i;}}
function jstime() {

//    tid=window.setTimeout("jstime(1)",1000);
    today = new Date();
    today1 = new Date();
    today1.setTime(today.getTime()+(__js_gmt_min*60*1000));

    y=today.getUTCFullYear(); if ((y-1900)<0) {y=y+1900;} 
    m=i02(today.getUTCMonth()+1);   d=i02(today.getUTCDate());   hour=i02(today.getUTCHours());    min=i02(today.getUTCMinutes());   sec=i02(today.getUTCSeconds());

    y1=today1.getUTCFullYear(); if ((y1-1900)<0) {y1=y1+1900;} 
    m1=i02(today1.getUTCMonth()+1);   d1=i02(today1.getUTCDate());   hour1=i02(today1.getUTCHours());    min1=i02(today1.getUTCMinutes());   sec1=i02(today1.getUTCSeconds());

    gmt=__js_gmt_min/60;
    if (gmt>0) gmt='+'+gmt;

    //timestr="<span class=\"js_gmt\">GMT: "+d+"."+m+"."+y+" "+hour+":"+min+":"+sec+",</span> Local: ("+gmt+") "+d1+"."+m1+"."+y1+" "+hour1+":"+min1+":"+sec1;
    if (hour==hour1) {
      timestr='<span title="'+d1+'.'+m1+'.'+y1+'">'+hour1+":"+min1+":"+sec1+" UTC "+gmt+'</span>';
    } else {
      timestr='<span title="'+d1+'.'+m1+'.'+y1+'">'+hour1+":"+min1+":"+sec1+" UTC "+gmt+'</span>, <span class=\"js_gmt\" title="'+d+'.'+m+'.'+y+'">'+hour+":"+min+":"+sec+" UTC</span>";
    }
//    obj_js_clock=document.all?document.all['js_clock']:document.getElementById('js_clock'); 
   $('div#js_clock').html(timestr);
//    if (obj_js_clock) {obj_js_clock.innerHTML=timestr;}
    //window.status = timestr;
    if (tid_clock) window.clearTimeout(tid_clock);
    tid_clock=window.setTimeout("jstime();",1000);
}

function bm_add(id,nm) {
  gc=getCookie('bet_bm');  if (!gc) gc='';
  ar=gc.split(/#@#/);
  nm=nm.replace(/|/,''); s_add=id+'|'+nm;
  if (!in_array(s_add,ar)) {ar.push(s_add);}
  ar=array_del_element('',ar);
//alert(ar.length);  
  gc=ar.join('#@#');
//alert(gc);  
  d = new Date(); d.setTime(d.getTime()+1000*3600*24*30); setCookie('bet_bm',gc,d);
  bm_draw();
}
function bm_del(id) {
  gc=getCookie('bet_bm');  if (!gc) gc='';
  ar=gc.split(/#@#/);  ar=array_del_element('',ar);
  if (ar.length>0) {
    new_ar=new Array(0);
    for (i=0; i<ar.length; i++) {
      sar=ar[i].split('|');
      if (sar[0]!=id) {new_ar.push(ar[i]);}
    }
    gc=new_ar.join('#@#');
    d = new Date(); d.setTime(d.getTime()+1000*3600*24*30); setCookie('bet_bm',gc,d);
    bm_draw();
  }
}
function bm_draw() {
  obj=document.all?document.all['bet_bm']:document.getElementById('bet_bm');
  if (obj) {
    html='<table border="0" cellpadding="1" cellspacing="1" width="100%" class="bm_tbl">';
    html+='<tr><td class="bm_tt">Мои избранные споры</td></tr>';
    gc=getCookie('bet_bm'); if (!gc) gc=''; 
    ar=gc.split(/#@#/);  ar=array_del_element('',ar);
    if (ar.length>0) {
      for (i=0; i<ar.length; i++) {
        sar=ar[i].split('|');
        html+='<tr valign="top"><td><img class="lb_bm_button" title="Удалить закладку" src="images/betylon/remove_small.png" onclick="bm_del('+sar[0]+')"> <a class="bm" href="?vbet='+sar[0]+'">'+sar[1]+'</a></td></tr>';
      }
    } else {
      html+='<tr><td align="center">ничего не выбрано</td></tr>';
    }
    html+='</table>';
html+='<table width="100%" border="0" cellpadding="0" cellspacing="0" height="2"><tr><td width="1" nowrap="nowrap"></td><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bm_tbl_1" height="2"><tr><td></td></tr></table></td><td width="1" nowrap="nowrap"></td></tr></table>';
html+='<table width="100%" border="0" cellpadding="0" cellspacing="0" height="1"><tr><td width="2" nowrap="nowrap"></td><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bm_tbl_1" height="1"><tr><td></td></tr></table></td><td width="2" nowrap="nowrap"></td></tr></table>';
html+='<table width="100%" border="0" cellpadding="0" cellspacing="0" height="1"><tr><td width="3" nowrap="nowrap"></td><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bm_tbl_2" height="1"><tr><td></td></tr></table></td><td width="3" nowrap="nowrap"></td></tr></table>';
html+='<table width="100%" border="0" cellpadding="0" cellspacing="0" height="1"><tr><td width="5" nowrap="nowrap"></td><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bm_tbl_bottom" height="1"><tr><td></td></tr></table></td><td width="5" nowrap="nowrap"></td></tr></table>';
html+='<table width="100%" border="0" cellpadding="0" cellspacing="0" height="1"><tr><td width="10" nowrap="nowrap"></td><td><table width="100%" border="0" cellpadding="0" cellspacing="0" class="bm_tbl_shadow" height="1"><tr><td></td></tr></table></td><td width="7" nowrap="nowrap"></td></tr></table>';
    obj.innerHTML=html;
  }
}

$(document).ready(function() {
  bm_draw();
});

var __js_gmt_min;
var mousexy = {x:0,y:0};

function _debug(s) {$('div#debug').html($('div#debug').html()+' '+s);}

function doCLInfo(id) {
   location.href="?bclinfo="+id;
}

function onScroll() {
  if (__id_client>0) _closeDoClient_G();
}

function _doLoadRightInfo() {
          $.post('?',{jajax:"betylon_right_info"},function(xml) {
               $('div#id_betylon_right_info').html($("html",xml).text());
          });
}

function _doLoadLastEvents() {
          $.post('?',{jajax:"betylon_last_event"},function(xml) {
               $('div#id_betylon_last_event').html($("html",xml).text());
          });
}

$(document).ready(function() {

          jQuery(document).bind('mousemove',function(e){mousexy.x=e.pageX; mousexy.y=e.pageY;}); 
   
           today = new Date(); __js_gmt_min=-today.getTimezoneOffset(); 
           if (typeof(doLoadTZO)!='undefined') {doLoadTZO();}
           jstime();

          $.post('?',{jajax:"tape_news"},function(xml) {
               $('div#id_bet_news').html($("html",xml).text());
          });

          _doLoadRightInfo();
          _doLoadLastEvents();

        $.post('?',{jajax:"cl_menu_stat"},function(xml) {
            $("#dims_g1").html($("g1",xml).text());
            $("#dims_g2").html($("g2",xml).text());
            $("#dims_all").html($("gall",xml).text());
            $("#dims_o1").html($("o1",xml).text());
            $("#dims_oall").html($("oall",xml).text());
            $("#dims_r1").html($("r1",xml).text());
            $("#dims_r34").html($("r34",xml).text());
            $("#dims_rall").html($("rall",xml).text());
        });


         window.onscroll = onScroll;

         parseAClients();

         $.blockUI.defaults.css.backgroundColor='';
         $.blockUI.defaults.css.border='none';
         $.blockUI.defaults.overlayCSS.backgroundColor='#ffffff';
         $.blockUI.defaults.overlayCSS.opacity=0.8;
         $.blockUI.defaults.baseZ=99999;

         if (__id_client>0) {
                checkMailINTimeOut();
                checkMailINCountTimeOut();
         }


});

function convertString(str) {
  var query="";
  for (i=0;i<str.length;i++) {
    var n=str.charCodeAt(i);
    if (n>=0x410 && n<=0x44F) n-=0x350; else if (n==0x451) n=0xB8; else if (n==0x401) n=0xA8;
    query=query+String.fromCharCode(n);
  }
  return escape(query);
};

function escape2(s) {res=escape(s); alert(res);  return res;};

function setCookie(name, value, expires, path, domain, secure) {
  var curCookie = name + "=" + escape(value) +
//  var curCookie = name + "=" + value +
  ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}

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;
  return unescape(dc.substring(begin + prefix.length, end));
//  return dc.substring(begin + prefix.length, end);
}

function deleteCookie(name, path, domain) {
  if (getCookie(name)) {document.cookie = name + "=" + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + "; expires=Thu, 01-Jan-70 00:00:01 GMT";}
}

function setCookieNV(name,value) {
  d=new Date(); d.setTime(d.getTime()+1000*3600*24*30); setCookie(name,value,d);
}

function ptrimN(s) {s=s.replace(/^[^0-9]*/,'');  s=s.replace(/[^0-9]*$/,'');  return parseInt(s);}

    function moveClip(obj_name,unit,l,t,r,b) {
      setClip(obj_name,unit,getClipValues(obj_name,unit,'l')+l,getClipValues(obj_name,unit,'t')+t,getClipValues(obj_name,unit,'r')+r,getClipValues(obj_name,unit,'b')+b);
    }

    function setClip(obj_name,unit,l,t,r,b) {
      s = "rect("+t+unit+" "+r+unit+" "+b+unit+" "+l+unit+")";
      obj=document.all?document.all[obj_name]:document.getElementById(obj_name);
      obj.style.clip=s;
    }
  
    function getClipValues(obj_name,unit,which) {
      obj=document.all?document.all[obj_name]:document.getElementById(obj_name);
      s=obj.style.clip;
      s=s.split("rect(")[1]; s=s.split(")")[0]; clipv=s.split(unit);
      switch (which) {
        case "t": return ptrimN(clipv[0]);
        case "r": return ptrimN(clipv[1]);
        case "b": return ptrimN(clipv[2]);
        case "l": return ptrimN(clipv[3]);
      }
    }


    function ExpandClipFromCorner(obj_name,unit,corner,level,step,left,top,width,height,speed) {
      obj=document.all?document.all[obj_name]:document.getElementById(obj_name);
      fl_rec=false;
      switch (corner) {
        case 'lt':
          if (level==0) {setClip(obj_name,unit,0,0,0,0);}
          if (getClipValues(obj_name,unit,'r')<width) {moveR=step;} else {moveR=0;}
          if (getClipValues(obj_name,unit,'b')<height) {moveB=step;} else {moveB=0;}
          if (moveR!=0 | moveB!=0) {moveClip(obj_name,unit,0,0,moveR,moveB); fl_rec=true;}
          break;
        case 'rt':
          if (level==0) {setClip(obj_name,unit,width,0,width,0);}
          if (getClipValues(obj_name,unit,'l')>0) {moveL=-step;} else {moveL=0;}
          if (getClipValues(obj_name,unit,'b')<height) {moveB=step;} else {moveB=0;}
          if (moveL!=0 | moveB!=0) {moveClip(obj_name,unit,moveL,0,0,moveB); fl_rec=true;}
        break;
        case 'lb':
          if (level==0) {setClip(obj_name,unit,0,height,0,height);}
          if (getClipValues(obj_name,unit,'r')<width) {moveR=step;} else {moveR=0;}
          if (getClipValues(obj_name,unit,'t')>0) {moveT=-step;} else {moveT=0;}
          if (moveR!=0 | moveT!=0) {moveClip(obj_name,unit,0,moveT,moveR,0); fl_rec=true;}
        break;
        case 'rb':
          if (level==0) {setClip(obj_name,unit,width,height,width,height);}
          if (getClipValues(obj_name,unit,'l')>0) {moveL=-step;} else {moveL=0;}
          if (getClipValues(obj_name,unit,'t')>0) {moveT=-step;} else {moveT=0;}
          if (moveL!=0 | moveT!=0) {moveClip(obj_name,unit,moveL,moveT,0,0); fl_rec=true;}
        break;
      }
      if (fl_rec) {
        setTimeout('ExpandClipFromCorner("'+obj_name+'","'+unit+'","'+corner+'",'+(level+1)+','+step+','+left+','+top+','+width+','+height+','+speed+')',speed);
      }
    }

var app_timeout;

function hideAppeal() {
   obj=document.all?document.all['id_appeal']:document.getElementById('id_appeal');
   if (obj) {obj.className='hide';}
   f_appeal.appeal_comm.value='';
}

function showAppeal() {
   obj=document.all?document.all['id_appeal']:document.getElementById('id_appeal');
   if (obj) {
      obj.style.left=mousexy.x-310;
      obj.style.top=mousexy.y+5;
      if ($.browser.msie) { //MUSDIE!!!
        obj.className='show';
      } else {
        setClip('id_appeal','px',0,0,0,0);
        obj.className='show';
        ExpandClipFromCorner('id_appeal','px','rt',0,15,310,100,310,310,1);
      }
   }
}

function doAppeal(max_nm) {
  nm=parseInt(f_appeal._i_na.value); 
  res=true;
  if (!isNaN(nm)) {if (nm<0 || nm>max_nm) {res=false;}} else {res=false;}
  if (res==false) {alert('Неверно указан вариант правильного ответа!'); return false;}
  s=f_appeal._st_link.value;
  if (s.length<8) {alert('Укажите ссылку на результат события!'); return false;}
  s=f_appeal.appeal_comm.value;
  if (s.length<15) {alert('Добавьте обоснованный комментарий к апелляции!'); return false;}


  $.blockUI({message:'<img src="images/wait_w.gif" border="0"/>'});
  nm=parseInt(f_appeal._i_na.value); s=escape(f_appeal._st_link.value); comm=escape(f_appeal.appeal_comm.value); idb=f_appeal.id_bet.value;
  $.post('?',{jajax:'appeal',_i_na:nm,_st_link:s,comm:comm,id_bet:idb},function(xml) {
        $.unblockUI();
        hideAppeal();
        alert("Ваша апелляция отправлена оператору и будет рассмотрена в ближайшее время.");
        obj=document.all?document.all['id_bt_appeal']:document.getElementById('id_bt_appeal');   if (obj) {obj.className='hide';} 
        obj1=document.all?document.all['id_appeal_count_text']:document.getElementById('id_appeal_count_text');  
        obj2=document.all?document.all['id_appeal_count']:document.getElementById('id_appeal_count');  
         if (obj1 && obj2) {
           obj1.className='appeal_count show';
           obj2.innerHTML=parseInt(obj2.innerHTML)+1;
           doLoadSC();
         } 
     });


}

function doCBCAPP() {
  if (f_appeal.cb_cancel.checked) {f_appeal._i_na.value=0;} else {f_appeal._i_na.value='';}
}

function doNA() {
  f_appeal.cb_cancel.checked=false;
  nm=parseInt(f_appeal._i_na.value); 
  if (!isNaN(nm)) {
    if (nm==0) {f_appeal.cb_cancel.checked=true;} 
  }
}

var _isugg = 0;
var _fl_sugg_open = false;
var _fl_sugg_mo = false;
var _fl_sugg_run = false;
var _fl_sugg_add = false;
var _ms_sugg_prev = 0;
//var _tid = 0;
var _ar_sugg = new Array();
var _fl13 = false;
var _isugg_cache = new Array();

function _addArSuggest(sg) {
  for (i=0; i<_ar_sugg.length; i++) {if (_ar_sugg[i]==sg) return true;} 
  _ar_sugg.splice(_ar_sugg, 0, sg); return true;
}

//function doSetSuggestFind(fn,w,s) {
//  eval('s1=document.'+fn+'.'+w+'.value;'); 
//  n1=s1.lastIndexOf(' ');  
//  n2=s1.lastIndexOf(',');  
//  n3=s1.lastIndexOf(';');  
//  n4=s1.lastIndexOf('|');  
//  n=Math.max(Math.max(n1,n2),Math.max(n3,n4));
//  if (n>0) {s=s1.substring(0,n+1)+s;} 
//  eval('document.'+fn+'.'+w+'.value=s;');  
//  hideSuggest(w);
//}

function setSuggestToInput(fn,w,prefix,i) {
  obj=document.all?document.all[prefix+'_isugg_b_'+i]:document.getElementById(prefix+'_isugg_b_'+i);
  if (obj) {
    s=obj.innerHTML;
    if (_fl_sugg_add) {
      eval('s1=document.'+fn+'.'+w+'.value;'); 
      n1=s1.lastIndexOf(' ');  
      n2=s1.lastIndexOf(',');  
      n3=s1.lastIndexOf(';');  
      n4=s1.lastIndexOf('|');  
      n=Math.max(Math.max(n1,n2),Math.max(n3,n4));
      if (n>0) {s=s1.substring(0,n+1)+s;} 
    }
    eval('document.'+fn+'.'+w+'.value=s;');  
    hideSuggest(w);
  }
}

function _doLoadSuggest(fn,w,prefix,s) {
  var req = new JsHttpRequest();
  req.onreadystatechange = function() {
      if (req.readyState == 4) {
          if (req.responseJS) {
            _addArSuggest(w);
            obj=document.all?document.all['sugg_'+w]:document.getElementById('sugg_'+w);
            if (obj) {obj.innerHTML = req.responseJS.html;}
            _fl_sugg_run=false;
            onSuggSetActive(prefix,1);
          }
      }
  }
  s=escape(s);
  req.caching=true; req.open('POST',('http://'+location.hostname+'/?jsload='+w+'&sbeg='+s+'&fname='+fn+'&prefix='+prefix+'&'),true); req.send();
}

function doSuggest(fn,finp,prefix,fsadd) {
//  if (!_fl_sugg_open) {
//  if (!_fl_sugg_run) {
  _fl_sugg_add=fsadd;
  _fl_sugg_run=true;
   eval('s=document.'+fn+'.'+finp+'.value;');  
  _now = new Date();
  _ms=_now.getTime(); 
	 s=escape(s);
	 ids=finp+s+fn+prefix;
	 idcache='';
	 for (i=0; i<ids.length; i++) {
	   idcache+=ids.charCodeAt(i);
	 }
	 if (_isugg_cache[idcache]) {
	    $('#sugg_'+finp).html(_isugg_cache[idcache]); 
	 } else {
		 $.post('?',{jajax:finp,_s_sbeg:s,fname:fn,prefix:prefix,_st_idcache:idcache},function(xml) {
				 _addArSuggest($("jajax",xml).text());
				 $('#sugg_'+$("jajax",xml).text()).html($("html",xml).text()); 
				 _fl_sugg_run=false;
				 onSuggSetActive($("prefix",xml).text(),1);
				 _isugg_cache[$("idcache",xml).text()]=$("html",xml).text();
		 });
	 }
//  } else {
//if (obj) {obj.innerHTML = (_ms-_ms_sugg_prev)+" : "+_tid+" : "+"_doLoadSuggest('"+fn+"','"+finp+"','"+prefix+"',"+s+");";}    
//    window.clearTimeout(_tid);
//    _tid=window.setTimeout("_doLoadSuggest('"+fn+"','"+finp+"','"+prefix+"','"+s+"');",(_ms-_ms_sugg_prev));
//  }
  _ms_sugg_prev=_ms;
//  }
//  }
}

function hideSuggest(w) {
  obj=document.all?document.all['sugg_'+w]:document.getElementById('sugg_'+w);  if (obj) {obj.innerHTML = '';}
  _fl_sugg_open=false;
}

function onSuggSetActive(prefix, i) {
  obji=document.all?document.all[prefix+'_isugg_'+i]:document.getElementById(prefix+'_isugg_'+i);
  objo=document.all?document.all[prefix+'_isugg_'+_isugg]:document.getElementById(prefix+'_isugg_'+_isugg);
//  if (obji && (objo || _isugg==-1)) {
  if (obji) {
    if (objo) {objo.className='sugg';}
    obji.className='sugg_hover';
    _isugg=i;
  }
  _fl_sugg_open=true;
//window.status=window.status+'true';  
}

function onSuggKeyUpDown(fname, finp, prefix, fsadd, e) {
  var kk = navigator.appName == 'Netscape' ? e.which : e.keyCode;
window.status=window.status+'UP:'+kk+_fl_sugg_open;  
//  alert(_fl_sugg_open);
  if (kk==13) {_fl13=true;} else {_fl13=false;}
  if (kk==13 && _fl_sugg_open) {setSuggestToInput(fname,finp,prefix,_isugg); return true;}
  if (kk==38 && _fl_sugg_open) {onSuggSetActive(prefix,(_isugg-1)); return false;}
  if (kk==40 && _fl_sugg_open) {onSuggSetActive(prefix,(_isugg+1)); return false;}
  if (kk==27 && _fl_sugg_open) {hideSuggest(finp); return false;}
  doSuggest(fname,finp,prefix,fsadd);
  return false;
}

function onSuggKeyDown13() {
  var kk = navigator.appName == 'Netscape' ? e.which : e.keyCode;
  if (kk==13) {_fl_sugg_open=true;}
window.status=window.status+'DONW:'+kk+_fl_sugg_open;    
}

function onMouseSuggOut() {_fl_sugg_mo=false;}

function onMouseSuggSetActive(prefix, i) {
  if (!_fl_sugg_mo) {onSuggSetActive(prefix, i);}
  _fl_sugg_mo=true;
}

function _hideSuggestAll() {for (i=0; i<_ar_sugg.length; i++) {hideSuggest(_ar_sugg[i]);}}

function in_array(a,ar) {for (i=0; i<ar.length; i++) {if (ar[i]==a) return true;} return false;}
  function array_add_no_dublicate(a,ar) {if (!in_array(a,ar)) {ar.splice(ar.length, 0, a); return ar;} return ar;}
  //function array_add_no_dublicate(a,ar) {if (!in_array(a,ar)) {ar[ar.length]=a;return ar;} return ar;}
  function array_del_element(a,ar) {for (i=0; i<ar.length; i++) {if (ar[i]==a) {ar.splice(i, 1);return ar;}} return ar;}
  function array_clear(ar) {ar.splice(0,ar.length); return ar;}
  function in_array_count(a,ar) {cou=0; for (i=0; i<ar.length; i++) {if (ar[i]==a) {cou++;}} return cou;}
  function in_array_first_ind(a,ar) {for (i=0; i<ar.length; i++) {if (ar[i]==a) {return i;}} return -1;}

/*
 * Date Time Picker
 * 
 * author page: http://shuric.dp.ua
 *
 * Copyright (c) 2008-2009 Shuric A. Cornery
 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
 *
 * version 1.5
 * 07/09/2009
 *
 * <div id="id_sugg_dt" onclick="sugg_dt.open();" class="sugg-date"></div>
 *	$_GP['_js'].="var sugg_dt;";
 *	$_GP['_js_ready'].="
 *   sugg_dt = new JsSuggCalendar('id_sugg_dt','sugg_dt',new Date(),true,false,1,'',0,true,false);
 * 	";
 *
 */
function JsSuggCalendar(obj_name,name_var_sugg,dt,fl_time,lm_check,fl_correct,js_on_ok,sec,not_fl_day,dt_from,dt_to,fl_static,fl_to_null) {
  this._nvs=name_var_sugg;
  if (!dt) {var dt = new Date();}
	if (!dt_from) {this.dt_from=false;} else {
	  this.dt_from=dt_from;
		this.dt_from.setSeconds(0);
	}
	if (!dt_to) {this.dt_to=false;} else {
	  this.dt_to=dt_to;
		this.dt_to.setSeconds(0);
	}
	if (!fl_to_null) {
	  this._fl_to_null = false;
	} else {
	  this._fl_to_null = fl_to_null;
	}	
	
	if (dt=='Invalid Date' || isNaN(dt)) {var dt = new Date(0,0,0,0,0); this.fl_date_empty=true;} else {this.fl_date_empty=false;}
	
  this.class_js_day='sugg-dtp-day';
  this.class_js_day_hol='sugg-dtp-day-hol';
  this.class_js_day_now='sugg-dtp-day-now';
  this.class_js_day_tec='sugg-dtp-day-tec';
	this.class_js_day_gray='sugg-dtp-day-gray';
  
	this._fl_kvartal=false;
	
	this._ua_holidays = new Array(
	  '0101','0701','0803','0105','0205','0905','2806','2408'
	);
	this.fl_holidays = 'ua';
	
  this._dt = dt;
	this._fl_static=fl_static;
  this._js_year = dt.getFullYear();
  this._js_month = dt.getMonth()+1;
  this._js_day = dt.getDate();
  this._js_hour = dt.getHours();
  this._js_min = dt.getMinutes();
	this._top_year = this._js_year; 
	this._top_month = this._js_month; 
	
  this._js_year_1 = this._js_year;
  this._js_month_1 = this._js_month;
  this._js_day_1 = this._js_day;
  this._js_hour_1 = this._js_hour;
  this._js_min_1 = this._js_min;
	
  this._fl_time = fl_time;
	if (not_fl_day) {this._fl_day = false;} else {this._fl_day=true;}
  this._sel_day = '';
  this._lm = lm_check;
  this._fl_open = false;
  this._fl_correct_lm = fl_correct; // 1 - другую дату, 0 - себя, -1 - никого
  this._js_on_ok=js_on_ok;
  this._js_on_open='';
  this._js_on_change_dt_more = '';
  this._js_on_change_dt_less = '';
  this._js_on_change_dt_self = '';
  this._js_after_change_month_func_name = '';
  this._js_on_day_func_name = ''; // function(year,month,day)
  this._href_on_day_func_name = ''; // 
  this._position = 'rb'; // rb, rt, lt, lb
  this._pos_delta_x = 0;
  this._pos_delta_y = 0;
  this._fl_change = false;
  this._dt_open = '';
	
	this._ar_day_click = new Array();
	this._ar_day_title = new Array();
	this._fl_day_click = false;
  
  this.prefix_draw_before='';
  this.prefix_draw_after='';
  
  if (!sec) sec=0;  this._dt.setSeconds(0);
  
  this._sugg_more=null;
  this._sugg_less=null;
  
	if (this._fl_static) {
		$('#'+obj_name).html('<div id="id_calendar_'+obj_name+'"></div>');
	} else {
    $('body').append('<div id="id_calendar_'+obj_name+'" style="position:absolute;z-index:10000;top:0px;left:0px; background-color:white;"></div>');
	}
	
	this._obj_calendar=$('#'+'id_calendar_'+obj_name);
  //this._obj_calendar=document.all?document.all['id_calendar_'+obj_name]:document.getElementById('id_calendar_'+obj_name);
  
	this._obj_dt=$('#'+obj_name);
	//document.all?document.all[obj_name]:document.getElementById(obj_name);
  
  this.l2sz2 = function(i) {
	  i=parseInt(i); 
		if (i<10) {return '0'+i;} else {return i;}
	}

  this.parseInt0 = function(i) {
	  i=String(i).replace(/^0+/,"");
	  if (i=='') {return 0;} else {return parseInt(i);}
	}

	this.isHoliday = function(d,m,y) {
	  tdate = new Date(y,m-1,d);
		w = tdate.getDay();
		if (w==0 || w==6) return true;
	  switch (this.fl_holidays) {
		  case 'ua':
//_debug(this.l2sz2(d)+''+this.l2sz2(m));			
			  if ($.inArray((this.l2sz2(d)+''+this.l2sz2(m)),this._ua_holidays)>-1) {return true;}
			break;
		}
		return false;
	}
	
  this.getDateSQL = function() {return this._js_year+'-'+this.l2sz2(this._js_month)+'-'+this.l2sz2(this._js_day)+' '+this.l2sz2(this._js_hour)+':'+this.l2sz2(this._js_min)+':00';}
  this.getDateWithoutTimeSQL = function() {return this._js_year+'-'+this.l2sz2(this._js_month)+'-'+this.l2sz2(this._js_day);}
  this.getDateDMYHI = function() {
  	s=this.l2sz2(this._js_day)+'.'+this.l2sz2(this._js_month)+'.'+this._js_year;
  	if (this._fl_time) {
  		s+=' '+this.l2sz2(this._js_hour)+':'+this.l2sz2(this._js_min);
  	}
  	return s;
  }
  this.getDateDMYHI_pba =function() {
    s=this.getDateDMYHI();
    if (this.prefix_draw_before!='') {s=this.prefix_draw_before+s;}
    if (this.prefix_draw_after!='') {s=s+this.prefix_draw_after;}
    return s;
  }
	
	this.setDayClick = function(year,month,sday) {
		this._fl_day_click = true;
	  year=parseInt(year); 
	  month=parseInt(month); 
	  if (!this._ar_day_click[year]) this._ar_day_click[year]=new Array();
	  if (!this._ar_day_click[year][month]) this._ar_day_click[year][month]=new Array();
	  if (!this._ar_day_title[year]) this._ar_day_title[year]=new Array();
	  if (!this._ar_day_title[year][month]) this._ar_day_title[year][month]=new Array();
	  ar_day=sday.split('|');
		for (i=0; i<ar_day.length; i++) {
		  ar1=ar_day[i].split(':'); 
		  day=parseInt(ar1[0]); 
	    this._ar_day_click[year][month][day]=true;
	    this._ar_day_title[year][month][day]=ar1[1];
		}	
		this._drawSuggestCalendar(this._top_year,this._top_month,-1,-1,-1);
	}
	
	this.checkDayClick = function(year,month,day) {
	  if (this._ar_day_click[year] && this._ar_day_click[year][month] && this._ar_day_click[year][month][day]) {
		  return true;
		} else {
		  return false;
		}
	}
  
  this.open = function(mousex,mousey) {
    if (!this._fl_static) {
      if (!mousex && mousexy) {mousex=mousexy.x;}
      if (!mousey && mousexy) {mousey=mousexy.y;}
      if ((mousex+170)>$(window).width()) {mousex=mousex-170;}
      if ((mousey+210)>$(window).height()) {mousey=mousey-210;}
      if (mousex<10) mousex=10; if (mousey<10) mousey=10;
      mousex+=this._pos_delta_x; mousey+=this._pos_delta_y;
      this._obj_calendar.css({left:mousex,top:mousey});
		}	
    this._obj_calendar.show();
		if (this.fl_date_empty) {
			dt = new Date();
			this._js_year = dt.getFullYear();
			this._js_month = dt.getMonth()+1;
			this._js_day = dt.getDate();
			this._js_hour = dt.getHours();
			this._js_min = dt.getMinutes();
		}	 else {
		  dt=new Date(this._js_year,this._js_month,this._js_day,this._js_hour,this._js_min);
		}
		if (this.dt_from && dt<this.dt_from) {this.setDate(this.dt_from);}
		if (this.dt_to && dt>this.dt_to) {this.setDate(this.dt_to);}
    this._drawSuggestCalendar(this._js_year,this._js_month,this._js_day,this._js_hour,this._js_min);
    this._fl_open=true;
    this._dt_open=this.getDateSQL();
    if (this._js_on_open!='') {eval(this._js_on_open);}
		this._jsAfterChangeMonth();
  }
	
  this.setPosition = function(spos, delta_x, delta_y) {
    this._position=spos; this._pos_delta_x=delta_x; this._pos_delta_y=delta_y;
  }
  
  this._checkDate = function() {
    if (this._sugg_more) {
      if (this._dt.getTime()>this._sugg_more._dt.getTime()-1000*this._lm*60) {
         switch (this._fl_correct_lm) {
           case 1: 
             dt2=new Date(); dt2.setTime(this._dt.getTime()+1000*this._lm*60); this._sugg_more.setDate(dt2); 
             if (this._js_on_change_dt_more!='') {eval(this._js_on_change_dt_more);}
           break;
           case 0: 
             dt2=new Date(); dt2.setTime(this._sugg_more._dt.getTime()-1000*this._lm*60); this.setDate(dt2); 
             if (this._js_on_change_dt_self!='') {eval(this._js_on_change_dt_self);}
           break;
         }
//alert('0:'+dt2+this._sugg_more._dt+this._nvs+' '+dt2);
      }
    }
    if (this._sugg_less) {
      if (this._dt.getTime()<this._sugg_less._dt.getTime()+1000*this._lm*60) {
         switch (this._fl_correct_lm) {
           case 1: 
             dt2=new Date(); dt2.setTime(this._dt.getTime()-1000*this._lm*60); this._sugg_less.setDate(dt2); 
             if (this._js_on_change_dt_less!='') {eval(this._js_on_change_dt_less);}
           break;
           case 0: 
             dt2=new Date(); dt2.setTime(this._sugg_less._dt.getTime()+1000*this._lm*60); this.setDate(dt2); 
             if (this._js_on_change_dt_self!='') {eval(this._js_on_change_dt_self);}
           break;
         }
      }
    }
  }
  
  this._drawIDDate = function(fl_cancel) {
	  if (!this._fl_static) {
			if (this.fl_date_empty) {
				this._obj_dt.html('');
				return;
			}
		
			if (!fl_cancel) {
				yy=this._js_year;
				mm=this.l2sz2(parseInt(this._js_month))
				dd=this.l2sz2(this._js_day);
				if (this._fl_time) {
					hh=this.l2sz2(this._js_hour);
					ii=this.l2sz2(this._js_min);
				}
			} else {
				yy=this._js_year_1;
				mm=this.l2sz2(parseInt(this._js_month_1));
				dd=this.l2sz2(this._js_day_1);
				if (this._fl_time) {
					hh=this.l2sz2(this._js_hour_1);
					ii=this.l2sz2(this._js_min_1);
				}
			}
			
			if (this._fl_kvartal) {
			  s=Math.round((mm-1)/3+1)+' кв. '+yy;
				s1=dd+'.'+mm+'.'+yy;
			} else {
				if (this._fl_day) {
					s=dd+'.'+mm+'.'+yy;
//_debug('['+this.parseInt0(dd)+' '+this.parseInt0(mm)+']');
					if (this.isHoliday(this.parseInt0(dd),this.parseInt0(mm),this.parseInt0(yy))) {
					  this._obj_dt.addClass('sugg-dtp-holiday');
					} else {
					  this._obj_dt.removeClass('sugg-dtp-holiday');
					}
					if (this._fl_time) {s=s+' '+hh+':'+ii;}
				} else {
					s=mm+'.'+yy;
				}
			}
			if (this.prefix_draw_before!='') {s=this.prefix_draw_before+s;}
			if (this.prefix_draw_after!='') {s=s+this.prefix_draw_after;}
			if (this._obj_dt.attr('tagName')=='INPUT') {
				this._obj_dt.val(s);
				if (this._fl_kvartal) {
					this._obj_dt.attr('tvalue',s1);
				}
			} else {
				if (jQuery.browser.msie) {
					this._obj_dt.html(s+'&'+'nbsp'+';');
				} else {
					this._obj_dt.html('<nobr>'+s+'&nbsp;</nobr>');
				}
				this._obj_dt.css({cursor:'pointer'});
			}
		}
  }
  
  this._drawIDDate();
	
	this._checkDTFromTo = function(dt) {
    if (this._fl_day) {
			if (this._fl_time) {
				dtf = dt;
				dtt = dt;
			} else {
				dtf = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),23,59,59);
				dtt = new Date(dt.getFullYear(),dt.getMonth(),dt.getDate(),0,0,0);
			}
		} else {
			dtf = new Date(dt.getFullYear(),dt.getMonth(),30,23,59,59);
			dtt = new Date(dt.getFullYear(),dt.getMonth(),1,0,0,0);
		}
//_debug(dt+' from='+dtf+' to='+dtt+' == from='+this.dt_from+' == to='+this.dt_to+' <br> ');
		if ((!this.dt_from || (this.dt_from && dtf>=this.dt_from)) &&
				(!this.dt_to || (this.dt_to && dtt<=this.dt_to)))
		{
		  return 0;
		} else {
		  if (this.dt_from && dtf<this.dt_from) {
			  return -1;
			} else {
			  return 1;
			}
		}
	}

  this.setDate = function(dt) {
	  if (!dt) {var dt = new Date();}
    this._js_year = dt.getFullYear();
		if (this._top_month!=(dt.getMonth()+1)) {fl_change_month = true;} else {fl_change_month = false;}
    this._js_month = dt.getMonth()+1;
    this._js_day = dt.getDate();
    this._js_hour = dt.getHours();
    this._js_min = dt.getMinutes();
//_debug(dt);		
		if (this._checkDTFromTo(dt)==0) {
			this._top_year = this._js_year; 
    	this._top_month = this._js_month; 

			this._dt = dt;
			this._drawIDDate();
			if (this._fl_open) {this._redraw();}
			
			if (fl_change_month) this._jsAfterChangeMonth();
		}
//    this._dt = new Date(this._js_year,this._js_month-1,this._js_day,this._js_hour,this._js_min,0);
  }
  
  this.incDay = function(inc) {
  	if (inc!=0) {d=this._dt; tm=d.getTime(); d.setTime(tm+inc*1000*60*60*24); this.setDate(d);}
  }
  
  this.setDateFormat = function(sdt,fmt) {
    re1 = /^\s*/;  re2 = /\s*$/;   sdt=sdt.replace(re1, "").replace(re2, "");
		d=0; m=0; y=0; h=0; i=0; s=0;
		for (ii=0; ii<fmt.length; ii++) {
		  if (ii<sdt.length) {
				v=parseInt(sdt.charAt(ii)); f=fmt.charAt(ii);
				if (f=='d') d=d*10+v;
				if (f=='y') y=y*10+v;
				if (f=='m') m=m*10+v;
				if (f=='h') h=h*10+v;
				if (f=='i') i=i*10+v;
				if (f=='s') s=s*10+v;
	      if (isNaN(d) || isNaN(m) || isNaN(y) || isNaN(h) || isNaN(i) || isNaN(s)) return false;
   	  }
		}
		d = new Date(y,m-1,d,h,i,s);
    if (d!=null) {this.setDate(d);}
  }
  
  this._close = function() {
    this._obj_calendar.html(''); this._obj_calendar.hide();
    this._fl_open=false; 
  }
	
  this.ok_empty = function() {
	  if (!this._fl_static) {
			if (this._obj_dt.attr('tagName')=='INPUT') {
				this._obj_dt.val('');
				if (this._fl_kvartal) {
					this._obj_dt.attr('tvalue','');
				}
			} else {
				this._obj_dt.html('NULL');
			}	
			this._close();
		}
	}
	
  this.ok = function() {
		this.fl_date_empty=false;
	  if (!this._fl_day) {
		  this._js_year=this._top_year;
			this._js_month=this._top_month;
		  dt = new Date(this._js_year,this._js_month-1,1);
		} else {
			dt = new Date(this._js_year,this._js_month-1,this._js_day,this._js_hour,this._js_min,0);
		}
  	if (this._checkDTFromTo(dt)==0) {
			this._js_year_1 = this._js_year;
			this._js_month_1 = this._js_month;
			this._js_day_1 = this._js_day;
			this._js_hour_1 = this._js_hour;
			this._js_min_1 = this._js_min;
			this._close();
			this._drawIDDate(true);
		}
  }
	
  this.cancel = function() {
	  this._close();
		this._fl_change=false;
		this._drawIDDate(true);
  }
  
  this.closee = function() {this._fl_change=false;}
  
  this._setIDDate = function (year,month,day) {
    if (year!=-1 && month!=-1 && day!=-1) {
      this._js_year=year;  this._js_month=month;  this._js_day=day;
    }
    //if (this._fl_time) {if (year!=-1) {this._deltaTime(-1,0);}}
    this._dt = new Date(this._js_year,this._js_month-1,this._js_day,this._js_hour,this._js_min,0);
    this._checkDate();
    this._drawIDDate();
    if (this._dt_open!=this.getDateSQL()) {this._fl_change=true;}
  }
  
  this._changeDay = function(year,month,day) {
    this._setIDDate(year,month,day);
		if (this._js_on_day_func_name!='' && this.checkDayClick(year,month,day)) {
		   eval(this._js_on_day_func_name+'('+year+','+month+','+day+');');
		}
    if (this._fl_time) {
      dt = new Date(this._js_year,this._js_month-1,this._js_day,this._js_hour,this._js_min,0);
			code=this._checkDTFromTo(dt);
			if (code!=0) {
			  if (code==-1 && this.dt_from) {
					$('#'+this._nvs+'_js_id_hour_1').html(Math.floor(this.dt_from.getHours()/10));
					$('#'+this._nvs+'_js_id_hour_2').html(this.dt_from.getHours()%10);
					$('#'+this._nvs+'_js_id_min_1').html(Math.floor(this.dt_from.getMinutes()/10));
					$('#'+this._nvs+'_js_id_min_2').html(this.dt_from.getMinutes()%10);
					this._js_hour=this.dt_from.getHours();
					this._js_min=this.dt_from.getMinutes();
				}
				if (code==1 && this.dt_to) {
					$('#'+this._nvs+'_js_id_hour_1').html(Math.floor(this.dt_to.getHours()/10));
					$('#'+this._nvs+'_js_id_hour_2').html(this.dt_to.getHours()%10);
					$('#'+this._nvs+'_js_id_min_1').html(Math.floor(this.dt_to.getMinutes()/10));
					$('#'+this._nvs+'_js_id_min_2').html(this.dt_to.getMinutes()%10);
					this._js_hour=this.dt_to.getHours();
					this._js_min=this.dt_to.getMinutes();
				}
			}
		}
    this._drawSuggestCalendar(this._js_year,this._js_month,this._js_day,-1,-1);
  }  
	
	this.viewAsKvartal = function() {
	  this._fl_kvartal = true;
    this._js_day = 1;
    this._js_hour = 0;
    this._js_min = 0;
		this._drawIDDate();
	}

  this._changeMonth = function(year,month) {
	  dt1=new Date(year,month,1);
		err=false;
		if (this.dt_from) {
			dtf=new Date(this.dt_from.getFullYear(),this.dt_from.getMonth()+1,1);
			if (dt1<dtf) err=true;
		}
		if (this.dt_to) {
			dtt=new Date(this.dt_to.getFullYear(),this.dt_to.getMonth()+1,1);
			if (dt1>dtt) err=true;
		}	
		if (!err) {
			this._top_year = year; 
    	this._top_month = month; 
			this._drawSuggestCalendar(year,month,-1,-1,-1);
			this._jsAfterChangeMonth();
		}
  }  
	
	this._jsAfterChangeMonth = function() {
		if (this._js_after_change_month!='') {
			eval(this._js_after_change_month_func_name+'('+this._top_year+','+this._top_month+');');
		}    
	}
	
  this._redraw = function() {
    this._drawSuggestCalendar(this._js_year,this._js_month,this._js_day,this._js_hour,this._js_min);
  }
  
  this._drawSuggestCalendar = function(year,month,day,hour,min) {
//    _sel_day=year+''+this.l2sz2(month-1)+''+this.l2sz2(day);
		_sel_day=this._js_year+''+this.l2sz2(this._js_month-1)+''+this.l2sz2(this._js_day);
    tdate = new Date();
    ordinal_day_now = tdate.getFullYear()+''+this.l2sz2(tdate.getMonth())+''+this.l2sz2(tdate.getDate());
    
    tdate = new Date(year,month-1,1);
    
    y_prev=year; m_prev=month-1; if (m_prev==0) {m_prev=12; y_prev=year-1;}
    y_next=year; m_next=month+1; if (m_next==13) {m_next=1; y_next=year+1;}
    
    day_start=tdate.getDay(); if (day_start==0) {day_start=7;} day_start=day_start-1;
    switch (month) {
      case 4:
      case 6:
      case 9:
      case 11: days=30; break;
      case 2: if (((year%4)==0) && ((year%100)!=0) || ((year%400)==0)) {days=29;} else {days=28;} break;
      default: days=31;
    }
//    if (month<10) {month='0'+month;}
  
    html='';
    
    html+='<TABLE BORDER="0" CELLSPACING="1" CELLPADDING="2" class="sugg-dtp">';
    html+='<tr><td class="sugg-dtp-close" onclick="'+this._nvs+'.setDate();" title="текущее">&#149;</td>';
		html+='<td colspan="5" align="center"><table border="0"><tr><td>';
		if (this._fl_kvartal) {
			html+='<td class="cp" onclick="'+this._nvs+'._changeMonth('+(year-1)+','+month+','+day+');">&lt;</td>';
			html+='<TD ALIGN="center">'+year+'</td>';
			html+='<td class="cp" onclick="'+this._nvs+'._changeMonth('+(year+1)+','+month+','+day+');">&gt;</td>';
		} else {
			html+='<td class="cp" onclick="'+this._nvs+'._changeMonth('+y_prev+','+m_prev+','+day+');">&lt;</td>';
			html+='<TD ALIGN="center">'+this.l2sz2(month)+'.'+year+'</td>';
			html+='<td class="cp" onclick="'+this._nvs+'._changeMonth('+y_next+','+m_next+','+day+');">&gt;</td>';
		}
		html+='</td></tr></table></td>';
	  if (this._fl_static) {
			html+='<td></td>';
		} else {
			html+='<td class="sugg-dtp-close" onclick="'+this._nvs+'.cancel();" title="отменить">&#215;</td>';
		}
		html+='</tr>';
		
		if (this._fl_kvartal) {
//cl='sugg-dtp-day-tec';		
//alert(_sel_day);		
			html+='<tr><td height="5"></td><td></td><td></td><td></td><td></td><td></td><td></td></TR>';
			html+='<tr class="sugg-dtp-title"><td colspan="3">квартал: </td>';
			i=1;
			while (i<=10) {
				if (_sel_day==year+''+this.l2sz2(i-1)+'01') {
					cl='sugg-dtp-day-tec';
				} else {
					cl='sugg-dtp-day';
				}
				html+='<td onclick="'+this._nvs+'._changeDay('+year+','+i+',1);" class="'+cl+'">'+Math.ceil(i/3) +'</td>';
			  i+=3;
			}
			html+='</TR>';
			html+='<tr><td colspan="7" height="5"></td></tr>';
		} else {
			if (this._fl_day) {
				html+='<tr class="sugg-dtp-title"><td>Пн</td><td>Вт</td><td>Ср</td><td>Чт</td><td>Пт</td><td class="sugg-dtp-holiday">Сб</td><td class="sugg-dtp-holiday">Вс</td></TR>';
				tday=0;
				tec_day=1;
				html+='<tr>';
				for (i=0;i<day_start;i++) {html+='<td></td>'; tday++;}
				for (tec_day=1; tec_day<=days; tec_day++) {
					if ((tday%7)==0) {
						if (day_start=0) {html+='<tr>';} else {html+='</tr><tr>';};
					}
					dttecf=new Date(year,month-1,tec_day,23,59,59);
					dttect=new Date(year,month-1,tec_day,0,0,0);
					oncl='';
					if ((!this.dt_from || (this.dt_from && dttecf>=this.dt_from)) &&
							(!this.dt_to || (this.dt_to && dttect<=this.dt_to)) &&
							(!this._fl_day_click || (this._fl_day_click && this.checkDayClick(year,month,tec_day))) 
						 )
					{
						html+='<td onclick="'+this._nvs+'._changeDay('+year+','+month+','+tec_day+');" ';
						cl='sugg-dtp-day';
						if (this.isHoliday(tec_day,month,year)) {cl='sugg-dtp-day-hol';}
						if (ordinal_day_now==tdate.getFullYear()+''+this.l2sz2(tdate.getMonth())+''+this.l2sz2(tec_day)) {cl='sugg-dtp-day-now';}
						if (_sel_day==tdate.getFullYear()+''+this.l2sz2(tdate.getMonth())+''+this.l2sz2(tec_day)) {cl='sugg-dtp-day-tec';}
						if (this._fl_day_click && this.checkDayClick(year,month,tec_day)) {
							html+=' title="'+this._ar_day_title[year][month][tec_day]+'"';
	//  				  oncl='onclick="'+this._nvs+'._changeDay('+year+','+month+','+tec_day+'); return false;"';
							oncl='onclick="return false;"';
						}
					} else {
						html+='<td ';
						cl='sugg-dtp-day-gray';
					}
					if (this._href_on_day_func_name!='' && oncl!='') {
						s_day='<a class="'+cl+'" '+oncl+' href="?'+this._href_on_day_func_name+'&year='+year+'&month='+month+'&day='+tec_day+'">'+tec_day+'</a>';
					} else {
						s_day=tec_day;
					}
					html+='class="'+cl+'">'+s_day+'</td>';
					tday++;
				}
				html+='</tr>';
				
				if (this._fl_time) {
					if (hour==-1) {hour=this._js_hour;}
					if (min==-1) {min=this._js_min;}
					html+='<tr>';
					html+='<td colspan="7" align="center">';
						html+='<table border="0" cellpadding="0" cellspacing="0" class="sugg-dtp-time">';
						html+='<tr valign="bottom">';
						html+='<td></td>';
						html+='<td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(1,1);">&#9650;</td><td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(2,1);">&#9650;</td>';
						html+='<td></td>';
						html+='<td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(3,1);">&#9650;</td><td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(4,1);">&#9650;</td>';
						html+='<td></td>';
						html+='</tr>';
						html+='<tr>';
						html+='<td class="sugg-dtp-time-hm" align="right" style="padding-right:3px;" onclick="'+this._nvs+'._deltaTime(1,0);'+this._nvs+'._deltaTime(2,0);">час</td>';
						html+='<td class="sugg-dtp-time-hm" id="'+this._nvs+'_js_id_hour_1" onclick="'+this._nvs+'._deltaTime(1,0);">'+Math.floor(hour/10)+'</td>';
						html+='<td class="sugg-dtp-time-hm" id="'+this._nvs+'_js_id_hour_2" onclick="'+this._nvs+'._deltaTime(2,0);">'+(hour%10)+'</td>';
						html+='<td>:</td>';
						html+='<td class="sugg-dtp-time-hm" id="'+this._nvs+'_js_id_min_1" onclick="'+this._nvs+'._deltaTime(3,0);">'+Math.floor(min/10)+'</td>';
						html+='<td class="sugg-dtp-time-hm" id="'+this._nvs+'_js_id_min_2" onclick="'+this._nvs+'._deltaTime(4,0);">'+(min%10)+'</td>';
						html+='<td class="sugg-dtp-time-hm" style="padding-left:3px;"  onclick="'+this._nvs+'._deltaTime(3,0);'+this._nvs+'._deltaTime(4,0);">мин</td>';
						html+='</tr>';
						html+='<tr valign="top">';
						html+='<td></td>';
						html+='<td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(1,-1);">&#9660;</td><td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(2,-1);">&#9660;</td>';
						html+='<td></td>';
						html+='<td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(3,-1);">&#9660;</td><td class="sugg-dtp-arrows" onclick="'+this._nvs+'._deltaTime(4,-1);">&#9660;</td>';
						html+='<td></td>';
						html+='</tr>';
						html+='</table>';
					html+='</td>';
					html+='</tr>';
				}
			}
		}
	  if (!this._fl_static) {
			html+='<tr>';
			if (this._fl_to_null) {
				html+='<td colspan="1" class="sugg-dtp-close" onclick="'+this._nvs+'.ok_empty(); '+this._js_on_ok+'; '+this._nvs+'.closee();" title="сбросить">&Theta;</td>';
				cs=6;
			} else {
			  cs=7;
			}
			html+='<td colspan="'+cs+'" class="sugg-dtp-close" onclick="'+this._nvs+'.ok(); '+this._js_on_ok+'; '+this._nvs+'.closee();" title="запомнить">ok</td>';
			html+='</tr>';
		}	
    
    html+="</TABLE>";
//alert(html);    
    this._obj_calendar.html(html);
		
    // this._obj_calendar.className='show'; this._obj_calendar.style.visibility='visible';
    
  }
  
  this._deltaTime = function(tp,delta) {
    if (this._fl_time) {
      fl_time=true;
			h1=parseInt($('#'+this._nvs+'_js_id_hour_1').html());
			h2=parseInt($('#'+this._nvs+'_js_id_hour_2').html());
			m1=parseInt($('#'+this._nvs+'_js_id_min_1').html());
			m2=parseInt($('#'+this._nvs+'_js_id_min_2').html());
      switch (tp) {
        case 1: 
           h1+=delta;
           if (delta>0) {if (h1>2) {h1=0;}}
           if (delta<0) {if (h1<0) {h1=2;}}
           if (delta==0) {h1=0;}
           $('#'+this._nvs+'_js_id_hour_1').html(h1);
           if (h1==2 && h2>3) {h2=3; $('#'+this._nvs+'_js_id_hour_2').html(h2);}
        break;   
        case 2: 
           h2+=delta;
           if (delta>0) {if (h2>9) {h2=0; if (h1<2) {h1++; $('#'+this._nvs+'_js_id_hour_1').html(h1);}}}
           if (delta<0) {if (h2<0) {h2=9; if (h1>0) {h1=h1-1;} else {h2=3; h1=2;} $('#'+this._nvs+'_js_id_hour_1').html(h1);}}
           if (delta==0) {h2=0;}
           if (h1==2 && h2>3) {h1=0; $('#'+this._nvs+'_js_id_hour_1').html(h1); h2=0;}
           $('#'+this._nvs+'_js_id_hour_2').html(h2);
        break;
        case 3: 
           m1+=delta;
           if (delta>0) {if (m1>5) {m1=0;}}
           if (delta<0) {if (m1<0) {m1=5;}}
           if (delta==0) {m1=0;}
           $('#'+this._nvs+'_js_id_min_1').html(m1);
        break;   
        case 4: 
           m2+=delta;
           if (delta>0) {if (m2>9) {m2=0; if (m1<5) {m1++;} else {m1=0;} $('#'+this._nvs+'_js_id_min_1').html(m1);}}
           if (delta<0) {if (m2<0) {m2=9; if (m1>0) {m1=m1-1;} else {m1=5;} $('#'+this._nvs+'_js_id_min_1').html(m1);}}
           if (delta==0) {m2=0;}
           $('#'+this._nvs+'_js_id_min_2').html(m2);
        break;   
      }
      if (m1==0) {this._js_min=m2;} else {this._js_min=parseInt(m1+''+m2);}
      if (h1==0) {this._js_hour=h2;} else {this._js_hour=parseInt(h1+''+h2);}
      dt = new Date(this._js_year,this._js_month-1,this._js_day,this._js_hour,this._js_min,0);
			code=this._checkDTFromTo(dt);
			if (code==0) {
				this._dt = dt;
				this._checkDate();
				this._drawIDDate();
				if (this._dt_open!=this.getDateSQL()) {this._fl_change=true;}
			} else {
			  if (code==-1) {
				  if (this.dt_from) {
						$('#'+this._nvs+'_js_id_hour_1').html(Math.floor(this.dt_from.getHours()/10));
						$('#'+this._nvs+'_js_id_hour_2').html(this.dt_from.getHours()%10);
						$('#'+this._nvs+'_js_id_min_1').html(Math.floor(this.dt_from.getMinutes()/10));
						$('#'+this._nvs+'_js_id_min_2').html(this.dt_from.getMinutes()%10);
						this._js_hour=this.dt_from.getHours();
						this._js_min=this.dt_from.getMinutes();
					}
				} else {
				  if (this.dt_to) {
						$('#'+this._nvs+'_js_id_hour_1').html(Math.floor(this.dt_to.getHours()/10));
						$('#'+this._nvs+'_js_id_hour_2').html(this.dt_to.getHours()%10);
						$('#'+this._nvs+'_js_id_min_1').html(Math.floor(this.dt_to.getMinutes()/10));
						$('#'+this._nvs+'_js_id_min_2').html(this.dt_to.getMinutes()%10);
						this._js_hour=this.dt_to.getHours();
						this._js_min=this.dt_to.getMinutes();
					}
				}
			}
    }
  }
  
};

function checkDate(s,fmt) {
// fmt='yyyy-mm-dd hh:ii:ss';  
	 yy=''; mm=''; dd=''; hh=''; ii=''; ss='';
	 if (fmt.length!=s.length) {return false;}
	 for (i=0; i<fmt.length; i++) {
		 if (i<s.length) {
			 char1=s.charAt(i);
			 charF=fmt.charAt(i);
			 switch (charF) {
				 case 'y':yy=yy+char1; if (!itInt(char1)) {return false;} break;
				 case 'm':mm=mm+char1; if (!itInt(char1)) {return false;} break;
				 case 'd':dd=dd+char1; if (!itInt(char1)) {return false;} break;
				 case 'h':hh=hh+char1; if (!itInt(char1)) {return false;} break;
				 case 'i':ii=ii+char1; if (!itInt(char1)) {return false;} break;
				 case 's':ss=ss+char1; if (!itInt(char1)) {return false;} break;
				 default: if (char1!=charF) {return false;}
			 }
		 } else {return false;}  
	 }
	 
	 yy=parseInt(sh_trim_to_int_without_zero(yy));
	 dd=parseInt(sh_trim_to_int_without_zero(dd));
	 mm=parseInt(sh_trim_to_int_without_zero(mm));
	 hh=parseInt(sh_trim_to_int_without_zero(hh));
	 ii=parseInt(sh_trim_to_int_without_zero(ii));
	 ss=parseInt(sh_trim_to_int_without_zero(ss));
	 
	 if (mm>12 || mm<1) {return false;}
	 if (hh>59 || hh<1) {return false;}
	 if (ii>59 || ii<1) {return false;}
	 if (ss>99 || ss<1) {return false;}
	 if (yy<1) {return false;}
	 
	 if (mm==2) {
		 maxday=28;
		 if (yy%400==0 || (yy%4==0 && yy%100>0)) maxday=29;
	 } else {
		 maxday=31;
		 if (mm==2) maxday=28; 
		 if (mm==4 || mm==6 || mm==9 || mm==11) maxday=30; 
	 }
	 if (dd>maxday) return false;  

	 return true;
}

/*
div.sugg-dtp {margin-bottom:3px; border-bottom:1px dashed #0D7C50; color:#0D7C50;}
input.sugg-dtp-holiday, div.sugg-dtp-holiday {color:red;}

table.sugg-dtp {width:100%; border:1px solid #dddddd; padding:2px; font-size:11px;}
tt.sugg-dtp-title {font-weight:bold; text-align:center;}
td.sugg-dtp-holiday {color:red;}
td.sugg-dtp-time-hm {cursor:crosshair; text-align:center;}
table.sugg-dtp-time {font-size:12px;}
td.sugg-dtp-arrows {cursor:crosshair; font-size:8px; text-align:center;}
td.sugg-dtp-close {cursor:pointer; font-size:13px; background-color:#eeeeee; text-align:center;}

td.sugg-dtp-day{background-color:#f7f7f7;cursor:pointer;text-align:center;border:1px solid white; color:black;}
td.sugg-dtp-day:hover{border:1px dotted #006600;background-color:#f0f0f0;}
a.sugg-dtp-day {text-decoration:none; color:black;}

td.sugg-dtp-day-hol{background-color:#f7f7f7;cursor:pointer;text-align:center;color:red;}
td.sugg-dtp-day-hol:hover{border:1px dotted #006600;background-color:#f0f0f0;}
a.sugg-dtp-day-hol {text-decoration:none; color:red;}

td.sugg-dtp-day-now{background-color:#f7f7f7;cursor:pointer;text-align:center;border:1px solid #FFD700;}
td.sugg-dtp-day-now:hover{border:1px dotted #006600;background-color:#f0f0f0;}
a.sugg-dtp-day-now{text-decoration:none; }

td.sugg-dtp-day-tec{background-color:#f7f7f7;cursor:pointer;text-align:center;border:1px solid #777777;}
a.sugg-dtp-day-tec {text-decoration:none; }

td.sugg-dtp-day-gray {background-color:#f0f0f0; cursor:default; text-align:center; border:1px solid white; color:#bbbbbb;}
a.sugg-dtp-day-gray {text-decoration:none; color:#bbbbbb;}
*/

function itInt(s) {
    if (s!='0' && s!='1' && s!='2' && s!='3' && s!='4' && s!='5' && s!='6' && s!='7' && s!='8' && s!='9') 
      {return false;} else {return true;}
  }

  function sh_trim_to_only_int(s) {
    while(s.length>0 && s.charAt(0)!='0' && s.charAt(0)!='1' && s.charAt(0)!='2' && s.charAt(0)!='3' && s.charAt(0)!='4' && s.charAt(0)!='5' && s.charAt(0)!='6' && s.charAt(0)!='7' && s.charAt(0)!='8' && s.charAt(0)!='9' && s.charAt(0)!='-') s=s.substring(1, s.length);
    while(s.length>0 && s.charAt(s.length-1)!='0' && s.charAt(s.length-1)!='1' && s.charAt(s.length-1)!='2' && s.charAt(s.length-1)!='3' && s.charAt(s.length-1)!='4' && s.charAt(s.length-1)!='5' && s.charAt(s.length-1)!='6' && s.charAt(s.length-1)!='7' && s.charAt(s.length-1)!='8' && s.charAt(s.length-1)!='9'&& s.charAt(s.length-1)!='-') s=s.substring(0, s.length-1);
    return s;
  }
  
  function sh_vert2space(s) { // меняет в строке все символы | на символ пробела
    res='';
    for (ii=0; ii<s.length; ii++) {a=s.charAt(ii); if (a=='|') {res+=' ';} else {res+=a;}}
    return res;
  }
  
  function sh_split_long(s,l) {
    r=''; dl=0;
    for (ii=0; ii<s.length; ii++) {
      a=s.charAt(ii);
      dl++;
      if (a==' ') {dl=0;};
      if (dl>l) {r+=' '; dl=1;}
      r+=a;
    }
    return r;
  }
  
  function sh_random(dl) {
    dl=Math.pow(10,dl);
    num=Math.floor(Math.random()*dl);
    return num;
  }

  function sh_trim_to_int(s) {
    while(s.length>0 && s.charAt(0)!='-' && s.charAt(0)!='0' && s.charAt(0)!='1' && s.charAt(0)!='2' && s.charAt(0)!='3' && s.charAt(0)!='4' && s.charAt(0)!='5' && s.charAt(0)!='6' && s.charAt(0)!='7' && s.charAt(0)!='8' && s.charAt(0)!='9') s=s.substring(1, s.length);
    while(s.length>0 && s.charAt(s.length-1)!='0' && s.charAt(s.length-1)!='1' && s.charAt(s.length-1)!='2' && s.charAt(s.length-1)!='3' && s.charAt(s.length-1)!='4' && s.charAt(s.length-1)!='5' && s.charAt(s.length-1)!='6' && s.charAt(s.length-1)!='7' && s.charAt(s.length-1)!='8' && s.charAt(s.length-1)!='9') s=s.substring(0, s.length-1);
    return s;
  }

  function sh_trim_to_int_without_zero(s) {
    while(s.length>0 && s.charAt(0)!='-' && s.charAt(0)!='1' && s.charAt(0)!='2' && s.charAt(0)!='3' && s.charAt(0)!='4' && s.charAt(0)!='5' && s.charAt(0)!='6' && s.charAt(0)!='7' && s.charAt(0)!='8' && s.charAt(0)!='9') s=s.substring(1, s.length);
    while(s.length>0 && s.charAt(s.length-1)!='0' && s.charAt(s.length-1)!='1' && s.charAt(s.length-1)!='2' && s.charAt(s.length-1)!='3' && s.charAt(s.length-1)!='4' && s.charAt(s.length-1)!='5' && s.charAt(s.length-1)!='6' && s.charAt(s.length-1)!='7' && s.charAt(s.length-1)!='8' && s.charAt(s.length-1)!='9') s=s.substring(0, s.length-1);
    return s;
  }

  function sh_trim_space(s) {
    while(s.length>0 && s.charAt(0)==' ') s=s.substring(1, s.length);
    while(s.length>0 && s.charAt(s.length-1)==' ') s=s.substring(0, s.length-1);
    return s;
  }

  function sh_trim_symbol(s,symb) {
    while(s.length>0 && s.charAt(0)==symb) s=s.substring(1, s.length);
    while(s.length>0 && s.charAt(s.length-1)==symb) s=s.substring(0, s.length-1);
    return s;
  }
  
  function sh_as_login_check(s,ds) {
    if (ds=='') {ds='0123456789_qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!.';}
    s=sh_trim_space(s);
    for (ii=0; ii<s.length; ii++) {if(ds.indexOf(s.charAt(ii))==-1) return false;}
    return true;
  }

  function realRound2 (r) {return Math.round(r*100)/100;}
  
  function trim(str) {
    var re1 = /^\s*/;
    var re2 = /\s*$/;
    return str.replace(re1, "").replace(re2, "");
  } 
  
  function s_replace(s,regexp,repl) {
    a1 = s.replace(regexp,repl);
    if (s!=a1) {return s_replace(a1,regexp,repl);} else {return s;}
  }

var fl_do_client_open = false;
var _fl_clnc = false;
var _tm_clnc;

function _doClient(obj) {
// if (!fl_do_client_open) {
   var memxy=mousexy;
   idcl=$(obj).attr('id_client')
   login=$(obj).attr('login')
   html='<div class="cl-div-a nowrap" onclick="doCLInfo('+idcl+')" onmouseover="_closeDoClient5s(true);" onmouseout="_closeDoClient5s(false);">&#149; информация о пользователе</div>';
   html+='<div class="cl-div-a nowrap" onclick="location.href=\'?betfindstr=*&ar_status=gambler&_s_find_referee=&_s_find_owner='+login+'&_s_find_gambler=\';" onmouseover="_closeDoClient5s(true);" onmouseout="_closeDoClient5s(false);">&#149; организатор споров</div>';
   html+='<div class="cl-div-a nowrap" onclick="location.href=\'?betfindstr=*&ar_status=gambler&_s_find_referee=&_s_find_owner=&_s_find_gambler='+login+'\';" onmouseover="_closeDoClient5s(true);" onmouseout="_closeDoClient5s(false);">&#149; участник споров</div>';
   html+='<div class="cl-div-a nowrap" onclick="location.href=\'?betfindstr=*&ar_status=gambler&_s_find_referee='+login+'&_s_find_owner=&_s_find_gambler=\';" onmouseover="_closeDoClient5s(true);" onmouseout="_closeDoClient5s(false);">&#149; арбитр споров</div>';
   if (__id_client>0 && __id_client!=idcl) {
      html+='<div class="cl-div-a nowrap" onclick="doMailCl2Cl('+idcl+'); _closeDoClient_G();" onmouseover="_closeDoClient5s(true);" onmouseout="_closeDoClient5s(false);">&#149; отправить пользователю сообщение</div>';
   }
   $('div#id_do_client_a').html(html);
   $('div#id_do_client_login').html(login);
   $('div#id_do_client').css({top:memxy.y-20, left:memxy.x-150});
   $('div#id_do_client').show();
   _closeDoClient5s(false);
   fl_do_client_open=true;
//  }
}

function _closeDoClient5s(fl) {
   _fl_clnc=fl;
   clearTimeout(_tm_clnc);
   if (!_fl_clnc) {
      _tm_clnc=setTimeout('_closeDoClient_G()',2000);
  }
}

function _closeDoClient_G() {
   $('div#id_do_client').hide();
   fl_do_client_open=false;
}

function parseAClients() {
//    $("a[fl_client=true]").mouseover( function() { _doClient(this);} );
   if (__id_client>0) {
       $("a[id_client]").mouseover( function() { _doClient(this);} );
   }
}

/*!
 * jQuery blockUI plugin
 * Version 2.25 (29-AUG-2009)
 * @requires jQuery v1.2.3 or later
 *
 * Examples at: http://malsup.com/jquery/block/
 * Copyright (c) 2007-2008 M. Alsup
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Thanks to Amir-Hossein Sobhi for some excellent contributions!
 */

;(function($) {

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
    return;
}

$.fn._fadeIn = $.fn.fadeIn;

// this bit is to ensure we don't call setExpression when we shouldn't (with extra muscle to handle
// retarded userAgent strings on Vista)
var mode = document.documentMode || 0;
var setExpr = $.browser.msie && (($.browser.version < 8 && !mode) || mode < 8);
var ie6 = $.browser.msie && /MSIE 6.0/.test(navigator.userAgent) && !mode;

// global $ methods for blocking/unblocking the entire page
$.blockUI   = function(opts) { install(window, opts); };
$.unblockUI = function(opts) { remove(window, opts); };

// convenience method for quick growl-like notifications  (http://www.google.com/search?q=growl)
$.growlUI = function(title, message, timeout, onClose) {
    var $m = $('<div class="growlUI"></div>');
    if (title) $m.append('<h1>'+title+'</h1>');
    if (message) $m.append('<h2>'+message+'</h2>');
    if (timeout == undefined) timeout = 3000;
    $.blockUI({
        message: $m, fadeIn: 700, fadeOut: 1000, centerY: false,
        timeout: timeout, showOverlay: false,
        onUnblock: onClose, 
        css: $.blockUI.defaults.growlCSS
    });
};

// plugin method for blocking element content
$.fn.block = function(opts) {
    return this.unblock({ fadeOut: 0 }).each(function() {
        if ($.css(this,'position') == 'static')
            this.style.position = 'relative';
        if ($.browser.msie)
            this.style.zoom = 1; // force 'hasLayout'
        install(this, opts);
    });
};

// plugin method for unblocking element content
$.fn.unblock = function(opts) {
    return this.each(function() {
        remove(this, opts);
    });
};

$.blockUI.version = 2.25; // 2nd generation blocking at no extra cost!

// override these in your code to change the default behavior and style
$.blockUI.defaults = {
    // message displayed when blocking (use null for no message)
    message:  '<h1>Please wait...</h1>',

    title: null,      // title string; only used when theme == true
    draggable: true,  // only used when theme == true (requires jquery-ui.js to be loaded)
    
    theme: false, // set to true to use with jQuery UI themes
    
    // styles for the message when blocking; if you wish to disable
    // these and use an external stylesheet then do this in your code:
    // $.blockUI.defaults.css = {};
    css: {
        padding:        0,
        margin:         0,
        width:          '30%',
        top:            '40%',
        left:           '35%',
        textAlign:      'center',
        color:          '#000',
        border:         '3px solid #aaa',
        backgroundColor:'#fff',
        cursor:         'wait'
    },
    
    // minimal style set used when themes are used
    themedCSS: {
        width:          '30%',
        top:            '40%',
        left:           '35%'
    },

    // styles for the overlay
    overlayCSS:  {
        backgroundColor: '#000',
        opacity:          0.6,
        cursor:          'wait'
    },

    // styles applied when using $.growlUI
    growlCSS: {
        width:  '350px',
        top:        '10px',
        left:       '',
        right:  '10px',
        border: 'none',
        padding:    '5px',
        opacity:    0.6,
        cursor:  null,
        color:      '#fff',
        backgroundColor: '#000',
        '-webkit-border-radius': '10px',
        '-moz-border-radius':     '10px'
    },
    
    // IE issues: 'about:blank' fails on HTTPS and javascript:false is s-l-o-w
    // (hat tip to Jorge H. N. de Vasconcelos)
    iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank',

    // force usage of iframe in non-IE browsers (handy for blocking applets)
    forceIframe: false,

    // z-index for the blocking overlay
    baseZ: 1000,

    // set these to true to have the message automatically centered
    centerX: true, // <-- only effects element blocking (page block controlled via css above)
    centerY: true,

    // allow body element to be stetched in ie6; this makes blocking look better
    // on "short" pages.  disable if you wish to prevent changes to the body height
    allowBodyStretch: true,

    // enable if you want key and mouse events to be disabled for content that is blocked
    bindEvents: true,

    // be default blockUI will supress tab navigation from leaving blocking content
    // (if bindEvents is true)
    constrainTabKey: true,

    // fadeIn time in millis; set to 0 to disable fadeIn on block
    fadeIn:  200,

    // fadeOut time in millis; set to 0 to disable fadeOut on unblock
    fadeOut:  400,

    // time in millis to wait before auto-unblocking; set to 0 to disable auto-unblock
    timeout: 0,

    // disable if you don't want to show the overlay
    showOverlay: true,

    // if true, focus will be placed in the first available input field when
    // page blocking
    focusInput: true,

    // suppresses the use of overlay styles on FF/Linux (due to performance issues with opacity)
    applyPlatformOpacityRules: true,

    // callback method invoked when unblocking has completed; the callback is
    // passed the element that has been unblocked (which is the window object for page
    // blocks) and the options that were passed to the unblock call:
    //     onUnblock(element, options)
    onUnblock: null,

    // don't ask; if you really must know: http://groups.google.com/group/jquery-en/browse_thread/thread/36640a8730503595/2f6a79a77a78e493#2f6a79a77a78e493
    quirksmodeOffsetHack: 4
};

// private data and functions follow...

var pageBlock = null;
var pageBlockEls = [];

function install(el, opts) {
    var full = (el == window);
    var msg = opts && opts.message !== undefined ? opts.message : undefined;
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    opts.overlayCSS = $.extend({}, $.blockUI.defaults.overlayCSS, opts.overlayCSS || {});
    var css = $.extend({}, $.blockUI.defaults.css, opts.css || {});
    var themedCSS = $.extend({}, $.blockUI.defaults.themedCSS, opts.themedCSS || {});
    msg = msg === undefined ? opts.message : msg;

    // remove the current block (if there is one)
    if (full && pageBlock)
        remove(window, {fadeOut:0});

    // if an existing element is being used as the blocking content then we capture
    // its current place in the DOM (and current display style) so we can restore
    // it when we unblock
    if (msg && typeof msg != 'string' && (msg.parentNode || msg.jquery)) {
        var node = msg.jquery ? msg[0] : msg;
        var data = {};
        $(el).data('blockUI.history', data);
        data.el = node;
        data.parent = node.parentNode;
        data.display = node.style.display;
        data.position = node.style.position;
        if (data.parent)
            data.parent.removeChild(node);
    }

    var z = opts.baseZ;

    // blockUI uses 3 layers for blocking, for simplicity they are all used on every platform;
    // layer1 is the iframe layer which is used to supress bleed through of underlying content
    // layer2 is the overlay layer which has opacity and a wait cursor (by default)
    // layer3 is the message content that is displayed while blocking

    var lyr1 = ($.browser.msie || opts.forceIframe) 
        ? $('<iframe class="blockUI" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;position:absolute;width:100%;height:100%;top:0;left:0" src="'+opts.iframeSrc+'"></iframe>')
        : $('<div class="blockUI" style="display:none"></div>');
    var lyr2 = $('<div class="blockUI blockOverlay" style="z-index:'+ (z++) +';display:none;border:none;margin:0;padding:0;width:100%;height:100%;top:0;left:0"></div>');
    
    var lyr3;
    if (opts.theme && full) {
        var s = '<div class="blockUI blockMsg blockPage ui-dialog ui-widget ui-corner-all" style="z-index:'+z+';display:none;position:fixed">' +
                    '<div class="ui-widget-header ui-dialog-titlebar blockTitle">'+(opts.title || '&nbsp;')+'</div>' +
                    '<div class="ui-widget-content ui-dialog-content"></div>' +
                '</div>';
        lyr3 = $(s);
    }
    else {
        lyr3 = full ? $('<div class="blockUI blockMsg blockPage" style="z-index:'+z+';display:none;position:fixed"></div>')
                    : $('<div class="blockUI blockMsg blockElement" style="z-index:'+z+';display:none;position:absolute"></div>');
    }                           

    // if we have a message, style it
    if (msg) {
        if (opts.theme) {
            lyr3.css(themedCSS);
            lyr3.addClass('ui-widget-content');
        }
        else 
            lyr3.css(css);
    }

    // style the overlay
    if (!opts.applyPlatformOpacityRules || !($.browser.mozilla && /Linux/.test(navigator.platform)))
        lyr2.css(opts.overlayCSS);
    lyr2.css('position', full ? 'fixed' : 'absolute');

    // make iframe layer transparent in IE
    if ($.browser.msie || opts.forceIframe)
        lyr1.css('opacity',0.0);

    $([lyr1[0],lyr2[0],lyr3[0]]).appendTo(full ? 'body' : el);
    
    if (opts.theme && opts.draggable && $.fn.draggable) {
        lyr3.draggable({
            handle: '.ui-dialog-titlebar',
            cancel: 'li'
        });
    }

    // ie7 must use absolute positioning in quirks mode and to account for activex issues (when scrolling)
    var expr = setExpr && (!$.boxModel || $('object,embed', full ? null : el).length > 0);
    if (ie6 || expr) {
        // give body 100% height
        if (full && opts.allowBodyStretch && $.boxModel)
            $('html,body').css('height','100%');

        // fix ie6 issue when blocked element has a border width
        if ((ie6 || !$.boxModel) && !full) {
            var t = sz(el,'borderTopWidth'), l = sz(el,'borderLeftWidth');
            var fixT = t ? '(0 - '+t+')' : 0;
            var fixL = l ? '(0 - '+l+')' : 0;
        }

        // simulate fixed position
        $.each([lyr1,lyr2,lyr3], function(i,o) {
            var s = o[0].style;
            s.position = 'absolute';
            if (i < 2) {
                full ? s.setExpression('height','Math.max(document.body.scrollHeight, document.body.offsetHeight) - (jQuery.boxModel?0:'+opts.quirksmodeOffsetHack+') + "px"')
                     : s.setExpression('height','this.parentNode.offsetHeight + "px"');
                full ? s.setExpression('width','jQuery.boxModel && document.documentElement.clientWidth || document.body.clientWidth + "px"')
                     : s.setExpression('width','this.parentNode.offsetWidth + "px"');
                if (fixL) s.setExpression('left', fixL);
                if (fixT) s.setExpression('top', fixT);
            }
            else if (opts.centerY) {
                if (full) s.setExpression('top','(document.documentElement.clientHeight || document.body.clientHeight) / 2 - (this.offsetHeight / 2) + (blah = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + "px"');
                s.marginTop = 0;
            }
            else if (!opts.centerY && full) {
                var top = (opts.css && opts.css.top) ? parseInt(opts.css.top) : 0;
                var expression = '((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + '+top+') + "px"';
                s.setExpression('top',expression);
            }
        });
    }

    // show the message
    if (msg) {
        if (opts.theme)
            lyr3.find('.ui-widget-content').append(msg);
        else
            lyr3.append(msg);
        if (msg.jquery || msg.nodeType)
            $(msg).show();
    }

    if (($.browser.msie || opts.forceIframe) && opts.showOverlay)
        lyr1.show(); // opacity is zero
    if (opts.fadeIn) {
        if (opts.showOverlay)
            lyr2._fadeIn(opts.fadeIn);
        if (msg)
            lyr3.fadeIn(opts.fadeIn);
    }
    else {
        if (opts.showOverlay)
            lyr2.show();
        if (msg)
            lyr3.show();
    }

    // bind key and mouse events
    bind(1, el, opts);

    if (full) {
        pageBlock = lyr3[0];
        pageBlockEls = $(':input:enabled:visible',pageBlock);
        if (opts.focusInput)
            setTimeout(focus, 20);
    }
    else
        center(lyr3[0], opts.centerX, opts.centerY);

    if (opts.timeout) {
        // auto-unblock
        var to = setTimeout(function() {
            full ? $.unblockUI(opts) : $(el).unblock(opts);
        }, opts.timeout);
        $(el).data('blockUI.timeout', to);
    }
};

// remove the block
function remove(el, opts) {
    var full = (el == window);
    var $el = $(el);
    var data = $el.data('blockUI.history');
    var to = $el.data('blockUI.timeout');
    if (to) {
        clearTimeout(to);
        $el.removeData('blockUI.timeout');
    }
    opts = $.extend({}, $.blockUI.defaults, opts || {});
    bind(0, el, opts); // unbind events
    
    var els;
    if (full) // crazy selector to handle odd field errors in ie6/7
        els = $('body').children().filter('.blockUI').add('body > .blockUI');
    else
        els = $('.blockUI', el);

    if (full)
        pageBlock = pageBlockEls = null;

    if (opts.fadeOut) {
        els.fadeOut(opts.fadeOut);
        setTimeout(function() { reset(els,data,opts,el); }, opts.fadeOut);
    }
    else
        reset(els, data, opts, el);
};

// move blocking element back into the DOM where it started
function reset(els,data,opts,el) {
    els.each(function(i,o) {
        // remove via DOM calls so we don't lose event handlers
        if (this.parentNode)
            this.parentNode.removeChild(this);
    });

    if (data && data.el) {
        data.el.style.display = data.display;
        data.el.style.position = data.position;
        if (data.parent)
            data.parent.appendChild(data.el);
        $(data.el).removeData('blockUI.history');
    }

    if (typeof opts.onUnblock == 'function')
        opts.onUnblock(el,opts);
};

// bind/unbind the handler
function bind(b, el, opts) {
    var full = el == window, $el = $(el);

    // don't bother unbinding if there is nothing to unbind
    if (!b && (full && !pageBlock || !full && !$el.data('blockUI.isBlocked')))
        return;
    if (!full)
        $el.data('blockUI.isBlocked', b);

    // don't bind events when overlay is not in use or if bindEvents is false
    if (!opts.bindEvents || (b && !opts.showOverlay)) 
        return;

    // bind anchors and inputs for mouse and key events
    var events = 'mousedown mouseup keydown keypress';
    b ? $(document).bind(events, opts, handler) : $(document).unbind(events, handler);

// former impl...
//       var $e = $('a,:input');
//       b ? $e.bind(events, opts, handler) : $e.unbind(events, handler);
};

// event handler to suppress keyboard/mouse events when blocking
function handler(e) {
    // allow tab navigation (conditionally)
    if (e.keyCode && e.keyCode == 9) {
        if (pageBlock && e.data.constrainTabKey) {
            var els = pageBlockEls;
            var fwd = !e.shiftKey && e.target == els[els.length-1];
            var back = e.shiftKey && e.target == els[0];
            if (fwd || back) {
                setTimeout(function(){focus(back)},10);
                return false;
            }
        }
    }
    // allow events within the message content
    if ($(e.target).parents('div.blockMsg').length > 0)
        return true;

    // allow events for content that is not being blocked
    return $(e.target).parents().children().filter('div.blockUI').length == 0;
};

function focus(back) {
    if (!pageBlockEls)
        return;
    var e = pageBlockEls[back===true ? pageBlockEls.length-1 : 0];
    if (e)
        e.focus();
};

function center(el, x, y) {
    var p = el.parentNode, s = el.style;
    var l = ((p.offsetWidth - el.offsetWidth)/2) - sz(p,'borderLeftWidth');
    var t = ((p.offsetHeight - el.offsetHeight)/2) - sz(p,'borderTopWidth');
    if (x) s.left = l > 0 ? (l+'px') : '0';
    if (y) s.top  = t > 0 ? (t+'px') : '0';
};

function sz(el, p) {
    return parseInt($.css(el,p))||0;
};

})(jQuery);

/**
 * Interface Elements for jQuery
 * Expander
 * 
 * http://interface.eyecon.ro
 * 
 * Copyright (c) 2006 Stefan Petre
 * Dual licensed under the MIT (MIT-LICENSE.txt) 
 * and GPL (GPL-LICENSE.txt) licenses.
 *   
 *
 */
 
/**
 * Expands text and textarea elements while new characters are typed to the a miximum width
 *
 * @name Expander
 * @description Expands text and textarea elements while new characters are typed to the a miximum width
 * @param Mixed limit integer if only expands in width, array if expands in width and height
 * @type jQuery
 * @cat Plugins/Interface
 * @author Stefan Petre
 */

jQuery.iExpander =
{
	helper : null,
	expand : function()
	{
		
		text = this.value;
		if (!text || (parseInt(this.style.height)==this.Expander.limit[1]))
			return;
		style = {
			fontFamily: jQuery(this).css('fontFamily')||'',
			fontSize: jQuery(this).css('fontSize')||'',
			fontWeight: jQuery(this).css('fontWeight')||'',
			fontStyle: jQuery(this).css('fontStyle')||'',
			fontStretch: jQuery(this).css('fontStretch')||'',
			fontVariant: jQuery(this).css('fontVariant')||'',
			letterSpacing: jQuery(this).css('letterSpacing')||'',
			wordSpacing: jQuery(this).css('wordSpacing')||''
		};
		jQuery.iExpander.helper.css(style);
		html = jQuery.iExpander.htmlEntities(text);
		html = html.replace(new RegExp( "\\n", "g" ), "<br />");
		jQuery.iExpander.helper.html('pW');
		spacer = jQuery.iExpander.helper.get(0).offsetWidth;
		jQuery.iExpander.helper.html(html);
		width = jQuery.iExpander.helper.get(0).offsetWidth + spacer;
		if (this.Expander.limit && width > this.Expander.limit[0]) {
			width = this.Expander.limit[0];
		}
                if (this.Expander.limit[0]>0) { 
  		   this.style.width = width + 'px';
                }
		if (this.tagName == 'TEXTAREA') {
                    height = jQuery.iExpander.helper.get(0).offsetHeight + spacer;
                    if (this.Expander.h_start<height) {  
			if (this.Expander.limit && height > this.Expander.limit[1]) {
				height = this.Expander.limit[1];
			}
			this.style.height = height + 'px';
                    }
		}
	},
	htmlEntities : function(text)
	{ 
		entities = {
			'&':'&amp;',
			'<':'&lt;',
			'>':'&gt;',
			'"':'&quot;'
		};
		for(i in entities) {
			text = text.replace(new RegExp(i,'g'),entities[i]);
		}
		return text;
	},
	build : function(limit)
	{
		if (jQuery.iExpander.helper == null) {
			jQuery('body', document).append('<div id="expanderHelper" style="position: absolute; top: 0; left: 0; visibility: hidden;"></div>');
			jQuery.iExpander.helper = jQuery('#expanderHelper');
		}
		return this.each(
			function()
			{
				if (/TEXTAREA|INPUT/.test(this.tagName)) {
					if (this.tagName == 'INPUT') {
						elType = this.getAttribute('type');
						if (!/text|password/.test(elType)) {
							return;
						}
					}
                                        h_start=0;
					if (this.tagName == 'TEXTAREA') {
                                           if (this.style.height) { 
                                             h_start=parseInt(this.style.height);
                                           } else {
                                             h_start=200; this.style.height = h_start+'px';
                                           }
                                        }
					if (limit && (limit.constructor == Number || (limit.constructor == Array && limit.length == 2))) {
						if (limit.constructor == Number)
							limit = [limit, limit];
						else {
                                                        if (parseInt(limit[0])==0) {limit[0]=0;} else {limit[0] = parseInt(limit[0])||400;}
							limit[1] = parseInt(limit[1])||400;
						}
						this.Expander = {
							limit : limit,
                                                        h_start : h_start
						};
					}
					jQuery(this)
						.blur(jQuery.iExpander.expand)
						.keyup(jQuery.iExpander.expand)
						.keypress(jQuery.iExpander.expand);
					jQuery.iExpander.expand.apply(this);
				}
			}
		);			
	}
};

jQuery.fn.Autoexpand = jQuery.iExpander.build;
