﻿var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;
top.nofeedback = false;

if ( document.getElementById )
  {
    DHTML = 1;
    DOM = 1;
  }
    
if ( window.opera )
  {
    OP = 1;
  }
    
if ( document.all && !OP )
  {
    DHTML = 1;
    MS = 1;
  }

if ( document.layers && !OP )
  {
    DHTML = 1;
    NS = 1;
  }

function getElement(id, doc)
{
  if ( !doc )
    {
      doc = document;
    }
  
  if ( DOM )
    {
      return doc.getElementById(id);
    }
  else if ( MS )
    {
      return doc[id];
    }
  else if ( NS )
    {
      return doc[id];
    }
  else
    {
      return void(0);
    }
}

function changeImages()
{
  if (document.images)
    {
      for (var i=0; i<changeImages.arguments.length; i+=2)
      {
        document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
      }
    }
}

function changeVisibility(element, visibility)
{
  element2Change = getElement(element);
  element2Change.style.visibility = visibility;
}

var PopWindow=null;
var PopCount=0;

function KillPopUp()
{
  if ( PopWindow != null && PopWindow.closed == false )
    {
      PopWindow.close();
    }
}

function PopUp(uri, size)
{
  PopCount ++;
  KillPopUp();
  params = size + "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,screenX=50,screenY=50";
  PopWindow = window.open(uri, ''+PopCount, params);
  PopWinodw = null;
}

function preload()
{
  images = new Array();
/*
  images[0]  = "images/buttonMenuHead01-over.jpg";
  images[1]  = "images/buttonMenuHead01-on.jpg";
  images[2]  = "images/buttonMenuHead02-over.jpg";
  images[3]  = "images/buttonMenuHead02-on.jpg";
  images[4]  = "images/buttonMenuHead03-over.jpg";
  images[5]  = "images/buttonMenuHead03-on.jpg";
  images[6]  = "images/buttonMenuHead04-over.jpg";
  images[7]  = "images/buttonMenuHead04-on.jpg";
  images[8]  = "images/buttonMenuHead05-over.jpg";
  images[9]  = "images/buttonMenuHead05-on.jpg";
*/
  im = new Array();

  for (var i = 0; i < images.length; i++)
  {
    im[i] = new Image();
    im[i].src = images[i];
  }
}

preload();

function SubmitShopFormWithActionValue(value)
{
  document.shopForm.act.value = value;
  document.shopForm.submit();
}



function checkNumeric(objName,minval, maxval,comma,period,hyphen,showAlertx)
{
  var numberfield = objName;
  
  if ( showAlertx=='noAlert' )
     {
       showAlert = false;
     }
   else
     {
       showAlert = true;
     }
  if (chkNumeric(objName,minval,maxval,comma,period,hyphen,showAlert)==false)
    {
      numberfield.select();
      numberfield.focus();

      if (showAlert==false)
        {
          numberfield.value = minval;
        }
      numberfield.value = 1;
      return false;
    }
  else
    {
      return true;
    }
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen,showAlert)
{
  // only allow 0-9 be entered, plus any values passed
  // (can be in any order, and don't have to be comma, period, or hyphen)
  // if all numbers allow commas, periods, hyphens or whatever,
  // just hard code it here and take out the passed parameters
  var checkOK = "0123456789" + comma + period + hyphen;
  var checkStr = objName;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";

  for (i = 0;  i < checkStr.value.length;  i++)
  {
    ch = checkStr.value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
    {
      if (ch == checkOK.charAt(j))
        {
          break;
        }
    }
        
      if (j == checkOK.length)
        {
          allValid = false;
          break;
        }
    
      if (ch != ",")
        {
          allNum += ch;
        }

  }

  if (!allValid)
    { 
      alertsay = "Please enter only these values \"";
      alertsay = alertsay + checkOK + "\" in the \"" + checkStr.name + "\" field.";
      if ( showAlert==true)
        {
          alert(alertsay);
        }
      
      return false;
    }
  
  // set the minimum and maximum
  var chkVal = allNum;
  var prsVal = parseInt(allNum);
  if (chkVal != "" && !(prsVal >= minval && prsVal <= maxval))
    {
      alertsay = "Please enter a value greater than or "
      alertsay = alertsay + "equal to \"" + minval + "\" and less than or "
      alertsay = alertsay + "equal to \"" + maxval + "\" in the \"" +   checkStr.name + "\" field."
      if (showAlert==true)
        {
          alert(alertsay);
        }

      return false;
    }
}
