/* 31.btbase64.min.js */

var BT=BT||{};(function(){BT.Base64={keyString:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",UTF8Encode:function(b){b=b.replace(/\x0d\x0a/g,"\x0a");var a="";for(var e=0;e<b.length;e++){var d=b.charCodeAt(e);if(d<128){a+=String.fromCharCode(d)}else{if((d>127)&&(d<2048)){a+=String.fromCharCode((d>>6)|192);a+=String.fromCharCode((d&63)|128)}else{a+=String.fromCharCode((d>>12)|224);a+=String.fromCharCode(((d>>6)&63)|128);a+=String.fromCharCode((d&63)|128)}}}
return a},UTF8Decode:function(a){var b="";var d=0;var e=c1=c2=0;while(d<a.length){e=a.charCodeAt(d);if(e<128){b+=String.fromCharCode(e);d++}else{if((e>191)&&(e<224)){c2=a.charCodeAt(d+1);b+=String.fromCharCode(((e&31)<<6)|(c2&63));d+=2}else{c2=a.charCodeAt(d+1);c3=a.charCodeAt(d+2);b+=String.fromCharCode(((e&15)<<12)|((c2&63)<<6)|(c3&63));d+=3}}}
return b},base64Encode:function(c){var a="";var k,h,f,j,g,e,d;var b=0;c=this.UTF8Encode(c);while(b<c.length){k=c.charCodeAt(b++);h=c.charCodeAt(b++);f=c.charCodeAt(b++);j=k>>2;g=((k&3)<<4)|(h>>4);e=((h&15)<<2)|(f>>6);d=f&63;if(isNaN(h)){e=d=64}else{if(isNaN(f)){d=64}}
a=a+this.keyString.charAt(j)
+this.keyString.charAt(g)
+this.keyString.charAt(e)
+this.keyString.charAt(d)}
return a},base64Decode:function(c){var a="";var k,h,f;var j,g,e,d;var b=0;c=c.replace(/[^A-Za-z0-9\+\/\=]/g,"");while(b<c.length){j=this.keyString.indexOf(c.charAt(b++));g=this.keyString.indexOf(c.charAt(b++));e=this.keyString.indexOf(c.charAt(b++));d=this.keyString.indexOf(c.charAt(b++));k=(j<<2)|(g>>4);h=((g&15)<<4)|(e>>2);f=((e&3)<<6)|d;a=a+String.fromCharCode(k);if(e!=64){a=a+String.fromCharCode(h)}
if(d!=64){a=a+String.fromCharCode(f)}}
a=this.UTF8Decode(a);return a}}})();;

/* b5.default.js */

