// This file contains scripts for controlling text inserted into the "Words" page

// global variables
var page_info_array = new Array();  // contains image information for updating the "Words" document window
var page_index=0;
var max_page_count = 8;

//-----------------------------------------------------
// HTML Page Control Functions for "Word" files
//

// update the Word file when '<' or '>' is clicked
function updatePage(){

var page_src = "";
var desc_src = "";

	if(page_index >= max_page_count) return;
	
	page_src = page_info_array[page_index].path;
	desc_src = page_info_array[page_index].desc;
	
	$('iframe#wframe').attr('src',page_src);
	$('iframe#tframe').attr('src',desc_src);
}

// update the Word file when '<' or '>' is clicked
function goToMainWordPage(){

var desc_src = "";

	document.getElementById("wframe").style.visibility = "hidden";
	desc_src = "word_text/main_words_text.html";
	page_index = 0;
	
	$('#tframe').attr('src',desc_src);
}



//------------------------------------------------------

// initialization and event functions
$(document).ready(function(){
				   
	loadPages();
	
	document.getElementById("wframe").style.visibility = "hidden";	
	
	// event handler for showing next page (">")	
	$("a#a2").click(function(){
		
		if(page_index == 0){
			document.getElementById("wframe").style.visibility = "visible";	
			page_index=page_index+1;
			updatePage();
			return;
		}
								   
		if(page_index<max_page_count-1)
		{
			page_index=page_index+1;
			updatePage();
		}
		
	 } // end click function
	); // end click
	
	
	// event handler for showing prev page ("<")	
	$("a#a1").click(function(){
	
		if(page_index == 1){
			goToMainWordPage();
		}
								  
		if(page_index>0)
		{
			page_index=page_index-1;
			updatePage();
		} 		
	 } // end click function
	); // end click
	
	
	}); // end ready function






