var currentPage, currentTopic, totalPages, totalTopics, sndSrc, prevPage, prevTopic;
var nextEnable, backEnable;
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}

function Set_Cookie(name,value,expires,path,domain,secure) {

    document.cookie = name + "=" +escape(value) +
       ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") + 
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}


function init()
{
	currentPage=1;
	currentTopic=0;	
	totalPages = nop_chap[currentTopic];	
	totalTopics = nop_chap.length;	
	nextEnable=true;
	backEnable=false;
	prevPage=1;
	prevTopic=1;
	openPage();
}

function openPage()
{
	parent.parent.data.currentTopic = currentTopic;
	parent.parent.data.currentPage = currentPage;
	
	if (currentTopic==0 && currentPage==1)
	{
		backNor.style.visibility="hidden";
		backDis.style.visibility="visible";
		dirText.innerHTML = "Click <b>Next</b> to begin.";
	}
	else if (currentTopic==1 && currentPage==nop_chap[1])
	{
		dirText.innerHTML = "";
		backnone.style.visibility="visible";
		nextnone.style.visibility="visible";
		nodot.style.visibility="visible";
	}
	else
	{
		backNor.style.visibility="visible";
		backDis.style.visibility="hidden";
		dirText.innerHTML = "Click <b>Next</b> to continue.";
	}

	source="t"+currentTopic+"p"+currentPage+".htm";
	parent.mainFrame.location=source;
}

function DisableBack()
{
	
}


function next()
{	
		currentPage++;
		if(currentPage == totalPages + 1)
		{
			currentTopic++;
 			currentPage = 1;
			totalPages = nop_chap[currentTopic];
		}
		if(currentTopic == totalTopics)
		{
			currentTopic = 0;
			currentPage = 1;
			totalPages = nop_chap[currentTopic];
		}
		openPage();
}

function back()
{
	currentPage--;
	if(currentPage == 0)
	{
		currentTopic--;
		totalPages= nop_chap[currentTopic];
		currentPage = totalPages;
	}
	openPage();
}

function openForMenu(topic, page)
{
		
		currentPage=page;
		currentTopic=topic;
		totalTopics = nop_chap.length;
		totalPages=nop_chap[currentTopic];
		openPage();
}
function openMenu()
{
	if(menuEnable)
	{
		prevPage=currentPage;
		prevTopic=currentTopic;
		currentPage=0;
		currentTopic=0;
		totalPages = nop_chap[currentTopic];
		openPage();
	}
}
function returnFromMenu()
{
	currentPage=prevPage;
	currentTopic=prevTopic;
	totalPages=nop_chap[currentTopic];
	prevPage=1;
	prevTopic=0;
	openPage();

}
function exit()
{
	if (confirm("Please click \"OK\" to exit the course or click \"Cancel\" to continue the course."))
	{
//		var exitpage="t"+currentTopic+"p"+currentPage+".htm";
//	  	parent.parent.sco_exit(exitpage);
//	  	parent.parent.sco_exitCourseRqstHandler();
		top.close();
	}
}

function popupWin(url, name1) 
{
		settings="fullscreen=no,toolbar=no,titlebar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+popupWidth+",height="+popupHeight+",left=130,top=60"; 
		MyNewerWindow=window.open(url,name1,settings);
		MyNewerWindow.focus();

}
function openDisclaimer()
 {
	discl.style.visibility = "visible";
	discl.style.top = (600 - 450) / 2;
	discl.style.left = (800-600) / 2;
 }
function closeDisclaimer()
 {
	discl.style.visibility = "hidden";
 }
function setPageNo()
{
		document.getElementById("numbering").style.visibility = "visible";
		document.getElementById("numbering").innerHTML = 'Page  '+ currentPage+' of '+totalPages;
}
function setPageTitle()
{
	parent.topFrame.document.getElementById("tHeading").innerHTML = topicInfo[currentTopic];
}
function disableImage(imgID)
{
	document.getElementById(imgID).style.visibility="hidden";
	document.getElementById(imgID+'l').style.cursor="default";
}

function enableImage(imgID)
{
	document.getElementById(imgID).style.visibility="visible";
	document.getElementById(imgID+'l').style.cursor="hand";
}
	


function sPopup(url, w,h,scroll)
{
	l = (screen.width - w)/2;
	t = (screen.height - h)/2;
	//t=t-10;
	temptext = url.substring(0,5)
	if(temptext=="gloss")
	{
		t=t-20;
	}
	if(scroll == true)
		settings="toolbar=no,status=no,scrollbars=yes,left="+l+",top="+t+",width="+w+",height="+h;
	else
		settings="toolbar=no,status=no,scrollbars=no,left="+l+",top="+t+",width="+w+",height="+h;

	window.open(url,"",settings);
}


function toggleSound()
{
	if(parent.data.audioOn)
	{
		document.getElementById("LaudioOff").style.visibility="hidden";
	}
	else
	{
		document.getElementById("LaudioOff").style.visibility="visible";
	}
	parent.data.audioOn = !parent.data.audioOn; 
}


function stopPageAudio()
{
	//alert("ash");
	document.snd.stop();
}

function pageMenu(page_num)
{
	currentPage=page_num;
	openPage();
}

function lesson(lesson_num)
{
	currentPage=1;
	currentTopic=lesson_num;
	openPage();
}

