LowPro={};LowPro.Version='0.5';LowPro.CompatibleWithPrototype='1.6';if(Prototype.Version.indexOf(LowPro.CompatibleWithPrototype)!=0&&window.console&&window.console.warn)
console.warn("This version of Low Pro is tested with Prototype "+LowPro.CompatibleWithPrototype+" it may not work as expected with this version ("+Prototype.Version+")");if(!Element.addMethods)
Element.addMethods=function(o){Object.extend(Element.Methods,o)};DOM={};DOM.Builder={tagFunc:function(tag){return function(){var attrs,children;if(arguments.length>0){if(arguments[0].constructor==Object){attrs=arguments[0];children=Array.prototype.slice.call(arguments,1);}else{children=arguments;};children=$A(children).flatten()}
return DOM.Builder.create(tag,attrs,children);};},create:function(tag,attrs,children){attrs=attrs||{};children=children||[];tag=tag.toLowerCase();var el=new Element(tag,attrs);for(var i=0;i<children.length;i++){if(typeof children[i]=='string')
children[i]=document.createTextNode(children[i]);el.appendChild(children[i]);}
return $(el);}};(function(){var els=("p|div|span|strong|em|img|table|tr|td|th|thead|tbody|tfoot|pre|code|"+"h1|h2|h3|h4|h5|h6|ul|ol|li|form|input|textarea|legend|fieldset|"+"select|option|blockquote|cite|br|hr|dd|dl|dt|address|a|button|abbr|acronym|"+"script|link|style|bdo|ins|del|object|param|col|colgroup|optgroup|caption|"+"label|dfn|kbd|samp|var").split("|");var el,i=0;while(el=els[i++])
window['$'+el]=DOM.Builder.tagFunc(el);})();DOM.Builder.fromHTML=function(html){var root;if(!(root=arguments.callee._root))
root=arguments.callee._root=document.createElement('div');root.innerHTML=html;return root.childNodes[0];};Object.extend(Event,{onReady:function(f){if(document.body)f();else document.observe('dom:loaded',f);}});Event.addBehavior=function(rules){var ab=this.addBehavior;Object.extend(ab.rules,rules);if(!ab.responderApplied){Ajax.Responders.register({onComplete:function(){if(Event.addBehavior.reassignAfterAjax)
setTimeout(function(){ab.reload()},10);}});ab.responderApplied=true;}
if(ab.autoTrigger){this.onReady(ab.load.bind(ab,rules));}};Event.delegate=function(rules){return function(e){var element=$(e.element());for(var selector in rules)
if(element.match(selector))return rules[selector].apply(this,$A(arguments));}}
Object.extend(Event.addBehavior,{rules:{},cache:[],reassignAfterAjax:false,autoTrigger:true,load:function(rules){for(var selector in rules){var observer=rules[selector];var sels=selector.split(',');sels.each(function(sel){var parts=sel.split(/:(?=[a-z]+$)/),css=parts[0],event=parts[1];$$(css).each(function(element){if(event){var wrappedObserver=Event.addBehavior._wrapObserver(observer);$(element).observe(event,wrappedObserver);Event.addBehavior.cache.push([element,event,wrappedObserver]);}else{if(!element.$$assigned||!element.$$assigned.include(observer)){if(observer.attach)observer.attach(element);else observer.call($(element));element.$$assigned=element.$$assigned||[];element.$$assigned.push(observer);}}});});}},unload:function(){this.cache.each(function(c){Event.stopObserving.apply(Event,c);});this.cache=[];},reload:function(){var ab=Event.addBehavior;ab.unload();ab.load(ab.rules);},_wrapObserver:function(observer){return function(event){if(observer.call(this,event)===false)event.stop();}}});Event.observe(window,'unload',Event.addBehavior.unload.bind(Event.addBehavior));$$$=Event.addBehavior.bind(Event);var Behavior={create:function(){var parent=null,properties=$A(arguments);if(Object.isFunction(properties[0]))
parent=properties.shift();var behavior=function(){if(!this.initialize){var args=$A(arguments);return function(){var initArgs=[this].concat(args);behavior.attach.apply(behavior,initArgs);};}else{var args=(arguments.length==2&&arguments[1]instanceof Array)?arguments[1]:Array.prototype.slice.call(arguments,1);this.element=$(arguments[0]);this.initialize.apply(this,args);behavior._bindEvents(this);behavior.instances.push(this);}};Object.extend(behavior,Class.Methods);Object.extend(behavior,Behavior.Methods);behavior.superclass=parent;behavior.subclasses=[];behavior.instances=[];if(parent){var subclass=function(){};subclass.prototype=parent.prototype;behavior.prototype=new subclass;parent.subclasses.push(behavior);}
for(var i=0;i<properties.length;i++)
behavior.addMethods(properties[i]);if(!behavior.prototype.initialize)
behavior.prototype.initialize=Prototype.emptyFunction;behavior.prototype.constructor=behavior;return behavior;},Methods:{attach:function(element){return new this(element,Array.prototype.slice.call(arguments,1));},_bindEvents:function(bound){for(var member in bound){var matches=member.match(/^on(.+)/);if(matches&&typeof bound[member]=='function')
bound.element.observe(matches[1],Event.addBehavior._wrapObserver(bound[member].bindAsEventListener(bound)));}}}};Remote=Behavior.create({initialize:function(options){if(this.element.nodeName=='FORM')new Remote.Form(this.element,options);else new Remote.Link(this.element,options);}});Remote.Base={initialize:function(options){this.options=Object.extend({evaluateScripts:true},options||{});this._bindCallbacks();},_makeRequest:function(options){if(options.update)new Ajax.Updater(options.update,options.url,options);else new Ajax.Request(options.url,options);return false;},_bindCallbacks:function(){$w('onCreate onComplete onException onFailure onInteractive onLoading onLoaded onSuccess').each(function(cb){if(Object.isFunction(this.options[cb]))
this.options[cb]=this.options[cb].bind(this);}.bind(this));}}
Remote.Link=Behavior.create(Remote.Base,{onclick:function(){var options=Object.extend({url:this.element.href,method:'get'},this.options);return this._makeRequest(options);}});Remote.Form=Behavior.create(Remote.Base,{onclick:function(e){var sourceElement=e.element();if(['input','button'].include(sourceElement.nodeName.toLowerCase())&&sourceElement.type=='submit')
this._submitButton=sourceElement;},onsubmit:function(){var options=Object.extend({url:this.element.action,method:this.element.method||'get',parameters:this.element.serialize({submit:this._submitButton.name})},this.options);this._submitButton=null;return this._makeRequest(options);}});Observed=Behavior.create({initialize:function(callback,options){this.callback=callback.bind(this);this.options=options||{};this.observer=(this.element.nodeName=='FORM')?this._observeForm():this._observeField();},stop:function(){this.observer.stop();},_observeForm:function(){return(this.options.frequency)?new Form.Observer(this.element,this.options.frequency,this.callback):new Form.EventObserver(this.element,this.callback);},_observeField:function(){return(this.options.frequency)?new Form.Element.Observer(this.element,this.options.frequency,this.callback):new Form.Element.EventObserver(this.element,this.callback);}});if(!window.Modalbox)
var Modalbox=new Object();Modalbox.Methods={overrideAlert:false,focusableElements:new Array,currFocused:0,initialized:false,active:true,options:{title:"ModalBox Window",overlayClose:true,width:500,height:90,overlayOpacity:.65,overlayDuration:.25,slideDownDuration:.5,slideUpDuration:.5,resizeDuration:.25,inactiveFade:true,transitions:true,loadingString:"Please wait. Loading...",closeString:"Close window",closeValue:"<img src=\"/images/close_button.gif\" width=\"11\" height=\"11\" alt=\"\">",params:{},method:'get',autoFocusing:true,aspnet:false},_options:new Object,setOptions:function(options){Object.extend(this.options,options||{});},_init:function(options){Object.extend(this._options,this.options);this.setOptions(options);this.MBoverlay=new Element("div",{id:"MB_overlay",opacity:"0"});this.MBwindow=new Element("div",{id:"MB_window",style:"display: none"}).update(this.MBframe=new Element("div",{id:"MB_frame"}).update(this.MBheader=new Element("div",{id:"MB_header"}).update(this.MBcaption=new Element("div",{id:"MB_caption"}))));this.MBclose=new Element("a",{id:"MB_close",title:this.options.closeString,href:"#"}).update("<span class='MB_CloseX'>"+this.options.closeValue+"</span> <span>"+this.options.closeString+"</span>");this.MBheader.insert({'bottom':this.MBclose});this.MBcontent=new Element("div",{id:"MB_content"}).update(this.MBloading=new Element("div",{id:"MB_loading"}).update(this.options.loadingString));this.MBframe.insert({'bottom':this.MBcontent});var injectToEl=this.options.aspnet?$(document.body).down('form'):$(document.body);injectToEl.insert({'top':this.MBwindow});injectToEl.insert({'top':this.MBoverlay});this.initScrollX=window.pageXOffset||document.body.scrollLeft||document.documentElement.scrollLeft;this.initScrollY=window.pageYOffset||document.body.scrollTop||document.documentElement.scrollTop;this.hideObserver=this._hide.bindAsEventListener(this);this.kbdObserver=this._kbdHandler.bindAsEventListener(this);this._initObservers();this.initialized=true;},show:function(content,options){if(!this.initialized)this._init(options);this.content=content;this.setOptions(options);if(this.options.title)
$(this.MBcaption).update(this.options.title);else{$(this.MBheader).hide();$(this.MBcaption).hide();}
if(this.MBwindow.style.display=="none"){this._appear();this.event("onShow");}
else{this._update();this.event("onUpdate");}},hide:function(options){if(this.initialized){if(options&&typeof options.element!='function')Object.extend(this.options,options);this.event("beforeHide");if(this.options.transitions)
Effect.SlideUp(this.MBwindow,{duration:this.options.slideUpDuration,transition:Effect.Transitions.sinoidal,afterFinish:this._deinit.bind(this)});else{$(this.MBwindow).hide();this._deinit();}}else throw("Modalbox is not initialized.");},_hide:function(event){event.stop();if(event.element().id=='MB_overlay'&&!this.options.overlayClose)return false;this.hide();},alert:function(message){var html='<div class="MB_alert"><p>'+message+'</p><input type="button" onclick="Modalbox.hide()" value="OK" /></div>';Modalbox.show(html,{title:'Alert: '+document.title,width:300});},_appear:function(){if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){window.scrollTo(0,0);this._prepareIE("100%","hidden");}
this._setWidth();this._setPosition();if(this.options.transitions){$(this.MBoverlay).setStyle({opacity:0});new Effect.Fade(this.MBoverlay,{from:0,to:this.options.overlayOpacity,duration:this.options.overlayDuration,afterFinish:function(){new Effect.SlideDown(this.MBwindow,{duration:this.options.slideDownDuration,transition:Effect.Transitions.sinoidal,afterFinish:function(){this._setPosition();this.loadContent();}.bind(this)});}.bind(this)});}else{$(this.MBoverlay).setStyle({opacity:this.options.overlayOpacity});$(this.MBwindow).show();this._setPosition();this.loadContent();}
this._setWidthAndPosition=this._setWidthAndPosition.bindAsEventListener(this);Event.observe(window,"resize",this._setWidthAndPosition);},resize:function(byWidth,byHeight,options){var wHeight=$(this.MBwindow).getHeight();var wWidth=$(this.MBwindow).getWidth();var hHeight=$(this.MBheader).getHeight();var cHeight=$(this.MBcontent).getHeight();var newHeight=((wHeight-hHeight+byHeight)<cHeight)?(cHeight+hHeight-wHeight):byHeight;if(options)this.setOptions(options);if(this.options.transitions){new Effect.ScaleBy(this.MBwindow,byWidth,newHeight,{duration:this.options.resizeDuration,afterFinish:function(){this.event("_afterResize");this.event("afterResize");}.bind(this)});}else{this.MBwindow.setStyle({width:wWidth+byWidth+"px",height:wHeight+newHeight+"px"});setTimeout(function(){this.event("_afterResize");this.event("afterResize");}.bind(this),1);}},resizeToContent:function(options){var byHeight=this.options.height-this.MBwindow.offsetHeight;if(byHeight!=0){if(options)this.setOptions(options);Modalbox.resize(0,byHeight);}},resizeToInclude:function(element,options){var el=$(element);var elHeight=el.getHeight()+parseInt(el.getStyle('margin-top'))+parseInt(el.getStyle('margin-bottom'))+parseInt(el.getStyle('border-top-width'))+parseInt(el.getStyle('border-bottom-width'));if(elHeight>0){if(options)this.setOptions(options);Modalbox.resize(0,elHeight);}},_update:function(){$(this.MBcontent).update("");this.MBcontent.appendChild(this.MBloading);$(this.MBloading).update(this.options.loadingString);this.currentDims=[this.MBwindow.offsetWidth,this.MBwindow.offsetHeight];Modalbox.resize((this.options.width-this.currentDims[0]),(this.options.height-this.currentDims[1]),{_afterResize:this._loadAfterResize.bind(this)});},loadContent:function(){if(this.event("beforeLoad")!=false){if(typeof this.content=='string'){var htmlRegExp=new RegExp(/<\/?[^>]+>/gi);if(htmlRegExp.test(this.content)){this._insertContent(this.content.stripScripts());this._putContent(function(){this.content.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));}.bind(window));}.bind(this));}else
new Ajax.Request(this.content,{method:this.options.method.toLowerCase(),parameters:this.options.params,onSuccess:function(transport){var response=new String(transport.responseText);this._insertContent(transport.responseText.stripScripts());this._putContent(function(){response.extractScripts().map(function(script){return eval(script.replace("<!--","").replace("// -->",""));}.bind(window));});}.bind(this),onException:function(instance,exception){Modalbox.hide();throw('Modalbox Loading Error: '+exception);}});}else if(typeof this.content=='object'){this._insertContent(this.content);this._putContent();}else{Modalbox.hide();throw('Modalbox Parameters Error: Please specify correct URL or HTML element (plain HTML or object)');}}},_insertContent:function(content){$(this.MBcontent).hide().update("");if(typeof content=='string'){setTimeout(function(){this.MBcontent.update(content);}.bind(this),1);}else if(typeof content=='object'){var _htmlObj=content.cloneNode(true);if(content.id)content.id="MB_"+content.id;$(content).select('*[id]').each(function(el){el.id="MB_"+el.id;});this.MBcontent.appendChild(_htmlObj);this.MBcontent.down().show();if(Prototype.Browser.IE)
$$("#MB_content select").invoke('setStyle',{'visibility':''});}},_putContent:function(callback){if(this.options.height==this._options.height){setTimeout(function(){Modalbox.resize(0,$(this.MBcontent).getHeight()-$(this.MBwindow).getHeight()+$(this.MBheader).getHeight(),{afterResize:function(){this.MBcontent.show().makePositioned();this.focusableElements=this._findFocusableElements();this._setFocus();setTimeout(function(){if(callback!=undefined)
callback();this.event("afterLoad");}.bind(this),1);}.bind(this)});}.bind(this),1);}else{this._setWidth();this.MBcontent.setStyle({overflow:'auto',height:$(this.MBwindow).getHeight()-$(this.MBheader).getHeight()-13+'px'});this.MBcontent.show();this.focusableElements=this._findFocusableElements();this._setFocus();setTimeout(function(){if(callback!=undefined)
callback();this.event("afterLoad");}.bind(this),1);}},activate:function(options){this.setOptions(options);this.active=true;$(this.MBclose).observe("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).observe("click",this.hideObserver);$(this.MBclose).show();if(this.options.transitions&&this.options.inactiveFade)
new Effect.Appear(this.MBwindow,{duration:this.options.slideUpDuration});},deactivate:function(options){this.setOptions(options);this.active=false;$(this.MBclose).stopObserving("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).stopObserving("click",this.hideObserver);$(this.MBclose).hide();if(this.options.transitions&&this.options.inactiveFade)
new Effect.Fade(this.MBwindow,{duration:this.options.slideUpDuration,to:.75});},_initObservers:function(){$(this.MBclose).observe("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).observe("click",this.hideObserver);if(Prototype.Browser.IE)
Event.observe(document,"keydown",this.kbdObserver);else
Event.observe(document,"keypress",this.kbdObserver);},_removeObservers:function(){$(this.MBclose).stopObserving("click",this.hideObserver);if(this.options.overlayClose)
$(this.MBoverlay).stopObserving("click",this.hideObserver);if(Prototype.Browser.IE)
Event.stopObserving(document,"keydown",this.kbdObserver);else
Event.stopObserving(document,"keypress",this.kbdObserver);},_loadAfterResize:function(){this._setWidth();this._setPosition();this.loadContent();},_setFocus:function(){if(this.focusableElements.length>0&&this.options.autoFocusing==true){var firstEl=this.focusableElements.find(function(el){return el.tabIndex==1;})||this.focusableElements.first();this.currFocused=this.focusableElements.toArray().indexOf(firstEl);firstEl.focus();}else if($(this.MBclose).visible())
$(this.MBclose).focus();},_findFocusableElements:function(){this.MBcontent.select('input:not([type~=hidden]), select, textarea, button, a[href]').invoke('addClassName','MB_focusable');return this.MBcontent.select('.MB_focusable');},_kbdHandler:function(event){var node=event.element();switch(event.keyCode){case Event.KEY_TAB:event.stop();if(node!=this.focusableElements[this.currFocused])
this.currFocused=this.focusableElements.toArray().indexOf(node);if(!event.shiftKey){if(this.currFocused==this.focusableElements.length-1){this.focusableElements.first().focus();this.currFocused=0;}else{this.currFocused++;this.focusableElements[this.currFocused].focus();}}else{if(this.currFocused==0){this.focusableElements.last().focus();this.currFocused=this.focusableElements.length-1;}else{this.currFocused--;this.focusableElements[this.currFocused].focus();}}
break;case Event.KEY_ESC:if(this.active)this._hide(event);break;case 32:this._preventScroll(event);break;case 0:if(event.which==32)this._preventScroll(event);break;case Event.KEY_UP:case Event.KEY_DOWN:case Event.KEY_PAGEDOWN:case Event.KEY_PAGEUP:case Event.KEY_HOME:case Event.KEY_END:if(Prototype.Browser.WebKit&&!["textarea","select"].include(node.tagName.toLowerCase()))
event.stop();else if((node.tagName.toLowerCase()=="input"&&["submit","button"].include(node.type))||(node.tagName.toLowerCase()=="a"))
event.stop();break;}},_preventScroll:function(event){if(!["input","textarea","select","button"].include(event.element().tagName.toLowerCase()))
event.stop();},_deinit:function()
{this._removeObservers();Event.stopObserving(window,"resize",this._setWidthAndPosition);if(this.options.transitions){Effect.toggle(this.MBoverlay,'appear',{duration:this.options.overlayDuration,afterFinish:this._removeElements.bind(this)});}else{this.MBoverlay.hide();this._removeElements();}
$(this.MBcontent).setStyle({overflow:'',height:''});},_removeElements:function(){$(this.MBoverlay).remove();$(this.MBwindow).remove();if(Prototype.Browser.IE&&!navigator.appVersion.match(/\b7.0\b/)){this._prepareIE("","");window.scrollTo(this.initScrollX,this.initScrollY);}
if(typeof this.content=='object'){if(this.content.id&&this.content.id.match(/MB_/)){this.content.id=this.content.id.replace(/MB_/,"");}
this.content.select('*[id]').each(function(el){el.id=el.id.replace(/MB_/,"");});}
this.initialized=false;this.event("afterHide");this.setOptions(this._options);},_setWidth:function(){$(this.MBwindow).setStyle({width:this.options.width+"px",height:this.options.height+"px"});},_setPosition:function(){$(this.MBwindow).setStyle({left:Math.round((Element.getWidth(document.body)-Element.getWidth(this.MBwindow))/2)+"px"});},_setWidthAndPosition:function(){$(this.MBwindow).setStyle({width:this.options.width+"px"});this._setPosition();},_getScrollTop:function(){var theTop;if(document.documentElement&&document.documentElement.scrollTop)
theTop=document.documentElement.scrollTop;else if(document.body)
theTop=document.body.scrollTop;return theTop;},_prepareIE:function(height,overflow){$$('html, body').invoke('setStyle',{width:height,height:height,overflow:overflow});$$("select").invoke('setStyle',{'visibility':overflow});},event:function(eventName){if(this.options[eventName]){var returnValue=this.options[eventName]();this.options[eventName]=null;if(returnValue!=undefined)
return returnValue;else
return true;}
return true;}};Object.extend(Modalbox,Modalbox.Methods);if(Modalbox.overrideAlert)window.alert=Modalbox.alert;Effect.ScaleBy=Class.create();Object.extend(Object.extend(Effect.ScaleBy.prototype,Effect.Base.prototype),{initialize:function(element,byWidth,byHeight,options){this.element=$(element)
var options=Object.extend({scaleFromTop:true,scaleMode:'box',scaleByWidth:byWidth,scaleByHeight:byHeight},arguments[3]||{});this.start(options);},setup:function(){this.elementPositioning=this.element.getStyle('position');this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;this.dims=null;if(this.options.scaleMode=='box')
this.dims=[this.element.offsetHeight,this.element.offsetWidth];if(/^content/.test(this.options.scaleMode))
this.dims=[this.element.scrollHeight,this.element.scrollWidth];if(!this.dims)
this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth];this.deltaY=this.options.scaleByHeight;this.deltaX=this.options.scaleByWidth;},update:function(position){var currentHeight=this.dims[0]+(this.deltaY*position);var currentWidth=this.dims[1]+(this.deltaX*position);currentHeight=(currentHeight>0)?currentHeight:0;currentWidth=(currentWidth>0)?currentWidth:0;this.setDimensions(currentHeight,currentWidth);},setDimensions:function(height,width){var d={};d.width=width+'px';d.height=height+'px';var topd=Math.round((height-this.dims[0])/2);var leftd=Math.round((width-this.dims[1])/2);if(this.elementPositioning=='absolute'||this.elementPositioning=='fixed'){if(!this.options.scaleFromTop)d.top=this.originalTop-topd+'px';d.left=this.originalLeft-leftd+'px';}else{if(!this.options.scaleFromTop)d.top=-topd+'px';d.left=-leftd+'px';}
this.element.setStyle(d);}});if(typeof(bsn)=="undefined")
_b=bsn={};if(typeof(_b.Autosuggest)=="undefined")
_b.Autosuggest={};else
alert("Autosuggest is already set!");_b.AutoSuggest=function(id,param)
{if(!document.getElementById)
return 0;this.fld=_b.DOM.gE(id);if(!this.fld)
return 0;this.sInp="";this.nInpC=0;this.aSug=[];this.iHigh=0;this.oP=param?param:{};var k,def={minchars:1,meth:"get",varname:"input",className:"autosuggest",timeout:2500,delay:500,offsety:-5,shownoresults:true,noresults:"No results!",maxheight:250,cache:true,maxentries:25};for(k in def)
{if(typeof(this.oP[k])!=typeof(def[k]))
this.oP[k]=def[k];}
var p=this;this.fld.onkeypress=function(ev){return p.onKeyPress(ev);};this.fld.onkeyup=function(ev){return p.onKeyUp(ev);};this.fld.setAttribute("autocomplete","off");};_b.AutoSuggest.prototype.onKeyPress=function(ev)
{var key=(window.event)?window.event.keyCode:ev.keyCode;var event=(window.event)?window.event:ev;event=Event.extend(event);var RETURN=13;var TAB=9;var ESC=27;var bubble=1;switch(key)
{case RETURN:this.setHighlightedValue();bubble=0;event.stop();break;case ESC:this.clearSuggestions();break;}
return bubble;};_b.AutoSuggest.prototype.onKeyUp=function(ev)
{var key=(window.event)?window.event.keyCode:ev.keyCode;var ARRUP=38;var ARRDN=40;var bubble=1;switch(key)
{case ARRUP:this.changeHighlight(key);bubble=0;break;case ARRDN:this.changeHighlight(key);bubble=0;break;default:this.getSuggestions(this.fld.value);}
return bubble;};_b.AutoSuggest.prototype.getSuggestions=function(val)
{if(val==this.sInp)
return 0;_b.DOM.remE(this.idAs);this.sInp=val;if(val.length<this.oP.minchars)
{this.aSug=[];this.nInpC=val.length;return 0;}
var ol=this.nInpC;this.nInpC=val.length?val.length:0;var l=this.aSug.length;if(this.nInpC>ol&&l&&l<this.oP.maxentries&&this.oP.cache)
{var arr=[];for(var i=0;i<l;i++)
{if(this.aSug[i].value.substr(0,val.length).toLowerCase()==val.toLowerCase())
arr.push(this.aSug[i]);}
this.aSug=arr;this.createList(this.aSug);return false;}
else
{var pointer=this;var input=this.sInp;clearTimeout(this.ajID);this.ajID=setTimeout(function(){pointer.doAjaxRequest(input)},this.oP.delay);}
return false;};_b.AutoSuggest.prototype.doAjaxRequest=function(input)
{if(input!=this.fld.value)
return false;var pointer=this;if(typeof(this.oP.script)=="function")
var url=this.oP.script(encodeURIComponent(this.sInp));else
var url=this.oP.script+this.oP.varname+"="+encodeURIComponent(this.sInp);if(!url)
return false;var meth=this.oP.meth;var input=this.sInp;var onSuccessFunc=function(req){pointer.setSuggestions(req,input)};var onErrorFunc=function(status){alert("AJAX error: "+status);};var myAjax=new _b.Ajax();myAjax.makeRequest(url,meth,onSuccessFunc,onErrorFunc);};_b.AutoSuggest.prototype.setSuggestions=function(req,input)
{if(input!=this.fld.value)
return false;this.aSug=[];if(this.oP.json)
{var jsondata=eval('('+req.responseText+')');for(var i=0;i<jsondata.results.length;i++)
{this.aSug.push({'id':jsondata.results[i].id,'value':jsondata.results[i].value,'info':jsondata.results[i].info});}}
else
{var xml=req.responseXML;var results=xml.getElementsByTagName('results')[0].childNodes;for(var i=0;i<results.length;i++)
{if(results[i].hasChildNodes())
this.aSug.push({'id':results[i].getAttribute('id'),'value':results[i].childNodes[0].nodeValue,'info':results[i].getAttribute('info')});}}
this.idAs="as_"+this.fld.id;this.createList(this.aSug);};_b.AutoSuggest.prototype.createList=function(arr)
{var pointer=this;_b.DOM.remE(this.idAs);this.killTimeout();if(arr.length==0&&!this.oP.shownoresults)
return false;var div=_b.DOM.cE("div",{id:this.idAs,className:this.oP.className});var hcorner=_b.DOM.cE("div",{className:"as_corner"});var hbar=_b.DOM.cE("div",{className:"as_bar"});var header=_b.DOM.cE("div",{className:"as_header"});header.appendChild(hcorner);header.appendChild(hbar);div.appendChild(header);var ul=_b.DOM.cE("ul",{id:"as_ul"});for(var i=0;i<arr.length;i++)
{var val=arr[i].value;var st=val.toLowerCase().indexOf(this.sInp.toLowerCase());var output=val.substring(0,st)+"<em>"+val.substring(st,st+this.sInp.length)+"</em>"+val.substring(st+this.sInp.length);var span=_b.DOM.cE("span",{},output,true);if(arr[i].info!="")
{var br=_b.DOM.cE("br",{});span.appendChild(br);var small=_b.DOM.cE("small",{},arr[i].info);span.appendChild(small);}
var a=_b.DOM.cE("a",{href:"#"});var tl=_b.DOM.cE("span",{className:"tl"}," ");var tr=_b.DOM.cE("span",{className:"tr"}," ");a.appendChild(tl);a.appendChild(tr);a.appendChild(span);a.name=i+1;a.onclick=function(){pointer.setHighlightedValue();return false;};a.onmouseover=function(){pointer.setHighlight(this.name);};var li=_b.DOM.cE("li",{},a);ul.appendChild(li);}
if(arr.length==0&&this.oP.shownoresults)
{if(typeof(venue_not_listed)=="function")venue_not_listed();var li=_b.DOM.cE("li",{className:"as_warning"},this.oP.noresults);ul.appendChild(li);}
div.appendChild(ul);var fcorner=_b.DOM.cE("div",{className:"as_corner"});var fbar=_b.DOM.cE("div",{className:"as_bar"});var footer=_b.DOM.cE("div",{className:"as_footer"});footer.appendChild(fcorner);footer.appendChild(fbar);div.appendChild(footer);var pos=_b.DOM.getPos(this.fld);div.style.left=pos.x+"px";div.style.top=(($("MB_window")?document.viewport.getScrollOffsets().top:0)+pos.y+this.fld.offsetHeight+this.oP.offsety)+"px";div.style.width=this.fld.offsetWidth+"px";div.onmouseover=function(){pointer.killTimeout()};div.onmouseout=function(){pointer.resetTimeout()};document.getElementsByTagName("body")[0].appendChild(div);this.iHigh=0;var pointer=this;this.toID=setTimeout(function(){pointer.clearSuggestions()},this.oP.timeout);};_b.AutoSuggest.prototype.changeHighlight=function(key)
{var list=_b.DOM.gE("as_ul");if(!list)
return false;var n;if(key==40)
n=this.iHigh+1;else if(key==38)
n=this.iHigh-1;if(n>list.childNodes.length)
n=list.childNodes.length;if(n<1)
n=1;this.setHighlight(n);};_b.AutoSuggest.prototype.setHighlight=function(n)
{var list=_b.DOM.gE("as_ul");if(!list)
return false;if(this.iHigh>0)
this.clearHighlight();this.iHigh=Number(n);list.childNodes[this.iHigh-1].className="as_highlight";this.killTimeout();};_b.AutoSuggest.prototype.clearHighlight=function()
{var list=_b.DOM.gE("as_ul");if(!list)
return false;if(this.iHigh>0)
{list.childNodes[this.iHigh-1].className="";this.iHigh=0;}};_b.AutoSuggest.prototype.setHighlightedValue=function()
{if(this.iHigh)
{this.sInp=this.fld.value=this.aSug[this.iHigh-1].value;this.fld.focus();if(this.fld.selectionStart)
this.fld.setSelectionRange(this.sInp.length,this.sInp.length);this.clearSuggestions();if(typeof(this.oP.callback)=="function")
this.oP.callback(this.aSug[this.iHigh-1]);}};_b.AutoSuggest.prototype.killTimeout=function()
{clearTimeout(this.toID);};_b.AutoSuggest.prototype.resetTimeout=function()
{clearTimeout(this.toID);var pointer=this;this.toID=setTimeout(function(){pointer.clearSuggestions()},1000);};_b.AutoSuggest.prototype.clearSuggestions=function()
{this.killTimeout();var ele=_b.DOM.gE(this.idAs);var pointer=this;if(ele)
{var fade=new _b.Fader(ele,1,0,250,function(){_b.DOM.remE(pointer.idAs)});}};if(typeof(_b.Ajax)=="undefined")
_b.Ajax={};_b.Ajax=function()
{this.req={};this.isIE=false;};_b.Ajax.prototype.makeRequest=function(url,meth,onComp,onErr)
{if(meth!="POST")
meth="GET";this.onComplete=onComp;this.onError=onErr;var pointer=this;if(window.XMLHttpRequest)
{this.req=new XMLHttpRequest();this.req.onreadystatechange=function(){pointer.processReqChange()};this.req.open("GET",url,true);this.req.send(null);}
else if(window.ActiveXObject)
{this.req=new ActiveXObject("Microsoft.XMLHTTP");if(this.req)
{this.req.onreadystatechange=function(){pointer.processReqChange()};this.req.open(meth,url,true);this.req.send();}}};_b.Ajax.prototype.processReqChange=function()
{if(this.req.readyState==4){if(this.req.status==200)
{this.onComplete(this.req);}else{this.onError(this.req.status);}}};if(typeof(_b.DOM)=="undefined")
_b.DOM={};_b.DOM.cE=function(type,attr,cont,html)
{var ne=document.createElement(type);if(!ne)
return 0;for(var a in attr)
ne[a]=attr[a];var t=typeof(cont);if(t=="string"&&!html)
ne.appendChild(document.createTextNode(cont));else if(t=="string"&&html)
ne.innerHTML=cont;else if(t=="object")
ne.appendChild(cont);return ne;};_b.DOM.gE=function(e)
{var t=typeof(e);if(t=="undefined")
return 0;else if(t=="string")
{var re=document.getElementById(e);if(!re)
return 0;else if(typeof(re.appendChild)!="undefined")
return re;else
return 0;}
else if(typeof(e.appendChild)!="undefined")
return e;else
return 0;};_b.DOM.remE=function(ele)
{var e=this.gE(ele);if(!e)
return 0;else if(e.parentNode.removeChild(e))
return true;else
return 0;};_b.DOM.getPos=function(e)
{var e=this.gE(e);var obj=e;var curleft=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curleft+=obj.offsetLeft;obj=obj.offsetParent;}}
else if(obj.x)
curleft+=obj.x;var obj=e;var curtop=0;if(obj.offsetParent)
{while(obj.offsetParent)
{curtop+=obj.offsetTop;obj=obj.offsetParent;}}
else if(obj.y)
curtop+=obj.y;return{x:curleft,y:curtop};};if(typeof(_b.Fader)=="undefined")
_b.Fader={};_b.Fader=function(ele,from,to,fadetime,callback)
{if(!ele)
return 0;this.e=ele;this.from=from;this.to=to;this.cb=callback;this.nDur=fadetime;this.nInt=50;this.nTime=0;var p=this;this.nID=setInterval(function(){p._fade()},this.nInt);};_b.Fader.prototype._fade=function()
{this.nTime+=this.nInt;var ieop=Math.round(this._tween(this.nTime,this.from,this.to,this.nDur)*100);var op=ieop/100;if(this.e.filters)
{try
{this.e.filters.item("DXImageTransform.Microsoft.Alpha").opacity=ieop;}catch(e){this.e.style.filter='progid:DXImageTransform.Microsoft.Alpha(opacity='+ieop+')';}}
else
{this.e.style.opacity=op;}
if(this.nTime==this.nDur)
{clearInterval(this.nID);if(this.cb!=undefined)
this.cb();}};_b.Fader.prototype._tween=function(t,b,c,d)
{return b+((c-b)*(t/d));};var cligs=function(){return{auto_select:function(el){if(el.tagName==="TEXTAREA"||(el.tagName==="INPUT"&&el.type==="text")){el.activate();return;}
if(window.getSelection){var sel=window.getSelection();var range=document.createRange();range.selectNodeContents(el);sel.removeAllRanges();sel.addRange(range);}else if(document.selection){document.selection.empty();var range=document.body.createTextRange();range.moveToElementText(el);range.select();}},helpify_forms:function(){$$('.help_message','#venue_fields').invoke('hide');$$('.helpful').each(function(el){el.observe('focus',function(){var div=el.next('div')||el.up().next('div');Effect.Appear(div);});el.observe('blur',function(){var div=el.next('div')||el.up().next('div');Effect.Fade(div);});});},clear_venue_fields:function(){$("venue_fields").hide();$("venue_not_listed_link").show();fields_to_clear=$('content').select('input[name*=event\[venue_attributes\]]');fields_to_clear.invoke('clear');},show_venue_fields:function(){$("venue_fields").show();fields_to_clear=$('content').select('input[name*=event\[venue_attributes\]]');fields_to_clear.shift();fields_to_clear.invoke('clear');$("event_venue_attributes_title").removeClassName('in_list');$("venue_not_listed_link").hide();},mark_message_as_read:function(message_id,read,token){if(read){new Ajax.Request('/messages/'+message_id+'/read',{method:'put',parameters:{authenticity_token:token}});$('message_'+message_id).down('li.message_subject a').removeClassName('unread').addClassName('read');}}};}
();var SuperResizingTextArea=Class.create();SuperResizingTextArea.prototype={initialize:function(field){this.hard_lines=(field.value.blank()?2:4);this.resizeNeeded=this.resizeNeeded.bindAsEventListener(this);Event.observe(field,"click",this.resizeNeeded);Event.observe(field,"keyup",this.resizeNeeded);this.resize(field);},resizeNeeded:function(event){var t=Event.element(event);this.resize(t);},resize:function(t){var cols=t.readAttribute("cols");var strtocount=t.value;var hard_lines=(t.value.blank()?2:this.hard_lines);var last=0;while(true){last=strtocount.indexOf("\n",last+1);hard_lines++;if(last==-1)break;}
var soft_lines=Math.round(strtocount.length/(cols-1));var hard=eval("hard_lines  "+unescape("%3e")+" soft_lines;");if(hard)soft_lines=hard_lines;t.setAttribute("rows",soft_lines);}}
var ResizingTextArea=Class.create();ResizingTextArea.prototype={defaultRows:1,initialize:function(field){this.defaultRows=Math.max(field.rows,1);this.resizeNeeded=this.resizeNeeded.bindAsEventListener(this);Event.observe(field,"click",this.resizeNeeded);Event.observe(field,"keyup",this.resizeNeeded);},resizeNeeded:function(event){var t=Event.element(event);var lines=t.value.split('\n');var newRows=lines.length+1;var oldRows=t.rows;for(var i=0;i<lines.length;i++){var line=lines[i];if(line.length>=t.cols)
newRows+=Math.floor(line.length/t.cols);}
if(newRows>t.rows)
t.rows=newRows;if(newRows<t.rows)
t.rows=Math.max(this.defaultRows,newRows);}}
var WidgetBehavior=Behavior.create({onclick:function(e){if(!$(this.element).hasClassName('selected'))
{var el=$(this.element);$$('#widget_tabs .selected').invoke('removeClassName','selected');el.up('li').addClassName('selected');$$('#widget > div').invoke('hide');$(el.getAttribute('rel')).show();if(el.getAttribute('rel')=='google_widget'){el.fire('gmaps:show');}
e.stop();}}});var SearchFieldBahavior=Behavior.create({onfocus:function(e){var el=$(this.element);if(el.value==el.title){el.value="";}},onblur:function(e){var el=$(this.element);if(el.value.empty()){el.value=el.title;}}});var ExternalLinkBehavior=Behavior.create({onclick:function(e){window.open($(this.element).href);e.stop();}});var CharCountBehavior=Behavior.create({onkeyup:function(e){if(this.element.value.length>=300){this.element.value=this.element.value.slice(0,300);}
$('chars_left').update(300-this.element.value.length);if(this.element.value.length>200){$('chars_left').setStyle({color:'red'});}else if(this.element.value.length>100){$('chars_left').setStyle({color:'orange'});}else{$('chars_left').setStyle({color:'#666666'});}}});Event.addBehavior({'a.external_link':ExternalLinkBehavior,'p.venue_url a':ExternalLinkBehavior,'.js':function(){this.setStyle({visibility:'visible'});},"textarea":function(){new SuperResizingTextArea(this)},"div.invite_link:click":function(){cligs.auto_select(this)},"textarea#user_user_info_attributes_description":CharCountBehavior,'#event-search':SearchFieldBahavior,'#widget_tabs .tab > a':WidgetBehavior});Event.addBehavior({"div#google_widget":function(){var latlng=new google.maps.LatLng(this.readAttribute("data-cligs-lat"),this.readAttribute("data-cligs-lng"));var myOptions={zoom:15,scrollwheel:false,center:latlng,mapTypeId:google.maps.MapTypeId.ROADMAP};var map=new google.maps.Map(this,myOptions);new google.maps.Marker({map:map,clickable:false,position:latlng,icon:"/images/icons/marker_parties.png"});}});if(typeof Prototype=='undefined')alert("CalendarDateSelect Error: Prototype could not be found. Please make sure that your application's layout includes prototype.js (.g. <%= javascript_include_tag :defaults %>) *before* it includes calendar_date_select.js (.g. <%= calendar_date_select_includes %>).");if(Prototype.Version<"1.6")alert("Prototype 1.6.0 is required. If using earlier version of prototype, please use calendar_date_select version 1.8.3");Element.addMethods({purgeChildren:function(element){$A(element.childNodes).each(function(e){$(e).remove();});},build:function(element,type,options,style){var newElement=Element.buildAndAppend(type,options,style);element.appendChild(newElement);return newElement;}});Element.buildAndAppend=function(type,options,style)
{var e=$(document.createElement(type));$H(options).each(function(pair){e[pair.key]=pair.value});if(style)e.setStyle(style);return e;};nil=null;Date.one_day=24*60*60*1000;Date.weekdays=$w("S M T W T F S");Date.first_day_of_week=0;Date.months=$w("January February March April May June July August September October November December");Date.padded2=function(hour){var padded2=parseInt(hour,10);if(hour<10)padded2="0"+padded2;return padded2;}
Date.prototype.getPaddedMinutes=function(){return Date.padded2(this.getMinutes());}
Date.prototype.getAMPMHour=function(){var hour=this.getHours();return(hour==0)?12:(hour>12?hour-12:hour)}
Date.prototype.getAMPM=function(){return(this.getHours()<12)?"AM":"PM";}
Date.prototype.stripTime=function(){return new Date(this.getFullYear(),this.getMonth(),this.getDate());};Date.prototype.daysDistance=function(compare_date){return Math.round((compare_date-this)/Date.one_day);};Date.prototype.toFormattedString=function(include_time){var hour,str;str=Date.months[this.getMonth()]+" "+this.getDate()+", "+this.getFullYear();if(include_time){hour=this.getHours();str+=" "+this.getAMPMHour()+":"+this.getPaddedMinutes()+" "+this.getAMPM()}
return str;}
Date.parseFormattedString=function(string){return new Date(string);}
Math.floor_to_interval=function(n,i){return Math.floor(n/i)*i;}
window.f_height=function(){return([window.innerHeight?window.innerHeight:null,document.documentElement?document.documentElement.clientHeight:null,document.body?document.body.clientHeight:null].select(function(x){return x>0}).first()||0);}
window.f_scrollTop=function(){return([window.pageYOffset?window.pageYOffset:null,document.documentElement?document.documentElement.scrollTop:null,document.body?document.body.scrollTop:null].select(function(x){return x>0}).first()||0);}
_translations={"OK":"OK","Now":"Now","Today":"Today","Clear":"Clear"}
SelectBox=Class.create();SelectBox.prototype={initialize:function(parent_element,values,html_options,style_options){this.element=$(parent_element).build("select",html_options,style_options);this.populate(values);},populate:function(values){this.element.purgeChildren();var that=this;$A(values).each(function(pair){if(typeof(pair)!="object"){pair=[pair,pair]};that.element.build("option",{value:pair[1],innerHTML:pair[0]})});},setValue:function(value){var e=this.element;var matched=false;$R(0,e.options.length-1).each(function(i){if(e.options[i].value==value.toString()){e.selectedIndex=i;matched=true;};});return matched;},getValue:function(){return $F(this.element)}}
CalendarDateSelect=Class.create();CalendarDateSelect.prototype={initialize:function(target_element,options){this.target_element=$(target_element);if(!this.target_element){alert("Target element "+target_element+" not found!");return false;}
if(this.target_element.tagName!="INPUT")this.target_element=this.target_element.down("INPUT")
this.target_element.calendar_date_select=this;this.last_click_at=0;this.options=$H({embedded:false,popup:nil,time:false,buttons:true,clear_button:false,year_range:10,close_on_click:nil,minute_interval:5,popup_by:this.target_element,month_year:"dropdowns",onchange:this.target_element.onchange,special_dates:[],special_dates_renderer:nil,before_refresh_calendar_grid:nil,valid_date_check:nil}).merge(options||{});this.use_time=this.options.get("time");this.parseDate();this.callback("before_show")
this.initCalendarDiv();if(!this.options.get("embedded")){this.positionCalendarDiv()
Event.observe(document,"mousedown",this.closeIfClickedOut_handler=this.closeIfClickedOut.bindAsEventListener(this));Event.observe(document,"keypress",this.keyPress_handler=this.keyPress.bindAsEventListener(this));}
this.callback("after_show")},positionCalendarDiv:function(){var above=false;var c_pos=this.calendar_div.cumulativeOffset(),c_left=c_pos[0],c_top=c_pos[1],c_dim=this.calendar_div.getDimensions(),c_height=c_dim.height,c_width=c_dim.width;var w_top=window.f_scrollTop(),w_height=window.f_height();var e_dim=$(this.options.get("popup_by")).cumulativeOffset(),e_top=e_dim[1],e_left=e_dim[0],e_height=$(this.options.get("popup_by")).getDimensions().height,e_bottom=e_top+e_height;if(((e_bottom+c_height)>(w_top+w_height))&&(e_bottom-c_height>w_top))above=true;var left_px=e_left.toString()+"px",top_px=(above?(e_top-c_height):(e_top+e_height)).toString()+"px";this.calendar_div.style.left=left_px;this.calendar_div.style.top=top_px;this.calendar_div.setStyle({visibility:""});if(navigator.appName=="Microsoft Internet Explorer")this.iframe=$(document.body).build("iframe",{src:"javascript:false",className:"ie6_blocker"},{left:left_px,top:top_px,height:c_height.toString()+"px",width:c_width.toString()+"px",border:"0px"})},initCalendarDiv:function(){if(this.options.get("embedded")){var parent=this.target_element.parentNode;var style={}}else{var parent=document.body
var style={position:"absolute",visibility:"hidden",left:0,top:0}}
this.calendar_div=$(parent).build('div',{className:"calendar_date_select"},style);var that=this;$w("top header body buttons footer bottom").each(function(name){eval("var "+name+"_div = that."+name+"_div = that.calendar_div.build('div', { className: 'cds_"+name+"' }, { clear: 'left'} ); ");});this.initHeaderDiv();this.initButtonsDiv();this.initCalendarGrid();this.updateFooter("&#160;");this.refresh();this.setUseTime(this.use_time);},initHeaderDiv:function(){var header_div=this.header_div;this.close_button=header_div.build("a",{innerHTML:"x",href:"#",onclick:function(){this.close();return false;}.bindAsEventListener(this),className:"close"});this.next_month_button=header_div.build("a",{innerHTML:"&gt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()+1);return false;}.bindAsEventListener(this),className:"next"});this.prev_month_button=header_div.build("a",{innerHTML:"&lt;",href:"#",onclick:function(){this.navMonth(this.date.getMonth()-1);return false;}.bindAsEventListener(this),className:"prev"});if(this.options.get("month_year")=="dropdowns"){this.month_select=new SelectBox(header_div,$R(0,11).map(function(m){return[Date.months[m],m]}),{className:"month",onchange:function(){this.navMonth(this.month_select.getValue())}.bindAsEventListener(this)});this.year_select=new SelectBox(header_div,[],{className:"year",onchange:function(){this.navYear(this.year_select.getValue())}.bindAsEventListener(this)});this.populateYearRange();}else{this.month_year_label=header_div.build("span")}},initCalendarGrid:function(){var body_div=this.body_div;this.calendar_day_grid=[];var days_table=body_div.build("table",{cellPadding:"0px",cellSpacing:"0px",width:"100%"})
var weekdays_row=days_table.build("thead").build("tr");Date.weekdays.each(function(weekday){weekdays_row.build("th",{innerHTML:weekday});});var days_tbody=days_table.build("tbody")
var row_number=0,weekday;for(var cell_index=0;cell_index<42;cell_index++)
{weekday=(cell_index+Date.first_day_of_week)%7;if(cell_index%7==0)days_row=days_tbody.build("tr",{className:'row_'+row_number++});(this.calendar_day_grid[cell_index]=days_row.build("td",{calendar_date_select:this,onmouseover:function(){this.calendar_date_select.dayHover(this);},onmouseout:function(){this.calendar_date_select.dayHoverOut(this)},onclick:function(){this.calendar_date_select.updateSelectedDate(this,true);},className:(weekday==0)||(weekday==6)?" weekend":""},{cursor:"pointer"})).build("div");this.calendar_day_grid[cell_index];}},initButtonsDiv:function()
{var buttons_div=this.buttons_div;if(this.options.get("time"))
{var blank_time=$A(this.options.get("time")=="mixed"?[[" - ",""]]:[]);buttons_div.build("span",{innerHTML:"@",className:"at_sign"});var t=new Date();this.hour_select=new SelectBox(buttons_div,blank_time.concat($R(0,23).map(function(x){t.setHours(x);return $A([t.getAMPMHour()+" "+t.getAMPM(),x])})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({hour:this.value});},className:"hour"});buttons_div.build("span",{innerHTML:":",className:"seperator"});var that=this;this.minute_select=new SelectBox(buttons_div,blank_time.concat($R(0,59).select(function(x){return(x%that.options.get('minute_interval')==0)}).map(function(x){return $A([Date.padded2(x),x]);})),{calendar_date_select:this,onchange:function(){this.calendar_date_select.updateSelectedDate({minute:this.value})},className:"minute"});}else if(!this.options.get("buttons"))buttons_div.remove();if(this.options.get("buttons")){buttons_div.build("span",{innerHTML:"&#160;"});if(this.options.get("time")=="mixed"||!this.options.get("time"))b=buttons_div.build("a",{innerHTML:_translations["Today"],href:"#",onclick:function(){this.today(false);return false;}.bindAsEventListener(this)});if(this.options.get("time")=="mixed")buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
if(this.options.get("time"))b=buttons_div.build("a",{innerHTML:_translations["Now"],href:"#",onclick:function(){this.today(true);return false}.bindAsEventListener(this)});if(!this.options.get("embedded")&&!this.closeOnClick())
{buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
buttons_div.build("a",{innerHTML:_translations["OK"],href:"#",onclick:function(){this.close();return false;}.bindAsEventListener(this)});}
if(this.options.get('clear_button')){buttons_div.build("span",{innerHTML:"&#160;|&#160;",className:"button_seperator"})
buttons_div.build("a",{innerHTML:_translations["Clear"],href:"#",onclick:function(){this.clearDate();if(!this.options.get("embedded"))this.close();return false;}.bindAsEventListener(this)});}}},refresh:function()
{this.refreshMonthYear();this.refreshCalendarGrid();this.setSelectedClass();this.updateFooter();},refreshCalendarGrid:function(){if((before_callback=this.options.get("before_refresh_calendar_grid"))&&typeof(before_callback)=='function'){this.options.get("before_refresh_calendar_grid")();}else{this.calendar_div.select('.special_event').invoke('removeClassName','special_event')}
this.beginning_date=new Date(this.date).stripTime();this.beginning_date.setDate(1);this.beginning_date.setHours(12);var pre_days=this.beginning_date.getDay()
if(pre_days<3)pre_days+=7;this.beginning_date.setDate(1-pre_days+Date.first_day_of_week);var iterator=new Date(this.beginning_date);var today=new Date().stripTime();var this_month=this.date.getMonth();vdc=this.options.get("valid_date_check");for(var cell_index=0;cell_index<42;cell_index++)
{day=iterator.getDate();month=iterator.getMonth();year=iterator.getFullYear();cell=this.calendar_day_grid[cell_index];Element.remove(cell.childNodes[0]);div=cell.build("div",{innerHTML:day});if(month!=this_month)div.className="other";if(this.options.get("special_dates").include(day+'.'+(month+1)+'.'+year)){if((renderer=this.options.get("special_dates_renderer"))&&typeof(renderer)=='function'){this.options.get("special_dates_renderer")(cell);}else{cell.addClassName('special_event');}}
cell.day=day;cell.month=month;cell.year=iterator.getFullYear();if(vdc){if(vdc(iterator.stripTime()))cell.removeClassName("disabled");else cell.addClassName("disabled")};iterator.setDate(day+1);}
if(this.today_cell)this.today_cell.removeClassName("today");if($R(0,41).include(days_until=this.beginning_date.stripTime().daysDistance(today))){this.today_cell=this.calendar_day_grid[days_until];this.today_cell.addClassName("today");}},refreshMonthYear:function(){var m=this.date.getMonth();var y=this.date.getFullYear();if(this.options.get("month_year")=="dropdowns")
{this.month_select.setValue(m,false);var e=this.year_select.element;if(this.flexibleYearRange()&&(!(this.year_select.setValue(y,false))||e.selectedIndex<=1||e.selectedIndex>=e.options.length-2))this.populateYearRange();this.year_select.setValue(y);}else{this.month_year_label.update(Date.months[m]+" "+y.toString());}},populateYearRange:function(){this.year_select.populate(this.yearRange().toArray());},yearRange:function(){if(!this.flexibleYearRange())
return $R(this.options.get("year_range")[0],this.options.get("year_range")[1]);var y=this.date.getFullYear();return $R(y-this.options.get("year_range"),y+this.options.get("year_range"));},flexibleYearRange:function(){return(typeof(this.options.get("year_range"))=="number");},validYear:function(year){if(this.flexibleYearRange()){return true;}else{return this.yearRange().include(year);}},dayHover:function(element){var hover_date=new Date(this.selected_date);hover_date.setYear(element.year);hover_date.setMonth(element.month);hover_date.setDate(element.day);this.updateFooter(hover_date.toFormattedString(this.use_time));},dayHoverOut:function(element){this.updateFooter();},clearSelectedClass:function(){if(this.selected_cell)this.selected_cell.removeClassName("selected");},setSelectedClass:function(){if(!this.selection_made)return;this.clearSelectedClass()
if($R(0,42).include(days_until=this.beginning_date.stripTime().daysDistance(this.selected_date.stripTime()))){this.selected_cell=this.calendar_day_grid[days_until];this.selected_cell.addClassName("selected");}},reparse:function(){this.parseDate();this.refresh();},dateString:function(){return(this.selection_made)?this.selected_date.toFormattedString(this.use_time):"&#160;";},parseDate:function()
{var value=$F(this.target_element).strip()
this.selection_made=(value!="");this.date=value==""?NaN:Date.parseFormattedString(this.options.get("date")||value);if(isNaN(this.date))this.date=new Date();if(!this.validYear(this.date.getFullYear()))this.date.setYear((this.date.getFullYear()<this.yearRange().start)?this.yearRange().start:this.yearRange().end);this.selected_date=new Date(this.date);this.use_time=/[0-9]:[0-9]{2}/.exec(value)?true:false;this.date.setDate(1);},updateFooter:function(text){if(!text)text=this.dateString();this.footer_div.purgeChildren();this.footer_div.build("span",{innerHTML:text});},clearDate:function(){if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return false;var last_value=this.target_element.value;this.target_element.value="";this.clearSelectedClass();this.updateFooter('&#160;');if(last_value!=this.target_element.value)this.callback("onchange");},updateSelectedDate:function(partsOrElement,via_click){var parts=$H(partsOrElement);if((this.target_element.disabled||this.target_element.readOnly)&&this.options.get("popup")!="force")return false;if(parts.get("day")){var t_selected_date=this.selected_date,vdc=this.options.get("valid_date_check");for(var x=0;x<=3;x++)t_selected_date.setDate(parts.get("day"));t_selected_date.setYear(parts.get("year"));t_selected_date.setMonth(parts.get("month"));if(vdc&&!vdc(t_selected_date.stripTime())){return false;}
this.selected_date=t_selected_date;this.selection_made=true;}
if(!isNaN(parts.get("hour")))this.selected_date.setHours(parts.get("hour"));if(!isNaN(parts.get("minute")))this.selected_date.setMinutes(Math.floor_to_interval(parts.get("minute"),this.options.get("minute_interval")));if(parts.get("hour")===""||parts.get("minute")==="")
this.setUseTime(false);else if(!isNaN(parts.get("hour"))||!isNaN(parts.get("minute")))
this.setUseTime(true);this.updateFooter();this.setSelectedClass();if(this.selection_made)this.updateValue();if(this.closeOnClick()){this.close();}
if(via_click&&!this.options.get("embedded")){if((new Date()-this.last_click_at)<333)this.close();this.last_click_at=new Date();}},closeOnClick:function(){if(this.options.get("embedded"))return false;if(this.options.get("close_on_click")===nil)
return(this.options.get("time"))?false:true
else
return(this.options.get("close_on_click"))},navMonth:function(month){(target_date=new Date(this.date)).setMonth(month);return(this.navTo(target_date));},navYear:function(year){(target_date=new Date(this.date)).setYear(year);return(this.navTo(target_date));},navTo:function(date){if(!this.validYear(date.getFullYear()))return false;this.date=date;this.date.setDate(1);this.refresh();this.callback("after_navigate",this.date);return true;},setUseTime:function(turn_on){this.use_time=this.options.get("time")&&(this.options.get("time")=="mixed"?turn_on:true)
if(this.use_time&&this.selected_date){var minute=Math.floor_to_interval(this.selected_date.getMinutes(),this.options.get("minute_interval"));var hour=this.selected_date.getHours();this.hour_select.setValue(hour);this.minute_select.setValue(minute)}else if(this.options.get("time")=="mixed"){this.hour_select.setValue("");this.minute_select.setValue("");}},updateValue:function(){var last_value=this.target_element.value;this.target_element.value=this.dateString();if(last_value!=this.target_element.value)this.callback("onchange");},today:function(now){var d=new Date();this.date=new Date();var o=$H({day:d.getDate(),month:d.getMonth(),year:d.getFullYear(),hour:d.getHours(),minute:d.getMinutes()});if(!now)o=o.merge({hour:"",minute:""});this.updateSelectedDate(o,true);this.refresh();},close:function(){if(this.closed)return false;this.callback("before_close");this.target_element.calendar_date_select=nil;Event.stopObserving(document,"mousedown",this.closeIfClickedOut_handler);Event.stopObserving(document,"keypress",this.keyPress_handler);this.calendar_div.remove();this.closed=true;if(this.iframe)this.iframe.remove();if(this.target_element.type!="hidden"&&!this.target_element.disabled)this.target_element.focus();this.callback("after_close");},closeIfClickedOut:function(e){if(!$(Event.element(e)).descendantOf(this.calendar_div))this.close();},keyPress:function(e){if(e.keyCode==Event.KEY_ESC)this.close();},callback:function(name,param){if(this.options.get(name)){this.options.get(name).bind(this.target_element)(param);}}}