var sFadeFPS = null; var sFadeDuration = null; var sFadeFromColor = null; var sFadeToColor = null; var sParentLayerId = null; var sChildLayerId = null; var sAlertText = null; var sTextLayerId = null; function initAlert() { var is = new Is(); if (!is.ie6up && !is.nav6up && !is.opera5up) { if (sAlertText) { alert(sAlertText); return;}
}
writeToLayer(); myFadeSize = new fx.FadeSize(sParentLayerId, {duration: 500}); myFadeSize.hide(); myFadeSize.toggle('height'); Fat.fade_element(sChildLayerId, sFadeFPS, sFadeDuration, sFadeFromColor, sFadeToColor)
}
function showAlert () { if (document.getElementById) { document.getElementById(sParentLayerId).style.display = 'block'; document.getElementById(sParentLayerId).style.visibility = 'visible';}
else if (document.all && !document.getElementById) { document.all[sParentLayerId].style.display = 'block'; document.all[sParentLayerId].style.visibility = 'visible';}
}
function hideAlert () { if (document.getElementById) { document.getElementById(sParentLayerId).style.display = 'none'; document.getElementById(sParentLayerId).style.visibility = 'hidden';}
else if (document.all && !document.getElementById) { document.all[sParentLayerId].style.display = 'none'; document.all[sParentLayerId].style.visibility = 'hidden';}
}
function writeToLayer() { var o_obj; if (document.getElementById) { o_obj = document.getElementById(sTextLayerId); o_obj.innerHTML = ''; o_obj.innerHTML = sAlertText;}
else if (document.all) { o_obj = document.all[sTextLayerId]; o_obj.innerHTML = sAlertText;}
else if (document.layers) { o_obj = document.layers[sTextLayerId]; o_obj.document.open(); o_obj.document.write(sAlertText); o_obj.document.close();}
}
var Class = { create: function() { return function() { this.initialize.apply(this, arguments);}
}
}
Object.extend = function(destination, source) { for (property in source) { destination[property] = source[property];}
return destination;}
Function.prototype.bind = function(object) { var __method = this; return function() { return __method.apply(object, arguments);}
}
function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string')
element = document.getElementById(element); if (arguments.length == 1)
return element; elements.push(element);}
return elements;}
document.getElementsByClassName = function(className) { var children = document.getElementsByTagName('*') || document.all; var elements = new Array(); for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { elements.push(child); break;}
}
}
return elements;}
if (!window.Element) { var Element = new Object();}
Object.extend(Element, { remove: function(element) { element = $(element); element.parentNode.removeChild(element);}, hasClassName: function(element, className) { element = $(element); if (!element)
return; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { if (a[i] == className)
return true;}
return false;}, addClassName: function(element, className) { element = $(element); Element.removeClassName(element, className); element.className += ' ' + className;}, removeClassName: function(element, className) { element = $(element); if (!element)
return; var newClassName = ''; var a = element.className.split(' '); for (var i = 0; i < a.length; i++) { if (a[i] != className) { if (i > 0)
newClassName += ' '; newClassName += a[i];}
}
element.className = newClassName;}, cleanWhitespace: function(element) { element = $(element); for (var i = 0; i < element.childNodes.length; i++) { var node = element.childNodes[i]; if (node.nodeType == 3 && !/\S/.test(node.nodeValue))
Element.remove(node);}
}
}); var fx = new Object(); fx.Base = function(){}; fx.Base.prototype = { setOptions: function(options) { this.options = { duration: 500, onComplete: ''
}
Object.extend(this.options, options || {});}, go: function() { this.duration = this.options.duration; this.startTime = (new Date).getTime(); this.timer = setInterval (this.step.bind(this), 13);}, step: function() { var time = (new Date).getTime(); var Tpos = (time - this.startTime) / (this.duration); if (time >= this.duration+this.startTime) { this.now = this.to; clearInterval (this.timer); this.timer = null; if (this.options.onComplete) setTimeout(this.options.onComplete.bind(this), 10);}
else { this.now = ((-Math.cos(Tpos*Math.PI)/2) + 0.5) * (this.to-this.from) + this.from;}
this.increase();}, custom: function(from, to) { if (this.timer != null) return; this.from = from; this.to = to; this.go();}, hide: function() { this.now = 0; this.increase();}, clearTimer: function() { clearInterval(this.timer); this.timer = null;}
}
fx.Layout = Class.create(); fx.Layout.prototype = Object.extend(new fx.Base(), { initialize: function(el, options) { this.el = $(el); this.el.style.overflow = "hidden"; this.el.iniWidth = this.el.offsetWidth; this.el.iniHeight = this.el.offsetHeight; this.setOptions(options);}
}); fx.Height = Class.create(); Object.extend(Object.extend(fx.Height.prototype, fx.Layout.prototype), { increase: function() { this.el.style.height = this.now + "px";}, toggle: function() { if (this.el.offsetHeight > 0) this.custom(this.el.offsetHeight, 0); else this.custom(0, this.el.scrollHeight);}
}); fx.Width = Class.create(); Object.extend(Object.extend(fx.Width.prototype, fx.Layout.prototype), { increase: function() { this.el.style.width = this.now + "px";}, toggle: function(){ if (this.el.offsetWidth > 0) this.custom(this.el.offsetWidth, 0); else this.custom(0, this.el.iniWidth);}
}); fx.Opacity = Class.create(); fx.Opacity.prototype = Object.extend(new fx.Base(), { initialize: function(el, options) { this.el = $(el); this.now = 1; this.increase(); this.setOptions(options);}, increase: function() { if (this.now == 1) this.now = 0.9999; if (this.now > 0 && this.el.style.visibility == "hidden") this.el.style.visibility = "visible"; if (this.now == 0) this.el.style.visibility = "hidden"; if (window.ActiveXObject) this.el.style.filter = "alpha(opacity=" + this.now*100 + ")"; this.el.style.opacity = this.now;}, toggle: function() { if (this.now > 0) this.custom(1, 0); else this.custom(0, 1);}
}); fx.FadeSize = Class.create(); fx.FadeSize.prototype = { initialize: function(el, options) { this.el = $(el); this.el.o = new fx.Opacity(el, options); if (options) options.onComplete = null; this.el.h = new fx.Height(el, options); this.el.w = new fx.Width(el, options);}, toggle: function() { this.el.o.toggle(); for (var i = 0; i < arguments.length; i++) { if (arguments[i] == 'height') this.el.h.toggle(); if (arguments[i] == 'width') this.el.w.toggle();}
}, hide: function(){ this.el.o.hide(); for (var i = 0; i < arguments.length; i++) { if (arguments[i] == 'height') this.el.h.hide(); if (arguments[i] == 'width') this.el.w.hide();}
}
}
var Fat = { make_hex : function (r,g,b)
{ r = r.toString(16); if (r.length == 1) r = '0' + r; g = g.toString(16); if (g.length == 1) g = '0' + g; b = b.toString(16); if (b.length == 1) b = '0' + b; return "#" + r + g + b;}, fade_all : function ()
{ var a = document.getElementsByTagName("*"); for (var i = 0; i < a.length; i++)
{ var o = a[i]; var r = /fade-?(\w{3,6})?/.exec(o.className); if (r)
{ if (!r[1]) r[1] = ""; if (o.id) Fat.fade_element(o.id,null,null,"#"+r[1]);}
}
}, fade_element : function (id, fps, duration, from, to)
{ if (!fps) fps = 30; if (!duration) duration = 400; if (!from || from=="#") from = "#FF0000"; if (!to) to = this.get_bgcolor(id); var frames = Math.round(fps * (duration / 1000)); var interval = duration / frames; var delay = interval; var frame = 0; if (from.length < 7) from += from.substr(1,3); if (to.length < 7) to += to.substr(1,3); var rf = parseInt(from.substr(1,2),16); var gf = parseInt(from.substr(3,2),16); var bf = parseInt(from.substr(5,2),16); var rt = parseInt(to.substr(1,2),16); var gt = parseInt(to.substr(3,2),16); var bt = parseInt(to.substr(5,2),16); var r,g,b,h; while (frame < frames)
{ r = Math.floor(rf * ((frames-frame)/frames) + rt * (frame/frames)); g = Math.floor(gf * ((frames-frame)/frames) + gt * (frame/frames)); b = Math.floor(bf * ((frames-frame)/frames) + bt * (frame/frames)); h = this.make_hex(r,g,b); setTimeout("Fat.set_bgcolor('"+id+"','"+h+"')", delay); frame++; delay = interval * frame;}
setTimeout("Fat.set_bgcolor('"+id+"','"+to+"')", delay); setTimeout("b_fade_in_progress = false", delay);}, set_bgcolor : function (id, c)
{ var o = document.getElementById(id); o.style.backgroundColor = c;}, get_bgcolor : function (id)
{ var o = document.getElementById(id); while(o)
{ var c; if (window.getComputedStyle) c = window.getComputedStyle(o,null).getPropertyValue("background-color"); if (o.currentStyle) c = o.currentStyle.backgroundColor; if ((c != "" && c != "transparent") || o.tagName == "BODY") { break;}
o = o.parentNode;}
if (c == undefined || c == "" || c == "transparent") c = "#FFFFFF"; var rgb = c.match(/rgb\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)/); if (rgb) c = this.make_hex(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3])); return c;}
}
