/*
$(document).ready(function(){

	$("ul.dropdown li").dropdown();

});

$.fn.dropdown = function() {
	$(this).hover(function(){
		$(this).addClass("hover");
		$('> .dir',this).addClass("open");
		$('ul:first',this).css('visibility', 'visible');
	},function(){
		$(this).removeClass("hover");
		$('.open',this).removeClass("open");
		$('ul:first',this).css('visibility', 'hidden');
	});
	
}
*/

/* jQuery Mega Menu v1.02
* Last updated: June 29th, 2009. This notice must stay intact for usage 
* Author: JavaScript Kit at http://www.javascriptkit.com/
* Visit http://www.javascriptkit.com/script/script2/jScale/ for full source code
*/

$j = jQuery.noConflict();

var jkmegamenu={

effectduration: 0, //duration of animation, in milliseconds
delaytimer: 200, //delay after mouseout before menu should be hidden, in milliseconds

//No need to edit beyond here
megamenulabels: [],
megamenus: [], //array to contain each block menu instances
zIndexVal: 1000, //starting z-index value for drop down menu
$jshimobj: null,

addshim:function($j){
	$j(document.body).append('<IFRAME id="outlineiframeshim" src="'+(location.protocol=="https:"? 'blank.htm' : 'about:blank')+'" style="display:none; left:0; top:0; z-index:999; position:absolute; filter:progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
	this.$jshimobj=$j("#outlineiframeshim")
},

alignmenu:function($j, e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $janchor=megamenu.$janchorobj
	var $jmenu=megamenu.$jmenuobj
	var menuleft=($j(window).width()-(megamenu.offsetx-$j(document).scrollLeft())>megamenu.actualwidth)? megamenu.offsetx : megamenu.offsetx-megamenu.actualwidth+megamenu.anchorwidth //get x coord of menu
	//var menutop=($j(window).height()-(megamenu.offsety-$j(document).scrollTop()+megamenu.anchorheight)>megamenu.actualheight)? megamenu.offsety+megamenu.anchorheight : megamenu.offsety-megamenu.actualheight
	var menutop=megamenu.offsety+megamenu.anchorheight  //get y coord of menu
	$jmenu.css({left:menuleft+"px", top:menutop+"px"})
	this.$jshimobj.css({width:megamenu.actualwidth+"px", height:megamenu.actualheight+"px", left:menuleft+"px", top:menutop+"px", display:"block"})
},

showmenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $jmenu=megamenu.$jmenuobj
	var $jmenuinner=megamenu.$jmenuinner
	if ($jmenu.css("display")=="none"){
		this.alignmenu(jQuery, e, megamenu_pos)
		$jmenu.css("z-index", ++this.zIndexVal);
		$jmenuinner.css('visibility', 'visible');
		/*
		$jmenu.show(this.effectduration, function(){
			$jmenuinner.css('visibility', 'visible')
		})
		*/
	}
	else if ($jmenu.css("display")=="block" && e.type=="click"){ //if menu is hidden and this is a "click" event (versus "mouseout")
		this.hidemenu(e, megamenu_pos)
	}
	return false
},

hidemenu:function(e, megamenu_pos){
	var megamenu=this.megamenus[megamenu_pos]
	var $jmenu=megamenu.$jmenuobj
	var $jmenuinner=megamenu.$jmenuinner
	$jmenuinner.css('visibility', 'hidden')
	this.$jshimobj.css({display:"none", left:0, top:0})
	$jmenu.hide(this.effectduration)
},

definemenu:function(anchorid, menuid, revealtype){
	this.megamenulabels.push([anchorid, menuid, revealtype])
},

render:function($j){
	for (var i=0, labels=this.megamenulabels[i]; i<this.megamenulabels.length; i++, labels=this.megamenulabels[i]){
		if ($j('#'+labels[0]).length!=1 || $j('#'+labels[1]).length!=1) //if one of the two elements are NOT defined, exist
			return
		this.megamenus.push({$janchorobj:$j("#"+labels[0]), $jmenuobj:$j("#"+labels[1]), $jmenuinner:$j("#"+labels[1]).children('ul:first-child'), revealtype:labels[2], hidetimer:null})
		var megamenu=this.megamenus[i]	
		megamenu.$janchorobj.add(megamenu.$jmenuobj).attr("_megamenupos", i+"pos") //remember index of this drop down menu
		megamenu.actualwidth=megamenu.$jmenuobj.outerWidth()
		megamenu.actualheight=megamenu.$jmenuobj.outerHeight()
		megamenu.offsetx=megamenu.$janchorobj.offset().left
		megamenu.offsety=megamenu.$janchorobj.offset().top
		megamenu.anchorwidth=megamenu.$janchorobj.outerWidth()
		megamenu.anchorheight=megamenu.$janchorobj.outerHeight()
		$j(document.body).append(megamenu.$jmenuobj) //move drop down menu to end of document
		megamenu.$jmenuobj.css("z-index", ++this.zIndexVal).hide()
		megamenu.$jmenuinner.css("visibility", "hidden")
		megamenu.$janchorobj.bind(megamenu.revealtype=="click"? "click" : "mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
			return jkmegamenu.showmenu(e, parseInt(this.getAttribute("_megamenupos")))
		})
		megamenu.$janchorobj.bind("mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			if (e.relatedTarget!=menuinfo.$jmenuobj.get(0) && $j(e.relatedTarget).parents("#"+menuinfo.$jmenuobj.get(0).id).length==0){ //check that mouse hasn't moved into menu object
				menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
					jkmegamenu.hidemenu(e, parseInt(menuinfo.$jmenuobj.get(0).getAttribute("_megamenupos")))
				}, jkmegamenu.delaytimer)
			}
		})
		megamenu.$jmenuobj.bind("mouseenter", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			clearTimeout(menuinfo.hidetimer) //cancel hide menu timer
		})
		megamenu.$jmenuobj.bind("click mouseleave", function(e){
			var menuinfo=jkmegamenu.megamenus[parseInt(this.getAttribute("_megamenupos"))]
			menuinfo.hidetimer=setTimeout(function(){ //add delay before hiding menu
				jkmegamenu.hidemenu(e, parseInt(menuinfo.$jmenuobj.get(0).getAttribute("_megamenupos")))
			}, jkmegamenu.delaytimer)
		})
	} //end for loop
	if(/Safari/i.test(navigator.userAgent)){ //if Safari
		$j(window).bind("resize load", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]
				var $janchorisimg=(megamenu.$janchorobj.children().length==1 && megamenu.$janchorobj.children().eq(0).is('img'))? megamenu.$janchorobj.children().eq(0) : null
				if ($janchorisimg){ //if anchor is an image link, get offsets and dimensions of image itself, instead of parent A
					megamenu.offsetx=$janchorisimg.offset().left
					megamenu.offsety=$janchorisimg.offset().top
					megamenu.anchorwidth=$janchorisimg.width()
					megamenu.anchorheight=$janchorisimg.height()
				}
			}
		})
	}
	else{
		$j(window).bind("resize", function(){
			for (var i=0; i<jkmegamenu.megamenus.length; i++){
				var megamenu=jkmegamenu.megamenus[i]	
				megamenu.offsetx=megamenu.$janchorobj.offset().left
				megamenu.offsety=megamenu.$janchorobj.offset().top
			}
		})
	}
	jkmegamenu.addshim($j)
}

}

jQuery(document).ready(function($j){
	jkmegamenu.render($j)
})

jkmegamenu.definemenu("megaanchor0", "megamenu0", "mouseover");
jkmegamenu.definemenu("megaanchor1", "megamenu1", "mouseover");
jkmegamenu.definemenu("megaanchor2", "megamenu2", "mouseover");
jkmegamenu.definemenu("megaanchor3", "megamenu3", "mouseover");
jkmegamenu.definemenu("megaanchor4", "megamenu4", "mouseover");