var currentMapCenter;function initializeMap(configs,markersCode,stylesCode,boxStyles){var myLatlng;configs.width=configs.width=='auto'||configs.width=='100%'?"100%":configs.width+'px';configs.height=configs.height=='auto'||configs.height=='100%'?"100%":configs.height+'px';document.getElementById(configs.cavas_id).style.width=configs.width;document.getElementById(configs.cavas_id).style.height=configs.height;if(configs.owm_api==''){configs.weather=false;}
var markersJson=BT.Base64.base64Decode(markersCode);var markers=JSON.parse(markersJson);var max=markers.length;var stylesJson=BT.Base64.base64Decode(stylesCode);var styles=JSON.parse(stylesJson);var infowindowData=Array();createMapCenter(configs,markers,styles,boxStyles);function createMapCenter(configs,markers,styles,boxStyles){if(configs.mapCenterType=='address'&&configs.mapCenterAddress==''||configs.mapCenterType=='coordinate'&&configs.mapCenterCoordinate==''){if(markers.length==0){var geocoder=new google.maps.Geocoder();geocoder.geocode({'address':'A2DN3 Nguyen Khanh Toan, Cau Giay, Ha Noi'},function(results,status){if(status==google.maps.GeocoderStatus.OK){mapCenter=results[0].geometry.location;return createMap(configs,styles,markers,mapCenter,boxStyles);}else{alert("Geocode map center was not successful for the following reason: "+status);}});}else{if(markers[0].markerType=='address'){var geocoder=new google.maps.Geocoder();geocoder.geocode({'address':markers[0].markerValue},function(results,status){if(status==google.maps.GeocoderStatus.OK){mapCenter=results[0].geometry.location;return createMap(configs,styles,markers,mapCenter,boxStyles);}else{alert("Geocode was not successful for the following reason: "+status+'! Map address: '+markers[0].markerValue);}})}else{mapCenterCoordinate=markers[0].markerValue.split(',');mapCenter=new google.maps.LatLng(mapCenterCoordinate[0],mapCenterCoordinate[1]);return createMap(configs,styles,markers,mapCenter,boxStyles);}}}else{if(configs.mapCenterType=='address'){var geocoder=new google.maps.Geocoder();geocoder.geocode({'address':configs.mapCenterAddress},function(results,status){if(status==google.maps.GeocoderStatus.OK){mapCenter=results[0].geometry.location;return createMap(configs,styles,markers,mapCenter,boxStyles);}else{alert("Geocode was not successful for the following reason: "+status+'! Map address: '+configs.mapCenterAddress);}})}else{mapCenterCoordinate=configs.mapCenterCoordinate.split(',');mapCenter=new google.maps.LatLng(mapCenterCoordinate[0],mapCenterCoordinate[1]);return createMap(configs,styles,markers,mapCenter,boxStyles);}}}
function createMap(configs,styles,markers,mapCenter,boxStyles){if(configs.enableStyle==1||configs.enableStyle=='1'){var stylesArr=[];for(var j=0;j<styles.length;j++)
{var style={};style.stylers=[];if(styles[j].featureType!='all'){style.featureType=styles[j].featureType;}
if(styles[j].elementType!='all'){style.elementType=styles[j].elementType;}
if(styles[j].invertLightness=='true'){style.stylers.push({"invert_lightness":true});}
if(styles[j].visibility){style.stylers.push({"visibility":styles[j].visibility});}
if(styles[j].mapColor){style.stylers.push({"color":styles[j].mapColor});}
if(styles[j].weight){style.stylers.push({"weight":styles[j].weight});}
if(styles[j].hue){style.stylers.push({"hue":styles[j].hue});}
if(styles[j].saturation){style.stylers.push({"saturation":styles[j].saturation});}
if(styles[j].lightness){style.stylers.push({"lightness":styles[j].lightness});}
if(styles[j].gamma){style.stylers.push({"gamma":styles[j].gamma});}
stylesArr.push(style);}
if(configs.createNewOrDefault=="applyDefault"){if(stylesArr.length!=0){var mapOptions={zoom:configs.zoom,zoomControl:configs.zoomControl,scaleControl:configs.scaleControl,mapTypeControl:configs.mapTypeControl,panControl:configs.panControl,streetViewControl:configs.streetViewControl,overviewMapControl:configs.overviewMapControl,draggable:configs.draggable,disableDoubleClickZoom:configs.disableDoubleClickZoom,scrollwheel:configs.scrollwheel,center:mapCenter,mapTypeId:configs.mapType,styles:stylesArr}}else{var mapOptions={zoom:configs.zoom,zoomControl:configs.zoomControl,scaleControl:configs.scaleControl,mapTypeControl:configs.mapTypeControl,panControl:configs.panControl,streetViewControl:configs.streetViewControl,overviewMapControl:configs.overviewMapControl,draggable:configs.draggable,disableDoubleClickZoom:configs.disableDoubleClickZoom,scrollwheel:configs.scrollwheel,center:mapCenter,mapTypeId:configs.mapType}}}else{var mapOptions={zoom:configs.zoom,zoomControl:configs.zoomControl,scaleControl:configs.scaleControl,mapTypeControl:configs.mapTypeControl,panControl:configs.panControl,streetViewControl:configs.streetViewControl,overviewMapControl:configs.overviewMapControl,draggable:configs.draggable,disableDoubleClickZoom:configs.disableDoubleClickZoom,scrollwheel:configs.scrollwheel,center:mapCenter,mapTypeControlOptions:{mapTypeIds:[configs.mapType,'map_style']}}
var styledMap=new google.maps.StyledMapType(stylesArr,{name:configs.styleTitle});}}else{var mapOptions={zoom:configs.zoom,zoomControl:configs.zoomControl,scaleControl:configs.scaleControl,mapTypeControl:configs.mapTypeControl,panControl:configs.panControl,streetViewControl:configs.streetViewControl,overviewMapControl:configs.overviewMapControl,draggable:configs.draggable,disableDoubleClickZoom:configs.disableDoubleClickZoom,scrollwheel:configs.scrollwheel,center:mapCenter,mapTypeId:configs.mapType}}
var map=new google.maps.Map(document.getElementById(configs.cavas_id),mapOptions);if((configs.enableStyle==1||configs.enableStyle=='1')&&configs.createNewOrDefault=="createNew"){map.mapTypes.set('map_style',styledMap);map.setMapTypeId('map_style');}
for(i=0;i<markers.length;i++){getMarker(configs,markers[i],map,boxStyles,i);}
currentMapCenter=map.getCenter();google.maps.event.addDomListener(map,'idle',function(){currentMapCenter=map.getCenter();});google.maps.event.addDomListener(window,'resize',function(){map.setCenter(currentMapCenter);});}
function getMarker(configs,markerSource,map,boxStyles,i){if(markerSource.markerType=='coordinate'){coordinate=markerSource.markerValue.split(',');var pos=new google.maps.LatLng(coordinate[0],coordinate[1]);if(configs.weather){createMakerWithWeather(configs,markerSource,map,pos,boxStyles,i);}else{createMarker(configs,markerSource,map,pos,boxStyles,i);}}else{var geocoder=new google.maps.Geocoder();geocoder.geocode({'address':markerSource.markerValue},function(results,status){if(status==google.maps.GeocoderStatus.OK){var pos=results[0].geometry.location;if(configs.weather){createMakerWithWeather(configs,markerSource,map,pos,boxStyles,i);}else{createMarker(configs,markerSource,map,pos,boxStyles,i);}}else{if(status==google.maps.GeocoderStatus.OVER_QUERY_LIMIT){setTimeout(function(){getMarker(configs,markerSource,map,boxStyles,i);},3000);}}})}}
function createMarker(configs,markerSource,map,pos,boxStyles,i){var marker,image;if(configs.weather&&markerSource.weatherInfo&&configs.replaceMarkerIcon){image=new google.maps.MarkerImage('http://openweathermap.org/img/w/'+markerSource.weatherInfo.weather[0].icon+'.png');}else{if(markerSource.markerIcon==''){image='';}else{markerSource.markerIcon=configs.url+markerSource.markerIcon;image={url:markerSource.markerIcon};}}
if(configs.weather&&markerSource.weatherInfo){marker=new google.maps.Marker({position:pos,map:map,icon:image,title:markerSource.markerTitle,zIndex:i*10});}else{marker=new google.maps.Marker({position:pos,map:map,icon:image,title:markerSource.markerTitle,zIndex:i*10});}
if(configs.weather&&configs.displayWeatherInfo&&markerSource.weatherInfo){markerSource.markerInfoWindow+='<p class="weather-info">'
+'<img src="'+'http://openweathermap.org/img/w/'+markerSource.weatherInfo.weather[0].icon+'.png'+'" alt=""/><br/>'
+markerSource.weatherInfo.main.temp+'&deg;'+(configs.temperatureUnit=='c'?'C':'F')+'<br/>'
+markerSource.weatherInfo.weather[0].main
+'</p>';}
if(markerSource.markerInfoWindow){if(configs.enableCustomInfoBox==1||configs.enableCustomInfoBox=='1'){var pixelOffset=configs.boxPosition.split(',');if(configs.closeBoxImage==''){configs.closeBoxImage='modules/mod_bt_googlemaps/tmpl/images/close.gif';}
var infoBoxOption={content:markerSource.markerInfoWindow,disableAutoPan:false,maxWidth:0,pixelOffset:new google.maps.Size(Number(pixelOffset[0]),Number(pixelOffset[1])),zIndex:i*10,boxStyle:boxStyles,closeBoxMargin:configs.closeBoxMargin,closeBoxURL:configs.url+'/'+configs.closeBoxImage,infoBoxClearance:new google.maps.Size(1,1),isHidden:false,pane:"floatPane",enableEventPropagation:false}
var infowindow=new InfoBox(infoBoxOption);}else{var infowindow=new google.maps.InfoWindow({content:markerSource.markerInfoWindow});}
infowindowData.push(infowindow);if(markerSource.markerShowInfoWindow==1){infowindow.open(map,marker);}
google.maps.event.addListener(marker,'click',function(){for(var i=0;i<infowindowData.length;i++){infowindowData[i].close();}
infowindow.open(map,marker);});}}
function createMakerWithWeather(configs,markerSource,map,pos,boxStyles,i){var requestString="http://api.openweathermap.org/data/2.5/weather?lat="+pos.lat()+'&lon='+pos.lng()
+"&cluster=yes&format=json"
+(configs.temperatureUnit=='c'?'&units=metric':'')
+"&APPID="+configs.owm_api;var request=new XMLHttpRequest();request.onload=function(){var results=JSON.parse(this.responseText);if(results.cod==200){markerSource.weatherInfo=results;}else{markerSource.weatherInfo=false;}
createMarker(configs,markerSource,map,pos,boxStyles,i);};request.open("get",requestString,true);request.send();}};

