var BBrowser={isIeLt7:function(){if(navigator.appName.toLowerCase()=="microsoft internet explorer"){var version=navigator.appVersion;version=version.substring(version.indexOf("MSIE"));version=parseInt(version.substring(version.indexOf(" ")+1,version.indexOf(".")));return(version<7)}else{return false}},isIeLt8:function(){if(navigator.appName.toLowerCase()=="microsoft internet explorer"){var version=navigator.appVersion;version=version.substring(version.indexOf("MSIE"));version=parseInt(version.substring(version.indexOf(" ")+1,version.indexOf(".")));return(version<8)}else{return false}}};var BConsole={DEBUG_ACTIVATED:true,init:function(){try{this.FIREBUG_CONSOLE=console&&console.firebug;this.COMPANIONJS_CONSOLE=!this.FIREBUG_CONSOLE&&console&&console.provider=="Companion.JS";this.GENERIC_CONSOLE=!this.FIREBUG_CONSOLE&&!this.COMPANIONJS_CONSOLE&&console}catch(ERR){this.DEBUG_ACTIVATED=false}},log:function(_msg,_level){if(!this.DEBUG_ACTIVATED){return }switch(_level){case"log":case"info":case"error":case"warn":if(BConsole.FIREBUG_CONSOLE||BConsole.COMPANIONJS_CONSOLE||BConsole.GENERIC_CONSOLE){console[_level](_msg)}break;case"debug":case"assert":case"dirxml":case"time":case"timeEnd":if(BConsole.FIREBUG_CONSOLE||BConsole.COMPANIONJS_CONSOLE){console[_level](_msg)}else{if(BConsole.GENERIC_CONSOLE){console.log("["+_level+"] "+_msg)}}break;case"group":case"groupEnd":case"dir":case"trace":case"profile":case"profileEnd":case"count":if(BConsole.FIREBUG_CONSOLE){console[_level](_msg)}else{if(BConsole.COMPANIONJS_CONSOLE||BConsole.GENERIC_CONSOLE){console.log("["+_level+"] "+_msg)}}break;default:if(BConsole.FIREBUG_CONSOLE||BConsole.COMPANIONJS_CONSOLE||BConsole.GENERIC_CONSOLE){if(_level){console.log("["+_level+"] "+_msg)}else{console.log(_msg)}}}},trace:function(){BConsole.log(null,"trace")},profile:function(_msg){BConsole.log(_msg,"profile")},profileEnd:function(_msg){BConsole.log(_msg,"profileEnd")},count:function(_msg){BConsole.log(_msg,"count")},debug:function(_msg){BConsole.log(_msg,"debug")},warn:function(_msg){BConsole.log(_msg,"warn")},error:function(_msg){BConsole.log(_msg,"error")},info:function(_msg){BConsole.log(_msg,"info")},group:function(_msg){BConsole.log(_msg,"group")},groupEnd:function(_msg){BConsole.log(_msg,"groupEnd")},time:function(_msg){BConsole.log(_msg,"time")},timeEnd:function(_msg){BConsole.log(_msg,"timeEnd")},dir:function(_msg){BConsole.log(_msg,"dir")}};BConsole.init();function $console(_msg,_level){BConsole.log(_msg,_level)}var BRessources=new Class({RES:new Hash(),initialize:function(_url){try{var options={method:"post",url:_url,async:false,onSuccess:function(_text,_xml){this.__loadRes(_xml,"")}.bind(this),onFailure:function(msg){$console("An error occured while loading '"+_url+"' : "+msg,"error")}};var params={date:new Date().getTime()};var myRequest=(MooTools.version=="1.2dev")?new XHR(options):new Request(options);if(MooTools.version=="1.2dev"){myRequest.send(options.url,(params)?Object.toQueryString(params):null)}else{myRequest.send((params)?{data:params}:null)}}catch(TT){$error(TT)}},get:function(_key){var r=this.RES.get(_key);if(!r){return""}return r},__loadRes:function(_xmlNode,_currentPath){try{var nodtxt="";for(var i=0;i<_xmlNode.childNodes.length;i++){var child=_xmlNode.childNodes[i];if(child.nodeType==3){nodtxt+=child.nodeValue}else{if(child.nodeType==1){this.__loadRes(child,(_currentPath==null||_currentPath.length==0)?child.tagName:_currentPath+"."+child.tagName)}}}nodtxt=nodtxt.trim();if(nodtxt.length>0){this.__addRes(_currentPath,nodtxt)}}catch(ERR){$error(ERR)}},__addRes:function(_key,_val){this.RES.set(_key,_val)}});var BRessourcesManager={res:null,loadRessources:function(_url){try{BRessourcesManager.res=new BRessources(_url)}catch(ERR){$error("An error occured while loading ressources : "+ERR)}},get:function(_key){if(!BRessourcesManager.res){throw"no ressources loaded"}return BRessourcesManager.res.get(_key)}};function $res(_key){return BRessourcesManager.get(_key)}var BRequestManager={send:function(opt,params,returnJSonObject){if(opt.onSuccess&&returnJSonObject){var origHandler={handler:opt.onSuccess};var handler=function(text,xml){try{var jsonResp=null;try{jsonResp=(MooTools.version=="1.2dev")?Json.evaluate(text,false):JSON.decode(text,false)}catch(ERR){throw'Invalid JSON response : "'+text+'"'}this.handler(text,jsonResp)}catch(FF){$console("BRequestManager.send()#handler : "+FF,"error")}}.bind(origHandler);opt.onSuccess=handler}var myRequest=(MooTools.version=="1.2dev")?new XHR(opt):new Request(opt);if(MooTools.version=="1.2dev"){myRequest.send(opt.url,(params)?Object.toQueryString(params):null)}else{myRequest.send((params)?{data:params}:null)}if(!opt.onSuccess&&returnJSonObject){myRequest.response.json=(MooTools.version=="1.2dev")?Json.evaluate(myRequest.response.text,false):JSON.decode(myRequest.response.text,false)}return myRequest}};var BSelect=new Class({Implements:[Events,Options],options:{entries:[{value:"",text:""}],id:"",styles:{},onChange:Class.empty},initialize:function(_obj,_options){this.setOptions(_options);this.states=[{selectedIndex:0,selectedValue:(this.options.entries!=null&&this.options.entries.length>0)?this.options.entries[0].value:null}];this.selectElement=new Element("select",{id:this.options.id,styles:this.options.styles,events:{change:function(){var curSel=this.selectElement.options[this.selectElement.selectedIndex].value;if(curSel==this.states[0].selectedValue){return }this.__updateStates();this.fireEvent("onChange",{esSelect:this,element:this.selectElement,newIndex:this.states[0].selectedIndex,newValue:this.states[0].selectedValue,oldIndex:this.states[1].selectedIndex,oldValue:this.states[1].selectedValue})}.bind(this)}});if(this.options.entries!=null){for(var i=0;i<this.options.entries.length;i++){this.addEntry(this.options.entries[i].value,this.options.entries[i].text)}}this.selectElement.injectInside(_obj)},addEntry:function(_value,_text){new Element("option",{value:_value}).set("text",_text).injectInside(this.selectElement)},removeEntry:function(_index){if(_index<0){return }var t=this.selectElement.getElements("option");if(_index>=t.length){return }t[_index].dispose();if(_index<=this.states[0].selectedIndex){this.__updateStates()}},selectValue:function(_value){for(var i=0;i<this.selectElement.options.length;i++){if(this.selectElement.options[i].value==_value){this.selectElement.selectedIndex=i;this.__updateStates();return }}},cancelChange:function(){if(this.states[1]==null){throw"no change to cancel"}this.states[0]=this.states[1];this.states[1]=this.states[2];this.states[2]=null;this.selectElement.selectedIndex=this.states[0].selectedIndex},__updateStates:function(){var newState={selectedIndex:this.selectElement.selectedIndex,selectedValue:this.selectElement.options[this.selectElement.selectedIndex].value};this.states[2]=this.states[1];this.states[1]=this.states[0];this.states[0]=newState}});var BOverlay=new Class({Implements:[Options],options:{background:"#000",zindex:1000,opacity:0.8},initialize:function(_options){this.setOptions(_options);var body=$$("body")[0];var posStyle=(BBrowser.isIeLt7())?"absolute":"fixed";this.overlay=new Element("div",{styles:{background:this.options.background,"z-index":this.options.zindex,position:posStyle,display:"none"}});if(MooTools.version=="1.2dev"){this.overlay.injectInside(body)}else{this.overlay.inject(body,"top")}},show:function(){if(BBrowser.isIeLt7()){this.overlay.setStyles({display:"block",width:window.getScrollWidth(),height:window.getScrollHeight(),top:0,left:0})}else{this.overlay.setStyles({display:"block",width:"100%",height:"100%",top:0,left:0})}this.overlay.setOpacity(this.options.opacity)},hide:function(){this.overlay.setStyle("display","none")},dispose:function(){this.overlay.dispose()}});var BCarousel=new Class({initialize:function(_listElement,_width,_height){var theWidth=_width;var theHeight=_height;var theList=$(_listElement);var divStyles={width:theWidth,overflow:"hidden",height:theHeight,position:"relative","z-index":"2",padding:"0"};
var divContainer=new Element("div",{styles:divStyles}).inject(theList,"before");theList.inject(divContainer,"top");var items=theList.getElements("li");var lw=theWidth*items.length+100;theList.setStyles({width:lw,border:"0",margin:"0",padding:"0",position:"relative",top:"0",left:"0",overflow:"hidden"});var itemsWidth=theWidth-8;items.each(function(item,index){item.setStyles({"float":"left",height:"75px","list-style-image":"none","list-style-position":"outside","list-style-type":"none",margin:"0",padding:"0",border:"0","margin-right":"4px",padding:"4px",width:itemsWidth,height:theHeight})});this.fx=new Fx.Tween(theList,{property:"left",duration:"500"});this.totIncrement=0;this.increment=theWidth+4;this.maxRightIncrement=this.increment*(-(items.length-1));this.currentIndex=0},slideNext:function(_onComplete){if(this.totIncrement>this.maxRightIncrement){this.totIncrement=this.totIncrement-this.increment;this.fx.removeEvents();if(_onComplete){this.fx.addEvent("complete",function(_fn){_fn()}.bind(this,_onComplete))}this.fx.start(this.totIncrement);this.currentIndex++}},slidePrevious:function(_onComplete){if(this.totIncrement<0){this.totIncrement=this.totIncrement+this.increment;this.fx.removeEvents();if(_onComplete){this.fx.addEvent("complete",function(_fn){_fn()}.bind(this,_onComplete))}this.fx.start(this.totIncrement);this.currentIndex--}},getCurrentIndex:function(){return this.currentIndex}});var BPopup=new Class({Implements:[Options],options:{width:"400px",height:"400px",zindex:"1001",opacity:0.8,background:"#000"},initialize:function(_options,_element){this.setOptions(_options);this.overlay=new BOverlay({zindex:parseInt(this.options.zindex)-1,opacity:this.options.opacity,background:this.options.background});var body=$$("body")[0];var posStyle=(BBrowser.isIeLt7())?"absolute":"fixed";this.container=new Element("div",{styles:{background:this.options.background,"z-index":this.options.zindex,position:posStyle,display:"none"}});this.popupDiv=new Element("div",{styles:{width:this.options.width,height:this.options.height,padding:"0",position:"absolute"}});if(MooTools.version=="1.2dev"){this.container.injectInside(body);this.popupDiv.injectInside(this.container);_element.injectInside(this.popupDiv)}else{this.container.inject(body,"top");this.popupDiv.inject(this.container);_element.inject(this.popupDiv)}},show:function(){this.overlay.show();this.popupDiv.setStyle("visibility","hidden");if(BBrowser.isIeLt7()){this.container.setStyles({display:"block",width:window.getScrollWidth(),height:window.getScrollHeight(),top:0,left:0})}else{this.container.setStyles({display:"block",width:"100%",height:"100%",top:0,left:0})}this.popupDiv.setStyles({left:(window.getSize().x-parseInt(this.options.width))/2,top:(window.getSize().y-parseInt(this.options.height))/2});this.popupDiv.fade(1)},hide:function(){this.popupDiv.fade(0);this.overlay.hide()},dispose:function(){this.overlay.dispose();this.container.dispose()}});