//Sets a specified image to a random image
var iHPImgIndex = 0;
var iHPImgMax = 11;
var iHPImgDelay = 5000;

function PageLoad()
{ 

  HPChangeImage();
  
}

function HPChangeImage()
{
  iHPImgIndex = iHPImgIndex + 1;
  if (iHPImgIndex > iHPImgMax)
  {
    iHPImgIndex = 1;
  }
  
  // Change the image
  document.getElementById("hpimgspot").src = "images/homeimg/hpimg_" + iHPImgIndex + ".jpg"
  
  setTimeout("HPChangeImage()", iHPImgDelay);
}

function SetFocus()
{
  document.getElementById("GoToWebSiteForm").GoToWebSiteText.focus();
}

function GoToSearchSite(sSearchID)
{
  var sLocation;

  switch(document.getElementById(sSearchID + "Combo").value)
  {
    //MADCAT Web Site All Words
    case("wb_all"):
    {
      document.getElementById("Google").action = "search.aspx";
      document.getElementById("Google").SearchType.value = 0;
      document.getElementById("Google").SearchCriteria.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //MADCAT Web Site Any Words
    case("wb_any"):
    {
      document.getElementById("Google").action = "search.aspx";
      document.getElementById("Google").SearchType.value = 1;
      document.getElementById("Google").SearchCriteria.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //MADCAT Web Site Phrase
    case("wb_phrase"):
    {
      document.getElementById("Google").action = "search.aspx";
      document.getElementById("Google").SearchType.value = 2;
      document.getElementById("Google").SearchCriteria.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //Google
    case("goo"):
    {
      //sLocation = "http://www.google.com.au";
      //sLocation = sLocation + "/search?hl=en&q=" + document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").action = "http://www.google.com.au/search";
      document.getElementById("Google").q.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //Google Australia
    case("goo_au"):
    {
      //sLocation = "http://www.google.com.au";
      //sLocation = sLocation + "/search?hl=en&meta=cr%3DcountryAU&q=" + document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").action = "http://www.google.com.au/search";
      document.getElementById("Google").meta.value = "cr=countryAU";
      document.getElementById("Google").q.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //Google Groups
    case("goo_gps"):
    {
      //sLocation = "http://www.google.com.au";
      //sLocation = sLocation + "/groups?hl=en&q=" + document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").action = "http://www.google.com.au/groups";
      document.getElementById("Google").q.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //Google News
    case("goo_news"):
    {
      //sLocation = "http://www.google.com.au";
      //sLocation = sLocation + "/news?hl=en&q=" + document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").action = "http://www.google.com.au/news";
      document.getElementById("Google").q.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("Google").submit();
      break;
    }
    //White pages WA Business
    case("wp_wa_bus"):
    {
      document.getElementById("WhitePages").action = "http://www.whitepages.com.au/wp/search/results.jhtml?_DARGS=%2Fwp%2Fsearch%2FsearchInput.jhtml";
      document.getElementById("WhitePages").state.value = "w";
      document.getElementById("WhitePages")["/WPRequestInput.searchType"].value = "bus";
      document.getElementById("WhitePages").name.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("WhitePages").submit();
      break;
    }
    //White Pages WA Residential
    case("wp_wa_res"):
    {
      document.getElementById("WhitePages").action = "http://www.whitepages.com.au/wp/search/results.jhtml?_DARGS=%2Fwp%2Fsearch%2FsearchInput.jhtml";
      document.getElementById("WhitePages").state.value = "w";
      document.getElementById("WhitePages")["/WPRequestInput.searchType"].value = "res";
      document.getElementById("WhitePages").name.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("WhitePages").submit();
      break;
    }
    //Yellow Pages WA
    case("yp_wa_perth"):
    {
      document.getElementById("YellowPages").action = "http://www.yellowpages.com.au/search/performSearch.do";
      document.getElementById("YellowPages").businessName.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("YellowPages").submit();
      break;
    }
    //Yellow Pages WA
    case("mqr"):
    {
      document.getElementById("MacquarieDictionary").action = "http://www.macquariedictionary.com.au:8008/macanonymous";
      document.getElementById("MacquarieDictionary").query.value = document.getElementById(sSearchID + "Text").value;
      document.getElementById("MacquarieDictionary").submit();
      break;
    }
  }
  
//  self.location = sLocation;
//  window.open(sLocation);

}

function GoToURL(sSearchID)
{
  var sLocation;

  sLocation = "http://www.";
  sLocation = sLocation + document.getElementById(sSearchID + "Text").value;
  sLocation = sLocation + document.getElementById(sSearchID + "Combo").value;
  window.open(sLocation);

}