function isDigit (c)
{   
  return ((c >= "0") && (c <= "9"))
}

function isEmpty(s)
{   
  return ((s == null) || (trim(s.length) == 0))
}

function lTrim(str)
{
  var whitespace = new String(" \t\n\r");
  var s = new String(str);

  if (whitespace.indexOf(s.charAt(0)) != -1) {
    var j=0, i = s.length;

    while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
      j++;
    s = s.substring(j, i);
  }

  return s;
}

function rTrim(str)
        
{
  var whitespace = new String(" \t\n\r");

  var s = new String(str);

  if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
    var i = s.length - 1;       // Get length of string
    while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
      i--;

    s = s.substring(0, i+1);
  }

  return s;
}


function trim(str) {
  return lTrim(rTrim(str));
}

function getRadioValue(radio)
{
  for (var i=0; i < radio.length; i++)
   {
   if (radio[i].checked)
      {
        return radio[i].value;
      }
   }
   return "";
}

function isValidSSN(sSSN)
{
  re1 = new RegExp("^[0-9]{9}$");
  re2 = new RegExp("^[0-9]{3}\-[0-9]{2}\-[0-9]{4}$");
  return (re1.test(sSSN) || re2.test(sSSN));
}

function showLayer(layername){
  document.all[layername].style.display="inline";
}

function hideLayer(layername){
  document.all[layername].style.display="none";
}

function one2two() 
{
  m1len = m1.length ;
  for ( i=0; i<m1len ; i++)
  {
    if (m1.options[i].selected == true ) 
    {
      m2len = m2.length;
      m2.options[m2len]= new Option(m1.options[i].text);
      m2.options[m2len].value = m1.options[i].value;
    }
  }

  for ( i = (m1len -1); i>=0; i--){
    if (m1.options[i].selected == true ) 
    {
      m1.options[i] = null;
    }
  }
}

function two2one() 
{
  m2len = m2.length ;
  for ( i=0; i<m2len ; i++){
    if (m2.options[i].selected == true ) {
      m1len = m1.length;
      m1.options[m1len]= new Option(m2.options[i].text);
      m1.options[m1len].value = m2.options[i].value;
    }
  }
  for ( i=(m2len-1); i>=0; i--) {
    if (m2.options[i].selected == true ) {
      m2.options[i] = null;
    }
  }
}

function selectAllInListBox(listbox)
{
  listboxlen = listbox.length;
  for (i=0; i<listboxlen; i++)
  {
    listbox.options[i].selected=true;
  }
  return true
}

function isValidName(sName, isRequired)
{
  var isReq = true;
  if (isValidName.arguments.length == 2)
  {
    isReq = isRequired[1];  
  }
  re = new RegExp("^[A-Za-z]+[A-Za-z ,'\-]*");  
  if (!isReq && isEmpty(sName))
    return true;
  else 
    return (re.test(sName));
}

function isValidCompanyName(sName, isRequired)
{
  var isReq = true
  if (isValidCompanyName.arguments.length == 2)
    isReq = isRequired;
  re = new RegExp("^[A-Za-z0-9]+[A-Za-z ,'\-]");
  if (!isReq && isEmpty(sName))
      return true;
  else {
    return (re.test(sName));
  }
}

function isValidUSZip(sZip)
{
  re = new RegExp("^[0-9]{5}(\-[0-9]{4})?$");
  return (re.test(sZip));
} 

function isValidZip(sZip)
{
//  re = new RegExp("^[0-9]{1}[0-9\-]{0,9}");
	re = new RegExp("^[0-9A-Za-z \-]{1,9}");
  return (re.test(sZip));
}

function isInteger (s)
{   
  var i;
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if (!isDigit(c)) return false;
  }
  return true;
}

function isFloat (s)
{   
  var i;
  var seenDecimalPoint = false;
  if (s == ".") 
    return false;
  for (i = 0; i < s.length; i++)
  {   
    var c = s.charAt(i);
    if ((c == ".") && !seenDecimalPoint) 
      seenDecimalPoint = true;
    else if (!isDigit(c)) 
      return false;
  }
  return true;
}

function isValidEmail(sStr, isRequired)
{
  var isReq = true
  if (isValidEmail.arguments.length == 2)
    isReq = isRequired;
//  re = new RegExp("^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$");
//  re = new RegExp("^([a-zA-Z0-9]+[a-zA-Z0-9_\.\-]*)\@(([a-zA-Z0-9_\-\.])+\.)+([a-zA-Z0-9]{2,4})+$");
  if (!isReq && isEmpty(sStr)) 
  	return true;
  else
  {
	    if (sStr.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)
	        return false;
	    else
	        return true;  
	}
}
function isValidURL(sStr)
{
  re = new RegExp("^(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+(/((~)*[a-zA-Z0-9]+)*)*")
  
  //re = new RegExp("^\\w[\\w.]+[a-zA-Z]{2,3}[\\w.~/]*$");
  return (re.test(sStr));  
}

