<!--
//will contain code to check for javascript/activex/flash/5+ browsers --not working yet


theLevel=0;

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function dosearch(){
}

function fnSendPage(language){
	if (language=="en"){
		addressPrompt="Please enter an email address.";
		senderPrompt="What is your name?";
		messageText="A great link for you"
		contentsText="Have a look at this link: "
	}
	if (language=="cz"){
		addressPrompt="Please enter an email address.[cz]";
		senderPrompt="What is your name?[cz]";
		messageText="A great link for you[cz]"
		contentsText="[cz]Have a look at this link: "
	}
	address=prompt(addressPrompt,"");
	sender=prompt(senderPrompt,"");
	document.all.sendlink.to.value=address;
	if (sender==""){message=messageText;}
	else{message="A great link from "+sender}
	document.all.sendlink.to.subject=message;
	document.all.sendlink.contents.value=contentsText+location.href;
	//alert(document.all.sendlink.to.value);
	document.all.sendlink.submit();
}

function filltotal(){
//;
}

function fnAddToFavorites(){
if (navigator.appName == 'Microsoft Internet Explorer' && parseInt(navigator.appVersion) >= 4)
	{
		thisURL=window.location;
		thisTitle=document.title;
		window.external.AddFavorite(thisURL,thisTitle);
	} 
}

function fnOpenPopupSmall(theFile,theTitle){
	var theURL="popups/"+theFile;
	var theParameters="dependent=yes,directories=no,hotkeys=no,scrollbars=no,width=339,height=410,location=no,menubar=no,resizable=no,screenX=50,screenY=50,titlebar=no,toolbar=no"
	window.open(theURL,theTitle,theParameters);
}

function fnOpenPopup(theFile,theTitle){
	var theURL="popups/"+theFile;
	var theParameters="dependent=yes,directories=no,hotkeys=no,scrollbars=no,width=627,height=410,location=no,menubar=no,resizable=no,screenX=50,screenY=50,titlebar=no,toolbar=no"
	window.open(theURL,theTitle,theParameters);
}

function replaceText(theText){
	//replaces synonyms with the default word. Default word is second in array
	//changes happen to the text in the order of the array
	//see at the top of the array how you can force incorrect changes to be returned as wrong

	synonyms=[

	["do not I","wrong"],
	["apologize","apologise"],
	["accommodations","accommodation"],
	["e-mail","email"],
	["´","'"]
	
	
	
	]
	
	sc=synonyms.length;
	var i=0;
	while (i<sc){
		s1=synonyms[i][0];
		s2=synonyms[i][1];
		eval("var myRegExp=/"+s1+"/g;theStr=theText.replace(myRegExp,\""+s2+"\");");
		theText=theStr;
		i++
	}
	return theText;
	
}


function fnLowercase(str){
	str=str.toLowerCase();
	return str;
}


function replaceSpaces(theText){
	//replaces a series of spaces with a single space
	var s1=""
	var s2=""
	var lastChar=""
	var ch=""
	var c=theText.length
	var i=0
	while(i<c){
		ch=theText.substring(i,(i+1));
		if ((ch==" " && lastChar !=" ")||(ch !=" ")){
			if ((  (ch=="?")||(ch==".")||(ch==",")  )&&(lastChar==" ")){
				s2=s1+ch;
				lastChar=ch;
			}else{
				s1=s2;
				s2=s2+ch;
				lastChar=ch;
			}
		}
		i++
	}
	return s2;
}


//*************COOKIE/LARGER FONTS SCRIPTS START*****************

function refresh() {
window.location.reload()
}

function fnUpdateMasterScores(theLevel){
//used on free worksheet master score libraris - 'beginner_heading.lbi' etc
//only seems to be called when the page first loads
//is there a master score and a master questionNum Total?
masterScoreArray= getCookie("masterScoreArray"+theLevel)

//if not, then set them to 0 and save the master cookie
	if (masterScoreArray==null) {
		var expdate = new Date();
 		expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
		setCookie(("masterScoreArray"+theLevel),"0 0",expdate);
	}
masterScoreArray= getCookie("masterScoreArray"+theLevel)

//otherwise, retrieve these values
mc=masterScoreArray.length
space=masterScoreArray.indexOf(" ")
var masterScore=((masterScoreArray.slice(0,space)).valueOf())*1
var masterQuestionTotal=((masterScoreArray.slice((space+1),(mc))).valueOf())*1

//has this quiz been done before?

//now divide the score by the total and multiply by a 100
	newMasterPercentage=Math.round((masterScore/masterQuestionTotal)*100)

if ((newMasterPercentage+"")=="NaN") newMasterPercentage=0;
	str="document.all."+theLevel+"Score.innerText=newMasterPercentage;";
	eval(str);
}

function getFileName(){
	theURL=window.location;
	theURL=""+theURL+""
	uc=theURL.length
	lastSlash=theURL.lastIndexOf("/")
	filename=theURL.slice((lastSlash+1),uc)
	return filename
}

