var scourse_sco_pages = total;

function scourse_next_page() {

   var current_page = scourse_get_current_page_num();

   if (current_page != scourse_sco_pages) {
      scourse_goto_page(current_page-(-1));
   }

}



function scourse_prev_page() {

   var current_page = scourse_get_current_page_num();

   if (current_page > 1) {
      scourse_goto_page(current_page-1);
   }

}



function scourse_get_current_page_num() {

   var temp1, temp2, page_num;
   
   current_url = document.location.href;

   temp1 = current_url.lastIndexOf("_") + 2;
   temp2 = current_url.lastIndexOf(".htm");

   temp1 = current_url.substring(temp1,temp2);

   return temp1;

}



function scourse_create_url(new_page_num) {

   var temp1, temp2, new_url;

   current_url = document.location.href;

   temp1 = current_url.lastIndexOf("_") + 2;
   temp2 = current_url.lastIndexOf(".htm");

   new_url = current_url.substring(0, temp1) + new_page_num + current_url.substring(temp2,(current_url.length));

   return new_url;

}



function scourse_goto_page(page) {

   var new_url = scourse_create_url(page);

   document.location.href = new_url;

}



function scourse_create_navigation(bool) {

if (bool) {

	var pageIndex = scourse_get_current_page_num();
	
	var navHTML1 = "";
	var navHTML2 = "";
	var navHTML3 = "";

	var eachWidth = 200/total;
	eachWidth = Math.round(eachWidth);

	if (pageIndex==1) {
		navHTML1 += "<img src='../_common/images/arrow_back_long_gr.gif' width='167' height='20' border='0' alt='button: back, disabled'> ";
	} else {
		navHTML1 += "<a href='" + scourse_create_url(pageIndex-1) + "'><img src='../_common/images/arrow_back_long.gif' width='167' height='20' border='0' alt='button: back'></a> ";
	}

	if (pageIndex==total) {
		navHTML1 += "<img src='../_common/images/arrow_next_long_gr.gif' width='167' height='20' border='0' alt='button: next, disabled'>";
	} else {
		navHTML1 += "<a href='" + scourse_create_url(pageIndex-(-1)) + "'><img src='../_common/images/arrow_next_long.gif' width='167' height='20' border='0' alt='button: next'></a>";
	}
	
	for (var i=1; i<=total; i++) {
		if (i<=pageIndex) {
			navHTML2 += "<a href='" + scourse_create_url(i) + "'><img src='../_common/images/progressFGgrad.gif' height='7' border='0' width='" + eachWidth + "' style='{ margin-right: 1px; }' alt='Page " + i + "'></a>";
		} else {
			navHTML2 += "<a href='" + scourse_create_url(i) + "'><img src='../_common/images/progressBGgrad.gif' height='7' border='0' width='" + eachWidth + "' style='{ margin-right: 1px; }' alt='Page " + i + "'></a>";
		}
	}

	var navHTML3, prevLink, nextLink;

	if (pageIndex==1) {
		prevLink = "Back";
	} else {
		prevLink = "<a href='" + scourse_create_url(pageIndex-1) + "'>Back</a>";
	}
	
	if (pageIndex==total) {
		nextLink = "Next";
	} else {
		nextLink = "<a href='" + scourse_create_url(pageIndex-(-1)) + "'>Next</a>";
	}
	
	navHTML3 = prevLink + " | " + nextLink;	
		

	var layerRef = document.getElementById('navbuttons');
	layerRef.innerHTML = navHTML1;
	
	layerRef = document.getElementById('navcells');
	layerRef.innerHTML = navHTML2;

	layerRef = document.getElementById('bottomnavbar_text');
	layerRef.innerHTML = navHTML3;
	
}

}


