/*************************************************************************************************************
Bluedrop Performance Learning
David Stokes
Navigation System
*************************************************************************************************************/
//Set page functions ---------------------------------------------------------------------
var page_curr = getNumber(this.location.href);
var pageNum = parseFloat(page_curr);
//Returns path
function getPath(URL) {
   var result = unescape(URL.substring(0,(URL.lastIndexOf("/"))+1))
   return result
}
//Returms filename
function getPage(URL) {
   var length = URL.length
   var result = unescape(URL.substring((URL.lastIndexOf("/"))+1,(URL.lastIndexOf("_"))))
   return result
}
//Returns the number in the filename
function getNumber(URL) {
   var result = parseFloat(URL.substring((URL.lastIndexOf("_"))+1,(URL.lastIndexOf("."))))
   return result
}

//This function converts numbers to strings
function ConvertNumToString(Num){
	return ("" + Num);
}

//This function prefixes strings with the correct # of 0's
function ZeroFill(Num, Digits){     
	var NewNum = ConvertNumToString(Num); 
	while (NewNum.length < Digits)
	NewNum = "0" + NewNum;
	return NewNum;
}

//This function handles the setting the navigation buttons.  
function ItemClicked(PageNum){
	var NewPageNum = ZeroFill(PageNum, 2); //2 equals # of digits 
	var PageHref = "page_" + NewPageNum + ".html"; //builds the filename
	this.location.href = PageHref; //changes location of the RBCContent frame
}

// Move relative to the current slide 
function Navigate(MoveTo,CurrentPage){
	var NewPage = parseInt(CurrentPage) + parseInt(MoveTo);
	ItemClicked(NewPage);
}

function ShowNav(){
	// Previous Link///////////////////////////////////////////////
	if (pageNum != 1){
			document.write("<a class='navlink' href='JavaScript:Navigate(-1,page_curr);' title='Previous - This link goes to the previous page.'>Previous</a>&nbsp; . &nbsp;");
		}
	else{
		document.write("<span class='disabled'>Previous</span>&nbsp; . &nbsp;");
		}
	//////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////
	// Next Link///////////WAS 72 FS///////////////////////////////////////
	if (pageNum != 46){
			document.write("<a class='navlink' href='JavaScript:Navigate(1,page_curr);' title='Next - This link goes to the next page.'>Next</a>");
		}
	else{
		document.write("<span class='disabled'>Next</span>");
		}
	/////////////////////////////////////////////////////////////
}

function ShowNav2(){
	// Previous Link///////////////////////////////////////////////
	if (pageNum != 1){
			document.write("<a class='navlink2' href='JavaScript:Navigate(-1,page_curr);' title='Previous - This link goes to the previous page.'>Previous</a>&nbsp; . &nbsp;");
		}
	else{
		document.write("<span class='disabled'>Previous</span>&nbsp; . &nbsp;");
		}
	//////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////
	// Next Link/////////WAS 72 FS/////////////////////////////////////////
	if (pageNum != 45){
			document.write("<a class='navlink2' href='JavaScript:Navigate(1,page_curr);' title='Next - This link goes to the next page.'>Next</a>");
		}
	else{
		document.write("<span class='disabled'>Next</span>");
		}
	/////////////////////////////////////////////////////////////
}

function ShowBreadCrumb(){
	var CurrTopic = "";
	var BreadCrumb = "";
	var HomeLink = "<a href='page_01.html' title='Home'>Home</a> &nbsp;.&nbsp; ";
	if (pageNum <= 2) {CurrTopic = "<a href='page_01.html' title='Introduction'>Introduction</a>";}
	else if (pageNum >= 3 && pageNum <= 18) {CurrTopic = "<a href='page_03.html' title='Consular Services'>Consular Services</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;}
	else if (pageNum >= 19 && pageNum <= 32) {CurrTopic = "<a href='page_19.html' title='Passport Canada'>Passport Canada</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum >= 33 && pageNum <= 39) {CurrTopic = "<a href='page_33.html' title='Before, During and After a Trip'>Before, During and After a Trip</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum >= 40 && pageNum <= 43) {CurrTopic = "<a href='page_40.html' title='When Help is Required'>When Help is Required</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum == 44) {CurrTopic = "<a href='page_44.html' title='Course Summary'>Course Summary</a>";}
	else if (pageNum == 45) {CurrTopic = "<a href='page_45.html' title='Resources'>Resources</a>";}
	else if (pageNum >= 46) {CurrTopic = "<a href='page_46.html' title='Certification Assessment'>Certification Assessment</a>";}
	else {CurrTopic = ""};	
	BreadCrumb = HomeLink + CurrTopic;
	document.getElementById("breadcrumbs").innerHTML = BreadCrumb;
}

////////////////////////////Popups//////////////////////////////
function show(value) {
	   document.getElementById(value).style.display = 'block'; 
}
function hide(value) {
	for (var x = 0; x < value; x++) {
		var popup = "popup"+(x+1);
		document.getElementById(popup).style.display = 'none';
	}
}
function PopWindow(location){
	//Opens a new window
	window.open(location,'NewWin','width=600,height=500,left=0,top=0,titlebar=No,toolbar=No,location=No,scrollbars=Yes,menubar=No,directories=No,status=No,resizable=No,fullscreen=No');	
}