function fnSaveEeeArray(percentage){
	filename=getFileName();
	//alert(filename);
	if (/on_line_worksheet_/.test(filename)){
		fc=filename.length;
		//firstUnderscore=filename.indexOf("_");
		filename=filename.slice(22,(fc-4));
		
	//alert(filename);
	firstUnderscore=filename.indexOf("_");
	firstNumber=filename.slice(0,(firstUnderscore));
	//alert(firstNumber);
	fc=filename.length;
	lastUnderscore=filename.lastIndexOf("_");
	secondNumber=filename.slice((lastUnderscore+1),fc);
	//alert(secondNumber);
	//the results from the quiz may be used in other levels, 
	//so eeeNumberArray holds all these positions which refer to utems in the eeeScoreArray
	if (secondNumber=="all"){
		secondNumber1=1;
		secondNumber2=2;
		secondNumber3=3;
		eeeNumberArray=[((12*(secondNumber1-1))+(firstNumber*1)),((12*(secondNumber2-1))+(firstNumber*1)),((12*(secondNumber3-1))+(firstNumber*1))];
	}else{
		eeeNumberArray=[((12*(secondNumber-1))+(firstNumber*1))];
	}
	//alert(eeeNumberArray);
	eeeScoreArray= getCookie("eeeScoreArray")

//if not, then set them to 0 and save the eee cookie
	if (eeeScoreArray==null) {
		var expdate = new Date();
 		expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
		setCookie(("eeeScoreArray"),"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",expdate);
	}
	eeeScoreArray= getCookie("eeeScoreArray");
	//now insert the current scores into this string
	
	//get the two chunks on either side of my score
	//get the position of my score by looping through space occurences
	//lastChunk=eeeScoreArray;
	i=0;
	//alert(eeeNumberArray);
	c=eeeNumberArray.length
	//alert("c"+c);
	while (i<c){
		e=eeeNumberArray[i];
		eeeScoreArray=eeeScoreArray.split(" ");//turns the string into a real array
		eeeScoreArray[e-1]=percentage;
		eeeScoreArray=eeeScoreArray.join(" ");//turns array back into string
		i++;
	}
	var expdate = new Date();
 		expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
		setCookie(("eeeScoreArray"),eeeScoreArray,expdate);
	//alert(eeeScoreArray);
	//alert(i+" "+e)
	
	//while (i<e){
	//	c=lastChunk.length
	//	spaceOccurence=lastChunk.indexOf(" ");
		//alert("space found at "+spaceOccurence)
		//alert(lastChunk+" * "+spaceOccurence);
	//	lastChunk=lastChunk.substring(spaceOccurence,(c-spaceOccurence));
		
	//	i++;
	//}
	//alert(lastChunk);
	}
}

function saveAdvancedArray(theURL, score, questionCount, theLevel){
//used for all free worksheets, not just advanced ones!
//saves current score to cookie -- see partner fnUpdateMasterScores whcih reads the cookie
//find quiz code from URL
filename=getFileName();
fc=filename.length
firstUnderscore=filename.indexOf("_")
filename=filename.slice(0,(firstUnderscore))
theURL=filename+theLevel
//is there a master score and a master questionNum Total?
masterScoreArray= getCookie("masterScoreArray"+theLevel)

//if not, then set them to 0 and save the master cookie
	if (masterScoreArray==null) {
		var expdate = new Date();
 		expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
		setCookie("masterScoreArray","0 0",expdate);
	}
masterScoreArray= getCookie("masterScoreArray"+theLevel)

//otherwise, retrieve these values
mc=masterScoreArray.length
space=masterScoreArray.indexOf(" ")
var masterScore=((masterScoreArray.slice(0,space)).valueOf())*1
var masterQuestionTotal=((masterScoreArray.slice((space+1),(mc))).valueOf())*1

//has this quiz been done before?

thisQuizArray=getCookie(theURL)

//if it hasn't, add the new score to the master score
//add the total number of questions to the master questionNum total
//save this page's cookie for future reference
//if it has, subtract the original score form the master score
	if (thisQuizArray==null) {
		masterScore=masterScore+score
		masterQuestionTotal=masterQuestionTotal+questionCount
	}else{
		previousScore=thisQuizArray
		masterScore=masterScore-previousScore+score

	}
	var expdate = new Date();
 	expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	setCookie(theURL,score,expdate);

	var expdate = new Date();
 	expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 
	setCookie("masterScoreArray"+theLevel,(masterScore+" "+masterQuestionTotal),expdate);


//now divide the score by the total and multiply by a 100
	newMasterPercentage=Math.round((masterScore/masterQuestionTotal)*100)
	

	str="document.all."+theLevel+"Score.innerText=newMasterPercentage;";
	eval(str);
}

 function setCookieArray(name){
 var expdate = new Date();
  expdate.setTime (expdate.getTime() +  (24 * 60 * 60 * 1000 * 365)); 

    this.length = setCookieArray.arguments.length - 1;
        for (var i = 0; i < this.length; i++) {
        data = setCookieArray.arguments[i + 1]
        setCookie (name + i, data, expdate);
        }        
    }
  function getCookieArray(name){
    var i = 0;
        while (getCookie(name + i) != null) {
        this[i + 1] = getCookie(name + i);
        i++; this.length = i; 
        }
    }

//*************SAVE COOKIE*****************
function setCookie (name, value, expires) { 

  if (!expires) expires = new Date(); 
    document.cookie = name + "=" + escape (value) + "; expires=" + expires.toGMTString() + "; path=/";  
} 

//*****OPEN COOKIE******
function getCookie (name) { 
   var dcookie = document.cookie; 
   var cname = name + "="; 
   var clen = dcookie.length; 
   var cbegin = 0; 
   while (cbegin < clen) { 
      var vbegin = cbegin + cname.length; 
         if (dcookie.substring(cbegin, vbegin) == cname) { 
         var vend = dcookie.indexOf (";", vbegin); 
         if (vend == -1) vend = clen; 
         return unescape(dcookie.substring(vbegin, vend)); 
      } 
      cbegin = dcookie.indexOf(" ", cbegin) + 1; 
      if (cbegin == 0) break; 
   } return null; 
}


//*************COOKIE SCRIPTS END*****************

//-->