/* fc.core.js */

function switchFontSize(ckname,val){var bd=document.getElementsByTagName('body');if(!bd||!bd.length)return;bd=bd[0];switch(val){case'inc':if(CurrentFontSize+1<7){CurrentFontSize++;}
break;case'dec':if(CurrentFontSize-1>0){CurrentFontSize--;}
break;case'reset':default:CurrentFontSize=DefaultFontSize;}
var newclass='fs'+CurrentFontSize;bd.className=bd.className.replace(new RegExp('fs.?','g'),'');bd.className=trim(bd.className);bd.className+=(bd.className?' ':'')+newclass;createCookie(ckname,CurrentFontSize,365);}
function switchTool(ckname,val){createCookie(ckname,val,365);window.location.reload();}
function cpanel_reset(){var matches=document.cookie.match(new RegExp('(?:^|;)\\s*'+tmpl_name.escapeRegExp()+'_([^=]*)=([^;]*)','g'));if(!matches)return;for(var i=0;i<matches.length;i++){var ck=matches[i].match(new RegExp('(?:^|;)\\s*'+tmpl_name.escapeRegExp()+'_([^=]*)=([^;]*)'));if(ck){createCookie(tmpl_name+'_'+ck[1],'',-1);}}
if(window.location.href.indexOf('?')>-1){window.location.href=window.location.href.substr(0,window.location.href.indexOf('?'));}else{window.location.reload(true);}}
function cpanel_apply(){var elems=document.getElementById('ja-cpanel-main').getElementsByTagName('*');var usersetting={};for(var i=0;i<elems.length;i++){var el=elems[i];if(el.name&&(match=el.name.match(/^user_(.*)$/))){var name=match[1];var value='';if(el.tagName.toLowerCase()=='input'&&(el.type.toLowerCase()=='radio'||el.type.toLowerCase()=='checkbox')){if(el.checked)value=el.value;}else{value=el.value;}
if(usersetting[name]){if(value)usersetting[name]=value+','+usersetting[name];}else{usersetting[name]=value;}}}
for(var k in usersetting){name=tmpl_name+'_'+k;value=usersetting[k].trim();if(value.length>0){createCookie(name,value,365);}}
if(window.location.href.indexOf('?')>-1){window.location.href=window.location.href.substr(0,window.location.href.indexOf('?'));}else{window.location.reload(true);}}
function createCookie(name,value,days){if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}else{expires="";}
document.cookie=name+"="+value+expires+"; path=/";}
function trim(str,chars){return ltrim(rtrim(str,chars),chars);}
function ltrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("^["+chars+"]+","g"),"");}
function rtrim(str,chars){chars=chars||"\\s";return str.replace(new RegExp("["+chars+"]+$","g"),"");}
function getScreenWidth(){var x=0;if(self.innerHeight){x=self.innerWidth;}else if(document.documentElement&&document.documentElement.clientHeight){x=document.documentElement.clientWidth;}else if(document.body){x=document.body.clientWidth;}
return x;}
function equalHeight(els){els=$$_(els);if(!els||els.length<2)return;var maxh=0;var els_=[];els.each(function(el,i){if(!el)return;els_[i]=el;var ch=els_[i].getCoordinates().height;maxh=(maxh<ch)?ch:maxh;},this);els_.each(function(el,i){if(!el)return;if(el.getStyle('padding-top')!=null&&el.getStyle('padding-bottom')!=null){if(maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt()>0){el.setStyle('min-height',maxh-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());}}else{if(maxh>0)el.setStyle('min-height',maxh);}},this);}
function getDeepestWrapper(el){while(el.getChildren().length==1){el=el.getChildren()[0];}
return el;}
function fixHeight(els,group1,group2){els=$$_(els);group1=$$_(group1);group2=$$_(group2);if(!els||!group1)return;var height=0;group1.each(function(el){if(!el)return;height+=el.getCoordinates().height;});if(group2){group2.each(function(el){if(!el)return;height-=el.getCoordinates().height;});}
els.each(function(el,i){if(!el)return;if(el.getStyle('padding-top')!=null&&el.getStyle('padding-bottom')!=null){if(height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt()>0){el.setStyle('min-height',height-el.getStyle('padding-top').toInt()-el.getStyle('padding-bottom').toInt());}}else{if(height>0){el.setStyle('min-height',height);}}});}
function addFirstLastItem(el){el=$(el);if(!el||!el.getChildren()||!el.getChildren().length)return;el.getChildren()[0].addClass('first-item');el.getChildren()[el.getChildren().length-1].addClass('last-item');}
function $$_(els){if(typeOf(els)=='string')return $$(els);var els_=[];els.each(function(el){el=$(el);if(el)els_.push(el);});return els_;};

