// Create a popup window
function popup(MyLink, WindowName, Width, Height)
{	
    if (! window.focus)
    {
        return true;
    }

    var href;

    if (typeof(mylink) == 'string')
    {
        href = MyLink;
    }
    else
    {
        href = MyLink.href;
    }

    window.open(href, "_blank",
      'width=' + Width + ',height=' + Height + ',left=300,top=200,scrollbars=yes');

    return false;
}

// Menu Images
if (document.images) 
{
  LtmOn = new Image();
  LtmOn.src = "tp_ltm_on.jpg";
  LtmOff = new Image();
  LtmOff.src = "tp_ltm.jpg";
	
  AntarcticOn = new Image();
  AntarcticOn.src = "tp_antarctic_on.jpg";
  AntarcticOff = new Image();
  AntarcticOff.src = "tp_antarctic.jpg";
}

// Function to 'activate' images.
function imgOn(imgName, imgIndex)
{
  if (document.images) 
  {
    if (imgIndex)
    {
      fullName = imgName + "_" + imgIndex;
      document[fullName].src = eval(imgName + "On.src");
    }
    else
    {
      document[imgName].src = eval(imgName + "On.src");
    }
  }
}

// Function to 'deactivate' images.
function imgOff(imgName, imgIndex)
{
  if (document.images) 
  {
    if (imgIndex)
    {
      fullName = imgName + "_" + imgIndex;
      document[fullName].src = eval(imgName + "Off.src");
    }
    else
    {
      document[imgName].src = eval(imgName + "Off.src");
    }
  }
}

// Function to 'activate' images in forms.
function imgFormOn(Element, imgName)
{
    Element.src = eval(imgName + "On.src");
}

// Function to 'deactivate' images in forms.
function imgFormOff(Element, imgName)
{
    Element.src = eval(imgName + "Off.src");
}

// Function to take the user to the specified location gallery
function goLocation(selectName)
{
  selectValues = selectName.options[selectName.selectedIndex].value.split(",");

  window.location.href = "gallery.php?GalleryId=" + selectValues[0] +
    "&Type=L&Contents=" + selectValues[1];
}

// Function to take the user to the specified subject gallery
function goSubject(selectName)
{
  selectValues = selectName.options[selectName.selectedIndex].value.split(",");

  window.location.href = "gallery.php?GalleryId=" + selectValues[0] +
    "&Type=S&Contents=" + selectValues[1];
}

// Redirect a Page
function RedirectPage(RedirectURL)
{
    setTimeout("window.location.href = '" + RedirectURL + "'", 4000);
    
    return true;
}

// Re-submit the cart form
function SubmitCart()
{
			var cartForm = document.getElementById("cart_form");			
			cartForm.action = "cart.php";
			cartForm.submit();			
}

// Re-submit the cart form
function SubmitCheckout()
{
			var checkoutForm = document.getElementById("checkout_form");			
			checkoutForm.action = "checkout.php";
			checkoutForm.submit();			
}

function unhide(divID) 
{
  var item = document.getElementById(divID);
	
  if (item) 
	{
    item.className = (item.className=='hidden')?'unhidden':'hidden';
  }
}