var Prototype={Version:"1.6.0.2",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div").__proto__&&document.createElement("div").__proto__!==document.createElement("form").__proto__},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(a){return a}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false}var Class={create:function(){var f=null,d=$A(arguments);if(Object.isFunction(d[0])){f=d.shift()}function a(){this.initialize.apply(this,arguments)}Object.extend(a,Class.Methods);a.superclass=f;a.subclasses=[];if(f){var b=function(){};b.prototype=f.prototype;a.prototype=new b;f.subclasses.push(a)}for(var c=0;c<d.length;c++){a.addMethods(d[c])}if(!a.prototype.initialize){a.prototype.initialize=Prototype.emptyFunction}a.prototype.constructor=a;return a}};Class.Methods={addMethods:function(h){var c=this.superclass&&this.superclass.prototype;var b=Object.keys(h);if(!Object.keys({toString:true}).length){b.push("toString","valueOf")}for(var a=0,d=b.length;a<d;a++){var g=b[a],f=h[g];if(c&&Object.isFunction(f)&&f.argumentNames().first()=="$super"){var j=f,f=Object.extend((function(k){return function(){return c[k].apply(this,arguments)}})(g).wrap(j),{valueOf:function(){return j},toString:function(){return j.toString()}})}this.prototype[g]=f}return this}};var Abstract={};Object.extend=function(a,c){for(var b in c){a[b]=c[b]}return a};Object.extend(Object,{inspect:function(a){try{if(Object.isUndefined(a)){return"undefined"}if(a===null){return"null"}return a.inspect?a.inspect():String(a)}catch(b){if(b instanceof RangeError){return"..."}throw b}},toJSON:function(a){var c=typeof a;switch(c){case"undefined":case"function":case"unknown":return;case"boolean":return a.toString()}if(a===null){return"null"}if(a.toJSON){return a.toJSON()}if(Object.isElement(a)){return}var b=[];for(var f in a){var d=Object.toJSON(a[f]);if(!Object.isUndefined(d)){b.push(f.toJSON()+": "+d)}}return"{"+b.join(", ")+"}"},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(a){var b=[];for(var c in a){b.push(c)}return b},values:function(b){var a=[];for(var c in b){a.push(b[c])}return a},clone:function(a){return Object.extend({},a)},isElement:function(a){return a&&a.nodeType==1},isArray:function(a){return a!=null&&typeof a=="object"&&"splice" in a&&"join" in a},isHash:function(a){return a instanceof Hash},isFunction:function(a){return typeof a=="function"},isString:function(a){return typeof a=="string"},isNumber:function(a){return typeof a=="number"},isUndefined:function(a){return typeof a=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var a=this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");return a.length==1&&!a[0]?[]:a},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var a=this,c=$A(arguments),b=c.shift();return function(){return a.apply(b,c.concat($A(arguments)))}},bindAsEventListener:function(){var a=this,c=$A(arguments),b=c.shift();return function(d){return a.apply(b,[d||window.event].concat(c))}},curry:function(){if(!arguments.length){return this}var a=this,b=$A(arguments);return function(){return a.apply(this,b.concat($A(arguments)))}},delay:function(){var a=this,b=$A(arguments),c=b.shift()*1000;return window.setTimeout(function(){return a.apply(a,b)},c)},wrap:function(b){var a=this;return function(){return b.apply(this,[a.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized){return this._methodized}var a=this;return this._methodized=function(){return a.apply(null,[this].concat($A(arguments)))}}});Function.prototype.defer=Function.prototype.delay.curry(0.01);Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var c;for(var b=0,d=arguments.length;b<d;b++){var a=arguments[b];try{c=a();break}catch(f){}}return c}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1")};var PeriodicalExecuter=Class.create({initialize:function(b,a){this.callback=b;this.frequency=a;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer){return}clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(a){return a==null?"":String(a)},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(f,c){var a="",d=this,b;c=arguments.callee.prepareReplacement(c);while(d.length>0){if(b=d.match(f)){a+=d.slice(0,b.index);a+=String.interpret(c(b));d=d.slice(b.index+b[0].length)}else{a+=d,d=""}}return a},sub:function(c,a,b){a=this.gsub.prepareReplacement(a);b=Object.isUndefined(b)?1:b;return this.gsub(c,function(d){if(--b<0){return d[0]}return a(d)})},scan:function(b,a){this.gsub(b,a);return String(this)},truncate:function(b,a){b=b||30;a=Object.isUndefined(a)?"...":a;return this.length>b?this.slice(0,b-a.length)+a:String(this)},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"")},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,"img");var a=new RegExp(Prototype.ScriptFragment,"im");return(this.match(b)||[]).map(function(c){return(c.match(a)||["",""])[1]})},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var a=new Element("div");a.innerHTML=this.stripTags();return a.childNodes[0]?(a.childNodes.length>1?$A(a.childNodes).inject("",function(b,c){return b+c.nodeValue}):a.childNodes[0].nodeValue):""},toQueryParams:function(b){var a=this.strip().match(/([^?#]*)(#.*)?$/);if(!a){return{}}return a[1].split(b||"&").inject({},function(f,g){if((g=g.split("="))[0]){var c=decodeURIComponent(g.shift());var d=g.length>1?g.join("="):g[0];if(d!=undefined){d=decodeURIComponent(d)}if(c in f){if(!Object.isArray(f[c])){f[c]=[f[c]]}f[c].push(d)}else{f[c]=d}}return f})},toArray:function(){return this.split("")},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?"":new Array(a+1).join(this)},camelize:function(){var d=this.split("-"),a=d.length;if(a==1){return d[0]}var c=this.charAt(0)=="-"?d[0].charAt(0).toUpperCase()+d[0].substring(1):d[0];for(var b=1;b<a;b++){c+=d[b].charAt(0).toUpperCase()+d[b].substring(1)}return c},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase()},dasherize:function(){return this.gsub(/_/,"-")},inspect:function(b){var a=this.gsub(/[\x00-\x1f\\]/,function(c){var d=String.specialChar[c[0]];return d?d:"\\u00"+c[0].charCodeAt().toPaddedString(2,16)});if(b){return'"'+a.replace(/"/g,'\\"')+'"'}return"'"+a.replace(/'/g,"\\'")+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,"#{1}")},isJSON:function(){var a=this;if(a.blank()){return false}a=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(a)},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var b=this.length-a.length;return b>=0&&this.lastIndexOf(a)===b},empty:function(){return this==""},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},unescapeHTML:function(){return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">")}})}String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b)){return b}var a=new Template(b);return function(c){return a.evaluate(c)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});with(String.prototype.escapeHTML){div.appendChild(text)}var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){if(Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(d){if(a==null){return""}var g=d[1]||"";if(g=="\\"){return d[2]}var b=a,h=d[3];var f=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;d=f.exec(h);if(d==null){return g}while(d!=null){var c=d[1].startsWith("[")?d[2].gsub("\\\\]","]"):d[1];b=b[c];if(null==b||""==d[3]){break}h=h.substring("["==d[3]?d[1].length:d[0].length);d=f.exec(h)}return g+String.interpret(b)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(c,b){var a=0;c=c.bind(b);try{this._each(function(f){c(f,a++)})}catch(d){if(d!=$break){throw d}}return this},eachSlice:function(d,c,b){c=c?c.bind(b):Prototype.K;var a=-d,f=[],g=this.toArray();while((a+=d)<g.length){f.push(g.slice(a,a+d))}return f.collect(c,b)},all:function(c,b){c=c?c.bind(b):Prototype.K;var a=true;this.each(function(f,d){a=a&&!!c(f,d);if(!a){throw $break}});return a},any:function(c,b){c=c?c.bind(b):Prototype.K;var a=false;this.each(function(f,d){if(a=!!c(f,d)){throw $break}});return a},collect:function(c,b){c=c?c.bind(b):Prototype.K;var a=[];this.each(function(f,d){a.push(c(f,d))});return a},detect:function(c,b){c=c.bind(b);var a;this.each(function(f,d){if(c(f,d)){a=f;throw $break}});return a},findAll:function(c,b){c=c.bind(b);var a=[];this.each(function(f,d){if(c(f,d)){a.push(f)}});return a},grep:function(d,c,b){c=c?c.bind(b):Prototype.K;var a=[];if(Object.isString(d)){d=new RegExp(d)}this.each(function(g,f){if(d.match(g)){a.push(c(g,f))}});return a},include:function(a){if(Object.isFunction(this.indexOf)){if(this.indexOf(a)!=-1){return true}}var b=false;this.each(function(c){if(c==a){b=true;throw $break}});return b},inGroupsOf:function(b,a){a=Object.isUndefined(a)?null:a;return this.eachSlice(b,function(c){while(c.length<b){c.push(a)}return c})},inject:function(a,c,b){c=c.bind(b);this.each(function(f,d){a=c(a,f,d)});return a},invoke:function(b){var a=$A(arguments).slice(1);return this.map(function(c){return c[b].apply(c,a)})},max:function(c,b){c=c?c.bind(b):Prototype.K;var a;this.each(function(f,d){f=c(f,d);if(a==null||f>=a){a=f}});return a},min:function(c,b){c=c?c.bind(b):Prototype.K;var a;this.each(function(f,d){f=c(f,d);if(a==null||f<a){a=f}});return a},partition:function(d,b){d=d?d.bind(b):Prototype.K;var c=[],a=[];this.each(function(g,f){(d(g,f)?c:a).push(g)});return[c,a]},pluck:function(b){var a=[];this.each(function(c){a.push(c[b])});return a},reject:function(c,b){c=c.bind(b);var a=[];this.each(function(f,d){if(!c(f,d)){a.push(f)}});return a},sortBy:function(b,a){b=b.bind(a);return this.map(function(d,c){return{value:d,criteria:b(d,c)}}).sort(function(g,f){var d=g.criteria,c=f.criteria;return d<c?-1:d>c?1:0}).pluck("value")},toArray:function(){return this.map()},zip:function(){var b=Prototype.K,a=$A(arguments);if(Object.isFunction(a.last())){b=a.pop()}var c=[this].concat(a).map($A);return this.map(function(f,d){return b(c.pluck(d))})},size:function(){return this.toArray().length},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">"}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(c){if(!c){return[]}if(c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}if(Prototype.Browser.WebKit){$A=function(c){if(!c){return[]}if(!(Object.isFunction(c)&&c=="[object NodeList]")&&c.toArray){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse}Object.extend(Array.prototype,{_each:function(b){for(var a=0,c=this.length;a<c;a++){b(this[a])}},clear:function(){this.length=0;return this},first:function(){return this[0]},last:function(){return this[this.length-1]},compact:function(){return this.select(function(a){return a!=null})},flatten:function(){return this.inject([],function(b,a){return b.concat(Object.isArray(a)?a.flatten():[a])})},without:function(){var a=$A(arguments);return this.select(function(b){return !a.include(b)})},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(a){return this.inject([],function(d,c,b){if(0==b||(a?d.last()!=c:!d.include(c))){d.push(c)}return d})},intersect:function(a){return this.uniq().findAll(function(b){return a.detect(function(c){return b===c})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]"},toJSON:function(){var a=[];this.each(function(b){var c=Object.toJSON(b);if(!Object.isUndefined(c)){a.push(c)}});return"["+a.join(", ")+"]"}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(c,a){a||(a=0);var b=this.length;if(a<0){a=b+a}for(;a<b;a++){if(this[a]===c){return a}}return -1}}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(b,a){a=isNaN(a)?this.length:(a<0?this.length+a:a)+1;var c=this.slice(0,a).reverse().indexOf(b);return(c<0)?c:a-c-1}}Array.prototype.toArray=Array.prototype.clone;function $w(a){if(!Object.isString(a)){return[]}a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var f=[];for(var b=0,c=this.length;b<c;b++){f.push(this[b])}for(var b=0,c=arguments.length;b<c;b++){if(Object.isArray(arguments[b])){for(var a=0,d=arguments[b].length;a<d;a++){f.push(arguments[b][a])}}else{f.push(arguments[b])}}return f}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(a){$R(0,this,true).each(a);return this},toPaddedString:function(c,b){var a=this.toString(b||10);return"0".times(c-a.length)+a},toJSON:function(){return isFinite(this)?this.toString():"null"}});$w("abs round ceil floor").each(function(a){Number.prototype[a]=Math[a].methodize()});function $H(a){return new Hash(a)}var Hash=Class.create(Enumerable,(function(){function a(b,c){if(Object.isUndefined(c)){return b}return b+"="+encodeURIComponent(String.interpret(c))}return{initialize:function(b){this._object=Object.isHash(b)?b.toObject():Object.clone(b)},_each:function(c){for(var b in this._object){var d=this._object[b],f=[b,d];f.key=b;f.value=d;c(f)}},set:function(b,c){return this._object[b]=c},get:function(b){return this._object[b]},unset:function(b){var c=this._object[b];delete this._object[b];return c},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck("key")},values:function(){return this.pluck("value")},index:function(c){var b=this.detect(function(d){return d.value===c});return b&&b.key},merge:function(b){return this.clone().update(b)},update:function(b){return new Hash(b).inject(this,function(c,d){c.set(d.key,d.value);return c})},toQueryString:function(){return this.map(function(d){var c=encodeURIComponent(d.key),b=d.value;if(b&&typeof b=="object"){if(Object.isArray(b)){return b.map(a.curry(c)).join("&")}}return a(c,b)}).join("&")},inspect:function(){return"#<Hash:{"+this.map(function(b){return b.map(Object.inspect).join(": ")}).join(", ")+"}>"},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(c,a,b){this.start=c;this.end=a;this.exclusive=b},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start){return false}if(this.exclusive){return a<this.end}return a<=this.end}});var $R=function(c,a,b){return new ObjectRange(c,a,b)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a)){this.responders.push(a)}},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(d,b,c,a){this.each(function(f){if(Object.isFunction(f[d])){f[d].apply(f,[b,c,a])}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(a){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams()}else{if(Object.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,b,a){$super(a);this.transport=Ajax.getTransport();this.request(b)},request:function(b){this.url=b;this.method=this.options.method;var c=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){c._method=this.method;this.method="post"}this.parameters=c;if(c=Object.toQueryString(c)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+c}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){c+="&_="}}}var a=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(a)}Ajax.Responders.dispatch("onCreate",this,a);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1)}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||c):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange()}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete)){this.respondToReadyState(this.transport.readyState)}},setRequestHeaders:function(){var f={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,Accept:"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){f["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){f.Connection="close"}}if(typeof this.options.requestHeaders=="object"){var c=this.options.requestHeaders;if(Object.isFunction(c.push)){for(var b=0,d=c.length;b<d;b+=2){f[c[b]]=c[b+1]}}else{$H(c).each(function(g){f[g.key]=g.value})}}for(var a in f){this.transport.setRequestHeader(a,f[a])}},success:function(){var a=this.getStatus();return !a||(a>=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(a){return 0}},respondToReadyState:function(a){var c=Ajax.Request.Events[a],b=new Ajax.Response(this);if(c=="Complete"){try{this._complete=true;(this.options["on"+b.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(b,b.headerJSON)}catch(d){this.dispatchException(d)}var f=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&f&&f.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse()}}try{(this.options["on"+c]||Prototype.emptyFunction)(b,b.headerJSON);Ajax.Responders.dispatch("on"+c,this,b,b.headerJSON)}catch(d){this.dispatchException(d)}if(c=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var a=this.url.match(/^\s*https?:\/\/[^\/]*/);return !a||(a[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}catch(b){return null}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch("onException",this,a)}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(c){this.request=c;var d=this.transport=c.transport,a=this.readyState=d.readyState;if((a>2&&!Prototype.Browser.IE)||a==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(d.responseText);this.headerJSON=this._getHeaderJSON()}if(a==4){var b=d.responseXML;this.responseXML=Object.isUndefined(b)?null:b;this.responseJSON=this._getResponseJSON()}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||""}catch(a){return""}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(a){return null}},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var a=this.getHeader("X-JSON");if(!a){return null}a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(b){this.request.dispatchException(b)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,a,c,b){this.container={success:(a.success||a),failure:(a.failure||(a.success?null:a))};b=Object.clone(b);var d=b.onComplete;b.onComplete=(function(f,g){this.updateContent(f.responseText);if(Object.isFunction(d)){d(f,g)}}).bind(this);$super(c,b)},updateContent:function(d){var c=this.container[this.success()?"success":"failure"],a=this.options;if(!a.evalScripts){d=d.stripScripts()}if(c=$(c)){if(a.insertion){if(Object.isString(a.insertion)){var b={};b[a.insertion]=d;c.insert(b)}else{a.insertion(c,d)}}else{c.update(d)}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,a,c,b){$super(b);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=c;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(b){if(arguments.length>1){for(var a=0,d=[],c=arguments.length;a<c;a++){d.push($(arguments[a]))}return d}if(Object.isString(b)){b=document.getElementById(b)}return Element.extend(b)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(g,a){var c=[];var f=document.evaluate(g,$(a)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var b=0,d=f.snapshotLength;b<d;b++){c.push(Element.extend(f.snapshotItem(b)))}return c}}if(!window.Node){var Node={}}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var a=this.Element;this.Element=function(d,c){c=c||{};d=d.toLowerCase();var b=Element.cache;if(Prototype.Browser.IE&&c.name){d="<"+d+' name="'+c.name+'">';delete c.name;return Element.writeAttribute(document.createElement(d),c)}if(!b[d]){b[d]=Element.extend(document.createElement(d))}return Element.writeAttribute(b[d].cloneNode(false),c)};Object.extend(this.Element,a||{})}).call(window);Element.cache={};Element.Methods={visible:function(a){return $(a).style.display!="none"},toggle:function(a){a=$(a);Element[Element.visible(a)?"hide":"show"](a);return a},hide:function(a){$(a).style.display="none";return a},show:function(a){$(a).style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){a=$(a);if(b&&b.toElement){b=b.toElement()}if(Object.isElement(b)){return a.update().insert(b)}b=Object.toHTML(b);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}else{if(!Object.isElement(c)){c=Object.toHTML(c);var a=b.ownerDocument.createRange();a.selectNode(b);c.evalScripts.bind(c).defer();c=a.createContextualFragment(c.stripScripts())}}b.parentNode.replaceChild(c,b);return b},insert:function(c,f){c=$(c);if(Object.isString(f)||Object.isNumber(f)||Object.isElement(f)||(f&&(f.toElement||f.toHTML))){f={bottom:f}}var d,g,b,h;for(var a in f){d=f[a];a=a.toLowerCase();g=Element._insertionTranslations[a];if(d&&d.toElement){d=d.toElement()}if(Object.isElement(d)){g(c,d);continue}d=Object.toHTML(d);b=((a=="before"||a=="after")?c.parentNode:c).tagName.toUpperCase();h=Element._getContentFromAnonymousElement(b,d.stripScripts());if(a=="top"||a=="after"){h.reverse()}h.each(g.curry(c));d.evalScripts.bind(d).defer()}return c},wrap:function(b,c,a){b=$(b);if(Object.isElement(c)){$(c).writeAttribute(a||{})}else{if(Object.isString(c)){c=new Element(c,a)}else{c=new Element("div",c)}}if(b.parentNode){b.parentNode.replaceChild(c,b)}c.appendChild(b);return c},inspect:function(b){b=$(b);var a="<"+b.tagName.toLowerCase();$H({id:"id",className:"class"}).each(function(g){var f=g.first(),c=g.last();var d=(b[f]||"").toString();if(d){a+=" "+c+"="+d.inspect(true)}});return a+">"},recursivelyCollect:function(a,c){a=$(a);var b=[];while(a=a[c]){if(a.nodeType==1){b.push(Element.extend(a))}}return b},ancestors:function(a){return $(a).recursivelyCollect("parentNode")},descendants:function(a){return $(a).select("*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1){a=a.nextSibling}return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild)){return[]}while(a&&a.nodeType!=1){a=a.nextSibling}if(a){return[a].concat($(a).nextSiblings())}return[]},previousSiblings:function(a){return $(a).recursivelyCollect("previousSibling")},nextSiblings:function(a){return $(a).recursivelyCollect("nextSibling")},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(b,a){if(Object.isString(a)){a=new Selector(a)}return a.match($(b))},up:function(b,d,a){b=$(b);if(arguments.length==1){return $(b.parentNode)}var c=b.ancestors();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},down:function(b,c,a){b=$(b);if(arguments.length==1){return b.firstDescendant()}return Object.isNumber(c)?b.descendants()[c]:b.select(c)[a||0]},previous:function(b,d,a){b=$(b);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(b))}var c=b.previousSiblings();return Object.isNumber(d)?c[d]:Selector.findElement(c,d,a)},next:function(c,d,b){c=$(c);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(c))}var a=c.nextSiblings();return Object.isNumber(d)?a[d]:Selector.findElement(a,d,b)},select:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b,a)},adjacent:function(){var a=$A(arguments),b=$(a.shift());return Selector.findChildElements(b.parentNode,a).without(b)},identify:function(b){b=$(b);var c=b.readAttribute("id"),a=arguments.callee;if(c){return c}do{c="anonymous_element_"+a.counter++}while($(c));b.writeAttribute("id",c);return c},readAttribute:function(c,a){c=$(c);if(Prototype.Browser.IE){var b=Element._attributeTranslations.read;if(b.values[a]){return b.values[a](c,a)}if(b.names[a]){a=b.names[a]}if(a.include(":")){return(!c.attributes||!c.attributes[a])?null:c.attributes[a].value}}return c.getAttribute(a)},writeAttribute:function(f,c,g){f=$(f);var b={},d=Element._attributeTranslations.write;if(typeof c=="object"){b=c}else{b[c]=Object.isUndefined(g)?true:g}for(var a in b){c=d.names[a]||a;g=b[a];if(d.values[a]){c=d.values[a](f,g)}if(g===false||g===null){f.removeAttribute(c)}else{if(g===true){f.setAttribute(c,c)}else{f.setAttribute(c,g)}}}return f},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a))){return}var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a))){return}if(!a.hasClassName(b)){a.className+=(a.className?" ":"")+b}return a},removeClassName:function(a,b){if(!(a=$(a))){return}a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)")," ").strip();return a},toggleClassName:function(a,b){if(!(a=$(a))){return}return a[a.hasClassName(b)?"removeClassName":"addClassName"](b)},cleanWhitespace:function(b){b=$(b);var c=b.firstChild;while(c){var a=c.nextSibling;if(c.nodeType==3&&!/\S/.test(c.nodeValue)){b.removeChild(c)}c=a}return b},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(f,d){f=$(f),d=$(d);var h=d;if(f.compareDocumentPosition){return(f.compareDocumentPosition(d)&8)===8}if(f.sourceIndex&&!Prototype.Browser.Opera){var g=f.sourceIndex,c=d.sourceIndex,b=d.nextSibling;if(!b){do{d=d.parentNode}while(!(b=d.nextSibling)&&d.parentNode)}if(b&&b.sourceIndex){return(g>c&&g<b.sourceIndex)}}while(f=f.parentNode){if(f==h){return true}}return false},scrollTo:function(a){a=$(a);var b=a.cumulativeOffset();window.scrollTo(b[0],b[1]);return a},getStyle:function(b,c){b=$(b);c=c=="float"?"cssFloat":c.camelize();var d=b.style[c];if(!d){var a=document.defaultView.getComputedStyle(b,null);d=a?a[c]:null}if(c=="opacity"){return d?parseFloat(d):1}return d=="auto"?null:d},getOpacity:function(a){return $(a).getStyle("opacity")},setStyle:function(b,c){b=$(b);var f=b.style,a;if(Object.isString(c)){b.style.cssText+=";"+c;return c.include("opacity")?b.setOpacity(c.match(/opacity:\s*(\d?\.?\d*)/)[1]):b}for(var d in c){if(d=="opacity"){b.setOpacity(c[d])}else{f[(d=="float"||d=="cssFloat")?(Object.isUndefined(f.styleFloat)?"cssFloat":"styleFloat"):d]=c[d]}}return b},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;return a},getDimensions:function(c){c=$(c);var h=$(c).getStyle("display");if(h!="none"&&h!=null){return{width:c.offsetWidth,height:c.offsetHeight}}var b=c.style;var g=b.visibility;var d=b.position;var a=b.display;b.visibility="hidden";b.position="absolute";b.display="block";var j=c.clientWidth;var f=c.clientHeight;b.display=a;b.position=d;b.visibility=g;return{width:j,height:f}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(window.opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=""}return a},makeClipping:function(a){a=$(a);if(a._overflow){return a}a._overflow=Element.getStyle(a,"overflow")||"auto";if(a._overflow!=="hidden"){a.style.overflow="hidden"}return a},undoClipping:function(a){a=$(a);if(!a._overflow){return a}a.style.overflow=a._overflow=="auto"?"":a._overflow;a._overflow=null;return a},cumulativeOffset:function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;b=b.offsetParent}while(b);return Element._returnOffset(c,a)},positionedOffset:function(b){var a=0,d=0;do{a+=b.offsetTop||0;d+=b.offsetLeft||0;b=b.offsetParent;if(b){if(b.tagName=="BODY"){break}var c=Element.getStyle(b,"position");if(c!=="static"){break}}}while(b);return Element._returnOffset(d,a)},absolutize:function(b){b=$(b);if(b.getStyle("position")=="absolute"){return}var d=b.positionedOffset();var g=d[1];var f=d[0];var c=b.clientWidth;var a=b.clientHeight;b._originalLeft=f-parseFloat(b.style.left||0);b._originalTop=g-parseFloat(b.style.top||0);b._originalWidth=b.style.width;b._originalHeight=b.style.height;b.style.position="absolute";b.style.top=g+"px";b.style.left=f+"px";b.style.width=c+"px";b.style.height=a+"px";return b},relativize:function(a){a=$(a);if(a.getStyle("position")=="relative"){return}a.style.position="relative";var c=parseFloat(a.style.top||0)-(a._originalTop||0);var b=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=c+"px";a.style.left=b+"px";a.style.height=a._originalHeight;a.style.width=a._originalWidth;return a},cumulativeScrollOffset:function(b){var a=0,c=0;do{a+=b.scrollTop||0;c+=b.scrollLeft||0;b=b.parentNode}while(b);return Element._returnOffset(c,a)},getOffsetParent:function(a){if(a.offsetParent){return $(a.offsetParent)}if(a==document.body){return $(a)}while((a=a.parentNode)&&a!=document.body){if(Element.getStyle(a,"position")!="static"){return $(a)}}return $(document.body)},viewportOffset:function(d){var a=0,c=0;var b=d;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body&&Element.getStyle(b,"position")=="absolute"){break}}while(b=b.offsetParent);b=d;do{if(!Prototype.Browser.Opera||b.tagName=="BODY"){a-=b.scrollTop||0;c-=b.scrollLeft||0}}while(b=b.parentNode);return Element._returnOffset(c,a)},clonePosition:function(b,d){var a=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});d=$(d);var f=d.viewportOffset();b=$(b);var g=[0,0];var c=null;if(Element.getStyle(b,"position")=="absolute"){c=b.getOffsetParent();g=c.viewportOffset()}if(c==document.body){g[0]-=document.body.offsetLeft;g[1]-=document.body.offsetTop}if(a.setLeft){b.style.left=(f[0]-g[0]+a.offsetLeft)+"px"}if(a.setTop){b.style.top=(f[1]-g[1]+a.offsetTop)+"px"}if(a.setWidth){b.style.width=d.offsetWidth+"px"}if(a.setHeight){b.style.height=d.offsetHeight+"px"}return b}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(d,b,c){switch(c){case"left":case"top":case"right":case"bottom":if(d(b,"position")==="static"){return null}case"height":case"width":if(!Element.visible(b)){return null}var f=parseInt(d(b,c),10);if(f!==b["offset"+c.capitalize()]){return f+"px"}var a;if(c==="height"){a=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{a=["border-left-width","padding-left","padding-right","border-right-width"]}return a.inject(f,function(g,h){var j=d(b,h);return j===null?g:g-parseInt(j,10)})+"px";default:return d(b,c)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(c,a,b){if(b==="title"){return a.title}return c(a,b)})}else{if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(c,b){b=$(b);var a=b.getStyle("position");if(a!=="static"){return c(b)}b.setStyle({position:"relative"});var d=c(b);b.setStyle({position:a});return d});$w("positionedOffset viewportOffset").each(function(a){Element.Methods[a]=Element.Methods[a].wrap(function(f,c){c=$(c);var b=c.getStyle("position");if(b!=="static"){return f(c)}var d=c.getOffsetParent();if(d&&d.getStyle("position")==="fixed"){d.setStyle({zoom:1})}c.setStyle({position:"relative"});var g=f(c);c.setStyle({position:b});return g})});Element.Methods.getStyle=function(a,b){a=$(a);b=(b=="float"||b=="cssFloat")?"styleFloat":b.camelize();var c=a.style[b];if(!c&&a.currentStyle){c=a.currentStyle[b]}if(b=="opacity"){if(c=(a.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(c[1]){return parseFloat(c[1])/100}}return 1}if(c=="auto"){if((b=="width"||b=="height")&&(a.getStyle("display")!="none")){return a["offset"+b.capitalize()]+"px"}return null}return c};Element.Methods.setOpacity=function(b,f){function g(h){return h.replace(/alpha\([^\)]*\)/gi,"")}b=$(b);var a=b.currentStyle;if((a&&!a.hasLayout)||(!a&&b.style.zoom=="normal")){b.style.zoom=1}var d=b.getStyle("filter"),c=b.style;if(f==1||f===""){(d=g(d))?c.filter=d:c.removeAttribute("filter");return b}else{if(f<0.00001){f=0}}c.filter=g(d)+"alpha(opacity="+(f*100)+")";return b};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_getAttrNode:function(a,c){var b=a.getAttributeNode(c);return b?b.value:""},_getEv:function(a,b){b=a.getAttribute(b);return b?b.toString().slice(23,-2):null},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){return a.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},Element._attributeTranslations.read.names),values:{checked:function(a,b){a.checked=!!b},style:function(a,b){a.style.cssText=b?b:""}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc").each(function(a){Element._attributeTranslations.write.names[a.toLowerCase()]=a;Element._attributeTranslations.has[a.toLowerCase()]=a});(function(a){Object.extend(a,{href:a._getAttr,src:a._getAttr,type:a._getAttr,action:a._getAttrNode,disabled:a._flag,checked:a._flag,readonly:a._flag,multiple:a._flag,onload:a._getEv,onunload:a._getEv,onclick:a._getEv,ondblclick:a._getEv,onmousedown:a._getEv,onmouseup:a._getEv,onmouseover:a._getEv,onmousemove:a._getEv,onmouseout:a._getEv,onfocus:a._getEv,onblur:a._getEv,onkeypress:a._getEv,onkeydown:a._getEv,onkeyup:a._getEv,onsubmit:a._getEv,onreset:a._getEv,onselect:a._getEv,onchange:a._getEv})})(Element._attributeTranslations.read.values)}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==="")?"":(b<0.00001)?0:b;return a}}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1||b==="")?"":(b<0.00001)?0:b;if(b==1){if(a.tagName=="IMG"&&a.width){a.width++;a.width--}else{try{var d=document.createTextNode(" ");a.appendChild(d);a.removeChild(d)}catch(c){}}}return a};Element.Methods.cumulativeOffset=function(b){var a=0,c=0;do{a+=b.offsetTop||0;c+=b.offsetLeft||0;if(b.offsetParent==document.body){if(Element.getStyle(b,"position")=="absolute"){break}}b=b.offsetParent}while(b);return Element._returnOffset(c,a)}}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(b,c){b=$(b);if(c&&c.toElement){c=c.toElement()}if(Object.isElement(c)){return b.update().insert(c)}c=Object.toHTML(c);var a=b.tagName.toUpperCase();if(a in Element._insertionTranslations.tags){$A(b.childNodes).each(function(d){b.removeChild(d)});Element._getContentFromAnonymousElement(a,c.stripScripts()).each(function(d){b.appendChild(d)})}else{b.innerHTML=c.stripScripts()}c.evalScripts.bind(c).defer();return b}}if("outerHTML" in document.createElement("div")){Element.Methods.replace=function(c,f){c=$(c);if(f&&f.toElement){f=f.toElement()}if(Object.isElement(f)){c.parentNode.replaceChild(f,c);return c}f=Object.toHTML(f);var d=c.parentNode,b=d.tagName.toUpperCase();if(Element._insertionTranslations.tags[b]){var g=c.next();var a=Element._getContentFromAnonymousElement(b,f.stripScripts());d.removeChild(c);if(g){a.each(function(h){d.insertBefore(h,g)})}else{a.each(function(h){d.appendChild(h)})}}else{c.outerHTML=f.stripScripts()}f.evalScripts.bind(f).defer();return c}}Element._returnOffset=function(b,c){var a=[b,c];a.left=b;a.top=c;return a};Element._getContentFromAnonymousElement=function(c,b){var d=new Element("div"),a=Element._insertionTranslations.tags[c];if(a){d.innerHTML=a[0]+b+a[1];a[2].times(function(){d=d.firstChild})}else{d.innerHTML=b}return $A(d.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.nextSibling)},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(a,c){c=Element._attributeTranslations.has[c]||c;var b=$(a).getAttributeNode(c);return b&&b.specified}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div").__proto__;Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K}var a={},b=Element.Methods.ByTag;var c=Object.extend(function(g){if(!g||g._extendedByPrototype||g.nodeType!=1||g==window){return g}var d=Object.clone(a),f=g.tagName,j,h;if(b[f]){Object.extend(d,b[f])}for(j in d){h=d[j];if(Object.isFunction(h)&&!(j in g)){g[j]=h.methodize()}}g._extendedByPrototype=Prototype.emptyFunction;return g},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(a,Element.Methods);Object.extend(a,Element.Methods.Simulated)}}});c.refresh();return c})();Element.hasAttribute=function(a,b){if(a.hasAttribute){return a.hasAttribute(b)}return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(c){var j=Prototype.BrowserFeatures,d=Element.Methods.ByTag;if(!c){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{FORM:Object.clone(Form.Methods),INPUT:Object.clone(Form.Element.Methods),SELECT:Object.clone(Form.Element.Methods),TEXTAREA:Object.clone(Form.Element.Methods)})}if(arguments.length==2){var b=c;c=arguments[1]}if(!b){Object.extend(Element.Methods,c||{})}else{if(Object.isArray(b)){b.each(h)}else{h(b)}}function h(l){l=l.toUpperCase();if(!Element.Methods.ByTag[l]){Element.Methods.ByTag[l]={}}Object.extend(Element.Methods.ByTag[l],c)}function a(o,n,l){l=l||false;for(var r in o){var p=o[r];if(!Object.isFunction(p)){continue}if(!l||!(r in n)){n[r]=p.methodize()}}}function f(o){var l;var n={OPTGROUP:"OptGroup",TEXTAREA:"TextArea",P:"Paragraph",FIELDSET:"FieldSet",UL:"UList",OL:"OList",DL:"DList",DIR:"Directory",H1:"Heading",H2:"Heading",H3:"Heading",H4:"Heading",H5:"Heading",H6:"Heading",Q:"Quote",INS:"Mod",DEL:"Mod",A:"Anchor",IMG:"Image",CAPTION:"TableCaption",COL:"TableCol",COLGROUP:"TableCol",THEAD:"TableSection",TFOOT:"TableSection",TBODY:"TableSection",TR:"TableRow",TH:"TableCell",TD:"TableCell",FRAMESET:"FrameSet",IFRAME:"IFrame"};if(n[o]){l="HTML"+n[o]+"Element"}if(window[l]){return window[l]}l="HTML"+o+"Element";if(window[l]){return window[l]}l="HTML"+o.capitalize()+"Element";if(window[l]){return window[l]}window[l]={};window[l].prototype=document.createElement(o).__proto__;return window[l]}if(j.ElementExtensions){a(Element.Methods,HTMLElement.prototype);a(Element.Methods.Simulated,HTMLElement.prototype,true)}if(j.SpecificElementExtensions){for(var k in Element.Methods.ByTag){var g=f(k);if(Object.isUndefined(g)){continue}a(d[k],g.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){var a={};var b=Prototype.Browser;$w("width height").each(function(f){var c=f.capitalize();a[f]=(b.WebKit&&!document.evaluate)?self["inner"+c]:(b.Opera)?document.body["client"+c]:document.documentElement["client"+c]});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(a){this.expression=a.strip();this.compileMatcher()},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath){return false}var a=this.expression;if(Prototype.Browser.WebKit&&(a.include("-of-type")||a.include(":empty"))){return false}if((/(\[[\w-]*?:|:checked)/).test(this.expression)){return false}return true},compileMatcher:function(){if(this.shouldUseXPath()){return this.compileXPathMatcher()}var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var f=this.expression,g=Selector.patterns,b=Selector.xpath,d,a;if(Selector._cache[f]){this.xpath=Selector._cache[f];return}this.matcher=[".//*"];while(f&&d!=f&&(/\S/).test(f)){d=f;for(var c in g){if(a=f.match(g[c])){this.matcher.push(Object.isFunction(b[c])?b[c](a):new Template(b[c]).evaluate(a));f=f.replace(a[0],"");break}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath},findElements:function(a){a=a||document;if(this.xpath){return document._getElementsByXPath(this.xpath,a)}return this.matcher(a)},match:function(j){this.tokens=[];var o=this.expression,a=Selector.patterns,f=Selector.assertions;var b,d,g;while(o&&b!==o&&(/\S/).test(o)){b=o;for(var k in a){d=a[k];if(g=o.match(d)){if(f[k]){this.tokens.push([k,Object.clone(g)]);o=o.replace(g[0],"")}else{return this.findElements(document).include(j)}}}}var n=true,c,l;for(var k=0,h;h=this.tokens[k];k++){c=h[0],l=h[1];if(!Selector.assertions[c](j,l)){n=false;break}}return n},toString:function(){return this.expression},inspect:function(){return"#<Selector:"+this.expression.inspect()+">"}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(a){if(a[1]=="*"){return""}return"[local-name()='"+a[1].toLowerCase()+"' or local-name()='"+a[1].toUpperCase()+"']"},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:function(a){a[1]=a[1].toLowerCase();return new Template("[@#{1}]").evaluate(a)},attr:function(a){a[1]=a[1].toLowerCase();a[3]=a[5]||a[6];return new Template(Selector.xpath.operators[a[2]]).evaluate(a)},pseudo:function(a){var b=Selector.xpath.pseudos[a[1]];if(!b){return""}if(Object.isFunction(b)){return b(a)}return new Template(Selector.xpath.pseudos[a[1]]).evaluate(a)},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]",empty:"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]",checked:"[@checked]",disabled:"[@disabled]",enabled:"[not(@disabled)]",not:function(b){var j=b[6],h=Selector.patterns,a=Selector.xpath,f,c;var g=[];while(j&&f!=j&&(/\S/).test(j)){f=j;for(var d in h){if(b=j.match(h[d])){c=Object.isFunction(a[d])?a[d](b):new Template(a[d]).evaluate(b);g.push("("+c.substring(1,c.length-1)+")");j=j.replace(b[0],"");break}}}return"[not("+g.join(" and ")+")]"},"nth-child":function(a){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",a)},"nth-last-child":function(a){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",a)},"nth-of-type":function(a){return Selector.xpath.pseudos.nth("position() ",a)},"nth-last-of-type":function(a){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",a)},"first-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-of-type"](a)},"last-of-type":function(a){a[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](a)},"only-of-type":function(a){var b=Selector.xpath.pseudos;return b["first-of-type"](a)+b["last-of-type"](a)},nth:function(h,f){var j,k=f[6],d;if(k=="even"){k="2n+0"}if(k=="odd"){k="2n+1"}if(j=k.match(/^(\d+)$/)){return"["+h+"= "+j[1]+"]"}if(j=k.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(j[1]=="-"){j[1]=-1}var g=j[1]?Number(j[1]):1;var c=j[2]?Number(j[2]):0;d="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(d).evaluate({fragment:h,a:g,b:c})}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);      c = false;',className:'n = h.className(n, r, "#{1}", c);    c = false;',id:'n = h.id(n, r, "#{1}", c);           c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}", c); c = false;',attr:function(a){a[3]=(a[5]||a[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(a)},pseudo:function(a){if(a[6]){a[6]=a[6].replace(/"/g,'\\"')}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(a)},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(b,c){var a=Element.readAttribute(b,c[1]);return a&&Selector.operators[c[2]](a,c[5]||c[6])}},handlers:{concat:function(d,c){for(var f=0,g;g=c[f];f++){d.push(g)}return d},mark:function(a){var d=Prototype.emptyFunction;for(var b=0,c;c=a[b];b++){c._countedByPrototype=d}return a},unmark:function(a){for(var b=0,c;c=a[b];b++){c._countedByPrototype=undefined}return a},index:function(a,d,h){a._countedByPrototype=Prototype.emptyFunction;if(d){for(var b=a.childNodes,f=b.length-1,c=1;f>=0;f--){var g=b[f];if(g.nodeType==1&&(!h||g._countedByPrototype)){g.nodeIndex=c++}}}else{for(var f=0,c=1,b=a.childNodes;g=b[f];f++){if(g.nodeType==1&&(!h||g._countedByPrototype)){g.nodeIndex=c++}}}},unique:function(b){if(b.length==0){return b}var d=[],f;for(var c=0,a=b.length;c<a;c++){if(!(f=b[c])._countedByPrototype){f._countedByPrototype=Prototype.emptyFunction;d.push(Element.extend(f))}}return Selector.handlers.unmark(d)},descendant:function(a){var d=Selector.handlers;for(var c=0,b=[],f;f=a[c];c++){d.concat(b,f.getElementsByTagName("*"))}return b},child:function(a){var f=Selector.handlers;for(var d=0,c=[],g;g=a[d];d++){for(var b=0,k;k=g.childNodes[b];b++){if(k.nodeType==1&&k.tagName!="!"){c.push(k)}}}return c},adjacent:function(a){for(var c=0,b=[],f;f=a[c];c++){var d=this.nextElementSibling(f);if(d){b.push(d)}}return b},laterSibling:function(a){var d=Selector.handlers;for(var c=0,b=[],f;f=a[c];c++){d.concat(b,Element.nextSiblings(f))}return b},nextElementSibling:function(a){while(a=a.nextSibling){if(a.nodeType==1){return a}}return null},previousElementSibling:function(a){while(a=a.previousSibling){if(a.nodeType==1){return a}}return null},tagName:function(a,k,c,b){var l=c.toUpperCase();var f=[],j=Selector.handlers;if(a){if(b){if(b=="descendant"){for(var g=0,d;d=a[g];g++){j.concat(f,d.getElementsByTagName(c))}return f}else{a=this[b](a)}if(c=="*"){return a}}for(var g=0,d;d=a[g];g++){if(d.tagName.toUpperCase()===l){f.push(d)}}return f}else{return k.getElementsByTagName(c)}},id:function(b,a,k,g){var j=$(k),d=Selector.handlers;if(!j){return[]}if(!b&&a==document){return[j]}if(b){if(g){if(g=="child"){for(var c=0,f;f=b[c];c++){if(j.parentNode==f){return[j]}}}else{if(g=="descendant"){for(var c=0,f;f=b[c];c++){if(Element.descendantOf(j,f)){return[j]}}}else{if(g=="adjacent"){for(var c=0,f;f=b[c];c++){if(Selector.handlers.previousElementSibling(j)==f){return[j]}}}else{b=d[g](b)}}}}for(var c=0,f;f=b[c];c++){if(f==j){return[j]}}return[]}return(j&&Element.descendantOf(j,a))?[j]:[]},className:function(b,a,c,d){if(b&&d){b=this[d](b)}return Selector.handlers.byClassName(b,a,c)},byClassName:function(c,b,g){if(!c){c=Selector.handlers.descendant([b])}var j=" "+g+" ";for(var f=0,d=[],h,a;h=c[f];f++){a=h.className;if(a.length==0){continue}if(a==g||(" "+a+" ").include(j)){d.push(h)}}return d},attrPresence:function(c,b,a,h){if(!c){c=b.getElementsByTagName("*")}if(c&&h){c=this[h](c)}var f=[];for(var d=0,g;g=c[d];d++){if(Element.hasAttribute(g,a)){f.push(g)}}return f},attr:function(a,k,j,l,c,b){if(!a){a=k.getElementsByTagName("*")}if(a&&b){a=this[b](a)}var n=Selector.operators[c],g=[];for(var f=0,d;d=a[f];f++){var h=Element.readAttribute(d,j);if(h===null){continue}if(n(h,l)){g.push(d)}}return g},pseudo:function(b,c,f,a,d){if(b&&d){b=this[d](b)}if(!b){b=a.getElementsByTagName("*")}return Selector.pseudos[c](b,f,a)}},pseudos:{"first-child":function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(Selector.handlers.previousElementSibling(f)){continue}c.push(f)}return c},"last-child":function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(Selector.handlers.nextElementSibling(f)){continue}c.push(f)}return c},"only-child":function(b,j,a){var f=Selector.handlers;for(var d=0,c=[],g;g=b[d];d++){if(!f.previousElementSibling(g)&&!f.nextElementSibling(g)){c.push(g)}}return c},"nth-child":function(b,c,a){return Selector.pseudos.nth(b,c,a)},"nth-last-child":function(b,c,a){return Selector.pseudos.nth(b,c,a,true)},"nth-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,false,true)},"nth-last-of-type":function(b,c,a){return Selector.pseudos.nth(b,c,a,true,true)},"first-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,false,true)},"last-of-type":function(b,c,a){return Selector.pseudos.nth(b,"1",a,true,true)},"only-of-type":function(b,d,a){var c=Selector.pseudos;return c["last-of-type"](c["first-of-type"](b,d,a),d,a)},getIndices:function(d,c,f){if(d==0){return c>0?[c]:[]}return $R(1,f).inject([],function(a,b){if(0==(b-c)%d&&(b-c)/d>=0){a.push(b)}return a})},nth:function(c,x,z,v,f){if(c.length==0){return[]}if(x=="even"){x="2n+0"}if(x=="odd"){x="2n+1"}var u=Selector.handlers,r=[],d=[],k;u.mark(c);for(var p=0,g;g=c[p];p++){if(!g.parentNode._countedByPrototype){u.index(g.parentNode,v,f);d.push(g.parentNode)}}if(x.match(/^\d+$/)){x=Number(x);for(var p=0,g;g=c[p];p++){if(g.nodeIndex==x){r.push(g)}}}else{if(k=x.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(k[1]=="-"){k[1]=-1}var A=k[1]?Number(k[1]):1;var y=k[2]?Number(k[2]):0;var B=Selector.pseudos.getIndices(A,y,c.length);for(var p=0,g,n=B.length;g=c[p];p++){for(var o=0;o<n;o++){if(g.nodeIndex==B[o]){r.push(g)}}}}}u.unmark(c);u.unmark(d);return r},empty:function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(f.tagName=="!"||(f.firstChild&&!f.innerHTML.match(/^\s*$/))){continue}c.push(f)}return c},not:function(a,d,l){var j=Selector.handlers,n,c;var k=new Selector(d).findElements(l);j.mark(k);for(var g=0,f=[],b;b=a[g];g++){if(!b._countedByPrototype){f.push(b)}}j.unmark(k);return f},enabled:function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(!f.disabled){c.push(f)}}return c},disabled:function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(f.disabled){c.push(f)}}return c},checked:function(b,g,a){for(var d=0,c=[],f;f=b[d];d++){if(f.checked){c.push(f)}}return c}},operators:{"=":function(b,a){return b==a},"!=":function(b,a){return b!=a},"^=":function(b,a){return b.startsWith(a)},"$=":function(b,a){return b.endsWith(a)},"*=":function(b,a){return b.include(a)},"~=":function(b,a){return(" "+b+" ").include(" "+a+" ")},"|=":function(b,a){return("-"+b.toUpperCase()+"-").include("-"+a.toUpperCase()+"-")}},split:function(b){var a=[];b.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(c){a.push(c[1].strip())});return a},matchElements:function(g,j){var f=$$(j),d=Selector.handlers;d.mark(f);for(var c=0,b=[],a;a=g[c];c++){if(a._countedByPrototype){b.push(a)}}d.unmark(f);return b},findElement:function(b,c,a){if(Object.isNumber(c)){a=c;c=false}return Selector.matchElements(b,c||"*")[a||0]},findChildElements:function(f,j){j=Selector.split(j.join(","));var d=[],g=Selector.handlers;for(var c=0,b=j.length,a;c<b;c++){a=new Selector(j[c].strip());g.concat(d,a.findElements(f))}return(b>1)?g.unique(d):d}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(d,c){for(var f=0,g;g=c[f];f++){if(g.tagName!=="!"){d.push(g)}}return d},unmark:function(a){for(var b=0,c;c=a[b];b++){c.removeAttribute("_countedByPrototype")}return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(h,b){if(typeof b!="object"){b={hash:!!b}}else{if(Object.isUndefined(b.hash)){b.hash=true}}var c,g,a=false,f=b.submit;var d=h.inject({},function(j,k){if(!k.disabled&&k.name){c=k.name;g=$(k).getValue();if(g!=null&&(k.type!="submit"||(!a&&f!==false&&(!f||c==f)&&(a=true)))){if(c in j){if(!Object.isArray(j[c])){j[c]=[j[c]]}j[c].push(g)}else{j[c]=g}}}return j});return b.hash?d:Object.toQueryString(d)}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(a){return $A($(a).getElementsByTagName("*")).inject([],function(b,c){if(Form.Element.Serializers[c.tagName.toLowerCase()]){b.push(Element.extend(c))}return b})},getInputs:function(h,c,d){h=$(h);var a=h.getElementsByTagName("input");if(!c&&!d){return $A(a).map(Element.extend)}for(var f=0,j=[],g=a.length;f<g;f++){var b=a[f];if((c&&b.type!=c)||(d&&b.name!=d)){continue}j.push(Element.extend(b))}return j},disable:function(a){a=$(a);Form.getElements(a).invoke("disable");return a},enable:function(a){a=$(a);Form.getElements(a).invoke("enable");return a},findFirstElement:function(b){var c=$(b).getElements().findAll(function(d){return"hidden"!=d.type&&!d.disabled});var a=c.findAll(function(d){return d.hasAttribute("tabIndex")&&d.tabIndex>=0}).sortBy(function(d){return d.tabIndex}).first();return a?a:c.find(function(d){return["input","select","textarea"].include(d.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(b,a){b=$(b),a=Object.clone(a||{});var d=a.parameters,c=b.readAttribute("action")||"";if(c.blank()){c=window.location.href}a.parameters=b.serialize(true);if(d){if(Object.isString(d)){d=d.toQueryParams()}Object.extend(a.parameters,d)}if(b.hasAttribute("method")&&!a.method){a.method=b.method}return new Ajax.Request(c,a)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return""},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value="";return a},present:function(a){return $(a).value!=""},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(a.type))){a.select()}}catch(b){}return a},disable:function(a){a=$(a);a.blur();a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a,b){switch(a.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b)){return a.checked?a.value:null}else{a.checked=!!b}},textarea:function(a,b){if(Object.isUndefined(b)){return a.value}else{a.value=b}},select:function(d,a){if(Object.isUndefined(a)){return this[d.type=="select-one"?"selectOne":"selectMany"](d)}else{var c,g,h=!Object.isArray(a);for(var b=0,f=d.length;b<f;b++){c=d.options[b];g=this.optionValue(c);if(h){if(g==a){c.selected=true;return}}else{c.selected=a.include(g)}}}},selectOne:function(b){var a=b.selectedIndex;return a>=0?this.optionValue(b.options[a]):null},selectMany:function(d){var a,f=d.length;if(!f){return null}for(var c=0,a=[];c<f;c++){var b=d.options[c];if(b.selected){a.push(this.optionValue(b))}}return a},optionValue:function(a){return Element.extend(a).hasAttribute("value")?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,b,c){$super(c,b);this.element=$(a);this.lastValue=this.getValue()},execute:function(){var a=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(a)?this.lastValue!=a:String(this.lastValue)!=String(a)){this.callback(this.element,a);this.lastValue=a}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks()}else{this.registerCallback(this.element)}},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case"checkbox":case"radio":Event.observe(a,"click",this.onElementEvent.bind(this));break;default:Event.observe(a,"change",this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event){var Event={}}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(b){var a;switch(b.type){case"mouseover":a=b.fromElement;break;case"mouseout":a=b.toElement;break;default:return null}return Element.extend(a)}});Event.Methods=(function(){var a;if(Prototype.Browser.IE){var b={0:1,1:4,2:2};a=function(d,c){return d.button==b[c]}}else{if(Prototype.Browser.WebKit){a=function(d,c){switch(c){case 0:return d.which==1&&!d.metaKey;case 1:return d.which==1&&d.metaKey;default:return false}}}else{a=function(d,c){return d.which?(d.which===c+1):(d.button===c)}}}return{isLeftClick:function(c){return a(c,0)},isMiddleClick:function(c){return a(c,1)},isRightClick:function(c){return a(c,2)},element:function(d){var c=Event.extend(d).target;return Element.extend(c.nodeType==Node.TEXT_NODE?c.parentNode:c)},findElement:function(d,g){var c=Event.element(d);if(!g){return c}var f=[c].concat(c.ancestors());return Selector.findElement(f,g,0)},pointer:function(c){return{x:c.pageX||(c.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),y:c.pageY||(c.clientY+(document.documentElement.scrollTop||document.body.scrollTop))}},pointerX:function(c){return Event.pointer(c).x},pointerY:function(c){return Event.pointer(c).y},stop:function(c){Event.extend(c);c.preventDefault();c.stopPropagation();c.stopped=true}}})();Event.extend=(function(){var a=Object.keys(Event.Methods).inject({},function(b,c){b[c]=Event.Methods[c].methodize();return b});if(Prototype.Browser.IE){Object.extend(a,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(b){if(!b){return false}if(b._extendedByPrototype){return b}b._extendedByPrototype=Prototype.emptyFunction;var c=Event.pointer(b);Object.extend(b,{target:b.srcElement,relatedTarget:Event.relatedTarget(b),pageX:c.x,pageY:c.y});return Object.extend(b,a)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents").__proto__;Object.extend(Event.prototype,a);return Prototype.K}})();Object.extend(Event,(function(){var b=Event.cache;function c(l){if(l._prototypeEventID){return l._prototypeEventID[0]}arguments.callee.id=arguments.callee.id||1;return l._prototypeEventID=[++arguments.callee.id]}function h(l){if(l&&l.include(":")){return"dataavailable"}return l}function a(l){return b[l]=b[l]||{}}function g(o,l){var n=a(o);return n[l]=n[l]||[]}function j(n,l,o){var u=c(n);var r=g(u,l);if(r.pluck("handler").include(o)){return false}var p=function(v){if(!Event||!Event.extend||(v.eventName&&v.eventName!=l)){return false}Event.extend(v);o.call(n,v)};p.handler=o;r.push(p);return p}function k(p,l,n){var o=g(p,l);return o.find(function(r){return r.handler==n})}function d(p,l,n){var o=a(p);if(!o[l]){return false}o[l]=o[l].without(k(p,l,n))}function f(){for(var n in b){for(var l in b[n]){b[n][l]=null}}}if(window.attachEvent){window.attachEvent("onunload",f)}return{observe:function(o,l,p){o=$(o);var n=h(l);var r=j(o,l,p);if(!r){return o}if(o.addEventListener){o.addEventListener(n,r,false)}else{o.attachEvent("on"+n,r)}return o},stopObserving:function(o,l,p){o=$(o);var u=c(o),n=h(l);if(!p&&l){g(u,l).each(function(v){o.stopObserving(l,v.handler)});return o}else{if(!l){Object.keys(a(u)).each(function(v){o.stopObserving(v)});return o}}var r=k(u,l,p);if(!r){return o}if(o.removeEventListener){o.removeEventListener(n,r,false)}else{o.detachEvent("on"+n,r)}d(u,l,p);return o},fire:function(o,n,l){o=$(o);if(o==document&&document.createEvent&&!o.dispatchEvent){o=document.documentElement}var p;if(document.createEvent){p=document.createEvent("HTMLEvents");p.initEvent("dataavailable",true,true)}else{p=document.createEventObject();p.eventType="ondataavailable"}p.eventName=n;p.memo=l||{};if(document.createEvent){o.dispatchEvent(p)}else{o.fireEvent(p.eventType,p)}return Event.extend(p)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var b;function a(){if(document.loaded){return}if(b){window.clearInterval(b)}document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){b=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){a()}},0);Event.observe(window,"load",a)}else{document.addEventListener("DOMContentLoaded",a,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;a()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(b,a,c){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(b,a,c)}this.xcomp=a;this.ycomp=c;this.offset=Element.cumulativeOffset(b);return(c>=this.offset[1]&&c<this.offset[1]+b.offsetHeight&&a>=this.offset[0]&&a<this.offset[0]+b.offsetWidth)},withinIncludingScrolloffsets:function(b,a,d){var c=Element.cumulativeScrollOffset(b);this.xcomp=a+c[0]-this.deltaX;this.ycomp=d+c[1]-this.deltaY;this.offset=Element.cumulativeOffset(b);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+b.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+b.offsetWidth)},overlap:function(b,a){if(!b){return 0}if(b=="vertical"){return((this.offset[1]+a.offsetHeight)-this.ycomp)/a.offsetHeight}if(b=="horizontal"){return((this.offset[0]+a.offsetWidth)-this.xcomp)/a.offsetWidth}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(a){Position.prepare();return Element.absolutize(a)},relativize:function(a){Position.prepare();return Element.relativize(a)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(b,c,a){a=a||{};return Element.clonePosition(c,b,a)}};if(!document.getElementsByClassName){document.getElementsByClassName=function(b){function a(c){return c.blank()?null:"[contains(concat(' ', @class, ' '), ' "+c+" ')]"}b.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(c,f){f=f.toString().strip();var d=/\s/.test(f)?$w(f).map(a).join(""):a(f);return d?document._getElementsByXPath(".//*"+d,c):[]}:function(f,g){g=g.toString().strip();var h=[],j=(/\s/.test(g)?$w(g):null);if(!j&&!g){return h}var c=$(f).getElementsByTagName("*");g=" "+g+" ";for(var d=0,l,k;l=c[d];d++){if(l.className&&(k=" "+l.className+" ")&&(k.include(g)||(j&&j.all(function(n){return !n.toString().blank()&&k.include(" "+n+" ")})))){h.push(Element.extend(l))}}return h};return function(d,c){return $(c||document.body).getElementsByClassName(d)}}(Element.Methods)}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(a){this.element.className.split(/\s+/).select(function(b){return b.length>0})._each(a)},set:function(a){this.element.className=a},add:function(a){if(this.include(a)){return}this.set($A(this).concat(a).join(" "))},remove:function(a){if(!this.include(a)){return}this.set($A(this).without(a).join(" "))},toString:function(){return $A(this).join(" ")}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();var Tools={IE6:false
/*@cc_on || @_jscript_version < 5.7 @*/
,send:function(b,g,a,f){var d=function(h){g(h)};var c=function(h){if(a){a(h)}};var f=f?f:"";if(b.params){f=b.params;b=b.url}new Ajax.Request(b,{method:"post",parameters:f,onComplete:d,onException:c,on404:c,on403:c,on400:c,on500:c})},setCookie:function(c,f,a,j,d,h){var b=new Date();b.setTime(b.getTime());if(a){a=a*1000*60*60*24}var g=new Date(b.getTime()+(a));document.cookie=c+"="+escape(f)+((a)?";expires="+g.toGMTString():"")+((j)?";path="+j:"")+((d)?";domain="+d:"")+((h)?";secure":"")},getCookie:function(a){var g=document.cookie.split(";");var b="";var d="";var f="";var c=false;for(i=0;i<g.length;i++){b=g[i].split("=");d=b[0].replace(/^\s+|\s+$/g,"");if(d==a){c=true;if(b.length>1){f=unescape(b[1].replace(/^\s+|\s+$/g,""))}return f;break}b=null;d=""}if(!c){return null}},selectValueOfDropDown:function(a,f){var b=a.options;for(var c=0;c<b.length;c++){var d=b[c];if(d.value==f){a.selectedIndex=c}}},stripPandBr:function(b){var a=/(<\/?p>)?(<\/?br\/?>)?/g;return b.replace(a,"")},stripTinyTags:function(a){a=Tools.stripWordTags(a);return a.replace(/(<.*?>)/g,function(b,c,d){if(c.search(/<\/?(em|strong|span|p|br).*?>/g)==-1){return""}else{return c}})},stripWordTags:function(c){if(c&&c.length>0){var b=String.fromCharCode(8226);var a=String.fromCharCode(183);c=c.replace("&lt;","<").replace("&gt;",">");c=c.replace(new RegExp('tab-stops: list [0-9]+.0pt">',"gi"),'">--list--');c=c.replace(new RegExp(b+"(.*?)<BR>","gi"),"<p>"+a+"$1</p>");c=c.replace(new RegExp('<SPAN style="mso-list: Ignore">',"gi"),"<span>"+b);c=c.replace(/<o:p><\/o:p>/gi,"");c=c.replace(new RegExp('<br style="page-break-before: always;.*>',"gi"),"-- page break --");c=c.replace(new RegExp("<(!--)([^>]*)(--)>","g"),"");c=c.replace(/<\/?font[^>]*>/gi,"");c=c.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");c=c.replace(/<\/?\\?\??xml[^>]*>(.*)<\/?\\?\??xml[^>]*>/gi,"");c=c.replace(/<\/?\w+:[^>]*>/gi,"");c=c.replace(/\n/gi,"").replace(/<!--.*?-->/gi,"");c=c.replace(/\s?class="?MsoNormal"?(\s?style=".*?")?/g,"");c=c.replace(/(<p>)\s*(<span.*?>)(.*?)(<\/span>)\s*(<\/p>)/gi,"$1$3$5");c=c.replace(/<span.*?font-family.*?>(.*?)<\/span>/gi,"$1");c=c.replace(/<p\/>/g,"");c=c.replace(/-- page break --\s*<p>&nbsp;<\/p>/gi,"");c=c.replace(/-- page break --/gi,"");c=c.replace(/<\/?div[^>]*>/gi,"");c=c.replace(/--list--/gi,"")}return c},getTinyValue:function(d,c){var a=tinyMCE.get(d);var b=a.getContent();if(c){b=Tools.stripTinyTags(b)}return b},setTinyValue:function(b,a){return tinyMCE.get(b).setContent(a)},getXMLDocObjectFromResponse:function(a){var b;try{b=new ActiveXObject("Microsoft.XMLDOM");b.async="false";b.loadXML(a.responseText)}catch(c){parser=new DOMParser();b=parser.parseFromString(a.responseText,"text/xml")}return b},getUniqueId:function(){var a=new Date();var b=a.getFullYear()+""+a.getMonth()+""+a.getDate()+""+a.getTime();return b},getResizedImagePath:function(b,a){filename=b.split("/").pop();ext=filename.split(".").pop();ext="."+ext;new_filename=filename.replace(ext,"_"+a+ext);return b.replace(filename,new_filename)},fgGetElementByClassName:function(b,a){if(navigator.userAgent.toLowerCase().indexOf("msie 7.")!=-1){return Element.getElementsByClassName(a,b)}return(Prototype.Browser.IE)?document.getElementsByClassName(b,a):a.getElementsByClassName(b)},isValueInDropDown:function(a,f){var b=a.options;for(var c=0;c<b.length;c++){var d=b[c];if(d.value==f){return true}}return false},addToFavories:function(b){var a=window.location.href;var c=window.document.title;if(Prototype.Browser.IE){window.external.AddFavorite(a,c)}else{if(Prototype.Browser.Opera){this.setAttribute("href",a);this.setAttribute("rel","sidebar");this.setAttribute("title",a+","+c);return true}else{window.sidebar.addPanel(c,a,"")}}return false},addToHomePage:function(b){var a=window.location.protocol+"//"+window.location.host;if(Prototype.Browser.IE){b.style.behavior="url(#default#homepage)";b.setHomePage(a)}},showError:function(a){var a=a?a:JS_ERROR_TEXT;alert(a)},addDaysToDate:function(c,b){var a=new Date(c);a.setDate(a.getDate()+b);return a},addMonthToDate:function(a,b){return new Date(a.getFullYear(),a.getMonth()+b,1)},daysBetween:function(a,c){var b=24*60*60*1000;var d=(c.getTime()-a.getTime())/b;return Math.round(d)},dateToString:function(b,d){var c=b.getDate()+" "+_fgCalendarMonthes[b.getMonth()];var a=c+" "+b.getFullYear()+" "+OFYEAR;return d?c:a},dateTo_dmy:function(a){return a.getDate()+" "+_fgCalendarMonthes[a.getMonth()]+", "+a.getFullYear()},dateTo_dmy_smart:function(b,a){if(b.getFullYear()==a){return b.getDate()+" "+_fgCalendarMonthes[b.getMonth()]}return Tools.dateTo_dmy(b)},dateTo_ymd:function(a){return a.getFullYear()+"."+(a.getMonth()+1)+"."+a.getDate()},ymd_ToDate:function(b){var a=b.split(".");return new Date(Tools.parse01Digit(a[0]),Tools.parse01Digit(a[1])-1,Tools.parse01Digit(a[2]))},datesEqual:function(b,a){return b.getFullYear()==a.getFullYear()&&b.getDate()==a.getDate()&&b.getMonth()==a.getMonth()},parse01Digit:function(a){return parseInt(a)==0?parseInt(a.substring(1,2)):parseInt(a)},sortDateArr:function(b,a){b.sort(function(d,c){if(d.date>c.date){return a?-1:1}if(d.date<c.date){return a?1:-1}if(d.date==c.date){return 1}})},disableDashedLink:function(a,b){if(!b){return Tools.enableDashedLink(a)}if(a.getElementsByTagName("a").length==0){return}var c=a.getElementsByTagName("a")[0].innerHTML;a.innerHTML=c},enableDashedLink:function(a){if(a.getElementsByTagName("a").length>0){return}var b=a.innerHTML;a.innerHTML="<a href='javascript:void(0)'>"+b+"</a>"},show:function(b,a){b.style.display=a?"block":"none"},hide:function(b,a){Tools.show(b,!a)},setVisible:function(b,a){var c=["visible","hidden"];b.style.visibility=c[a?0:1]},insertIE6Iframe:function(b,a){if(!Tools.IE6){return}var c=new Template("<iframe frameborder='0' tabindex='-1' src='/media/img/px.gif' style='position:absolute;top:#{top}px;left:#{left}px;width:#{width}px;height:#{height}px; z-index:-1;'></iframe>");b.insert({bottom:c.evaluate(a)})},isUrl:function(a){var b=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return b.test(a)},isEmail:function(a){var b=/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/;return b.test(a)},isWord:function(a){return/^\w+$/.test(a)},preloadImage:function(b,c){var a=new Image();a.onload=function(d){c(a.width,a.height)};a.src=b},hideFade:function(a,b){Tools.animateOpacity(a,100,0,4000,b)},animateOpacity:function(c,g,a,b,f){var d=Math.round(b/100);var h=0;if(g>a){for(i=g;i>=a;i--){setTimeout(function(j){Tools.changeOpacity(j,c);if((j-1<a)&&a==0){c.style.display="none";Tools.changeOpacity(100,c);if(f){f()}}}.bind(this,i),h*d);h++}}else{if(g<a){for(i=g;i<=a;i++){setTimeout(function(j){Tools.changeOpacity(j,c),h*d}.bind(this,i));h++}}}},changeOpacity:function(b,c){var a=c.style;a.opacity=(b/100);a.MozOpacity=(b/100);a.KhtmlOpacity=(b/100);a.filter="alpha(opacity="+b+")"},isCtrlEnter:function(a){return((a.keyCode==13)||(a.keyCode==10))&&(a.ctrlKey==true)},declension:function(c,a){var b=2;if((c%10==1)&&(c%100!=11)){b=0}if((c%10>=2&&c%10<=4)&&(c%100<10||c%100>=20)){b=1}return a[b]},getScrollProperties:function(){var b=0;var a=0;if(typeof(window.pageYOffset)=="number"){b=window.pageYOffset;a=window.pageXOffset}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){b=document.body.scrollTop;a=document.body.scrollLeft}else{if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){b=document.documentElement.scrollTop;a=document.documentElement.scrollLeft}}}return{top:b,left:a}},IE8:function(){if(!Prototype.Browser.IE){return false}if(/MSIE (\d+\.\d+);/.test(navigator.userAgent)){return parseInt(RegExp.$1)==8}return false}};var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);
/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/
return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return}f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return}if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return}}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return}var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return}var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return}AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();function doGetCaretPosition(c){var b=0;if(document.selection){c.focus();var a=document.selection.createRange();a.moveStart("character",-c.value.length);b=a.text.length}else{if(c.selectionStart||c.selectionStart=="0"){b=c.selectionStart}}return(b)}var Input=Class.create();Input.prototype={initialize:function(a,b){this.el=$(a);this.separator=b;this.el.object=this;this.el.onkeypress=this.onkey.bindAsEventListener(this);this.el.onkeyup=this.onkeyUp.bindAsEventListener(this);this.el.onpaste=this.onPaste.bindAsEventListener(this);Event.observe(this.el,"blur",this.onChange.bindAsEventListener(this))},validate:function(a){if(this.el.getAttribute("requiredField")&&$F(this.el)==""){if(a==undefined){a=true}showError(this.el,"Should not be empty",a);return false}return true},onkey:function(){},onkeyUp:function(){},onPaste:function(){},onChange:function(){}};var NumberInput=Class.create(Input,{isMatch:function(a){var b=doGetCaretPosition(this.el);return this.regEx.test(this.el.value.substring(0,b)+a+this.el.value.substring(b,this.el.value.length))},getValue:function(){return this.el.value},clearType:function(){var a=getValue(this.el);a=a.replace(/\s/g,"");a=a.replace(/[,.]/g,this.separator);setValue(this.el,a)},onkey:function(g){var d=Prototype.Browser.IE;var a=g.keyCode?g.keyCode:(g.which?g.which:g.charCode);var f=String.fromCharCode(a);if(a==37&&g.shiftKey&&(d||g.which==37)){return false}if([9,8,16,37,39].indexOf(a)>-1){return true}if(f==","){f=this.separator}if(f=="."){f=this.separator}var c=this.strWork.indexOf(f)!==-1;var b=c&&this.isMatch(f);if(b){if(d){window.event.keyCode=f.charCodeAt(0)}}else{if(d){window.event.keyCode=0}else{return false}}},validate:function(a){if(this.el.getAttribute("range")&&this.el.value!=this.el.getAttribute("defValue")&&!this.el.disabled&&!this.el.parentNode.parentNode.disabled){if(!getScriptResult(this.el.getAttribute("range"),parseFloat(this.el.value))){showError(this.el,this.el.getAttribute("rangeMessage"),a);return false}}if(!this.el.getAttribute("relatedId")){return this.parent()}return true},onChange:function(){var a=this.el.value;if(a.substring(a.length-1,a.length)==this.separator){setValue(this.el,a.substring(0,a.length-1))}},onPaste:function(b){if(!Prototype.Browser.isIE){return true}var a=this.regEx.test(window.clipboardData.getData("Text"));if(!a){b.returnValue=false}},onkeyUp:function(){var b=this.el.value;var a=b.replace(",",this.separator).replace(".",this.separator);if(b!=a){this.el.value=a}}});var IntInput={initialize:function(a){this.parent(a);this.regEx=/^(\d+?)$/;this.strWork="1234567890"}};var IntInput=Object.extend(NumberInput,IntInput);var DateInput={initialize:function(a){this.parent(a);this.regEx=/^(0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20)[0-9]{2}$/;this.strWork="1234567890.";this.el.onkeypress="";this.el.onkeyup="";this.el.onpaste=""},validate:function(a){if(this.el.value==""){return true}if(this.regEx.test(this.el.value)){return true}else{showError(this.el,"Date in not correct format(dd.mm.yyyy)",true);return false}}};var DateInput=Object.extend(NumberInput,DateInput);var FloatInput=Class.create(NumberInput,{initialize:function($super,a,b){$super(a,b);a.floatinput=true;this.regEx=/^(\d+?)([.,]\d?\d?)?$/;this.strWork="1234567890"+this.separator}});var NegativeIntInput=Class.create(NumberInput,{initialize:function($super,a){$super(a);this.regEx=/^(\-?)(\d+?)?$/;this.strWork="-1234567890"},onChange:function(){if(this.el.value=="-"){this.el.value=0}}});var NumInput=Class.create(NumberInput,{initialize:function($super,d){$super(d);this.el.value=this.el.value.toString().replace(",",".");var a=this.el.getAttribute("decimalSigns");if(a=="*"){this.regEx=/^(\d+?)(\.\d*?)?$/}else{var c="";for(var b=0;b<parseInt(a);b++){c+="\\d?"}this.regEx=new RegExp("^(\\d+?)(\\."+c+")?$")}this.strWork="1234567890.";if(a=="0"){this.strWork="1234567890"}}});var DynamicButton=Class.create();DynamicButton.prototype={initialize:function(a){this.container=a;this.down=false;if(!this.container){return}this.setEventListeners()},setEventListeners:function(){this.container.onmousedown=this.onmousedown.bindAsEventListener(this);this.container.onmouseup=this.onmouseup.bindAsEventListener(this);this.container.onmouseout=this.onmouseout.bindAsEventListener(this)},onmousedown:function(a){if(this.down){return}this.updateBtn(true);this._onmousedown()},onmouseup:function(a){if(!this.down){return}this.updateBtn(false);this._onmouseup()},onmouseout:function(a){if(!this.down){return}this.updateBtn(false)},updateBtn:function(a){if(a){this.container.addClassName("b-down")}else{this.container.removeClassName("b-down")}this.down=a},setValue:function(a){this.container.down("span",0).innerHTML=a},_onmousedown:function(){},_onmouseup:function(){}};var HelpDialog=Class.create();HelpDialog.prototype={initialize:function(b,a){this.opener=$(b);this.container=$(a);this.keywordContainers=$$(".bookmarkSignPlatform");if(!this.opener||!this.container){return}this.overed=true;this.setKeyword();this.setEventListeners()},setEventListeners:function(){this.opener.onclick=this._show.bindAsEventListener(this,true);var a=this.container.select(".b-addbookmark-close")[0];if(a){a.onclick=this.show.bind(this,false)}},setEvents:function(){this.container.onmouseover=this.onmouseover.bindAsEventListener(this);this.container.onmouseout=this.onmouseout.bindAsEventListener(this);Event.observe(document,"click",this.onclick.bindAsEventListener(this));this.overed=false},resetEvents:function(){this.container.onmouseover=null;this.container.onmouseout=null;Event.stopObserving(document,"click",this.onclick);this.overed=true},onclick:function(b){var a=Event.element(b);if(a==this.opener){return}if(!this.overed&&this.opened){this.show(false)}},onmouseover:function(a){this.setOvered(true)},onmouseout:function(a){this.setOvered(false)},setOvered:function(a){this.overed=a},_show:function(a,b){this.show(b)},show:function(b){if(!this.container){return}this.opened=(b)?true:false;var a=(b)?"block":"none";this.container.style.display=a;if(b){this.setEvents()}else{this.resetEvents()}},setKeyword:function(){if(this.isMacOS()){this.keywordContainers.each(function(a){a.innerHTML="&#8984;D"})}},isMacOS:function(){return navigator.appVersion.indexOf("Mac")!=-1}};var Autocomplete=function(b,a){this.el=$(b);this.id=this.el.identify();this.el.setAttribute("autocomplete","off");this.suggestions=[];this.data=[];this.badQueries=[];this.selectedIndex=-1;this.currentValue=this.el.value;this.intervalId=0;this.cachedResponse=[];this.instanceId=null;this.onChangeInterval=null;this.ignoreValueChange=false;this.serviceUrl=a.serviceUrl;this.options={autoSubmit:false,minChars:1,maxHeight:300,deferRequestBy:0,width:0,container:null};if(a){Object.extend(this.options,a)}if(Autocomplete.isDomLoaded){this.initialize()}else{Event.observe(document,"dom:loaded",this.initialize.bind(this),false)}};Autocomplete.instances=[];Autocomplete.isDomLoaded=false;Autocomplete.getInstance=function(c){var b=Autocomplete.instances;var a=b.length;while(a--){if(b[a].id===c){return b[a]}}};Autocomplete.highlight=function(b,a){return b.replace(a,function(c){return"<strong>"+c+"</strong>"})};Autocomplete.prototype={killerFn:null,initialize:function(){var a=this;this.killerFn=function(c){if(!$(Event.element(c)).up(".autocomplete")){a.killSuggestions();a.disableKillerFn()}}.bindAsEventListener(this);if(!this.options.width){this.options.width=this.el.getWidth()}var b=new Element("div",{style:"position:absolute;"});b.update('<div class="autocomplete-w1"><div class="autocomplete-w2"><div class="autocomplete" id="Autocomplete_'+this.id+'" style="display:none; width:'+this.options.width+'px;"></div></div></div>');this.options.container=$(this.options.container);if(this.options.container){this.options.container.appendChild(b);this.fixPosition=function(){}}else{document.body.appendChild(b)}this.mainContainerId=b.identify();this.container=$("Autocomplete_"+this.id);this.fixPosition();Event.observe(this.el,window.opera?"keypress":"keydown",this.onKeyPress.bind(this));Event.observe(this.el,"keyup",this.onKeyUp.bind(this));Event.observe(this.el,"blur",this.enableKillerFn.bind(this));Event.observe(this.el,"focus",this.fixPosition.bind(this));this.container.setStyle({maxHeight:this.options.maxHeight+"px"});this.instanceId=Autocomplete.instances.push(this)-1},fixPosition:function(){var a=this.el.cumulativeOffset();if(Tools.IE6){a.left=a.left-6}$(this.mainContainerId).setStyle({top:(a.top+this.el.getHeight())+"px",left:a.left+"px"})},enableKillerFn:function(){Event.observe(document.body,"click",this.killerFn)},disableKillerFn:function(){Event.stopObserving(document.body,"click",this.killerFn)},killSuggestions:function(){this.stopKillSuggestions();this.intervalId=window.setInterval(function(){this.hide();this.stopKillSuggestions()}.bind(this),300)},stopKillSuggestions:function(){window.clearInterval(this.intervalId)},onKeyPress:function(a){if(!this.enabled){return}switch(a.keyCode){case Event.KEY_ESC:this.el.value=this.currentValue;this.hide();break;case Event.KEY_TAB:case Event.KEY_RETURN:case 44:if(this.selectedIndex===-1){this.hide();return}this.select(this.selectedIndex);if(a.keyCode===Event.KEY_TAB){return}break;case Event.KEY_UP:this.moveUp();break;case Event.KEY_DOWN:this.moveDown();break;default:return}Event.stop(a)},onKeyUp:function(a){switch(a.keyCode){case Event.KEY_UP:case Event.KEY_DOWN:return}clearInterval(this.onChangeInterval);if(this.currentValue!==this.el.value){if(this.options.deferRequestBy>0){this.onChangeInterval=setInterval((function(){this.onValueChange()}).bind(this),this.options.deferRequestBy)}else{this.onValueChange()}}},onValueChange:function(){clearInterval(this.onChangeInterval);this.currentValue=this.el.value;this.selectedIndex=-1;if(this.ignoreValueChange){this.ignoreValueChange=false;return}value=this.get_tagvalue(this.currentValue);if(value===""||value.length<this.options.minChars){this.hide()}else{this.getSuggestions()}},setvalue:function(d){var c=this.el.value.substr(0,this.curpos);var b=this.el.value.substr(this.curpos);var g=c.match(/[^,]+$/);var f=b.match(/^[^,]+/);var a=[];if(g){a.push(c.substr(0,this.curpos-g[0].length))}a.push(d);if(f){a.push(b.substr(f[0].length))}else{a.push(b)}this.el.value=a.join("");this.el.selectionStart=this.el.value.indexOf(d);this.el.selectionEnd=d.length+this.el.value.indexOf(d)},get_tagvalue:function(f){this.curpos=this.el.selectionStart;var c=f.substr(this.curpos);var b=new RegExp("[^,]+"+c+"$","gi");var d=f.match(b);if(!d){return f}var a=d[0].replace(c,"");return a.strip()},getSuggestions:function(){value=this.get_tagvalue(this.currentValue);var a=this.cachedResponse[value];if(a&&Object.isArray(a.suggestions)){this.suggestions=a.suggestions;this.data=a.data;this.suggest()}else{if(!this.isBadQuery(value)){new Ajax.Request(this.serviceUrl,{parameters:{query:value},onComplete:this.processResponse.bind(this),method:"get"})}}},isBadQuery:function(b){var a=this.badQueries.length;while(a--){if(b.indexOf(this.badQueries[a])===0){return true}}return false},hide:function(){this.enabled=false;this.selectedIndex=-1;this.el.selectionStart=this.el.selectionEnd;this.container.hide()},suggest:function(){if(this.suggestions.length===0){this.hide();return}var b=[];var a=new RegExp("\\b"+this.currentValue.match(/[A-Za-z0-9_а-яА-Я]+/g).join("|\\b"),"gi");this.suggestions.each(function(d,c){b.push((this.selectedIndex===c?'<div class="selected"':"<div"),' title="',d,'" onclick="Autocomplete.instances[',this.instanceId,"].select(",c,');" onmouseover="Autocomplete.instances[',this.instanceId,"].activate(",c,');">',Autocomplete.highlight(d,a),"</div>")}.bind(this));this.enabled=true;if(Tools.IE6){this.container.setStyle({height:19*this.suggestions.length+"px"})}this.container.update(b.join("")).show()},processResponse:function(c){var a;try{a=c.responseText.evalJSON();if(!Object.isArray(a.data)){a.data=[]}}catch(b){return}this.suggestions=a.suggestions;this.data=a.data;this.cachedResponse[a.query]=a;if(a.suggestions.length===0){this.badQueries.push(a.query)}if(a.query===this.get_tagvalue(this.currentValue)){this.suggest()}},activate:function(a){var b=this.container.childNodes;var c;if(this.selectedIndex!==-1&&b.length>this.selectedIndex){b[this.selectedIndex].className=""}this.selectedIndex=a;if(this.selectedIndex!==-1&&b.length>this.selectedIndex){c=b[this.selectedIndex];c.className="selected"}return c},deactivate:function(b,a){b.className="";if(this.selectedIndex===a){this.selectedIndex=-1}},select:function(b){var a=this.suggestions[b];if(a){this.setvalue(a);if(this.options.autoSubmit&&this.el.form){this.el.form.submit()}this.ignoreValueChange=true;this.hide();this.onSelect(b)}},moveUp:function(){if(this.selectedIndex===-1){return}if(this.selectedIndex===0){this.container.childNodes[0].className="";this.selectedIndex=-1;this.setvalue(this.get_tagvalue(this.currentValue));return}this.adjustScroll(this.selectedIndex-1)},moveDown:function(){if(this.selectedIndex===(this.suggestions.length-1)){return}this.adjustScroll(this.selectedIndex+1)},adjustScroll:function(b){var a=this.container;var g=this.activate(b);var c=g.offsetTop;var d=a.scrollTop;var f=d+this.options.maxHeight-25;if(c<d){a.scrollTop=c}else{if(c>f){a.scrollTop=c-this.options.maxHeight+25}}this.setvalue(this.suggestions[b])},onSelect:function(a){(this.options.onSelect||Prototype.emptyFunction)(this.suggestions[a],this.data[a])}};Event.observe(document,"dom:loaded",function(){Autocomplete.isDomLoaded=true},false);var CaloryManager=Class.create();CaloryManager.prototype={initialize:function(){this.calculator=new CaloryCalculator();this.summary=new CalorySummary(this);this.summary.onRemoveRow=this.onRemoveProduct.bind(this);this.categories=$$(".b-calory-product-category");this.menuContainer=$("menuContainer");this.addToProfile=$("addToProfile");if(this.addToProfile){this.addToProfile.onclick=this.addTableToProfile.bindAsEventListener(this)}this.productChooser=new CaloryProductChooser();this.productChooser.onAddProduct=this.onAddProduct.bind(this);this.data=[];$("btnPrint").onclick=this.print.bind(this)},addTableToProfile:function(){var a=this.getCleanedTableHTML();this.addToProfile.disabled=true;Tools.send(URL_ADD_INFO_TO_PROFILE,function(b){var c=b.responseText;if(c=="OK"){document.location.href=USER_PROFILE}}.bind(this),null,{data:a})},onAddProduct:function(c){c.uid=Tools.getUniqueId();for(var a=0;a<this.data.length;a++){var b=this.data[a];if(b.id==c.id&&c.id){this.data[a]=c;return this.recalculate()}}this.data.splice(0,0,c);this.recalculate()},onRemoveProduct:function(b){for(var a=0;a<this.data.length;a++){if(this.data[a].uid==b){this.data.splice(a,1);break}}if(this.data.length==0){this.menuContainer.hide();return this.summary.hide()}this.recalculate()},onRemoveAllProducts:function(){this.data=[];this.menuContainer.hide();this.summary.hide()},recalculate:function(){var a=this.calculator.calculate(this.data);this.summary.update(a);this.menuContainer.style.display=a.items.length>0?"block":"none";if(this.addToProfile){this.addToProfile.disabled=!a.items.length>0}},getCleanedTableHTML:function(){var b=$$(".l-calc-te")[0].innerHTML;var a=$("tableCleaner");a.innerHTML=b;a=this.removeFirstColumn(a);return a.innerHTML},removeFirstColumn:function(d){var b=d;var a=b.select("tr");for(var c=0;c<a.length;c++){a[c].firstDescendant().remove()}var f=b.select("col");f[0].remove();return b},print:function(){var a=this.getCleanedTableHTML();w=window.open("/food/myration/?print");w.onloaded=function(){w.document.getElementById("table").innerHTML=a};window.printData=w.onloaded}};var CaloryProductChooser=Class.create();CaloryProductChooser.prototype={initialize:function(){this.setTabs();this.productSelector=new CaloryProductSelector();this.productInserter=new CaloryProductInserter();var a=function(b){this.onAddProduct(b)};this.productSelector.onAddProduct=a.bind(this);this.productInserter.onAddProduct=a.bind(this)},setTabs:function(){this.tabs=$$(".b-calc-add-lk, .b-calc-add-dd, .b-calc-add-dt");var b="h-calc-add-dd__selected";var d=function(f){return f.tagName!="A"?$(f):$(f.parentNode)};for(var a=0;a<this.tabs.length;a++){var c=this.tabs[a];if(c.tagName!="A"){continue}c.onclick=function(h){var f=Event.element(h);this.tabs.each(function(j){d(j).removeClassName(b)});var g=d(f);g.addClassName(b);$(g.nextSibling).addClassName(b)}.bindAsEventListener(this)}}};var CaloryProductInserter=Class.create();CaloryProductInserter.prototype={initialize:function(){this.attributes=["title","weight","proteins","fats","carbohydrates","calories"];this.inputs=[];this.initInputs();this.btnAdd=$("btnAddNewProduct");this.btnAdd.onclick=this.onAddClick.bind(this)},initInputs:function(){for(var c=0;c<this.attributes.length;c++){var d=this.attributes[c];var a=d.slice(0,1).toUpperCase()+d.slice(1);var b=$("txtAdd"+a);Event.observe(b,"keyup",this.checkDisableRules.bind(this));this.inputs[d]=b;if(c>0){new FloatInput(b,",")}}},checkDisableRules:function(){for(var a=0;a<this.attributes.length;a++){if(this.inputs[this.attributes[a]].value==""||this.inputs[this.attributes[1]].value==0){return this.btnAdd.disabled=true}}this.btnAdd.disabled=""},serialize:function(){var a={};for(var b=0;b<this.attributes.length;b++){var c=this.attributes[b];a[c]=this.inputs[c].value.replace(",",".").escapeHTML()}a.weight=parseFloat(this.inputs.weight.value.replace(",",".").escapeHTML());return a},isWeightIncorrect:function(){return($("txtAddWeight").value==""||$("txtAddWeight").value==0)},onAddClick:function(){if(this.isWeightIncorrect()){return}if(this.onAddProduct){this.onAddProduct(this.serialize())}this.clear()},clear:function(){for(var a=0;a<this.attributes.length;a++){var b=this.attributes[a];this.inputs[b].value=""}this.btnAdd.disabled=true}};var CaloryProductSelector=Class.create();CaloryProductSelector.prototype={optionTemplate:new Template("<option value='#{id}'>#{title}</option>"),initialize:function(){this.cbCategory=$("cbSelectCategory");this.cbCategory.onchange=this.getProducts.bind(this);this.cachedProducts=[];this.cbProduct=$("cbSelectProduct");this.cbProduct.onchange=this.checkDisableRules.bind(this);this.txtWeight=$("txtWeight");Event.observe(this.txtWeight,"keydown",this.onAddProductByEnter.bindAsEventListener(this));new FloatInput(this.txtWeight);Event.observe(this.txtWeight,"keyup",this.checkDisableRules.bind(this));this.btnAdd=$("btnAddSelectedProduct");this.btnAdd.onclick=this.onAddClick.bind(this);this.loader=$("ration_loader")},onAddProductByEnter:function(b){var a=b.keyCode?b.keyCode:(b.which?b.which:b.charCode);if(a==13){this.onAddClick()}},onAddClick:function(){if(this.txtWeight.value==""||this.txtWeight.value==0){return}var d=this.cachedProducts[$F(this.cbCategory)];var f=$F(this.cbProduct);for(var b=0;b<d.length;b++){var c=d[b];if(c.id==f){var a={title:c.title,weight:parseFloat($F(this.txtWeight)),calories:c.calories,fats:c.fats,proteins:c.proteins,carbohydrates:c.carbohydrates,id:c.id};if(this.onAddProduct){this.onAddProduct(a);this.cbCategory.selectedIndex=0;this.clearControls();this.checkDisableRules();return}}}},getProducts:function(){var b=$F(this.cbCategory);this.clearControls();if(b==""){this.checkDisableRules();return}var a=this.cachedProducts[b];if(a){this.renderProducts(a);return}this.getProductsFromServer(b)},addProductsToCache:function(b,a){this.cachedProducts[b]=a},showLoader:function(b){var a=(b)?"visible":"hidden";this.loader.setStyle({visibility:a})},getProductsFromServer:function(a){this.showLoader(true);Tools.send(URL_GET_PRODUCTS_BY_CATEGORY_ID+a,function(c){var b=c.responseText.evalJSON();this.showLoader(false);this.addProductsToCache(a,b);this.renderProducts(b)}.bind(this))},renderProducts:function(a){var b=[];b.push(this.optionTemplate.evaluate({id:"",title:""}));for(var c=0;c<a.length;c++){b.push(this.optionTemplate.evaluate(a[c]))}this.cbProduct.innerHTML="";this.cbProduct.insert({bottom:b.join("")});this.cbProduct.selectedIndex=0;this.checkDisableRules()},checkDisableRules:function(){var b=function(g){this.btnAdd.disabled=g}.bind(this);var f=function(g){this.cbProduct.disabled=g}.bind(this);var a=function(g){this.txtWeight.disabled=g}.bind(this);var c=function(g){b(g);f(g);a(g)};var d=function(){b(true);a(true)};c(false);if($F(this.cbCategory)==""){return c(true)}if($F(this.cbProduct)==""){return d(true)}if(this.txtWeight.value==""||this.txtWeight.value==0){return b(true)}},clearControls:function(){this.txtWeight.value="";this.cbProduct.selectedIndex=0}};var testData=[{title:"Бородинский",proteins:"2",fats:"2",carbohydrates:"2",calories:"4543",weight:2200},{title:"Украинский",proteins:"23",fats:"2",carbohydrates:"23",calories:"433.23",weight:1200}];var CaloryCalculator=Class.create();CaloryCalculator.prototype={initialize:function(){},calculate:function(d){var c=0;var p=0;var b=0;var j=0;var g=0;for(var f=0;f<d.length;f++){var n=Object.clone(d[f]);this.recalculateProductFor100gram(n);c+=n.calories;p+=n.proteins;b+=n.fats;j+=n.carbohydrates;g+=Number(n.weight)}var a=this.getPercent(g,c);var o=this.getPercent(g,p);var l=this.getPercent(g,b);var k=this.getPercent(g,j);var h={calories:this.round(c),proteins:this.round(p),fats:this.round(b),carbohydrates:this.round(j),weight:this.round(g),proteinsPercent:o,caloriesPercent:a,fatsPercent:l,carbohydratesPercent:k};return{items:d,summary:h}},recalculateProductFor100gram:function(a){a.calories=this.calculateFor100gram(a.weight,a.calories);a.proteins=this.calculateFor100gram(a.weight,a.proteins);a.fats=this.calculateFor100gram(a.weight,a.fats);a.carbohydrates=this.calculateFor100gram(a.weight,a.carbohydrates)},calculateFor100gram:function(b,a){return this.round(Number(b)*Number(a)/100)},getPercent:function(b,a){value=Number(a)/Number(b)*100;return this.round(value)},round:function(a){return Math.round(100*a)/100}};var CalorySummary=Class.create();CalorySummary.prototype={initialize:function(a){this.manager=a;this.rowToClone=$("summaryRowToClone");this.summaryItems=$("sItems");this.table=this.summaryItems.parentNode;this.table.onclick=this.onTableClick.bindAsEventListener(this);this.footer=$("sFoot");this.proteins=$("sProteins");this.fats=$("sFats");this.carbohydrates=$("sCarbohydrates");this.weight=$("sWeight");this.calories=$("sCalories");this.proteinsPercent=$("sProteinsPercent");this.fatsPercent=$("sFatsPercent");this.carbohydratesPercent=$("sCarbohydratesPercent");this.proteins=$("sProteins");this.btnRemoveAllItems=$("removeAll");Event.observe(document.body,"mousemove",this.lightDeleteBtns.bindAsEventListener(this));this.btnRemoveAllItems.onclick=this._onRemoveAllProducts.bind(this)},_onRemoveAllProducts:function(){this.manager.onRemoveAllProducts()},lightDeleteBtns:function(b){var a=Event.element(b)==this.btnRemoveAllItems;$(this.summaryItems).select(".b-calc-te-clear").each(function(c){c=$(c);if(a){c.addClassName("b-calc-te-clear-hover")}else{c.removeClassName("b-calc-te-clear-hover")}})},onTableClick:function(b){var a=$(Event.element(b));if(!a.hasClassName("b-calc-te-clear")){return}if(this.onRemoveRow){this.onRemoveRow(a.parentNode.getAttribute("uid"))}},setValue:function(a,b){if(b==""||b==0){a.innerHTML="0,00";Element.addClassName(a,"b-calc-te-light");return}Element.removeClassName(a,"b-calc-te-light");a.innerHTML=b.toString().replace(".",",")},update:function(b){var a=b.summary;this.setValue(this.proteins,a.proteins);this.setValue(this.fats,a.fats);this.setValue(this.carbohydrates,a.carbohydrates);this.setValue(this.weight,a.weight);this.setValue(this.calories,a.calories);this.setValue(this.proteinsPercent,a.proteinsPercent);this.setValue(this.fatsPercent,a.fatsPercent);this.setValue(this.carbohydratesPercent,a.carbohydratesPercent);this.updateItems(b.items);this.table.style.display=""},hide:function(){this.table.style.display="none"},clearTable:function(){this.table.removeChild(this.summaryItems);this.summaryItems=document.createElement("tbody");this.table.insertBefore(this.summaryItems,this.footer)},updateItems:function(a){this.clearTable();rows=[];for(var c=0;c<a.length;c++){product=a[c];var b=this.rowToClone.cloneNode(true);this.summaryItems.appendChild(b);b.id="";tds=b.getElementsByTagName("td");tds[0].setAttribute("uid",product.uid);this.setValue(tds[1],product.title);this.setValue(tds[2],product.weight);this.setValue(tds[4],this.getCalculatedValue(product.proteins,product.weight));this.setValue(tds[6],this.getCalculatedValue(product.fats,product.weight));this.setValue(tds[8],this.getCalculatedValue(product.carbohydrates,product.weight));this.setValue(tds[10],this.getCalculatedValue(product.calories,product.weight));b.removeAttribute("style")}},getCalculatedValue:function(f,c){var a=parseFloat((f=="")?0:f);var d=100;var b=Math.round(a*c)/d;var b=(Math.ceil(b)==b)?b.toFixed(1):b;return b}};var CalendarManager=Class.create();CalendarManager.prototype={initialize:function(a,b){this.counter=0;this.calendars=new Array();this.calendar_field_names=a;if(b==null){this.use_year=true}else{this.use_year=b}this.initCalendars()},initCalendars:function(){$A(this.calendar_field_names).each(function(b){var a=$(b.id);if(a){this.addCalendar(a,b.type)}}.bind(this))},setEvents:function(){Event.observe(window,"load",this.initCalendars.bind(this))},addCalendar:function(a,d){if(!this.use_year||document.location.pathname.split("/")[1]=="admin"){var c=new FeelGoodCalendar(a,d,this.counter++,this.setCalenarDate.bind(this),this.use_year);this.calendars.push(c);return}var b=$(a.parentNode).getElementsByClassName("b-choose-date-link")[0];var f=new MashCalendar(b,a);if(d=="filter"){f.onDateChoosed=function(h){var g=h.getMonth()+1;var j=h.getDate();g=(g<10?"0":"")+g;j=(j<10?"0":"")+j;window.location.href=_url_for_view+"/"+h.getFullYear()+"/"+g+"/"+j+"/";return true}}},setCalenarDate:function(f,a,c,b){this.calendars[b].setDate(f,a,c)}};var RatingVoter=Class.create();RatingVoter.prototype={initialize:function(){this.rateCont=$("rating_container");this.fillClass="filled";this.form=$("ratingform");this.links=$$(".b-rating-votes-lk");this.template=new Template('<span class="b-rating-rate">#{rate}</span><span class="b-rating-voters">#{vote}</span>');this.setEventListeners()},setEventListeners:function(){if(!this.form){return}this.form.onmouseout=this.fillHearts.bind(this,false,5,false);this.links.each(function(a){a.onmouseover=this.setRating.bindAsEventListener(this);a.onclick=this.saveRating.bindAsEventListener(this)}.bind(this))},resetRating:function(){var a=$$("."+this.fillClass);a.each(function(b){b.removeClassName(this.fillClass)}.bind(this))},setRating:function(h){var d=Event.element(h);var g=this.links.indexOf(d)+1;var c=Event.pointerX(h);var b=d.offsetLeft;var j=Event.pointerY(h);var a=d.offsetTop;var f=Math.abs(j-a)<d.getHeight();this.fillHearts(c>b,g,f)},fillHearts:function(a,b,d){if(d){this.links[b-1].addClassName(this.fillClass);return}else{for(var c=0;c<b;c++){if(a){this.links[c].addClassName(this.fillClass)}else{this.links[c].removeClassName(this.fillClass)}}}},saveRating:function(c){var b=Event.element(c);var d={rate:b.id.replace("heart__","")};var a=this.form.action;Tools.send(a,this.onSavedRating.bind(this),null,d)},onSavedRating:function(a){var b=a.responseText.evalJSON();var c=this.template.evaluate(b);Element.remove(this.form);this.rateCont.innerHTML=c}};var MashCalendarRenderer=Class.create({initialize:function(){this.monthTableTemplate=new Template(CALENDAR_MONTH_TABLE);this.dayTemplate=new Template('<td id="#{ymd}" #{weekend}><a href="javascript:void(0);">#{day}</a></td>');this.calendarTemplate=new Template(CALENDAR_TEMPLATE);this.yearTemplate=new Template('<li><a href="javascript:void(0);">#{year}</a></li>');this.yearRangeTemplate=new Template('<option value="#{from}_#{to}">#{from} &mdash; #{to}<i></i></option>');this.returnToYearTemplate=new Template('<a class="caption-year" href="javascript:void(0)"><span class="b-calendar-sign">←</span>оставить #{year}\'й</a>')},render:function(b,f){var d=this.renderMonth(b);var c=this.renderYearsRange(b.getFullYear());var a=this.calendarTemplate.evaluate({calendar_id:f,table:d,ranges:c});return a},renderMonth:function(b){var a=this.renderDays(b);var c=this.monthTableTemplate.evaluate({days:a,currentDayMonth:Tools.dateToString(b,true),currentYear:this.getCaption(b)});return c},getCaption:function(a){if(this.onGetCaption){return this.onGetCaption(a)}return a.getFullYear()},_renderMonthOffset:function(c){var a=[];for(var b=1;b<c;b++){a.push("<td></td>")}return a.join("")},renderDays:function(d){var j=d.getMonth();var o=new Date(d.getFullYear(),j,1);var b='class="holidays"';var g=["<tr>"];var n=o.getDay();if(n==0){n=7}g.push(this._renderMonthOffset(n));while(o.getMonth()==j){var a=Tools.dateTo_ymd(o);var l=o.getDate();var c=o.getDay();var h=c==0;var k=c==6||c==0;var f="";if(this.onGetDay){f=this.onGetDay(o,a,l)}if(f==""){f=this.dayTemplate.evaluate({ymd:a,day:l,weekend:k?b:""})}g.push(f);if(h){g.push("</tr><tr>")}o=Tools.addDaysToDate(o,1)}if(o.getDate>29){g.push(this._renderMonthOffset(6-o.getDay()))}if(g[g.length-1]!="</tr>"){g.push("</tr>")}return g.join("")},createRangesArray:function(d){var a=[];var h=d-89;var g=d+10;var c=0;var b={from:h};for(var f=h;f<=g;f++){if(c==0){b={from:f}}if(c==9){b.to=f;a.push(b);c=-1}c++}return a.reverse()},renderYearsRange:function(d){var b=this.createRangesArray(d);var a=[];for(var f=0;f<b.length;f++){var c=b[f];a.push(this.yearRangeTemplate.evaluate(c))}return a.join("")},renderYearsOfRange:function(d,c){var a=[];for(var b=d;b<c;b++){a.push(this.yearTemplate.evaluate({year:b}))}return a.reverse().join("")},renderReturnToYear:function(a){return this.returnToYearTemplate.evaluate({year:a})}});var MashCalendar=Class.create({onDateChoosed:null,initialize:function(c,b,a){this.elToSetDate=$(b);this.btn=$(c);if(this.btn){Event.observe(this.btn,"click",this.show.bindAsEventListener(this))}this._hide=this.hide.bindAsEventListener(this);this.renderer=new MashCalendarRenderer();this.container=a;this.date=window.SERVER_DATE_JS?window.SERVER_DATE_JS:new Date();this.parseElToSetDateValue();this.id=Tools.getUniqueId();this.firstTime=true;this.render()},parseElToSetDateValue:function(){if(!this.elToSetDate||!this.elToSetDate.value){return}var a=this.elToSetDate.value.split("-");var b=Tools.parse01Digit(a[2]);if(b<25){b=b+2000}else{b=b+1900}this.date=new Date(b,Tools.parse01Digit(a[1])-1,Tools.parse01Digit(a[0]))},getContainer:function(){if(this.container){return this.container}var a=$("_calendarHolder");if(!a){$(document.body).insert({bottom:"<div style='position:relative' id='_calendarHolder'></div>"})}return $("_calendarHolder")},render:function(){var a=this.renderer.render(this.date,this.id);$(this.getContainer()).insert({bottom:a});this.bindAsEventListener();this.previousMonth=null;this.selectMonthInList(this.date.getMonth());this.onSelectRange()},bindAsEventListener:function(){this.el=$(this.id);this.monthesEl=this.el.getElementsBySelector(".b-calendar-months ul")[0];this.monthesEl.onclick=this._onMonthClick.bindAsEventListener(this);this.monthesElems=$A(this.monthesEl.getElementsByTagName("li"));this.navEl=this.el.getElementsBySelector(".b-calendar-nav ul")[0];this.navEl.onclick=this._onNavClick.bindAsEventListener(this);this.navElems=$A(this.navEl.getElementsByTagName("a"));this.monthTableContainer=this.el.getElementsByClassName("calendar2")[0];this.monthTableContainer.onclick=this._onMonthTableClick.bindAsEventListener(this);this.yearCaption=this.el.getElementsByTagName("caption")[0];this.monthMode=true;this.yearsEl=this.el.getElementsBySelector(".b-calendar-years ul")[0];this.yearsEl.onclick=this._onYearClick.bindAsEventListener(this);this.rangeSelect=this.el.getElementsBySelector(".b-calendar-years-period select")[0];this.rangeSelect.onchange=this.onSelectRange.bindAsEventListener(this);if(Tools.IE6){this.el.style.visibility="hidden";this.el.style.display="block";Tools.insertIE6Iframe(this.el,{width:this.el.clientWidth-2,height:this.el.clientHeight-2,top:0,left:0});this.el.style.visibility="";this.el.style.display="none"}},_onNavClick:function(c){var b=Event.element(c);if(b.tagName!="A"){return}var d=this.navElems.indexOf(b)-1;var a=Tools.addDaysToDate(new Date(),d);this._setDatefireEventAndClose(a);Event.stop(c)},_onYearClick:function(c){var b=Event.element(c);if(b.tagName!="A"){return}Event.stop(c);var a=parseInt(b.innerHTML);this.date=new Date(a,0,1);this.showRanges()},onSelectRange:function(c){var a=$F(this.rangeSelect).split("_");var b=this.renderer.renderYearsOfRange(parseInt(a[0]),parseInt(a[1])+1);this.yearsEl.innerHTML=b},showRanges:function(){var a=this.monthMode;Tools.show(this.yearsEl.parentNode,a);Tools.show(this.rangeSelect.parentNode,a);if(a){this.yearCaption.innerHTML=this.renderer.renderReturnToYear(this.date.getFullYear())}else{this._setDate(this.date)}Tools.hide(this.monthesEl.parentNode,a);this.monthMode=!a},selectMonth:function(b){var a=new Date(this.date.getFullYear(),b,1);this._setDate(a)},selectMonthInList:function(b){var a=this.monthesElems[this.previousMonth!=null?this.previousMonth:b];Tools.enableDashedLink(a);Tools.disableDashedLink(this.monthesElems[b],true);this.previousMonth=b},_setDate:function(a){var b=this.renderer.renderMonth(a);this.selectMonthInList(a.getMonth());this.monthTableContainer.innerHTML=b;this.yearCaption=this.el.getElementsByTagName("caption")[0]},setDate:function(a){this.date=a},getDate:function(){return this.date},_onMonthClick:function(c){var a=Event.element(c);if(a.tagName!="A"){return}var b=this.monthesElems.indexOf(a.parentNode);this.selectMonth(b);Event.stop(c)},_onMonthTableClick:function(b){var a=Event.element(b);if(a.tagName!="A"){return}Event.stop(b);if(a.parentNode.tagName=="TD"){return this._onDayClick(a)}if(a.className=="caption-year"){this.showRanges()}},_onDayClick:function(c){var b=c.parentNode.id.split(".");var a=new Date(parseInt(b[0]),parseInt(b[1])-1,parseInt(b[2]));this._setDatefireEventAndClose(a)},_setDatefireEventAndClose:function(a){var b=false;this.date=a;if(this.onDateChoosed){b=this.onDateChoosed(a)}if(b){return}this._setElValue(a);this.hide()},_setElValue:function(a){if(this.elToSetDate){this.elToSetDate.value=a.getDate()+"-"+a.getMonth()+"-"+a.getFullYear()}this.getElToShowDate().innerHTML=Tools.dateToString(a)},getElToShowDate:function(){return this.btn},hide:function(a){if(a){if(Event.findElement(a,".b-calendar")){return}}Event.stopObserving(document.body,"click",this._hide);this.el.style.display="none"},show:function(a){if(a){Event.stop(a)}Event.observe(document.body,"click",this._hide);this.monthMode=true;if(!this.firstTime){}this._setDate(this.date);this.el.style.display="block";this.firstTime=false;this.el.clonePosition(this.btn,{setWidth:false,setHeight:false,offsetTop:Prototype.Browser.IE?30:20});return false}});var MensesCalendarDialog=Class.create();MensesCalendarDialog.prototype={initialize:function(){this.el=$("add_note_dialog");this.title=this.el.select(".dialog-header-center")[0];this.note=$("new_note");this.btnSave=$("btnSaveMenseDay");this.btnDelete=$("btnDeleteMenseDay");this.el.select(".dialog-close-btn")[0].onclick=this.fireOnClose.bindAsEventListener(this);this.btnDelete.onclick=this.fireOnDelete.bindAsEventListener(this);this.btnSave.onclick=this.fireOnSave.bindAsEventListener(this);this.keyup=this._onKeyUp.bindAsEventListener(this);this.el.onclick=function(a){Event.stop(a)}.bindAsEventListener(this)},show:function(b,d,c,a){Event.observe(document.body,"keyup",this.keyup);this.el.clonePosition(b,{setWidth:false,setHeight:false,offsetTop:45});this.note.value="";if(d){this.note.value=d.unescapeHTML()}this.title.innerHTML=c;this.el.style.display="block";this.btnDelete.style.display=a?"inline":"none";this.note.focus()},fireOnClose:function(a){if(this.onClose){this.onClose(a)}this.hide()},fireOnDelete:function(){if(this.onDelete){this.onDelete()}this.hide()},fireOnSave:function(){var a=this.note.value.escapeHTML();if(this.onSave){this.onSave(a)}this.hide()},hide:function(){Event.stopObserving(document.body,"keyup",this.keyup);this.el.hide()},_onKeyUp:function(a){if(a.keyCode==27){this.fireOnClose(a)}}};var MensesXmlGenerator=Class.create({initialize:function(b){this.days=b;var a='<?xml version="1.0" encoding="UTF-8"?><root><mense><starts year="#{start_year}" month="#{start_month}" day="#{start_day}"></starts><ends year="#{end_year}" month="#{end_month}" day="#{end_day}"></ends></mense><notes>#{notes_xml}</notes></root>';this.docTemplate=new Template(a);a='<note year="#{year}" month="#{month}" day="#{day}">#{note_text}</note>';this.noteTemplate=new Template(a)},daysToArray:function(){var a=[];for(day in this.days){a.push({date:Tools.ymd_ToDate(day),note:this.days[day]})}Tools.sortDateArr(a);return a},generate:function(){var b=this.daysToArray();var c=b[0].date;var a=b[b.length-1].date;return this.docTemplate.evaluate({start_year:c.getFullYear(),start_month:c.getMonth()+1,start_day:c.getDate(),end_year:a.getFullYear(),end_month:a.getMonth()+1,end_day:a.getDate(),notes_xml:this.getNotesXML(b)})},getNotesXML:function(b){var a=[];$A(b).each(function(f){var c=f.date;var d=f.note;if(d!=""){a.push(this.noteTemplate.evaluate({year:c.getFullYear(),month:c.getMonth()+1,day:c.getDate(),note_text:Base64.encode(d)}))}}.bind(this));return a.join("")}});var MensesStatisticPageManager=Class.create({initialize:function(){this.yearsEl=$("yearsEl");if(!this.yearsEl){return}if(!M_READ_ONLY){this.accessManager=new ExpertAccessManager(document.location.href,"")}this.selectedCls="b-messtat-content-head-span-current";this.selectedYearEl=this.yearsEl.select("."+this.selectedCls)[0];this.yearsEl.onclick=this.changeYear.bindAsEventListener(this);this.statisticRowsEl=$("statisticRowsEl")},changeYear:function(d){var c=Event.findElement(d,".b-messtat-content-head-span");if(!c){return}if(c==this.selectedYearEl){return}this.selectedYearEl.removeClassName(this.selectedCls);var a=this.selectedYearEl.down("span").innerHTML;c.addClassName(this.selectedCls);this.selectedYearEl=c;var b=c.down("span").innerHTML;this.statisticRowsEl.select("[year="+a+"]").each(function(f){f.style.display="none"});this.statisticRowsEl.select("[year="+b+"]").each(function(f){f.style.display=""})}});function RecipeFilterProduct(){}RecipeFilterProduct.filter=function(b,d,c){var a=b;if(c||d){a+="?"}if(c){a+="dish="+c}if(d){if(c){a+="&"}a+="product="+d}window.location=a};var MensesManager=Class.create();MensesManager.prototype={initialize:function(){this.dayCounter=1;this.leftCalendar=new MCalendar(this,"leftCalendar",YEAR_OF_MENSE,MONTH_OF_MENSE);this.rightCalendar=new MCalendar(this,"rightCalendar",YEAR_OF_MENSE,MONTH_OF_MENSE+1);this.calendars=[this.leftCalendar,this.rightCalendar];this.pleaseStart=$("pleaseStart");this.selectDaysOnCalendar=$("selectDaysOnCalendar");this.calendarsPrint=$("calendars_print");if(!READ_ONLY){this.addEvent("onChangeMonth",this.changeMonth);this.addEvent("onDayClick",this.onDayClick);this.calendarDialog=new MensesCalendarDialog();this.calendarDialog.onSave=this.onSaveDay.bind(this);this.calendarDialog.onDelete=this.onDeleteDay.bind(this);this.xmlGenerator=new MensesXmlGenerator(MENSE_JSON);this.btnDelete=$("btnDelete");this.btnDelete.onclick=this.deleteMense.bind(this,true);this.updateControlsState()}this.commentTemplate=new Template('<li class="b-item"><h4 class="b-date">#{dayMonth}</h4><p class="b-comment">#{comment}</p></li>');this.commentsContainer=$("commentsContainer");this.comments=$("comments");this.renderComments();var a=$$(".b-rating-a")[0];a.onclick=this.print.bind(this)},addEvent:function(a,b){this.calendars.each(function(d){d[a]=b.bind(this,d)}.bind(this))},changeMonth:function(b,a){this.dayCounter=1;this.leftCalendar._setDate(Tools.addMonthToDate(this.leftCalendar.date,a));this.rightCalendar._setDate(Tools.addMonthToDate(this.rightCalendar.date,a))},updateCalendars:function(){var a=this.isFirstDayOnRightCalendar?1:0;this.changeMonth(null,a)},elIsSelected:function(b,a){var c=Tools.dateTo_ymd(Tools.addDaysToDate(b,a));return MENSE_JSON[c]!=null},gaysCount:function(){var a=0;for(ymd in MENSE_JSON){a++}return a},onDayClick:function(l,a,d,h){var f=Tools.ymd_ToDate(a);var g=this.elIsSelected(f,1)||this.elIsSelected(f,-1);var o=this.gaysCount();var n=(!g&&o==1&&h);if(!g&&o!=0&&!n){return}this.isFirstDayOnRightCalendar=o==0&&this.calendars.indexOf(l)==1;var b=Tools.dateToString(f,true);var k=MENSE_JSON[a];var j=h&&(!this.elIsSelected(f,1)||!this.elIsSelected(f,-1));this.current_ymd=a;this.calendarDialog.show(d,k,b,j)},update:function(){this.updateCalendars();this.renderComments();this.updateControlsState();this.save()},updateControlsState:function(){var a=this.gaysCount()==0;this.btnDelete.disabled=a;this.pleaseStart.style.display=a?"block":"none";this.selectDaysOnCalendar.style.display=a?"none":"block";this.calendarsPrint[a?"removeClassName":"addClassName"]("h-hide-prev-next")},onSaveDay:function(a){MENSE_JSON[this.current_ymd]=a;this.update()},onDeleteDay:function(){delete MENSE_JSON[this.current_ymd];this.update()},renderComments:function(){var a=[];var f=[];for(ymd in MENSE_JSON){var d=MENSE_JSON[ymd];if(d!=""){f.push({comment:d,date:Tools.ymd_ToDate(ymd)})}}Tools.sortDateArr(f,true);for(var c=0;c<f.length;c++){var b=f[c];b.dayMonth=Tools.dateToString(b.date,true);a.push(this.commentTemplate.evaluate(b))}this.comments.innerHTML=a.join("");return this.commentsContainer.style.display=f.length>0?"block":"none"},save:function(){if(this.gaysCount()==0){this.deleteMense(false);return}var a=this.xmlGenerator.generate();if(a!=""){this.sendSaveMenseRequest(a)}},deleteMense:function(a){if(a&&!confirm(ARE_YOU_SURE_WANT_TO_DETELE_CALENDAR)){return}this.btnDelete.disabled=a;Tools.send(SAVE_MENSE_LINK+MENSE_ID,this.onDeleteResponse.bind(this,a),null,{"delete":""})},onDeleteResponse:function(c,a){if(a.responseText=="ERROR"){Tools.showError();return}var b=a.responseText.evalJSON();MENSE_ID=0;if(c){document.location.href="/health/mensescalendar/"+USERNAME+"/"}},sendSaveMenseRequest:function(a){Tools.send(SAVE_MENSE_LINK+MENSE_ID,this.onSaveMenseResponse.bind(this),null,{data:a})},onSaveMenseResponse:function(a){if(a.responseText=="ERROR"){Tools.showError();return}var d=a.responseText.evalJSON();if(d.id){MENSE_ID=d.id;return;var b=top.location.href;var c=b.split("/");c.splice(c.length-2,2);b=c.join("/");top.location.href=b+"/"+d.id}},print:function(){var b=$("calendars_print").innerHTML;var d=$("comments_print");var a=d.down("div").style.display!="none"?d.innerHTML:"";w=window.open(document.location.href+"?print");var c=function(){var f=function(h,g){w.document.getElementById(h).innerHTML=g};f("calendars_print",b);f("comments_print",a)};w.onloaded=c;window.printData=w.onloaded}};var MCalendar=Class.create(MashCalendar,{initialize:function($super,b,a,c,d){this.manager=b;this.renderer=new MashCalendarRenderer();this.renderer.onGetCaption=this.getYearMonth.bind(this);this.renderer.onGetDay=this.getDay.bind(this);this.container=$(a);this.container.onclick=this.onCalendarClick.bindAsEventListener(this);this.date=new Date(c,d-1,1);this.id=Tools.getUniqueId();this.firstTime=true;this.yearTemplate=new Template("<div class='calendar-caption'><span class='prev'>← #{prev}</span><span class='year'>#{year}</span><span class='next'>#{next} →</span></div>");if(READ_ONLY){this.yearTemplate=new Template("<div class='calendar-caption'><span class='year'>#{year}</span></div>")}this.selectedDayTemplate=new Template('<td id="#{ymd}" class="#{cls}">#{dayNum}<a href="javascript:void(0);">#{day}</a></td>');this.dayNumTemplate=new Template('<div class="sup">#{day}</div>');this.commentIcon="<i class='note_icon'></i>";this.render()},show:function(){this.monthMode=true;this._setDate(this.date);this.firstTime=false},selectMonthInList:function(){},onSelectRange:function(){},bindAsEventListener:function(){if(READ_ONLY){return}this.el=this.container.select(".calendar")[0];this.prev=this.el.select(".prev")[0];this.next=this.el.select(".next")[0];this.prev.onclick=this.changeMonth.bind(this,-1);this.next.onclick=this.changeMonth.bind(this,1)},changeMonth:function(a){if(this.onChangeMonth){this.onChangeMonth(a)}},_setDate:function(a){this.date=a;var b=this.renderer.renderMonth(a);this.el.innerHTML=b;this.bindAsEventListener()},getYearMonth:function(b){var a=MONTHES[b.getMonth()]+" "+b.getFullYear();var c=Tools.addMonthToDate(b,1).getMonth();var d=Tools.addMonthToDate(b,-1).getMonth();return this.yearTemplate.evaluate({year:a,prev:MONTHES[d],next:MONTHES[c]})},onCalendarClick:function(d){if(READ_ONLY){return}var b=Event.findElement(d,"td>a");if(!b){return}var f=$(b.parentNode);if(f.hasClassName("occupied")){return}var c=f.id;var a=f.hasClassName("selected_pink");if(this.onDayClick){this.onDayClick(c,f,a)}},getDay:function(b,f,a){var d=MENSE_JSON[f];var j=d!=null;if(j){var h=this.dayNumTemplate.evaluate({day:this.manager.dayCounter});if(d!=""){a=this.commentIcon+a}var g=this.selectedDayTemplate.evaluate({ymd:f,day:a,cls:"selected_pink",dayNum:h});this.manager.dayCounter++;return g}var c=OTHER_MENSE_JSON.indexOf(f)!=-1;if(c){return this.selectedDayTemplate.evaluate({ymd:f,day:a,cls:"occupied",dayNum:""})}return""}});var Drag={obj:null,init:function(d,j,g,b,f,a,k,h,l,c){d.onmousedown=Drag.start;d.hmode=k?false:true;d.vmode=h?false:true;d.root=j&&j!=null?j:d;if(d.hmode&&isNaN(parseInt(d.root.style.left))){d.root.style.left="0px"}if(d.vmode&&isNaN(parseInt(d.root.style.top))){d.root.style.top="0px"}if(!d.hmode&&isNaN(parseInt(d.root.style.right))){d.root.style.right="0px"}if(!d.vmode&&isNaN(parseInt(d.root.style.bottom))){d.root.style.bottom="0px"}d.minX=typeof g!="undefined"?g:null;d.minY=typeof f!="undefined"?f:null;d.maxX=typeof b!="undefined"?b:null;d.maxY=typeof a!="undefined"?a:null;d.xMapper=l?l:null;d.yMapper=c?c:null;d.root.onDragStart=new Function();d.root.onDragEnd=new Function();d.root.onDrag=new Function()},start:function(b){var c=Drag.obj=this;b=Drag.fixE(b);var d=parseInt(c.vmode?c.root.style.top:c.root.style.bottom);var a=parseInt(c.hmode?c.root.style.left:c.root.style.right);c.root.onDragStart(a,d);c.lastMouseX=b.clientX;c.lastMouseY=b.clientY;if(c.hmode){if(c.minX!=null){c.minMouseX=b.clientX-a+c.minX}if(c.maxX!=null){c.maxMouseX=c.minMouseX+c.maxX-c.minX}}else{if(c.minX!=null){c.maxMouseX=-c.minX+b.clientX+a}if(c.maxX!=null){c.minMouseX=-c.maxX+b.clientX+a}}if(c.vmode){if(c.minY!=null){c.minMouseY=b.clientY-d+c.minY}if(c.maxY!=null){c.maxMouseY=c.minMouseY+c.maxY-c.minY}}else{if(c.minY!=null){c.maxMouseY=-c.minY+b.clientY+d}if(c.maxY!=null){c.minMouseY=-c.maxY+b.clientY+d}}document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false},drag:function(f){f=Drag.fixE(f);var g=Drag.obj;var c=f.clientY;var d=f.clientX;var j=parseInt(g.vmode?g.root.style.top:g.root.style.bottom);var b=parseInt(g.hmode?g.root.style.left:g.root.style.right);var a,h;if(g.minX!=null){d=g.hmode?Math.max(d,g.minMouseX):Math.min(d,g.maxMouseX)}if(g.maxX!=null){d=g.hmode?Math.min(d,g.maxMouseX):Math.max(d,g.minMouseX)}if(g.minY!=null){c=g.vmode?Math.max(c,g.minMouseY):Math.min(c,g.maxMouseY)}if(g.maxY!=null){c=g.vmode?Math.min(c,g.maxMouseY):Math.max(c,g.minMouseY)}a=b+((d-g.lastMouseX)*(g.hmode?1:-1));h=j+((c-g.lastMouseY)*(g.vmode?1:-1));if(g.xMapper){a=g.xMapper(j)}else{if(g.yMapper){h=g.yMapper(b)}}Drag.obj.root.style[g.hmode?"left":"right"]=a+"px";Drag.obj.root.style[g.vmode?"top":"bottom"]=h+"px";Drag.obj.lastMouseX=d;Drag.obj.lastMouseY=c;Drag.obj.root.onDrag(a,h);return false},end:function(){document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));Drag.obj=null},fixE:function(a){if(typeof a=="undefined"){a=window.event}if(typeof a.layerX=="undefined"){a.layerX=a.offsetX}if(typeof a.layerY=="undefined"){a.layerY=a.offsetY}return a}};var DialogWidget=Class.create();DialogWidget.prototype={initialize:function(c,a,d,b,f){this.freeze=f;this.dialogEl=$(c);this.bottomCenterBorder=this.el("dialog-bottom-center");this.headerCenterBorder=this.el("dialog-header-center");img=new Image();img.src="/media/img/admin/closedhand.png";this.contentHeight=d;this.contentWidth=a;this.btnCloseDialog=this.el("dialog-close-btn");this.btnCloseDialog.onclick=this.hide.bindAsEventListener(this);this.keyup=this._onKeyUp.bindAsEventListener(this);if(!this.freeze){Event.observe(this.headerCenterBorder,"mousedown",function(){Element.addClassName(this.headerCenterBorder,"move-cursor")}.bind(this));Event.observe(this.headerCenterBorder,"mouseup",function(){Element.removeClassName(this.headerCenterBorder,"move-cursor")}.bind(this));Drag.init(this.headerCenterBorder,this.dialogEl)}this.opener=true;this.closeByOutClick=false;if(b){return}Event.observe(this.dialogEl,"keypress",function(h){if(!h){h=window.event}var g=h.keyCode?h.keyCode:h.charCode;if(g!=Event.KEY_RETURN){return false}Event.stop(h);if(this.onEnterPress){this.onEnterPress(this)}}.bindAsEventListener(this))},isOpener:function(a){if(this.opener.constructor&&this.opener.constructor.toString().indexOf("Array")>-1){return this.opener.indexOf(a)>-1}return this.opener==a},onclick:function(b){var a=Event.element(b);if(a.descendantOf(this.dialogEl)||this.isOpener(a)){return}this.hide()},_onKeyUp:function(b){if(!b){b=window.event}var a=b.keyCode?b.keyCode:b.charCode;if(a==Event.KEY_ESC&&this.hide){this.hide()}},el:function(a){return Tools.fgGetElementByClassName(a,this.dialogEl)[0]},setPosition:function(){this.dialogEl.style.visibility="hidden";this.dialogEl.style.display="block";if(this.freeze){this.dialogEl.style.left="440px";this.dialogEl.style.top="145px"}else{var c=document.viewport.getScrollOffsets();var a=document.viewport.getDimensions();var b=-this.dialogEl.clientHeight/2+a.height/2+c.top;this.dialogEl.style.left=-this.dialogEl.clientWidth/2+a.width/2+c.left+"px";this.dialogEl.style.top=(b>0?b:40)+"px"}},show:function(){this.setPosition();if(this.onShow){this.onShow(this)}Event.observe(document.body,"keyup",this.keyup);if(this.closeByOutClick){Event.observe(document,"click",this.onclick.bindAsEventListener(this))}if(!this.firstAppear){this.calculateWidth();var IE6=false
/*@cc_on || @_jscript_version < 5.7 @*/
;if(IE6){this.customizeForIe6()}this.firstAppear=true}this.dialogEl.style.visibility=""},customizeForIe6:function(){var d=this.el("dialog-content-right");if(d){d.style.height=this.contentHeight+"px"}var c=this.el("dialog-content-left");if(c){c.style.height=this.contentHeight+"px"}var b=this.el("dialog-content");if(b){b.style.width="0px"}var a=this.el("dialog-header");if(a){a.style.width="0px"}this.calculateWidth(this.contentWidth+14)},calculateWidth:function(a){calcWidth=this.calculateWidth.bind(this);if(!a){a=this.dialogEl.clientWidth}if(this.bottomCenterBorder){this.bottomCenterBorder.style.width=a-24+"px";this.bottomCenterBorder.parentNode.style.width=a-14+"px";this.headerCenterBorder.style.width=a-24+5+"px"}},hide:function(){if(this.onHide){this.onHide(this)}Event.observe(this.headerCenterBorder,"mouseup",function(){Element.removeClassName(this.headerCenterBorder,"move-cursor")}.bind(this));this.dialogEl.style.display="none";Event.stopObserving(document.body,"keyup",this.keyup);if(this.closeByOutClick){Event.stopObserving(document,"click",this.onclick.bind(this))}}};var BtManager=Class.create();BtManager.prototype={initialize:function(c,a){this.initial_page=a;if(a){this.chart={points:{}};return this.createInitialData()}this.chart=new BtChart();this.chart.onChartChange=this.saveChart.bind(this);this.chartContainer=$("chartContainer");if(!bt_read_only){this.btnDelete=$("btnDelete");this.btnDelete.onclick=this.deleteChart.bindAsEventListener(this)}var b=$$(".b-rating-a")[0];b.href="javascript:void(0);";b.onclick=this.printChart.bind(this);if(c!=""&&c){this.createChart(c);if(!bt_read_only){this.accessManager=new ExpertAccessManager(SAVE_BT_CHART_LINK,window.chartId)}return}},createInitialData:function(){this.initialData=new BtInitialData(this);this.initialData.onChange=this.validateInitialData.bind(this);if(this.initial_page){return this.initialData.onCreateChart=this.createChartAndRedirect.bind(this)}this.initialData.onCreateChart=this.onCreateChartClicked.bind(this)},onCreateChartClicked:function(){this.createChart(this.initialData.getData())},createChart:function(a){this.data=a;this.chart.render(a);this.chartContainer.style.display="block"},validateInitialData:function(b,c){this.data=b;var a=this.generateXml();Tools.send(GET_CHARTS_IN_RANGE,function(d){return c(d.responseText.evalJSON())}.bind(this),null,{data:a,id:this.chartId})},createChartAndRedirect:function(){this.data=this.initialData.getData();this.saveChart()},saveChart:function(){if(this.btnSaveChart){this.btnSaveChart.disabled=true}var a=this.generateXml();Tools.send(SAVE_BT_CHART_LINK,function(f){var c=f.responseText.evalJSON();var b=!this.chartId;var d=c.id;if(b&&d){this.chartId=c.id;this.redirectToPageWithChart()}if(!d){this.showChartsWithThisDataRange(c)}}.bind(this),null,{data:a,id:this.chartId})},deleteChart:function(){if(!confirm(ARE_YOU_SURE_WANT_TO_DETELE_CHART)){return}this.btnDelete.disabled="true";Tools.send(SAVE_BT_CHART_LINK,function(b){var a=b.responseText.evalJSON();if(a){document.location.href="/health/bazaltemperature/"+USERNAME+"/"}}.bind(this),null,{id:this.chartId,"delete":""})},showChartsWithThisDataRange:function(a){},redirectToPageWithChart:function(){document.location.href=this.getUrlByDate(this.data.date)},getUrlWithoutDate:function(){return document.location.href.replace(/\d\d-\d\d-\d\d\d\d\//,"")},getUrlByDate:function(b){var a=b.getDate()<10?"0"+b.getDate():b.getDate();var c=(b.getMonth()+1);c=c<10?"0"+c:c;var d=this.getUrlWithoutDate();return d+a+"-"+c+"-"+b.getFullYear()+"/"},generateXml:function(){this.data.date_ymd=Tools.dateTo_ymd(this.data.date);var a=['<?xml version="1.0" encoding="UTF-8"?>'];a.push(new Template("<chart cycle_first_day='#{date_ymd}' menstruation='#{menstruation}' cycle='#{cycle}'>").evaluate(this.data));var b=new Template("<point note='#{note}' top='#{rectTop}' left='#{rectLeft}' temperature='#{temperature}' date='#{date_ymd}'/>");for(point in this.chart.points){var c=this.chart.points[point];c.note=Base64.encode(c.comment);a.push(b.evaluate(c))}a.push("</chart>");return a.join("")},printChart:function(){var f=$("chartComments");var a=$("chartRange").innerHTML;var b=$$(".b-chart-container")[0].innerHTML;var d=f.style.display!="none"?f.innerHTML:"";w=window.open(this.getUrlWithoutDate()+"?print");var c=function(){var g=function(j,h){w.document.getElementById(j).innerHTML=h};g("chartRange",a);g("chartContainer",b);g("chartComments",d)};w.onloaded=c;window.printData=w.onloaded}};var BT_COLUMN_WIDTH=17;var BT_ROWS=21;var BT_CHART_PADDING=67;var BtChart=Class.create();BtChart.prototype={initialize:function(){this.settings=new BtChartSettings();this.settings.onChangeGrid=this.onChangeGrid.bind(this);this.settings.onChangeDots=this.onChangeDots.bind(this);this.el=$("chart");this.renderer=new BtChartRenderer(this);this.chartPoint=new BtChartPoint(this);this.chartPoint.onChartClick=this.onChartClick.bind(this);this.chartDialog=new BtChartDialog(this);this.chartDialog.onClose=this.onDialogClose.bind(this);this.chartDialog.onDelete=this.onDialogDelete.bind(this);this.chartDialog.onSave=this.onDialogSave.bind(this);this.chartComments=$("chartComments");this.chartCommentsContainer=this.chartComments.select("ul")[0];this.chartExpander=new BtChartExpander()},render:function(a){this.data=a;this.settings.init(a.date,a.cycle);this.currentDay=null;this.el.innerHTML=this.renderer.render(a);this.btPointsContainer=$("btPointsContainer");this.points={};$$(".b-bazal-fg-te")[0].style.width=a.cycle*BT_COLUMN_WIDTH+BT_CHART_PADDING+"px";this.chartPoint.init(a.date,a.cycle);this.chartDialog.init();if(a.points&&a.points.length>0){this.fillPoints(a.points);this.updateComments(this.points)}this.chartExpander.update(a.cycle,this.currentDay)},updateComments:function(a){var b=this.renderer.renderComments(a);this.chartCommentsContainer.innerHTML=b;this.chartComments.style.display=b==""?"none":"block"},createPointStructure:function(h,b){var d=h*BT_COLUMN_WIDTH;var c=b*BT_COLUMN_WIDTH;var f=this.getPointDate(h);var g=this.getComment(h,b);var a={id:"bt"+d+"_"+c,pointLeft:d,pointTop:c,rectLeft:h,rectTop:b,date_ymd:Tools.dateTo_ymd(f),date:f,comment:g,temperature:this.getDegree(b)};return a},getComment:function(c,a){if(!this.points){return""}var b=this.points[c];if(!b){return""}if(b.rectTop!=a){return""}return b.comment},getPointDate:function(a){return Tools.addDaysToDate(this.data.date,a)},getDegree:function(a){return 38-a/10},getDegreeString:function(a){return a.toString().replace(".",",")+"°"},fillPoints:function(d){for(var c=0;c<d.length;c++){var b=d[c];var a=this.createPointStructure(b.left,b.top);a.comment=b.note;this.points[a.rectLeft]=a}},fillDomElemWithPoint:function(d,a){var c=this.getDegreeString(a.temperature);var b=Tools.dateToString(a.date,true);d.degree.innerHTML=c;d.date.innerHTML=b;d.day.innerHTML=(a.rectLeft+1)+CYCLEDAY;d.comment[d.comment.tagName=="TEXTAREA"?"value":"innerHTML"]=a.comment},onChartClick:function(a,d){if(bt_read_only){return}if(this.dialogMode){this.chartDialog.hide();this.onDialogClose(d);return}this.cachedPoint=this.points[a.rectLeft];var b=this.cachedPoint&&this.cachedPoint.id!=a.id;var c=this.cachedPoint&&this.cachedPoint.id==a.id;if(b){return}this.chartDialog.show(a,this.cachedPoint);this.dialogMode=true},onDialogClose:function(a){this.dialogMode=false;this.chartPoint.showPoint(a)},onDialogDelete:function(){if(this.cachedPoint){var a=this.cachedPoint.id;$(a).remove();delete this.points[this.cachedPoint.rectLeft];this.dialogMode=false;if(this.onChartChange){this.onChartChange()}this.updateComments(this.points)}},onDialogSave:function(a){if(this.cachedPoint){this.cachedPoint.comment=a.comment}else{var b=this.renderer.renderPoint(a.id,a.pointLeft,a.pointTop);this.btPointsContainer.insert({bottom:b});this.points[a.rectLeft]=a}this.updateComments(this.points);this.dialogMode=false;if(this.onChartChange){this.onChartChange()}},onChangeGrid:function(a){this.el[!a?"addClassName":"removeClassName"]("b-bazal__no_grid")},onChangeDots:function(a){this.el[a=="dots"?"addClassName":"removeClassName"]("b-bazal__no_lines")}};var BtChartRenderer=Class.create();BtChartRenderer.prototype={initialize:function(f){this.chart=f;this.tdTemplate=new Template("<td>#{day}</td>");var a='<td><div class="b-bazal-graf-tp">#{day}<div class="b-bazal-graf-tp-tt"><span>'+TODAY+"</span> #{dayMonth}, #{day}"+CYCLEDAY+"</div></div></td>";this.todayTemplateTop=new Template(a);var d='<div id="#{id}" class="b-bazal-bt-day" style="left:#{left}px;top:#{top}px;"><div class="b-bazal-bt-point"></div></div>';this.pointTemplate=new Template(d);var b='<div class="b-bazal-bt-#{cls}" style="left:#{left}px;">#{month}</div>';this.monthTemplate=new Template(b);var g='<td><div class="b-bazal-graf-tp">#{day}</div></td>';var c="<li><h4><span> #{dayMonth}</span>, #{day}"+CYCLEDAY+"</h4><p>#{comment}</p></li>";this.chartCommentTemplate=new Template(c);this.todayTemplateBottom=new Template(g);this.chartTemplate=new Template(CHART_TEMPLATE)},renderComment:function(a){return this.chartCommentTemplate.evaluate({comment:a.comment,day:(a.rectLeft+1),dayMonth:Tools.dateToString(a.date,true)})},renderComments:function(c){if(!c){return""}var a=[];var d=[];for(point in c){if(c[point].comment!=""){d.push(c[point])}}Tools.sortDateArr(d,true);for(var b=0;b<d.length;b++){a.push(this.renderComment(d[b]))}return a.join("")},render:function(a){this.data=a;var b=this.createAxes();b.points=this.createPoints(a.points);b.menstruation=BT_COLUMN_WIDTH*this.data.menstruation;b.monthes=this.createMonthes();return this.chartTemplate.evaluate(b)},createAxes:function(){var f=this.data.date;var d=[];var b=[];for(var g=1;g<=this.data.cycle;g++){f=Tools.addDaysToDate(this.data.date,g-1);var c=f.getDate();var a=this.tdTemplate.evaluate({day:g});var h=this.tdTemplate.evaluate({day:c});if(Tools.datesEqual(SERVER_DATE_JS,f)){a=this.todayTemplateTop.evaluate({day:g,dayMonth:Tools.dateToString(f,true)});h=this.todayTemplateBottom.evaluate({day:c});this.chart.currentDay=g}d.push(a);b.push(h)}return{topRow:d.join(""),bottomRow:b.join("")}},createMonthes:function(){var f=[this.data.date.getMonth()];var a=[];var c=this.data.date.getDate();var h=c>=26?-13*(c-26):0;a.push(this.monthTemplate.evaluate({cls:"fmth",left:h,month:MONTHES[this.data.date.getMonth()]}));for(var d=1;d<=this.data.cycle;d++){date=Tools.addDaysToDate(this.data.date,d-1);if(f.indexOf(date.getMonth())==-1){var b=this;f.push(date.getMonth());var g=BT_COLUMN_WIDTH*(d-1);a.push(this.monthTemplate.evaluate({cls:"mth",left:g,month:MONTHES[date.getMonth()]}))}}return a.join("")},createPoints:function(f){if(!f){return""}var b=[];for(var d=0;d<f.length;d++){var c=f[d];var a=this.chart.createPointStructure(c.left,c.top);b.push(this.renderPoint(a.id,a.pointLeft,a.pointTop))}return b.join("")},renderPoint:function(c,b,a){return this.pointTemplate.evaluate({id:c,top:a,left:b})}};var BtChartPoint=Class.create();BtChartPoint.prototype={initialize:function(a){this.chart=a},init:function(a,b){this.startDate=a;this.days=b;this.dataRow=$("dataRow");this.chartEl=$("chart");this.chartVerticalLine=$("chartVerticalLine");this.chartHorizontalLine=$("chartHorizontalLine");this.chartRedPoint=$("chartRedPoint");this.initHint();this.elems=$A([this.chartVerticalLine,this.chartHorizontalLine,this.chartRedPoint,this.chartHint]);$$(".b-content-table")[0].onmousemove=this.showPoint.bindAsEventListener(this);this.dataRow.onclick=this._onChartClick.bindAsEventListener(this)},initHint:function(){this.chartHint=$("chartHint");var a=this.chartHint.getElementsByTagName("div");this.hintDegree=a[0];this.hintDate=a[1];this.hintDay=a[2];this.hintComment=a[3]},getTargetRect:function(f){var a=Event.pointerX(f);var o=Event.pointerY(f);var c=this.dataRow.cumulativeOffset();offsetX=c[0];offsetY=c[1];var h=a-offsetX;var d=o-offsetY;var n=this.days*BT_COLUMN_WIDTH;var l=BT_ROWS*BT_COLUMN_WIDTH;var b=Math.floor(h/BT_COLUMN_WIDTH);var j=Math.floor(d/BT_COLUMN_WIDTH);var g=!((h<0||d<0)||(h>n||d>l));var k=this.chart.createPointStructure(b,j);k.withinChart=g;return k},showPoint:function(d){if(this.chart.dialogMode){return}if(!Event.findElement(d,"#chartTable")){return this.hidePoint()}var a=this.getTargetRect(d);if(!a.withinChart){return this.hidePoint()}var c=a.pointLeft;var b=a.pointTop;this.chartRedPoint.style.left=c+"px";this.chartRedPoint.style.top=b+"px";this.chartVerticalLine.style.left=c+"px";this.chartHorizontalLine.style.top=b+"px";this.chartHorizontalLine.style.width=c+"px";this.chartHint.style.top=b+BT_COLUMN_WIDTH+BT_CHART_PADDING+"px";this.chartHint.style.left=c+BT_COLUMN_WIDTH+BT_CHART_PADDING+"px";this.fillHint(a);if(!this.pointShowed){this.pointShowed=true;this.elems.each(function(f){f.style.display="block"})}},hidePoint:function(){this.pointShowed=false;this.elems.each(function(a){a.style.display="none"})},fillHint:function(a){this.chart.fillDomElemWithPoint({degree:this.hintDegree,date:this.hintDate,day:this.hintDay,comment:this.hintComment},a)},_onChartClick:function(b){var a=this.getTargetRect(b);if(this.onChartClick){this.onChartClick(a,b)}}};var BtChartDialog=Class.create();BtChartDialog.prototype={onClose:null,onSave:null,onDelete:null,initialize:function(a){this.chart=a},init:function(){this.el=$("chartDialog");this.date=this.el.select(".b-bazal-bt-bar-date")[0];this.temp=this.el.select(".b-bazal-bt-bar-temp")[0];this.day=this.el.select(".b-bazal-bt-bar-day")[0];this.comment=this.el.select("#txtComment")[0];this.btnSave=$("btnSaveComment");this.btnDelete=$("btnDeleteComment");this.btnClose=$("btnClose");this.btnClose.onclick=this.fireOnClose.bindAsEventListener(this);this.btnDelete.onclick=this.fireOnDelete.bindAsEventListener(this);this.btnSave.onclick=this.fireOnSave.bindAsEventListener(this);this.keyup=this._onKeyUp.bindAsEventListener(this);this.el.onclick=function(a){Event.stop(a)}.bindAsEventListener(this)},fireOnClose:function(a){if(this.onClose){this.onClose(a)}this.hide()},fireOnDelete:function(){if(this.onDelete){this.onDelete()}this.hide()},fireOnSave:function(){this.point.comment=this.comment.value.escapeHTML();if(this.onSave){this.onSave(this.point)}this.hide()},show:function(a,b){Event.observe(document.body,"keyup",this.keyup);this.point=a;this.el.style.top=a.pointTop+BT_COLUMN_WIDTH+BT_CHART_PADDING+"px";this.el.style.left=a.pointLeft+BT_COLUMN_WIDTH+BT_CHART_PADDING+"px";this.chart.fillDomElemWithPoint({degree:this.temp,date:this.date,day:this.day,comment:this.comment},a);this.comment.value=this.comment.value.unescapeHTML();this.btnDelete.style.display=b?"":"none";this.el.style.display="block";this.comment.focus()},hide:function(){Event.stopObserving(document.body,"keyup",this.keyup);this.el.style.display="none"},_onKeyUp:function(a){if(a.keyCode==27){this.fireOnClose(a)}}};var BtChartExpander=Class.create();BtChartExpander.prototype={initialize:function(){this.expandContainer=$("expandContainer");this.btnExpandChart=$("btnExpandChart");this.btnExpandChart.onclick=this.expandChart.bind(this);this.btnCollapseChart=$("btnCollapseChart");this.btnCollapseChart.onclick=this.collapseChart.bind(this);this.overflovEl=$("chart");this.collapseContainer=$("collapseContainer");this.collapseSizer=this.collapseContainer.select(".border")[0];this.collapseSizerDefaultWidth=194;this.IE=Prototype.Browser.IE;if(this.IE){this.rightSide=$$(".h-bazal .b-content-divider, .h-bazal .b-content-right");this.leftSide=$$(".h-bazal .b-content-left")[0].parentNode}},hideIE6RightSide:function(a){if(!this.IE){return}this.rightSide.each(function(b){b.style.position=a?"relative":"static"});this.leftSide.style.position=!a?"relative":"static";this.leftSide.style.zIndex=!a?200:0},update:function(b,a){this.collapseChart();this.collapseSizer.style.width=this.collapseSizerDefaultWidth+"px";this.currentDay=a;if(b>36){this.showExpandAbility()}else{this.hideExpandAbility()}},showExpandAbility:function(){this.expandContainer.style.display="block";this.overflovEl.style.overflow="hidden"},hideExpandAbility:function(){this.expandContainer.style.display="none";this.collapseContainer.style.display="none";this.overflovEl.style.overflow="visible"},expandChart:function(){if(this.currentDay&&this.currentDay>37){this.collapseSizer.style.width=(this.collapseSizerDefaultWidth+(this.currentDay-37)*17.5)+"px"}this.hideIE6RightSide();this.expandContainer.style.display="none";this.collapseContainer.style.display="block";this.overflovEl.style.overflow="visible"},collapseChart:function(){this.hideIE6RightSide(true);this.expandContainer.style.display="block";this.collapseContainer.style.display="none";this.overflovEl.style.overflow="hidden"}};var BtChartSettings=Class.create();BtChartSettings.prototype={initialize:function(){this.cbShowGrid=$("fg_bazal_shaw_all");this.btnShowDots=$("btnShowDots");this.btnShowColumns=$("btnShowColumns");this.btnShowDots.onclick=this._onChangeDots.bind(this,"dots");this.btnShowColumns.onclick=this._onChangeDots.bind(this,"columns");this.cbShowGrid.onclick=this._onChangeGrid.bind(this)},init:function(a,c){var f=Tools.addDaysToDate(a,parseInt(c));var b=new Date().getFullYear();var d=(a.getFullYear()==b)||(f.getFullYear()==b)},_onChangeGrid:function(){if(this.onChangeGrid){return this.onChangeGrid($F(this.cbShowGrid))}},_onChangeDots:function(a){if(a=="dots"){this.toggleBtns(this.btnShowDots,this.btnShowColumns)}else{this.toggleBtns(this.btnShowColumns,this.btnShowDots)}if(this.onChangeDots){this.onChangeDots(a)}},toggleBtns:function(d,c){var b=d.getElementsByTagName("a");if(b.length==0){return}d.innerHTML=b[0].innerHTML;d.removeClassName("b-bazal-mu-sn");d.addClassName("b-bazal-mu-sn-sd");c.removeClassName("b-bazal-mu-sn-sd");c.addClassName("b-bazal-mu-sn");c.innerHTML='<a href="javascript:void(0)">'+c.innerHTML+"</a>"}};var BtInitialData=Class.create();BtInitialData.prototype={initialize:function(a){this.manager=a;this.dateBtn=$("btnBtDate");this.dateTitle=this.dateBtn.down("span");this.calendar=new MashCalendar(this.dateBtn);this.calendar.getElToShowDate=function(){return this.dateTitle}.bind(this);this.calendar.onDateChoosed=this._onChange.bind(this);this.btnCreateChart=$("btnCreateChart");this.btnCreateChart.onclick=function(){this.btnCreateChart.disabled=true;if(this.onCreateChart){this.onCreateChart()}}.bind(this);this.cbCycleLength=$("cbCycleLength");this.cbCycleLength.onchange=this._onChange.bind(this);this.cbMenstruationLength=$("cbMenstruationLength");this.errorContainer=$("errorContainer");this.linkToExistingChart=$("linkToExistingChart")},showCalendar:function(a){this.calendar.show()},_onChange:function(a){if(this.onChange){this.onChange(this.getData(),this.validate.bind(this))}},parseDate:function(b){var a=b.split("-");return new Date(Tools.parse01Digit(a[0]),Tools.parse01Digit(a[1])-1,Tools.parse01Digit(a[2]))},validate:function(d){this.btnCreateChart.disabled=d.length>0;if(d.length>0){var b=d[0];var a=this.parseDate(b.cycle_first_day);var c=this.parseDate(b.cycle_last_day);this.linkToExistingChart.title=Tools.dateToString(a)+" - "+Tools.dateToString(c);this.linkToExistingChart.href=this.manager.getUrlByDate(a);this.errorContainer.style.display="";return}this.errorContainer.style.display="none";this.dateTitle.innerHTML=Tools.dateToString(this.calendar.getDate());this.btnCreateChart.disabled=false},getData:function(){return{date:this.calendar.getDate(),cycle:$F(this.cbCycleLength),menstruation:$F(this.cbMenstruationLength)}}};var ExpertList=Class.create();ExpertList.prototype={initialize:function(b,a){this.el=$(b);this.itemsEl=$(this.el.getElementsByTagName("ul")[0]);this.btn=$(a);this.btn.onclick=this._onDeleteExperts.bindAsEventListener(this);this.el.onclick=this._onClick.bindAsEventListener(this)},_onDeleteExperts:function(b){if(Event.element(b).hasClassName("disabled")){return}var a=this.getSelectedElements();a.each(function(c){c.remove});if(this.onDeleteExperts){this.onDeleteExperts(a)}},getIds:function(){var a=[];this.itemsEl.select("li").each(function(b){a.push(b.id.replace("e",""))});return a},selectBy:function(c){var a=[];for(var b=0;b<c.length;b++){var d="e"+c[b];a.push($(d))}return a},getSelectedElements:function(){return this.el.select(".sd")},_onClick:function(b){var a=Event.findElement(b,"li");if(!a){return}$(a).toggleClassName("sd");this.updateBtn()},updateBtn:function(){var a=this.getSelectedElements();if(a.length>0){this.btn.removeClassName("disabled")}else{this.btn.addClassName("disabled")}},append:function(a){this.itemsEl.insert({top:a})},filterByModules:function(b){var c=[];var a=this.itemsEl.select("li");a.each(function(h){var g=h.getAttribute("m").split(",");var d=false;for(var f=0;f<b.length;f++){if(g.indexOf(b[f])!=-1){d=true;break}}h[d?"show":"hide"]()})},selectAll:function(){this.itemsEl.select("li").each(function(a){a.addClassName("sd")});this.updateBtn()}};var ModuleList=Class.create();ModuleList.prototype={initialize:function(){this.el=$("moduleList");this.btnSelectModule=$("btnSelectModule");this.btnSelectModule.onclick=this.show.bind(this);this.closed=true;this.itemsEl=$(this.el.getElementsByTagName("ul")[0]);this.itemsEl.onclick=this._onClick.bindAsEventListener(this)},show:function(){if(this.closed){this.closed=false;this.btnSelectModule.addClassName("open");this.el.style.display="block";return}this.closed=true;this.btnSelectModule.removeClassName("open");this.el.style.display="none"},_onClick:function(b){var a=Event.findElement(b,"li");if(!a){return}this.fireOnSelect()},fireOnSelect:function(){var a=this.getModules();if(this.onSelectModule){this.onSelectModule(a)}},getModules:function(){var b=[];var a=this.itemsEl.select("input");a.each(function(c){if(c.checked){b.push(c.id.replace("m",""))}});return b},selectAll:function(){this.itemsEl.select("li").each(function(a){a.addClassName("sd")});this.fireOnSelect()}};var ExpertChooser=Class.create();ExpertChooser.prototype={initialize:function(){this.selectedExpertList=new ExpertList("selectedExpertList","btnExLeft");this.el=$("expertChooser");this.expertList=new ExpertList("expertList","btnExRight");this.selectedExpertList.onDeleteExperts=this.moveExpertsTo.bind(this,this.expertList);this.expertList.onDeleteExperts=this.moveExpertsTo.bind(this,this.selectedExpertList);this.moduleList=new ModuleList();this.moduleList.onSelectModule=this.onSelectModule.bind(this);if(shared_with_experts.length>0){this.initSelectedExpertList(shared_with_experts)}},initSelectedExpertList:function(a){var b=this.expertList.selectBy(a);this.moveDom(this.selectedExpertList,b)},moveDom:function(b,a){a.each(function(c){c.removeClassName("sd");b.append(c)})},moveExpertsTo:function(c,b){this.moveDom(c,b);this.selectedExpertList.updateBtn();this.expertList.updateBtn();var a=this.moduleList.getModules();this.expertList.filterByModules(a);if(this.onChange){this.onChange(this.selectedExpertList.getIds())}},onSelectModule:function(a){this.expertList.filterByModules(a)},show:function(){if(this.el.parentNode.style.fontSize!=""){this.font_mode=true;this.el.parentNode.style.fontSize=""}this.el.style.display="block"},hide:function(){this.el.style.display="none";if(this.font_mode){this.el.parentNode.style.fontSize="0px"}}};var ExpertAccessManager=Class.create();ExpertAccessManager.prototype={initialize:function(a,b){this.id=b;this.cbAccess=$("cbAccess");this.cbAccess.onchange=this._onChange.bind(this);this.experts=new ExpertChooser();this.experts.onChange=this.onChooseExperts.bind(this);this.url=a;if(shared_with_experts.length>0){this.experts.show()}},onResponse:function(a){},_onChange:function(){var a=$F(this.cbAccess);if(a=="closed"){Tools.send(this.url,this.onResponse.bind(this),null,{access:"access",experts:"empty",id:this.id});this.experts.hide();return}if(a=="experts"){this.experts.show()}},onChooseExperts:function(a){if(a==""){a="empty"}else{a=a.join(",")}Tools.send(this.url,this.onResponse.bind(this),null,{access:"access",experts:a,id:this.id})}};var ExpertQuestionManager=new Class.create({initialize:function(a,b){this.form=$(a);if(!this.form){return}this.textArea=Element.down(this.form,"textarea");this.submit=Element.down(this.form,"input");this.border_class=b?b:"h-border-f66";this.is_question=false;this.is_tags=false;this.setEvents()},setEvents:function(){this.form.onsubmit=this.validate.bindAsEventListener(this);this.textArea.onkeyup=this.onchangeTextArea.bindAsEventListener(this)},onchangeTextArea:function(a){this.is_question=!(this.textArea.value.strip()=="");this.enable_submit()},validate:function(){if(this.is_valid()){return true}return false},is_add_question:function(){this.is_question=this.is_add_content(this.textArea);return this.is_question},is_add_content:function(a){if(a.value.strip()==""){this.set_no_valid(a);return false}return true},is_valid:function(){return this.is_add_question()},set_no_valid:function(a){Element.addClassName(a,this.border_class)},set_valid:function(a){Element.removeClassName(a,this.border_class)},enable_submit:function(){if(this.is_question){this.submit.removeAttribute("disabled")}else{this.submit.setAttribute("disabled","true")}}});var Base64={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(c){var a="";var l,j,g,k,h,f,d;var b=0;c=Base64._utf8_encode(c);while(b<c.length){l=c.charCodeAt(b++);j=c.charCodeAt(b++);g=c.charCodeAt(b++);k=l>>2;h=((l&3)<<4)|(j>>4);f=((j&15)<<2)|(g>>6);d=g&63;if(isNaN(j)){f=d=64}else{if(isNaN(g)){d=64}}a=a+this._keyStr.charAt(k)+this._keyStr.charAt(h)+this._keyStr.charAt(f)+this._keyStr.charAt(d)}return a},decode:function(c){var a="";var l,j,g;var k,h,f,d;var b=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(b<c.length){k=this._keyStr.indexOf(c.charAt(b++));h=this._keyStr.indexOf(c.charAt(b++));f=this._keyStr.indexOf(c.charAt(b++));d=this._keyStr.indexOf(c.charAt(b++));l=(k<<2)|(h>>4);j=((h&15)<<4)|(f>>2);g=((f&3)<<6)|d;a=a+String.fromCharCode(l);if(f!=64){a=a+String.fromCharCode(j)}if(d!=64){a=a+String.fromCharCode(g)}}a=Base64._utf8_decode(a);return a},_utf8_encode:function(b){b=b.replace(/\r\n/g,"\n");var a="";for(var f=0;f<b.length;f++){var d=b.charCodeAt(f);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}return a},_utf8_decode:function(a){var b="";var d=0;var f=c1=c2=0;while(d<a.length){f=a.charCodeAt(d);if(f<128){b+=String.fromCharCode(f);d++}else{if((f>191)&&(f<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((f&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((f&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}return b}};tagsHandler={sendForm:function(d){var b="/tags/";var f=true;var a=$("tag").value;var c=$("id-module").value;if(a!=""){b+=a+"/";f=false}if(c!=""){b+=c+"/"}if(f==false){tagsHandler.redirect(b)}return false},redirect:function(a){window.location.href=a}};var BabyStatsManager=Class.create();BabyStatsManager.prototype={initialize:function(){this.month_days=new Array();this.setup_events()},setup_events:function(){this.setup_year_link_events();this.setup_month_link_events()},setup_year_link_events:function(){year_links=$$("a.babystats_archive_year");for(i=0;i<year_links.length;i++){var a=year_links[i];Event.observe(a,"click",this.open_year_block.bindAsEventListener(a))}},setup_month_link_events:function(){var b=$$("a.babystats_archive_month");for(i=0;i<b.length;i++){var a=b[i];Event.observe(a,"click",this.open_month_block.bindAsEventListener(this))}},open_year_block:function(d){var c=d.target;var b=/^year_([0-9]+)_action$/;var a=b.exec(c.id);if(a[1]){$$("tr.year_"+a[1]+"_month").each(function(f){Element.toggleClassName(f,"hidden")})}Event.stop(d)},open_month_block:function(d){var c=d.target;var b=/^month_([0-9]+)_([0-9]+)_action$/;var a=b.exec(c.id);if(a[1]&&a[2]){if(!this.month_days[a[1]+"-"+a[2]]){Tools.send(this.callback_url,this.populate_month.bindAsEventListener(this),null,{year:a[1],month:a[2]})}else{this.show_month_rows(a[1],a[2])}}Event.stop(d)},populate_month:function(b){var c=$("date_"+b.responseJSON.year+"_"+b.responseJSON.month);if(b.status!=200||!c){return}var a=new Template('<tr class="year_#{year}_#{month}_day hidden"><th>#{day}</th><td>#{boys}</td><td>#{girls}</td><td>#{total}</td></tr>');var f="";for(i=1;i<=b.responseJSON.days;i++){var d=b.responseJSON.data[i];f+=a.evaluate(d)}Element.insert(c,{after:f});this.month_days[b.responseJSON.year+"-"+b.responseJSON.month]=b.responseJSON.days;this.show_month_rows(b.responseJSON.year,b.responseJSON.month)},show_month_rows:function(a,b){$$("tr.year_"+a+"_"+b+"_day").each(function(c){c.toggleClassName("hidden")})},set_callback_url:function(a){this.callback_url=a}};SearchContentTypeManager=Class.create({initialize:function(a){this.switcher=a;this._infoTemplate=new Template('<div class="b-search-extended-module" id="b-search-module-#{moduleid}"><h2 class="b-search-extended-module-title"><a href="javascript:void(0)" id="module-search-link-#{moduleid}">#{moduletitle}</a></h2><ul class="b-search-extended-module-ul" id="b-search-extended-module-ul-#{moduleid}"></ul></div>');this._listTemplate=new Template('<li class="b-search-extended-module-li" id="b-search-module-extended-li-#{moduleid}_#{contenttypeid}"><a href="javascript:void(0)" id="b-search-link-#{moduleid}-#{contenttypeid}">#{contenttitle},</a> </li>');this._filterInfo=$("extended-modules");this.parse_content_types();this.setup_checkbox_status();this.setup_content_type_events()},setup_module_checkbox_events:function(){var a=$$("select.module-switcher");a.each(function(b){Event.observe(b,"click",this.module_checkbox_click.bindAsEventListener(this))},this)},module_checkbox_click:function(d){var a=d.target;var c=parseInt(a.value);var b=$$("input.content-type-checkbox-"+c);b.each(function(f){f.checked=a.checked;this.set_content_type(f.value,a.checked)},this)},setup_link_events:function(){var a=$("open-modules-div");var b=$("module-list");b.hide();Event.observe(a,"click",this.toggle_modules_div.bindAsEventListener(b))},toggle_modules_div:function(a){$(this).toggle()},setup_checkbox_status:function(){var a=$$("table.b-search-extended-column input[type=checkbox]");a.each(function(b){if(this.content_types.indexOf(b.value)!=-1){b.checked=true;this.setup_selected_info(b)}else{b.checked=false}},this)},setup_selected_info:function(c){var g=c.value.split("-");var f=g[0];var h=g[1];var b=$("b-search-module-"+f);if(!b){var d=this.switcher.get_textvalue_by_module(f);Element.insert(this._filterInfo,{bottom:this._infoTemplate.evaluate({moduleid:f,moduletitle:d})});b=$("b-search-module-"+f);$("module-search-link-"+f).onclick=function(n,j,l){j.style.display="none";var k=$$("table#section-"+l+" input[type=checkbox]");k.each(function(p){p.checked=false;var o=p.value.split("-");var r=$("b-search-module-extended-li-"+l+"_"+o[1]);if(r){r.style.display="none"}this.set_content_type(p.value,p.checked)},this)}.bindAsEventListener(this,b,f)}var a=$("b-search-module-extended-li-"+f+"_"+h);if(!a){Element.insert($("b-search-extended-module-ul-"+f),{bottom:this._listTemplate.evaluate({moduleid:f,contenttypeid:h,contenttitle:c.title})});a=$("b-search-module-extended-li-"+f+"_"+h);$("b-search-link-"+f+"-"+h).onclick=function(n,o,j,l,k){checkbox=$("extended_search_"+l+"_"+k);checkbox.checked=false;if(this.empty_section_filter(f)){j.style.display="none"}this.set_content_type(checkbox.value,checkbox.checked);o.style.display="none"}.bindAsEventListener(this,a,b,f,h)}if(c.checked){a.style.display="inline";b.style.display="block"}else{a.style.display="none"}if(this.empty_section_filter(f)){b.style.display="none"}},empty_section_filter:function(b){var a=$$("table#section-"+b+" input[type=checkbox]");this._temp_result=true;a.each(function(c){if(c.checked){this._temp_result=false}},this);return this._temp_result},parse_content_types:function(){var a=$("content_types");this.content_types=new Array();if(a.value){var b=a.value.split(",");b.each(function(c){this.content_types.push(c)},this)}},setup_content_type_events:function(){var a=$$("table.b-search-extended-column input[type=checkbox]");a.each(function(b){Event.observe(b,"click",this.content_type_click.bindAsEventListener(this))},this)},content_type_click:function(b){var a=b.target;this.set_content_type(a.value,a.checked);this.setup_selected_info(a)},set_content_type:function(b,a){if(a){this.content_types.push(b)}else{this.content_types=this.content_types.without(b)}var c=$("content_types");c.value=this.content_types.join(",")}});var SectionSwitcher=Class.create({initialize:function(a){this.selected=0;this.switcher_element=a;this.switching(this.switcher_element.value);this.switcher_element.onchange=function(b){this.switching(b.target.value)}.bind(this)},get_textvalue:function(){var a=this.switcher_element.options[this.switcher_element.selectedIndex];return a.text},get_textvalue_by_module:function(b){for(var a=0;a<this.switcher_element.options.length;a++){if(this.switcher_element.options[a].value==b){return this.switcher_element.options[a].text}}return false},switching:function(b){var c=$("section-"+this.selected);if(c){c.style.display="none"}var a=$("section-"+b);if(a){a.style.display="block"}this.selected=b}});var FormSearch=Class.create();FormSearch.prototype={initialize:function(){this.adv_form=$("extended_form");this.cb_extended=$("extended_search");this.switchForm(this.cb_extended.checked);this.cb_extended.onclick=function(a){this.switchForm(a.target.checked)}.bind(this);this.switcher=new SectionSwitcher($("section-switcher"));this.searchManagerCt=new SearchContentTypeManager(this.switcher)},switchForm:function(a){if(a){Element.show(this.adv_form)}else{Element.hide(this.adv_form)}}};var SmallSearch=Class.create({initialize:function(b,a,c){this.search=$(b);this.searchForm=$("small-search-form");this.is_safari=c?true:false;this.s_types=a;if(!this.search){return}this.link=this.searchForm.down("a");if(this.search){this.placeholder=this.search.getAttribute("placeholder")}this.setEvents();if(!this.is_safari&&this.search.value==""){this.onblur()}},setEvents:function(){if(!this.is_safari){Event.observe(this.search,"keyup",this.onkeyup.bindAsEventListener(this));Event.observe(this.search,"focus",this.onfocus.bindAsEventListener(this));Event.observe(this.search,"blur",this.onblur.bindAsEventListener(this))}if(this.link){this.link.onclick=this.submit.bind(this,this.searchForm,this.s_types)}this.searchForm.onsubmit=this.submit.bind(this,this.searchForm,this.s_types)},getRadioCheckedValue:function(c,a){var d=c.elements[a];if(!d){return}if(d.length==0){return""}for(var b=0;b<d.length;b++){if(d[b].checked){return d[b].value}}return""},submit:function(c,b){q=c.elements.q.value;if(!q||q==c.elements.q.getAttribute("placeholder")){return false}radio=this.getRadioCheckedValue(c,"e");if(radio=="1"){var a=b.split("-");m=a[0];t=a[1];window.location="/search/?q="+q+"&e=1&m="+m+"&t="+t}else{window.location="/search/?q="+q}return false},onclick:function(){if(Prototype.Browser.IE){setTimeout(function(){this.submit()},10)}else{this.submit()}return false},onkeyup:function(){this.search.style.color="#000"},onfocus:function(){if(this.search.value==this.placeholder){this.search.value=""}this.search.style.color="#000"},onblur:function(){if(this.search.value==""){this.resetSearch()}},resetSearch:function(){this.search.style.color="#999";this.search.value=this.placeholder}});var SearchForm=Class.create({checkbox:false,spoiler:false,initialize:function(a){this.search=$(a.textfield);if(!this.search){return}if(a.extended){if(a.extended.checkbox){this.checkbox=$(a.extended.checkbox);this.spoiler=$(a.extended.spoiler)}}this.placeholder=this.search.getAttribute("placeholder");this.btn_submit=$(a.submit);this.set_events()},set_events:function(){Event.observe(this.search,"keyup",this.onkeyup.bindAsEventListener(this));Event.observe(this.search,"focus",this.onfocus.bindAsEventListener(this));Event.observe(this.search,"blur",this.onblur.bindAsEventListener(this));if(this.search.value==""){this.onblur()}if(this.checkbox){Event.observe(this.checkbox,"click",this.checkbox_onchange.bindAsEventListener(this));this.checkbox_onchange()}},checkbox_onchange:function(){this.spoiler.style.display=this.checkbox.checked?"block":"none"},onchange:function(){if(this.search.value==this.placeholder||this.search.value==""){this.btn_submit.disabled=true}else{this.btn_submit.disabled=false}},onkeyup:function(){this.search.style.color="#000";this.onchange()},onfocus:function(){if(this.search.value==this.placeholder){this.search.value=""}this.search.style.color="#000";this.onchange()},onblur:function(){if(this.search.value==""){this.reset()}this.onchange()},reset:function(){this.search.style.color="#999";this.search.value=(this.placeholder)?this.placeholder:""},submit:function(b,a){if(this.search.value==this.placeholder){this.search.value=""}if(Prototype.Browser.IE){setTimeout(this.do_search(a),10)}else{this.do_search(a)}return false},do_search:function(f){f.onsubmit=function(){return false};var a=$("s-module").value;var c=$("s-types").value;var g=$("search-txt").value;var d=$("s-ext").checked;if(!d){window.location="?q="+g;return false}var b="?e=1&q="+g;if(a!=""){b+="&m="+a}if(c!=""){b+="&t="+c}window.location=b;return false}});var SearchMap=Class.create({mapping:{},initialize:function(a,b,c){this.select_module=a;this.select_module.onchange=this.onmodule_changed.bind(this);this.select_type=b;this.typelist=c},assign:function(a,b){this.mapping[a]=b},settypes:function(d,c){var b=[];if(!d||!this.mapping[d]){for(item in this.typelist){b.push(this.typelist[item].id)}}else{b=this.mapping[d]}for(var a=this.select_type.options.length-1;a>=1;a--){this.select_type.remove(a)}for(var a=0;a<b.length;a++){option=this.create_options(b[a],c);if(!Prototype.Browser.IE){this.select_type.add(option,null)}else{this.select_type.add(option)}}},create_options:function(b,a){var c=document.createElement("option");var a=this.typelist["t"+b];c.text=a.text;c.value=a.id;if(a==a.id){option.selected=true}return c},onmodule_changed:function(){value=this.select_module.value;if(value==""){this.settypes()}else{this.settypes(value)}}});var GeoSelect=Class.create();GeoSelect.prototype={optionTemplate:new Template('<option value="#{id}">#{name}</option>'),initialize:function(){this.cbCountry=$("id_country");this.mainClassName="b-database-filter-main-rec";this.cbCountry.onchange=this.getCities.bindAsEventListener(this);this.cbCity=$("id_city");if($F(this.cbCountry)==""){this.cbCity.disabled=true}this.cachedCities=[]},getCities:function(){var b=$F(this.cbCountry);if(b==""){this.cbCity.disabled=true;this.cbCity.innerHTML="";return}var a=this.getFromCache(b);if(a){this.renderCities(a);return}this.getCitiesFromServer(b)},getFromCache:function(a){return this.cachedCities[a]},addCitiesToCache:function(b,a){this.cachedCities[b]=a},getUrl:function(a){return URL_GET_CITIES_BY_COUNTRY_ID+a},getCitiesFromServer:function(a){Tools.send(this.getUrl(a),function(b){var c=b.responseText.evalJSON();this.addCitiesToCache(a,c);this.renderCities(c)}.bind(this))},renderCities:function(f){this.cbCity.disabled=false;var b=[];b.push(this.optionTemplate.evaluate({id:"",name:ALL_CITIES}));var a=false;for(var d=0;d<f.length;d++){var g=f[d];b.push(this.optionTemplate.evaluate(g));if(g.id.toString()==DEFAULT_CITY){a=true}}this.cbCity.innerHTML="";this.cbCity.insert({bottom:b.join("")});if(a){var c=$(this.cbCity.options[DEFAULT_CITY]);c.selected=true;c.addClassName(this.mainClassName)}}};var CatalogFilter=Class.create({optionTemplate:new Template('<option value="#{id}">#{name}</option>'),initialize:function(){this.geoSelect=new GeoSelect();this.geoSelect.getUrl=this.getCityUrl.bind(this);this.geoSelect.addCitiesToCache=this.addCitiesToCache.bind(this);this.geoSelect.getFromCache=this.getCitiesFromCache.bind(this);this.cbType=$("id_type");this.cbCountry=$("id_country");this.cbType.onchange=this.getCountries.bindAsEventListener(this);this.cachedCountries=[]},getCountries:function(){var a=$F(this.cbType);var b=this.cachedCountries[a];if(b){this.renderCountries(b);return}this.getCountriesFromServer(a)},addCountriesToCache:function(b,a){this.cachedCountries[b]=a},getCityUrl:function(a){return URL_GET_CITIES_BY_COUNTRY_ID+a+"/"+$F(this.cbType)},getCitiesFromCache:function(a){return this.geoSelect.cachedCities[a+"_"+$F(this.cbType)]},addCitiesToCache:function(b,a){this.geoSelect.cachedCities[b+"_"+$F(this.cbType)]=a},getCountriesFromServer:function(a){Tools.send(URL_GET_COUNTRIES_BY_TYPE_ID+a,function(c){var b=c.responseText.evalJSON();this.addCountriesToCache(a,b);this.renderCountries(b)}.bind(this))},renderCountries:function(a){var d=[];d.push(this.optionTemplate.evaluate({id:"",name:ALL_COUNTRIES}));var g=false;for(var f=0;f<a.length;f++){var h=a[f];d.push(this.optionTemplate.evaluate(h));if(h.id.toString()==DEFAULT_COUNTRY){g=true}}this.cbCountry.innerHTML="";this.cbCountry.insert({bottom:d.join("")});var b="b-database-filter-main-rec";if(g){$(this.cbCountry.options[DEFAULT_COUNTRY]).addClassName(b)}this.cbCountry.selectedIndex=0;this.geoSelect.getCities()}});var DietSubscribeManager=Class.create({initialize:function(d,b,c,a){this.dynamicButton=new DynamicButton($("subscribe_link"));this.link=b;this.subscribe_text=c;this.unsubscribe_text=a;this.is_subscribed=d;this.down=false;this.setEvents()},setEvents:function(){this.dynamicButton._onmouseup=this.onmouseup.bind(this)},onmouseup:function(){if(this.loaded){return}var a=!this.is_subscribed?"subscribe/":"unsubscribe/";this.sendSubscribeRequest(a)},sendSubscribeRequest:function(a){this.loaded=true;Tools.send(this.link+a,this.onResponse.bind(this))},onResponse:function(a){var b=a.responseText.evalJSON();this.loaded=false;this.is_subscribed=!this.is_subscribed;this.setMode()},setMode:function(){var a=["b-subscribe","b-unsubscribe"];Element.removeClassName(this.dynamicButton.container.parentNode,a[this.is_subscribed?0:1]);Element.addClassName(this.dynamicButton.container.parentNode,a[this.is_subscribed?1:0]);this.dynamicButton.setValue(this.is_subscribed?this.subscribe_text:this.unsubscribe_text)}});var IprojJoinManager=Class.create();IprojJoinManager.prototype={initialize:function(){this.joinButton=$("join_iproj");this.leaveButton=$("leave_iproj");this.notification=$("notification");if(this.joinButton){this.joinButton.onclick=this.sendRequest.bind(this,"/join")}if(this.leaveButton){this.leaveButton.onclick=this.sendRequestForLeaving.bind(this,"/leave")}},sendRequestForLeaving:function(a){if(!confirm("Вы действительно хотите покинуть проект?")){return}this.sendRequest(a)},sendRequest:function(a){Tools.send(JOIN_IPROJ_LINK+a,this.onResponse.bind(this))},onResponse:function(a){if(a.responseText=="JOINED"){this.notification.style.visibility="visible";this.joinButton.style.display="none";this.leaveButton.style.display="inline"}if(a.responseText=="LEAVED"){this.notification.style.visibility="hidden";this.joinButton.style.display="inline";this.leaveButton.style.display="block"}}};var ConditionManager=Class.create();ConditionManager.prototype={initialize:function(){this.el=$("conditions");this.emptyConditionsLabel=$("emptyConditionsLabel");this.conditionTemplate=new Template("<li condition_id='#{id}'><a class='g-external-link' target='_blank' href='/health/glossary/#{glossary_url}/'>#{name}<i></i></a></li>")},renderConditions:function(d){this.clear();var a=[];for(var b=0;b<d.length;b++){var c=d[b];a.push(this.conditionTemplate.evaluate(c))}this.el.innerHTML=a.join("");this.emptyConditionsLabel.style.display=a.length==0?"block":"none";var f=this.el.getElementsByTagName("li");for(var b=0;b<d.length;b++){f[b].data=d[b]}},clear:function(a){this.el.innerHTML=""}};var SymptomList=Class.create();SymptomList.prototype={initialize:function(a,b){this.el=$(a);this.commonSymptom=b;this.createSymptomTemplate()},createSymptomTemplate:function(){var a="<li id='"+this.el.id+"_#{id}' #{display} body_part='#{body_part}' "+this.el.id+"='#{id}'><a href='javascript:void(0)'>#{symptom__name}</a>";a+="</li>";this.symptomTemplate=new Template(a)},clear:function(){this.el.innerHTML=""},show:function(a){this.el.style.display=a?"":"none"},render:function(b,f){var a=[];for(var c=0;c<f.length;c++){var d=f[c];d.body_part=b;if(this.onRender){this.onRender(d)}a.push(this.symptomTemplate.evaluate(d))}this.el.innerHTML=a.join("");this.el.onclick=this.symptomClicked.bindAsEventListener(this)},append:function(a){this.el.insert({bottom:this.symptomTemplate.evaluate(a)});this.el.onclick=this.symptomClicked.bindAsEventListener(this)},symptomClicked:function(b){var a=Event.element(b);if(a.tagName=="A"){a=a.parentNode;if(this.onSymptomSelected){this.onSymptomSelected(a.getAttribute(this.el.id),a,this.commonSymptom)}}},getSymptoms:function(){var b=this.el.getElementsByTagName("li");var a=[];for(var c=0;c<b.length;c++){var d=b[c];a.push(d.getAttribute(this.el.id))}return a.join(",")}};var SelectedSymptomList=Class.create(SymptomList,{initialize:function(){this.el=$("selectedSymptoms");this.createSymptomTemplate()},createSymptomTemplate:function(){this.symptomTemplate=new Template(SELECTED_SYMPTOM_TEMPLATE)},symptomClicked:function(d){var a=Event.element(d);if(a.tagName=="A"){var c=$(a).up("table");var b=c.getAttribute("bp_id");if(this.onDelete){this.onDelete(b,c)}}},getSymptoms:function(){var b=this.el.getElementsByTagName("table");var a=[];for(var c=0;c<b.length;c++){var d=b[c];a.push(d.getAttribute("bp_id"))}return a.join(",")}});var SymptomManager=Class.create();SymptomManager.prototype={initialize:function(a){this.manager=a;this.dialogEl=$("symcheckerDialog");var b=this.closeDialog.bind(this);$("btnCloseSymcheckerDialog").onclick=b;$("btnCloseSymcheckerDialog1").onclick=b;this.emptySymptomsLabel=$("emptySymptomsLabel");this.selectedSymptomsContainer=$("selectedSymptomsContainer");this.btnClearSymptoms=$("btnClearSymptoms");this.btnClearSymptoms.onclick=this.onClearSymptomsClick.bind(this);this.btnClearSymptoms.onmouseover=this.highlightAllRemoveBtns.bindAsEventListener(this);this.btnClearSymptoms.onmouseout=this.highlightAllRemoveBtns.bindAsEventListener(this,true);this.bodyPartSymptoms=new SymptomList("symptoms");this.bodyPartSymptoms.onSymptomSelected=this.selectSymptom.bind(this);this.bodyPartSymptoms.onRender=this.onRenderBodyPart.bind(this);this.currentBodyPart=$("currentBodyPart");this.customSymptoms=new SymptomList("commonSymptoms",true);this.customSymptoms.onSymptomSelected=this.selectSymptom.bind(this);this.childMenuSep=$("childSep");this.btnSymptomsCommon=$("btnSymptomsCommon");this.btnSymptomsCommon.onclick=this.showSymptoms.bind(this,"common");this.currentBodyPart.onclick=this.showSymptoms.bind(this);this.emptyTitle=true;this.selectedSymptoms=new SelectedSymptomList();this.selectedSymptoms.onDelete=this.deselectSymptom.bind(this);this.selectedHash={}},clear:function(){this.bodyPartSymptoms.clear();this.clearSelectedSymptoms();if(!this.emptyTitle){this.currentBodyPart.innerHTML=""}this.currentBodyPartTitle=null},clearSelectedSymptoms:function(){this.selectedSymptoms.clear();this.selectedHash={};this.updateStateOfSymptoms()},onClearSymptomsClick:function(){this.clearSelectedSymptoms();this.fireOnSelectedSymptomsChanged()},renderCustomSymptoms:function(a,b){this.customSymptoms.render(a,b)},clearMenu:function(){this.currentBodyPart.innerHTML="";this.childMenuSep.style.display="none"},showMenu:function(a){this.currentBodyPart.innerHTML=a;this.childMenuSep.style.display="inline"},renderBodyPartSymptoms:function(a,b,d,c){this.isBigPart=d;this.currentBodyPartTitle=a;this.bodyPartId=b;this.emptyTitle=false;if(!this.common&&!this.isBigPart){this.showMenu(a)}if(this.isBigPart){this.clearMenu()}this.updateSymptomSelection();this.bodyPartSymptoms.render(a,c);this.showSymptoms(this.common)},fireOnSelectedSymptomsChanged:function(){if(this.onSelectedSymptomsChanged){this.onSelectedSymptomsChanged(this.selectedSymptoms.getSymptoms())}},onRenderBodyPart:function(a){if(this.selectedHash[a.id]){a.display="style='display:none'"}},highlightAllRemoveBtns:function(c,b){var a=this.selectedSymptomsContainer.select(".x");a.each(function(d){if(b){d.removeClassName("x-hover")}else{d.addClassName("x-hover")}})},getBodyPartParents:function(c){var a={leaf:null,parents:[]};var b=this.manager.getBodyPartById(c);a.leaf=b;while(b){a.leaf=b;b=this.manager.getBodyPartById(b[2]);if(b){a.parents.push(a.leaf[1])}}a.parentPart=a.leaf[1]+(a.parents.length>0?",":"");a.bodyPart=a.parents.reverse().join(", ").toLowerCase();return a},selectSymptom:function(g,b,f){if(b.disabled){return}if(this.selectedHash[g]){return}this.selectedHash[g]=b.id;b.style.display="none";var d=f?SYMCHECKER_COMMON_BODY_PART_ID:this.bodyPartId;var c=this.getBodyPartParents(d);var a=$(b).select("a")[0].innerHTML;this.selectedSymptoms.append({id:g,symptom__name:a,body_part:c.bodyPart,parent_part:c.parentPart});this.updateStateOfSymptoms();this.fireOnSelectedSymptomsChanged()},updateSymptomSelection:function(){for(id in this.selectedHash){var a=$(this.selectedHash[id]);if(a){a.disabled=true;a.style.display="none"}}},deselectSymptom:function(c,b){var a=$(this.selectedHash[c]);if(a){a.style.display="block"}delete this.selectedHash[c];$(b).remove();this.updateStateOfSymptoms();this.fireOnSelectedSymptomsChanged()},symptomsIsEmpty:function(){for(s in this.selectedHash){return false}return true},updateStateOfSymptoms:function(){var a=this.symptomsIsEmpty();this.emptySymptomsLabel.style.display=a?"block":"none";this.selectedSymptomsContainer.style.display=a?"none":"block"},getCurrentBodyPartTitle:function(){return this.currentBodyPartTitle?this.currentBodyPartTitle:""},showSymptoms:function(b){var a=b=="common";this.emptyTitle=false;if(!COMMON&&!this.isBigPart){this.showMenu(this.getCurrentBodyPartTitle())}this.common=a;this.dialogEl.clonePosition($("symcheckerEl"),{setWidth:false,setHeight:false,offsetTop:-10,offsetLeft:-10});this.dialogEl.style.display="block";this.customSymptoms.show(a);this.bodyPartSymptoms.show(!a)},closeDialog:function(){this.dialogEl.style.display="none"}};var SymcheckerButtonController=Class.create();SymcheckerButtonController.prototype={initialize:function(a){this.manager=a;this.manager.onBigPartSelected=this.enableAll.bind(this);this.manager.onShowPart=this.onShowPart.bind(this);this.gender=new Gender();this.gender.onChange=this.onBtnClick.bind(this);this.btnTurn=$("btnTurn");this.btnTurn.state="front";this.btnTurn.onclick=this.onBtnTurnClick.bindAsEventListener(this);this.btnToBody=$("btnToBody");this.btnToBody.onclick=this.onBtnToBodyClick.bindAsEventListener(this)},disableDashed:function(c,a){var b="";if(!a){b=c.innerHTML.replace('<a href="javascript:void(0)">',"<font>")}if(a){b=c.innerHTML.replace("<font>",'<a href="javascript:void(0)">')}c.innerHTML=b},showDashed:function(b,a){b.style.display=a==false?"none":"inline"},onShowPart:function(b,a){this.showDashed(this.btnToBody,false);this.showDashed(this.btnTurn);this.disableOneSide(a=="front")},onBtnToBodyClick:function(){this.manager.backToBody()},onBtnClick:function(a){if(a=="man"){this.manager.showMan()}else{this.manager.showWoman()}},onBtnTurnClick:function(a){if(this.btnTurn.state=="front"){this.manager.showBack()}else{this.manager.showFront()}},disableOneSide:function(a){var b=this.btnTurn.innerHTML;this.btnTurn.innerHTML=b.replace(a?SHOW_FRONT:SHOW_BACK,a?SHOW_BACK:SHOW_FRONT);this.btnTurn.state=a?"front":"back"},enableAll:function(){this.showDashed(this.btnToBody);this.showDashed(this.btnTurn,false)}};function onLittlePartSelected(a){}function onBigPartSelected(a){}function getPartName(a){}var SymcheckerManager=Class.create();SymcheckerManager.prototype={initialize:function(){new SymcheckerButtonController(this);this.parentMenuSeparator=$("parentSep");this.parentMenuPart=$("parentBodyPart");this.parentMenuPart.onclick=this.selectEntirePart.bind(this);this.symcheckerFloatHint=$("symcheckerFloatHint");this.symcheckerFloatHint.onmouseover=function(){this.style.display="none"};this.body_part=null;this.symptom=null;this.cachedSymptoms=[];this.cachedConditions=[];this.symptomManager=new SymptomManager(this);this.symptomManager.onSelectedSymptomsChanged=this.onSelectedSymptomsChanged.bind(this);this.conditionManager=new ConditionManager();this.symchecker=new Symchecker();this.symchecker.onBigPartSelected=this._onBigPartSelected.bind(this);this.symchecker.onLittlePartSelected=this._onLittlePartSelected.bind(this);this.symchecker.onPartHovered=this.getBodyPartTitle.bind(this);this.conditionsBlock=$("conditionsBlock");this.updateState();this.onShowPart(false,"front");this.is_man=false;this.is_woman=true;this.side="front";Event.observe(document.body,"mousemove",function(b){var a=Event.element(b).tagName;if(a!="AREA"&&a!="IMG"){this.symcheckerFloatHint.style.display="none"}}.bindAsEventListener(this))},onSelectedSymptomsChanged:function(a){this.symptoms=a;this.conditionsBlock.style.display=a.length>0?"block":"none";if(a.length==0){this.conditionManager.clear()}this.getConditions()},getBodyPartId:function(a){return BODY_PARTS[a][0]},getBodyPartTitle:function(b,a,f,c){var d=b;if(b!=""){d=BODY_PARTS[b][1]}a=Event.pointerX(c);f=Event.pointerY(c);this.symcheckerFloatHint.style.top=f+20+"px";this.symcheckerFloatHint.style.left=a+15+"px";this.symcheckerFloatHint.innerHTML=d;this.symcheckerFloatHint.style.display=d==""?"none":"block";return d},getBodyPartTitleById:function(a){return this.getBodyPartById(a)[1]},getBodyPartById:function(b){for(flash_id in BODY_PARTS){var a=BODY_PARTS[flash_id];if(a[0]==b){return a}}return null},selectEntirePart:function(){this.body_part=this.big_body_part;this.getSymptoms(true)},_onBigPartSelected:function(a){this.body_part=this.getBodyPartId(a);this.big_body_part=this.body_part;this.parentMenuSeparator.style.display="inline";this.parentMenuPart.innerHTML=this.getBodyPartTitleById(this.body_part);this.parentMenuPart.style.display="inline";if(this.onBigPartSelected){this.onBigPartSelected(a)}},_onLittlePartSelected:function(a){this.body_part=this.getBodyPartId(a);this.getSymptoms(false);if(this.onLittlePartSelected){this.onLittlePartSelected(a)}},showMan:function(){if(this.is_woman){this.updateState()}this.showPart(true,"front")},showWoman:function(){if(this.is_man){this.updateState()}this.showPart(false,"front")},showFront:function(){this.showPart(this.is_man,"front")},showBack:function(){this.showPart(this.is_man,"back")},showPart:function(c,b){this.hideMenu(c,b);this.side=b;if(this.onShowPart){this.onShowPart(c,b)}this.is_man=c;this.is_woman=!c;var a=(c?"man":"woman")+"_"+b;this.symchecker.showPart(a)},hideMenu:function(){this.parentMenuSeparator.style.display="none";this.parentMenuPart.style.display="none";this.symptomManager.clearMenu()},backToBody:function(){this.showPart(this.is_man,this.side)},updateState:function(){this.clear();this.getCustomSymptoms()},clear:function(){this.conditionsBlock.style.display="none";this.symptomManager.clear();this.conditionManager.clear();this.hideMenu()},getCustomSymptoms:function(){var a=this.getBodyPartTitleById(SYMCHECKER_COMMON_BODY_PART_ID);this.getData({body_part:SYMCHECKER_COMMON_BODY_PART_ID},this.symptomManager.renderCustomSymptoms.bind(this.symptomManager,a),this.cachedSymptoms)},getSymptoms:function(b){var a=this.getBodyPartTitleById(this.body_part);this.getData({body_part:this.body_part,is_man:this.is_man?"1":"0",is_woman:this.is_woman?"1":"0"},this.symptomManager.renderBodyPartSymptoms.bind(this.symptomManager,a,this.body_part,b),this.cachedSymptoms)},getConditions:function(){this.getData({symptom:this.symptoms,is_man:this.is_man?"1":"0",is_woman:this.is_woman?"1":"0"},this.conditionManager.renderConditions.bind(this.conditionManager),this.cachedConditions)},getData:function(d,c,b){var a=b[Object.toJSON(d)];if(a){c(a);return}this.getDataFromServer(d,c,b)},getDataFromServer:function(c,b,a){Tools.send(URL_GET_SYMCHECKER_DATA,function(d){var f=d.responseText.evalJSON();a[Object.toJSON(c)]=f;b.bind(this)(f)}.bind(this),null,c)}};var Symchecker=Class.create({onLittlePartSelected:function(){},onBigPartSelected:function(){},onPartHovered:function(){},initialize:function(){this.currentPart=$("el_woman_front");window.showCoords=this.onPartHovered.bind(this);this.symcheckerEl=$("symcheckerEl");this.symcheckerEl.onclick=this.onclick.bindAsEventListener(this);this.isDisplayNone=false;addMapper()},hideAllDivsAferLoad:function(){if(!this.isDisplayNone){this.symcheckerEl.select("div").each(function(a){a.style.display="none"});this.isDisplayNone=true}},showPart:function(a){this.showBigPartEl(a+"_big")},_showPart:function(a){this.hideAllDivsAferLoad();if(a.indexOf("_big")==-1){return this.onLittlePartSelected(this.cleanPartName(a))}this.showBigPartEl(a);this.onBigPartSelected(this.cleanPartName(a))},showBigPartEl:function(a){var b=$("el_"+a.replace("_big",""));this.currentPart.style.display="none";this.currentPart=b;this.currentPart.style.display="block";this.currentPart.style.visibility="visible";this.currentPart.style.position="static"},onPartHovered:function(d,h,b,j,f,a,g){if(h==0){h=""}var c=this.cleanPartName(h);this.onPartHovered(c,b,j,g)},cleanPartName:function(a){return a.replace(/(woman_|man_|1)/g,"")},onclick:function(c){var b=Event.element(c);if(b.tagName!="AREA"){return}var a=b.id.replace("1","");this._showPart(a)}});var canvascheck=document.createElement("canvas");var isIE=window.navigator.systemLanguage?1:0;var isVM=document.namespaces?1:0;var isJG=0;var isCV=canvascheck.getContext?1:0;var jg=new Array();if(isVM){if(document.namespaces.v==null){var e=["shape","shapetype","group","background","path","formulas","handles","fill","stroke","shadow","textbox","textpath","imagedata","line","polyline","curve","roundrect","oval","rect","arc","image"],s=document.createStyleSheet();for(var i=0;i<e.length;i++){s.addRule("v\\:"+e[i],"behavior: url(#default#VML); antialias: true;")}document.namespaces.add("v","urn:schemas-microsoft-com:vml")}}function showCoords(f,d,a,g,b,c){}function getClasses(d,c){var a="";for(var b=0;b<d.length;b++){if(d[b]!=c){if(a){a+=" "}a+=d[b]}}return a}function getClassValue(d,c){var a=0;var f=c.length;for(var b=0;b<d.length;b++){if(d[b].indexOf(c)==0){a=Math.min(d[b].substring(f),100);break}}return Math.max(0,a)}function getClassRGBColor(f,k,g){var o,b=g,n=k.length;for(var h=0;h<f.length;h++){if(f[h].indexOf(k)==0){o=f[h].substring(n);b=o.toLowerCase();break}}if(!b.match(/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i)){b=g||"000000"}if(!isCV){return b}else{function c(j){return(Math.max(0,Math.min(parseInt(j,16),255)))}var l=c(b.substr(0,2)),a=c(b.substr(2,2)),d=c(b.substr(4,2));return l+","+a+","+d}}function getClassAttribute(d,c){var a=0;var f=c.length;for(var b=0;b<d.length;b++){if(d[b].indexOf(c)==0){a=1;break}}return a}function getMaps(k){var d=document.getElementsByTagName("img");var b=new Array();var h=0;var f="";var c;var a;var g=0;var l="";for(h=0;h<d.length;h++){c=d[h];a=c.className.split(" ");for(g=0;g<a.length;g++){if(a[g]==k){f=c.useMap.split("#");if(f[1]!=""&&f[1].length>=1){l=document.getElementsByName(f[1]);if(l){b.push(c);break}}}}}return b}function fadeCanvas(c,a){var b=document.getElementById(c);if(b.fading==1&&a<=100){b.style.opacity=a/100;a+=90;window.setTimeout("fadeCanvas('"+c+"',"+a+")",2)}}function setAreaOver(J,N,A,B,E,C,U,D){var Z,T,S,V,W,O,X,P,Q,L,H,I,G,F,M,R=0,K="",L=J.getAttribute("rel"),g,h=document.getElementById(N);if(L!=null){V=L.split(",");H=V.unshift(J.id)}else{V=new Array(J.id)}function Y(){if(Q.indexOf("forcegroup")!=-1){R=getClassAttribute(I,"forcegroup")}else{R=0}if(Q.indexOf("iopacity")!=-1){O=getClassValue(I,"iopacity")/100}else{O=E}if(Q.indexOf("iborder")!=-1){X=getClassRGBColor(I,"iborder",A)}else{X=A}if(Q.indexOf("icolor")!=-1){W=getClassRGBColor(I,"icolor",B)}else{W=B}if(Q.indexOf("noborder")!=-1){P=getClassAttribute(I,"noborder")}else{P=C}}if(isVM){for(Z=0;Z<V.length;Z++){J=document.getElementById(V[Z]);if(J){M="",Q=J.className,I=Q.split(" "),H=J.coords.split(",");if(R==0){Y()}if(J.shape.toLowerCase()=="rect"){K+='<v:rect strokeweight="1" filled="t" stroked="'+(P<1?"t":"f")+'" strokecolor="#'+X+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+parseInt(H[0])+"px;top:"+parseInt(H[1])+"px;width:"+parseInt(H[2]-H[0])+"px;height:"+parseInt(H[3]-H[1])+'px;"><v:fill color="#'+W+'" opacity="'+O+'" /></v:rect>'}else{if(J.shape.toLowerCase()=="circle"){K+='<v:oval strokeweight="1" filled="t" stroked="'+(P<1?"t":"f")+'" strokecolor="#'+X+'" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+parseInt(H[0]-H[2])+"px;top:"+parseInt(H[1]-H[2])+"px;width:"+(parseInt(H[2])*2)+"px;height:"+(parseInt(H[2])*2)+'px;"><v:fill color="#'+W+'" opacity="'+O+'" /></v:oval>'}else{for(S=2;S<H.length;S+=2){M+=parseInt(H[S])+","+parseInt(H[S+1])+","}K+='<v:shape strokeweight="1" filled="t" stroked="'+(P<1?"t":"f")+'" strokecolor="#'+X+'" coordorigin="0,0" coordsize="'+h.width+","+h.height+'" path="m '+parseInt(H[0])+","+parseInt(H[1])+" l "+M+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+h.width+"px;height:"+h.height+'px;"><v:fill color="#'+W+'" opacity="'+O+'" /></v:shape>'}}}}h.innerHTML=K}else{if(isCV){if(U<1){h.fading=0;h.style.opacity=0}g=h.getContext("2d");for(Z=0;Z<V.length;Z++){J=document.getElementById(V[Z]);if(J){Q=J.className,I=Q.split(" "),H=J.coords.split(",");if(R==0){Y()}g.beginPath();if(J.shape.toLowerCase()=="rect"){g.rect(0.5+parseInt(H[0]),0.5+parseInt(H[1]),parseInt(H[2]-H[0]),parseInt(H[3]-H[1]));g.closePath()}else{if(J.shape.toLowerCase()=="circle"){g.arc(0.5+parseInt(H[0]),0.5+parseInt(H[1]),parseInt(H[2]),0,(Math.PI/180)*360,false)}else{g.moveTo(parseInt(H[0]),parseInt(H[1]));for(S=2;S<H.length;S+=2){g.lineTo(parseInt(H[S]),parseInt(H[S+1]))}g.closePath()}}g.fillStyle="rgba("+W+","+O+")";g.strokeStyle="rgba("+X+",1)";g.fill();if(P<1){g.stroke()}}}if(U<1){h.fading=1;fadeCanvas(N,0)}}else{O=E;Q=J.className;I=Q.split(" ");if(Q.indexOf("forcegroup")!=-1){R=getClassAttribute(I,"forcegroup");if(R!=0){if(Q.indexOf("iopacity")!=-1){O=getClassValue(I,"iopacity")/100;R=0}}}if(isIE){h.style.filter="Alpha(opacity="+(O*100)+")"}else{h.style.opacity=O;h.style.MozOpacity=O;h.style.KhtmlOpacity=O}for(Z=0;Z<V.length;Z++){J=document.getElementById(V[Z]);if(J){Q=J.className,I=Q.split(" "),H=J.coords.split(",");if(R==0){if(Q.indexOf("forcegroup")!=-1){R=getClassAttribute(I,"forcegroup")}else{R=0}if(Q.indexOf("icolor")!=-1){W=getClassRGBColor(I,"icolor",B)}else{W=B}}jg[D].setColor("#"+W);if(J.shape.toLowerCase()=="rect"){jg[D].fillRect(parseInt(H[0]),parseInt(H[1]),parseInt(H[2]-H[0])+1,parseInt(H[3]-H[1])+1)}else{if(J.shape.toLowerCase()=="circle"){jg[D].fillEllipse(parseInt(H[0]-H[2]),parseInt(H[1]-H[2]),parseInt(H[2])*2+1,parseInt(H[2])*2+1)}else{G=new Array();F=new Array();T=0;for(S=0;S<H.length;S+=2){G[T]=parseInt(H[S]);F[T]=parseInt(H[S+1]);T++}jg[D].fillPolygon(G,F)}}jg[D].paint()}}}}}function setAreaOut(d,h,c,g){var a=document.getElementById(h);if(isVM){a.innerHTML=""}else{if(isJG){jg[g].clear()}else{if(isCV){var b=a.getContext("2d");b.clearRect(0,0,a.width,a.height)}}}}function getCoords(F,A,H,B,k,j,l,C,v,G){var p,z,g,f,E,D,d,c,u=0,r=0;if(!F){F=window.event}if(F.pageX||F.pageY){u=F.pageX;r=F.pageY}E=F.clientX;D=F.clientY;if(self.pageXOffset||self.pageYOffset){g=self.pageXOffset;if(g>0&&u==E){E-=g}f=self.pageYOffset;if(f>0&&r==D){D-=f}}else{if(document.documentElement){g=document.documentElement.scrollLeft;f=document.documentElement.scrollTop}else{if(document.body){g=document.body.scrollLeft;f=document.body.scrollTop}}}if(document.body.scrollHeight!=G||document.body.scrollWidth!=v){var z=document.getElementById(B);var p=findPosXY(z);k=p.x;j=p.y}d=Math.min(Math.max(E+g-k,0),l);c=Math.min(Math.max(D+f-j,0),C);if(Prototype.Browser.IE){var b=Event.element(F);if(b.tagName=="AREA"){H=b.id}}showCoords(A,H,d,c,l,C,F)}function findPosXY(b){var a;var c={x:b.offsetLeft,y:b.offsetTop};if(b.offsetParent){a=findPosXY(b.offsetParent);c.x+=a.x;c.y+=a.y}return c}function roundedRect(d,c,h,g,b,a,f){if(!f){d.beginPath()}d.moveTo(c,h+a);d.lineTo(c,h+b-a);d.quadraticCurveTo(c,h+b,c+a,h+b);d.lineTo(c+g-a,h+b);d.quadraticCurveTo(c+g,h+b,c+g,h+b-a);d.lineTo(c+g,h+a);d.quadraticCurveTo(c+g,h,c+g-a,h);d.lineTo(c+a,h);d.quadraticCurveTo(c,h,c,h+a);if(!f){d.closePath()}}function getRadius(b,d,a){var c=(Math.min(d,a)/100);b=Math.max(Math.min(100,b/c),0);return b+"%"}function addMapper(){var a=getMaps("mapper");var G,W,l,k,U,g,v,p,C,J;var P="",V="",u="",R,L,K,H,T,Q,O,E,D,I,N,A,z,B,M,F,S;for(L=0;L<a.length;L++){G=a[L];W=G.parentNode;if(G.id==""){G.id="gmipam_"+L}W.style.position=(W.style.position=="static"||W.style.position==""?"relative":W.style.position);W.style.height=G.height+"px";W.style.width=G.width+"px";W.style.padding=0+"px";W.style.MozUserSelect="none";W.style.KhtmlUserSelect="none";W.unselectable="on";E=0;I=0;N=0;T="0000ff";Q="000000";H=33;if(isCV){k=document.createElement("canvas")}else{if(isVM){k=document.createElement(['<var style="zoom:1;overflow:hidden;display:block;width:'+G.width+"px;height:"+G.height+'px;padding:0;">'].join(""))}else{k=document.createElement("div")}}k.id=G.id+"_canvas";P=G.className.split(" ");E=getClassValue(P,"iradius");H=getClassValue(P,"iopacity");T=getClassRGBColor(P,"iborder","0000ff");Q=getClassRGBColor(P,"icolor","000000");I=getClassAttribute(P,"noborder");N=getClassAttribute(P,"nofade");O=getClassAttribute(P,"showcoords");H=H==0?0.33:H/100;E=parseInt(Math.min(Math.min(G.width/4,G.height/4),E));V=getClasses(P,"mapper");G.className=V;p=G.useMap.split("#");p=p[1];v=document.getElementsByName(p);if(v.length>0){for(K=0;K<v[0].areas.length;K++){if(v[0].areas[K].shape.match(/(rect|poly|circle)/i)){if(window.opera||v[0].areas[K].coords!=""){if(v[0].areas[K].id==""){v[0].areas[K].id=p+"_"+K}if(isVM||isIE){u=v[0].areas[K].onmouseover;if(u!=null){R=String(u);u=R.substr(23,R.length-25)}v[0].areas[K].onmouseover=new Function('setAreaOver(this,"'+k.id+'","'+T+'","'+Q+'","'+H+'",'+I+","+N+","+L+");"+u);u=v[0].areas[K].onmouseout;if(u!=null){R=String(u);u=R.substr(23,R.length-25)}v[0].areas[K].onmouseout=new Function('setAreaOut(this,"'+k.id+'",'+N+","+L+");"+u)}else{u=v[0].areas[K].getAttribute("onmouseover");v[0].areas[K].setAttribute("onmouseover","setAreaOver(this,'"+k.id+"','"+T+"','"+Q+"','"+H+"',"+I+","+N+","+L+");"+u);u=v[0].areas[K].getAttribute("onmouseout");v[0].areas[K].setAttribute("onmouseout","setAreaOut(this,'"+k.id+"',"+N+","+L+");"+u)}}}}}k.style.height=G.height+"px";k.style.width=G.width+"px";k.height=G.height;k.width=G.width;k.left=0;k.top=0;k.style.position="absolute";k.style.left=0+"px";k.style.top=0+"px";k.fading=0;G.className="";G.style.cssText="";G.left=0;G.top=0;G.style.position="absolute";G.style.height=G.height+"px";G.style.width=G.width+"px";G.style.left=0+"px";G.style.top=0+"px";G.style.MozUserSelect="none";G.style.KhtmlUserSelect="none";G.unselectable="on";if(isIE){G.style.filter="Alpha(opacity=0)"}else{G.style.opacity=0;G.style.MozOpacity=0;G.style.KhtmlOpacity=0}if(isCV&&E>0){l=document.createElement("canvas")}else{if(isVM&&E>0){l=document.createElement(['<var style="zoom:1;overflow:hidden;display:block;width:'+G.width+"px;height:"+G.height+'px;padding:0;">'].join(""))}else{l=document.createElement("img");l.src=G.src}}l.id=G.id+"_image";l.left=0;l.top=0;l.style.position="absolute";l.style.height=G.height+"px";l.style.width=G.width+"px";l.style.left=0+"px";l.style.top=0+"px";W.insertBefore(k,G);U=document.createElement("div");U.id=p+"_blind";U.className="blind_area";U.left=0;U.top=0;U.style.position="absolute";U.style.height=G.height+"px";U.style.width=G.width+"px";U.style.left=0+"px";U.style.top=0+"px";U.innerHTML=" ";W.insertBefore(U,G);if(isCV){g=k.getContext("2d");g.clearRect(0,0,k.width,k.height)}else{if(!isVM&&!isCV){if(isIE){k.style.filter="Alpha(opacity="+(H*100)+")"}else{k.style.opacity=H;k.style.MozOpacity=H;k.style.KhtmlOpacity=H}if(typeof(window.jsGraphics)!=="undefined"){jg[L]=new jsGraphics(k);isJG=1}}}W.insertBefore(l,k);if(isCV&&E>0){l.height=G.height;l.width=G.width;g=l.getContext("2d");g.clearRect(0,0,l.width,l.height);roundedRect(g,0,0,l.width,l.height,E);g.clip();g.fillStyle="rgba(0,0,0,0)";g.fillRect(0,0,l.width,l.height);g.drawImage(G,0,0,l.width,l.height)}else{if(isVM&&E>0){l.height=G.height;l.width=G.width;E=getRadius(E,l.width,l.height);l.innerHTML='<v:roundrect arcsize="'+E+'" strokeweight="0" filled="t" stroked="f" fillcolor="#ffffff" style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:0px;top:0px;width:'+l.width+"px;height:"+l.height+'px;"><v:fill src="'+G.src+'" type="frame" /></v:roundrect>'}}if(O>0){C=document.getElementById(G.id);B=parseInt(G.width);M=parseInt(G.height);D=findPosXY(C);A=D.x;z=D.y;S=document.body.scrollHeight;F=document.body.scrollWidth;if(isVM||isIE){u=G.onmousemove;if(u!=null){R=String(u);u=R.substr(23,R.length-25)}G.onmousemove=new Function('getCoords(event,"'+p+'",0,"'+G.id+'",'+A+","+z+","+B+","+M+","+F+","+S+");"+u)}else{u=G.getAttribute("onmousemove");G.setAttribute("onmousemove","getCoords(event,'"+p+"',0,'"+G.id+"',"+A+","+z+","+B+","+M+","+F+","+S+");"+u)}if(v.length>0){for(K=0;K<v[0].areas.length;K++){if(v[0].areas[K].shape.match(/(rect|poly|circle)/i)){if(window.opera||v[0].areas[K].coords!=""){J=v[0].areas[K].id;if(isVM||isIE){u=v[0].areas[K].onmousemove;if(u!=null){R=String(u);u=R.substr(23,R.length-25)}v[0].areas[K].onmousemove=new Function('getCoords(event,"'+p+'","'+J+'","'+G.id+'",'+A+","+z+","+B+","+M+","+F+","+S+");"+u)}else{u=v[0].areas[K].getAttribute("onmousemove");v[0].areas[K].setAttribute("onmousemove","getCoords(event,'"+p+"','"+J+"','"+G.id+"',"+A+","+z+","+B+","+M+","+F+","+S+");"+u)}}}}}}}}var CaptchaManager=Class.create();CaptchaManager.prototype={initialize:function(){this.refresh_path=CAPTCHA_REFRESH_PATH;this.refreshLink=$("refresh_captcha");if(this.refreshLink){this.refreshLink.onclick=this.refreshCaptcha.bind(this)}},refreshCaptcha:function(){Tools.send(this.refresh_path,this.onResponse.bind(this))},onResponse:function(a){var b=a.responseText;if(b.length==0){return}var c=Tools.fgGetElementByClassName("captcha",document)[0];var d=$("id_captcha_0");if(c.tagName!="IMG"||!d){return}c.src="/captcha/image/"+b;d.value=b}};var LoginManager=Class.create();LoginManager.prototype={initialize:function(b){this.loginLink=b;this.loginLinks=$$(".show-login");this.forgotLink=$("forgot_link");this.registerFromLoginLink=$("register_from_login_link");this.registerFromLoginLink.href="javascript:void(0)";this.doLoginButton=$("do_login");this.doLoginButton.disabled=true;this.usernameFld=$("username");this.passwordFld=$("password");this.passwordFld.error=$("id_login_error");this.isErrorShowed=true;this.rememberMeChbx=$("remember_me");this.dialogMode=$("login_dialog");this.passwdManager=new PassRemindManager(this,this.forgotLink);if(this.dialogMode){this.dialog=new DialogWidget("login_dialog",566,261,false,true);this.dialog.opener=[this.loginLink,this.passwdManager.getLoginOpenerLink()].concat(this.loginLinks);this.dialog.closeByOutClick=true;this.dialog.onShow=function(){var c=$$(".b-profile-small")[0];this.dialogEl.clonePosition(c,{setWidth:false,setHeight:false,offsetTop:30,offsetLeft:-437})};this.dialog.onEnterPress=this.sendRequest.bind(this)}else{this.el=$("login_content");this.el.onclick=this.checkFields.bind(this);Event.observe(this.el,"keypress",function(d){if(!d){d=window.event}var c=d.keyCode?d.keyCode:d.charCode;if(c!=Event.KEY_RETURN){return false}if(this.isValid()){this.sendRequest()}Event.stop(d)}.bindAsEventListener(this))}$$(".show-registration").each(function(c){c.onclick=this.showScroll.bind(this)}.bind(this));this.loginLinks.each(function(c){c.onclick=this.showScrollLogin.bind(this)}.bind(this));var a=document.location.href.toQueryParams()["next"];if(a){$("returnUrl").value=a}this.loginForm=$("login_form");this.bind();if(!this.dialogMode){this.checkFields()}},showScroll:function(){this.showRegisterDialog();return false},showScrollLogin:function(){this.show();return false},bind:function(){if(this.loginLink){this.loginLink.onclick=this.show.bind(this)}this.forgotLink.onclick=this.showPasswordRemindDialog.bind(this);this.registerFromLoginLink.onclick=this.showRegisterDialog.bindAsEventListener(this);this.doLoginButton.onclick=this.sendRequest.bind(this);this.usernameFld.onkeyup=this.checkFields.bind(this);this.usernameFld.onclick=this.checkFields.bind(this);this.passwordFld.onchange=this.checkFields.bind(this);this.passwordFld.onkeyup=this.checkFields.bind(this);$$(".b-login")[0].onmousemove=this.checkFields.bind(this)},hidePswd:function(){if(this.isErrorShowed){return}Tools.hideFade(this.passwordFld.error);this.isErrorShowed=true},checkFields:function(a){if(this.startedSubmit){return}if(this.requestMode){this.requestMode=false;return}this.passwordFld.error.innerHTML="";if(this.isValid()){this.doLoginButton.disabled=false}else{this.doLoginButton.disabled=true}},isValid:function(){if(this.usernameFld.value.replace(/\s*/,"")==""){return false}if(this.passwordFld.value.replace(/\s*/,"")==""){return false}return true},show:function(){var a="/login/";this.usernameFld.value="";this.passwordFld.value="";if(this.dialogMode){this.hideRegisterDialog();this.dialog.show()}else{this.el.style.display="block";if(location.pathname!=a){location.href=a}}setTimeout(function(){this.usernameFld.focus()}.bind(this),10)},sendRequest:function(){this.doLoginButton.disabled=true;this.startedSubmit=true;this.requestMode=true;Tools.send(AJAX_LOGIN_PATH,this.onResponse.bind(this),null,{username:Base64.encode(this.usernameFld.value),password:Base64.encode(this.passwordFld.value),remember:this.rememberMeChbx.checked})},onResponse:function(a){var a=a.responseText.evalJSON();if(a.status=="OK"){if(this.dialogMode){this.dialog.hide()}this.loginForm.action="";this.loginForm.submit()}else{this.startedSubmit=false;this.doLoginButton.disabled=false;this.showError(a.error)}},showError:function(a){this.passwordFld.error.innerHTML=a;this.isErrorShowed=false},showRegisterDialog:function(a){if(!this.dialog){return}Event.stop(a);this.dialog.hide();if(this.regManager){return this.regManager.show()}this.regManager=new RegisterManager(this);return false},hideRegisterDialog:function(){if(this.regManager){this.regManager.dialog.hide()}},hide:function(){if(this.dialogMode){this.dialog.hide()}else{this.el.style.display="none"}},showPasswordRemindDialog:function(){this.hide();this.passwdManager.show()}};var PasswdManager=Class.create();PasswdManager.prototype={initialize:function(){this.dialog=$("login_content");this.passwd1=$("password1");this.passwd2=$("password2");this.code=$("code");this.error=$("id_pwd_error");this.button=$("do_change");this.bind()},bind:function(){this.button.onclick=this.button_click.bind(this);Event.observe(this.dialog,"keypress",function(b){if(!b){b=window.event}var a=b.keyCode?b.keyCode:b.charCode;if(a!=Event.KEY_RETURN){return false}this.button_click(b);Event.stop(b)}.bindAsEventListener(this))},sendRequest:function(){this.button.disabled=true;Tools.send(AjaxHandlerUrl,this.onResponse.bind(this),null,{password1:Base64.encode(this.passwd1.value),password2:Base64.encode(this.passwd2.value),ajax:1,code:this.code.value})},button_click:function(a){if(this.validate_input()){this.sendRequest()}else{this.error.innerHTML=Txt_IncorrectInputData}},onResponse:function(a){var b=a.responseText.evalJSON();if(b.status=="OK"){window.location=Txt_ReturnUrl;return}this.error.innerHTML=b.error},validate_input:function(){if(this.passwd1.value.replace(/\s*/,"")==""){return false}if(this.passwd2.value.replace(/\s*/,"")==""){return false}if(this.passwd1.value!=this.passwd2.value){return false}return true}};var PassRemindManager=Class.create();PassRemindManager.prototype={initialize:function(a,b){this.dialogCaller=a;this.dialogMode=$("register_dialog");if(this.dialogMode){this.dialog=new DialogWidget("password_remind_dialog",566,196,false,true);this.dialog.opener=b;this.dialog.closeByOutClick=true;this.dialog.onShow=function(){var c=$$(".b-profile-small")[0];this.dialogEl.clonePosition(c,{setWidth:false,setHeight:false,offsetTop:30,offsetLeft:-437})};this.dialog.onEnterPress=this.sendRequest.bind(this)}else{this.el=$("reminder_content")}this.passOrEmailFld=$("username_or_email");this.passOrEmailFld.error=$("id_username_or_email_error");this.sendPasswordButton=$("send_password_button");this.fromReminderToLoginLink=$("from_reminder_to_login_link");this.sendPasswordButton.disabled=true;this.bind()},getLoginOpenerLink:function(){return this.fromReminderToLoginLink},bind:function(){this.sendPasswordButton.onclick=this.sendRequest.bind(this);this.passOrEmailFld.onkeyup=this.checkPassOrEmailField.bind(this);this.fromReminderToLoginLink.onclick=this.goBackToLoginDialoig.bind(this)},checkPassOrEmailField:function(){this.passOrEmailFld.error.innerHTML="";if(this.passOrEmailFld.value.replace(/\s*/,"")==""){this.sendPasswordButton.disabled=true}else{this.sendPasswordButton.disabled=false}},show:function(){window.validationManager=new AdminValidationManager(this.requiredFields);this.passOrEmailFld.value="";if(this.dialogMode){this.dialog.show()}else{this.el.style.display="block"}setTimeout(function(){this.passOrEmailFld.focus()}.bind(this),10)},goBackToLoginDialoig:function(){if(this.dialogMode){this.dialog.hide()}else{this.el.style.display="none"}this.dialogCaller.show()},sendRequest:function(){Tools.send(PASSWORD_RESET_PATH,this.onResponse.bind(this),null,{email:Base64.encode(this.passOrEmailFld.value)});this.sendPasswordButton.disabled=true},onResponse:function(a){var a=a.responseText.evalJSON();this.sendPasswordButton.disabled=false;if(a.status=="OK"){this.goBackToLoginDialoig();alert(NEW_PASSWORD_SEND_SUCCESSFULLY)}else{this.showError(a.error)}},showError:function(a){this.passOrEmailFld.error.innerHTML=a}};var RegisterManager=Class.create();RegisterManager.prototype={initialize:function(a){this.dialogCaller=a;var b=$("register_dialog");this.dialogMode=b;this.usernameFld=$("id_username");this.usernameFld.error=$("id_username_error");this.emailFld=$("id_email");this.emailFld.error=$("id_email_error");this.password1Fld=$("id_password1");this.password1Fld.error=$("id_password1_error");this.password2Fld=$("id_password2");this.password2Fld.error=$("id_password2_error");this.captcha0Fld=$("id_captcha_0");this.captcha1Fld=$("id_captcha_1");this.captcha1Fld.error=$("id_captcha_1_error");this.receiveNotifications=$("id_receive_notifications");this.agreement=$("id_tos");this.agreement.checked=false;this.formFields=[this.usernameFld,this.emailFld,this.password1Fld,this.password2Fld,this.captcha1Fld];this.doRegisterButton=$("do_register_button");this.doRegisterButton.disabled=true;this.gender=new Gender("register");this.removeGenderFields();this.rValidManager=new RegisterValidationManager2();if(this.dialogMode){this.dialog=new DialogWidget(b,566,521,false,true);this.dialog.closeByOutClick=true;this.dialog.onShow=function(){var c=$$(".b-profile-small")[0];this.dialogEl.clonePosition(c,{setWidth:false,setHeight:false,offsetTop:30,offsetLeft:-437})};$("from_register_to_login_link").onclick=this.goBackToLoginDialog.bindAsEventListener(this);$("from_register_to_login_link").href="javascript:void(0)"}this.doRegisterButton.onclick=this.sendRegisterRequest.bind(this);this.show()},removeGenderFields:function(){if(!IS_WOMAN_MODULE){return}var a=$$(".b-registration-gender");a.each(function(b){b.innerHTML=""}.bind(this))},show:function(){this.resetWarnings();for(var a=0;a<this.formFields.length;a++){this.formFields[a].value=""}$("id_subscribe_span").style.display="none";this.captcha=new CaptchaManager();if(this.dialogMode){this.dialog.show()}setTimeout(function(){this.usernameFld.focus()}.bind(this),10)},resetWarnings:function(){$$(".g-not-valid").each(function(a){a.removeClassName("g-not-valid")});this.rValidManager.hideErrors(null)},goBackToLoginDialog:function(a){if(!this.dialog){return}Event.stop(a);this.dialog.hide();this.dialogCaller.show();return false},sendRegisterRequest:function(){var a=(this.gender.getValue()?(this.gender.getValue()=="man"?"M":"F"):"F");this.doRegisterButton.disabled=true;Tools.send(AJAX_REGISTER_PATH,this.onResponse.bind(this),null,{username:this.usernameFld.value,email:this.emailFld.value,gender:a,password1:this.password1Fld.value,password2:this.password2Fld.value,captcha_0:this.captcha0Fld.value,captcha_1:this.captcha1Fld.value,receive_notifications:this.receiveNotifications.checked,tos:this.agreement.checked})},getLink:function(){return this.dialogMode?document.location.href:$("returnUrl").value},onResponse:function(a){var a=a.responseText.evalJSON();if(a.status=="OK"){if(this.dialogMode){this.dialog.hide()}document.location.href=this.getLink()}else{if(this.captcha){this.captcha.refreshCaptcha()}this.showError(a.error)}},showError:function(a){this.rValidManager.onValidate(a)}};var RegisterValidationManager=Class.create();RegisterValidationManager.prototype={initialize:function(a,b,c){this.usernameFld=a[0];this.emailFld=a[1];this.password1Fld=a[2];this.password2Fld=a[3];this.captcha1Fld=a[4];this.agreement=b;this.subscribeBlock=$("id_subscribe_span");this.doRegisterButton=c;this.nonValidFields=[];this.error="";this.bind();this.lastSentUsername="";this.lastSentEmail="";this.unmarkAllErrors(a);this.usernameExist=false;this.emailExist=false},unmarkAllErrors:function(a){for(var b=0;b<a.length;b++){this.unmarkError(a[b])}},bind:function(a){this.usernameFld.onblur=this.checkUsername.bind(this);this.usernameFld.onkeyup=this.uncheckAgreementCheckbox.bind(this);this.emailFld.onblur=this.checkEmail.bind(this);this.emailFld.onkeyup=this.uncheckAgreementCheckbox.bind(this);this.password1Fld.onblur=this.checkPassword1.bind(this);this.password1Fld.onkeyup=this.uncheckAgreementCheckbox.bind(this);this.password2Fld.onblur=this.checkPassword2.bind(this);this.password2Fld.onkeyup=this.uncheckAgreementCheckbox.bind(this);this.captcha1Fld.onblur=this.checkCaptcha.bind(this);this.captcha1Fld.onkeyup=this.uncheckAgreementCheckbox.bind(this);this.agreement.onchange=this.showOrHideButton.bind(this)},uncheckAgreementCheckbox:function(){this.agreement.checked=false;this.showOrHideButton()},unmarkError:function(a){Element.removeClassName(a,"g-not-valid");this.nonValidFields.pop();a.error.innerHTML="";a.error.style.display="none";this.agreement.checked=false},markError:function(a){Element.addClassName(a,"g-not-valid");this.pushIfNeed(a);if(a==this.emailFld){this.subscribeBlock.style.display="none"}a.error.innerHTML=this.error;a.error.style.display="block";this.agreement.checked=false},pushIfNeed:function(b){for(var a=0;a<this.nonValidFields.length;a++){if(this.nonValidFields[a]==b){return}}this.nonValidFields.push(b)},checkCaptcha:function(){var a=this.captcha1Fld.value;if(a.replace(/\s*/,"")==""){this.error="";this.markError(this.captcha1Fld)}else{this.unmarkError(this.captcha1Fld)}this.showOrHideButton()},checkPassword1:function(){var b=this.password1Fld.value;if(b.replace(/\s*/,"")==""){this.error="";this.markError(this.password1Fld)}else{this.unmarkError(this.password1Fld);var a=this.password2Fld.value.replace(/\s*/,"");if(a!=""){this.error=window.PASSWORDS_IS_NOT_EQUAL;if(b!=a){this.markError(this.password2Fld)}else{this.unmarkError(this.password2Fld)}}}this.showOrHideButton()},checkPassword2:function(){var a=this.password2Fld.value;var b=a.replace(/\s*/,"")==""||a!=this.password1Fld.value;if(b){this.error=a.replace(/\s*/,"")==""?"":window.PASSWORDS_IS_NOT_EQUAL;this.markError(this.password2Fld)}else{this.unmarkError(this.password2Fld)}this.showOrHideButton()},checkEmail:function(){var b=this.emailFld.value;if(b.replace(/\s*/,"")==""){this.error="";return this.validateEmail({responseText:""})}var a=/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/;if(!a.test(b)){this.error=window.NOT_VALID_EMAIL;return this.validateEmail({responseText:""})}if(b!=this.lastSentEmail){this.lastSentEmail=b;Tools.send(CHECK_EMAIL_PATH,this.validateEmail.bind(this),null,{email:b})}if(!this.emailExist){this.unmarkError(this.emailFld)}this.showOrHideButton()},validateEmail:function(b){var a=b.responseText;if(a=="NO"){this.error=window.EMAIL_IS_REGISTERED}if(a=="NO"||a==""){this.emailExist=true;this.markError(this.emailFld)}else{this.emailExist=false;this.unmarkError(this.emailFld);this.subscribeBlock.style.display="block"}this.showOrHideButton()},checkUsername:function(){var b=this.usernameFld.value;if(b.replace(/\s*/,"")==""){this.error="";return this.validateUsername({responseText:""})}var a=/^[A-Za-z0-9_]+$/;if(!a.test(b)){this.error=window.NOT_VALID_SYMBOLS;return this.validateUsername({responseText:""})}if(this.lastSentUsername!=b){this.lastSentUsername=b;Tools.send(CHECK_USERNAME_PATH,this.validateUsername.bind(this),null,{username:b});return}if(!this.usernameExist){this.unmarkError(this.usernameFld)}this.showOrHideButton()},validateUsername:function(b){var a=b.responseText;if(a=="NO"){this.error=window.USER_ALREADY_REGISTERED}if(a=="NO"||a==""){this.usernameExist=true;this.markError(this.usernameFld)}else{this.usernameExist=false;this.unmarkError(this.usernameFld)}this.showOrHideButton()},showOrHideButton:function(){if(this.nonValidFields.length==0&&this.agreement.checked){this.doRegisterButton.disabled=false}else{this.doRegisterButton.disabled=true}}};var RegisterValidationManager2=Class.create({initialize:function(){this.fieldNames=$A(["username","email","password1","password2","captcha_1"]);this.fields={};this.fieldErrors={};this.validator=new RegisterValidationLogic();this.validator.onValidate=this.onValidate.bind(this);this.agreement=$("id_tos");this.subscribeBlock=$("id_subscribe_span");this.btnRegister=$("do_register_button");this.emptyMode=true;this.bind()},hideErrors:function(a){for(var b in this.fieldErrors){if(a&&b!=a&&!b.include("password")){continue}this.hideError(b)}},hideError:function(a){this.fields[a].removeClassName("g-not-valid");this.fieldErrors[a].style.display="none"},showErrors:function(c){for(var b=0;b<c.length;b++){var a=c[b];this.showError(a)}},showError:function(b){var d=b.field;if(d=="captcha"){d="captcha_1"}var c=b.message=="empty";if((this.emptyMode&&c)||b.message==true){return}if(!this.fields[d]){return}this.fields[d].addClassName("g-not-valid");var a=this.fieldErrors[d];a.style.display="block";message=c?"":b.message;a.innerHTML=message},bind:function(){this.fieldNames.each(function(c){var b=$("id_"+c);var a=$("id_"+c+"_error");this.fields[c]=b;this.fieldErrors[c]=a;b.onblur=this.validate.bind(this,c,false);b.onkeyup=this.validate.bind(this,c,true)}.bind(this));this.agreement.onclick=this._onAgreementChange.bind(this)},validate:function(a,b){this.hideErrors(a);this.keyupMode=b;this.validator.validate({username:this.fields.username.value,email:this.fields.email.value,passwords:[this.fields.password1.value,this.fields.password2.value],captcha_1:this.fields.captcha_1.value})},isValidEverything:function(b){if(this.emptyMode){return false}if($F(this.agreement)!="on"){return false}for(var a=0;a<b.length;a++){if(b[a].message!=true){return false}}return true},updateSubscribeBlock:function(c){var b=false;for(var a=0;a<c.length;a++){b=c[a].field=="email";if(b&&c[a].message==true){return this.subscribeBlock.style.display="block"}}if(!b){return}this.subscribeBlock.style.display="none"},onValidate:function(a){if(!this.keyupMode){this.showErrors(a)}var b=this.isValidEverything(a);this.updateSubscribeBlock(a);this.btnRegister.disabled=!b},_onAgreementChange:function(){this.emptyMode=$F(this.agreement)!="on";this.validate()}});var RegisterValidationLogic=Class.create({EMPTY:"empty",VALID:true,NOT_VALID:"NO",initialize:function(){this.msgFuncs={};this.rules={username:this.validateUserName.bind(this),email:this.validateEmail.bind(this),passwords:this.validatePasswords.bind(this),captcha_1:this.validateCaptcha.bind(this)};this.ajaxCache={}},removeSpaces:function(a){return a.replace(/\s*/,"")},responseIsNotValid:function(a){return a.responseText==this.NOT_VALID},getMsgFunc:function(a){if(!this.msgFuncs[a]){this.msgFuncs[a]=function(b){return{field:a,message:b}}}return this.msgFuncs[a]},validateUserName:function(a){var c=this.getMsgFunc("username");a=this.removeSpaces(a);if(a==""){return c(this.EMPTY)}if(!Tools.isWord(a)){return c(NOT_VALID_SYMBOLS)}if(a.length<3){return c(USERNAME_TOO_SHORT)}if(RESERVED_WORDS.indexOf(a)!=-1){return c(USERNAME_RESERVED_WORD)}var b="username"+a;if(this.ajaxCache[b]){return this.ajaxCache[b]}Tools.send(CHECK_USERNAME_PATH,function(d){var f="";if(this.responseIsNotValid(d)){f=c(USER_ALREADY_REGISTERED)}else{f=c(this.VALID)}this.ajaxCache[b]=f;return this.onValidationResponse(f)}.bind(this),null,{username:a});return false},validateEmail:function(a){a=this.removeSpaces(a);var c=this.getMsgFunc("email");if(a==""){return c(this.EMPTY)}if(!Tools.isEmail(a)){return c(NOT_VALID_EMAIL)}var b="email"+a;if(this.ajaxCache[b]){return this.ajaxCache[b]}Tools.send(CHECK_EMAIL_PATH,function(d){if(this.responseIsNotValid(d)){value=c(EMAIL_IS_REGISTERED)}else{value=c(this.VALID)}this.ajaxCache[b]=value;return this.onValidationResponse(value)}.bind(this),null,{email:a});return false},validatePasswords:function(f){var c=this.getMsgFunc("password1");var a=this.getMsgFunc("password2");var d=f[0];var b=f[1];if(d==""){return c(this.EMPTY)}if(b==""){return a(this.EMPTY)}if(d!=b){return a(PASSWORDS_IS_NOT_EQUAL)}return a(this.VALID)},validateCaptcha:function(a){a=this.removeSpaces(a);var b=this.getMsgFunc("captcha_1");if(a==""){return b(this.EMPTY)}return b(this.VALID)},onValidationResponse:function(a){this.validationResult.push(a);this.waitServerResponse=this.waitServerResponse.without(a.field);if(this.waitServerResponse.length==0){this.fireOnValidate()}},validate:function(b){this.validationResult=[];this.waitServerResponse=[];for(field in b){var a=this.rules[field](b[field]);if(a==false){this.waitServerResponse.push(field);continue}this.validationResult.push(a)}if(this.waitServerResponse.length==0){this.fireOnValidate()}},fireOnValidate:function(){if(this.onValidate){this.onValidate(this.validationResult)}}});ValidationManager=Class.create();ValidationManager.prototype={initialize:function(a,b){this.el=$(a);this.requiredFields=b;this.initInputs()},initInputs:function(){this.inputElems=[];this.getValidationInputs();this.inputValidators=[];this.inputElems.each(function(a){var b=(a.tagName=="SELECT"||a.type=="checkbox");Event.observe(a,"keyup",this._validate.bindAsEventListener(this));new_input_validator=new InputValidator(this,a,b?"change":null);this.inputValidators.push(new_input_validator);this.fillReferencedValidators(new_input_validator)}.bind(this));if(this.isReferencedValidatorsFilled()){this.main_validator.setReferenced(this.validator_to_reference)}},fillReferencedValidators:function(a){if(a.el.getAttribute("referenced")){this.main_validator=a}if(this.main_item&&a.el.id==this.main_item.referenced){this.validator_to_reference=a}},isReferencedValidatorsFilled:function(){if(this.main_validator&&this.validator_to_reference){return true}return false},getValidationInputs:function(){if(!this.requiredFields){return this.inputElems=$$(this.el.tagName+" input,"+this.el.tagName+" select")}var d=document.getElementsByTagName("LABEL");for(var a=0;a<this.requiredFields.length;a++){var c=this.requiredFields[a];var b=$(c.id);if(!b){continue}b=this.setElLabels(d,b);if(c.notempty_input){b.setAttribute("notempty","")}if(c.date){b.setAttribute("date","")}if(c["int"]){b.setAttribute("int","")}if(c.url){b.setAttribute("url","")}if(c.tiny){b.setAttribute("tiny","")}if(c.email){b.setAttribute("email","")}if(c.equals_to){b.setAttribute("equals_to",c.equals_to)}if(c.trim_spaces){b.setAttribute("trim_spaces",c.trim_spaces)}if(c.checkbox){b.setAttribute("checkbox","")}if(c.time){b.setAttribute("time","")}if(c.referenced){b.setAttribute("referenced",c.referenced);this.main_item=c}this.inputElems.push(b)}},setElLabels:function(c,b){for(var a=0;a<c.length;a++){if(c[a].htmlFor==b.id){b.label=c[a]}}return b},valide:function(b){var a=true;this.inputValidators.each(function(c){if(!c.valide(b)){a=false}});return a},removeHighLight:function(){this.inputValidators.each(function(a){a.removeHighLight()})},_validate:function(){if(this.onValide){return this.onValide(this.valide(false))}}};InputValidator=Class.create();InputValidator.prototype={initialize:function(b,c,a){this.manager=b;this.el=$(c);this.setReferenced();this.el_label=this.el.label;this.notValideClass="g-not-valid";if(this.el.hasAttribute("tiny")){tinyMCE.get(this.el.id).onKeyUp.add(this.onchange.bindAsEventListener(this))}Event.observe(this.el,"blur",this.onchange.bindAsEventListener(this));Event.observe(this.el,"blur",this.trimSpaces.bind(this));if(!a){Event.observe(this.el,"keyup",this.onchange.bindAsEventListener(this))}else{Event.observe(this.el,a,this.onchange.bindAsEventListener(this))}},onchange:function(){this.removeHighLight();if(this.referenced){this.referenced.removeHighLight()}this.manager._validate()},setReferenced:function(a){this.referenced=a},removeHighLight:function(){$(this.el).removeClassName(this.notValideClass);if(this.el_label){$(this.el_label).removeClassName(this.notValideClass)}},valide:function(b){var j=this.urlCondition();var a=this.emptyCondition();var h=this.tinyCondition();var c=this.emailCondition();var f=this.equalsToCondition();var d=this.intCondition();var g=this.checkboxCondition();var k=this.timeCondition();if(!a||!j||!h||!c||!f||!d||!g||!k){if(b){$(this.el).addClassName(this.notValideClass)}if(this.el_label){$(this.el_label).addClassName(this.notValideClass)}return false}return true},emptyCondition:function(){if(!this.el.hasAttribute("notempty")){return true}return $F(this.el)!=""},urlCondition:function(){return this.regExpCondition("url",/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/)},emailCondition:function(){return this.regExpCondition("email",/^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+@[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$/)},regExpCondition:function(b,a){if(!this.el.hasAttribute(b)){return true}value=$F(this.el);var c=a;return c.test(value)},trimSpaces:function(){if(!this.el.hasAttribute("trim_spaces")){return}value=$F(this.el);this.el.value=value.replace(/(^\s*)?(\s*$)?/ig,"")},tinyCondition:function(){if(!this.el.hasAttribute("tiny")){return true}var a=tinyMCE.get(this.el.id);return a.getContent().stripTags()!=""},equalsToCondition:function(){if(!this.el.hasAttribute("equals_to")){return true}if(!this.el.validator){this.el.validator=this}if(!this.equalsTo){this.equalsTo=$(this.el.getAttribute("equals_to"))}var a=this.el.value==this.equalsTo.value;if(a&&this.el.value!=""){this.removeHighLight();if(this.equalsTo.validator){this.equalsTo.validator.removeHighLight()}}return a},intCondition:function(){return this.regExpCondition("int",/^[0-9]*$/)},checkboxCondition:function(){if(!this.el.hasAttribute("checkbox")){return true}return this.el.checked},timeCondition:function(){return this.regExpCondition("time",/^(2[0-3]|1\d|0\d)[:]?[0-5]\d$/)}};var AdminValidationManager=Class.create();AdminValidationManager.prototype={initialize:function(a){if(!a){return false}this.validator=new ValidationManager(null,a);this.validator.onValide=this.onValide.bind(this);this.saveBtns=$$(".saveBtn");setTimeout(function(){this.validator.removeHighLight();this.validator._validate()}.bind(this),10)},setShadowWidth:function(){var b=-5;for(var a=0;a<this.saveBtns.length;a++){var c=this.saveBtns[a];b+=c.clientWidth+5}this.disableShadow.style.width=b+"px"},onValide:function(b){for(var a=0;a<this.saveBtns.length;a++){if(!b){this.saveBtns[a].setAttribute("disabled","-1")}else{this.saveBtns[a].removeAttribute("disabled")}}}};var AutoComplete=Class.create();AutoComplete.prototype={EXPANDED:false,REQUESTING:false,_onclick:function(){},_disable:function(){},_search:function(){return this.json},initialize:function(c,a){this.fld=$(c);if(this.fld){this.fld.setAttribute("autocomplete","off")}this.searchStr="";this.requestStr="";this.dropdown=$("dropdown");this.curSel=-1;this.curObject=null;this.setEvents();this.itemHeight=24;this.color=a?a:"#B2B4BF";this.request_url="/admin/health/symchecker/get_diseases_by_first_letters/";this.ie6=(navigator.userAgent.toLowerCase().indexOf("msie 6.")!=-1);if(this.ie6){var b="<iframe frameborder='0' tabindex='-1' src='/media/img/symchecker/px.gif' id='ie6ComboHider' style='display:none;position:absolute;z-index:-1;'></iframe>";new Insertion.After(this.dropdown,b);this.ie6ComboHider=$("ie6ComboHider")}},setEvents:function(){this.fld.onkeydown=this.onKeyDown.bindAsEventListener(this);this.fld.onkeyup=this.onKeyUp.bindAsEventListener(this);Event.observe(document.body,"click",this.onBlur.bind(this))},onKeyDown:function(b){if(!b){b=window.event}var a=b.keyCode?b.keyCode:b.charCode;switch(a){case Event.KEY_RETURN:Event.stop(b);if(this.curSel!=-1){var c=this.dropdown.childNodes[this.curSel];this.fld.value=c.innerHTML;this.curObject={id:c.id,title:c.innerHTML};this._onclick();this.collapseList(0);if(this.onselect){this.onselect(encodeURIComponent(this.fld.value))}}break;case 38:this.moveSelectionUp(this.dropdown.childNodes);this.doScroll(this.dropdown.childNodes);Event.stop(b);break;case 40:this.moveSelectionDown(this.dropdown.childNodes);this.doScroll(this.dropdown.childNodes);Event.stop(b);break;case 35:this.moveSelectionEnd(this.dropdown.childNodes);this.doScroll(this.dropdown.childNodes);break;case 36:this.moveSelectionHome(this.dropdown.childNodes);this.doScroll(this.dropdown.childNodes);break;default:this.curSel=-1;this._disable();break}},moveSelectionDown:function(a){if(this.dropdown.style.display!="none"){if(this.curSel!=-1){a[this.curSel].style.backgroundColor="white"}if(this.curSel==a.length-1){a[0].style.backgroundColor=this.color;this.curSel=0}else{this.curSel++;a[this.curSel].style.backgroundColor=this.color}}},moveSelectionUp:function(a){if(this.dropdown.style.display!="none"){if(this.curSel!=-1){a[this.curSel].style.backgroundColor="white"}if(this.curSel==-1){this.curSel=a.length-1;a[this.curSel].style.backgroundColor=this.color;return}if(this.curSel==0){a[a.length-1].style.backgroundColor=this.color;this.curSel=a.length-1}else{this.curSel--;a[this.curSel].style.backgroundColor=this.color}}},moveSelectionHome:function(a){this.moveSelection(a,0)},moveSelectionEnd:function(a){this.moveSelection(a,a.length-1)},moveSelection:function(b,a){if(this.dropdown.style.display!="none"){if(this.curSel!=-1){b[this.curSel].backgroundColor="white"}b[a].backgroundColor=this.color;this.curSel=a}},doScroll:function(a){if(a.length>5){if(((this.curSel*this.itemHeight)<this.dropdown.scrollTop)){setTimeout(function(){this.dropdown.scrollTop=this.curSel*this.itemHeight}.bind(this),0)}if((this.curSel*this.itemHeight)>(this.dropdown.scrollTop+a.length+this.itemHeight*5)){setTimeout(function(){this.dropdown.scrollTop=(this.curSel-4)*this.itemHeight}.bind(this),0)}}},onBlur:function(){this.collapseList(0)},doSearch:function(c){if(!c){c=window.event}var a=c.keyCode?c.keyCode:c.charCode;var b=false;if((a>=48&&a<=90)||a==0||a==46||a==32||a==8||a==189||a==190){b=true}return b},onKeyUp:function(a){if(this.doSearch(a)){this.getString(this.fld.value)}},getString:function(a){this.curObject=null;switch(a.length){case 0:this.collapseList(0);break;case 1:this.collapseList(0);break;case 2:if(a!=this.requestStr){this.requestStr=a;this.searchStr=a;this.sendSearchRequest(this.searchStr)}else{this.collapseList(this.paint(this.searchLocal(a)))}break;default:this.searchStr=a;if(this.REQUESTING==false){this.collapseList(this.paint(this.searchLocal(this.searchStr)))}break}},searchLocal:function(d){var f=new Array();var b=new Array();var a=new Array();try{if(this.json){var c=this.json;c=this._search();c.each(function(j){j.name=j.name.replace(/<b>/g,"");j.name=j.name.replace(/<\/b>/g,"");var g=j.name.toLowerCase().indexOf(d.toLowerCase());if(g==0){f.push(j)}if(g!=-1&&g!=0){a=this.getLastName(j);for(var h=1;h<a.length;h++){if(a[h].toLowerCase().indexOf(d.toLowerCase())==0){b.push(j);break}}}}.bind(this))}return f.concat(b)}finally{f=null;b=null;a=null}},boldMatched:function(a,d){var c=this.getRightString(d);for(var b=0;b<a.length;b++){a[b].name=a[b].name.replace(c,"<b>"+c+"</b>")}return a},getRightString:function(d){var b=d.split(" ");var a=new String();for(var c=0;c<b.length;c++){if(c!=0){a+=" "}a+=b[c].toLowerCase().capitalize()}try{return a}finally{b=null;a=null}},getLastName:function(b){var a=new Array();a=b.name.split(" ");return a},sendSearchRequest:function(a){this.fld.style.background="url(/media/img/symchecker/autocomplete-loader.gif) no-repeat scroll 100% 5%";this.resetAutoComplete();this.REQUESTING=true;Tools.send(this.request_url,this.onResponse.bindAsEventListener(this),null,"kw="+encodeURIComponent(a))},resetAutoComplete:function(){this.dropdown.innerHTML="";this.curSel=-1},onResponse:function(a){this.json=a.responseText.evalJSON();var b=this.json;if(this.searchStr.length!=2){b=this.searchLocal(this.searchStr)}b=this._search();this.collapseList(this.paint(b));this.bindEventsToDropdownListElements(this.dropdown);this.REQUESTING=false},bindEventsToDropdownListElements:function(a){a.onmouseover=this.onmouseover.bindAsEventListener(this);a.onclick=this.onclick.bindAsEventListener(this)},getProperSelectedItem:function(a){if(a.className.indexOf("drop-item")!=-1){return a}if(a.parentNode.className!="autocomplete_div"){return a.parentNode}},onclick:function(a){var b=Event.element(a);try{this.fld.value=b.innerHTML;this.curObject={id:b.id,title:b.innerHTML};if(this.onselect){this.onselect(encodeURIComponent(this.fld.value))}this._onclick()}finally{b=null}},onmouseover:function(a){var c=Event.element(a);var b=this.getProperSelectedItem(c);try{if(b){if(b!=this.curCelebItem){if((this.curSel!=-1)&&$(this.celebArray[this.curSel].id)){$(this.celebArray[this.curSel].id.toString()).style.backgroundColor="white"}this.curCelebItem=b;this.curCelebItem.style.backgroundColor=this.color;this.getCurSel()}}}finally{c=null;b=null}},getCurSel:function(){if(this.curCelebItem){for(var a=0;a<this.celebArray.length;a++){if(this.celebArray[a].id==this.curCelebItem.id){this.curSel=a}}}else{this.curSel=-1}},createDiv:function(a){var b=document.createElement("div");b.className="drop-item";b.id=a.id;b.innerHTML=a.name;try{return b}finally{b=null}},paint:function(b){this.celebArray=b;this.dropdown.innerHTML="";this.ie7=(navigator.userAgent.toLowerCase().indexOf("msie 7.")!=-1);if(b){for(var a=0;a<b.length;a++){var c=this.createDiv(b[a]);this.dropdown.appendChild(c)}}setTimeout(function(){this.dropdown.scrollTop=0}.bind(this),0);this.fld.style.background="none";this.dropdown.style.display="block";this.bindEventsToDropdownListElements(this.dropdown);try{return b?b.length:0}finally{if(c){c=null}}},showScrollbar:function(){this.dropdown.style.overflowY="scroll";this.fld.style.background="none"},collapseList:function(a){this.dropdown.style.height="0px";if(a==0){this.dropdown.style.height="0px";this.dropdown.hide();if(this.ie6){this.ie6ComboHider.hide()}}else{if(a>=7){this.dropdown.style.height=(7*this.itemHeight)+"px"}else{this.dropdown.style.height=(a*this.itemHeight)+"px"}}}};var ArrayListData=Class.create();ArrayListData.prototype={initialize:function(a){if(a instanceof Array){this.array_data=a}else{this.array_data=a.split(",")}this.is_in_array=false},insert:function(c){var b=false;var a=c;this.array_data.each(function(d){if(d==a){b=true}});if(!b){this.array_data.push(c);return true}return false},del:function(a){this.array_data=this.array_data.without(a)},cleanData:function(){this.array_data=[]}};var AutoCompleteManager=Class.create();AutoCompleteManager.prototype={initialize:function(b,d,a,c){this.ac=b;this.simpleList=d;this.container=a;this.link=c;this.setEvents()},setEvents:function(){this.link.onclick=this.link_onclick.bindAsEventListener(this);this.ac._onclick=this.link_enable.bindAsEventListener(this);this.ac._disable=this.link_disable.bindAsEventListener(this);this.ac._search=this.upadte_list.bindAsEventListener(this)},link_onclick:function(){var a=this.ac.curObject;if(!a){return false}this.simpleList.appendRow(a.id,a.title);this.container.value="";this.link_disable()},link_enable:function(){Element.removeClassName(this.link,"autocomplete_link_disabled")},link_disable:function(){Element.addClassName(this.link,"autocomplete_link_disabled")},upadte_list:function(){var a=[];if(!this.ac.json){return a}$A(this.ac.json).each(function(c){var b=true;$A(this.simpleList.alst_data.array_data).each(function(d){if(parseInt(d)==c.id){b=false}}.bind(this));if(b){a.push(c)}}.bind(this));return a}};var MenuManager=Class.create();MenuManager.prototype={initialize:function(){this.linksContainer=$("fg_mainPageArticleTabs");if(!this.linksContainer){return}this.container=this.linksContainer.up("div.b-hot");this.tabs=this.linksContainer.select("div.b-hot-title");this.items=this.container.down("div.b-hot-content").childElements();this.tabManagers=[];this.initTabManagers();this.tabManager=this.tabManagers[0];this.tab=this.tabs[0]},initTabManagers:function(){$A(this.tabs).each(function(c){var a=this.tabs.indexOf(c);if(a<this.items.length){var b=new TabManager(c,this.items[a]);b._onclick=this.setActive.bindAsEventListener(this);this.tabManagers.push(b)}}.bind(this))},setActive:function(a){if(this.tabManager==a){return}this.tabManager.content.style.display="none";this.tabManager.unselect();this.tabManager=a;this.tabManager.updateManager();this.tabManager.select();this.tabManager.content.style.display="block"}};var TabManager=Class.create();TabManager.prototype={initialize:function(a,b){this.container=a;this.content=b;this.tabClass="b-hot-title-selected";this.activeClass="b-hot-item-selected";this.initStructure();this.setEventListeners()},initStructure:function(){this.tabs=Element.select(this.content,"li.tab-t-m");this.articles=Element.select(this.content,"div.b-hot-article");this.tab=this.tabs[0];this.curArticle=this.articles[0];this.setActive(this.tab)},setEventListeners:function(){this.container.onclick=this.click.bindAsEventListener(this);this.tabs.each(function(a){Element.down(a,"a").onmouseover=this.setActive.bind(this,a)}.bind(this))},click:function(){this._onclick(this)},updateManager:function(){this.setActive(this.tabs[0])},unselect:function(){Element.removeClassName(this.container,this.tabClass)},select:function(){Element.addClassName(this.container,this.tabClass)},resetTab:function(){Element.removeClassName(this.tab,this.activeClass)},setActive:function(a){if(this.tab==a){return}this.resetTab();this.tab=a;Element.addClassName(this.tab,this.activeClass);this.showArticle(false,this.curArticle);this.setArticle()},setArticle:function(){this.curArticle=this.getArticleFromTab();this.showArticle(true,this.curArticle)},getArticleFromTab:function(){var a=this.tabs.indexOf(this.tab);return this.articles[a]},showArticle:function(a,c){var b=(a)?"block":"none";c.setStyle({display:b})}};var PostEditToolsManager=Class.create();PostEditToolsManager.prototype={initialize:function(){var a=navigator.userAgent.toLowerCase();this.is_ie=((a.indexOf("msie")!=-1)&&(a.indexOf("opera")==-1));this.is_win=((a.indexOf("win")!=-1)||(a.indexOf("16bit")!=-1));this.content=$("id_content");this.boldButton=$("bold_button");this.italicButton=$("italic_button");this.underlineButton=$("underline_button");this.strikedButton=$("striked_button");this.linkButton=$("link_button");this.imageButton=$("image_button");if(this.imageButton){this.photoDialog=new ClientPhotoDialogManager();this.photoDialog.onGetImagePath=this.onGetImagePath.bind(this);this.bindImageButton()}this.bind()},bindImageButton:function(){this.imageButton.onclick=this.showImageChooseDialog.bind(this)},bind:function(){this.boldButton.onclick=this.wrapWithTag.bind(this,"strong");this.italicButton.onclick=this.wrapWithTag.bind(this,"em");this.underlineButton.onclick=this.wrapWithTag.bind(this,"u");this.strikedButton.onclick=this.wrapWithTag.bind(this,"s");this.linkButton.onclick=this.wrapWithLink.bind(this)},wrapWithLink:function(){if(url=prompt("Введите URL","http://")){this.content.focus();if(this.is_ie&&this.is_win){sel=document.selection.createRange();if(sel.text!=""){sel.text='<a href="'+url+'">'+sel.text+"</a>"}else{this.putString('<a href="'+url+'">'+url+"</a>")}}else{this.mozWrap('<a href="'+url+'">',"</a>",url)}this.content.focus()}},putString:function(c){if(document.selection){this.content.focus();sel=document.selection.createRange();sel.text=c}else{if(this.content.selectionStart||this.content.selectionStart=="0"){var a=this.content.selectionStart;var b=this.content.selectionEnd;this.content.value=this.content.value.substring(0,a)+c+this.content.value.substring(b,this.content.value.length)}else{this.content.value+=c}}},wrapWithTag:function(a){this.content.focus();if(this.is_ie&&this.is_win){sel=document.selection.createRange();sel.text="<"+a+">"+sel.text+"</"+a+">"}else{this.mozWrap("<"+a+">","</"+a+">")}this.content.focus()},mozWrap:function(c,k,d){var b=this.content.textLength;var a=this.content.selectionStart;var f=this.content.selectionEnd;if(f==1||f==2){f=b}var j=(this.content.value).substring(0,a);var h=(this.content.value).substring(a,f);var g=(this.content.value).substring(f,b);if(h!=""){this.content.value=j+c+h+k+g}else{if(d){this.content.value=j+c+d+k+g}}return},onGetImagePath:function(a){this.putString('<img src="'+a+'"/>')},showImageChooseDialog:function(){this.photoDialog.show(this.imageButton)}};var PostManager=Class.create();PostManager.prototype={initialize:function(){this.titleInput=$("id_title");this.contentTextarea=$("id_content");this.keywordInput=$("id_tags");this.saveButton=$("post_save_button");this.tagManager=new BlogTagManager();this.saveButton.onclick=function(){this.tagManager.isBtn=true;this.saveButton.disabled=true;$("post-add-form").submit()}.bind(this);this.checkValidity();this.bind()},bind:function(){this.titleInput.onkeyup=this.checkValidity.bind(this);this.contentTextarea.onkeyup=this.checkValidity.bind(this);$("post-add-form").onsubmit=this.send.bind(this)},send:function(){if(!this.isDataValid()){return}this.tagManager.writePostValues()},isDataValid:function(){return(this.titleInput.value.replace(/\s*/,"")!=""&&this.contentTextarea.value.replace(/\s*/,"")!="")},checkValidity:function(){if(!this.isDataValid()){this.saveButton.disabled=true}else{this.saveButton.disabled=false}}};var BlogTagManager=Class.create({initialize:function(){this.txtTags=$("id_tags");this.specialTagsEl=$("specialTagsEl");this.specialTagsSelect=$("specialTagsSelect");var a=new Autocomplete("id_tags",{serviceUrl:"/admin/taglist/",minChars:3,onSelect:function(b){$("id_tags").focus()}});this.cbProjects=$("id_interactive_project");this.projectsContainer=$("projectsContainer");this.myTourSelect=$("id_tour");if(this.cbProjects){this.cbProjects.onchange=this.onChangeProject.bind(this)}if(this.specialTagsEl){this.specialTagsSelect.onchange=this.onSelectTag.bind(this);this.myTourSelect.onchange=this.onSelectCountry.bind(this)}if(this.txtTags){this.txtTags.onkeypress=this.preventSending.bindAsEventListener(this)}},preventSending:function(b){if(!b){b=window.event}var a=b.keyCode?b.keyCode:(b.which?b.which:b.charCode);return(a!=13)},onSelectTag:function(){var a=this.specialTagsSelect.selectedIndex<3;if(a){this.myTourSelect.selectedIndex=0}this.myTourSelect.style.visibility=a?"hidden":"visible";this.updateProjectsState()},updateProjectsState:function(){if(!this.projectsContainer){return}var a=$F(this.specialTagsSelect)!=="";this.projectsContainer.style.display=a?"none":"table-row"},onSelectCountry:function(){var a=$F(this.myTourSelect);this.updateProjectsState()},onChangeProject:function(){var a=$F("id_interactive_project");this.specialTagsEl.style.display=a==""?"table-row":"none";this.projectsMode=a!=""},removeCountry:function(){$("txtCountry").name=""},writePostValues:function(){if(this.projectsMode){this.specialTagsSelect.selectedIndex=0;this.removeCountry();return true}var a=$F(this.myTourSelect);if(a!=""){$("txtCountry").value=a}else{this.removeCountry()}return true}});var Drag={obj:null,init:function(d,j,g,b,f,a,k,h,l,c){d.onmousedown=Drag.start;d.hmode=k?false:true;d.vmode=h?false:true;d.root=j&&j!=null?j:d;if(d.hmode&&isNaN(parseInt(d.root.style.left))){d.root.style.left="0px"}if(d.vmode&&isNaN(parseInt(d.root.style.top))){d.root.style.top="0px"}if(!d.hmode&&isNaN(parseInt(d.root.style.right))){d.root.style.right="0px"}if(!d.vmode&&isNaN(parseInt(d.root.style.bottom))){d.root.style.bottom="0px"}d.minX=typeof g!="undefined"?g:null;d.minY=typeof f!="undefined"?f:null;d.maxX=typeof b!="undefined"?b:null;d.maxY=typeof a!="undefined"?a:null;d.xMapper=l?l:null;d.yMapper=c?c:null;d.root.onDragStart=new Function();d.root.onDragEnd=new Function();d.root.onDrag=new Function()},start:function(b){var c=Drag.obj=this;b=Drag.fixE(b);var d=parseInt(c.vmode?c.root.style.top:c.root.style.bottom);var a=parseInt(c.hmode?c.root.style.left:c.root.style.right);c.root.onDragStart(a,d);c.lastMouseX=b.clientX;c.lastMouseY=b.clientY;if(c.hmode){if(c.minX!=null){c.minMouseX=b.clientX-a+c.minX}if(c.maxX!=null){c.maxMouseX=c.minMouseX+c.maxX-c.minX}}else{if(c.minX!=null){c.maxMouseX=-c.minX+b.clientX+a}if(c.maxX!=null){c.minMouseX=-c.maxX+b.clientX+a}}if(c.vmode){if(c.minY!=null){c.minMouseY=b.clientY-d+c.minY}if(c.maxY!=null){c.maxMouseY=c.minMouseY+c.maxY-c.minY}}else{if(c.minY!=null){c.maxMouseY=-c.minY+b.clientY+d}if(c.maxY!=null){c.minMouseY=-c.maxY+b.clientY+d}}document.onmousemove=Drag.drag;document.onmouseup=Drag.end;return false},drag:function(f){f=Drag.fixE(f);var g=Drag.obj;var c=f.clientY;var d=f.clientX;var j=parseInt(g.vmode?g.root.style.top:g.root.style.bottom);var b=parseInt(g.hmode?g.root.style.left:g.root.style.right);var a,h;if(g.minX!=null){d=g.hmode?Math.max(d,g.minMouseX):Math.min(d,g.maxMouseX)}if(g.maxX!=null){d=g.hmode?Math.min(d,g.maxMouseX):Math.max(d,g.minMouseX)}if(g.minY!=null){c=g.vmode?Math.max(c,g.minMouseY):Math.min(c,g.maxMouseY)}if(g.maxY!=null){c=g.vmode?Math.min(c,g.maxMouseY):Math.max(c,g.minMouseY)}a=b+((d-g.lastMouseX)*(g.hmode?1:-1));h=j+((c-g.lastMouseY)*(g.vmode?1:-1));if(g.xMapper){a=g.xMapper(j)}else{if(g.yMapper){h=g.yMapper(b)}}Drag.obj.root.style[g.hmode?"left":"right"]=a+"px";Drag.obj.root.style[g.vmode?"top":"bottom"]=h+"px";Drag.obj.lastMouseX=d;Drag.obj.lastMouseY=c;Drag.obj.root.onDrag(a,h);return false},end:function(){document.onmousemove=null;document.onmouseup=null;Drag.obj.root.onDragEnd(parseInt(Drag.obj.root.style[Drag.obj.hmode?"left":"right"]),parseInt(Drag.obj.root.style[Drag.obj.vmode?"top":"bottom"]));Drag.obj=null},fixE:function(a){if(typeof a=="undefined"){a=window.event}if(typeof a.layerX=="undefined"){a.layerX=a.offsetX}if(typeof a.layerY=="undefined"){a.layerY=a.offsetY}return a}};var DialogWidget=Class.create();DialogWidget.prototype={initialize:function(c,a,d,b,f){this.freeze=f;this.dialogEl=$(c);this.bottomCenterBorder=this.el("dialog-bottom-center");this.headerCenterBorder=this.el("dialog-header-center");img=new Image();img.src="/media/img/admin/closedhand.png";this.contentHeight=d;this.contentWidth=a;this.btnCloseDialog=this.el("dialog-close-btn");this.btnCloseDialog.onclick=this.hide.bindAsEventListener(this);this.keyup=this._onKeyUp.bindAsEventListener(this);if(!this.freeze){Event.observe(this.headerCenterBorder,"mousedown",function(){Element.addClassName(this.headerCenterBorder,"move-cursor")}.bind(this));Event.observe(this.headerCenterBorder,"mouseup",function(){Element.removeClassName(this.headerCenterBorder,"move-cursor")}.bind(this));Drag.init(this.headerCenterBorder,this.dialogEl)}this.opener=true;this.closeByOutClick=false;if(b){return}Event.observe(this.dialogEl,"keypress",function(h){if(!h){h=window.event}var g=h.keyCode?h.keyCode:h.charCode;if(g!=Event.KEY_RETURN){return false}Event.stop(h);if(this.onEnterPress){this.onEnterPress(this)}}.bindAsEventListener(this))},isOpener:function(a){if(this.opener.constructor&&this.opener.constructor.toString().indexOf("Array")>-1){return this.opener.indexOf(a)>-1}return this.opener==a},onclick:function(b){var a=Event.element(b);if(a.descendantOf(this.dialogEl)||this.isOpener(a)){return}this.hide()},_onKeyUp:function(b){if(!b){b=window.event}var a=b.keyCode?b.keyCode:b.charCode;if(a==Event.KEY_ESC&&this.hide){this.hide()}},el:function(a){return Tools.fgGetElementByClassName(a,this.dialogEl)[0]},setPosition:function(){this.dialogEl.style.visibility="hidden";this.dialogEl.style.display="block";if(this.freeze){this.dialogEl.style.left="440px";this.dialogEl.style.top="145px"}else{var c=document.viewport.getScrollOffsets();var a=document.viewport.getDimensions();var b=-this.dialogEl.clientHeight/2+a.height/2+c.top;this.dialogEl.style.left=-this.dialogEl.clientWidth/2+a.width/2+c.left+"px";this.dialogEl.style.top=(b>0?b:40)+"px"}},show:function(){this.setPosition();if(this.onShow){this.onShow(this)}Event.observe(document.body,"keyup",this.keyup);if(this.closeByOutClick){Event.observe(document,"click",this.onclick.bindAsEventListener(this))}if(!this.firstAppear){this.calculateWidth();var IE6=false
/*@cc_on || @_jscript_version < 5.7 @*/
;if(IE6){this.customizeForIe6()}this.firstAppear=true}this.dialogEl.style.visibility=""},customizeForIe6:function(){var d=this.el("dialog-content-right");if(d){d.style.height=this.contentHeight+"px"}var c=this.el("dialog-content-left");if(c){c.style.height=this.contentHeight+"px"}var b=this.el("dialog-content");if(b){b.style.width="0px"}var a=this.el("dialog-header");if(a){a.style.width="0px"}this.calculateWidth(this.contentWidth+14)},calculateWidth:function(a){calcWidth=this.calculateWidth.bind(this);if(!a){a=this.dialogEl.clientWidth}if(this.bottomCenterBorder){this.bottomCenterBorder.style.width=a-24+"px";this.bottomCenterBorder.parentNode.style.width=a-14+"px";this.headerCenterBorder.style.width=a-24+5+"px"}},hide:function(){if(this.onHide){this.onHide(this)}Event.observe(this.headerCenterBorder,"mouseup",function(){Element.removeClassName(this.headerCenterBorder,"move-cursor")}.bind(this));this.dialogEl.style.display="none";Event.stopObserving(document.body,"keyup",this.keyup);if(this.closeByOutClick){Event.stopObserving(document,"click",this.onclick.bind(this))}}};var Gender=Class.create({onChange:function(a){},initialize:function(a){if(IS_WOMAN_MODULE){return}this.mod="";if(a){this.mod=a}this.el=$(this.mod+"rbG");this.bindElements();Event.observe(this.el,"click",this.onclick.bindAsEventListener(this));this.selectedEl=null;this.setSelection()},bindElements:function(){this.man=$(this.mod+"rbgMan");this.woman=$(this.mod+"rbgWoman")},getSelectedClassName:function(a){return a.className.split(" ")[0]+"-sd"},setSelection:function(){if(this.man.hasClassName(this.getSelectedClassName(this.man))){this.selectedEl=this.man}if(this.woman.hasClassName(this.getSelectedClassName(this.woman))){this.selectedEl=this.woman}},isLabelOfElements:function(a){return a==this.man.id||a==this.woman.id},isRbElement:function(a){return a!=this.man&&a!=this.woman},onclick:function(f){var c=Event.element(f);var b=c.getAttribute("for");var a=(b&&this.isLabelOfElements(b));if(this.isRbElement(c)&&!b){return}c=a?$(b):c;var d=this.getSelectedClassName(c);if(c.hasClassName(d)){return}if(c.hasClassName("disabled")){return}if(this.selectedEl){this.selectedEl.removeClassName(this.getSelectedClassName(this.selectedEl))}this.selectedEl=c;this.selectedEl.addClassName(d);this.onChange(this.getValue())},_getValue:function(){var a=null;if(this.selectedEl==this.man){a="man"}if(this.selectedEl==this.woman){a="woman"}return a},getValue:function(){return this._getValue()}});var PhotoDialogManager=Class.create();PhotoDialogManager.prototype={initialize:function(){if(DIALOG_DOMAIN!=""){document.domain=DIALOG_DOMAIN}this.btnAddPhoto=$("btnAddPhoto");this.announceImg=$("announceImageEl");if(this.btnAddPhoto){this.btnAddPhoto.onclick=this.onImageBtClick.bindAsEventListener(this)}this.dialog=new DialogWidget("photoDialogEl",512,588);this.inputAnnounceImage=$("inputAnnounceImage");var a=$$(".imagePlace")[0];if(a){$$(".imagePlace")[0].ondblclick=this.onImageBtClick.bindAsEventListener(this)}this.iframeEl=$("photoDialogIframeEl");this.dialog.onShow=function(){this.iframeEl.src="/admin/sysmodules/photodialog/"}.bind(this)},onImageBtClick:function(a){this.openDialog()},openDialog:function(a){this.editor=a;this.dialog.show();window.onDialogClose=this.onDialogClose.bind(this)},onDialogClose:function(a,b){if(!a){return this.dialog.hide()}if(this.editor){this.editor.execCommand("mceInsertContent",false,b,{skip_undo:1});this.editor.undoManager.add()}else{this.addImageToAnnounce(a)}this.dialog.hide()},addImageToAnnounce:function(a){this.announceImg.src=a.src;this.announceImg.style.visibility="visible";this.inputAnnounceImage.value=a.id.replace("image_","")}};var PhotoDialogBaseTab=Class.create();PhotoDialogBaseTab.prototype={setEl:function(a){this.el=$(a)},hide:function(){this.el.style.display="none"},show:function(){this.el.style.display="block"},fireOnGetImagePath:function(a){if(this.onGetImagePath){return this.onGetImagePath(a)}}};var PhotoDialogAlbumTab=Class.create(PhotoDialogBaseTab,{initialize:function(){this.setEl("pdAlbumTab");this.el.onclick=this.onImageClick.bindAsEventListener(this);this.appender=new PhotoListAppender(this.el)},addImage:function(a){this.el.select(".no-photos").each(function(b){$(b).remove()});this.appender.addImage(a)},onImageClick:function(b){var a=Event.findElement(b,"#pdAlbumTab div");if(!a){return}this.fireOnGetImagePath(a.getAttribute("url"))}});var PhotoDialogLinkTab=Class.create(PhotoDialogBaseTab,{initialize:function(){this.setEl("pdLinkTab");this.btnAddLink=$("btnAddLink");this.txtLink=$("txtLink");this.txtLink.onchange=this.enableBtn.bind(this);this.txtLink.onkeyup=this.enableBtn.bind(this);this.txtLink.onblur=this.enableBtn.bind(this);this.btnAddLink.onclick=function(){this.fireOnGetImagePath(this.txtLink.value)}.bind(this)},enableBtn:function(){this.btnAddLink.disabled=!Tools.isUrl(this.txtLink.value)}});var PhotoDialogUploadTab=Class.create(PhotoDialogBaseTab,{initialize:function(){this.setEl("pdUploadTab");this.uploader=new PhotoUploader("id_image");this.uploader.onFileUploaded=this.fireOnGetImagePath.bind(this)},refreshUploader:function(){this.uploader.refresh()}});var ClientPhotoDialogManager=Class.create();ClientPhotoDialogManager.prototype={initialize:function(){this.el=$("clientPhotoDialog");this.tabMenu=$("pdTabs");this.tabMenu.onclick=this.changeTab.bindAsEventListener(this);$("closePhotoDialogBtn").onclick=this.hide.bind(this);this.tabs=$A([new PhotoDialogAlbumTab(),new PhotoDialogUploadTab(),new PhotoDialogLinkTab()]);this.currentTab=this.tabs[0];this.uploadTab=this.tabs[1];this.currentTabLink=this.tabMenu.select(".t0-current")[0];this.keyup=this._onKeyUp.bindAsEventListener(this);this.setListeners()},setListeners:function(){this.tabs.each(function(a){a.onGetImagePath=this._onGetImagePath.bind(this,a)}.bind(this))},_onGetImagePath:function(a,b){if(a==this.tabs[1]){this.tabs[0].addImage(b)}this.fireEventAndClose(b)},fireEventAndClose:function(a){if(this.onGetImagePath){this.onGetImagePath(a)}this.hide()},show:function(a){Event.observe(window,"keyup",this.keyup);var b=Tools.IE6?-7:0;this.el.clonePosition(a,{setWidth:false,setHeight:false,offsetLeft:37,offsetTop:-58+b});this.uploadTab.refreshUploader();this.el.style.display="block"},hide:function(){Event.stopObserving(window,"keyup",this.keyup);this.el.style.display="none"},getCurrentCls:function(a){var b=a.id.replace("tab","");return"t"+b+"-current"},selectTabLink:function(a){this.currentTabLink.innerHTML=this.currentTabLink.innerHTML.replace(/<\/?em>/ig,"");this.currentTabLink.removeClassName(this.getCurrentCls(this.currentTabLink));this.currentTabLink.removeClassName("current");this.currentTabLink=$(a);this.currentTabLink.innerHTML="<em>"+this.currentTabLink.innerHTML+"</em>";this.currentTabLink.addClassName(this.getCurrentCls(this.currentTabLink));this.currentTabLink.addClassName("current")},changeTab:function(c){var b=Event.element(c);if(b.tagName!="SPAN"){return}var a=parseInt(b.id.replace("tab",""));this.currentTab.hide();this.currentTab=this.tabs[a];this.selectTabLink(b);this.currentTab.show()},_onKeyUp:function(a){if(a.keyCode==27){this.hide()}}};var PhotoViewer=Class.create({initialize:function(){this.el=$("photoContainer");this.viewer=$("photoViewer");this.overlay=new Overlay();Event.observe(this.el,"click",this.showFullSize.bindAsEventListener(this));this.loader=$("load_indicator");this.keyup=this._onKeyUp.bindAsEventListener(this);this.docClick=this._docClick.bindAsEventListener(this)},showFullSize:function(c){var d=Event.element(c);if(d.tagName=="INPUT"){return}var b=Event.findElement(c,".b-photos div");if(!b){return}Event.stop(c);var a=b.getAttribute("url");this.showLoader(b);Tools.preloadImage(a,function(g,f){this.hideLoader();this.showLoadedFullSize(a,g,f)}.bind(this))},showLoader:function(a){this.loader.clonePosition(a,{setWidth:false,setHeight:false,offsetLeft:a.clientWidth/2-8,offsetTop:a.clientHeight/2-8});this.loader.style.display="block"},hideLoader:function(){this.loader.style.display="none"},showLoadedFullSize:function(b,c,a){Event.observe(window,"keyup",this.keyup);Event.observe(document.body,"keyup",this.keyup);Event.observe(document.body,"click",this.docClick);this.viewer.innerHTML="<img src='"+b+"'/>";this.setViewerPosition(c,a);this.overlay.show();this.viewer.style.display="block"},setViewerPosition:function(c,b){var d=document.viewport.getDimensions();var a=document.viewport.getScrollOffsets();var g=a.top+d.height/2-b/2;var f=a.left+d.width/2-c/2;if(b>d.height){g=a.top}if(c>d.width){f=a.left}this.viewer.style.top=g+"px";this.viewer.style.left=f+"px"},hide:function(){Event.stopObserving(window,"keyup",this.keyup);Event.stopObserving(document.body,"keyup",this.keyup);Event.stopObserving(document.body,"click",this.docClick);this.overlay.hide();this.viewer.style.display="none"},_onKeyUp:function(a){if(a.keyCode==27){this.hide()}},_docClick:function(b){var a=Event.findElement(b,"#photoViewer");if(a){return}this.hide()}});ClientPhotoAlbumPageManager=Class.create({initialize:function(){this.btnDeletePhoto=$("btnDeletePhoto");this.btnDeletePhoto.onmouseover=this.lightBtnDelete.bind(this,"over");this.btnDeletePhoto.onmouseout=this.lightBtnDelete.bind(this);if(!this.btnDeletePhoto){return}this.uploader=new PhotoUploader("file_photoalbum_photo");this.uploader.onFileUploaded=this.addImage.bind(this);this.appender=new PhotoListAppender($("photoContainer"));this.appender.photoTemplate=new Template('<div id="photo#{id}" url="#{url}"><span class="b-photos-item-chx"><input type="checkbox" /></span><a href="#{url}" target="_blank"><div class="b-item"><img src="#{thumb_url}"/></div></a></div>');this.el=$("photoContainer");this.btnDeletePhoto.onclick=this.deletePhotos.bind(this);this.btnDeletePhoto.hidden=true;Event.observe(this.el,"click",this.checkedPhoto.bindAsEventListener(this));this.photosToDelete={};this.photosToDeleteCount=0;this.photosCountEl=$("photosCount");this.photosCount=parseInt(this.photosCountEl.getAttribute("count"));this.clsOver="btn-delete-photo-hover";this.createDownBtn()},createDownBtn:function(){var c=$("subscribe_link");var a=$("file_photoalbum_photo");var b="b-down";Event.observe(a,"mousedown",function(d){c.addClassName(b)});Event.observe(document.body,"mouseup",function(d){c.removeClassName(b)})},lightBtnDelete:function(a){if(this.btnDeletePhoto.disabled){return}if(a=="over"){this.btnDeletePhoto.addClassName(this.clsOver)}else{this.btnDeletePhoto.removeClassName(this.clsOver)}},addImage:function(a,b){this.appender.addImage(a,b);this.photosCount++;this.displayPhotosCount()},checkedPhoto:function(c){var a=Event.element(c);if(a.tagName!="INPUT"){return}var d=a.up("div").getAttribute("id").replace("photo","");var b=$F(a);if(!this.photosToDelete[d]&&b){this.photosToDelete[d]=b;this.photosToDeleteCount++}else{if(this.photosToDelete[d]&&!b){delete this.photosToDelete[d];this.photosToDeleteCount--}}this.hideBtnDelete(this.photosToDeleteCount==0)},hideBtnDelete:function(a){this.btnDeletePhoto.hidden=a;if(a){this.btnDeletePhoto.style.display="none";this.photosToDeleteCount=0;setTimeout(function(){this.btnDeletePhoto.removeClassName(this.clsOver)}.bind(this),10)}else{this.btnDeletePhoto.style.display="inline"}},deletePhotos:function(){if(this.btnDeletePhoto.hidden){return}var a=[];for(id in this.photosToDelete){a.push(id)}this.hideBtnDelete(true);var b=a.join(",");Tools.send(URL_DELETE_PHOTO+"0",function(c){if(c.responseText.evalJSON()){return this.removeFromDom(a)}}.bind(this),null,{"delete":b})},displayPhotosCount:function(){if(this.photosCount==0){this.photosCountEl.innerHTML=EMPTY_LABEL;return}var b=ALREADY+" "+this.photosCount+" ";var a=Tools.declension(this.photosCount,COUNT_LABELS);this.photosCountEl.innerHTML=b+a},removeFromDom:function(a){this.photosCount-=a.length;this.displayPhotosCount();for(var b=0;b<a.length;b++){var c=a[b];$("photo"+c).remove();delete this.photosToDelete[c]}}});var PhotoUploader=Class.create({initialize:function(a){this.bindInput(a);window.getUploadedFile=this.getUploadedFile.bind(this);this.error=$("uploadError")},bindInput:function(a){this.fileInput=$(a);this.fileInput.onchange=this.onFileChoose.bind(this)},onFileChoose:function(){this.error.style.display="none";$("uploadForm").submit()},getUploadedFile:function(b,a,c){if(a!=""){return this.displayError(a)}if(this.onFileUploaded){this.onFileUploaded(b,c)}},displayError:function(a){this.error.innerHTML=a;this.error.style.display="block"},refresh:function(){this.fileInput.parentNode.innerHTML=this.fileInput.parentNode.innerHTML;this.bindInput(this.fileInput.id)}});var PhotoListAppender=Class.create({initialize:function(a){this.el=a;this.photoTemplate=new Template('<div url="#{url}"><img src="#{thumb_url}"/></div>')},addImage:function(a,c){var b=a.replace(/^(.*?)(\.\w{1,4})$/,"$1_"+THUMB_SIZE+"$2");this.el.insert({bottom:this.photoTemplate.evaluate({url:a,thumb_url:b,id:c})})}});var BornedManager=Class.create();BornedManager.prototype={initialize:function(b,a){this.calendars_params=b;this.url=a;this.initCalendars()},initCalendars:function(){if(this.calendars_params.lenght<2){return}this.cal_from_date=this.initCalendar(this.calendars_params[0]);this.cal_to_date=this.initCalendar(this.calendars_params[1])},initCalendar:function(d){el=$(d.id);if(!el){return}var b=Element.up(el,"span").down("span");var c=new MashCalendar(el,b);var a=new Date();a.setFullYear(d.year,d.month-1,d.day);Event.observe(c.btn,"click",this.onclick.bindAsEventListener(this,c));c.setDate(a);c.onDateChoosed=this.setPeriod.bind(this);c.getElToShowDate=function(){return this.elToSetDate}.bind(c);c._setElValue=function(f){if(this.elToSetDate){this.elToSetDate.value=f.getDate()+"-"+f.getMonth()+"-"+f.getFullYear()}this.getElToShowDate().innerHTML=Tools.dateTo_dmy(f)};return c},setPeriod:function(b){var f=this.cal_from_date.getDate();var c=this.cal_to_date.getDate();var d=[this.dateTo_Ymd(f),this.dateTo_Ymd(c)];var a=c>f?0:1;_url_for_view+="?from-date="+d[(0+a)%2]+"&to-date="+d[(1+a)%2];window.location.href=_url_for_view;return true},dateTo_Ymd:function(b){var a=b.getMonth()+1;var c=b.getDate();a=(a<10?"0":"")+a;c=(c<10?"0":"")+c;return b.getFullYear()+"-"+a+"-"+c},onclick:function(b,a){if(this.show&&this.show!=a){this.show.hide()}this.show=a}};var HoroscopeManager=Class.create();HoroscopeManager.prototype={initialize:function(c,a,b){this.calendar_params=c;this.btn=$(this.calendar_params[0].id);this.calendar=new MashCalendar(this.btn,b);this.url=a;this.setEvents()},setEvents:function(){this.calendar.onDateChoosed=this.onclick.bind(this)},onclick:function(a){this.url+=this.dateTo_Ymd(a)+"/";window.location.href=this.url;return true},dateTo_Ymd:function(b){var a=b.getMonth()+1;var c=b.getDate();a=(a<10?"0":"")+a;c=(c<10?"0":"")+c;return b.getFullYear()+"-"+a+"-"+c}};_template_str='<table pair="#{zodiak_url}-#{compability_pair_url}" class="b-horoscope-left-content-table"><colgroup><col width="273"/><col width="410"/></colgroup><tr><td><div class="b-horoscope-left-content-table-first"><div class="b-horoscope-left-content-table-first-zodiak b-horoscope-#{zodiak_url}_logo">#{zodiak}<span class="b-horoscope-plus">+</span></div><div class="b-horoscope-left-content-table-first-zodiak b-horoscope-#{compability_pair_url}_logo b-horoscope-left-content-table-first-zodiak-nonfloat">#{compability_pair}<span class="b-horoscope-equal">=</span></div><a href="javascript:void(0)" class="b-horoscope-left-content-table-first-a">#{reset}</a></div></td><td class="b-horoscope-left-content-table-td">#{text}</td></tr></table>';var _template_hor=new Template(_template_str);var CompabilityManager=Class.create();CompabilityManager.prototype={initialize:function(a,d,b,c){this.container=a;this.zodiaks=d;this.messages=c;this.selected=b?b:false;this.tbody=d.down("tbody");this.caption=d.down("div.b-horoscope-selected");this.cap_spans=this.caption.getElementsByTagName("span");this.desription=Element.down(this.tbody,"td");this.is_showed_cup=false;this.tables=[];this.setEvents()},setEvents:function(){Event.observe(this.tbody,"mousemove",this.onmousemove.bindAsEventListener(this));Event.observe(this.tbody,"click",this.onclick.bindAsEventListener(this));Event.observe(this.container,"click",this.onResetClick.bindAsEventListener(this))},onmousemove:function(b){var a=this.check_link(b);if(!a){return this.hideCap()}point={x:a.parentNode.parentNode.offsetLeft,y:a.offsetTop};this.showCap(a.getAttribute("title"),point)},onResetClick:function(c){var a=Event.element(c);if(a.tagName.toLowerCase()!="a"){return}var b=a.up("table");Element.remove(b)},check_link:function(c){var a=Event.element(c);if(a.tagName.toLowerCase()=="a"){return a}else{if(a.tagName.toLowerCase()=="i"){return a.parentNode}else{if(a.tagName.toLowerCase()=="div"){var d=Event.pointerX(c);var b=Event.pointerY(c);var f=a.cumulativeOffset();if(f[0]-d>-50&&f[1]-b>-27){return Element.down(a,"a")}}}}return false},onclick:function(c){var b=this.check_link(c);if(!b){return}this.desription.innerHTML=this.selected?this.messages.two:this.messages.one;var a={title:b.getAttribute("title"),url:b.getAttribute("url")};if(this.selected){return this.sendRequest(a)}this.selected=a},sendRequest:function(a){if(this.pair_is_not_exist(this.selected.url,a.url)){this.json={zodiak_url:this.selected.url,zodiak:this.selected.title,compability_pair_url:a.url,compability_pair:a.title,reset:_RESET};Tools.send(_path,this.getResponse.bind(this),this.onFailure.bind(this),{ajax:"true",zodiak:this.json.zodiak_url,compability_pair:this.json.compability_pair_url})}this.selected=false;this.hideCap()},pair_is_not_exist:function(b,d){var a=true;if(b==d){b=d=[b,d].join("-")}for(var c=0;c<this.tables.length;c++){var f=this.tables[c].getAttribute("pair");if(f.indexOf(b)!=-1&&f.indexOf(d)!=-1){a=false;Element.insert(this.container,{top:this.tables[c]});break}}return a},getResponse:function(a){response_json=a.responseText.evalJSON()[0];this.json.text=response_json.text;var b=_template_hor.evaluate(this.json);Element.insert(this.container,{top:b});this.tables.push($(this.container).down("table"))},onFailure:function(a){},showCap:function(c,a){var b=["visible","hidden"];this.cap_spans[0].innerHTML=this.selected?this.selected.title:c;this.cap_spans[this.selected?2:0].innerHTML=c;this.cap_spans[1].style.visibility=b[this.selected?0:1];if(this.is_showed_cup){return}this.is_showed_cup=true;this.caption.style.display="block";this.caption.style.left=a.x+60+"px";this.caption.style.top=a.y+20+"px"},hideCap:function(a){this.is_showed_cup=false;this.caption.style.display="none";this.cap_spans[2].innerHTML="";if(!this.selected){this.cap_spans[0].innerHTML=""}}};var EastManager=Class.create();EastManager.prototype={initialize:function(b,a){this.link=b;this.url=a;this.form=Element.down(this.link.parentNode,"span");this.input=Element.down(this.form,"input");this.input.value="";this.num_input=new NumInput(this.input);this.num_input.strWork="1234567890";this.span=Element.down(this.form,"span.b-horoscope-born-an");this.anchor=Element.down(this.form,"a");this.setEvents()},setEvents:function(){Event.observe(this.link,"click",this.onclick.bindAsEventListener(this));Event.observe(this.input,"keyup",this.onkeyup.bindAsEventListener(this))},onclick:function(){this.link.style.display="none";this.form.style.display="inline"},onkeyup:function(){if(this.input.value.length==4){var a=this.getAnimal();if(a){this.anchor.setAttribute("href",this.url+a.url);this.anchor.innerHTML=a.name;this.span.style.display="inline"}}else{this.span.style.display="none"}},getAnimal:function(){var a=parseInt(this.input.value)%12;var b=false;$A(window.ZODIAK_ANIMALS).each(function(c){if(c.index==a){b=c}}.bind(this));return b}};var HolidayCalendar=Class.create();HolidayCalendar.prototype={initialize:function(c,a,b){this.calendar_params=c;this.btn=$(this.calendar_params[0].id);this.calendar=new MashCalendar(this.btn,b);this.url=a;this.setEvents()},setEvents:function(){this.calendar.onDateChoosed=this.onclick.bind(this)},onclick:function(a){this.url+="/"+this.dateTo_Ymd(a)+"/";window.location.href=this.url;return true},dateTo_Ymd:function(b){var a=b.getMonth()+1;var c=b.getDate();a=(a<10?"0":"")+a;c=(c<10?"0":"")+c;return b.getFullYear()+"-"+a+"-"+c}};var NamedayCalendar=Class.create();NamedayCalendar.prototype={initialize:function(b,a,c){this.select_month=a;this.select_day=b;this.path=c;this.filter=$("flt_namedays");this.month=new Array(12);this.month[0]="january";this.month[1]="february";this.month[2]="march";this.month[3]="april";this.month[4]="may";this.month[5]="june";this.month[6]="july";this.month[7]="august";this.month[8]="september";this.month[9]="october";this.month[10]="november";this.month[11]="december";this.days=new Array(12);this.days[0]=31;this.days[1]=28;this.days[2]=31;this.days[3]=30;this.days[4]=31;this.days[5]=30;this.days[6]=31;this.days[7]=31;this.days[8]=30;this.days[9]=31;this.days[10]=30;this.days[11]=31;this.setEvents()},setEvents:function(){this.select_month.onchange=this.onMonthChanged.bind(this);this.filter.onclick=this.dofilter.bind(this)},dofilter:function(){var b=this.select_day.value;var c=this.select_month.value;if(c==""){window.location=this.path;return}var d=this.month[c-1];var a=this.path+d;if(b!=""){a+="/"+b}window.location=a;return},onMonthChanged:function(){this.refresh_days(this.select_month.value)},refresh_days:function(a){while(this.select_day.options.length>1){this.select_day.remove(1)}if(a==""){return}for(i=0;i<this.days[a-1];i++){var b=document.createElement("OPTION");b.value=i+1;b.text=i+1;this.select_day.appendChild(b)}}};var ChatManager=Class.create();if(Prototype.Browser.IE){window.console={log:function(){}}}ChatManager.prototype={initialize:function(){this.questionTemplate=new Template(QUESTION_TEMPLATE);this.answerTemplate=new Template(ANSWER_TEMPLATE);this.userTableTrTemplate=new Template(USER_TABLE_TR_TEMPLATE);this.startDate=START_DATE;this.txtMessage=$("id_text");this.btnSend=$("btnSend");if(this.btnSend){this.btnSend.disabled=true}this.notAnsweredCntSpan=$("not_answered_count");this.askedCntSpan=$("asked_count");this.answeredCntSpan=$("answered_count");if(this.txtMessage){this.txtMessage.onkeyup=this.validateReply.bind(this)}this.messagesEl=$("messagesEl");this.userTableTbody=$("user_table").down("tbody");this.onlineUsersCountSpan=$("online_users_count");this.messageTemplateStr="";this.message="";this.lastId="";this.lastAid=LAST_AID?LAST_AID:"False";this.needUserlistRefresh=true;this.comma=$("comma");this.showUserlistIcon=$("show_userlist_icon");this.userlistBlock=$("userlist_block");this.usersEl=$("userlist_block_users");this.users_width=$("users_width");this.initial=true;this.bindUserList();this.resetLink=$("reset_link");if(this.resetLink){this.resetLink.onclick=this.clearTextMessage.bind(this)}this.userlistIsShowed=false;this.user_ids=[];this.periodicalUpdate();setInterval(this.setNeedUserlistRefreshToTrue.bind(this),USERLIST_UPDATE_TIME*1000)},bindUserList:function(){if($("show_userlist_icon")){$("show_userlist_icon").onclick=this.toggleUserlist.bind(this)}},clearTextMessage:function(){this.txtMessage.value=""},changeNotAnsweredCount:function(a){if(NOT_ANSWERED_COUNT==-1){return}NOT_ANSWERED_COUNT+=a;if(!this.notAnsweredCntSpan){return}this.notAnsweredCntSpan.innerHTML=NOT_ANSWERED_COUNT;if(NOT_ANSWERED_COUNT==0){this.notAnsweredCntSpan.parentNode.style.display="none";this.comma.innerHTML=""}else{this.notAnsweredCntSpan.parentNode.style.display="block";this.comma.innerHTML=","}},changeAskedCount:function(a){this.askedCntSpan.innerHTML=a},changeAnsweredCount:function(a){this.answeredCntSpan.innerHTML=a},validateReply:function(){var a=this.txtMessage.value;if(a.replace(/\s*/,"")==""){this.btnSend.disabled=true}else{this.btnSend.disabled=false}},retriveServerData:function(){params={text:this.message,need_userlist_refresh:this.needUserlistRefresh,current_users:this.user_ids.join(",")};this.needUserlistRefresh=false;this.sendAjaxRequest(params,this.responseCallback.bind(this))},responseCallback:function(a){var b=a.responseText.evalJSON();if(b.closed){alert(THANK_FOR_CHAT);document.location.href=document.location.href}this.renderMessages(b);this.message="";if(this.onServerResponse){this.onServerResponse()}this.periodicalUpdate()},renderMessages:function(a){if(a.id!=""){this.lastId=a.id}if(a.aid!=""){this.lastAid=a.aid}var b=a.common.length;var c=a.answered.length;this.changeAskedCount(a.question_count);this.changeAnsweredCount(a.answer_count);if(NOT_ANSWERED_COUNT==-1){this.renderAnswered(a.answered)}else{this.renderCommon(a.common)}this.renderUserlist(a.users)},sendAjaxRequest:function(b,c){urlStr=URL_GET_LAST_MESSAGES+this.lastAid+"/"+this.startDate+"/"+this.lastId;var a={url:urlStr,params:b};Tools.send(a,c)},renderCommon:function(c){this.changeNotAnsweredCount(c.length);var b="";messageTemplate=new Template(this.messageTemplateStr);for(var a=0;a<c.length;a++){b+=messageTemplate.evaluate(c[a])}if(b!=""){this.messagesEl.insert({bottom:b})}},renderAnswered:function(f,d){for(var c=0;c<f.length;c++){var a=f[c];a.expert=EXPERT;var h=a.question.evalJSON();var b=this.questionTemplate.evaluate(h);var g=this.answerTemplate.evaluate(a);messageTemplate=new Template(this.messageTemplateStr);this.messagesEl.insert({bottom:messageTemplate.evaluate({que:b,ans:g})})}if(f.length>0){if(this.onNewMessages){this.onNewMessages()}}},collectInitialUsers:function(){$$("#user_table tr").each(function(a){this.user_ids.push(a.className.replace("tr",""))}.bind(this))},searchUserIndexById:function(c,b){for(var a=0;a<c.length;a++){if(c[a].id==b){return a}}return -1},initialClear:function(c){if(this.initial){this.collectInitialUsers();this.initial=false;for(var b=0;b<this.user_ids.length;b++){var a=this.searchUserIndexById(c,this.user_ids[b]);if(a!=-1){c.splice(a,1)}}}return c},renderUserlist:function(a){a.joined=this.initialClear(a.joined);this.renderJoined(a.joined);this.deleteLeaved(a.leaved)},renderJoined:function(c){if(c.length!=0){this.renderOnlineUserCount(c.length,true)}var b="";for(var a=0;a<c.length;a++){this.user_ids.push(c[a].id);b+=this.userTableTrTemplate.evaluate({id:c[a].id,thumb:c[a].thumbnail,username:c[a].user})}if(b!=""){Insertion.Bottom(this.userTableTbody,b)}},deleteLeaved:function(b){if(b.length!=0){this.renderOnlineUserCount(b.length,false)}for(var a=0;a<b.length;a++){this.deleteLeavedFromCurrent(b[a]);trs=this.userTableTbody.getElementsByClassName("tr"+b[a].id);if(trs){this.userTableTbody.removeChild(trs[0])}}},deleteLeavedFromCurrent:function(a){indexToDelete=-1;for(var b=0;b<this.user_ids.length;b++){if(this.user_ids[b]==a.id){indexToDelete=b;break}}if(indexToDelete!=-1){this.user_ids.splice(indexToDelete,1)}},periodicalUpdate:function(){setTimeout(this.retriveServerData.bind(this),UPDATE_SECONDS*1000)},setNeedUserlistRefreshToTrue:function(){this.needUserlistRefresh=true},renderOnlineUserCount:function(a,b){var c=parseInt(this.onlineUsersCountSpan.innerHTML.replace("(","").replace(")",""));if(b){a=c+a}else{a=c-a}this.onlineUsersCountSpan.innerHTML="("+a+")"},toggleUserlist:function(){if(this.userlistIsShowed){this.hideUserlist()}else{this.showUserlist()}},showUserlist:function(){this.users_width.style.width="332px";this.userlistBlock.style.right="331px";this.userlistIsShowed=true;this.usersEl.style.display="block"},hideUserlist:function(){this.users_width.style.width="0px";this.userlistBlock.style.right="44px";this.userlistIsShowed=false;this.usersEl.style.display="none"}};var ExpertChat=Class.create();ExpertChat.prototype={initialize:function(a){this.manager=a;this.reply_form=$("expert_answer_form");this.replyLabel=$("replyLabel");this.replyQuestionImage=$("replyQuestionImg");this.showAnswered=$("chat_exp_show_answered");this.manager.changeNotAnsweredCount(0);this.questionAuthor=$("question_author");this.hideReplyForm();this.manager.messageTemplateStr=EXPERT_MESSAGE_TEMPLATE;this.bindEvents()},bindEvents:function(){this.manager.btnSend.onclick=this.sendAnswer.bind(this);if(this.showAnswered){this.showAnswered.onchange=this.toggleAnswered.bind(this)}$("refuse_reply").onclick=this.hideReplyForm.bind(this);Event.observe(this.manager.txtMessage,"keypress",this.onKeyPress.bindAsEventListener(this));if(this.manager.messagesEl){this.manager.messagesEl.onclick=this.messagesOnClick.bindAsEventListener(this)}},onKeyPress:function(a){if(!a){a=window.event}if(Tools.isCtrlEnter(a)&&!this.manager.btnSend.disabled){return this.sendAnswer()}},hideReplyForm:function(){this.manager.txtMessage.value="";if(this.reply_form){this.reply_form.style.display="none"}},messagesOnClick:function(g){this.elToAnswer=Event.element(g);if(this.elToAnswer.tagName!="A"){return}if(this.elToAnswer.className.indexOf("hide")!=-1){var b=this.elToAnswer.parentNode.parentNode.parentNode;this.deleteQuestion(b);return}if(this.elToAnswer.id==""||!this.reply_form){return}var f=this.elToAnswer.parentNode.parentNode;this.reply_form.style.display="block";var d=f.getElementsByTagName("em")[0].innerHTML;var a=f.getElementsByTagName("A")[1].innerHTML;this.replyLabel.innerHTML=d;var c=this.elToAnswer.getAttribute("thumbnail");if(c){this.replyQuestionImage.src=c}else{this.replyQuestionImage.src=""}this.questionAuthor.innerHTML=a.substring(0,a.length-1);setTimeout(function(){this.manager.txtMessage.focus()}.bind(this),10)},deleteQuestion:function(a){this.manager.changeNotAnsweredCount(-1);this.hideReplyForm();var b=a.id.replace("id_","");Tools.send(DELETE_QUESTION_URL+b,this.deleteQuestionResponse.bind(this,a))},deleteQuestionResponse:function(b,a){if(a.responseText=="OK"){b.parentNode.removeChild(b)}},sendAnswer:function(){var a=this.manager.txtMessage.value;params={text:a,question_id:this.elToAnswer.id};this.manager.sendAjaxRequest(params,this.responseCallback.bind(this));this.hideReplyForm();this.manager.changeNotAnsweredCount(-1);this.renderAnswered(this.elToAnswer,a)},renderAnswered:function(b,c){var a=this.manager.questionTemplate.evaluate({author:this.questionAuthor.innerHTML,text:this.replyLabel.innerHTML});var c=this.manager.answerTemplate.evaluate({expert:EXPERT,text:c});var d=b.parentNode.parentNode.parentNode;d.innerHTML=a+c;if(!this.showAnswered.checked){d.style.display="none"}},responseCallback:function(a){var b=a.responseText.evalJSON();this.manager.renderCommon(b.common)},toggleAnswered:function(){var a=this.manager.messagesEl.childNodes;for(var b=0;b<a.length;b++){if(a[b].tagName!="DIV"||a[b].id=="userlist_block"){continue}if(a[b].getElementsByTagName("SCRIPT").length!=0){continue}if(this.showAnswered.checked){a[b].style.display="block"}else{a[b].style.display="none"}}}};var UserChat=Class.create();UserChat.prototype={initialize:function(a){this.manager=a;this.manager.onServerResponse=this.onServerResponse.bind(this);if(!this.manager.txtMessage){return}this.manager.messageTemplateStr=MESSAGE_TEMPLATE;this.manager.onNewMessages=function(){this.messagesEl.scrollTop=this.messagesEl.scrollHeight}.bind(a);this.indicator=$("sendIndicator");this.txtLimit=parseInt(a.txtMessage.getAttribute("length"));this.bindEvents()},bindEvents:function(){Event.observe(this.manager.txtMessage,"keypress",this.onKeyPress.bindAsEventListener(this));this.manager.btnSend.onclick=this.sendMessage.bind(this)},limitTextLength:function(){var a=this.manager.txtMessage;var b=a.value;if(b.length>this.txtLimit){a.value=b.substring(0,this.txtLimit)}},onKeyPress:function(a){if(!a){a=window.event}this.limitTextLength();if(Tools.isCtrlEnter(a)&&!this.manager.btnSend.disabled){return this.sendMessage()}},sendMessage:function(){this.limitTextLength();this.manager.message=this.manager.txtMessage.value;this.manager.txtMessage.value="";this.manager.btnSend.disabled=true;if(this.animation){return}this.indicator.innerHTML=MESSAGE_SENDING;this.indicator.style.display="block"},onServerResponse:function(){if(this.indicator.style.display!="block"){return}if(this.animation){return}this.indicator.innerHTML=MESSAGE_SENT;this.animation=true;Tools.hideFade(this.indicator,function(){this.animation=false}.bind(this))}};var NamebookPageManager=Class.create({initialize:function(){this.gender=new NamebookGender();this.gender.onChange=this.redirect.bind(this)},redirect:function(a){if(a=="ono"){document.location.href=document.location.href.replace(/(male|female)\/?/i,"");return}document.location.href=a=="man"?MALE_URL:FEMALE_URL}});var NamebookGender=Class.create(Gender,{bindElements:function($super){$super();this.ono=$("rbgOno")},setSelection:function($super){$super();if(this.ono.hasClassName(this.getSelectedClassName(this.ono))){this.selectedEl=this.ono}},isLabelOfElements:function($super,a){return a==this.man.id||a==this.woman.id||a==this.ono.id},isRbElement:function($super,a){return a!=this.man&&a!=this.woman&&a!=this.ono},getValue:function($super){var a=this._getValue();if(this.selectedEl==this.ono){return"ono"}return a}});var MailBoxManager=Class.create({initialize:function(){this.el=$("messageBox");if(!this.el){return}if($("no_data")){return}this.chekboxes=this.el.select(".b-message-mark");this.cbSelectAll=$("cbSelectAll");this.cbSelectAll.onclick=this.checkAll.bind(this);this.btnDeleteMessages=$("btnDeleteMessages");this.btnDeleteMessages.onclick=this.deleteMarkedMessages.bind(this);this.btnMarkAsRead=$("btnMarkAsRead");if(this.btnMarkAsRead){this.btnMarkAsRead.onclick=this.markMessagesAsRead.bind(this)}this.bindCb()},bindCb:function(){this.el.select("a.b-mail-item").each(function(a){a.onclick=function(d,b){var c=Event.element(d);if(c.tagName=="INPUT"){setTimeout(function(){c.checked=!c.checked;this.updateBtns()}.bind(this),10);Event.stop(d);return false}document.location.href=b.href;return true}.bindAsEventListener(this,a)}.bind(this))},updateBtns:function(){var a=this.getChecked();this.disableBtn(this.btnDeleteMessages,a.length>0);if(!this.btnMarkAsRead){return}var b=this.el.select(".selected-item input.b-message-mark:checked");this.disableBtn(this.btnMarkAsRead,b.length>0)},disableBtn:function(b,a){var c=$(b.parentNode);if(a){c.removeClassName("b-inputs-lk-disabled");b.href="javascript:;"}else{c.addClassName("b-inputs-lk-disabled");b.href=""}},isDisabledBtn:function(a){return $(a.parentNode).hasClassName("b-inputs-lk-disabled")},getChecked:function(){return this.el.select("input.b-message-mark:checked")},getSelectedIds:function(){var a=[];this.getChecked().each(function(b){a.push(b.value)});return encodeURIComponent(a.join(","))},checkAll:function(a){this.chekboxes.each(function(b){b.checked=this.cbSelectAll.checked}.bind(this));this.updateBtns()},uncheck:function(){this.getChecked().each(function(a){a.checked=false})},sendRequest:function(a,b){Tools.send(a,b,false,"ids="+this.getSelectedIds())},removeDeletedMessages:function(){this.getChecked().each(function(a){Element.up(a,"a.b-mail-item").remove()})},unmarkReadMessages:function(){this.getChecked().each(function(a){var b=Element.up(a,"a.b-mail-item");b.removeClassName("selected-item")})},deleteMarkedMessages:function(){if(this.isDisabledBtn(this.btnDeleteMessages)){return}this.sendRequest("/profile/mailbox/delete/",function(a){result=a.responseText.evalJSON();if(result.status=="fail"){return}this.removeDeletedMessages();this.updateBtns()}.bind(this));return false},markMessagesAsRead:function(){if(this.isDisabledBtn(this.btnMarkAsRead)){return}this.sendRequest("/profile/mailbox/read/",function(a){result=a.responseText.evalJSON();if(result.status=="fail"){return}$("smallProfile").replace(result.profile);this.unmarkReadMessages();this.uncheck();this.updateBtns()}.bind(this))}});var ProfileEditManager=Class.create({initialize:function(){this.gender=new Gender();this.genderHiddenInput=$("genderHiddenInput");this.btnSaveProfile=$("btnSaveProfile");this.btnSaveProfile.onclick=this.submit.bind(this);var a=new MashCalendar($("b-calendar-sw"),$("b-calendar-edit"));a._setElValue=function(d){if(this.elToSetDate){var c=d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();var b=Element.down(this.elToSetDate.parentNode.parentNode,"input");b.setAttribute("value",c)}this.getElToShowDate().innerHTML=Tools.dateTo_dmy(d)};a.getElToShowDate=function(){return this.elToSetDate}.bind(a)},submit:function(){this.genderHiddenInput.value=this.gender.getValue()=="man"?"M":"F";$("profile-form").submit()}});var MailManager=new Class.create({initialize:function(b,c,a,f,d){this.form=$(b);if(!this.form){return}this.textArea=Element.down(this.form,"textarea");this.recipient=Element.down(this.form,"input");this.submit=Element.down(this.form,"input",2);this.autocomplete=new AutoComplete(this.recipient,"#eee");this.autocomplete.request_url=c;this.url=c;this.username=f;this.user_url=a;this.border_class=d?d:"h-border-f66";this.is_text=false;this.is_recipient=false;this.setEvents()},setEvents:function(){this.form.onsubmit=this.validate.bindAsEventListener(this);this.textArea.onkeyup=this.onchangeTextArea.bindAsEventListener(this);Event.observe(this.recipient,"keyup",this.onchange.bindAsEventListener(this));Event.observe(this.recipient,"keydown",this.checkForTab.bindAsEventListener(this));this.autocomplete._onclick=this.onchange.bindAsEventListener(this);Event.observe(document.body,"click",this.onCloseAutocomplete.bindAsEventListener(this))},checkForTab:function(b){var a=b.keyCode?b.keyCode:(b.which?b.which:b.charCode);if(a==9){this.autocomplete.onBlur()}},onCloseAutocomplete:function(b){var a=Event.element(b);if(this.isChild(a,this.autocomplete.dropdown)){return}this.autocomplete.onBlur()},isChild:function(b,a){parents=b.ancestors();return parents.member(a)},onchangeTextArea:function(a){this.is_text=!(this.textArea.value.strip()=="");this.enable_submit()},onchange:function(a){if((this.recipient.value.strip()!="")&&(this.username!=this.recipient.value.strip().toLowerCase())){Tools.send(this.user_url,this.check_change.bindAsEventListener(this),null,"username="+encodeURIComponent(this.recipient.value))}},check_change:function(a){this.is_recipient=a.responseText=="NO";this.enable_submit()},validate:function(){if(this.is_valid()){this.submit.disabled=true;return true}return false},is_add_text:function(){this.is_text=this.is_add_content(this.textArea);return this.is_text},is_add_recipient:function(){this.is_recipient=this.is_add_content(this.recipient);return this.is_recipient},is_add_content:function(a){if(a.value.strip()==""){this.set_no_valid(a);return false}return true},is_valid:function(){return this.is_add_text()&&this.is_add_recipient()},set_no_valid:function(a){Element.addClassName(a,this.border_class)},set_valid:function(a){Element.removeClassName(a,this.border_class)},enable_submit:function(){if(!(this.textArea.value.strip()=="")&&this.is_recipient){this.submit.removeAttribute("disabled")}else{this.submit.setAttribute("disabled","true")}}});var Overlay=Class.create({initialize:function(){this.overlay=$("overlay");this.windowSizeChange=this.windowSizeChange.bind(this)},windowSizeChange:function(a){this.overlay.style.height=document.body.clientHeight+"px"},show:function(){this.overlay.style.display="block";Event.observe(window,"resize",this.windowSizeChange);this.windowSizeChange()},hide:function(){this.overlay.style.display="none";Event.stopObserving(window,"resize",this.windowSizeChange)}});try{document.execCommand("BackgroundImageCache",false,true)}catch(e){}function fixPNG(c){if(/MSIE (5\.5|6).+Win/.test(navigator.userAgent)){var f;if(c.tagName=="IMG"){if(/\.png$/.test(c.src)){f=c.src;c.src="/media/img/px.gif"}}else{f=c.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);if(f){f=f[1];c.runtimeStyle.backgroundImage="none"}}var d=/iesizing\-(\w+)/;var a=d.exec(c.className);var b=(a)?a[1]:"crop";if(f){c.runtimeStyle.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+f+"',sizingMethod='"+b+"')"}}}var MagazineController=new Class.create();MagazineController.prototype={iterations:0,steps:10,initialize:function(a){this.container=$(a);if(!this.container){return}this.btnClass="b-magazine-btn";this.template=new Template("<img class='b-magazine-edition' src='#{src}' month='#{month}' year='#{year}' href='#{href}' alt='#{alt}' id='magazine_block_cover__#{id}' />");this.buttons=[];this.initButtons();this.magazines=$A(this.container.getElementsByTagName("img"));this.currentClass="current";var b=this.container.childElements();this.nextMagazine=b.find(function(c){return Element.hasClassName(c,"right")});this.previousMagazine=b.find(function(c){return Element.hasClassName(c,"mage_left")});this.currentMagazine=b.find(function(c){return Element.hasClassName(c,"current")});this.currentIndex=this.magazines.indexOf(this.currentMagazine);this.magazineLink=$("magazineLink");this.nonActiveLinkClass="inactive__link";this.nonActiveEditionClass="inactive__edition";this.initShadow();this.nonActiveIndex=false;this.buttons_hidden=true;this.hideNavBtns();this.setEventListeners();this.updateEventListeners();this.loadMagazines()},isIE6:function(){return !window.XMLHttpRequest},initShadow:function(){if(this.isIE6()){return}this.shadow=$("magazineShadow");if(!this.shadow){return}this.showShadow(true);this.shadowMiddleBlock=this.shadow.down("div.middle");this.updateShadowHeight()},showShadow:function(a){if(this.isIE6()||!this.shadow){return}var b=["block","none"];this.shadow.style.display=b[(a)?0:1]},updateShadowHeight:function(){if(this.isIE6()||!this.shadow){return}var a=Element.getHeight(this.currentMagazine);this.shadowMiddleBlock.style.height=[a-50,"px"].join("")},initPositions:function(){this.curTop=-116;this.sibTop=-86;this.pDim=Math.abs(this.curTop-this.sibTop)/this.steps;this.curWidth=175;this.sibWidth=125;this.wDim=(this.curWidth-this.sibWidth)/this.steps;this.curLeft=-this.curWidth/2;this.psibLeft=-this.sibWidth;this.nsibLeft=0;this.lDim=Math.abs(this.psibLeft-this.curLeft)/this.steps;this.rDim=Math.abs(this.curLeft)/this.steps},initButtons:function(){var a=-1;$$(".b-magazine-btn").each(function(c){var b=new MagazineButton(c,a);a=a*a;this.buttons.push(b)}.bind(this))},setMagazines:function(){this.setPreviousMagazine();this.setNextMagazine()},setPreviousMagazine:function(a,b){if(this.previousMagazine){Element.removeClassName(this.previousMagazine,"mage_left")}if(this.currentIndex>0){this.previousMagazine=this.magazines[this.currentIndex-1];Element.addClassName(this.previousMagazine,"mage_left")}else{this.previousMagazine=null}},setNextMagazine:function(){if(this.nextMagazine){Element.removeClassName(this.nextMagazine,"right")}if(this.currentIndex<this.magazines.length-1){this.nextMagazine=this.magazines[this.currentIndex+1];Element.addClassName(this.nextMagazine,"right")}else{this.nextMagazine=null}},setCurrentMagazine:function(){Element.removeClassName(this.currentMagazine,this.currentClass);this.currentMagazine=this.magazines[this.currentIndex];Element.addClassName(this.currentMagazine,this.currentClass);this.updateEventListeners();this.currentMagazine.removeClassName(this.nonActiveEditionClass);this.updateShadowHeight();this.showShadow(true)},updateEventListeners:function(){if(this.currentMagazine){this.currentMagazine.onclick=this.redirect.bindAsEventListener(this)}},redirect:function(c){var b=Event.element(c);if(b!=this.currentMagazine){return}var a=this.currentMagazine.getAttribute("href");location.href=a},_showButtons:function(c,b){var a=Event.element(c);if(this.isInContainer(c)&&!b){return}if(this.onMouseovered==b){return}this.showButtons(b)},updateButtonsMode:function(a){if(!this.onMouseovered){return}if(!this.isInContainer(a)){return}this.showButtons(true)},showButtons:function(a){this.buttons.each(function(b){a?b.show():b.hide()}.bind(this));this.onMouseovered=a},isNavButton:function(a){return a.hasClassName(this.btnClass)},isInContainer:function(f){var c=Event.pointerX(f);var b=Event.pointerY(f);var h=Element.cumulativeOffset(this.container);var d=Element.getDimensions(this.container);var g=(b>h.top&&b<(h.top+d.height));var a=(c>h.left&&c<(h.left+d.width));return a&&g},setEventListeners:function(){this.buttons.each(function(a){a._onclick=this.changeMagazine.bindAsEventListener(this,a.step)}.bind(this));this.container.onmouseover=this._showButtons.bindAsEventListener(this,true);this.container.onmouseout=this._showButtons.bindAsEventListener(this,false);this.container.onmousemove=this.updateButtonsMode.bindAsEventListener(this);this.container.onselectionstart=this.preventHandler.bindAsEventListener(this);this.container.onmousedown=this.preventHandler.bindAsEventListener(this)},preventHandler:function(a){Event.stop(a);return false},changeMagazine:function(b,a){if(this.is_moving){return}this.showShadow(false);this.step=a;this.currentIndex+=a;this.hideNavBtns();this.initPositions();this.moveMagazines()},updateMagazineClasses:function(){this.setCurrentMagazine();this.setMagazines();this.setLink();if(this.currentIndex===this.nonActiveIndex){this.unlinkMagazine()}},setLink:function(){var a=this.currentMagazine;var d=a.getAttribute("month");var c=a.getAttribute("year");var b=a.getAttribute("href");if(!d||!c||!b){return}var a=this.currentMagazine;var f=d+", "+c;this.magazineLink.innerHTML=f;this.magazineLink.href=b;this.magazineLink.removeClassName(this.nonActiveLinkClass)},unlinkMagazine:function(){this.magazineLink.href="javascript:void(0)";this.magazineLink.addClassName(this.nonActiveLinkClass);this.currentMagazine.addClassName(this.nonActiveEditionClass);this.currentMagazine.onclick=this.preventHandler.bindAsEventListener(this)},updateStyles:function(){this.updateTopPositions();this.updateWidth();this.updateLeftPositions()},moveMagazines:function(){this.is_moving=true;this.iterations+=1;this.updateStyles();if(this.iterations%10==0){this.updateMagazineClasses();this.is_moving=false;return}setTimeout(this.moveMagazines.bind(this),25)},updateTopPositions:function(){this.curTop+=this.pDim;this.sibTop-=this.pDim;if(isNaN(this.curTop)||isNaN(this.sibTop)){return}this.currentMagazine.style.marginTop=[this.curTop,"px"].join("");if(this.step==1){this.nextMagazine.style.marginTop=[this.sibTop,"px"].join("")}else{this.previousMagazine.style.marginTop=[this.sibTop,"px"].join("")}},updateLeftPositions:function(){this.curLeft=this.step==1?(this.curLeft-this.lDim):(this.curLeft+this.rDim);this.psibLeft+=this.lDim;this.nsibLeft-=this.rDim;if(isNaN(this.curLeft)||isNaN(this.nsibLeft)||isNaN(this.psibLeft)){return}this.currentMagazine.style.marginLeft=[Math.floor(this.curLeft),"px"].join("");if(this.step==1){this.nextMagazine.style.marginLeft=[Math.floor(this.nsibLeft),"px"].join("")}else{this.previousMagazine.style.marginLeft=[Math.floor(this.psibLeft),"px"].join("")}},updateWidth:function(){this.curWidth-=this.wDim;this.sibWidth+=this.wDim;if(isNaN(this.curWidth)||isNaN(this.sibWidth)){return}this.currentMagazine.style.width=[this.curWidth,"px"].join("");if(this.step==1){this.nextMagazine.style.width=[this.sibWidth,"px"].join("")}else{this.previousMagazine.style.width=[this.sibWidth,"px"].join("")}},hideNavBtns:function(){this.buttons[0].setDisplayable(this.currentIndex!=0);this.buttons[1].setDisplayable(this.currentIndex!=this.magazines.length-1)},loadMagazines:function(){Tools.send(GET_MAGAZINES_PATH,this.onLoadMagazines.bindAsEventListener(this))},onLoadMagazines:function(a){var d=a.responseText.evalJSON();var c="";for(var b=0;b<d.length;b++){c+=this.template.evaluate(d[b])}Element.insert(this.magazines.first(),{before:c});this.magazines=$A(this.container.getElementsByTagName("img"));this.currentIndex+=d.length;this._onMagazineUpdated()},_onMagazineUpdated:function(){},initNotActiveMagazine:function(a){if(a<0){return}this.nonActiveIndex=a;if(this.currentIndex===this.nonActiveIndex){this.unlinkMagazine()}}};var MagazineButton=Class.create({initialize:function(a,b){this.button=a;this.active=false;this.showed=false;this.disabled=false;this.end_effect=null;this.step=b;this.setEvents()},setEvents:function(){Event.observe(this.button,"mouseover",this.setActive.bindAsEventListener(this));Event.observe(this.button,"mouseout",this.setActive.bindAsEventListener(this));this.button.onclick=this.onclick.bindAsEventListener(this)},setActive:function(a){if(a){Event.stop(a)}if(this.disabled){return}this.active=!this.active},onclick:function(a){this._onclick(a)},setDisplayable:function(a){if(this.disabled!=a){return}var b=["block","none"];this.button.style.display=b[a?0:1];if(this.active){this.setActive()}this.disabled=!a},show:function(){if(this.showed==true){return}this.setVisible(true)},hide:function(){if(this.showed==false){return}this.setVisible(false)},setVisible:function(a){this.showed=a;var b=["visible","hidden"];this.button.style.visibility=b[this.showed?0:1]}});var MagazinePageController=Class.create();MagazinePageController.prototype={initialize:function(b,a){this.mainCover=$(b);this.blockController=a;this.blockController._onMagazineUpdated=this.setBlockMagazine.bind(this)},setBlockMagazine:function(){if(!this.mainCover||!this.blockController){return}var b=this.blockController.magazines;var c=$(this.mainCover.id.replace("main","block"));if(!c){return}var a=b.indexOf(c);this.blockController.initNotActiveMagazine(a)}};var InputFileController=Class.create();InputFileController.prototype={initialize:function(b,a){this.field=$(b);this.contaienr=$(a);if(this.field){this.field.onchange=this.fillContainer.bind(this)}},fillContainer:function(){if(!this.contaienr){return}var a=this.field.value.match(/[^\/\\]+$/);this.contaienr.innerHTML=a}};var CommentManager=Class.create({initialize:function(){this.comments=$$(".b-comments .b-comments-li");if(this.comments.length==0){return}this.el=$$(".b-comments-ul")[0];this.commentsCountEl=$("comments_count");this.commentsCount=parseInt(this.commentsCountEl.innerHTML);Event.observe(this.el,"click",this.onDelete.bindAsEventListener(this));this.btnTemplate=new Template('<a cid="#{id}" class="bdc" href="javascript:;"><i></i>'+DELETE_COMMENT+"</a>");this.insertCommentBtns()},insertCommentBtns:function(){this.comments.each(function(a){var b={id:a.getAttribute("cid")};a.insert({bottom:this.btnTemplate.evaluate(b)})}.bind(this))},onDelete:function(b){var a=Event.element(b);if(!a.hasClassName("bdc")&&!a.up().hasClassName("bdc")){return}if(!confirm(ARE_YOU_SURE_WANT_TO_DELETE_COMMENT)){return}Tools.send("../comment/delete/"+a.getAttribute("cid")+"/",function(c){if(c.responseText=="ok"){$(a.parentNode).remove();this.commentsCount--;if(this.commentsCount==0){this.commentsCountEl.style.display="none"}this.commentsCountEl.innerHTML=this.commentsCount}}.bind(this),false,null)}});var MSMenu=Class.create({initialize:function(a){this.table=$(a);this.tabs=this.table.select("div.b-box-lk");this.setEvent()},setEvent:function(){this.tabs.each(function(a){a.onmouseover=this.onmouseover.bindAsEventListener(this,a);a.onmouseout=this.onmouseout.bindAsEventListener(this,a)}.bind(this))},onmouseover:function(c,b){if(Element.hasClassName(b.parentNode.parentNode,"h-box__selected")){return}var a=Event.element(c);Element.addClassName(b,"b-box-lk_hover")},onmouseout:function(c,b){var a=Event.element(c);Element.removeClassName(b,"b-box-lk_hover")}});var CookieDialogManager=Class.create({onDialogClosed:function(){},initialize:function(c,a){this.siteblockContainer=c;if(!c){}else{this.opener=this.siteblockContainer.select("#cookieOpenerLk")[0];this.isActive=Element.hasClassName(c,"isActive");var b=this.siteblockContainer.select("#siteblockBusket")[0];if(!this.opener||!this.isActive){return}this.container=a;this.innerContainer=$("cookiesInnerContainer");this.openers=[this.opener,b];this.closeBtn=this.container.select("#cookieCloseBtn")[0];this.preloader=new CookiesImagePreloader();this.initElements();this.setEventListeners()}},setInactive:function(){Element.removeClassName(this.siteblockContainer,"isActive");this.isActive=false},onLoadedAll:function(){Tools.show(this.innerContainer,true)},initElements:function(){},setEventListeners:function(){Event.observe(document,"keyup",this.closeByEscape.bindAsEventListener(this));$A(this.openers).each(function(a){a.onclick=this.openDialog.bind(this)}.bind(this));this.closeBtn.onclick=this.closeDialog.bind(this);this.preloader._onLoadedAll=this.onLoadedAll.bind(this)},closeByEscape:function(b){var a=b.keyCode?b.keyCode:(b.which?b.which:b.charCode);if(a==27){this.closeDialog()}},closeDialog:function(){Tools.hide(this.container,true);this.onDialogClosed()},openDialog:function(){if(!this.container||!this.isActive){return}var a=Tools.getScrollProperties();var c=window.innerHeight?window.innerHeight:document.documentElement.clientHeight;var b=a.top+c/2;this.container.style.top=b+"px";Tools.show(this.container,true)}});var CookieManager=Class.create(CookieDialogManager,{initElements:function(){this.itemContainer=$("cookieItemContainer");this.templateContainer=new Template('<div class="b-item"><i class="b-item-img #{color}"></i>&laquo;#{text}&raquo;</div>');this.busketManager=new BusketManager(this.container,this.closeBtn,this.opener)},onLoadedAll:function($super){$super();this.busketManager.onLoadedAll()},setEventListeners:function($super){$super();this.busketManager._onCookieSelect=this.onGetComment.bind(this);this.busketManager._setInactive=this.setInactive.bind(this)},onGetComment:function(a){Tools.send(SHAKE_BASKET_URL,this.onReceivedComment.bind(this,a),null,{color:a})},onReceivedComment:function(c,b){var f=b.responseText.evalJSON();if(!f){return}var a=this.busketManager.commentContainer;var h=f.error||f.cookie;var g=a.select("div.textContainer")[0];g.innerHTML=h;Tools.setVisible(a,true);this.busketManager.showCloudInTop();if(f.error){return}var d=this.templateContainer.evaluate({color:c,text:h});this.itemContainer.innerHTML=d},onDialogClosed:function(){this.busketManager.reset()}});var BusketManager=Class.create({_onCookieSelect:function(){},initialize:function(a,c,b){this.container=$(a);this.opener=b;this.commentContainer=$("commentContainer");this.busket=new Busket(this.container);this.busketAnimator=new CookieAnimator(this.container,this.busket.container);this.cockiePointer=new CookiePointer();this.cookieLinks=$("cookieLinks");this.retryLk=this.cookieLinks.select("#cookiesTry")[0];this.limitMessage=this.cookieLinks.select("#cookieTryMessage")[0];this.closeBtn=c;this.tryLimit=SHAKE_COUNT_LIMIT-SHAKE_BASKET_TIMES;this.limitText=$("cookiesLimitText");this.laps=1;this.isViewChanged=false;this.allImagesLoaded=false;this.setEventListeners()},onLoadedAll:function(){this.allImagesLoaded=true},setEventListeners:function(){this.container.onclick=this.start.bindAsEventListener(this);this.busket._onAnimationFinished=this.changeView.bind(this);this.cockiePointer._onCookieSelect=this.onCookieSelect.bind(this);this.busketAnimator._onViewChanged=this.setCookiesSelectable.bind(this);this.busketAnimator._onCloudReturned=this.showLinks.bind(this);this.retryLk.onclick=this.reset.bind(this)},setCookiesSelectable:function(){this.cockiePointer.setSelectable(true)},onCookieSelect:function(a){this.laps++;if(this.laps>this.tryLimit){Tools.hide(this.opener,true);Tools.show(this.limitText,true);Tools.hide(this.retryLk,true);Tools.show(this.limitMessage,true);this._setInactive()}this._onCookieSelect(a.id);this.cockiePointer.setSelectable(false)},reset:function(){this.busketAnimator.reset();this.cockiePointer.setSelectable(false);Tools.setVisible(this.commentContainer,false);Tools.hide(this.cookieLinks,true);this.isViewChanged=false;this.busket.resetAnimation();this.busket.show(true)},stop:function(){this.busket.animation.stop()},changeView:function(){this.busketAnimator.resetIterations();this.busketAnimator.setSecondState()},showCloudInTop:function(){this.busketAnimator.cloudStep=-20;this.busketAnimator.resetIterations();this.busketAnimator.showCloudInTop()},showLinks:function(){Tools.show(this.cookieLinks,true)},start:function(b){if(this.laps>this.tryLimit||!this.allImagesLoaded){return}var a=Event.element(b);if(this.isViewChanged||a==this.retryLk||a==this.closeBtn){return}this.busket.animation.start();this.busketAnimator.setCloudText(false);this.isViewChanged=true},showCookies:function(){this.busket.changeView()}});var Busket=Class.create({_onCookieChoosed:function(){},_onAnimationFinished:function(){},initialize:function(){this.container=$("cookieBusket");this.animation=this.initAnimation()},resetAnimation:function(){this.animation.reset()},initAnimation:function(){var a=spriteAnimation(this.container,{width:600,height:600},7200,"backgroundPositionY",3);a.frameDelay(70);a.onLapsOver=this.onAnimationFinished.bind(this);return a},onAnimationFinished:function(){this.animation.stop();this._onAnimationFinished()},show:function(a){Tools.show(this.container,a)},onCookieChoosed:function(a){this._onCookieChoosed(a)}});var CookieAnimator=Class.create({_onViewChanged:function(){},_onCloudReturned:function(){},initialize:function(a,b){this.container=a;this.busket=b;this.cloud=$("cookiesCloud");this.cloudText="Кликните на коробочку";this.resetData();this.resetIterations();this.setCloudText(true)},setCloudText:function(a){var b=a?this.cloudText:"";this.cloud.innerHTML=b},resetData:function(){this.cloudTop=350;this.step=15;this.cloudStep=20;this.busketHeight=600},resetIterations:function(){this.iterations=0},reset:function(){this.resetData();this.setCloudText(true);this.cloud.style.marginTop="350px";this.busket.style.height="600px"},setSecondState:function(){this.is_moving=true;this.iterations+=1;this.updateCloudStyles();this.updateBusketStyles();if(this.iterations%60==0){this.is_moving=false;this.onViewChanged();return}setTimeout(this.setSecondState.bind(this),25)},showCloudInTop:function(){this.is_moving=true;this.iterations+=1;this.updateCloudStyles();if(this.iterations%23==0){this.is_moving=false;this.onCloudReturned();return}setTimeout(this.showCloudInTop.bind(this),25)},updateCloudStyles:function(){this.cloudTop-=this.cloudStep;this.cloud.style.marginTop=this.cloudTop+"px"},updateBusketStyles:function(){var a=this.cloudStep;this.busketHeight-=this.cloudStep;if(this.busketHeight<0){return}this.busket.style.height=this.busketHeight+"px"},onViewChanged:function(){this._onViewChanged()},onCloudReturned:function(){this._onCloudReturned()}});document.createElement("canvas").getContext||(function(){var ab=Math,ag=ab.round,S=ab.sin,K=ab.cos,f=ab.abs,d=ab.sqrt,af=10,R=af/2;function c(){return this.context_||(this.context_=new J(this))}var x=Array.prototype.slice;function b(j,k){var v=x.call(arguments,2);return function(){return j.apply(k,v.concat(x.call(arguments)))}}var u={init:function(j){if(/MSIE/.test(navigator.userAgent)&&!window.opera){var k=j||document;k.createElement("canvas");k.attachEvent("onreadystatechange",b(this.init_,this,k))}},init_:function(j){j.namespaces.g_vml_||j.namespaces.add("g_vml_","urn:schemas-microsoft-com:vml","#default#VML");j.namespaces.g_o_||j.namespaces.add("g_o_","urn:schemas-microsoft-com:office:office","#default#VML");if(!j.styleSheets.ex_canvas_){var k=j.createStyleSheet();k.owningElement.id="ex_canvas_";k.cssText="canvas{display:inline-block;overflow:hidden;text-align:left;width:300px;height:150px}g_vml_\\:*{behavior:url(#default#VML)}g_o_\\:*{behavior:url(#default#VML)}"}var y=j.getElementsByTagName("canvas"),v=0;for(;v<y.length;v++){this.initElement(y[v])}},initElement:function(j){if(!j.getContext){j.getContext=c;j.innerHTML="";j.attachEvent("onpropertychange",a);j.attachEvent("onresize",h);var k=j.attributes;if(k.width&&k.width.specified){j.style.width=k.width.nodeValue+"px"}else{j.width=j.clientWidth}if(k.height&&k.height.specified){j.style.height=k.height.nodeValue+"px"}else{j.height=j.clientHeight}}return j}};function a(j){var k=j.srcElement;switch(j.propertyName){case"width":k.style.width=k.attributes.width.nodeValue+"px";k.getContext().clearRect();break;case"height":k.style.height=k.attributes.height.nodeValue+"px";k.getContext().clearRect();break}}function h(j){var k=j.srcElement;if(k.firstChild){k.firstChild.style.width=k.clientWidth+"px";k.firstChild.style.height=k.clientHeight+"px"}}u.init();var r=[],ad=0;for(;ad<16;ad++){var ac=0;for(;ac<16;ac++){r[ad*16+ac]=ad.toString(16)+ac.toString(16)}}function E(){return[[1,0,0],[0,1,0],[0,0,1]]}function z(j,k){var C=E(),B=0;for(;B<3;B++){var A=0;for(;A<3;A++){var v=0,y=0;for(;y<3;y++){v+=j[B][y]*k[y][A]}C[B][A]=v}}return C}function o(j,k){k.fillStyle=j.fillStyle;k.lineCap=j.lineCap;k.lineJoin=j.lineJoin;k.lineWidth=j.lineWidth;k.miterLimit=j.miterLimit;k.shadowBlur=j.shadowBlur;k.shadowColor=j.shadowColor;k.shadowOffsetX=j.shadowOffsetX;k.shadowOffsetY=j.shadowOffsetY;k.strokeStyle=j.strokeStyle;k.globalAlpha=j.globalAlpha;k.arcScaleX_=j.arcScaleX_;k.arcScaleY_=j.arcScaleY_;k.lineScale_=j.lineScale_}function n(j){var k,C=1;j=String(j);if(j.substring(0,3)=="rgb"){var B=j.indexOf("(",3),A=j.indexOf(")",B+1),v=j.substring(B+1,A).split(",");k="#";var y=0;for(;y<3;y++){k+=r[Number(v[y])]}if(v.length==4&&j.substr(3,1)=="a"){C=v[3]}}else{k=j}return{color:k,alpha:C}}function ai(j){switch(j){case"butt":return"flat";case"round":return"round";case"square":default:return"square"}}function J(j){this.m_=E();this.mStack_=[];this.aStack_=[];this.currentPath_=[];this.fillStyle=this.strokeStyle="#000";this.lineWidth=1;this.lineJoin="miter";this.lineCap="butt";this.miterLimit=af*1;this.globalAlpha=1;this.canvas=j;var k=j.ownerDocument.createElement("div");k.style.width=j.clientWidth+"px";k.style.height=j.clientHeight+"px";k.style.overflow="hidden";k.style.position="absolute";j.appendChild(k);this.element_=k;this.lineScale_=this.arcScaleY_=this.arcScaleX_=1}var ah=J.prototype;ah.clearRect=function(){this.element_.innerHTML=""};ah.beginPath=function(){this.currentPath_=[]};ah.moveTo=function(j,k){var v=this.getCoords_(j,k);this.currentPath_.push({type:"moveTo",x:v.x,y:v.y});this.currentX_=v.x;this.currentY_=v.y};ah.lineTo=function(j,k){var v=this.getCoords_(j,k);this.currentPath_.push({type:"lineTo",x:v.x,y:v.y});this.currentX_=v.x;this.currentY_=v.y};ah.bezierCurveTo=function(D,F,C,B,y,k){var v=this.getCoords_(y,k),j=this.getCoords_(D,F),A=this.getCoords_(C,B);l(this,j,A,v)};function l(j,k,y,v){j.currentPath_.push({type:"bezierCurveTo",cp1x:k.x,cp1y:k.y,cp2x:y.x,cp2y:y.y,x:v.x,y:v.y});j.currentX_=v.x;j.currentY_=v.y}ah.quadraticCurveTo=function(j,k,C,B){var A=this.getCoords_(j,k),v=this.getCoords_(C,B),y={x:this.currentX_+0.6666666666666666*(A.x-this.currentX_),y:this.currentY_+0.6666666666666666*(A.y-this.currentY_)};l(this,y,{x:y.x+(v.x-this.currentX_)/3,y:y.y+(v.y-this.currentY_)/3},v)};ah.arc=function(L,M,I,H,F,C){I*=af;var D=C?"at":"wa",B=L+K(H)*I-R,G=M+S(H)*I-R,A=L+K(F)*I-R,j=M+S(F)*I-R;if(B==A&&!C){B+=0.125}var y=this.getCoords_(L,M),v=this.getCoords_(B,G),k=this.getCoords_(A,j);this.currentPath_.push({type:D,x:y.x,y:y.y,radius:I,xStart:v.x,yStart:v.y,xEnd:k.x,yEnd:k.y})};ah.rect=function(j,k,y,v){this.moveTo(j,k);this.lineTo(j+y,k);this.lineTo(j+y,k+v);this.lineTo(j,k+v);this.closePath()};ah.strokeRect=function(j,k,A,y){var v=this.currentPath_;this.beginPath();this.moveTo(j,k);this.lineTo(j+A,k);this.lineTo(j+A,k+y);this.lineTo(j,k+y);this.closePath();this.stroke();this.currentPath_=v};ah.fillRect=function(j,k,A,y){var v=this.currentPath_;this.beginPath();this.moveTo(j,k);this.lineTo(j+A,k);this.lineTo(j+A,k+y);this.lineTo(j,k+y);this.closePath();this.fill();this.currentPath_=v};ah.createLinearGradient=function(j,k,A,y){var v=new T("gradient");v.x0_=j;v.y0_=k;v.x1_=A;v.y1_=y;return v};ah.createRadialGradient=function(j,k,C,B,A,v){var y=new T("gradientradial");y.x0_=j;y.y0_=k;y.r0_=C;y.x1_=B;y.y1_=A;y.r1_=v;return y};ah.drawImage=function(U){var V,Q,P,N,L,M,I,O,H=U.runtimeStyle.width,B=U.runtimeStyle.height;U.runtimeStyle.width="auto";U.runtimeStyle.height="auto";var G=U.width,F=U.height;U.runtimeStyle.width=H;U.runtimeStyle.height=B;if(arguments.length==3){V=arguments[1];Q=arguments[2];L=M=0;I=P=G;O=N=F}else{if(arguments.length==5){V=arguments[1];Q=arguments[2];P=arguments[3];N=arguments[4];L=M=0;I=G;O=F}else{if(arguments.length==9){L=arguments[1];M=arguments[2];I=arguments[3];O=arguments[4];V=arguments[5];Q=arguments[6];P=arguments[7];N=arguments[8]}else{throw Error("Invalid number of arguments")}}}var C=this.getCoords_(V,Q),A=[];A.push(" <g_vml_:group",' coordsize="',af*10,",",af*10,'"',' coordorigin="0,0"',' style="width:',10,"px;height:",10,"px;position:absolute;");if(this.m_[0][0]!=1||this.m_[0][1]){var y=[];y.push("M11=",this.m_[0][0],",","M12=",this.m_[1][0],",","M21=",this.m_[0][1],",","M22=",this.m_[1][1],",","Dx=",ag(C.x/af),",","Dy=",ag(C.y/af),"");var D=C,j=this.getCoords_(V+P,Q),v=this.getCoords_(V,Q+N),k=this.getCoords_(V+P,Q+N);D.x=ab.max(D.x,j.x,v.x,k.x);D.y=ab.max(D.y,j.y,v.y,k.y);A.push("padding:0 ",ag(D.x/af),"px ",ag(D.y/af),"px 0;filter:progid:DXImageTransform.Microsoft.Matrix(",y.join(""),", sizingmethod='clip');")}else{A.push("top:",ag(C.y/af),"px;left:",ag(C.x/af),"px;")}A.push(' ">','<g_vml_:image src="',U.src,'"',' style="width:',af*P,"px;"," height:",af*N,'px;"',' cropleft="',L/G,'"',' croptop="',M/F,'"',' cropright="',(G-L-I)/G,'"',' cropbottom="',(F-M-O)/F,'"'," />","</g_vml_:group>");this.element_.insertAdjacentHTML("BeforeEnd",A.join(""))};ah.stroke=function(ak){var al=[],aj=n(ak?this.fillStyle:this.strokeStyle),aa=aj.color,Y=aj.alpha*this.globalAlpha;al.push("<g_vml_:shape",' filled="',!!ak,'"',' style="position:absolute;width:',10,"px;height:",10,'px;"',' coordorigin="0 0" coordsize="',af*10," ",af*10,'"',' stroked="',!ak,'"',' path="');var W={x:null,y:null},X={x:null,y:null},V=0;for(;V<this.currentPath_.length;V++){var Z=this.currentPath_[V];switch(Z.type){case"moveTo":al.push(" m ",ag(Z.x),",",ag(Z.y));break;case"lineTo":al.push(" l ",ag(Z.x),",",ag(Z.y));break;case"close":al.push(" x ");Z=null;break;case"bezierCurveTo":al.push(" c ",ag(Z.cp1x),",",ag(Z.cp1y),",",ag(Z.cp2x),",",ag(Z.cp2y),",",ag(Z.x),",",ag(Z.y));break;case"at":case"wa":al.push(" ",Z.type," ",ag(Z.x-this.arcScaleX_*Z.radius),",",ag(Z.y-this.arcScaleY_*Z.radius)," ",ag(Z.x+this.arcScaleX_*Z.radius),",",ag(Z.y+this.arcScaleY_*Z.radius)," ",ag(Z.xStart),",",ag(Z.yStart)," ",ag(Z.xEnd),",",ag(Z.yEnd));break}if(Z){if(W.x==null||Z.x<W.x){W.x=Z.x}if(X.x==null||Z.x>X.x){X.x=Z.x}if(W.y==null||Z.y<W.y){W.y=Z.y}if(X.y==null||Z.y>X.y){X.y=Z.y}}}al.push(' ">');if(ak){if(typeof this.fillStyle=="object"){var U=this.fillStyle,L=0,Q={x:0,y:0},O=0,M=1;if(U.type_=="gradient"){var I=U.x1_/this.arcScaleX_,H=U.y1_/this.arcScaleY_,N=this.getCoords_(U.x0_/this.arcScaleX_,U.y0_/this.arcScaleY_),B=this.getCoords_(I,H);L=Math.atan2(B.x-N.x,B.y-N.y)*180/Math.PI;if(L<0){L+=360}if(L<0.000001){L=0}}else{var N=this.getCoords_(U.x0_,U.y0_),F=X.x-W.x,D=X.y-W.y;Q={x:(N.x-W.x)/F,y:(N.y-W.y)/D};F/=this.arcScaleX_*af;D/=this.arcScaleY_*af;var v=ab.max(F,D);O=2*U.r0_/v;M=2*U.r1_/v-O}var G=U.colors_;G.sort(function(ap,ao){return ap.offset-ao.offset});var C=G.length,am=G[0].color,y=G[C-1].color,P=G[0].alpha*this.globalAlpha,an=G[C-1].alpha*this.globalAlpha,k=[],V=0;for(;V<C;V++){var j=G[V];k.push(j.offset*M+O+" "+j.color)}al.push('<g_vml_:fill type="',U.type_,'"',' method="none" focus="100%"',' color="',am,'"',' color2="',y,'"',' colors="',k.join(","),'"',' opacity="',an,'"',' g_o_:opacity2="',P,'"',' angle="',L,'"',' focusposition="',Q.x,",",Q.y,'" />')}else{al.push('<g_vml_:fill color="',aa,'" opacity="',Y,'" />')}}else{var A=this.lineScale_*this.lineWidth;if(A<1){Y*=A}al.push("<g_vml_:stroke",' opacity="',Y,'"',' joinstyle="',this.lineJoin,'"',' miterlimit="',this.miterLimit,'"',' endcap="',ai(this.lineCap),'"',' weight="',A,'px"',' color="',aa,'" />')}al.push("</g_vml_:shape>");this.element_.insertAdjacentHTML("beforeEnd",al.join(""))};ah.fill=function(){this.stroke(true)};ah.closePath=function(){this.currentPath_.push({type:"close"})};ah.getCoords_=function(j,k){var v=this.m_;return{x:af*(j*v[0][0]+k*v[1][0]+v[2][0])-R,y:af*(j*v[0][1]+k*v[1][1]+v[2][1])-R}};ah.save=function(){var j={};o(this,j);this.aStack_.push(j);this.mStack_.push(this.m_);this.m_=z(E(),this.m_)};ah.restore=function(){o(this.aStack_.pop(),this);this.m_=this.mStack_.pop()};function p(j){var k=0;for(;k<3;k++){var v=0;for(;v<2;v++){if(!isFinite(j[k][v])||isNaN(j[k][v])){return false}}}return true}function ae(j,k,v){if(!!p(k)){j.m_=k;if(v){j.lineScale_=d(f(k[0][0]*k[1][1]-k[0][1]*k[1][0]))}}}ah.translate=function(j,k){ae(this,z([[1,0,0],[0,1,0],[j,k,1]],this.m_),false)};ah.rotate=function(j){var k=K(j),v=S(j);ae(this,z([[k,v,0],[-v,k,0],[0,0,1]],this.m_),false)};ah.scale=function(j,k){this.arcScaleX_*=j;this.arcScaleY_*=k;ae(this,z([[j,0,0],[0,k,0],[0,0,1]],this.m_),true)};ah.transform=function(j,k,B,A,y,v){ae(this,z([[j,k,0],[B,A,0],[y,v,1]],this.m_),true)};ah.setTransform=function(j,k,B,A,y,v){ae(this,[[j,k,0],[B,A,0],[y,v,1]],true)};ah.clip=function(){};ah.arcTo=function(){};ah.createPattern=function(){return new g};function T(j){this.type_=j;this.r1_=this.y1_=this.x1_=this.r0_=this.y0_=this.x0_=0;this.colors_=[]}T.prototype.addColorStop=function(j,k){k=n(k);this.colors_.push({offset:j,color:k.color,alpha:k.alpha})};function g(){}G_vmlCanvasManager=u;CanvasRenderingContext2D=J;CanvasGradient=T;CanvasPattern=g})();var CanvasAdapter=Class.create({initialize:function(b,a,d,c){this.canvas=document.createElement("canvas");this.parent=$(c);this.canvas.width=b;this.canvas.height=a;if(this.parent){this.parent.appendChild(this.canvas)}if(window.G_vmlCanvasManager){G_vmlCanvasManager.initElement(this.canvas)}if(d){this.canvas.id=d}this.ctx=this.canvas.getContext("2d");this.ctx.lineWidth=1;this.ctx.save()},clear:function(){this.ctx.restore();this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.beginPath();this.ctx.save()},moveTo:function(a){this.ctx.moveTo(Math.round(a.x),Math.round(a.y))},lineTo:function(a){this.ctx.lineTo(Math.round(a.x),Math.round(a.y))},draw:function(){this.ctx.stroke()},getElement:function(){return this.canvas},fill:function(){return this.ctx.fill()},setOpacity:function(a){this.ctx.globalAlpha=a}});var CookiePointer=Class.create({_onCookieSelect:function(){},initialize:function(){this.fgCookies=[{coords:[282,141,294,148,306,158,316,171,324,183,330,197,331,214,325,233,316,243,302,251,284,255,269,254,257,249,245,239,226,249,211,221,226,211,223,190,227,172,237,153,242,147,257,158,265,170,271,151,278,145],color:"#6bdded",id:"blue"},{coords:[328,189,338,188,350,190,363,194,379,201,389,209,398,221,401,231,407,242,410,257,410,265,407,271,405,274,400,270,395,268,390,266,386,262,381,260,375,257,365,255,360,256,357,248,351,238,341,226,331,219,330,197,331,205],color:"#027aeb",id:"darkblue"},{coords:[330,222,324,235,314,245,311,248,307,262,308,281,299,281,284,274,267,269,260,268,252,267,248,265,242,267,241,282,245,294,255,309,273,327,286,326,301,328,313,332,320,337,337,330,351,317,359,303,363,284,362,270,359,253,348,237,336,224,335,224],color:"#f74b22",id:"red"},{coords:[362,262,361,256,361,256,369,255,381,260,394,266,406,273,421,283,432,295,448,314,454,325,459,333,460,338,456,342,449,342,428,339,412,336,405,336,413,350,419,360,423,366,420,371,411,374,405,380,396,384,385,387,377,387,369,385,363,382,355,374,344,360,334,347,326,336,342,326,355,313,361,297,364,281,362,268],color:"#834a29",id:"brown"},{coords:[287,327,282,327,270,329,259,336,249,346,241,357,236,369,233,381,233,384,218,388,226,414,237,413,241,425,246,430,254,430,270,421,275,416,277,425,279,434,282,443,287,449,292,453,309,445,329,427,338,418,343,405,346,393,346,382,345,371,344,361,337,351,327,341,316,333,303,329,294,327],color:"#ee57a3",id:"pink"},{coords:[241,271,230,266,214,262,198,262,185,268,176,264,169,259,153,273,165,283,153,298,148,305,150,312,159,319,169,322,189,325,215,324,227,322,220,325,207,336,200,343,192,349,187,356,185,362,187,369,194,373,208,376,218,377,227,377,233,376,237,365,240,354,249,345,257,336,263,331,272,327,253,310,247,303,245,298],color:"#f3db3a",id:"yellow"}];this.canvas=new CanvasAdapter(600,600,"canv","cookieContainer");this.cookieEl=document.getElementById("cookieContainer");this.isSelectable=false;this.setEventListeners()},setEventListeners:function(){Event.observe(this.cookieEl,"mousemove",this.onmousemove.bindAsEventListener(this));Event.observe(this.cookieEl,"click",this.onclick.bindAsEventListener(this))},getCoords:function(d){var g=this.cookieEl.viewportOffset();var c=window.opera?d.pageX:d.clientX;var b=window.opera?d.pageY:d.clientY;var a=c-g.left;var f=b-g.top;return{x:a,y:f}},onmousemove:function(g){if(!this.isSelectable){return}var b=this.canvas;var d=this.getCoords(g);var h=this.getCookieByPoint(d.x,d.y);b.clear();b.parent.setStyle({cursor:h?"pointer":"default"});if(!h){return}b.ctx.strokeStyle=h.color;for(var a=0;a<h.coords.length;a++){var f={x:h.coords[a],y:h.coords[a+1]};if(a==0){b.moveTo(f)}else{b.lineTo(f)}a++}if(!this.correctVML&&window.G_vmlCanvasManager){$("cookieContainer").down("canvas div").setStyle({width:600+"px",height:600+"px"});this.correctVML=true}b.setOpacity(0.38);b.ctx.fillStyle=h.color;b.fill()},setSelectable:function(a){this.isSelectable=a},onclick:function(b){if(!this.isSelectable){return}var a=this.getCoords(b);var d=this.getCookieByPoint(a.x,a.y);if(!d){return}this.canvas.clear();this._onCookieSelect(d)},getCookieByPoint:function(a,d){var c=this.fgCookies;for(var b=0;b<c.length;b++){if(this.pointInPolygon(c[b].coords,a,d)){return c[b]}}return false},pnpoly:function(g,h,a,l){var d,b,k=0,f=g.length;for(d=0,b=f-1;d<f;b=d++){if((((h[d]<=l)&&(l<h[b]))||((h[b]<=l)&&(l<h[d])))&&(a<(g[b]-g[d])*(l-h[d])/(h[b]-h[d])+g[d])){k=!k}}return k},pointInPolygon:function(o,p,l){var d=[];var a=[];for(var g=0;g<o.length;g++){d.push(o[g]);a.push(o[g+1]);g++}return this.pnpoly(d,a,p,l);var g,f,h=0,b=o.length/2;for(g=0,f=b-1;g<b;f=g++){var r=o[g+1];var k=o[f+1];var u=o[g];var n=o[f];if((((r<=l)&&(l<k))||((k<=l)&&(l<r)))&&(p<(n-u)*(l-r)/(k-r)+u)){h=!h}}return h}});var CookiesImagePreloader=Class.create({_onLoadedAll:function(){},initialize:function(){var b=COOKIES_IMAGES_PATH;var a=["cloud.png","cookies.jpg","cookies_bgd.jpg","cookies_border_leftright.png","cookies_border_topbottom.png","cookies_border_topbottom.png","cookies_comment_bgd.png","cookies_comment_headfoot.png"];this.preloader=$("cookiesPreloader");this.images=this.initImages(b,a);this.loadedCount=0;this.setEventListeners()},initImages:function(b,c){var d,a=[];if(Prototype.Browser.IE){return[]}$A(c).each(function(f){d=new Image();d.src=b+f;a.push(d)});return a},show:function(a){Tools.show(this.preloader,a)},setEventListeners:function(){if(Prototype.Browser.IE){setTimeout(this.onLoadedAll.bind(this),3000)}$A(this.images).each(function(a){a.onload=this.onImageLoaded.bind(this)}.bind(this))},onImageLoaded:function(){this.loadedCount++;if(this.loadedCount==this.images.length){this.onLoadedAll()}},onLoadedAll:function(){this.show(false);this._onLoadedAll()}});(function(){var c=[],h=33,l="backgroundPositionX",j="backgroundPositionY",o={x:["left",l],y:["top",j]},C=0;lap_counter=0;var D=navigator.userAgent.toLowerCase();var B=/msie/.test(D)&&!/opera/.test(D);function g(G,E){if(G.style[E]){return G.style[E]}else{if(B){return G.currentStyle[E]}else{if(document.defaultView&&document.defaultView.getComputedStyle){E=E.replace(/([A-Z])/g,"-$1").toLowerCase();var F=document.defaultView.getComputedStyle(G,"");return F&&F.getPropertyValue(E)}else{return null}}}}function p(){lap_counter=0}function d(G,F){for(var E=0;E<G.length;E++){if(G[E]===F){return true}}return false}function z(G){var E=[];if(typeof(G)=="string"){G=G.split(/\s|,/)}for(var F=0;F<G.length;F++){if(G[F]){E.push(G[F].replace(/\-(\w)/g,function(I,H){return H.toUpperCase()}))}}return E}function A(){return(new Date).getTime()}function u(F){var E={width:0,height:0};if(typeof(F)=="number"||typeof(F)=="string"){E.width=E.height=parseInt(F,10)}else{E.width=F.width||0;E.height=F.height||0}E.x=E.width;E.y=E.height;return E}function v(){if(c.length){var F=A();for(var E=0;E<c.length;E++){if(c[E].time<=F){f(c[E].sprite,c[E]);c[E].time=F+Math.abs(c[E].sprite.frameDelay());if(c[E].cur_frame.backgroundPositionY==0){lap_counter++}if(lap_counter==c[E].laps){c[E].sprite.onLapsOver()}}}setTimeout(v,5)}}function f(P,N){var G=(P.frameDelay()<0)?"right":"left",O=P.getProperties(),F,I=P.elem;if(n(O)){F=y(P.elem)}for(var L=0;L<O.length;L++){var J=O[L],H=r(J),E=N.cur_frame[J]+(G=="left"?1:-1);if(E>=N.frame_count[H]){E=0}else{if(E<0){E=N.frame_count[H]-1}}N.cur_frame[J]=E}for(var L=0;L<O.length;L++){var J=O[L];if(J!=l&&J!=j){I.style[J]=(-P.frameSize()[r(J)]*N.cur_frame[J])+"px"}}if(F){var M=(l in N.cur_frame)?-P.frameSize().x*N.cur_frame[l]:F[l];var K=(j in N.cur_frame)?-P.frameSize().y*N.cur_frame[j]:F[j];I.style.backgroundPosition=M+"px "+K+"px"}}function y(G){var F=g(G,"backgroundPosition"),E={backgroundPositionX:0,backgroundPositionY:0};if(F){F=F.split(" ",2);E[l]=parseInt(F[0],10);E[j]=parseInt(F[1],10)}return E}function x(E){E.time=0;c.push(E);if(c.length==1){v()}}function a(F){for(var E=0;E<c.length;E++){if(c[E].id==F){c.splice(E,1);break}}}function n(E){return d(E,l)||d(E,j)}function r(E){return d(o.y,E)?"y":"x"}function k(K,G,J){var E={},I;if(n(J)){I=y(K)}for(var H=0;H<J.length;H++){var F=J[H];var L=(F.indexOf("background")!=-1)?I[F]:(g(K,F)||0);L=(L=="auto")?0:parseInt(L,10);E[F]=Math.round(L/G[r(F)])}return E}function b(G,I,M,K,N){I=u(I);M=u(M);K=z(K);_laps=(N)?N:3;var L=false,H=h,E=++C;var F={start:function(){if(!L){J.laps=_laps;x(J);L=true}},stop:function(){if(L){a(E);L=false}},reset:function(){p()},onLapsOver:function(){},isAnimating:function(){return L},frameDelay:function(O){if(arguments.length){H=parseInt(O,10)}return H},elem:G,getProperties:function(){return K},frameSize:function(O){if(arguments.length){I=u(O);J.frame_count.x=(M.width/I.width);J.frame_count.y=(M.height/I.height)}return I}};var J={frame_count:{x:0,y:0},cur_frame:k(G,I,K),sprite:F,time:0,id:E};F.frameSize(I);return F}window.spriteAnimation=b})();var FgSmile=Class.create({_onclick:function(){},_onmouseover:function(){},_onmouseout:function(){},_onStop:function(){},initialize:function(a){this.container=a;this.link=this.container.select(".smilesLink")[0];this.background=this.container.next();this.left=this.calculateLeft();this.currentLeft=0;this.step=20;this.setEventListeners()},calculateLeft:function(){var a=this.container.positionedOffset().left;return(window.opera||Tools.IE8())?a-1:a},isSelected:function(){return this.container.hasClassName("selected")},unSelect:function(){this.container.removeClassName("selected")},show:function(a){Tools.setVisible(this.container,a)},showBackground:function(a){Tools.show(this.background,a)},setEventListeners:function(){this.container.onclick=this.onclick.bind(this);this.container.onmouseover=this.onmouseover.bind(this);this.container.onmouseout=this.onmouseout.bind(this)},onmouseover:function(){Element.addClassName(this.link,"hover");this._onmouseover(this)},onmouseout:function(){Element.removeClassName(this.link,"hover");this._onmouseout(this)},onclick:function(){this._onclick(this)},reset:function(){this.setMarginLeft(0);this.unSelect();this.left=this.calculateLeft();this.show(true);this.container.removeClassName("checked");this.hideTitle(false);this.showBackground(false)},setMarginLeft:function(a){this.container.style.marginLeft=a+"px";this.currentLeft=a},move:function(){if((this.currentLeft+this.left)<=0){this.onStop();return}this.currentLeft-=this.step;this.setMarginLeft(this.currentLeft);setTimeout(this.move.bind(this),10)},hideTitle:function(a){Tools.setVisible(this.link,!a)},onStop:function(){this.showBackground(true);this.container.addClassName("checked");this._onStop(true)}});var FgSmilesManager=Class.create({initialize:function(a){this.container=a;if(a){this.smiles=this.initSmiles();this.currentSmile=null;this.commentManager=new FgSmileCommentManager();this.title=new FgSmilesTitle();this.resetLink=$("smilesResetLink");this.isFirstAnimated=true;this.initStartState();this.setEventListeners()}},initStartState:function(){var a=this.container.hasClassName("has-selected");if(!a){return}var b=$A(this.smiles).find(function(c){return c.isSelected()});this.currentSmile=b;if(b){this.commentManager.setSmile(b);b.showBackground(false)}},hasSelected:function(){return this.container.hasClassName("has-selected")},setEventListeners:function(){$A(this.smiles).each(function(a){a._onclick=this.clickSmile.bind(this);a._onmouseover=this.onSmileover.bind(this);a._onmouseout=this.onSmileout.bind(this);a._onclick=this.clickSmile.bind(this);a._onStop=this.showCommentAttrs.bind(this)}.bind(this));this.resetLink.onclick=this.reset.bind(this)},onSmileover:function(){Element.addClassName(this.resetLink,"hover")},onSmileout:function(){Element.removeClassName(this.resetLink,"hover")},showCommentAttrs:function(a){this.showResetLk(a);this.commentManager.show(true)},clickSmile:function(a){if(this.currentSmile==a&&!this.isFirstAnimated){return this.reset()}this.currentSmile=a;this.chooseSmile(a);this.hideSmilesTitle();this.isFirstAnimated=false;a.move();this.title.move()},hideSmilesTitle:function(){$A(this.smiles).each(function(a){a.hideTitle(true)})},showResetLk:function(a){Tools.show(this.resetLink,a)},initSmiles:function(){var a=[];var b=this.container.select(".smile");$A(b).each(function(c){a.push(new FgSmile(c))});return a},getComment:function(a){},reset:function(){this.showResetLk(false);this.commentManager.reset();$A(this.smiles).each(function(a){a.reset()});this.title.setUnderSmile(this.currentSmile);this.currentSmile=null},hideSmiles:function(a){var b=this.smiles.without(a);$A(b).each(function(c){c.show(false)})},chooseSmile:function(a){this.hideSmiles(a);this.commentManager.onGetComment(a,1)}});var FgSmilesRenderer=Class.create({_onRendered:function(){},initialize:function(a){this.container=a;this.itemTemplate=new Template('<li><a href="#{url}">#{title}</a></li>');this.wrapperTemplate=new Template('<div class="b-smiles-comment-item news-item"><ul>#{content}</ul></div>')},getMaterials:function(d){var c,a="";var g="";var b=0;var f=$A(d.object_list);$A(f).each(function(h){c=h.url?this.itemTemplate.evaluate(h):"<li>"+h+"</li>";g+=c;b++;if(b%3==0||b==f.length){a+=this.wrapperTemplate.evaluate({content:g});g=""}}.bind(this));return a},onGetComment:function(a,c){var d=a.container.id.replace("smile_","");var b=SMILE_MATERIALS_GET+d+"/?page="+c;Tools.send(b,this.onGetCommentSuccess.bind(this),this.onGetCommentFailure.bind(this))},onResetComment:function(){var a=SMILE_RESET;Tools.send(a,function(b){return true},this.onGetCommentFailure.bind(this))},onGetCommentSuccess:function(b){var c=b.responseText.evalJSON();var a=this.getMaterials(c);this.container.insert({bottom:a});this._onRendered()},onGetCommentFailure:function(){alert("Ошибка передачи данных")}});var FgSmileCommentManager=Class.create({initialize:function(){this.container=$("smilesCommentContainer");this.navBlock=$("smilesNavLinks");this.wrapper=$("smilesСommentWrapper");this.renderer=new FgSmilesRenderer(this.container);this.navigator=new FgSmilesCommentNavigator();this.step=25;this.scrollStep=475;this.resetData();this.isMoving=false;this.smile=null;this.updateNews();this.initCurrentNews();this.setEventsListeners()},setSmile:function(a){this.smile=a},resetData:function(){this.currentPortion=1;this.curLap=1;this.currentLeft=0},setEventsListeners:function(){this.renderer._onRendered=this.onCommentRendered.bind(this);this.navigator._onClickLink=this.getMoreComments.bind(this)},onGetComment:function(a,b){if(a){this.setSmile(a)}this.renderer.onGetComment(this.smile,b)},onCommentRendered:function(){this.updateNews();this.initCurrentNews();this.checkNewsCount()},initCurrentNews:function(){if(!this.currentNews){this.currentNews=this.news.length>0?this.news[0]:null}},updateNews:function(){this.news=this.container.select(".news-item");this.maxLap=this.news.length},setMovingStyles:function(a){this.currentNews.style.marginLeft=a+"px"},reset:function(){this.renderer.onResetComment();this.container.innerHTML="";this.resetData();this.navigator.reset();this.show(false);this.currentNews=null},getMoreComments:function(a){if(this.isMoving||!this.currentNews){return}if(!a){return}if(this.curLap==this.maxLap-2){this.currentPortion++;this.onGetComment(null,this.currentPortion)}this.isMoving=true;this.step=Math.abs(this.step)*a;this.correctCurrentElement(a);this.initCurrentLeft();this.onCommentsMove()},initCurrentLeft:function(){var a=Element.getStyle(this.currentNews,"marginLeft");this.currentLeft=parseInt(a.match(/-*\d+/))},correctCurrentElement:function(b){if(b>0){return}var a=this.news.indexOf(this.currentNews);if(a<0){return}this.currentNews=this.news[a-1]},checkNewsCount:function(){var b=this.curLap>=this.maxLap;var a=this.curLap<=1;this.navigator.hideRightLink(b);this.navigator.hideLeftLink(a);this.navigator.hideBlock(false)},updateCurrentParams:function(a){this.curLap+=a;this.checkNewsCount();this.isMoving=false;this.currentLeft=0;this.currentNews=this.news[this.curLap-1]},onCommentsMove:function(){this.currentLeft-=this.step;this.setMovingStyles(this.currentLeft);if(this.currentLeft<=-this.scrollStep||this.currentLeft>=0){var a=this.step>0?1:-1;this.updateCurrentParams(a);return}setTimeout(this.onCommentsMove.bind(this),20)},show:function(a){Tools.show(this.wrapper,a);this.navigator.hideBlock(!a)}});var FgSmilesCommentNavigator=Class.create({_onClickLink:function(){},initialize:function(){this.navBlock=$("smilesNavLinks");this.initLinks();this.setEventsListeners()},initLinks:function(){this.leftNavLk=this.navBlock.select(".left")[0];this.rightNavLk=this.navBlock.select(".right")[0];this.hideLeftLink(true)},reset:function(){this.hideBlock(true)},setEventsListeners:function(){this.navBlock.onclick=this.onClickLink.bindAsEventListener(this)},isLink:function(a){return a.tagName.toLowerCase()=="a"},hideRightLink:function(a){Tools.hide(this.rightNavLk,a)},hideLeftLink:function(a){Tools.hide(this.leftNavLk,a)},hideBlock:function(a){Tools.hide(this.navBlock,a)},onClickLink:function(c){var a=Event.element(c);if(!this.isLink(a)){return}var b=a.hasClassName("right")?1:-1;this._onClickLink(b)}});var FgSmilesTitle=Class.create({onStop:function(){},initialize:function(){this.title=$("smilesStateTitle");this.left=this.calculateLeft();this.currentLeft=0;this.step=20;this.setEventListeners()},setMarginLeft:function(a){this.title.style.marginLeft=a+"px";this.currentLeft=a},setLeft:function(a){this.title.style.left=a+"px";this.left=a},setUnderSmile:function(a){this.setMarginLeft(a.left)},calculateLeft:function(){var a=this.title.positionedOffset().left;return(window.opera||Tools.IE8())?a-1:a},reset:function(){this.setMarginLeft(0);this.setLeft(0)},move:function(){if((this.currentLeft+this.left)<=0){this.onStop();this.reset();return}this.currentLeft-=this.step;this.setMarginLeft(this.currentLeft);setTimeout(this.move.bind(this),10)},setEventListeners:function(){}});var CaloriesRangeHandler=Class.create();CaloriesRangeHandler.prototype={initialize:function(a){this.currange=a.currange;this.ranges=a.ranges;this.showCaloryTitle($("rlink"+this.currange),true);this.bindRLinks()},bindRLinks:function(){this.ranges.each(this.bindLink.bindAsEventListener(this))},showCaloryTitle:function(a,c){var b=["inline","none"];a.select(".caloryTitle")[0].style.display=b[c?0:1]},bindLink:function(a){var b=$("rlink"+a);b.onclick=function(f){var c=$("rlink"+this.currange);var d=$("rlink"+f);Element.removeClassName(c,"current");Element.addClassName($("range"+this.currange),"hidden");this.showCaloryTitle(c,false);Element.addClassName(d,"current");Element.removeClassName($("range"+f),"hidden");this.showCaloryTitle(d,true);this.currange=f;return false}.bind(this,a)}};