/* 9c.mega.js */

var jaMegaMenuMoo=new Class({Implements:Options,options:{slide:0,duration:300,fading:0,bgopacity:0.9,delayHide:500,direction:'down',action:'mouseenter',hidestyle:'normal',offset:5,fixArrow:false},toElement:function(){return this.menu;},initialize:function(menu,options){this.menu=$(menu);if(!this.menu){return;}
this.setOptions(options);if(!this.options.slide&&!this.options.fading){this.options.delayHide=10;}
this.childopen=[];this.imgloaded=false;this.loaded=false;this.prepare();},prepare:function(){var imgElms=this.menu.getElements('img');if(imgElms.length&&!this.imgloaded){var imgSrcs=[];imgElms.each(function(image){imgSrcs.push(image.src)});new Asset.images(imgSrcs,{onComplete:function(){this.start();}.bind(this)});this.imgloaded=true;this.start.delay(3000,this);}else{this.start();}},start:function(){if(this.loaded){return;}
this.loaded=true;this.zindex=1000;var pw=this.menu;while(pw=pw.getParent()){if(pw.hasClass('main')||pw.hasClass('wrap')){this.wrapper=pw;break;}}
this.items=this.menu.getElements('li.mega');this.items.each(function(li){var link=li.getChildren('a.mega')[0],child=li.getChildren('.childcontent')[0],level0=li.getParent().hasClass('level0'),parent=this.getParent(li),item={stimer:null,direction:((level0&&this.options.direction=='up')?0:1)};if(child){var childwrap=child.getElement('.childcontent-inner-wrap'),childinner=child.getElement('.childcontent-inner'),width=childinner.getWidth(),height=childinner.getHeight(),padding=childwrap.getStyle('padding-left').toInt()+childwrap.getStyle('padding-right').toInt(),overflow=false;child.setStyles({width:width+20,height:height+20});childwrap.setStyle('width',width);if(['auto','scroll'].contains(childinner.getStyle('overflow'))){overflow=true;if(Browser.ie){if(Browser.version<=7){childinner.setStyle('position','relative');}
if(Browser.version==6){childinner.setStyle('height',childinner.getStyle('max-height')||400);}}}
if(this.options.direction=='up'){if(level0){child.setStyle('top',-child.getHeight());}else{child.setStyle('bottom',0);}}}
if(child&&this.options.bgopacity){new Element('div',{'class':'childcontent-bg',styles:{width:'100%',height:height,opacity:this.options.bgopacity,position:'absolute',top:0,left:0,zIndex:1,background:child.getStyle('background'),backgroundImage:child.getStyle('background-image'),backgroundRepeat:child.getStyle('background-repeat'),backgroundColor:child.getStyle('background-color')}}).inject(childwrap,'top');child.setStyle('background','none');childwrap.setStyles({position:'relative',zIndex:2});}
if(child&&(this.options.slide||this.options.fading)){if(child.hasClass('right')){child.setStyle('right',0);}
var fx=new Fx.Morph(childwrap,{duration:this.options.duration,transition:Fx.Transitions.linear,onComplete:this.itemAnimDone.bind(this,item),link:'cancel'}),stylesOn={};if(this.options.slide){if(level0){stylesOn[item.direction==1?'margin-top':'bottom']=0;}else{stylesOn[window.isRTL?'margin-right':'margin-left']=0;}}
if(this.options.fading){stylesOn['opacity']=1;}}
if(child&&this.options.action=='click'){li.addEvent('click',function(e){e.stopPropagation();if(li.hasClass('group')){return;}
if(item.status=='open'){if(this.cursorIn(li,e)){this.itemHide(item);}else{this.hideOthers(li);}}else{this.itemShow(item);}}.bind(this));}
if(this.options.action=='mouseover'||this.options.action=='mouseenter'){li.addEvent('mouseover',function(e){if(li.hasClass('group')){return;}
e.stop();clearTimeout(item.stimer);clearTimeout(this.atimer);this.intent(item,'open');this.itemShow(item);}.bind(this)).addEvent('mouseleave',function(e){if(li.hasClass('group')){return;}
clearTimeout(item.stimer);this.intent(item,'close');if(child){item.stimer=this.itemHide.delay(this.options.delayHide,this,[item]);}else{this.itemHide(item);}}.bind(this));if(link&&child){link.addEvent('click',function(e){if(!item.clickable){e.stop();}});}
li.addEvent('click',function(e){e.stopPropagation()});if(child){child.addEvent('mouseover',function(){clearTimeout(item.stimer);clearTimeout(this.atimer);this.intent(item,'open');this.itemShow(item);}.bind(this)).addEvent('mouseleave',function(e){e.stop();this.intent(item,'close');clearTimeout(item.stimer);if(!this.cursorIn(item.el,e)){this.atimer=this.hideAlls.delay(this.options.delayHide,this);}}.bind(this))}}
if(link&&!child){link.addEvent('click',function(e){e.stopPropagation();this.hideOthers(null);this.menu.getElements('.active').removeClass('active');var p=li;while(p){var idata=p.retrieve('item');p.addClass('active');idata.link.addClass('active');p=idata.parent;}}.bind(this));}
Object.append(item,{el:li,parent:parent,link:link,child:child,childwrap:childwrap,childinner:childinner,width:width,height:height,padding:padding,level0:level0,fx:fx,stylesOn:stylesOn,overflow:overflow,clickable:!(link&&child)});li.store('item',item);},this);var container=$('ja-wrapper');if(!container){container=document.body;}
container.addEvent('click',function(e){this.hideAlls();}.bind(this));this.menu.getElements('.childcontent').setStyle('display','none');},getParent:function(el){var p=el;while((p=p.getParent())){if(this.items.contains(p)&&!p.hasClass('group')){return p;}
if(!p||p==this.menu){return null;}}},intent:function(item,action){item.intent=action;while(item.parent&&(item=item.parent.retrieve('item'))){item.intent=action;}},cursorIn:function(el,event){if(!el||!event){return false;}
var pos=el.getPosition(),cursor=event.page;return(cursor.x>pos.x&&cursor.x<pos.x+el.getWidth()&&cursor.y>pos.y&&cursor.y<pos.y+el.getHeight());},itemOver:function(item){item.el.addClass('over');if(item.el.hasClass('haschild')){item.el.removeClass('haschild').addClass('haschild-over');}
if(item.link){item.link.addClass('over');}},itemOut:function(item){item.el.removeClass('over');if(item.el.hasClass('haschild-over')){item.el.removeClass('haschild-over').addClass('haschild');}
if(item.link){item.link.removeClass('over');}},itemShow:function(item){if(this.childopen.indexOf(item)<this.childopen.length-1){this.hideOthers(item.el);}
if(item.status=='open'){return;}
this.itemOver(item);if(item.level0){this.childopen.length=0;}
if(item.child){this.childopen.push(item);}
item.intent='open';item.status='open';this.enableclick.delay(100,this,item);if(item.child){this.positionSubmenu(item);if(item.fx&&!item.stylesOff){item.stylesOff={};if(this.options.slide){if(item.level0){item.stylesOff[item.direction==1?'margin-top':'bottom']=-item.height;}else{item.stylesOff[window.isRTL?'margin-right':'margin-left']=(item.direction==1?-item.width:item.width);}}
if(this.options.fading){item.stylesOff['opacity']=0;}
item.fx.set(item.stylesOff);}
clearTimeout(item.sid);item.child.setStyles({display:'block',zIndex:this.zindex++});}
if(!item.fx||!item.child){return;}
item.child.setStyle('overflow','hidden');if(item.overflow){item.childinner.setStyle('overflow','hidden');}
item.fx.start(item.stylesOn);},itemHide:function(item){clearTimeout(item.stimer);item.status='close';item.intent='close';this.itemOut(item);this.childopen.erase(item);if(!item.fx&&item.child){clearTimeout(item.sid);item.sid=setTimeout(function(){item.child.setStyle('display','none');},this.options.delayHide);}
if(!item.fx||!item.child||item.child.getStyle('opacity')=='0'){return;}
item.child.setStyle('overflow','hidden');if(item.overflow){item.childinner.setStyle('overflow','hidden');}
switch(this.options.hidestyle){case'fast':item.fx.options.duration=100;item.fx.start(item.stylesOff);break;case'fastwhenshow':item.fx.start(Object.merge(item.stylesOff,{'opacity':0}));break;case'normal':default:item.fx.start(item.stylesOff);break;}},itemAnimDone:function(item){if(item.status=='close'){if(this.options.hidestyle.test(/fast/)){item.fx.options.duration=this.options.duration;if(!this.options.fading){item.childwrap.setStyle('opacity',1);}}
item.child.setStyle('display','none');this.disableclick.delay(100,this,item);var pitem=item.parent?item.parent.retrieve('item'):null;if(pitem&&pitem.intent=='close'){this.itemHide(pitem);}}
if(item.status=='open'){item.child.setStyle('overflow','');if(item.overflow){item.childinner.setStyle('overflow-y','auto');}
item.childwrap.setStyle('opacity',1);item.child.setStyle('display','block');}},hideOthers:function(el){this.childopen.each(function(item){if(!el||(item.el!=el&&!item.el.contains(el))){item.intent='close';}});if(this.options.slide||this.options.fading){var last=this.childopen.getLast();if(last&&last.intent=='close'){this.itemHide(last);}}else{this.childopen.each(function(item){if(item.intent=='close'){this.itemHide(item);}},this);}},hideAlls:function(el){this.childopen.flatten().each(function(item){if(!item.fx){this.itemHide(item);}else{item.intent='close';}},this);if(this.options.slide||this.options.fading){var last=this.childopen.getLast();if(last&&last.intent=='close'){this.itemHide(last);}}},enableclick:function(item){if(item.link&&item.child){item.clickable=true;}},disableclick:function(item){item.clickable=false;},positionSubmenu:function(item){var options=this.options,offsleft,offstop,left,top,stylesOff={},icoord=item.el.getCoordinates(),bodySize=$(document.body).getScrollSize(),winRect={top:window.getScrollTop(),left:window.getScrollLeft(),width:window.getWidth(),height:window.getHeight()},wrapRect=this.wrapper?this.wrapper.getCoordinates():{top:0,left:0,width:winRect.width,height:winRect.height};winRect.top=Math.max(winRect.top,wrapRect.top);winRect.left=Math.max(winRect.left,wrapRect.left);winRect.width=Math.min(winRect.width,wrapRect.width);winRect.height=Math.min(winRect.height,$(document.body).getScrollHeight());winRect.right=winRect.left+winRect.width;winRect.bottom=winRect.top+winRect.height;if(!item.level0){var pitem=item.parent.retrieve('item'),offsety=parseFloat(pitem.child.getFirst().getStyle('margin-top')),offsetx=parseFloat(pitem.child.getFirst().getStyle(window.isRTL?'margin-right':'margin-left'));item.direction=pitem.direction;window.isRTL&&(offsetx=0-offsetx);icoord.top-=offsety;icoord.bottom-=offsety;icoord.left-=offsetx;icoord.right-=offsetx;}
if(item.level0){if(window.isRTL){offsleft=Math.max(winRect.left,icoord.right-item.width-20);left=Math.max(0,offsleft-winRect.left);}else{offsleft=Math.max(winRect.left,Math.min(winRect.right-item.width,icoord.left));left=Math.max(0,Math.min(winRect.right-item.width,icoord.left)-winRect.left);}}else{if(window.isRTL){if(item.direction==1){offsleft=icoord.left-item.width-20+options.offset;left=-icoord.width-20;if(offsleft<winRect.left){item.direction=0;offsleft=Math.min(winRect.right,Math.max(winRect.left,icoord.right+item.padding-20-options.offset));left=icoord.width-20;stylesOff['margin-right']=item.width;}}else{offsleft=icoord.right+item.padding-20;left=icoord.width-20;if(offsleft+item.width>winRect.right){item.direction=1;offsleft=Math.max(winRect.left,icoord.left-item.width-20);left=-icoord.width-20;stylesOff['margin-right']=-item.width;}}}else{if(item.direction==1){offsleft=icoord.right-options.offset;left=icoord.width;if(offsleft+item.width>winRect.right){item.direction=0;offsleft=Math.max(winRect.left,icoord.left-item.width-item.padding+options.offset);left=-icoord.width;stylesOff['margin-left']=item.width;}}else{offsleft=icoord.left-item.width-item.padding+options.offset;left=-icoord.width;if(offsleft<winRect.left){item.direction=1;offsleft=Math.max(winRect.left,Math.min(winRect.right-item.width,icoord.right-options.offset));left=icoord.width;stylesOff['margin-left']=-item.width;}}}}
if(options.slide&&item.fx&&Object.getLength(stylesOff)){item.fx.set(stylesOff);}
if(options.fixArrow&&item.childinner){item.childinner.setStyle('background-position',(icoord.left-offsleft+(icoord.width/2-4.5))+'px top');}
var oldp=item.child.getStyle('display');item.child.setStyle('display','block');if(item.child.getOffsetParent()){left=offsleft-item.child.getOffsetParent().getCoordinates().left;}
item.child.setStyles({'margin-left':0,'left':left,'display':oldp});}});;

