
Type.registerNamespace("Competir.Web.UI.Webparts.Behaviors");Competir.Web.UI.Webparts.Behaviors.WeatherBar=function(element)
{Competir.Web.UI.Webparts.Behaviors.WeatherBar.initializeBase(this,[element]);};Competir.Web.UI.Webparts.Behaviors.WeatherBar.prototype={_ClockDiv:null,_template:null,_dataView:null,getClockDiv:function()
{if(!this._ClockDiv)
{var target=this.get_Target();this._ClockDiv=target.getChild("clock");}
return this._ClockDiv;},setupClockTimer:function()
{var timer=$create(Competir.Web.UI.Timer);timer.set_interval(1000);var div=this.getClockDiv();timer.add_tick(function()
{var now=new Date();var time=now.format("HH:mm:ss");Competir.Web.UI.setInnerHTML(div,time);});timer.set_enabled(true);},renderTime:function()
{var now=new Date();var time=now.format("HH:mm:ss");var div=this.getClockDiv();if(div)Competir.Web.UI.setInnerHTML(div,time);},renderWeather:function(locCode)
{if(typeof(Aula365)!="undefined")
{var target=this.get_Target();var svc=new Aula365.Json();svc.Weather_GetInfo(locCode,"c",function(result)
{var divLoading=target.getChild("div_loading");if(divLoading)
{Competir.Web.UI.hide(divLoading);}
var divInfo=target.getChild("div_info");if(divInfo)
{Competir.Web.UI.show(divInfo);}
var imgIcon=target.getChild("img_weathericon");if(imgIcon)
{imgIcon.src="/virtual/images/widgets/weatherbar/icons/"+result.ConditionCode+".png";}
var divCurTemp=target.getChild("div_curtemp");if(divCurTemp)
{Competir.Web.UI.setInnerHTML(divCurTemp,result.CurrentTemp+"°");}},function(error)
{alert(error);});}},showCitySelectionPanel:function()
{var target=this.get_Target();var div=target.getChild("div_selectcity");var citylink=target.getChild("citylink");Competir.Web.UI.show(div);var linkBounds=Sys.UI.DomElement.getBounds(citylink);var divBounds=Sys.UI.DomElement.getBounds(div);div.style.left=0+linkBounds.width-divBounds.width;},hideCitySelectionPanel:function()
{var target=this.get_Target();var div=target.getChild("div_selectcity");Competir.Web.UI.hide(div);},selectCity:function(code,cityName,persist)
{this.renderWeather(code);this.hideCitySelectionPanel();var target=this.get_Target();var citylink=target.getChild("citylink");var cityText=target.getChild("cityText");if(cityText)Competir.Web.UI.setInnerHTML(cityText,cityName);if(persist)
{if(typeof(Aula365)!="undefined")
{var svc=new Aula365.Json();svc.Weather_PersistPreferredCity(code,cityName);}}},searchCityCode:function()
{if(typeof(Aula365)!="undefined")
{var svc=new Aula365.Json();var target=this.get_Target();var txt=target.getChild("txt_cityname");var divContainer=target.getChild("div_container");var dv=this._dataView;svc.Weather_SearchCityCode(txt.value,function(result)
{dv.set_data(result);if(!dv.get_isInitialized())
{dv.initialize();}},function(error)
{alert(error);});}},_onApplicationLoad:function(o)
{this.renderTime();this.setupClockTimer();var context=Competir.MiEmpresa.Context.getCurrent();if(context)
{if(context.get_AKInstancia()!="Global.Aula365")
{var locCode;var cityName;var target=this.get_Target();var hdnCode=target.getChild("hdncitycode");if(hdnCode)
{locCode=hdnCode.value;}
var hdnName=target.getChild("hdncityname");if(hdnName)
{cityName=hdnName.value;}
if((locCode==null||locCode=="")|(cityName==null||cityName==""))
{switch(context.get_AKInstancia())
{case"Argentina.Aula365":locCode="ARBA0009";cityName="Buenos Aires";break;case"Colombia.Aula365":locCode="COXX0004";cityName="Bogotá";break;case"Italia.Aula365":locCode="ITXX0067";cityName="Roma";break;case"Mexico.Aula365":locCode="MXDF0132";cityName="Mexico DF";break;case"Peru.Aula365":locCode="PEXX0011";cityName="Lima";break;case"Bolivia.Aula365":locCode="BLXX0006";cityName="La Paz";break;case"Chile.Aula365":locCode="CIXX0020";cityName="Santiago";break;case"Ecuador.Aula365":locCode="ECXX0008";cityName="Quito";break;case"ElSalvador.Aula365":locCode="ESXX0001";cityName="San Salvador";break;case"Espana.Aula365":locCode="SPXX0050";cityName="Madrid";break;case"Panama.Aula365":locCode="USIA0667";cityName="Panamá";break;case"PuertoRico.Aula365":locCode="USPR0087";cityName="San Juan";break;case"RepublicaDominicana.Aula365":locCode="DRXX0009";cityName="Santo Domingo";break;case"Uruguay.Aula365":locCode="UYXX0006";cityName="Montevideo";break;case"Venezuela.Aula365":locCode="VEXX0008";cityName="Caracas";break;case"SanLuis.Aula1a1":case"EntreClases.Aula365":locCode="ARSL5700";cityName="San Luis";break;}}
this.selectCity(locCode,cityName,false);this._template=new Sys.UI.Template(target.getChild("div_template"));this._dataView=new Sys.UI.DataView(target.getChild("div_container"));this._dataView.set_template(this._template);}}},onTxtCityNameKeyDown:function(event)
{if(Competir.Web.UI.getKeyCode(event)==13)
{this.searchCityCode();}}};Competir.Web.UI.Webparts.Behaviors.WeatherBar.registerClass("Competir.Web.UI.Webparts.Behaviors.WeatherBar",Competir.Web.UI.Webparts.Behaviors.BaseWebpartBehavior);