/* clickMenu - v0.1.6
* Copyright (c) 2007 Roman Weich
* http://p.sohei.org
*/
(function($) { var E = { onClick: function() { var a = $(this).find(">a"); if (a.length > 0) { a.each(function() { if (this.href) { window.location = this.href } }) } else { return false } }, arrowSrc: '', subDelay: 300, mainDelay: 10 }; $.fn.clickMenu = function(f) { var g = false; var h = (($.browser.msie) ? 4 : 2); var k = $.extend({}, E, f); var l = function(a, b) { if (a.timer && !a.isVisible) { clearTimeout(a.timer) } else if (a.timer) { return } if (a.isVisible) { a.timer = setTimeout(function() { $(A(z(a, 'UL'), 'LI')).unbind('mouseover', s).unbind('mouseout', u).unbind('click', k.onClick); $(a).hide(); a.isVisible = false; a.timer = null }, b) } }; var m = function(b, c) { if (b.timer) { clearTimeout(b.timer) } if (!b.isVisible) { b.timer = setTimeout(function() { if (!C(b.parentNode, 'hover')) { return } $(A(z(b, 'UL'), 'LI')).mouseover(s).mouseout(u).click(k.onClick); if (!C(b.parentNode, 'main')) { $(b).css('left', b.parentNode.offsetWidth - h) } b.isVisible = true; $(b).show(); if ($.browser.msie) { var a = $(z(b, 'UL')).width(); if (a < 100) { a = 100 } $(b).css('width', a) } b.timer = null }, c) } }; var o = function(e) { var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while (p && p != this) { try { p = p.parentNode } catch (e) { p = this } } if (p == this) { return false } return true }; var q = function(e) { var a = A(this.parentNode, 'LI'); var b = new RegExp("(^|\\s)hover(\\s|$)"); for (var i = 0; i < a.length; i++) { if (b.test(a[i].className)) { $(a[i]).removeClass('hover') } } $(this).addClass('hover'); if (g) { t(this, k.mainDelay) } }; var s = function(e) { if (!o(e)) { return false } if (e.target != this) { if (!D(this, e.target)) { return } } t(this, k.subDelay) }; var t = function(a, b) { var c = z(a, 'DIV'); var n = a.parentNode.firstChild; for (; n; n = n.nextSibling) { if (n.nodeType == 1 && n.nodeName.toUpperCase() == 'LI') { var d = z(n, 'DIV'); if (d && d.timer && !d.isVisible) { clearTimeout(d.timer); d.timer = null } } } var e = a.parentNode; for (; e; e = e.parentNode) { if (e.nodeType == 1 && e.nodeName.toUpperCase() == 'DIV') { if (e.timer) { clearTimeout(e.timer); e.timer = null; $(e.parentNode).addClass('hover') } } } $(a).addClass('hover'); if (c && c.isVisible) { if (c.timer) { clearTimeout(c.timer); c.timer = null } else { return } } $(a.parentNode.getElementsByTagName('DIV')).each(function() { if (this != c && this.isVisible) { l(this, b); $(this.parentNode).removeClass('hover') } }); if (c) { m(c, b) } }; var u = function(e) { if (!o(e)) { return false } if (e.target != this) { if (!D(this, e.target)) { return } } var a = z(this, 'DIV'); if (!a) { $(this).removeClass('hover') } else { if (!a.isVisible) { $(this).removeClass('hover') } } }; var v = function(e) { var a = z(this, 'DIV'); var b = e.relatedTarget || e.toElement; var p; if (!g) { $(this).removeClass('hover') } else if (!a && b) { p = B(e.target, 'UL', 'clickMenu'); if (p.contains(b)) { $(this).removeClass('hover') } } else if (b) { p = B(e.target, 'UL', 'clickMenu'); if (!a.isVisible && (p.contains(b))) { $(this).removeClass('hover') } } }; var w = function() { var a = z(this, 'DIV'); if (a && a.isVisible) { y(); $(this).addClass('hover') } else { t(this, k.mainDelay); g = true; $(document).bind('mousedown', x) } return false }; var x = function(e) { var a = false; var b = B(e.target, 'UL', 'clickMenu'); if (b) { $(b.getElementsByTagName('DIV')).each(function() { if (this.isVisible) { a = true } }) } if (!a) { y() } }; var y = function() { $('ul.clickMenu div.outerbox').each(function() { if (this.timer) { clearTimeout(this.timer); this.timer = null } if (this.isVisible) { $(this).hide(); this.isVisible = false } }); $('ul.clickMenu li').removeClass('hover'); $('ul.clickMenu>li li').unbind('mouseover', s).unbind('mouseout', u).unbind('click', k.onClick); $(document).unbind('mousedown', x); g = false }; var z = function(a, b) { if (!a) { return null } var n = a.firstChild; for (; n; n = n.nextSibling) { if (n.nodeType == 1 && n.nodeName.toUpperCase() == b) { return n } } return null }; var A = function(a, b) { if (!a) { return [] } var r = []; var n = a.firstChild; for (; n; n = n.nextSibling) { if (n.nodeType == 1 && n.nodeName.toUpperCase() == b) { r[r.length] = n } } return r }; var B = function(a, b, c) { var d = a.parentNode; var e = new RegExp("(^|\\s)" + c + "(\\s|$)"); for (; d; d = d.parentNode) { if (d.nodeType == 1 && d.nodeName.toUpperCase() == b && e.test(d.className)) { return d } } return null }; var C = function(a, b) { var c = new RegExp("(^|\\s)" + b + "(\\s|$)"); if (c.test(a.className)) { return true } return false }; var D = function(a, b) { var n = a.firstChild; for (; n; n = n.nextSibling) { if (n == b) { return true } } return false }; return this.each(function() { if (window.Node && Node.prototype && !Node.prototype.contains) { Node.prototype.contains = function(a) { return !!(this.compareDocumentPosition(a) & 16) } } if (!C(this, 'clickMenu')) { $(this).addClass('clickMenu') } $('ul', this).shadowBox(); if ($.browser.msie && (!$.browser.version || parseInt($.browser.version) <= 6)) { if ($.fn.bgiframe) { $('div.outerbox', this).bgiframe() } else { $('div.outerbox', this).append('<iframe style="display:block;position:absolute;top:0;left:0;z-index:-1;filter:mask();' + 'width:expression(this.parentNode.offsetWidth);height:expression(this.parentNode.offsetHeight)"/>') } } $(this).bind('closemenu', function() { y() }); var b = A(this, 'LI'); for (var j = 0; j < b.length; j++) { if (z(z(z(b[j], 'DIV'), 'UL'), 'LI')) { $(b[j]).click(w) } } $(b).hover(q, v).addClass('main').find('>div').addClass('inner'); if (k.arrowSrc) { $('div.inner div.outerbox', this).before('<img src="' + k.arrowSrc + '" class="liArrow" />') } $(this).wrap('<div class="cmDiv"></div>').after('<div style="clear: both; visibility: hidden;"></div>') }) }; $.fn.clickMenu.setDefaults = function(o) { $.extend(E, o) } })(jQuery); (function($) { $.fn.shadowBox = function() { return this.each(function() { var a = $('<div class="outerbox"></div>').get(0); if ($(this).css('position') == 'absolute') { $(a).css({ position: 'relative', width: this.offsetWidth, height: this.offsetHeight }) } else { $(a).css('position', 'absolute') } $(this).addClass('innerBox').wrap(a).before('<div class="shadowbox1"></div><div class="shadowbox2"></div><div class="shadowbox3"></div>') }) } })(jQuery);
