	var delay = 1000;    //1000 ~ 1 second
	var duration = 15;    //15 seconds
	var timerRunning = false;
	var timerId = null;
	var userClicked = false;
	
	var speed = 600;	
	
	function hideAd() {			
		//$("#blackout").fadeOut(speed);	
		$("#blackout").animate({opacity:0},speed);
		$("#blackout").hide();
		$("#divpopup").fadeOut(speed);	
		$(document.body).css("overflow","visible");
	}
	
	function showAd() {					
		$("#blackout").show();
		$("#blackout").animate({opacity:0.8},speed);
		$("#divpopup").fadeIn(speed);		
		if($.browser.msie)
			$(document.body).css("overflow","hidden");
	}
	
	function stopTimer() {		
		if(timerRunning) {
			clearTimeout(timerId);					
		}
		timerRunning = false;			
	}
	
	function startTimer() {
		if(duration == 0) {    			
			stopTimer();
			
			hideAd();						
		}
		else {
			var count = document.getElementById("count");
			count.firstChild.nodeValue -= 1;
			
			duration -= 1;
			timerRunning = true;
			timerId = self.setTimeout("startTimer()",delay);
		}
	}
	
	function hide() {				
		//Stop the timer
		stopTimer();			
		hideAd();
		userClicked = true;
	}
	
	function show() {
		duration = 15;
		stopTimer();
		$("#count").text(15);
		showAd();
		startTimer();
	}
	
	
function unhide(divID) {
    var item = document.getElementById(divID);
    var hint = document.getElementById(divID + "_hint");
    if (item) {
        if(item.className == 'hidden') {
          item.className = 'unhidden';
		   /*hint.firstChild.nodeValue = "<img src='../images/open.gif'>";*/
         hint.firstChild.nodeValue = '(click to minimize chapter list)';
        }
        else {
          item.className = 'hidden';
          /*hint.firstChild.nodeValue = "<img src='../images/closed.gif'>";*/
          hint.firstChild.nodeValue = '(click to expand chapter list)';
        //item.className=(item.className=='hidden')?'unhidden':'hidden';
        }
    }
}

function bottomSect(){
	
	document.write('&copy; Copyright 2009. Blue Orange Pte Ltd');
}

function helpSect(x){
	
	if(x=="1")
	{
		document.write('<p class="marTop"><img src="images/help_icon.jpg" width="18" height="18" align="absmiddle" /> &nbsp;Click on the links below to go into the corresponding chapters</p>');
	}
	else
	{
	document.write('<p class="marTop"><img src="images/help_icon.jpg" width="18" height="18" align="absmiddle" /> &nbsp;Click on the links below to play the videos</p>');
	}
	
}

