/* * (с) Oleg Osepyants 2008-2009 * Элемент "Прогноз погоды" JavaScript */ function Wether(CookieObj) { this.Titles = new Array(0); this.Images = new Array(0); this.Links = new Array(0); this.Defaults = new Array(0); this.Cookie = CookieObj; this.Current = CookieObj.GetOption("wether"); this.Current = ((this.Current != "") ? parseInt(this.Current) : -1) function GetElementById(Id) { try { if(document.getElementById) return(document.getElementById(Id)); else if(document.all) return(document.all[Id]); else if(document.children) return(document.children[Id]); else return(NULL); } catch(E) {} return(NULL); } //Обработчик изменения выбранного города function OnSelect(Index) { GetElementById("WetherShower").src = this.Images[Index] GetElementById("WetherLinker").href = this.Links[Index]; this.Cookie.SetOption("wether", Index, null, "/"); } //Добавить город в список function AddTown(Link, Image, Title, Default) { this.Titles.push(Title); this.Images.push(Image); this.Links.push(Link); this.Defaults.push(Default); } //Отсортировать города function Sort() { var T = ""; var P = ""; var L = ""; var D = ""; for(I = 0; I < this.Titles.length; I++) for(J = I + 1; J < this.Titles.length; J++) if(this.Titles[I] > this.Titles[J]) { T = this.Titles[I]; P = this.Images[I]; L = this.Links[I]; D = this.Defaults[I]; this.Titles[I] = this.Titles[J]; this.Images[I] = this.Images[J]; this.Links[I] = this.Links[J]; this.Defaults[I] = this.Defaults[J]; this.Titles[J] = T; this.Images[J] = P; this.Links[J] = L; this.Defaults[J] = D; } } //Отобразить прогноз погоды function Draw() { this.Sort(); var Im = ""; var Ln = ""; var S = "
"; document.write(S); } /*protected methods*/ this.GetElementById = GetElementById; this.Sort = Sort; this.OnSelect = OnSelect; /*public methods*/ this.Draw = Draw; this.AddTown = AddTown; /*CSS classes*/ /*constructing*/ if(!document.UserObjects) document.UserObjects = new Array(0); document.UserObjects.push(this); this.GlobalIndex = document.UserObjects.length - 1; }