// JavaScript Document

domain_str=location.href

//*************************************SWAP IMAGE**********************************************//
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) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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];}
}

//***************************GENERAL FUNCTIONS ********************************
function getUnit(){
	return document.URL.slice(document.URL.indexOf("unit")+4,document.URL.indexOf("unit")+5);
}

function getBase(){
	return "";
}

//set the target URL of the next and prev activity in the bottom navigation
function setNavigation(){	
	//represent the number of activities in each unit
	var activities = new Array(9,10,10,15,16,14,15,16);
	var hl_alts= new Array("The Family" , "At Home" ,"Friends" , "At school" ,"My Body" , "In the Zoo" ,"Food and Drinks" , "Clothing and Weather" );
	
	var act_alts= new Array();
	act_alts.push(["My Family","The Family Tree","The Monster Home","Meet the Monsters","Color the Picture","True or False","My Day ","I feel happy","Quiz"]);
	act_alts.push(["What's in the house","Who's at home?","Listen, listen","Dress the Snowman","Falling down","Out you go!","Prediction","Story","Things we do","Quiz"]);
	act_alts.push(["Jackie meets a friend","Ask Me a Question","What's in the Classroom?","Going to School","What do you like?","How many syllables?","Opposites","Story: The Big Race","After you Read","Quiz"]);
	act_alts.push(["What's in the bag?" , "Parachutes - Letter Cc" ,"The Classroom - Letter Bb" , "The Classroom - Letter Tt" ,"Word Sort" , "True Or False - Letter Aa" ,"True Or False - Letter Ss" , "Matching - Letter Ee" , "Parachutes - Capital letters" , "Mathing - Letter Ll" , "Trash can monster - Letter Mm" , "Word Machine" , "Memory game" , "My Dictionary" , "Story - Max Is Late For School"]);
	act_alts.push(["Where is everyone?" , "F Monster" ,"Where Is The H?" , "G Memory Game" ,"It's Raining I's" , "Word Machine" ,"True Or False In P" , "Matching N Words" , "ABC In Space" ,"R Is For Race" , "Matching W Words" ,"Letter Tetris" , "Draw A Clown" ,"I Can Read" , "Story - Lazy Jack"]);
	act_alts.push(["Build the Zoo" , "Find the D" ,"Letter Parachute" , "Memory Game" ,"''A'' or ''An'' Bubbles" , "Desert Race" ,"Numbers 1-20" , "Animals Colors and Numbers" , "Matching Opposites" ,"The Safe" , "Comics" ,"Sequencing" , "A Small House" ,"After Story: A Small House" , "Quiz"]);
	act_alts.push(["Max eats Lunch" , "Space Sounds" ," Food machine" , "Spell me" ,"Yummy or Yucky" , "The Food Pyramid " ,"It’s all in the Family." , "What am I?" , "It's time to eat!" ,"My Menu " , "The Little Caterpillar" , "Meet the Caterpillar" ,"Story; The Caterpillar that Wanted to Fly" , "All About the Caterpillar" ,"Quiz"]);
	
	act_alts.push(["At the Shopping Mall" , "About the Mall" ,"At the Mall" , "Color the Clothes" ,"Maze" , "Sorting" ,"Word Machine" , "What am I?" , "The Weather" ,"Magnet poetry" , "My Favorite Season" , "Write a Book!" ,"Prediction" , "Story" ,"After you Read","Quiz"]);


	var currentUnit = getUnit();
	var base = getBase();
	var newAct = 0;
	var currentAct = document.URL.slice(document.URL.indexOf("act_")+4,document.URL.indexOf("act_")+6);

	if(currentAct.charAt(1) == ".")
		currentAct = currentAct.charAt(0);

	
	document.getElementById("unitTitle").src= "images/hl.jpg";
	document.getElementById("unitTitle").style.display="block";
	document.getElementById("unitTitle").alt=document.getElementById("unitTitle").title=hl_alts[currentUnit-1];
	document.getElementById("actTitle").src=base +   "images/hl_"+currentAct+".gif";
	document.getElementById("actTitle").title=document.getElementById("actTitle").alt=act_alts[parseInt(getUnit())-1][currentAct-1];
	document.getElementById("actTitle").style.display="block";
	
	if(currentAct == 1){
		document.getElementById("back").parentNode.href = base +  "";
	}
	else{
		newAct = parseFloat(currentAct)-1;
		if(getUnit()==4 && newAct==14)newAct=13;
		if(getUnit()==2 && newAct==6)newAct=5;
		document.getElementById("back").parentNode.href = base +  "act_" + newAct + ".html";
	}
	
	if(currentAct == activities[currentUnit-1]){
		document.getElementById("fwd").parentNode.href = base + ".";
	}
	else{
		newAct = parseFloat(currentAct)+1;
		if(getUnit()==4 && newAct==14)newAct=15;
		if(getUnit()==2 && newAct==6)newAct=7;
		document.getElementById("fwd").parentNode.href = base +  "act_" + newAct + ".html";
	}
}