// JavaScript Document
var dicoLoaded = false;
var hasLoaded = false;
var firstTimeLoaded = true;
var ROW_BASE = 1; // first number (for display)
//Variables for the mouse position
var tipPosX;
var tipPosY;
//Variables for the pages navigation
var startwordU = 0;
var wordStart;
var wordEnd;
var nbPages;
var nbViews;
var nbWordsPerPage = 10;
var oriPageInc = 1;
var pageInc = 1;
var nbWords;
var totalWords = nbWordsPerPage;
var firstPage = 1;
var currentPage;
var startWord = 0;
var endWord = startWord + nbWordsPerPage - 1;
var lastPage;
var navBarLoaded = false;
var nbLastWords = nbWordsPerPage;


var NBITEMS = nbitems = 10;
//var NBPAGES = 23;
var currentListItem;
var currentListItemValue;
var firstItemValue;
var next = true;
var prev = false;
var remainingPages; 
var nbitems = NBITEMS;

//Variables for the tables
var wordNb;
var expanded = new Array();
var fwordShow = new Array();
var ewordShow = new Array();
var fexpShow = new Array();
var eexpShow = new Array();
var openAll = true;
var fwordShowAll = false; 
var ewordShowAll = false;
var fexpShowAll = true;
var eexpShowAll = true;
var borderColour = "#66cc33";
var wordRowColour = "#ff6600";
var dropDownPic;
var dropDownPicTitle;
var hidefexpTitle = "Click to show French expressions";
var showfexpTitle = "Click to hide French expresions";
var hidefexpAllTitle = "Click to show French expressions";
var showfexpAllTitle = "Click to hide French expresions";
var hideeexpAllTitle = "Click to show English expressions";
var showeexpAllTitle = "Click to hide English expresions";

var hidefwi = "Hide French words";
var hidefei = "Hide French expressions";
var hideewi = "Hide English words";
var hideeei = "Hide English expressions";
var showfwi = "Show French words";
var showfei = "Show French expressions";
var showewi = "Show English words";
var showeei = "Show English expressions";


var hideeexpTitle = "Click to show English expressions";
var showeexpTitle = "Click to hide English expressions";
var hidefwordTitle = "Click to show French words";
var showfwordTitle = "Click to hide French words";
var hideewordTitle = "Click to show English words";
var showewordTitle = "Click to hide English words";
var hidefwordAllTitle = "Click to show all the French words";
var showfwordAllTitle = "Click to hide all the French words";
var hideewordAllTitle = "Click to show all the English words";
var showewordAllTitle = "Click to hide all the English words";
var plusExpAllTitle = "Click to show all the Expressions";
var minusExpAllTitle = "Click to hide all the Expressions";

var plusPicTitle = "Click to see expressions";
var minusPicTitle = "Click to hide expressions";
var egalPicTitle = "No expressions for this word";
var minusPic = "../images/minus.gif";
var plusPic = "../images/plus.gif";
var egalPic = "../images/egal.gif";
var comment = "../images/comment.gif";
var show = "../images/show.png";
var wordlist;

var wordRowColour1 = '#FFCC00';
var wordRowColour2 = '#FF6600';

function getWordList(){
document.getElementById('waitingBox').style.display = "block";
new Ajax.Request('../jsonphp/dicolist-json.php',
  {
    method:'get',
	parameters: {dummy: new Date().getTime(),  page: 1, startP: 0, endP: nbWordsPerPage - 1, nbwperpage:nbWordsPerPage},
    onSuccess: function(transport){
	  wordlist = transport.responseText.evalJSON() || "no response text";
		hasLoaded = true;
		document.getElementById('waitingBox').style.display = "none";
		//totalWords = wordlist[0]['tw']; nbPages = wordlist[0]['tp'];
		//alert("Total words = " + totalWords + " and nbpages = "+nbPages);
		createWordTables(1, nbWordsPerPage);
		},
    onFailure: function(){ alert('Something went wrong...') }
  });
}



