/* MMG_MenuFader 2008 */ function MenuFader(elem,NORMcolor,OVERcolor,ONcolor,timeMS, N) { this.POS = N; this.element = null; this.colors = [NORMcolor,OVERcolor,ONcolor]; this.time = timeMS; this.fading = false; this.colorList = null; this.Timer = 0; this.currColor = 0; this.AnimStep = 0; this.Hilite = false; if(elem.className == "MENU_ON") { this.Hilite = true; } this.GetAnchor = function(LI_node) { var LI_length = LI_node.childNodes.length; for (var i=0; i < LI_length; i++) { if(LI_node.childNodes[i].nodeName == "A") { return(LI_node.childNodes[i]); } } }; this.element = this.GetAnchor(elem); this.getHex = function(color) { var Tcolor = new Fader_RGBColor(this.colors[color]); return Tcolor.toHex(); }; this.HexAsArr = function(HexColor) { var Hx = new Array(); var fx = HexColor.substring(1, HexColor.length); Hx[0] = eval('0x'+ fx.charAt(0) + fx.charAt(1)); Hx[1] = eval('0x'+ fx.charAt(2) + fx.charAt(3)); Hx[2] = eval('0x'+ fx.charAt(4) + fx.charAt(5)); return(Hx); }; this.GetColors = function(from,to) { var st = this.HexAsArr(this.getHex(from)); var end = this.HexAsArr(this.getHex(to)); this.colorList = GetFadeSteps(st,end,8); this.currColor = to; }; this.stop = function() { this.fading = false; window.clearInterval(this.Timer); } this.Animate = function() { this.AnimStep += 1; if(this.AnimStep < this.colorList.length) { this.element.style.backgroundColor = this.colorList[this.AnimStep]; } else { this.stop(); } }; this.start = function(tm) { this.AnimStep = -1; this.fading = true; this.Timer = window.setInterval("StepNext(" + this.POS + ")",tm); } } StepNext = function(whoN) { MMG_JSMenu.FaderItems[Number(whoN)].Animate(); }; function GetFadeSteps(startColorARR,endColorARR,steps) { var colorSteps = new Array(); for(var step=0; step<=steps; step++) { var inc=eval(steps), epct=step/inc; var spct = (1 - epct); var fx = '#' + dechex(Math.floor(startColorARR[0] * spct + endColorARR[0] * epct)); fx += '' + dechex(Math.floor(startColorARR[1] * spct + endColorARR[1] * epct)); fx += '' + dechex(Math.floor(startColorARR[2] * spct + endColorARR[2] * epct)); colorSteps.push(fx); } return(colorSteps); } function SizeAnimator(elem, width, timeMS, N) { this.POS = N; this.element = elem; this.Width = width; this.time = timeMS; this.Timer = 0; this.AnimStep = 0; this.sizing = false; this.stop = function() { this.sizing = false; window.clearInterval(this.Timer); } this.Animate = function() { this.AnimStep += 12; if(this.AnimStep < this.Width) { this.element.style.width = this.AnimStep + 'px'; } else { this.element.style.width = (this.Width + 1) + 'px'; this.stop(); } }; this.start = function(tm) { this.AnimStep = -1; this.sizing = true; this.Timer = window.setInterval("SizeNext(" + this.POS + ")",tm); } } SizeNext = function(whoN) { MMG_JSMenu.SizerItems[Number(whoN)].Animate(); }; /* @author Stoyan Stefanov */ function Fader_RGBColor(_c) {this.ok=false;if(_c.charAt(0)=='#') {_c=_c.substr(1,6);}_c=_c.replace(/ /g,'');_c=_c.toLowerCase();var _d=[{re: /^rgb\((\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)$/,_pr:function(bt){return[parseInt(bt[1]),parseInt(bt[2]),parseInt(bt[3])];}},{re: /^(\w{2})(\w{2})(\w{2})$/,_pr: function(bt){return [parseInt(bt[1], 16),parseInt(bt[2], 16),parseInt(bt[3], 16)];}},{re: /^(\w{1})(\w{1})(\w{1})$/,_pr: function(bt){return [parseInt(bt[1] + bt[1], 16),parseInt(bt[2] + bt[2], 16),parseInt(bt[3] + bt[3], 16)];}}];for (var i=0;i<_d.length;i++){var re=_d[i].re;var _p=_d[i]._pr;var bt=re.exec(_c);if(bt){_ch=_p(bt);this.r=_ch[0];this.g=_ch[1];this.b=_ch[2];this.ok=true;}}this.r=(this.r < 0 || isNaN(this.r)) ? 0 : ((this.r > 255) ? 255 : this.r);this.g=(this.g < 0 || isNaN(this.g)) ? 0 : ((this.g > 255) ? 255 : this.g);this.b=(this.b < 0 || isNaN(this.b)) ? 0 : ((this.b > 255) ? 255 : this.b);this.toRGB=function () {return 'rgb(' + this.r + ', ' + this.g + ', ' + this.b + ')';};this.toHex=function() {var r=this.r.toString(16);var g=this.g.toString(16);var b=this.b.toString(16);if (r.length==1) {r='0' + r;}if (g.length==1) {g='0' + g;}if(b.length==1) {b='0' + b;}return '#' + r + g + b;};} var chex = "0123456789abcdef"; function dechex(d) {d=eval(d);var i = d % 16, j = (d - i) / 16;return chex.charAt(j) + chex.charAt(i);} _MenuFader = true;