
function showBanner(){
	$('#customLayer,.bannerTitle img,#bgLayer img').show();
	$('#customLayer,.bannerTitle img,#bgLayer img').removeClass('hidden');
	$('#bgLayer .loading').hide();
}

function initBannerHover(){
  	var cover = $("#transparentLayer .lessonCover");
  	//Show or hide overlay window.
	cover.hover(
		function (){
			for(i=1;i<11;i++){
				if($(this).is(".l"+i)){
					$("#customLayer .l"+i+" .coverImg").removeClass("blurImg");
				}
			}
			var overlay=$(this).find(".lessonOverlay");
			if(!overlay.is(".inited")){
				overlay.html($("#infoBoxTemplate").html().replace("<!--", "").replace("-->","").replace("@@content@@",overlay.html())).addClass("inited");
			}	
			overlay.show();
		},
  		function(){
			$(this).find(".lessonOverlay").hide();
			for(i=1;i<11;i++){
				if($(this).is(".l"+i)){
					$("#customLayer .l"+i+" .coverImg").addClass("blurImg");
				}
			}
		}
  	)

 	// Toggle background of item in menu list.
	$("#featureLessons li").hover( function() {
		$("#featureLessons .hoverBackground").removeClass('hoverBackground');
		$(this).addClass('hoverBackground');
	}, function() {
		$(this).removeClass('hoverBackground');
	});	
}

function loadDemo(lessonId){
	 if (lessonId != "") {
	 	createSWFObject("/lesson_preview_homePage.swf?learningObjectID1="+lessonId, "home_flash", "625", "357", {
	     quality :'high',
	     wmode :'opaque'
   }, {
     allowFullScreen :'true',
     wmode :'transparent'
   }, {
     id :'home_flash'
   });
	 }
}

function loadDemoWithButtonHistory(lessonId,page,feature){
	var timestamp = Date.parse(new Date()); 
	var param = [
 		{ name : 'page', value : page }
		,{ name : 'feature', value : feature}
		,{ name : 'timestamp', value : timestamp}
	];				 
	$.ajax( {
    	type :"post",
    	url :ctx+"/stat/buttonHistory.u",
    	data: param,
    	success : function(msg){
		 	loadDemo(lessonId);
    	},
    	error : function() {		    
	    	loadDemo(lessonId);
		}
	});
}

function showAnimation(){	
	$("#animation").show();
	swfobject.embedSWF(ctx+"/knoodleanimation.swf", "movie", "948", "318", "9.0.0", 
			"expressInstall.swf",
			{wmode :'opaque'},{allowFullScreen :'true',wmode :'transparent'});
	$("#images").hide();
}

function skipAnimation(){
	swfobject.removeSWF("movie");	
	$("#animation").hide();
	$("#animation").append('<div id="movie"></div>');
	$("#images").show();
}

function clipEnd(){
	swfobject.removeSWF("movie");	
	$("#animation").hide();
	$("#animation").append('<div id="movie"></div>');
	$("#images").show();
}

function selectTabHead(objId){
	$(".headTab").each(function(){
		$(".headTab").removeClass("currentHeadTab");
	});
	$("#"+objId).addClass("currentHeadTab");
	
	var url = "";
	if(objId=="tabFLessons")
		url = ctx + "/ajaxGetFeaturedLessons.u";
	else if(objId=="tabRPLessons")
		url = ctx + "/ajaxGetRecentPublishedItems.u";
	
	$.ajax( {
		type :"post",
		url :url,
		success : function(msg){
			$("#lessonList").html(msg);
		},
		error : function() {
			return;
		}
	});	
}