/*
 * Superfish - jQuery menu widget
 *
 * Copyright (c) 2007 Joel Birch
 *
 * Dual licensed under the MIT and GPL licenses:
 * 	http://www.opensource.org/licenses/mit-license.php
 * 	http://www.gnu.org/licenses/gpl.html
 *
 */

(function($){
	$.fn.superfish = function(o){
		var defaults = {
			hoverClass	: "sfHover",
			delay		: 500,
			animation	: {opacity:"show"},
			speed		: "fast"
		},
			over = function(){
				var $$ = $(this);
				clearTimeout(this.sfTimer);
				if (!$$.is("."+o.hoverClass)) {
					$$.addClass(o.hoverClass)
						.find("ul")
							.animate(o.animation,o.speed)
							.end()
						.siblings()
						.removeClass(o.hoverClass);
				}
			},
			out = function(){
				var $$ = $(this);
				this.sfTimer=setTimeout(function(){
					$$.removeClass(o.hoverClass)
					.find("iframe", this)
						.remove();
				},o.delay);
			};
		o = $.extend(defaults, o || {});
		var sfHovAr=$("li",this)
			.hover(over,out)
			.find("a").each(function() {
				var $a = $(this), $li = $a.parents("li");
				$a.focus(function(){ $li.each(over); })
				  .blur(function(){ $li.each(out); });
			}).end();
		$(window).unload(function() {
			sfHovAr.unbind("mouseover").unbind("mouseout");
		});
		return this;
	};
})(jQuery);

	$.fn.bgIframe = $.fn.bgiframe = function(o) {
		// This is only for IE6
		if ( !($.browser.msie && typeof XMLHttpRequest == 'function') ) return this;
		o = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, o || {});
		var prop = function(n){return n&&n.constructor==Number?n+"px":n;},
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+o.src+'"'+
		               'style="display:block;position:absolute;z-index:-1;'+
			               (o.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
					       'top:'+(o.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(o.top))+';'+
					       'left:'+(o.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(o.left))+';'+
					       'width:'+(o.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(o.width))+';'+
					       'height:'+(o.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(o.height))+';'+
					'"/>';
		return this.each(function() {
			if ( !$('iframe.bgiframe', this)[0] )
				this.insertBefore( document.createElement(html), this.firstChild );
		});
	};
	