// Image swap code

one=null;
two=null;
three=null;
four=null;
five=null;
six=null;
seven=null;
eight=null;
nine=null;
ten=null;
eleven=null;
twelve=null;
thirteen=null;
fourteen=null;
	
function off_image(img) { }
function on_image(loc, img) {  }

menuImages = new Array(28)

for (i = 1; i <= 28; i++)
{
 	menuImages[i] = new Image(20,20)
	menuImages[i].src = "http://www.edlingua.com/edlingua/navbar/button"+i+".gif"
}

function on_image(loc, img)
{
   loc.src=menuImages[img].src;
}

function off_image(loc, img) 
{
   loc.src=menuImages[img].src;
}

// End of image swap code


// Random image: Image tag generator


// Picture image open function.

function openPic(imgFile,imgWidth,imgHeight,imgAlt) {
		 var theLink = 'http://www.edlingua.com/edlingua/picture.php?jpgFile='
		 	 + imgFile + '&picWidth=' + imgWidth + '&picHeight=' + imgHeight + 
			 '&picAlt=' + imgAlt;
		 var winWidth = imgWidth + 30;
		 if (winWidth < 400) { winWidth = 400; }
		 var winHeight = imgHeight + 180;
		 var winSize = "width=" + winWidth + ",height=" + winHeight;
		 window.open(theLink,'',winSize);
		 }

// End of picture open function


// Translator execute

function Translate(FormName,StartName,TargetName,TheWord)
{
   var StartLang      = document.forms[FormName].elements[StartName];
   var TargetLang	  = document.forms[FormName].elements[TargetName];
   var TheWordElement = document.forms[FormName].elements[TheWord];

   thePage =  'dictionary.php?startlang='+StartLang.value+'&targetlang=';
   thePage += TargetLang.value+'&theword='+TheWordElement.value;
  
  if (TheWordElement.value.length == 0)
  { 
  	 alert('Please enter a word to translate.')
  	 TheWordElement.focus()
  }
  else
  {
   	  window.location = thePage;
  }
}

// End of translator execute function


// Email form field validity checker

function IsEmailValid(FormName,MailElement)
{ 
   var EmailOk = true
   var TheMailElement = document.forms[FormName].elements[MailElement]

   var AtSym = TheMailElement.value.indexOf('@')
   var Length = TheMailElement.value.length - 1   // Array is from 0 to length-1
  
   // Check a valid e-mail address has been entered
   if ((AtSym < 1)  ||	(AtSym == Length)) // '@' cannot be in first or last position.
   { 
   	  EmailOk = false
   	  alert('You must enter a valid E-Mail address.')
   	  TheMailElement.focus()
   }
   return EmailOk
}

// End of Mail form validity checker


// Blank form field checker

function IsElementBlank(FormName,ElementName)
{
   var ElementOk = true
   var TheElement = document.forms[FormName].elements[ElementName]
   
   // Check the field hasn't been left blank
   if (TheElement.value.length == 0)
   { 
   	  ElementOk = false
   	  alert('You must enter some text in the ' + ElementName + ' box.')
   	  TheElement.focus()
   }
   return ElementOk
}

// End of Blank form field checker function


// Mail form check and submit function

function IsFormValid(FormName,EmailElement,SubjectElement,MessageElement)
{ 
   var FormOk = true
   var EmailField = IsEmailValid(FormName,EmailElement)
   
   if (EmailField == false)
   {
   	  FormOk = false;
   	  return FormOk;
   }
   
   var SubjectField = IsElementBlank(FormName,SubjectElement)
   if (SubjectField == false)
   {
   	  FormOk = false;
   	  return FormOk;
   }
   
   var MessageField = IsElementBlank(FormName,MessageElement)
   if (MessageField == false)
   {
   	  FormOk = false;
   	  return FormOk;
   }
   
   if (FormOk == true)
   { 
   	  document.forms[FormName].submit();
   	  return FormOk;
   }
}

// End of Mail form check and submit function