var imagesNormal;
var imagesHilite;

//**************************************************************
// Function: processGo
// 08-06-07 Dave Walker - Process Go button of Country Selector.
//**************************************************************
function processGo()
{
  var f = document.forms[0];
  if (f.countryFinder.selectedIndex > 0)
  {
     var s = f.countryFinder.options[f.countryFinder.selectedIndex].value;
     window.open(s);
  }
}

//**************************************************************
// Function: initPage
// 08-06-07 Dave Walker - Process onLoad of Init Page.
// 02-18-08 Dave Walker - Allow for links for all languages.
//**************************************************************
function initPage()
{
   var ptrLine1, ptrLine2, ptrLT1, ptrLT2, ptrGT1, ptrGT2, ptrHref, ptrComma, ptrDash, ptr1;
   var strHref, strCode, href, strLang, hrefAll, hrefNew;
 
   //Determine which language to display
   hrefAll = window.location.href;

   //Process browser languages
   var inLangs = document.forms[0].strLangs.value;
   ptrComma = inLangs.indexOf(",");
   if (ptrComma == -1)
      ptrComma = inLangs.length;
    strLang = inLangs.substring(0,ptrComma);
    ptrDash = strLang.indexOf("-");
    if (ptrDash != -1)
       strLang = strLang.substring(0,ptrDash);
    strLang = strLang.toLowerCase();
  
    //Process languages allowed on page.
    var elem = document.getElementById("languageSwitcher");
    var temp = elem.innerHTML;
    temp = temp.toLowerCase()

    ptrLine1 = 0;
    ptrLine2 = 0;
    while (ptrLine2 != -1)
    {
       ptrLT1 = temp.indexOf("<a",ptrLine1);
       ptrLine2 = temp.indexOf("|",ptrLine1);
       if (ptrLT1 != -1 && (ptrLT1 < ptrLine2 || ptrLine2 == -1))
       {
          ptrGT1 = temp.indexOf(">",ptrLT1);
          ptrLT2 = temp.indexOf("<",ptrGT1 + 1);
          strHref = temp.substring(ptrLT1+2, ptrGT1-1);
          ptrHref = strHref.indexOf("=");
          href = strHref.substring(ptrHref+2);
          strCode = temp.substring(ptrGT1+1, ptrLT2);
          strCode =strCode.substring(0,2);
        }

        ptrLine1 = ptrLine2 + 1;
       if (strCode == strLang)
        break;
    }
        ptr1 = hrefAll.indexOf("group_");
        hrefNew = hrefAll.substring(0,ptr1-1) + href;
        window.location.href = hrefNew;
}

//**************************************************************
// Function: initLoad
// 06-10-07 Dave Walker - Process onLoad of Jumppage.
//**************************************************************
function initLoad(image1, image2)
{
   var ptrLine1, ptrLine2, ptrLT1, ptrLT2, ptrGT1, ptrGT2, ptrHref, ptrComma, ptrDash, ptr1;
   var strHref, strCode, href, strLang, hrefAll, hrefNew;
 
   //Determine which language to display
   hrefAll = window.location.href;

   if (hrefAll.indexOf("?skip") == -1)
   {
        //Process browser languages
      var inLangs = document.forms[0].strLangs.value;
       ptrComma = inLangs.indexOf(",");
      if (ptrComma == -1)
         ptrComma = inLangs.length;
      strLang = inLangs.substring(0,ptrComma);
      ptrDash = strLang.indexOf("-");
      if (ptrDash != -1)
        strLang = strLang.substring(0,ptrDash);
      strLang = strLang.toLowerCase();
  
      //Process languages allowed on page.
      var elem = document.getElementById("languageSwitcher");
      var temp = elem.innerHTML;
      temp = temp.toLowerCase()

      ptrLine1 = 0;
      ptrLine2 = 0;
      while (ptrLine2 != -1)
      {
         ptrLT1 = temp.indexOf("<a",ptrLine1);
         ptrLine2 = temp.indexOf("|",ptrLine1);
         if (ptrLT1 != -1 && (ptrLT1 < ptrLine2 || ptrLine2 == -1))
         {
            ptrGT1 = temp.indexOf(">",ptrLT1);
            ptrLT2 = temp.indexOf("<",ptrGT1 + 1);
            strHref = temp.substring(ptrLT1+2, ptrGT1-1);
            ptrHref = strHref.indexOf("=");
            href = strHref.substring(ptrHref+2);
            strCode = temp.substring(ptrGT1+1, ptrLT2);
            strCode =strCode.substring(0,2);
         }

         ptrLine1 = ptrLine2 + 1;
      }

      if (strCode == strLang)
      {
          ptr1 = hrefAll.indexOf("group_");
          hrefNew = hrefAll.substring(0,ptr1-1) + href;
          window.location.href = hrefNew;
      }
   }
   loadImages(image1, image2);
}

function loadImages(image1, image2)
{  
   if (document.images)
   {
          imagesNormal = new Object();
          imagesNormal["visit"] = new Image;
          imagesNormal["visit"].src = image1;
          imagesHilite = new Object();
          imagesHilite["visit"] = new Image;
          imagesHilite["visit"].src = image2;
    }
}

function setImage(imgName, type)
{
   if (document.images)
   {
       if (type == "hilite")
       {
           document.getElementById(imgName).src = imagesHilite[imgName].src;
           return true;
       }
       else if (type == "normal")
       {
            document.getElementById(imgName).src = imagesNormal[imgName].src;
            return true;
        }
   }
   return false;
}