$(document).ready(function() {	
	$("#content .barHolder").show(); //Show Banner
	var cnt = $(".statusbar tr").children().size();
	//alert(cnt);
	if(cnt == 2) {
		var loginInfo = $(".statusbar td:eq(2)").html();		
		//alert(loginInfo);
		$("#logoMenu ul").prepend("<li>"+loginInfo+"</li><li><a href=http://globalawakening.com/MyArea/Introduction.aspx>My Area</a></li>");
	}
	else {
		var loginInfo = $(".statusbar td:eq(1)").html();				
		//alert(loginInfo);
		$("#logoMenu ul").prepend("<li>"+loginInfo+"</li><li><a href=http://globalawakening.com/MyArea/Introduction.aspx>My Area</a></li>");
	}
	$(".bar ul li").animate({ opacity: 0.85 }, 1 ); //Set Opacity
	$(".subMenu").animate({ opacity: 0.90 }, 1 ); //Set Opacity
	$("#backgrounds img:first").nextAll().animate({ opacity: 0}, 1 );
	$("#backgrounds img").show();

	//$(".bar ul li:first").addClass('active');
	//$("#backgrounds img:first").addClass('bgactive');
	var menuConfig = {sensitivity: 3,interval: 50, over: openMenu, timeout: 200, out: closeMenu };
	var config = { sensitivity: 3, interval: 100, over: iconOver,timeout: 100, out: iconOut };
	var eeConfig = {sensitivity: 3,interval: 5000,over: showEE, timeout: 200, out: closeMenu};

	function openMenu() {
		if ($(this).parents("li").is(".active")) { 
			return false; 
		} else { 
		var openMenu = $(this).parents("li").find("ul");
		$(".subMenu").animate({ width: "0px" }, 500, "", function(){
			$(this).html("")
			.append(openMenu.clone())
			.animate({ width: "300px" }, 500 )
		});
		}
	}
	function closeMenu() {$(".subMenu").show();}	
	function iconOver(){
		$(this).fadeTo("fast", 1); 
			//Set Variables

		var imgAlt = $(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = $(this).find('img').attr("title"); //Get Main Image URL
		var imgDesc = $(this).find('.block').html(); 	//Get HTML of block
		var imgDescWidth = $(".subMenu").width();	//Calculate width  of block	
		imgTitle = "."+imgTitle;

		if ($(this).is(".active")) { 
			return false; 
		} else { 
			$(".bar ul li").removeClass('active'); //Remove class of 'active' on all lists
			$(this).addClass('active');  //add class of 'active' on this list only
			$(this).fadeTo("fast", 1 );
			$("#backgrounds "+imgTitle).show();
			
			$("#backgrounds .bgactive").animate({opacity: 0}, 500);
			$("#backgrounds "+imgTitle).animate({opacity: 1}, 300);
			$("#backgrounds img").removeClass('bgactive'); //Remove class of 'active' on all lists
			$("#backgrounds "+imgTitle).addClass('bgactive');  //add class of 'active' on this list only
		}
	}
	function iconOut() {return true;	}
   function OnLoad() {
   new CSEOverlay("016151542735505297870:vqodoe4tbrc",document.getElementById("searchbox_016151542735505297870:vqodoe4tbrc"),document.getElementById("results_016151542735505297870:vqodoe4tbrc"));}	
   GSearch.setOnLoadCallback(OnLoad);
   $("#search").append('<form action="" id="searchbox_016151542735505297870:vqodoe4tbrc" class="searchform" onsubmit="return false;"><input type="text" name="q" class="search" size="40"/><input type="submit" class="searchbtn" value="GO"/></form>');
	$(".bar img").hoverIntent(menuConfig);
	$(".bar ul li").hoverIntent(config);
	$("#footerwrapper img").hoverIntent(eeConfig);
	$(".bar ul li").hover(function (){$(this).animate({opacity: 1}, 300);},function () {$(this).animate({opacity: 0.85}, 300);});	
	$(".footerMenu li, .footerMenuRight li").siblings().hover(function (){$("#footerMenuWrapper li").css("background-color","transparent");$(this).css("background-color","#3c74ba");$(this).find("ul").show();},function () {$(this).find("ul").hide();});
	function showEE(){$("#footerwrapper img").dblclick(function(){alert('you found me');});};
	$(".footerMenu li ul li, .footerMenuRight li ul li").hover(function (){$(this).parents("li").css("background-color","#3c74ba");},function () {$(this).show()});
	$(".footerList li").hover(function (){$(this).css("background-color","#3c74ba");},function () {$(this).css("background-color","transparent");});
	$("#footerMenuWrapper").hover(function(){this.show();}, function() {$("#footerMenuWrapper li").css("background-color", "transparent");});
});