/*************************************************************************************************************
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;
    //if (CurrentPage == 11 && MoveTo == 1) {
//        NewPage = parseInt(CurrentPage) + parseInt(2);
//    }
//    else if (CurrentPage == 13 && MoveTo == -1) {
//        NewPage = parseInt(CurrentPage) + parseInt(-2);
//    }
//    else 
	{
        NewPage = parseInt(CurrentPage) + parseInt(MoveTo);
    }
    ItemClicked(NewPage);

    //var NewPage = parseInt(CurrentPage) + parseInt(MoveTo);
    //ItemClicked(NewPage);
}

function ShowNav(){
	// Précédent Link///////////////////////////////////////////////
	if (pageNum != 1){
			document.write("<a class='navlink' href='JavaScript:Navigate(-1,page_curr);' title='Pr&eacute;c&eacute;dent - Ce lien vous am&egrave;ne &agrave; la page pr&eacute;c&eacute;dente.'>Précédent</a>&nbsp; . &nbsp;");
		}
	else{
		document.write("<span class='disabled'>Précédent</span>&nbsp; . &nbsp;");
		}
	//////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////
	// Next Link////////////WAS 72 FS//////////////////////////////////////
	if (pageNum != 47){
			document.write("<a class='navlink' href='JavaScript:Navigate(1,page_curr);' title='Suivant - Ce lien vous am&egrave;ne &agrave; la page suivante.'>Suivant</a>");
		}
	else{
		document.write("<a class='navlink2' href='https://www.voyage.gc.ca/forms_formulaires/STP_GPV/questions.aspx?lang=fra' title='Examen de certification'>Suivant</a>");
		}
	/////////////////////////////////////////////////////////////
}

function ShowNav2(){
	// Précédent Link///////////////////////////////////////////////
	if (pageNum != 1){
			document.write("<a class='navlink2' href='JavaScript:Navigate(-1,page_curr);' title='Pr&eacute;c&eacute;dent - Ce lien vous am&egrave;ne &agrave; la page pr&eacute;c&eacute;dente.'>Précédent</a>&nbsp; . &nbsp;");
		}
	else{
		document.write("<span class='disabled'>Précédent</span>&nbsp; . &nbsp;");
		}
	//////////////////////////////////////////////////////////////	
	//////////////////////////////////////////////////////////////
	// Next Link////////////WAS 72 FS/////////////////////////////////////
	if (pageNum != 47){
			document.write("<a class='navlink2' href='JavaScript:Navigate(1,page_curr);' title='Suivant - Ce lien vous am&egrave;ne &agrave; la page suivante.'>Suivant</a>");
		}
	else{
		document.write("<a class='navlink2' href='https://www.voyage.gc.ca/forms_formulaires/STP_GPV/questions.aspx?lang=fra' title='Examen de certification'>Suivant</a>");
		}
	/////////////////////////////////////////////////////////////
}

function ShowBreadCrumb(){
	var CurrTopic = "";
	var BreadCrumb = "";
	var HomeLink = "<a href='page_01.html' title='Accueil'>Accueil</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='Services consulaires'>Services consulaires</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;}
	else if (pageNum >= 20 && pageNum <= 32) {CurrTopic = "<a href='page_20.html' title='Passeport Canada'>Passeport Canada</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum >= 34 && pageNum <= 39) {CurrTopic = "<a href='page_34.html' title='Avant, pendant et apr&egrave;s le voyage'>Avant, pendant et apr&egrave;s le voyage</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum >= 41 && pageNum <= 43) {CurrTopic = "<a href='page_41.html' title='Pour obtenir de l&rsquo;aide'>Pour obtenir de l&rsquo;aide</a> &nbsp;.&nbsp; " + document.getElementById("h1").innerHTML;;}
	else if (pageNum == 45) {CurrTopic = "<a href='page_45.html' title='R&eacute;sum&eacute; du cours'>R&eacute;sum&eacute; du cours</a>";}
	else if (pageNum == 46) {CurrTopic = "<a href='page_46.html' title='Sources d’information '>Sources d’information</a>";}
	else if (pageNum >= 47) {CurrTopic = "<a href='page_47.html' title='Examen de certification'>Examen de certification</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');	
}
