function IsBlank(elem)
{
  var str = elem.value;
  var ix, ch;
  for (ix = 0; ix < str.length; ix++)
  {
    ch = str.charAt(ix);
    if ((ch > ' ') && (ch < '~'))
    {
      return false;
    }
  }
  return true;
}

function IsNotNull(val,msg) 
{
  var errmsg = msg + " can not be zero or blank.";
  if ((val.value == 0) || (val.value.length == 0)) 
  {
    alert(errmsg);
    return false;
  }
  return true;
}

function GetQueryString()
// Parse querystring, store the name/value pairs in properties of an object, return that object.
{
  var argname, argvalue, pos, ix;
  var args = new Object();
  var query = location.search.substring(1); 
  var pairs = query.split("&");
  var str = "";
  for (ix = 0; ix < pairs.length; ix++)
  {
    pos = pairs[ix].indexOf('=');
    if (pos < 0)
    {
      continue;
    }
    argname = pairs[ix].substring(0,pos);
    argvalue = (pairs[ix].substring(pos+1)).replace(/\+/g, " ");
    args[argname] = unescape(argvalue);
    str = str + " " + argname + "=" + argvalue;
  }
  return args;
}

function GetCookieExp(days)
{
  var exp;
  exp = new Date((new Date()).getTime() + (60*60*24*days*1000));
  exp = exp.toGMTString();
  return exp;
}

function FormatNumber(val, precision, separator) 
{
  var round, tmp, decimals, ix, integers, result;
  if (precision > 0) 
  {
    precision++;
    round = "."; 
    for (var ix = 1; ix < precision; ix++) 
    { 
      round += "0"; 
    } 
    round += "5";
    tmp = eval(val) + eval(round);
    decimals = "" + (tmp - Math.floor(tmp));
    decimals = decimals.substring(2,precision+1);
  }
  else 
  { 
    tmp = Math.round(val); 
  }
  integers = "" + Math.floor(tmp);
  result = integers.substring(integers.length,(integers.length - 1));
  for (ix = 1; ix < integers.length; ix++) 
  {
    if (separator) 
    { 
      if (!(ix % 3)) 
      { 
        result = separator + result; 
      } 
    }
    result = integers.substring((integers.length - ix),(integers.length - ix - 1)) + result;
  }
  if (precision > 0) 
  { 
    result = result + "." + decimals; 
  }
  return result;
}

function AllImagesLoaded() 
{
  // All images are saved in an array called document.images. Very useful.
  var images = document.images;
  // Loop through all the images
  for (var ix = 0; ix < images.length; ix++)
  {
    if (images[ix].complete == false) 
    {
      return 0;
	}
  }

  return 1;
}

function GetMailTo(name)
{
  window.location = "mailto:" + name + "@" + "thewrightjewelry" + ".com";
}

function InfoOverBackground(elem,on)
{
  if (on)
  {
    elem.style.backgroundColor = "#B6DEE8";
  }
  else
  {
    elem.style.backgroundColor = "#FFFFFF";
  }
}