function isValidUSPhone(sNum, isRequired)
{
  var isReq = true
  if (isValidUSPhone.arguments.length == 2)
    isReq = isRequired;
  if (!isReq && isEmpty(sNum))
    return true;
  else
  {
    re1 = new RegExp("^[0-9]{10,11}$");
    re2 = new RegExp("^[0-9]{3}\-[0-9]{3}\-[0-9]{4}$");
    return (re1.test(sNum) || re2.test(sNum));
  }
}

function isValidPhone(sNum, isRequired)
{
  var isReq = true
  if (isValidPhone.arguments.length == 2)
    isReq = isRequired;
  if (!isReq && isEmpty(sNum))
    return true;
  else
  {
    re1 = new RegExp("^[0-9](\-*[0-9])*$");
    return (re1.test(sNum));
  }
}

function getImageNames()
{
  var imgId1, imgId2, imgId3;
  var min_wall1, min_wall2, min_wall3, max_wall1, max_wall2, max_wall3;
  min_wall1 = 1;
  min_wall2 = 1;
  min_wall3 = 1;
  max_wall1 = 10;
  max_wall2 = 13;
  max_wall3 = 5;
  
  diff = max_wall1 - min_wall1 + 1;
  imgId1=Math.floor(min_wall1+(diff*Math.random()));
  
  diff = max_wall2 - min_wall2 + 1;
  imgId2=Math.floor(min_wall2+(diff*Math.random()));

  diff = max_wall3 - min_wall3 + 1
  imgId3=Math.floor(min_wall3+(diff*Math.random()));
  
  var rnd1, rnd2, rnd3
  rnd1 = Math.floor(1+(3*Math.random()));
  do 
  {
    rnd2 = Math.floor(1+(3*Math.random()));
  }
  while (rnd1 == rnd2)
  
  do 
    {
      rnd3 = Math.floor(1+(3*Math.random()));
    }
  while (rnd3 == rnd2 || rnd3 == rnd1)
  imgNames = new Array();
  imgNames[rnd1] = "images/com_pic" + imgId1 +".gif";
  imgNames[rnd2] = "images/obj_pic" + imgId2 +".gif";
  imgNames[rnd3] = "images/ind_pic" + imgId3 +".gif";
  
  return (imgNames);
  
}

function gotoLang(lang)
{
  if (lang == "French")
    location.href = 'french/index.htm';
  else if (lang == "German")
    location.href = 'german/index.htm';
  else if (lang == "Italian")
    location.href = 'italian/index.htm';
  else if (lang == "Portuguese")
    location.href = 'portuguese/index.htm';
  else if (lang == "Spanish")
    location.href = 'spanish/index.htm';
  else if (lang == "US English")
    location.href = 'index.htm';
}

function gotoLang1(lang)
{
  if (lang == "French")
    location.href = '../french/index.htm';
  else if (lang == "German")
    location.href = '../german/index.htm';
  else if (lang == "Italian")
    location.href = '../italian/index.htm';
  else if (lang == "Portuguese")
    location.href = '../portuguese/index.htm';
  else if (lang == "Spanish")
    location.href = '../spanish/index.htm';
  else if (lang == "US English")
    location.href = '../index.htm';
}

function getImageNames1()
{
  var imgId1, imgId2, imgId3;
  var min_wall1, min_wall2, min_wall3, max_wall1, max_wall2, max_wall3;
  min_wall1 = 1;
  min_wall2 = 1;
  min_wall3 = 1;
  max_wall1 = 10;
  max_wall2 = 13;
  max_wall3 = 5;
  
  diff = max_wall1 - min_wall1 + 1;
  imgId1=Math.floor(min_wall1+(diff*Math.random()));
  
  diff = max_wall2 - min_wall2 + 1;
  imgId2=Math.floor(min_wall2+(diff*Math.random()));

  diff = max_wall3 - min_wall3 + 1
  imgId3=Math.floor(min_wall3+(diff*Math.random()));
  
  var rnd1, rnd2, rnd3
  rnd1 = Math.floor(1+(3*Math.random()));
  do 
  {
    rnd2 = Math.floor(1+(3*Math.random()));
  }
  while (rnd1 == rnd2)
  
  do 
    {
      rnd3 = Math.floor(1+(3*Math.random()));
    }
  while (rnd3 == rnd2 || rnd3 == rnd1)
  imgNames = new Array();
  imgNames[rnd1] = "../images/com_pic" + imgId1 +".gif";
  imgNames[rnd2] = "../images/obj_pic" + imgId2 +".gif";
  imgNames[rnd3] = "../images/ind_pic" + imgId3 +".gif";
  
  return (imgNames);
  
}


