var $=function(){var elements=new Array();for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element=='string')element=document.getElementById(element);if(arguments.length==1)return element;elements.push(element);}return elements;};var undefined='undefined';var $def=function(data){return(typeof data!=undefined&&data!=null);};function is_function(stuff){return Boolean(typeof stuff=='function');}function is_array(stuff){return Boolean(stuff instanceof Array)};function is_string(stuff){return Boolean(typeof stuff=='string');}function is_number(stuff){return Boolean(typeof stuff=='number');}function is_object(stuff){return Boolean(typeof stuff=='object');}var _cssval=function(val,ref){if(/[%]/.test(val)){if(ref){var x=$E(ref.parentNode).getWidth();var p=val.replace(/[%]/gi,'');return(x*p/100)+'px';}}return(is_number(val)?val+'px':(is_string(val)?val:''));};function foreach(list,callback){if(!list.length||!is_function(callback))return;for(var i=0;i<list.length;i++)callback(list[i]);}var $extend=function(destination,source,overwrite){overwrite=overwrite||false;destination=destination||{};for(var key in source){destination[key]=source[key];}return destination;};String.prototype.trim=function(){var str=this;if(str==null||str=='undefined'||typeof str=='undefined')return'';return str.replace(/(^\s*)|(\s*$)/g,'');};String.prototype.cut=function(size){var str=this;if(str.length>size)return str.substr(0,size-3)+'...';else return str;};Number.random=function(limit){return Math.ceil(Math.random()*(limit||999999));};Function.prototype.inScope=function(context){var slice=Array.prototype.slice;if(arguments.length<2&&!$def(arguments[0]))return this;var __method=this,args=slice.call(arguments,1);return function(){var a=Array.merge(args,arguments);return __method.apply(context,a);}};Function.prototype.extend=function(data){$extend(this,data);return this;};Object.prototype.extend=function(data){$extend(this,data);this.asString=asString;return this;};var asString=function(){var l=[];for(var j in this){switch(typeof this[j]){case'string':l.push(j+':"'+this[j]+'"');break;case'function':l.push(j+':function(){}');break;case'object':if(is_array(this[j]))l.push(j+':Array ['+this[j].join(',')+']');else{l.push(j+':Object { }');}break;case'number':case'boolean':l.push(j+':'+this[j]);break;}}return'Object { \n'+l.join(',')+'\n }';};$extend(Array.prototype,{popValue:function(value){if(this.length==0)return[];var newList=[];for(var i=0;i<this.length;i++){if(this[i]!=value){newList.push(this[i]);}}this.length=0;for(var i=0;i<newList.length;i++){this.push(newList[i]);}return this;},popIndex:function(index){if(this.length==0)return[];var newList=new Array();for(var i=0;i<this.length;i++){if(i!=index)newList.push(this[i]);}this.length=0;for(var i=0;i<newList.length;i++){this.push(newList[i]);}return this;},clean:function(){if(this.length==0)return[];var newList=[];for(var i=0;i<this.length;i++)if(this[i]!=null)newList.push(this[i]);this.length=0;for(var i=0;i<newList.length;i++){this.push(newList[i]);}return this;},exists:function(value){if(this.length==0)return false;var exists=false;for(var i=0;i<this.length;i++){if(this[i]==value)return true;}return exists;},first:function(){return this.length>0?this[0]:null;},last:function(){return this.length>0?this[this.length-1]:null;},index_of:function(item,offset){if(offset>this.length-1||offset==null)offset=0;for(var i=offset;i<this.length;i++){if(this[i]==item){return i;}}return null;},foreach:function(processor){for(var i=0;i<this.length;i++)processor(this[i]);return this;},process:function(iterator){var results=[];for(var i=0;i<this.length;i++)results.push(iterator(this[i],i));return results;},filter:function(funel){var results=[];for(var i=0;i<this.length;i++)if(funel(this[i]))results.push(this[i]);return results;},mergeWith:function(array){if(!array||!array.length)return this;for(var i=0;i<array.length;i++)if(!this.exists(array[i]))this.push(array[i]);return this;}});Array.merge=function(){var arr=new Array();for(var i=0;i<arguments.length;i++){for(var j=0;j<arguments[i].length;j++)if(!arr.exists(arguments[i][j]))arr.push(arguments[i][j]);}return arr;};Date.prototype.setFullDate=function(day,month,year){if(day)this.setDate(day);if($def(month))this.setMonth(month);if(year)this.setFullYear(year);};var Pointers={pointers:{},read:function(id){return this.pointers['ptr'+id];},write:function(data){var key='';for(var i in this.pointers)if(this.pointers[i]==data)key=i;if(key==''){do{key='ptr'+Number.random();}while(this.pointers[key]!=null);this.pointers[key]=data;}return key.replace('ptr','');},free:function(id){if($def(this.pointers['ptr'+id])){if($def(this.pointers['ptr'+id]._object))$E(this.pointers['ptr'+id]._object).destroy();delete this.pointers['ptr'+id];}}};var $P=function(pointer,make){return Pointers[(make!=null?'write':'read')](pointer);};var Browser=function(){var ua=navigator.userAgent.toLowerCase();var isOpera=Object.prototype.toString.call(window.opera)=='[object Opera]';var FF=ua.indexOf('Gecko')>-1&&ua.indexOf('KHTML')===-1;return{Agent:ua,IE:!!document.all,IEVersion:parseFloat(ua.substring(ua.indexOf('msie ')+5))||0,Opera:isOpera,WebKit:ua.indexOf('AppleWebKit/')>-1,Gecko:FF,FF:FF,Safari:ua.indexOf("safari")!=-1}};var IO={loadScript:function(url){$$('script').extend({type:'text/javascript',language:'javascript',src:url}).appendTo(document.body);},addScript:function(code){var s=$$('script').set('type','text/javascript').set('language','javascript').set('text',code).appendTo(document.body);},loadCSS:function(url){var header=document.getElementsByTagName('head')[0];$$('link').extend({rel:'stylesheet',href:url}).appendTo(header);},addCSS:function(code){if(Browser.IE){setTimeout(function(){document.body.innerHTML+='<style type="text/css">'+code+'</style>';},1500);}else{var header=document.getElementsByTagName('head')[0];var node=$T(code);$$('style').extend({type:'text/css'}).append(node).appendTo(header);}},call:function(name,params){}};function _load(path){return function(){IO.loadScript(path);};}var Debug={'_log':[],fatal:false,log:function(message){if(is_object(message))message=message.asString();Debug._log.push(message);if(Debug._log.length>10)Debug._log.shift();if($def(window.console))window.console.log(message);},assert:function(procedure,fallback){try{Debug.log('> assert: '+String(procedure));if(is_string(procedure))procedure=Function(procedure);procedure();}catch(e){if(is_function(fallback))fallback(e);Debug.log('< result: '+(e.message||e));}},show:function(){alert('Last lines:\n'+this._log.join("\n"));}};var Class=function(){var classes=[];if(arguments.length>0)for(var i=0;i<arguments.length;i++)classes.push(arguments[i]);var result={};for(var i=0;i<classes.length;i++)$extend(result,classes[i],true);return result;};var UID=function(base){var id=null;do{id=base+Number.random();}while($(id)!=null);return id;};var ENUM=function(){if(arguments.length>0){for(var i=0;i<arguments.length;i++)window[arguments[i]]=i+1;}var f=function(){return this.value;};$extend(f,{value:0,add:function(){for(var i=0;i<arguments.length;i++)if(!this.exists(arguments[i]))this.value+=arguments[i];},sub:function(){for(var i=0;i<arguments.length;i++)if(this.exists(arguments[i]))this.value-=arguments[i];},exists:function(item){return(~this.value&item==item);}});return f;};var Cookies={setCookie:function(pA,pB,days){var dt=new Date();var cookie='';if(days>0){dt.setTime(dt.getTime()+days*24*360000);cookie="; expires="+dt.toGMTString();}document.cookie=pA+"="+pB+cookie;},getCookie:function(cookie){if(document.cookie){var st=document.cookie.indexOf(cookie);if(st>-1){st=st+cookie.length+1;var end=document.cookie.indexOf(';',st);if(end==-1)end=document.cookie.length;return unescape(document.cookie.substring(st,end));}return null;}return null;}};window.reload=function(){window.open(document.location.href,'_self');};var Events={list:{},deAttach:function(pointer){for(var evnt in this.list){var item=this.list[evnt];for(var i=0;i<item.length;i++)if(pointer==item[i].pointer){item[i]=null;item.clean();console.log('removed '+pointer);console.log(item);}}},attach:function(toObject,theEvent,callback){if(!toObject)toObject=window;if(!this.list['on'+theEvent])this.list['on'+theEvent]=[];var vPointer=Number.random();this.list['on'+theEvent].push({refer:toObject,event:theEvent,callback:callback,pointer:vPointer});toObject['on'+theEvent]=function(ev){Events.dispatch(toObject,theEvent,ev);};return vPointer;},dispatch:function(element,theEvent,object){object=object||window.event;var list=this.list['on'+theEvent];for(var i=0;i<list.length;i++){if(typeof element=='string')element=$(element);if(list[i]&&list[i].refer==element&&list[i].callback!=null)list[i].callback(object);}},getEventSource:function(ev){ev=ev||window.event;if(!ev)return null;var res=((ev)?((ev.target)?ev.target:ev.srcElement):window.event.srcElement);return res;},addEvent:function(func,evnt,object){if(!object)object=window;var oldfunction=object[evnt],call;if(typeof oldfunction=='function')call=function(){oldfunction();func();};else call=func;if(object.attachEvent)object.attachEvent(evnt,call);else if(object.addEventListener)object.addEventListener(evnt,call,false);else object[evnt]=call;}};Loader={list:[],run:function(){this.list.foreach(function(f){f();});},init:function(){if(document.all){setTimeout("Loader.run();",999);}else{Loader.run();}},add:function(f){if(is_function(f))Loader.list.push(f);}};Events.attach(window,'load',Loader.init);var Mouse={x:0,y:0,lastEvent:null,source:null,getMouseXY:function(event){event=event||window.event;Mouse.lastEvent=event;Mouse.source=Events.getEventSource(event);if(Browser.IE){Mouse.x=(event.clientX+document.body.scrollLeft)||0;Mouse.y=(event.clientY+document.body.scrollTop)||0;}else{Mouse.x=event.pageX;Mouse.y=event.pageY;}if(Mouse.x<0)Mouse.x=0;if(Mouse.y<0)Mouse.y=0;return true;}};Events.attach(document,'mousemove',Mouse.getMouseXY);var Drag={objectEvent:null,element:null,mouseOffset:null,capabilities:{x:false,y:false},callback:null,startDragY:function(obj,ev,callback){Drag.callback=callback;Drag.capabilities={x:false,y:true};Drag.drag(obj,ev);return false;},startDragX:function(obj,ev,callback){Drag.callback=callback;Drag.capabilities={x:true,y:false};Drag.drag(obj,ev);return false;},startDrag:function(obj,ev,callback){Drag.callback=callback;Drag.capabilities={x:true,y:true};Drag.drag(obj,ev);return false;},drag:function(el,ev){Drag.objectEvent=ev||window.ev;Drag.element=$E(el);Drag.getMouseOffset(Drag.element,Drag.objectEvent);},stopDrag:function(){Drag.element=null;Drag.objectEvent=null;Drag.capabilities={x:false,y:false};if(is_function(Drag.callback))Drag.callback();Drag.callback=null;},moveObject:function(ev){if(Drag.element==null)return;var MO=Drag.mouseOffset;var MP=Drag.mouseCoords(ev);if(Drag.capabilities.x==true){var pleft=MP.x-MO.x;Drag.element.style.left=pleft+'px';}if(Drag.capabilities.y==true){var ptop=MP.y-MO.y;Drag.element.style.top=ptop+'px';}},mouseCoords:function(ev){ev=ev||window.event;if(!ev||ev==null){return{x:0,y:0};}if(ev.pageX||ev.pageY)return{x:ev.pageX,y:ev.pageY};else return{x:ev.clientX,y:ev.clientY};},getMouseOffset:function(target,ev){if(!target){Drag.mouseOffset={x:0,y:0};}else{var docPos=target.getPosition();var mousePos=Drag.mouseCoords(ev);Drag.mouseOffset={x:mousePos.x-docPos.x,y:mousePos.y-docPos.y};}return Drag.mouseOffset;}};Events.attach(document,'mousemove',Drag.moveObject);Events.attach(document,'mouseup',Drag.stopDrag);var Element=function(tagname){var valid_tags=String('a|abbr|acronym|address|applet|area|b|base|basefont|bdo|big|blockquote|'+'body|br|button|caption|center|cite|code|col|colgroup|dd|del|dfn|dir|'+'div|dl|dt|em|fieldset|font|form|frame|frameset|head|h1|h2|h3|h4|h5|h6|'+'hr|html|i|iframe|img|input|ins|kbd|label|legend|li|link|map|menu|meta|'+'noframes|noscript|object|ol|optgroup|option|p|param|pre|q|s|samp|script|'+'select|small|span|strike|strong|style|sub|sup|table|tbody|td|textarea|'+'tfoot|th|thead|title|tr|tt|u|ul|var').split('|');if(!valid_tags.exists(tagname)){throw'Error: invalid tag name '+tagname;return false;}var element=document.createElement(tagname);$extend(element,Element._prototype);return element;};Element._prototype={getHeight:function(){return this.offsetHeight||0;},getWidth:function(){return this.offsetWidth||0;},getSize:function(){with(this){return{h:offsetHeight||0,w:offsetWidth||0};}},getRect:function(){var pos=this.getPosition(this);var size=this.getSize(this);return{x:pos.x,y:pos.y,w:size.w,h:size.h};},getPosition:function(){var element=this;var left=0,top=0;if(element.offsetParent){var PO=element.parentNode==document.body?{x:0,y:0}:$E(element.offsetParent).getPosition();while(element.offsetParent){left+=element.offsetLeft;top+=element.offsetTop;element=element.offsetParent;}}else PO={x:0,y:0};left+=element.offsetLeft;top+=element.offsetTop;return{x:left-PO.x,y:top-PO.y};},setPosition:function(x,y){if(!$def(x)||!$def(y))return this;this.css({left:x+'px',top:y+'px'});return this;},show:function(){if(this.style)this.style.display='';return this;},hide:function(){if(this.style)this.style.display='none';return this;},css:function(source){if(source)for(var property in source)try{this.style[property]=source[property];}catch(e){Debug.log('Invalid CSS value for "'+property+'": '+source[property]);}return this;},cssText:function(text){if(text!=''){var list=text.split(';');var obj={};for(var i=0;i<list.length;i++){var item=list[i].split(':');var key=String(item[0]).trim();var value=String(item[1]).trim();if(key&&value)obj[key]=value;}if(this.style){for(var k in obj)this.style[k]=obj[k];}}return this;},addClass:function(){var list=this.className.split(' ');if(arguments.length>0)for(var i=0;i<arguments.length;i++){var name=arguments[i];if(!list.exists(name))list.push(name);}this.className=list.join(' ').trim();return this;},removeClass:function(){var list=this.className.split(' ');if(arguments.length>0)for(var i=0;i<arguments.length;i++){list.popValue(arguments[i]);}this.className=list.join(' ').trim();return this;},haveClass:function(name){list=this.className.split(' ');return list.exists(name);},setSize:function(width,height){var suffixW='',suffixH='';var reg=/(%|em)/;if(reg.test(width)==false)suffixW='px';if(reg.test(height)==false)suffixH='px';if(width)this.style.width=width+suffixW;if(height)this.style.height=height+suffixH;return this;},getCenter:function(){var size=this.getSize();var pos=this.getPosition();var scr=Screen.portSize();var px=Math.ceil((scr.w-size.w)/2)||pos.x;var py=Math.ceil((scr.h-size.h)/2)+Screen.pageScroll().y||pos.y;if(py<0)py=0;return{x:px,y:py};},centerfx:function(moveX,moveY){moveX=(moveX==null?true:moveX);moveY=(moveY==null?true:moveY);var pos=this.getCenter();return Effects.Move().applyTo(this,'auto',{x:pos.x,y:pos.y}).init();},center:function(){var pos=this.getCenter();this.setPosition(pos.x,pos.y);return this;},centerX:function(){return this.center(true,false);},centerY:function(){return this.center(false,true);},movefx:function(x,y,start){if(start)this.setPosition(start.x,start.y);var pos=this.getPosition();x=x||pos.x;y=y||pos.y;return Effects.Move().applyTo(this,'auto',{x:x,y:y}).init();},resizefx:function(width,height){if(width==null)width=this.getWidth();if(height==null)width=this.getheight();return Effects.Size().applyTo(this,'auto',{w:width,h:height}).init();},extend:function(k){$extend(this,k);return this;},append:function(element){element=$(element);if(!element)return false;this.appendChild(element);return this;},appendTo:function(element){element=$(element);if(!element)return false;element.appendChild(this);return this;},appendAsFirst:function(element){element=$(element);if(!element)return false;element.insertBefore(this,element.firstChild);return this;},appendAfter:function(ref){if(!ref)return this;if(ref.nextSibling==null)ref.parentNode.appendChild(this);else ref.parentNode.insertBefore(this,ref.nextSibling);},findFirst:function(tag){var k=this.getElementsByTagName(tag);if(k)return k[0];return null;},destroy:function(){if(this.parentNode)this.parentNode.removeChild(this);},clearNodes:function(){while(this.hasChildNodes())this.removeChild(this.firstChild);return this;},addHTML:function(htmltext){var html=$$('div').set('innerHTML',htmltext);while(html.hasChildNodes()){this.appendChild(html.firstChild);html.removeChild(html.firstChild);}return this;},getHTML:function(){var html='',tmpnode=$$('div').append(this.cloneNode(true));html=tmpnode.innerHTML;delete tmpnode;return html;},set:function(p,v){this[p]=v;return this;},getAttrib:function(name){var attr=this.attributes.getNamedItem(name);if(attr)return attr.value;return null;},getCSS:function(name){var y;if(this.currentStyle)y=this.currentStyle[name];else if(window.getComputedStyle)y=document.defaultView.getComputedStyle(this,null).getPropertyValue(name);return y;},byTag:function(tag){var list=null;if(tag){list=this.getElementsByTagName(tag);}return list;},byClass:function(tag,className){var list=this.byTag(tag),ret=[];for(var i=0;i<list.length;i++){if($E(list[i]).haveClass(className))ret.push(list[i]);}return ret;},cancelEffects:function(yes){this._cancelEffects=yes!=null?Boolean(yes):true;},_cancelEffects:false};var $$=function(tag){return new Element(tag);};var $T=function(value){return document.createTextNode(value);};var $E=function(element){element=$(element);if(!element)return null;if(!element.byClass)$extend(element,Element._prototype);return element;};var Screen={portSize:function(){var width=0,height=0;if(self.innerHeight){width=self.innerWidth;height=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){width=document.documentElement.clientWidth;height=document.documentElement.clientHeight;}else if(document.body){width=document.body.clientWidth;height=document.body.clientHeight;}return{w:width,h:height};},pageSize:function(){var scroll=this.pageScroll(),xScroll=scroll.x,yScroll=scroll.y;var wW=0,wH=0;if(self.innerHeight){wW=self.innerWidth;wH=self.innerHeight;}else if(document.documentElement&&document.documentElement.clientHeight){wW=document.documentElement.clientWidth;wH=document.documentElement.clientHeight;}else if(document.body){wW=document.body.clientWidth;wH=document.body.clientHeight;}if(yScroll<wH)var pH=wH;else var pH=yScroll;if(xScroll<wW)var pW=wW;else var pW=xScroll;return{w:pW,h:pH,pw:wW,wH:wH};},pageScroll:function(){var x=0,y=0;if(self.pageYOffset){x=self.pageXOffset;y=self.pageYOffset;}else if(document.documentElement&&document.documentElement.scrollTop){x=document.documentElement.scrollLeft;y=document.documentElement.scrollTop;}else if(document.body){x=document.body.scrollLeft;y=document.body.scrollTop;}return{x:x,y:y};}};var EffectsList=function(){return Class(EffectsList);}.extend({list:[],pointer:null,add:function(effect){if(effect)this.list.push(effect);else throw"EffectsList: invalid effect !";},init:function(){this.pointer=$P(this,true);this.exec();if(this.list[0])this.list[0].init();},next:function(){if(this.list[0].fxback)this.list[0].fxback();this.list.shift();if(this.list[0])this.list[0].init();},exec:function(){for(var i=0;i<this.list.length;i++){var element=this.list[i];if(element.callback)element.fxback=element.callback;element.callback=Function('$P('+this.pointer+').next()');}}});var Effects={};Effects.Size=function(){return Class(Effects.Size);}.extend({pointer:null,factor:5,time:50,start:null,end:null,object:null,clock:null,callback:null,applyTo:function(object,start,end,callback){this.object=$E(object);if(!this.object){throw"Effects.Move: object not found!";return null;}this.start=start;this.end=end;if(this.end==null||this.end.w==null||this.end.h==null){throw"Effects.Move: invalid end size!";return null;}this.pointer=$P(this,true);this.object.style.overflow='hidden';this.object.style.display='block';this.callback=callback;if(this.start!='auto'){this.object.style.width=this.start.w+'px';this.object.style.height=this.start.h+'px';}return this;},init:function(){if(!this.pointer)return null;if(this.start=='auto')this.start=this.object.getSize();this.clock=setInterval(Function('$P('+this.pointer+').fx()'),this.time);return this;},fx:function(){var diffX=this.start.w-this.end.w,diffY=this.start.h-this.end.h;var valueX=Math.ceil(Math.abs(diffX/this.factor));var valueY=Math.ceil(Math.abs(diffY/this.factor));if(valueX<0)valueX*=-1;if(valueY<0)valueY*=-1;if(this.start.w>this.end.w){this.start.w-=valueX;}else if(this.start.w<this.end.w){this.start.w+=valueX;}else this.start.w=this.end.w;if(this.start.h>this.end.h){this.start.h-=valueY;}else if(this.start.h<this.end.h){this.start.h+=valueY;}else this.start.h=this.end.h;if((valueX==0&&valueY==0)||this.object._cancelEffects){clearInterval(this.clock);if(typeof this.callback=='function')this.callback();Pointers.free(this.pointer);return;}this.object.style.width=this.start.w+'px';this.object.style.height=this.start.h+'px';}});Effects.Move=function(){return Class(Effects.Move);}.extend({pointer:null,factor:5,time:50,start:null,end:null,object:null,clock:null,callback:null,applyTo:function(object,start,end,callback){this.object=$E(object);if(!this.object){throw'Effects.Move: invalid object!';return null;}this.start=start;this.end=end;if(this.end==null||this.end.x==null||this.end.y==null){throw"Effects.Move: invalid end position!";return null;}this.callback=callback;this.pointer=$P(this,true);if(this.start!='auto'){this.object.style.top=this.start.y+'px';this.object.style.left=this.start.x+'px';}return this;},init:function(){if(!this.pointer)return null;if(this.start=='auto')this.start=this.object.getPosition();this.clock=setInterval(Function('$P('+this.pointer+').fx()'),this.time);return this;},fx:function(){var diffX=this.start.x-this.end.x,diffY=this.start.y-this.end.y;var valueX=Math.ceil(Math.abs(diffX/this.factor));var valueY=Math.ceil(Math.abs(diffY/this.factor));if(valueX<0)valueX*=-1;if(valueY<0)valueY*=-1;if(this.start.x>this.end.x){this.start.x-=valueX;}else if(this.start.x<this.end.x){this.start.x+=valueX;}else this.start.x=this.end.x;if(this.start.y>this.end.y){this.start.y-=valueY;}else if(this.start.y<this.end.y){this.start.y+=valueY;}else this.start.y=this.end.y;if((valueX==0&&valueY==0)||this.object._cancelEffects){clearInterval(this.clock);if(typeof this.callback=='function')this.callback();Pointers.free(this.pointer);return;}this.object.style.left=this.start.x+'px';this.object.style.top=this.start.y+'px';}});Effects.Fade=function(){return Class(Effects.Fade)}.extend({pointer:null,factor:5,time:50,start:null,end:null,object:null,clock:null,callback:null,applyTo:function(object,start,end,callback){this.object=$E(object);if(!this.object){throw'Effects.fade: invalid object!';return null;}this.start=start;this.end=end;if(this.end>100)this.end=100;if(this.start<0)this.start=0;this.callback=callback;this.pointer=$P(this,true);return this;},init:function(){if(!this.pointer)return null;this.clock=setInterval(this.fx.inScope(this),this.time);return this;},fx:function(){var diff=this.end-this.start;var value=Math.ceil(Math.abs(diff/this.factor));if(value<0)valueX*=-1;if(this.start>this.end){this.start-=value;}else if(this.start<this.end){this.start+=value;}else this.start=this.end;if(value==0||this.object._cancelEffects){clearInterval(this.clock);if(typeof this.callback=='function')this.callback();Pointers.free(this.pointer);return;}this.object.style.opacity=this.start/100;this.object.style.filter='alpha(Opacity='+this.start+')';}});var Ajax={};Ajax.getTransport=function(){var requestElements=["MSXML2.XMLHTTP.5.0","MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0","MSXML2.XMLHTTP","MICROSOFT.XMLHTTP.1.0","MICROSOFT.XMLHTTP.1","MICROSOFT.XMLHTTP"];var requestElement;if(typeof XMLHttpRequest=='undefined'&&typeof ActiveXObject!='undefined'){for(var a=0;a<requestElements.length;a++){var b=requestElements[a];try{new ActiveXObject(b);requestElement=b;break;}catch(c){}}if(typeof requestElement=='undefined'){throw"Este navegador não dá suporte ao site. Atualize-o!";}}if(typeof requestElement!='undefined')return new ActiveXObject(requestElement);else return new XMLHttpRequest;};Ajax.Get=function(url,variables,params){var k=$extend({url:url+'?'+variables},params);return Ajax.Request(k);};Ajax.Response={text:null,xml:null,status:null,error:null,target:null,object:null,onSuccess:null,onError:null,process:function(){switch(this.object.readyState){case 1:case 2:case 3:break;case 4:this.text=this.object.responseText;this.xml=this.object.responseXML||null;this.status=this.object.status;if(this.status==200){if(this.target){this.target=$E(this.target);this.target.clearNodes();if(RegExp('\.(gif|jpe?g|png|bmp)','i').test(this.url)&&!is_function(this.onSuccess))$$('img').set('src',this.url+'?'+this.query).appendTo(this.target);else $E(this.target).innerHTML=this.text;}Ajax.jsRun(this.text);if(is_function(this.onSuccess))this.onSuccess(this);}else{this.error=this.object.statusText;if(is_function(this.onError))this.onError(this);}}}};Ajax.Request=function(params){return Class(Ajax.Request).get(params);}.extend({target:null,method:null,loader:false,async:true,url:'',query:null,request:null,get:function(params){var response=Class(Ajax.Response);response.object=Ajax.getTransport();if(!response.object){throw"Ajax: unable to find transport object!";return null;}params=params||{};this.target=params.target||null;this.method=String(params.method||'GET').toUpperCase();response.onSuccess=params.onSuccess||null;response.onError=params.onError||null;this.url=params.url;this.async=Boolean(params.async||true);if(this.url=='')return null;if(this.url.indexOf('?')===-1)this.url+='?';var u=this.url.split('?');this.query=u[1];this.url=u[0];response.target=this.target;var isGet=this.method=='GET';var isPost=this.method=='POST';if(isGet)this.query+='&rand='+Number.random();var reqURL=this.url+(isGet?'?'+this.query:'');response.object.open(this.method,reqURL,this.async);if(isPost)response.object.setRequestHeader("Content-Type","application/x-www-form-urlencoded");response.object.setRequestHeader("X-Ajax","RDA Ajax Lib rev. 4");response.object.onreadystatechange=response.process.inScope(response);try{response.object.send(isGet?null:this.query);}catch(err){throw"Ajax: exception on XHR.Send: "+err;}return response;}});Ajax.jsRun=function(text){if(!text)return false;var start=0;var end=0;var code='';while(start!=-1){start=text.indexOf('<scr'+'ipt',start);if(start>=0){start=text.indexOf('>',start)+1;end=text.indexOf('</scr'+'ipt>',start);code=String(text.substring(start,end)).trim();if(Debug&&Debug.assert)code='Debug.assert(function(){\n'+code+'\n});';if(code!='')IO.addScript(code);}}return true;};Ajax.JSON=function(url,callback){if(url.indexOf('?')===-1)url+='?';return IO.loadScript(url+'&cback='+callback);};var Form={serialize:function(form){var elements=Form.getElements($(form));var queryComponents=new Array();for(var i=0;i<elements.length;i++){var queryComponent=Form.Element.serialize(elements[i]);if(queryComponent)queryComponents.push(queryComponent);}return queryComponents.join('&');},getElements:function(form){form=$(form);var elements=new Array();for(tagName in Form.Element.Serializers){var tagElements=form.getElementsByTagName(tagName);for(var j=0;j<tagElements.length;j++)elements.push(tagElements[j]);}return elements;},getInputs:function(form,typeName,name){form=$(form);var inputs=form.getElementsByTagName('input');if(!typeName&&!name)return inputs;var matchingInputs=new Array();for(var i=0;i<inputs.length;i++){var input=inputs[i];if((typeName&&input.type!=typeName)||(name&&input.name!=name))continue;matchingInputs.push(input);}return matchingInputs;},disable:function(form){var elements=Form.getElements(form);for(var i=0;i<elements.length;i++){var element=elements[i];element.blur();element.disabled='true';}},enable:function(form){var elements=Form.getElements(form);for(var i=0;i<elements.length;i++){var element=elements[i];element.disabled='';}},reset:function(form){$(form).reset();},focusFirst:function(element){var list=Form.getInputs(element,'text');if(list.length>0)list[0].focus();},send:function(element,target,callback){var form=$(element);if(!form)return false;var method=form.method||'post';target=target||form.target;Ajax.Request({url:form.action+'?'+Form.serialize(form),target:target,method:form.method,onSuccess:callback});return true;},sendAsFrame:function(element,callback){element=$(element);var id=UID('frame');var sendComplete=function(){var e=this;var doc=(e.contentDocument?e.contentDocument:(e.contentWindow?e.contentWindow.document:window.frames[id].document));if(!doc||doc.location.href=="about:blank")return;var result=doc.body.innerHTML;this.parentNode.removeChild(this);if(callback)callback(result);};var frame=$$('iframe').extend({src:"about:blank",id:id,name:id,onload:sendComplete,width:1,height:1,frameborder:0});document.body.appendChild(frame);element.target=id;return true;}};Form.Element={serialize:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter){var key=encodeURIComponent(parameter[0]);if(key.length==0)return;if(parameter[1].constructor!=Array)parameter[1]=[parameter[1]];var res=[];for(var k=0;k<parameter[1].length;k++)res.push(key+'='+encodeURIComponent(parameter[1][k]));return res.join('|');}},getValue:function(element){element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter)return parameter[1];}};Form.Element.Serializers={input:function(element){switch(element.type.toLowerCase()){case'submit':case'hidden':case'password':case'text':return Form.Element.Serializers.textarea(element);case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(element);}return false;},inputSelector:function(element){if(element.checked)return[element.name,element.value];},textarea:function(element){return[element.name,element.value];},select:function(element){return Form.Element.Serializers[element.type=='select-one'?'selectOne':'selectMany'](element);},selectOne:function(element){var value='',opt,index=element.selectedIndex;if(index>=0){opt=element.options[index];value=opt.value;if(!value&&!('value'in opt))value=opt.text;}return[element.name,value];},selectMany:function(element){var value=new Array();for(var i=0;i<element.length;i++){var opt=element.options[i];if(opt.selected){var optValue=opt.value;if(!optValue&&!('value'in opt))optValue=opt.text;value.push(optValue);}}return[element.name,value];}};Form.Validator={rules:{},addRule:function(form,theField,rule,extra){form=$(form);if(!form.id)form.setAttribute('id',UID('form-'));field=$(theField);if(!field){throw'Validator: invalid field "'+theField+'"!';return false;}if(!Form.Validator.rules[form.id])Form.Validator.rules[form.id]=[];Form.Validator.rules[form.id].push({field:field,rule:rule,re:null,extra:extra});},removeRule:function(form,field){form=$(form);field=$(field);var list=Form.Validator.rules[form.id];if(!list)return;for(var i=0;i<list.lenght;i++){if(list[i].field==field)list[i]=null;}list.clean();},check:function(form){form=$(form);var list=Form.Validator.rules[form.id];if(!list)return false;var formValid=true;for(var i=0;i<list.length;i++){if(list[i].field){if(list[i].rule!=''){list[i].re=new RegExp(list[i].rule);var valid=(list[i].re.exec(list[i].field.value)!=null);}if(typeof list[i].extra=='function'){var valid=list[i].extra(list[i].field);}list[i].field.setAttribute('valid',valid);if(!valid){$E(list[i].field.parentNode).addClass('invalid').removeClass('valid');}else{$E(list[i].field.parentNode).removeClass('invalid').addClass('valid');}formValid=formValid&&valid;}}form.setAttribute('valid',formValid);return formValid;}};
