/**
 * menuMatic 
 * @version 0.68.3 (beta)
 * @author Jason J. Jaeger | greengeckodesign.com
 * @copyright 2008 Jason John Jaeger
 * @license MIT-style License
 **/	
var MenuMatic=new Class({Implements:Options,options:{id:"nav",subMenusContainerId:"subMenusContainer",effect:"slide & fade",duration:600,physics:Fx.Transitions.Pow.easeOut,hideDelay:1000,stretchMainMenu:false,matchWidthMode:false,orientation:"horizontal",direction:{x:"right",y:"down"},tweakInitial:{x:0,y:0},tweakSubsequent:{x:0,y:0},center:false,opacity:95,mmbFocusedClassName:null,mmbClassName:null,killDivider:null,fixHasLayoutBug:false,onHideAllSubMenusNow_begin:(function(){}),onHideAllSubMenusNow_complete:(function(){}),onInit_begin:(function(){}),onInit_complete:(function(){})},hideAllMenusTimeout:null,allSubMenus:[],subMenuZindex:1,initialize:function(B){this.setOptions(B);this.options.onInit_begin();if(this.options.opacity>99){this.options.opacity=99.9}this.options.opacity=this.options.opacity/100;Element.implement({getId:function(){if(!this.id){var E=this.get("tag")+"-"+$time();while($(E)){E=this.get("tag")+"-"+$time()}this.id=E}return this.id}});this.options.direction.x=this.options.direction.x.toLowerCase();this.options.direction.y=this.options.direction.y.toLowerCase();if(this.options.direction.x==="right"){this.options.direction.xInverse="left"}else{if(this.options.direction.x==="left"){this.options.direction.xInverse="right"}}if(this.options.direction.y==="up"){this.options.direction.yInverse="down"}else{if(this.options.direction.y==="down"){this.options.direction.yInverse="up"}}
if (!$(this.options.id)) return;
var A=$(this.options.id).getElements("a");A.each(function(F,E){F.store("parentLinks",F.getParent().getParents("li").getFirst("a"));F.store("parentLinks",F.retrieve("parentLinks").erase(F.retrieve("parentLinks").getFirst()));F.store("childMenu",F.getNext("ul")||F.getNext("ol"));theSubMenuType="subsequent";if($(F.getParent("ul")||F.getParent("ol")).id===this.options.id){theSubMenuType="initial"}F.store("subMenuType",theSubMenuType);if(theSubMenuType==="initial"&&$(F.getNext("ul")||F.getNext("ol"))){F.addClass("mainMenuParentBtn")}else{if($(F.getNext("ul")||F.getNext("ol"))){F.addClass("subMenuParentBtn")}}}.bind(this));var D=new Element("div",{id:this.options.subMenusContainerId}).inject($(document.body),"bottom");$(this.options.id).getElements("ul, ol").each(function(F,E){new Element("div",{"class":"smOW"}).inject(D).grab(F)}.bind(this));D.getElements("a").set("tabindex","-1");A.each(function(G,E){if(!G.retrieve("childMenu")){return }G.store("childMenu",G.retrieve("childMenu").getParent("div"));this.allSubMenus.include(G.retrieve("childMenu"));G.store("parentSubMenus",G.retrieve("parentLinks").retrieve("childMenu"));var F=new MenuMaticSubMenu(this.options,this,G)}.bind(this));var C=$(this.options.id).getElements("a").filter(function(F,E){return !F.retrieve("childMenu")});C.each(function(F,E){F.addEvents({mouseenter:function(G){this.hideAllSubMenusNow();if(this.options.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options.duration/2),transition:this.options.physics,link:"cancel"})).start(this.options.mmbFocusedClassName)}}.bind(this),focus:function(G){this.hideAllSubMenusNow();if(this.options.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options.duration/2),transition:this.options.physics,link:"cancel"})).start(this.options.mmbFocusedClassName)}}.bind(this),mouseleave:function(G){if(this.options.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options.duration*5),transition:this.options.physics,link:"cancel"})).start(this.options.mmbClassName)}}.bind(this),blur:function(G){if(this.options.mmbClassName&&this.options.mmbFocusedClassName){$(F).retrieve("btnMorph",new Fx.Morph(F,{duration:(this.options.duration*5),transition:this.options.physics,link:"cancel"})).start(this.options.mmbClassName)}}.bind(this),keydown:function(H){var G=new Event(H);if(H.key==="up"||H.key==="down"||H.key==="left"||H.key==="right"){H.stop()}if(H.key==="left"&&this.options.orientation==="horizontal"||H.key==="up"&&this.options.orientation==="vertical"){if(F.getParent("li").getPrevious("li")){F.getParent("li").getPrevious("li").getFirst("a").focus()}else{F.getParent("li").getParent().getLast("li").getFirst("a").focus()}}else{if(H.key==="right"&&this.options.orientation==="horizontal"||H.key==="down"&&this.options.orientation==="vertical"){if(F.getParent("li").getNext("li")){F.getParent("li").getNext("li").getFirst("a").focus()}else{F.getParent("li").getParent().getFirst("li").getFirst("a").focus()}}}}.bind(this)})},this);this.stretch();this.killDivider();this.center();this.fixHasLayoutBug();this.options.onInit_complete()},fixHasLayoutBug:function(){if(Browser.Engine.trident&&this.options.fixHasLayoutBug){$(this.options.id).getParents().setStyle("zoom",1);$(this.options.id).setStyle("zoom",1);$(this.options.id).getChildren().setStyle("zoom",1);$(this.options.subMenusContainerId).setStyle("zoom",1);$(this.options.subMenusContainerId).getChildren().setStyle("zoom",1)}},center:function(){if(!this.options.center){return }$(this.options.id).setStyles({left:"50%","margin-left":-($(this.options.id).getSize().x/2)})},stretch:function(){if(this.options.stretchMainMenu&&this.options.orientation==="horizontal"){var C=parseFloat($(this.options.id).getCoordinates().width);var D=0;var B=$(this.options.id).getElements("a");B.setStyles({"padding-left":0,"padding-right":0});B.each(function(F,E){D+=F.getSize().x}.bind(this));if(C<D){return }var A=(C-D)/B.length;B.each(function(F,E){F.setStyle("width",F.getSize().x+A)}.bind(this));B.getLast().setStyle("width",B.getLast().getSize().x-1)}},killDivider:function(){if(this.options.killDivider&&this.options.killDivider.toLowerCase()==="first"){$($(this.options.id).getElements("li")[0]).setStyles({background:"none"})}else{if(this.options.killDivider&&this.options.killDivider.toLowerCase()==="last"){$($(this.options.id).getElements("li").getLast()).setStyles({background:"none"})}}},hideAllSubMenusNow:function(){this.options.onHideAllSubMenusNow_begin();$clear(this.hideAllMenusTimeout);$$(this.allSubMenus).fireEvent("hide");this.options.onHideAllSubMenusNow_complete()}});var MenuMaticSubMenu=new Class({Implements:Options,Extends:MenuMatic,options:{onSubMenuInit_begin:(function(A){}),onSubMenuInit_complete:(function(A){}),onMatchWidth_begin:(function(A){}),onMatchWidth_complete:(function(A){}),onHideSubMenu_begin:(function(A){}),onHideSubMenu_complete:(function(A){}),onHideOtherSubMenus_begin:(function(A){}),onHideOtherSubMenus_complete:(function(A){}),onHideAllSubMenus_begin:(function(A){}),onHideAllSubMenus_complete:(function(A){}),onPositionSubMenu_begin:(function(A){}),onPositionSubMenu_complete:(function(A){}),onShowSubMenu_begin:(function(A){}),onShowSubMenu_complete:(function(A){})},root:null,btn:null,hidden:true,myEffect:null,initialize:function(B,A,C){this.setOptions(B);this.root=A;this.btn=C;this.childMenu=this.btn.retrieve("childMenu");this.subMenuType=this.btn.retrieve("subMenuType");this.childMenu=this.btn.retrieve("childMenu");this.parentSubMenus=$$(this.btn.retrieve("parentSubMenus"));this.parentLinks=$$(this.btn.retrieve("parentLinks"));this.parentSubMenu=$(this.parentSubMenus[0]);if(this.parentSubMenu){this.parentSubMenu=this.parentSubMenu.retrieve("class")}this.childMenu.store("class",this);this.btn.store("class",this);this.childMenu.store("status","closed");this.options.onSubMenuInit_begin(this);this.childMenu.addEvent("hide",function(){this.hideSubMenu()}.bind(this));this.childMenu.addEvent("show",function(){this.showSubMenu()}.bind(this));if(this.options.effect){this.myEffect=new Fx.Morph($(this.childMenu).getFirst(),{duration:this.options.duration,transition:this.options.physics,link:"cancel"})}if(this.options.effect==="slide"||this.options.effect==="slide & fade"){if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"){this.childMenu.getFirst().setStyle("margin-top","0")}else{this.childMenu.getFirst().setStyle("margin-left","0")}}else{if(this.options.effect==="fade"||this.options.effect==="slide & fade"){this.childMenu.getFirst().setStyle("opacity",0)}}if(this.options.effect!="fade"&&this.options.effect!="slide & fade"){this.childMenu.getFirst().setStyle("opacity",this.options.opacity)}var D=$(this.childMenu).getElements("a").filter(function(F,E){return !F.retrieve("childMenu")});D.each(function(F,E){$(F).addClass("subMenuBtn");F.addEvents({mouseenter:function(G){this.childMenu.fireEvent("show");this.cancellHideAllSubMenus();this.hideOtherSubMenus()}.bind(this),focus:function(G){this.childMenu.fireEvent("show");this.cancellHideAllSubMenus();this.hideOtherSubMenus()}.bind(this),mouseleave:function(G){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),blur:function(G){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),keydown:function(H){var G=new Event(H);if(H.key==="up"||H.key==="down"||H.key==="left"||H.key==="right"||H.key==="tab"){H.stop()}if(H.key==="up"){if(F.getParent("li").getPrevious("li")){F.getParent("li").getPrevious("li").getFirst("a").focus()}else{if(this.options.direction.y==="down"){this.btn.focus()}else{if(this.options.direction.y==="up"){F.getParent("li").getParent().getLast("li").getFirst("a").focus()}}}}else{if(H.key==="down"){if(F.getParent("li").getNext("li")){F.getParent("li").getNext("li").getFirst("a").focus()}else{if(this.options.direction.y==="down"){F.getParent("li").getParent().getFirst("li").getFirst("a").focus()}else{if(this.options.direction.y==="up"){this.btn.focus()}}}}else{if(H.key===this.options.direction.xInverse){this.btn.focus()}}}}.bind(this)})},this);$(this.btn).removeClass("subMenuBtn");if(this.subMenuType=="initial"){this.btn.addClass("mainParentBtn")}else{this.btn.addClass("subParentBtn")}$(this.btn).addEvents({mouseenter:function(E){this.cancellHideAllSubMenus();this.hideOtherSubMenus();this.showSubMenu();if(this.subMenuType==="initial"&&this.options.mmbClassName&&this.options.mmbFocusedClassName){$(this.btn).retrieve("btnMorph",new Fx.Morph($(this.btn),{duration:(this.options.duration/2),transition:this.options.physics,link:"cancel"})).start(this.options.mmbFocusedClassName)}}.bind(this),focus:function(E){this.cancellHideAllSubMenus();this.hideOtherSubMenus();this.showSubMenu();if(this.subMenuType==="initial"&&this.options.mmbClassName&&this.options.mmbFocusedClassName){$(this.btn).retrieve("btnMorph",new Fx.Morph($(this.btn),{duration:(this.options.duration/2),transition:this.options.physics,link:"cancel"})).start(this.options.mmbFocusedClassName)}}.bind(this),mouseleave:function(E){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),blur:function(E){this.cancellHideAllSubMenus();this.hideAllSubMenus()}.bind(this),keydown:function(E){E=new Event(E);if(E.key==="up"||E.key==="down"||E.key==="left"||E.key==="right"){E.stop()}if(!this.parentSubMenu){if(this.options.orientation==="horizontal"&&E.key===this.options.direction.y||this.options.orientation==="vertical"&&E.key===this.options.direction.x){if(this.options.direction.y==="down"){this.childMenu.getFirst().getFirst("li").getFirst("a").focus()}else{if(this.options.direction.y==="up"){this.childMenu.getFirst().getLast("li").getFirst("a").focus()}}}else{if(this.options.orientation==="horizontal"&&E.key==="left"||this.options.orientation==="vertical"&&E.key===this.options.direction.yInverse){if(this.btn.getParent().getPrevious()){this.btn.getParent().getPrevious().getFirst().focus()}else{this.btn.getParent().getParent().getLast().getFirst().focus()}}else{if(this.options.orientation==="horizontal"&&E.key==="right"||this.options.orientation==="vertical"&&E.key===this.options.direction.y){if(this.btn.getParent().getNext()){this.btn.getParent().getNext().getFirst().focus()}else{this.btn.getParent().getParent().getFirst().getFirst().focus()}}}}}else{if(E.key==="tab"){E.stop()}if(E.key==="up"){if(this.btn.getParent("li").getPrevious("li")){this.btn.getParent("li").getPrevious("li").getFirst("a").focus()}else{if(this.options.direction.y==="down"){this.parentSubMenu.btn.focus()}else{if(this.options.direction.y==="up"){this.btn.getParent("li").getParent().getLast("li").getFirst("a").focus()}}}}else{if(E.key==="down"){if(this.btn.getParent("li").getNext("li")){this.btn.getParent("li").getNext("li").getFirst("a").focus()}else{if(this.options.direction.y==="down"){this.btn.getParent("li").getParent().getFirst("li").getFirst("a").focus()}else{if(this.options.direction.y==="up"){this.parentSubMenu.btn.focus()}}}}else{if(E.key===this.options.direction.xInverse){this.parentSubMenu.btn.focus()}else{if(E.key===this.options.direction.x){if(this.options.direction.y==="down"){this.childMenu.getFirst().getFirst("li").getFirst("a").focus()}else{if(this.options.direction.y==="up"){}}}}}}}}.bind(this)});this.options.onSubMenuInit_complete(this)},matchWidth:function(){if(this.widthMatched||!this.options.matchWidthMode||this.subMenuType==="subsequent"){return }this.options.onMatchWidth_begin(this);var A=this.btn.getCoordinates().width;$(this.childMenu).getElements("a").each(function(E,D){var C=parseFloat($(this.childMenu).getFirst().getStyle("border-left-width"))+parseFloat($(this.childMenu).getFirst().getStyle("border-right-width"));var B=parseFloat(E.getStyle("padding-left"))+parseFloat(E.getStyle("padding-right"));var F=C+B;if(A>E.getCoordinates().width){E.setStyle("width",A-F);E.setStyle("margin-right",-C)}}.bind(this));this.width=this.childMenu.getFirst().getCoordinates().width;this.widthMatched=true;this.options.onMatchWidth_complete(this)},hideSubMenu:function(){if(this.childMenu.retrieve("status")==="closed"){return }this.options.onHideSubMenu_begin(this);if(this.subMenuType=="initial"){if(this.options.mmbClassName&&this.options.mmbFocusedClassName){$(this.btn).retrieve("btnMorph",new Fx.Morph($(this.btn),{duration:(this.options.duration),transition:this.options.physics,link:"cancel"})).start(this.options.mmbClassName).chain(function(){$(this.btn).removeClass("mainMenuParentBtnFocused");$(this.btn).addClass("mainMenuParentBtn")}.bind(this))}else{$(this.btn).removeClass("mainMenuParentBtnFocused");$(this.btn).addClass("mainMenuParentBtn")}}else{$(this.btn).removeClass("subMenuParentBtnFocused");$(this.btn).addClass("subMenuParentBtn")}this.childMenu.setStyle("z-index",1);if(this.options.effect&&this.options.effect.toLowerCase()==="slide"){if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"&&this.options.direction.y==="down"){this.myEffect.start({"margin-top":-this.height}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"&&this.options.direction.y==="up"){this.myEffect.start({"margin-top":this.height}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.options.direction.x==="right"){this.myEffect.start({"margin-left":-this.width}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.options.direction.x==="left"){this.myEffect.start({"margin-left":this.width}).chain(function(){this.childMenu.style.display="none"}.bind(this))}}}}}else{if(this.options.effect=="fade"){this.myEffect.start({opacity:0}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.options.effect=="slide & fade"){if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"&&this.options.direction.y==="down"){this.myEffect.start({"margin-top":-this.height,opacity:0}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"&&this.options.direction.y==="up"){this.myEffect.start({"margin-top":this.height,opacity:0}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.options.direction.x==="right"){this.myEffect.start({"margin-left":-this.width,opacity:0}).chain(function(){this.childMenu.style.display="none"}.bind(this))}else{if(this.options.direction.x==="left"){this.myEffect.start({"margin-left":this.width,opacity:0}).chain(function(){this.childMenu.style.display="none"}.bind(this))}}}}}else{this.childMenu.style.display="none"}}}this.childMenu.store("status","closed");this.options.onHideSubMenu_complete(this)},hideOtherSubMenus:function(){this.options.onHideOtherSubMenus_begin(this);if(!this.btn.retrieve("otherSubMenus")){this.btn.store("otherSubMenus",$$(this.root.allSubMenus.filter(function(A){return !this.btn.retrieve("parentSubMenus").contains(A)&&A!=this.childMenu}.bind(this))))}this.parentSubMenus.fireEvent("show");this.btn.retrieve("otherSubMenus").fireEvent("hide");this.options.onHideOtherSubMenus_complete(this)},hideAllSubMenus:function(){this.options.onHideAllSubMenus_begin(this);$clear(this.root.hideAllMenusTimeout);this.root.hideAllMenusTimeout=(function(){$clear(this.hideAllMenusTimeout);$$(this.root.allSubMenus).fireEvent("hide")}).bind(this).delay(this.options.hideDelay);this.options.onHideAllSubMenus_complete(this)},cancellHideAllSubMenus:function(){$clear(this.root.hideAllMenusTimeout)},showSubMenu:function(A){if(this.childMenu.retrieve("status")==="open"){return }this.options.onShowSubMenu_begin(this);if(this.subMenuType=="initial"){$(this.btn).removeClass("mainMenuParentBtn");$(this.btn).addClass("mainMenuParentBtnFocused")}else{$(this.btn).removeClass("subMenuParentBtn");$(this.btn).addClass("subMenuParentBtnFocused")}this.root.subMenuZindex++;this.childMenu.setStyles({display:"block",visibility:"hidden","z-index":this.root.subMenuZindex});if(!this.width||!this.height){this.width=this.childMenu.getFirst().getCoordinates().width;this.height=this.childMenu.getFirst().getCoordinates().height;this.childMenu.setStyle("height",this.height,"border");if(this.options.effect==="slide"||this.options.effect==="slide & fade"){if(this.subMenuType=="initial"&&this.options.orientation==="horizontal"){this.childMenu.getFirst().setStyle("margin-top","0");if(this.options.direction.y==="down"){this.myEffect.set({"margin-top":-this.height})}else{if(this.options.direction.y==="up"){this.myEffect.set({"margin-top":this.height})}}}else{if(this.options.direction.x==="left"){this.myEffect.set({"margin-left":this.width})}else{this.myEffect.set({"margin-left":-this.width})}}}}this.matchWidth();this.positionSubMenu();if(this.options.effect==="slide"){this.childMenu.setStyles({display:"block",visibility:"visible"});if(this.subMenuType==="initial"&&this.options.orientation==="horizontal"){if(A){this.myEffect.set({"margin-top":0}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{this.myEffect.start({"margin-top":0}).chain(function(){this.showSubMenuComplete()}.bind(this))}}else{if(A){this.myEffect.set({"margin-left":0}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{this.myEffect.start({"margin-left":0}).chain(function(){this.showSubMenuComplete()}.bind(this))}}}else{if(this.options.effect==="fade"){if(A){this.myEffect.set({opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{this.myEffect.start({opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}}else{if(this.options.effect=="slide & fade"){this.childMenu.setStyles({display:"block",visibility:"visible"});this.childMenu.getFirst().setStyles({left:0});if(this.subMenuType==="initial"&&this.options.orientation==="horizontal"){if(A){this.myEffect.set({"margin-top":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{this.myEffect.start({"margin-top":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}}else{if(A){if(this.options.direction.x==="right"){this.myEffect.set({"margin-left":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{if(this.options.direction.x==="left"){this.myEffect.set({"margin-left":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}}}else{if(this.options.direction.x==="right"){this.myEffect.set({"margin-left":-this.width,opacity:this.options.opacity});this.myEffect.start({"margin-left":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}else{if(this.options.direction.x==="left"){this.myEffect.start({"margin-left":0,opacity:this.options.opacity}).chain(function(){this.showSubMenuComplete()}.bind(this))}}}}}else{this.childMenu.setStyles({display:"block",visibility:"visible"}).chain(function(){this.showSubMenuComplete(this)}.bind(this))}}}this.childMenu.store("status","open")},showSubMenuComplete:function(){this.options.onShowSubMenu_complete(this)},positionSubMenu:function(){this.options.onPositionSubMenu_begin(this);this.childMenu.setStyle("width",this.width);this.childMenu.getFirst().setStyle("width",this.width);if(this.subMenuType==="subsequent"){if(this.parentSubMenu&&this.options.direction.x!=this.parentSubMenu.options.direction.x){if(this.parentSubMenu.options.direction.x==="left"&&this.options.effect&&this.options.effect.contains("slide")){this.myEffect.set({"margin-left":this.width})}}this.options.direction.x=this.parentSubMenu.options.direction.x;this.options.direction.xInverse=this.parentSubMenu.options.direction.xInverse;this.options.direction.y=this.parentSubMenu.options.direction.y;this.options.direction.yInverse=this.parentSubMenu.options.direction.yInverse}var C;var A;if(this.subMenuType=="initial"){if(this.options.direction.y==="up"){if(this.options.orientation==="vertical"){C=this.btn.getCoordinates().bottom-this.height+this.options.tweakInitial.y}else{C=this.btn.getCoordinates().top-this.height+this.options.tweakInitial.y}this.childMenu.style.top=C+"px"}else{if(this.options.orientation=="horizontal"){this.childMenu.style.top=this.btn.getCoordinates().bottom+this.options.tweakInitial.y+"px"}else{if(this.options.orientation=="vertical"){C=this.btn.getPosition().y+this.options.tweakInitial.y;if((C+this.childMenu.getSize().y)>=$(document.body).getScrollSize().y){A=(C+this.childMenu.getSize().y)-$(document.body).getScrollSize().y;C=C-A-20}this.childMenu.style.top=C+"px"}}}if(this.options.orientation=="horizontal"){this.childMenu.style.left=this.btn.getPosition().x+this.options.tweakInitial.x+"px"}else{if(this.options.direction.x=="left"){this.childMenu.style.left=this.btn.getPosition().x-this.childMenu.getCoordinates().width+this.options.tweakInitial.x+"px"}else{if(this.options.direction.x=="right"){this.childMenu.style.left=this.btn.getCoordinates().right+this.options.tweakInitial.x+"px"}}}}else{if(this.subMenuType=="subsequent"){if(this.options.direction.y==="down"){if((this.btn.getCoordinates().top+this.options.tweakSubsequent.y+this.childMenu.getSize().y)>=$(document.body).getScrollSize().y){A=(this.btn.getCoordinates().top+this.options.tweakSubsequent.y+this.childMenu.getSize().y)-$(document.body).getScrollSize().y;this.childMenu.style.top=(this.btn.getCoordinates().top+this.options.tweakSubsequent.y)-A-20+"px"}else{this.childMenu.style.top=this.btn.getCoordinates().top+this.options.tweakSubsequent.y+"px"}}else{if(this.options.direction.y==="up"){if((this.btn.getCoordinates().bottom-this.height+this.options.tweakSubsequent.y)<1){this.options.direction.y="down";this.options.direction.yInverse="up";this.childMenu.style.top=this.btn.getCoordinates().top+this.options.tweakSubsequent.y+"px"}else{this.childMenu.style.top=this.btn.getCoordinates().bottom-this.height+this.options.tweakSubsequent.y+"px"}}}if(this.options.direction.x=="left"){this.childMenu.style.left=this.btn.getCoordinates().left-this.childMenu.getCoordinates().width+this.options.tweakSubsequent.x+"px";if(this.childMenu.getPosition().x<0){this.options.direction.x="right";this.options.direction.xInverse="left";this.childMenu.style.left=this.btn.getPosition().x+this.btn.getCoordinates().width+this.options.tweakSubsequent.x+"px";if(this.options.effect==="slide"||this.options.effect==="slide & fade"){this.myEffect.set({"margin-left":-this.width,opacity:this.options.opacity})}}}else{if(this.options.direction.x=="right"){this.childMenu.style.left=this.btn.getCoordinates().right+this.options.tweakSubsequent.x+"px";var D=this.childMenu.getCoordinates().right;var B=document.getCoordinates().width+window.getScroll().x;if(D>B){this.options.direction.x="left";this.options.direction.xInverse="right";this.childMenu.style.left=this.btn.getCoordinates().left-this.childMenu.getCoordinates().width+this.options.tweakSubsequent.x+"px";if(this.options.effect==="slide"||this.options.effect==="slide & fade"){this.myEffect.set({"margin-left":this.width,opacity:this.options.opacity})}}}}}}this.options.onPositionSubMenu_complete(this)}});
/**
Script: 		n2Select.js
Credits:		NN2LUV - http://nn2luv.com/
Framework:		Mootools 1.2.1 - mootools.net.

Script site:
	http://nn2luv.com/sugar/n2select/

Inspiration:
	- Ideas and mootools 1.11 code by [comboBoo.js, Bruno Torrinha]( www.torrinha.com)
	- Ideas of label click, key events and support HTML selects by [adamnfish]( http://www.mooforum.net/member/adamnfish/)
	- Ideas of key shortcut to option and code by [PJMODOS]( http://www.mooforum.net/member/PJMODOS/)

Discussion:
	http://www.mooforum.net/scripts12/n2select-select-with-mootools-former-mooselect-t744.html
*/


/**
* Another extend, check original, if not in extended put into extended, return extended
* Faster than $merge in some cases
*/
function $extendEx(original, extended) {
	for (var key in (original || {}))
		if (!$defined(extended[key])) extended[key] = original[key];

	return extended;
};


/**
* n2Select Class
*/
var n2Select = new Class({

	Implements: [Events, Options],

	options: {
		klass: 'combobox',
		options: {
		/*
			value: {
				html: string,
				klass: string,
				disabled: boolean
			}
		*/
		},
		selected: false, // default selected value
		/*
		onChange: $empty(),
		*/
		show: 2 // minimum items to show on list
	},
	
	initialize: function(el, options) {
		this.setOptions(options);

		this.elm = $(el);
		this.open = false;
		
		// create custom select
		this.build();

		// we keep an array of our sellinks to hide when click out of them
		n2Select.anchors.push(this.sSelect);
		
		// we keep an array of our objects to re-position when window resize
		n2Select.instances.push(this);
		
		// add events
		this.addSEvents();
	},

	/* generator functions */
	build: function() {
		// generate object from select object & passed options
		this.gen();
		
		// check if selected a disabled item, if so selected first item
		if (this.options.selected === false) this.options.selected = this.elm.get('value');

		if (this.options.options[this.options.selected].disabled === true) {
			for (var op in this.options.options) 
				if (!this.options.options[op].group && !this.options.options[op].disabled) {
					this.options.selected = op;
					break;
				}

			this.elm.set('value', this.options.selected);
		}

		// position
		var el = this.elm,
			pos = this.elm.pos = this.pos(el),

		// styles
			styles = $extend(el.getStyles('font-family',/* 'font-weight',*/ 'font-size'), {
				lineHeight: pos.height
			}),

		// options
			opt = this.options;
		
		// select element
		this.sSelect = new Element('a', {
			'class': opt.klass + '-anchor',
			'styles': $extendEx(styles, {
				top: pos.top,
				left: pos.left,
				width: pos.width - 25,
				height: pos.height
			}),
			'href': 'javascript:void(0)'
		})
		.inject(this.elm, 'after');
		
		// more position
		pos.width += 5;
		pos.height += 2;

		// select list
		this.sList = new Element('div', {
			'class': opt.klass + '-list',
			'styles': $extendEx(styles, {
				top: pos.top + pos.height,
				left: pos.left,
				width: Browser.Engine.trident ? pos.width : ''
			})
		})
		.set('tween', {duration: 150})
		.inject(this.sSelect, 'after');
		
		this.sScroll = new Fx.Scroll(this.sList, {link: 'cancel'});
		
		// IE6 select objects hack
		if (Browser.Engine.trident4) {
			this.sShim = IFrame({
				src: 'about:blank',
				frameBorder: 0,
				background: 'transparent',
				'styles': {
					top: pos.top + pos.height,
					left: pos.left,
					width: pos.width + 2,
					zIndex: 0,
					position: 'absolute'
				}
			})
			.inject(this.sList, 'after');
		} else
			this.sShim = 0;
		
		// more position
		this.sList.pos = {
			below: pos.top + pos.height,
			above: pos.top - 2 // border-top-size + border-bottom-size
		};

		// item list
		var height = pos.height,
			cnt = 0;

		if (Browser.Engine.trident4)
			$extend(styles, {height: height});
		else
			$extend(styles, {minHeight: height, height: 'auto'});

		//for (var op in opt.options) {
		for (var i=0, l=opt.options.order.length; i<l; i++) { // this helps work with Google Chrome
			var op = opt.options.order[i],
				opp = opt.options[op],
				el2 = new Element('div', {
					'class':
						opt.klass + (cnt%2 ? '-odd' : '-even') + ' ' + 
						opt.klass + (opp.group === true ? '-group' : (opp.sub === true ? '-sub' : '-item')) + 
						(opp.disabled ? ' ' + opt.klass + '-disabled' : '') + 
						(opp.klass ? ' ' + opp.klass : '') + ' ' + 
						(!opp.group && !opp.disabled ? ' ' + opt.klass + '-selectable' : ''),
					'styles': styles,
					'html': opp.html
				})
				.inject(this.sList);
			if (opp.disabled) el2.set('html', el2.get('text'));
			if (opp.klass) el2.klass = opp.klass;
			el2.val = op;

			cnt++;

			if (op+'' === opt.selected+'') {
				this.over(el2);
				this.change(el2, true);
			}
			
			if (!opp.group && !opp.disabled) this.addIEvents(el2);
		}
		delete opt.options/*.order*/; // we may not need the options anymore
		
		// where to find our options
		this.regx = 'div[class*=' + this.options.klass + '-selectable]';

		$extend(this.sList, {
			cnt: cnt,
			ith: height,
			mih: height*opt.show,
			mah: height*cnt
		});

		// more position
		this.sList.pos.above -= this.sList.mah;
		if (this.sList.offsetWidth < pos.width) this.sList.setStyle('width', pos.width);

		// hide elements
		el.setStyle('visibility', 'hidden');
		this.sList.setStyle('display', '');
		this.hide();
	},
	
	destroy: function(show) {
		this.removeSEvents();
		this.sSelect.destroy();

		this.sList.getChildren(this.regx).each(function(el) {
			this.removeIEvents(el);
			el.destroy();
		}.bind(this));
		this.sList.getChildren().destroy();
		this.sList.destroy();

		if (this.sShim) this.sShim.destroy();

		// show HTML select
		if (show) this.elm.setStyle('visibility', 'visible');
	},
	
	gen: function() {
		var R = {}, O = this.options.options, order = []; // it seems Google Chrome sorts options so we need and order array here to work with Google Chrome; IE, FF & Opera does not need this

		function gGrp(el) {
			var k = el.get('label');
		
			if (!O[k]) R[k] = {html: k}; else R[k] = O[k];
			if (el.get('disabled')) R[k].disabled = true;
			
			R[k].group = true;
			
			order.push(k);
		
			el.getElements('option').each(function(e) {
				gOpt(e, k, 1);
			});
		};
	
		function gOpt(el, par, sub) {
			var k = el.get('value');

			if (!O[k]) R[k] = {html: el.get('text')}; else R[k] = O[k];
			if (el.get('disabled')) R[k].disabled = true;
			if (sub && (R[par] && R[par]['disabled']) || (O[par] && O[par]['disabled'])) R[k].disabled = true;
			if (el.get('class')) R[k].klass = el.get('class');
			
			if (sub) R[k].sub = true;
			
			order.push(k);
		};
	
		this.elm.getChildren().each(function(el) {
			if (el.match('optgroup'))
				gGrp(el);
			else
				gOpt(el);
		});
		
		for (var op in O) if (!R[op]) {
			R[op] = O[op];
			
			order.push(op);
		}
		
		R.order = order;
		
		this.options.options = R;
	},
	/* generator functions */
	
	/* anchor functions */
	addSEvents: function() {
		this.sSelect
			.addEvents({
				click: this.click.bind(this),
				blur: this.hide.bind(this),
				keydown: this.key.bind(this)
			});
			//.addEvent((Browser.Engine.trident || Browser.Engine.webkit) ? 'keydown' : 'keypress', this.key.bind(this));
	},

	removeSEvents: function() {
		this.sSelect
			.removeEvents({
				click: this.click.bind(this),
				blur: this.hide.bind(this),
				keydown: this.key.bind(this)
			});
			//.removeEvent((Browser.Engine.trident || Browser.Engine.webkit) ? 'keydown' : 'keypress', this.key.bind(this));
	},

	click: function() {
		if (this.open) this.hide(); else this.show();
	},

	key: function(e) {
		if (e.key == 'tab') return true;

		e = new Event(e);// e.stop();

		var el = 0,
			funcs = {
				esc: 'hide',
				enter: 'click',
				up: 'prev',
				down: 'next',
				36: 'first',
				35: 'last'
			};
			
		switch (e.key) {
			case 'esc':
			case 'enter':
				e.stop();
				this[funcs[e.key]]();
			break;
		
			default:
				switch (e.key) {
					case 'up':
					case 'down':
						e.stop();
						el = this[funcs[e.key]]();
					break;
				}

				switch (e.code) {
					case 36:
					case 35:
						e.stop();
						el = this[funcs[e.code]]();
					break;
				}

				// key shortcut to item
				if (!el) {
					var i, curr, list = this.sList.getElements(this.regx);
					for (i = 0, curr = this.next(); i < list.length; i++, curr = curr.getNext(this.regx)) {
						if (!curr) curr = this.first();
						if (e.key == curr.get('text').charAt(0).toLowerCase()) {
							el = curr;
							break;
						}
					}
				}

				if (el) {
					e.stop();
					this.over(el);
					this.change(el);
				} else if (e.key.length == 1) {
					e.stop();
				}
			break;
		}
	},
	
	first: function() {
		return this.sList.getFirst(this.regx);
	},
	
	last: function() {
		return this.sList.getLast(this.regx);
	},
	
	next: function() {
		return this.selected.getNext(this.regx);
	},
	
	prev: function() {
		return this.selected.getPrevious(this.regx);
	},
	/* anchor functions */
	
	/* list functions */
	show: function() {
		if (n2Select.active !== 0) n2Select.active.hide();
		n2Select.active = this;
		
		// more position
		var pos = 'below', height = window.getSize().y + window.getScroll().y - this.sList.pos[pos], items = this.sList.cnt;
		
		if (height >= this.sList.mih) {
			if (height < this.sList.mah) {
				items = Math.floor(height/this.sList.ith);
			}
		} else {
			pos = 'above';
		}

		pos = {
			top: this.sList.pos[pos],
			height: items*this.sList.ith
		};
		
		this.sList.setStyles(pos);
		
		// IE6 select objects hack
		if (this.sShim) this.sShim.setStyles(pos).set('opacity', 1);

		this.open = true;
		this.sList.tween('opacity', 1);
	},

	hide: function() {
		this.open = false;
		this.sList.tween('opacity', 0);
		
		// IE6 select objects hack
		if (this.sShim) this.sShim.set('opacity', 0);

		n2Select.active = 0;
	},
	/* list functions */
	
	/* item functions */
	over: function(el) {
		var k = this.options.klass + '-selected';
		
		if (this.selected) this.selected.removeClass(k);
		this.selected = el.addClass(k);
	},
	
	change: function(el, first) {
		var opt = el.val;
		
		if ((this.options.selected != opt) || first) {
			this.sSelect.set('html', el.get('html'));

			if (this.sSelect.klass) {
				this.sSelect.removeClass(this.sSelect.klass);
				this.sSelect.klass = 0;
			}
			
			if (el.klass) {
				this.sSelect.addClass(el.klass);
				this.sSelect.klass = el.klass;
			}
			
			this.sScroll.toElement(el);
			
			this.options.selected = opt;
			this.elm.set('value', opt);
		
			this.fireEvent('change', opt);
		}
	},

	select: function(el) {
		this.hide();
		this.change(el);
	},

	addIEvents: function(el) {
		el.addEvents({
			mouseenter: this.over.bind(this, el),
			click: this.select.bind(this, el)
		});
	},

	removeIEvents: function(el) {
		el.removeEvents({
			mouseenter: this.over.bind(this, el),
			click: this.select.bind(this, el)
		});
	},
	/* item functions */

	/* re-position functions */
	pos: function(el) {
		return el.getCoordinates();
		
		/*
		var orgWidth = el.getStyle('width');
		el.setStyles({'position':'absolute', 'width':el.offsetWidth});
			
		var pos = el.getCoordinates();
		pos.left -= el.getStyle('margin-left').toInt();
		pos.top -= el.getStyle('margin-top').toInt();

		el.setStyles({'position':'relative', 'width':orgWidth});
		
		return pos;
		*/
	},
	
	repos: function() {
		var p2 = this.pos(this.elm),
			p1 = this.elm.pos,
			dx = p2.left - p1.left,
			dy = p2.top - p1.top;
			
		[this.sSelect, this.sList, this.sShim].each(function(el) {
			if (el) el.setStyles({
				top: el.getStyle('top').toInt() + dy,
				left: el.getStyle('left').toInt() + dx
			});
		});
		
		this.elm.pos = p2;
	}
	/* re-position functions */
});

n2Select.anchors = [];
n2Select.active = 0;
n2Select.instances = [];

// hide when click out of our sellinks
window.addEvent('domready', function() {
	window.document.addEvent('click', function(e) {
		if ((!n2Select.anchors.contains(e.target)) && (n2Select.active !== 0)) {
			n2Select.active.hide();
			n2Select.active = 0;
		}
	});

	window.addEvent('resize', function() {
		n2Select.instances.each(function(el) {
			el.repos();
		});
	});
});
/*
Author:  jan angel manolov <email@webhike.de>  <http://netjard.de/lab/ddmenu>
License: MIT-style license.
*/

var DDMenu = new Class ({
    Implements: [Events, Options],
    options: {
	onOpen: $empty,
	onClose: $empty,
	onItemSelect: $empty, 
	observe_disabled_items: false, //call onItemSelect() on disabled items?
	rightclick_to_open: true,      //open menu on rightclick (if browser supports contextmenu-events)
	crtl_switch: true,             //allow to switch between default menu and dd
	shift_with_contentmenu: true,  //not ie //show default & dd menu together
	fade_in: true,
	cursorx: 2,  //distance to cursors-coords
	cursory: 1,
        opacity: 0.95 //menu transparency
    },
    
    initialize: function (menu, bindon, options) {
        this.setOptions (options);
        this.eMenu = $(menu);
        this.eBindon = $(bindon);
        this.eMenu.setStyles ({ 
            position: 'absolute', 
            'z-index': 9999, 
            display: 'none'
        });
        this.open = this.open.bindWithEvent(this);
        this.close = this.close.bind(this);
        this.preOpenEvent = this.preOpenEvent.bind(this)
        this.menuEvent = this.menuEvent.bindWithEvent(this);
        this.clickedElement = $empty;
        this.eBindon.addEvents ({
            'mousedown': function () { this.eBindon.addEvent ('contextmenu', $break) }.bind(this),
            'mouseup': this.preOpenEvent
        });
        //this.eMenu.getElements('li.item a').addEvent('click', $break); //safari bug :(
        $$('#'+menu+' li a').addEvent('click', $break);
    },

    //while hidden

    preOpenEvent: function (event) {
        if (event.shift) {
            this.eBindon.removeEvent ('contextmenu', $break);
        }
        else if (this.options.crtl_switch && event.rightClick && event.control) { //open browser default contextmenu
            this.eBindon.removeEvent ('contextmenu', $break);
            return true; 
        }
        event.preventDefault();
        if (this.eMenu.style.display == 'block') this.close(event);
        this.clickedElement = $(event.target);
        if (event.rightClick) {
            if (this.options.crtl_switch && event.control) return true;
            else if (this.options.rightclick_to_open) this.open(event);
        }
        if (event.control) this.open(event); else return true;
        return false;        
    },

    open: function (event) { 
        this.eMenu.setStyles ({opacity: 0, display: 'block', 'z-index':99999, top:event.page.y + this.options.cursory, left:event.page.x + this.options.cursorx});
        var coords = {};
        this.eMenu.getPosition().y-$(document.body).getScroll().y+this.eMenu.getSize().y < $(document.body).getSize().y ?
            coords.y = event.page.y + this.options.cursory :
            coords.y = event.page.y - this.eMenu.getSize().y + this.options.cursory;
        if (coords.y<$(document.body).getScroll().y+1) coords.y = $(document.body).getScroll().y+1;
        this.eMenu.getPosition().x-$(document.body).getScroll().x+this.eMenu.getSize().x < $(document.body).getSize().x ?
            coords.x = event.page.x + this.options.cursorx :
            coords.x = event.page.x - this.eMenu.getSize().x + this.options.cursorx;
        if (coords.x<$(document.body).getScroll().x+1) coords.x = $(document.body).getScroll().x+1;
        if (event.shift) coords.x = event.page.x - this.eMenu.getSize().x - this.options.cursorx;
        this.eMenu.setStyles({ top: coords.y, left: coords.x });
        if (this.options.fade_in) {
            var op = this.options.opacity;
            var fadein = new Fx.Morph (this.eMenu, {duration:200}).start({ 'opacity': [.32, op] });
        }
        else this.eMenu.style.opacity = this.options.opacity;
        window.addEvent ('blur', function () { if (!Browser.Engine.trident) this.close() }.bind(this)); //ie throws currious blur events
        document.addEvent ('mousedown', this.menuEvent);
        this.eMenu.addEvents({
            'contextmenu': function () {return false},
            'mouseup': this.menuEvent
        });
        this.fireEvent('onOpen', event);
    },

    //while opened

    menuEvent: function (event) { 
        event.preventDefault();
        var item = $(event.target);
        if (item == this.eMenu || item == this.eMenu.getElement('ul')) return false; 
        item = this.ascendTo(item, ['item','sepline','title']); 
        if (item === false) {
            this.close(event); //outer event
        }
        else if (item.hasClass('item') && event.type == 'mouseup') {
            if (!(item.getElement('a').hasClass('disabled') && !this.options.observe_disabled_items)) {
                this.action(item); 
                this.close(event); 
            }
        }
    },    

    close: function (event) {
        this.eMenu.style.display = 'none';         
        document.removeEvent('mousedown', this.menuEvent);
        window.removeEvent('blur', function () {if (!Browser.Engine.trident) this.close()}.bind(this));
        this.eMenu.removeEvents();
        this.fireEvent('onClose', event);    
    },
    
    action: function (item) {
        //this.clickedElement.focus();
	window.location=item.getElement('a');
        this.fireEvent('onItemSelect', [item.get('id'), this.clickedElement, this.eBindon]);
        return;
    },

    ascendTo: function (el, peakto) {
        if (el == window) return false;
        var ascel = el;
        while (ascel.get('tag') != 'html') { 
            for (var i=0; i<peakto.length; i++) {
                if (ascel.hasClass(peakto[i])) return ascel;
            }
            ascel = ascel.getParent(); 
        }
        return false;
    },
    
    enableThisItemsOnly: function (items, enable) {
        if (!$chk(enable) && enable!=false) enable = true;
        if ($type(items) == 'string') items = [items];
        if (!items.length) return;
        enable == true ?
            this.eMenu.getElements ('li.item a').addClass('disabled') :
            this.eMenu.getElements ('li.item a').removeClass('disabled');
        items.each (function (item) {
            enable == true ? 
                this.eMenu.getElement('li#'+item+' a').removeClass('disabled') :
                this.eMenu.getElement('li#'+item+' a').addClass('disabled');
        }.bind(this));            
    },

    enableItems: function (items, enable) {
        if (!$chk(items) && items!=false) items = true;
        if ($type(items) == 'boolean') {
            items == true ? 
                this.eMenu.getElements('li.item a').removeClass('disabled') : 
                this.eMenu.getElements('li.item a').addClass('disabled');
            return;
        }     
        if (!$chk(enable) && enable!=false) enable = true;
        if ($type(items) == 'string') items = [items];
        items.each (function (item) {
            enable == true ? 
                this.eMenu.getElement('li#'+item+' a').removeClass('disabled') :
                this.eMenu.getElement('li#'+item+' a').addClass('disabled');
        }.bind(this));
    }
});

$break = function () {return false;}


var TipsX3 = new Class({
	options: { // modded for X3
		onShow: function(tip){
			tip.setStyle('visibility', 'visible');
		},
		onHide: function(tip){
			tip.setStyle('visibility', 'hidden');
		},
		maxTitleChars: 30,
		showDelay: 150,
		hideDelay: 0,
		className: 'tool',
		offsets: {'x': 16, 'y': 16},
		fixed: false,
		loadingText: 'Chargement...',
		errTitle: 'Erreur..',
		errText: 'Une erreur est survenue.'
	},

	initialize: function(elements, options){
		this.setOptions(options);
		this.toolTip = new Element('div', {
			'class': this.options.className + '-tip',
			'styles': {
				'position': 'absolute',
				'top': '0',
				'left': '0',
				'visibility': 'hidden'
			}
		}).inject(document.body);
		this.wrapper = new Element('div').inject(this.toolTip);
		$$(elements).each(this.build, this);
		if (this.options.initialize) this.options.initialize.call(this);
	},

	build: function(el){ // modded for X3
		//el.myTitle = (el.href && el.get('tag') == 'a') ? el.href.replace('http://', '') : (el.rel || false);
		//el.myTitle = (el.rel || false);
		//if (el.rel) return;
		if (!el.title) return;
		el.myTitle = false
		if (el.title){
			// check if we need to extract contents from a DOM element
			if (el.title.test('^DOM:', 'i')) {
				el.title = $(el.title.split(':')[1].trim()).innerHTML;
			}
			// check for an URL to retrieve content from
			if (el.title.test('^AJAX:', 'i')) {
				el.title = this.options.loadingText + '::' + el.title;
			}
			var dual = el.title.split('::');
			if (dual.length > 1) {
				el.myTitle = dual[0].trim();
				el.myText = dual[1].trim();
			} else {
				el.myText = el.title;
			}
			el.removeAttribute('title');
		} else {
			el.myText = false;
		}
		if (!el.myTitle && !el.myText) return;
		if (el.myTitle && el.myTitle.length > this.options.maxTitleChars) el.myTitle = el.myTitle.substr(0, this.options.maxTitleChars - 1) + "&hellip;";
		el.addEvent('mouseenter', function(event){
			this.start(el);
			if (!this.options.fixed) this.locate(event);
			else this.position(el);
		}.bind(this));
		if (!this.options.fixed) el.addEvent('mousemove', this.locate.bindWithEvent(this));
		var end = this.end.bind(this);
		el.addEvent('mouseleave', end);
		el.addEvent('trash', end);
	},

	start: function(el){ // modded for X3
		this.wrapper.empty();
		// check if we have an AJAX request - if so, show a loading animation and launch the request
		if (el.myText && el.myText.test('^AJAX:', 'i')) {
			//if (this.ajax) this.ajax.cancel();
			this.ajax = new Request ({url: el.myText.replace(/AJAX:/i,''),
				onComplete: function (responseText, responseXML) {
					el.title = responseText;
					this.build(el);
					this.start(el);
					}.bind(this),
				onFailure: function () {
					el.title = this.options.errTitle + '::' + this.options.errText;
					this.build(el);
					this.start(el);
					}.bind(this),
				method: 'get'
				}).send();				
			el.myText = '<div class="' + this.options.className + '-loading">&nbsp;</div>';			
		}
		if (el.myTitle){
			this.title = new Element('span').inject(
				new Element('div', {'class': this.options.className + '-title'}).inject(this.wrapper)
			).set('html', el.myTitle);
		}
		if (el.myText){
			this.text = new Element('span').inject(
				new Element('div', {'class': this.options.className + '-text'}).inject(this.wrapper)
			).set('html', el.myText);
		}
		$clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this);
	},

	end: function(event){
		$clear(this.timer);
		this.timer = this.hide.delay(this.options.hideDelay, this);
	},

	position: function(element){
		var pos = element.getPosition();
		this.toolTip.setStyles({
			'left': pos.x + this.options.offsets.x,
			'top': pos.y + this.options.offsets.y
		});
	},

	locate: function(event){
		var win = {'x': window.getWidth(), 'y': window.getHeight()};
		var scroll = {'x': window.getScrollLeft(), 'y': window.getScrollTop()};
		var tip = {'x': this.toolTip.offsetWidth, 'y': this.toolTip.offsetHeight};
		var prop = {'x': 'left', 'y': 'top'};
		for (var z in prop){
			var pos = event.page[z] + this.options.offsets[z];
			if ((pos + tip[z] - scroll[z]) > win[z]) pos = event.page[z] - this.options.offsets[z] - tip[z];
			this.toolTip.setStyle(prop[z], pos);
		};
	},

	show: function(){
		if (this.options.timeout) this.timer = this.hide.delay(this.options.timeout, this);
		this.fireEvent('onShow', [this.toolTip]);
	},

	hide: function(){
		this.fireEvent('onHide', [this.toolTip]);
	}

});

TipsX3.implement(new Events, new Options);/**
 * Observer - Observe formelements for changes
 *
 * - Additional code from clientside.cnet.com
 *
 * @version		1.1
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */
var Observer = new Class({

	Implements: [Options, Events],

	options: {
		periodical: false,
		delay: 1000
	},

	initialize: function(el, onFired, options){
		this.element = $(el) || $$(el);
		this.addEvent('onFired', onFired);
		this.setOptions(options);
		this.bound = this.changed.bind(this);
		this.resume();
	},

	changed: function() {
		var value = this.element.get('value');
		if ($equals(this.value, value)) return;
		this.clear();
		this.value = value;
		this.timeout = this.onFired.delay(this.options.delay, this);
	},

	setValue: function(value) {
		this.value = value;
		this.element.set('value', value);
		return this.clear();
	},

	onFired: function() {
		this.fireEvent('onFired', [this.value, this.element]);
	},

	clear: function() {
		$clear(this.timeout || null);
		return this;
	},

	pause: function(){
		if (this.timer) $clear(this.timer);
		else this.element.removeEvent('keyup', this.bound);
		return this.clear();
	},

	resume: function(){
		this.value = this.element.get('value');
		if (this.options.periodical) this.timer = this.changed.periodical(this.options.periodical, this);
		else this.element.addEvent('keyup', this.bound);
		return this;
	}

});

var $equals = function(obj1, obj2) {
	return (obj1 == obj2 || JSON.encode(obj1) == JSON.encode(obj2));
};/**
 * Autocompleter
 *
 * http://digitarald.de/project/autocompleter/
 *
 * @version		1.1.2
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */

var Autocompleter = new Class({

	Implements: [Options, Events],

	options: {/*
		onOver: $empty,
		onSelect: $empty,
		onSelection: $empty,
		onShow: $empty,
		onHide: $empty,
		onBlur: $empty,
		onFocus: $empty,*/
		minLength: 1,
		markQuery: true,
		width: 'inherit',
		maxChoices: 10,
		injectChoice: null,
		customChoices: null,
		emptyChoices: null,
		visibleChoices: true,
		className: 'autocompleter-choices',
		zIndex: 42,
		delay: 400,
		observerOptions: {},
		fxOptions: {},

		autoSubmit: false,
		overflow: false,
		overflowMargin: 25,
		selectFirst: false,
		filter: null,
		filterCase: false,
		filterSubset: false,
		forceSelect: false,
		selectMode: true,
		choicesMatch: null,

		multiple: false,
		separator: ', ',
		separatorSplit: /\s*[,;]\s*/,
		autoTrim: false,
		allowDupes: false,

		cache: true,
		relative: false
	},

	initialize: function(element, options) {
		this.element = $(element);
		this.setOptions(options);
		this.build();
		this.observer = new Observer(this.element, this.prefetch.bind(this), $merge({
			'delay': this.options.delay
		}, this.options.observerOptions));
		this.queryValue = null;
		if (this.options.filter) this.filter = this.options.filter.bind(this);
		var mode = this.options.selectMode;
		this.typeAhead = (mode == 'type-ahead');
		this.selectMode = (mode === true) ? 'selection' : mode;
		this.cached = [];
	},

	/**
	 * build - Initialize DOM
	 *
	 * Builds the html structure for choices and appends the events to the element.
	 * Override this function to modify the html generation.
	 */
	build: function() {
	    if (!this.element) return false;
		if ($(this.options.customChoices)) {
			this.choices = this.options.customChoices;
		} else {
			this.choices = new Element('ul', {
				'class': this.options.className,
				'styles': {
					'zIndex': this.options.zIndex
				}
			}).inject(document.body);
			this.relative = false;
			if (this.options.relative) {
				this.choices.inject(this.element, 'after');
				this.relative = this.element.getOffsetParent();
			}
			this.fix = new OverlayFix(this.choices);
		}
		if (!this.options.separator.test(this.options.separatorSplit)) {
			this.options.separatorSplit = this.options.separator;
		}
		this.fx = (!this.options.fxOptions) ? null : new Fx.Tween(this.choices, $merge({
			'property': 'opacity',
			'link': 'cancel',
			'duration': 200
		}, this.options.fxOptions)).addEvent('onStart', Chain.prototype.clearChain).set(0);
		this.element.setProperty('autocomplete', 'off')
			.addEvent((Browser.Engine.trident || Browser.Engine.webkit) ? 'keydown' : 'keypress', this.onCommand.bind(this))
			.addEvent('click', this.onCommand.bind(this, [false]))
			.addEvent('focus', this.toggleFocus.create({bind: this, arguments: true, delay: 100}))
			.addEvent('blur', this.toggleFocus.create({bind: this, arguments: false, delay: 100}));
	},

	destroy: function() {
		if (this.fix) this.fix.destroy();
		this.choices = this.selected = this.choices.destroy();
	},

	toggleFocus: function(state) {
		this.focussed = state;
		if (!state) this.hideChoices(true);
		this.fireEvent((state) ? 'onFocus' : 'onBlur', [this.element]);
	},

	onCommand: function(e) {
		if (!e && this.focussed) return this.prefetch();
		if (e && e.key && !e.shift) {
			switch (e.key) {
				case 'enter':
					if (this.element.value != this.opted) return true;
					if (this.selected && this.visible) {
						this.choiceSelect(this.selected);
						return !!(this.options.autoSubmit);
					}
					break;
				case 'up': case 'down':
					if (!this.prefetch() && this.queryValue !== null) {
						var up = (e.key == 'up');
						this.choiceOver((this.selected || this.choices)[
							(this.selected) ? ((up) ? 'getPrevious' : 'getNext') : ((up) ? 'getLast' : 'getFirst')
						](this.options.choicesMatch), true);
					}
					return false;
				case 'esc': case 'tab':
					this.hideChoices(true);
					break;
			}
		}
		return true;
	},

	setSelection: function(finish) {
		var input = this.selected.inputValue, value = input;
		var start = this.queryValue.length, end = input.length;
		if (input.substr(0, start).toLowerCase() != this.queryValue.toLowerCase()) start = 0;
		if (this.options.multiple) {
			var split = this.options.separatorSplit;
			value = this.element.value;
			start += this.queryIndex;
			end += this.queryIndex;
			var old = value.substr(this.queryIndex).split(split, 1)[0];
			value = value.substr(0, this.queryIndex) + input + value.substr(this.queryIndex + old.length);
			if (finish) {
				var tokens = value.split(this.options.separatorSplit).filter(function(entry) {
					return this.test(entry);
				}, /[^\s,]+/);
				if (!this.options.allowDupes) tokens = [].combine(tokens);
				var sep = this.options.separator;
				value = tokens.join(sep) + sep;
				end = value.length;
			}
		}
		this.observer.setValue(value);
		this.opted = value;
		if (finish || this.selectMode == 'pick') start = end;
		this.element.selectRange(start, end);
		this.fireEvent('onSelection', [this.element, this.selected, value, input]);
	},

	showChoices: function() {
		var match = this.options.choicesMatch, first = this.choices.getFirst(match);
		this.selected = this.selectedValue = null;
		if (this.fix) {
			var pos = this.element.getCoordinates(this.relative), width = this.options.width || 'auto';
			this.choices.setStyles({
				'left': pos.left,
				'top': pos.bottom,
				'width': (width === true || width == 'inherit') ? pos.width : width
			});
		}
		if (!first) return;
		if (!this.visible) {
			this.visible = true;
			this.choices.setStyle('display', '');
			if (this.fx) this.fx.start(1);
			this.fireEvent('onShow', [this.element, this.choices]);
		}
		if (this.options.selectFirst || this.typeAhead || first.inputValue == this.queryValue) this.choiceOver(first, this.typeAhead);
		var items = this.choices.getChildren(match), max = this.options.maxChoices;
		var styles = {'overflowY': 'hidden', 'height': ''};
		this.overflown = false;
		if (items.length > max) {
			var item = items[max - 1];
			styles.overflowY = 'scroll';
			styles.height = item.getCoordinates(this.choices).bottom;
			this.overflown = true;
		};
		this.choices.setStyles(styles);
		this.fix.show();
		if (this.options.visibleChoices) {
			var scroll = document.getScroll(),
			size = document.getSize(),
			coords = this.choices.getCoordinates();
			if (coords.right > scroll.x + size.x) scroll.x = coords.right - size.x;
			if (coords.bottom > scroll.y + size.y) scroll.y = coords.bottom - size.y;
			window.scrollTo(Math.min(scroll.x, coords.left), Math.min(scroll.y, coords.top));
		}
	},

	hideChoices: function(clear) {
		if (clear) {
			var value = this.element.value;
			if (this.options.forceSelect) value = this.opted;
			if (this.options.autoTrim) {
				value = value.split(this.options.separatorSplit).filter($arguments(0)).join(this.options.separator);
			}
			this.observer.setValue(value);
		}
		if (!this.visible) return;
		this.visible = false;
		if (this.selected) this.selected.removeClass('autocompleter-selected');
		this.observer.clear();
		var hide = function(){
			this.choices.setStyle('display', 'none');
			this.fix.hide();
		}.bind(this);
		if (this.fx) this.fx.start(0).chain(hide);
		else hide();
		this.fireEvent('onHide', [this.element, this.choices]);
	},

	prefetch: function() {
		var value = this.element.value, query = value;
		if (this.options.multiple) {
			var split = this.options.separatorSplit;
			var values = value.split(split);
			var index = this.element.getSelectedRange().start;
			var toIndex = value.substr(0, index).split(split);
			var last = toIndex.length - 1;
			index -= toIndex[last].length;
			query = values[last];
		}
		if (query.length < this.options.minLength) {
			this.hideChoices();
		} else {
			if (query === this.queryValue || (this.visible && query == this.selectedValue)) {
				if (this.visible) return false;
				this.showChoices();
			} else {
				this.queryValue = query;
				this.queryIndex = index;
				if (!this.fetchCached()) this.query();
			}
		}
		return true;
	},

	fetchCached: function() {
		return false;
		if (!this.options.cache
			|| !this.cached
			|| !this.cached.length
			|| this.cached.length >= this.options.maxChoices
			|| this.queryValue) return false;
		this.update(this.filter(this.cached));
		return true;
	},

	update: function(tokens) {
		this.choices.empty();
		this.cached = tokens;
		var type = tokens && $type(tokens);
		if (!type || (type == 'array' && !tokens.length) || (type == 'hash' && !tokens.getLength())) {
			(this.options.emptyChoices || this.hideChoices).call(this);
		} else {
			if (this.options.maxChoices < tokens.length && !this.options.overflow) tokens.length = this.options.maxChoices;
			tokens.each(this.options.injectChoice || function(token){
				var choice = new Element('li', {'html': this.markQueryValue(token)});
				choice.inputValue = token;
				this.addChoiceEvents(choice).inject(this.choices);
			}, this);
			this.showChoices();
		}
	},

	choiceOver: function(choice, selection) {
		if (!choice || choice == this.selected) return;
		if (this.selected) this.selected.removeClass('autocompleter-selected');
		this.selected = choice.addClass('autocompleter-selected');
		this.fireEvent('onSelect', [this.element, this.selected, selection]);
		if (!this.selectMode) this.opted = this.element.value;
		if (!selection) return;
		this.selectedValue = this.selected.inputValue;
		if (this.overflown) {
			var coords = this.selected.getCoordinates(this.choices), margin = this.options.overflowMargin,
				top = this.choices.scrollTop, height = this.choices.offsetHeight, bottom = top + height;
			if (coords.top - margin < top && top) this.choices.scrollTop = Math.max(coords.top - margin, 0);
			else if (coords.bottom + margin > bottom) this.choices.scrollTop = Math.min(coords.bottom - height + margin, bottom);
		}
		if (this.selectMode) this.setSelection();
	},

	choiceSelect: function(choice) {
		if (choice) this.choiceOver(choice);
		this.setSelection(true);
		this.queryValue = false;
		this.hideChoices();
	},

	filter: function(tokens) {
		return (tokens || this.tokens).filter(function(token) {
			return this.test(token);
		}, new RegExp(((this.options.filterSubset) ? '' : '^') + this.queryValue.escapeRegExp(), (this.options.filterCase) ? '' : 'i'));
	},

	/**
	 * markQueryValue
	 *
	 * Marks the queried word in the given string with <span class="autocompleter-queried">*</span>
	 * Call this i.e. from your custom parseChoices, same for addChoiceEvents
	 *
	 * @param		{String} Text
	 * @return		{String} Text
	 */
	markQueryValue: function(str) {
		return (!this.options.markQuery || !this.queryValue) ? str
			: str.replace(new RegExp('(' + ((this.options.filterSubset) ? '' : '^') + this.queryValue.escapeRegExp() + ')', (this.options.filterCase) ? '' : 'i'), '<span class="autocompleter-queried">$1</span>');
	},

	/**
	 * addChoiceEvents
	 *
	 * Appends the needed event handlers for a choice-entry to the given element.
	 *
	 * @param		{Element} Choice entry
	 * @return		{Element} Choice entry
	 */
	addChoiceEvents: function(el) {
		return el.addEvents({
			'mouseover': this.choiceOver.bind(this, [el]),
			'click': this.choiceSelect.bind(this, [el])
		});
	}
});

var OverlayFix = new Class({

	initialize: function(el) {
		if (Browser.Engine.trident) {
			this.element = $(el);
			this.relative = this.element.getOffsetParent();
			this.fix = new Element('iframe', {
				'frameborder': '0',
				'scrolling': 'no',
				'src': 'javascript:false;',
				'styles': {
					'position': 'absolute',
					'border': 'none',
					'display': 'none',
					'filter': 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'
				}
			}).inject(this.element, 'after');
		}
	},

	show: function() {
		if (this.fix) {
			var coords = this.element.getCoordinates(this.relative);
			delete coords.right;
			delete coords.bottom;
			this.fix.setStyles($extend(coords, {
				'display': '',
				'zIndex': (this.element.getStyle('zIndex') || 1) - 1
			}));
		}
		return this;
	},

	hide: function() {
		if (this.fix) this.fix.setStyle('display', 'none');
		return this;
	},

	destroy: function() {
		if (this.fix) this.fix = this.fix.destroy();
	}

});

Element.implement({

	getSelectedRange: function() {
		if (!Browser.Engine.trident) return {start: this.selectionStart, end: this.selectionEnd};
		var pos = {start: 0, end: 0};
		var range = this.getDocument().selection.createRange();
		if (!range || range.parentElement() != this) return pos;
		var dup = range.duplicate();
		if (this.type == 'text') {
			pos.start = 0 - dup.moveStart('character', -100000);
			pos.end = pos.start + range.text.length;
		} else {
			var value = this.value;
			var offset = value.length - value.match(/[\n\r]*$/)[0].length;
			dup.moveToElementText(this);
			dup.setEndPoint('StartToEnd', range);
			pos.end = offset - dup.text.length;
			dup.setEndPoint('StartToStart', range);
			pos.start = offset - dup.text.length;
		}
		return pos;
	},

	selectRange: function(start, end) {
		if (Browser.Engine.trident) {
			var diff = this.value.substr(start, end - start).replace(/\r/g, '').length;
			start = this.value.substr(0, start).replace(/\r/g, '').length;
			var range = this.createTextRange();
			range.collapse(true);
			range.moveEnd('character', start + diff);
			range.moveStart('character', start);
			range.select();
		} else {
			this.focus();
			this.setSelectionRange(start, end);
		}
		return this;
	}

});

/* compatibility */

Autocompleter.Base = Autocompleter;/**
 * Autocompleter.Local
 *
 * http://digitarald.de/project/autocompleter/
 *
 * @version		1.1.2
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */

Autocompleter.Local = new Class({

	Extends: Autocompleter,

	options: {
		minLength: 0,
		delay: 200
	},

	initialize: function(element, tokens, options) {
		this.parent(element, options);
		this.tokens = tokens;
	},

	query: function() {
		this.update(this.filter());
	}

});function autocompleter_country()
{
	var ac_country = [
	'Abkhazie',
	'Açores',
	'Afghanistan',
	'Afrique du Sud',
	'Albanie',
	'Algérie',
	'Allemagne',
	'Andorre',
	'Angola',
	'Anguilla',
	'Antigua-et-Barbuda',
	'Arabie saoudite',
	'Archipel des Chagos',
	'Argentine',
	'Arménie',
	'Aruba',
	'Atoll de Johnston',
	'Atoll de Midway',
	'Australie',
	'Autriche',
	'Azerbaïdjan',
	'Bahamas',
	'Bahreïn',
	'Bangladesh',
	'Barbade',
	'Belgique',
	'Belize',
	'Bénin',
	'Bermudes',
	'Bhoutan',
	'Biélorussie',
	'Birmanie',
	'Bolivie',
	'Bonaire',
	'Bosnie-Herzégovine',
	'Botswana',
	'Brésil',
	'Brunei',
	'Bulgarie',
	'Burkina&#160',
	'Burundi',
	'Cambodge',
	'Cameroun',
	'Canada',
	'Canaries',
	'Cap-Vert',
	'Centrafrique',
	'Ceuta',
	'Chili',
	'Chine',
	'Chypre',
	'Chypre du Nord',
	'Colombie',
	'Comores',
	'Congo',
	'Corée du Nord',
	'Corée du Sud',
	'Costa Rica',
	'Côte d\'Ivoire',
	'Croatie',
	'Cuba',
	'Curaçao',
	'Danemark',
	'Dépendances fédérales',
	'Djibouti',
	'Dominique',
	'Égypte',
	'Émirats arabes unis',
	'Équateur',
	'Érythrée',
	'Espagne',
	'Estonie',
	'États-Unis',
	'Éthiopie',
	'Fidji',
	'Finlande',
	'France',
	'Gabon',
	'Gagaouzie',
	'Galmudug',
	'Gambie',
	'Géorgie',
	'Ghana',
	'Grèce',
	'Grenade',
	'Groenland',
	'GSISS',
	'Guadeloupe',
	'Guam',
	'Guatemala',
	'Guernesey',
	'Guinée',
	'Guinée-Bissau',
	'Guinée équatoriale',
	'Guyana',
	'Guyane',
	'Haïti',
	'Haut-Karabakh',
	'Hawaii',
	'Honduras',
	'Hongrie',
	'Île Clipperton',
	'Île de la Navasse',
	'Île de Man',
	'Île de Pâques',
	'Îles Caïmans',
	'Îles Cook',
	'Îles Éparses',
	'Îles Galápagos',
	'Îles Malouines',
	'Îles Mariannes du Nord',
	'Îles Pitcairn',
	'Îles Turques-et-Caïques',
	'Îles Vierges américaines',
	'Îles Vierges britanniques',
	'Île Wake',
	'Inde',
	'Indonésie',
	'Irak',
	'Iran',
	'Irlande',
	'Islande',
	'Israël',
	'Italie',
	'Jamaïque',
	'Japon',
	'Jersey',
	'Jordanie',
	'Kazakhstan',
	'Kenya',
	'Kirghizistan',
	'Kiribati',
	'Koweït',
	'Laos',
	'Lesotho',
	'Lettonie',
	'Liban',
	'Libéria',
	'Libye',
	'Liechtenstein',
	'Lituanie',
	'Luxembourg',
	'Maakhir',
	'Macédoine',
	'Madagascar',
	'Madère',
	'Malaisie',
	'Malawi',
	'Maldives',
	'Mali',
	'Malte',
	'Maroc',
	'Marshall',
	'Martinique',
	'Maurice',
	'Mauritanie',
	'Mayotte',
	'Melilla',
	'Mexique',
	'Micronésie',
	'Moldavie',
	'Monaco',
	'Mongolie',
	'Monténégro',
	'Montserrat',
	'Mozambique',
	'Namibie',
	'Nauru',
	'Népal',
	'Nicaragua',
	'Niger',
	'Nigeria',
	'Niué',
	'Norvège',
	'Nouvelle-Calédonie',
	'Nouvelle-Zélande',
	'Oman',
	'Ossétie du Sud',
	'Ouganda',
	'Ouzbékistan',
	'Pakistan',
	'Palaos',
	'Palestine',
	'Panamá',
	'Papouasie-Nouvelle-Guinée',
	'Paraguay',
	'Pays-Bas',
	'Pérou',
	'Philippines',
	'Plazas de soberanía',
	'Pologne',
	'Polynésie française',
	'Porto Rico',
	'Portugal',
	'Puntland',
	'Qatar',
	'République démocratique du Congo',
	'République dominicaine',
	'République moldave de Transnistrie',
	'République tchèque',
	'Réunion',
	'Roumanie',
	'Royaume-Uni',
	'Russie',
	'Rwanda',
	'Saba',
	'Sahara Occidental',
	'Saint-Barthélemy',
	'Saint-Christophe-et-Niévès',
	'Sainte-Lucie',
	'Saint-Eustache',
	'Saint-Marin',
	'Saint Martin',
	'Saint-Pierre et Miquelon',
	'Saint-Vincent-et-les Grenadines',
	'Salomon',
	'Salvador',
	'Samoa',
	'Samoa américaines',
	'San Andrés et Providencia',
	'Sao Tomé-et-Principe',
	'Sénégal',
	'Serbie',
	'Seychelles',
	'Sierra Leone',
	'Singapour',
	'Sint-Maarten',
	'Slovaquie',
	'Slovénie',
	'Somalie',
	'Somaliland',
	'Soudan',
	'Sri Lanka',
	'Suède',
	'Suisse',
	'Suriname',
	'Swaziland',
	'Syrie',
	'Tadjikistan',
	'Taïwan',
	'Tanzanie',
	'Tchad',
	'Territoire de Sainte-Hélène',
	'Thaïlande',
	'Timor oriental',
	'Togo',
	'Tonga',
	'Trinité-et-Tobago',
	'Tunisie',
	'Turkménistan',
	'Turquie',
	'Tuvalu',
	'Ukraine',
	'Uruguay',
	'Vanuatu',
	'Vatican',
	'Venezuela',
	'Viêt Nam',
	'Wallis-et-Futuna',
	'Yémen',
	'Zambie',
	'Zimbabwe'
];

	// selectMode 'type-ahead' allows fast typing
	new Autocompleter.Local('ac-country', ac_country, {
		'minLength': 1,
		'overflow': true,
		'selectMode': 'type-ahead'
	});

	// Custom choices creation
	/*
	new Autocompleter.Local('ac-country', ac_country, {
		'minLength': 1,
		'selectMode': 'type-ahead',
		'injectChoice': function(token){
			var choice = new Element('li');
			new Element('span', {'html': this.markQueryValue(token)}).inject(choice);
			new Element('img', {
				'class': 'ac-pic',
				'src': '/ico/ico_account.gif' //+ token
			}).inject(choice);
			choice.inputValue = token;
			this.addChoiceEvents(choice).inject(this.choices);
		}
	});
	*/
}
