
/*BEGIN: DROPDOWN MENU*/
//var IsShow = false;
	
var lis = null;
var IsTag1Shown = new Boolean(false);
var IsTag2Shown = new Boolean(false);
var IsTag3Shown = new Boolean(false);
var IsTag4Shown = new Boolean(false);

function handler(event) {
	event.data.foo.css("display","block");
}
function Initialization(){	
	l1s = $("#topdropmenu .L0").find(".L1");
	
	//Initialize menu
	var tts = $("#topdropmenu .L0").find(".TopTag").each(function(i){
		$(this).addClass("tag"+(i+1).toString());
	});

	CalendarPatch();
}

$(document).ready(function(){	
	Initialization();	
	$("#topdropmenu .L0 li .L1hc").mouseover(function(){
		var L2 = $(this).next();
		(L2.css("display") == "none")?L2.css("display","block"):null;
	}).mouseout(function(){
		var L2 = $(this).next();
		(L2.css("display") == "block")?L2.css("display","none"):null;
	});
	$("#topdropmenu .L0 li .L0nc").mouseover(function(){$(this).addClass("active");}).mouseout(function(){				
		$(this).removeClass("active");
	});
	$("#topdropmenu .L0 li .L0hc").mouseover(function(){
		//make all tags to be invisiable first
		l1s.css("display","none");
		
		var L1 = $(this).next();
		var pra = $(this).parent();
		
		if(pra.hasClass("tag1")){			
			IsTag1Shown=true;
			L1.fadeIn(300,function(){
				if(!IsTag1Shown){
					L1.css("display","none");
				}
			});
		}
		if(pra.hasClass("tag2")){
			IsTag2Shown=true;
			L1.fadeIn(300,function(){
				if(!IsTag2Shown){
					L1.css("display","none");
				}
			});
		}
		if(pra.hasClass("tag3")){
			IsTag3Shown=true;
			L1.fadeIn(300,function(){
				if(!IsTag3Shown){
					L1.css("display","none");
				}
			});
		}
		if(pra.hasClass("tag4")){
			IsTag4Shown=true;
			L1.fadeIn(300,function(){
				if(!IsTag4Shown){
					L1.css("display","none");					
				}
			});
		}
		
		//L1.css("display","block");		
		//make the tag to be active
		$(this).addClass("active").find("span").addClass("active");
	}).mouseout(function(){		
		var pra = $(this).parent();
		
		if(pra.hasClass("tag1")){IsTag1Shown = false;}
		if(pra.hasClass("tag2")){IsTag2Shown = false;}
		if(pra.hasClass("tag3")){IsTag3Shown = false;}
		if(pra.hasClass("tag4")){IsTag4Shown = false;}
		
		var L1 = $(this).next();		
		(L1.css("display") == "block")?L1.css("display","none"):null;	
		$(this).removeClass("active").find("span").removeClass("active");
	});	
	
	$("#topdropmenu .L1").mouseover(function(){
		var par = $(this).parent();
		if(par.hasClass("tag1")){IsTag1Shown=true;}
		if(par.hasClass("tag2")){IsTag2Shown=true;}
		if(par.hasClass("tag3")){IsTag3Shown=true;}
		if(par.hasClass("tag4")){IsTag4Shown=true;}
		
		var L1 = $(this);
		(L1.css("display") == "none")?L1.css("display","block"):null;		
		
		L1.prev().addClass("active");		
	}).mouseout(function(){
		var L1 = $(this);
		(L1.css("display") == "block")?L1.css("display","none"):null;
		
		var ahc = L1.prev();
		ahc.removeClass("active").find("span").removeClass("active");
	});	
	
	$("#topdropmenu .L2").mouseover(function(){
		var L1 = $(this).parent().parent();		
		(L1.css("display") == "none")?L1.css("display","block"):null;
		L1.prev().addClass("active");		
		
		var L2 = $(this);
		(L2.css("display") == "none")?L2.css("display","block"):null;		
	}).mouseout(function(){
		var L2 = $(this);
		(L2.css("display") == "block")?L2.css("display","none"):null;	
	});		
});
/*END: DROPDOWN MENU*/
CalendarPatch = function() {
    //Initialize Imm Calendar control
    $(".eventCalendar .eventDetailsHeaders a").each(function() {
        if ($(this).attr("href").indexOf("mailto:") == -1) {
            $(this).attr("target", "_blank");
        } else {
            if ($(this).text().length != 0) { $(this).text("Click here") };
        }
    });

    $(".eventCalendar .eventMonth").filter(function(index) {
        if (index == 0) {
            $(this).parent().addClass("event1stTR");
            return;
        }
    });

    $(".eventCalendar .eventFooter").parent()
		.addClass("eventKeyTR")
		.insertBefore(".event1stTR");
}