function calcMedalionPrice(ppsqf, diam) {
	var retVal;
	retVal = parseFloat(ppsqf) * (Math.pow(parseFloat(diam) / 2, 2) * Math.PI);
	return retVal;
}

function isEmail(strEmail) {
	return ( strEmail.search( /\w+((-\w+)|(\.\w+)|(\_\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]{2,5}/ ) != -1); 
}
// to reload page with category in drop list 
// like onChange = "setCondition('medalionsTEST.asp?shape=',this)">
 function  setCondition(urllink,curfield) {
	var cat,url;
    cat = curfield[curfield.selectedIndex].value;
	url = urllink;
    url = url + cat;
	 window.location.href = url;
	}

var detail_window;				
function showPop(url, name, attributes) {

if((typeof(detail_window) == "undefined") || detail_window.closed) {
	detail_window = window.open(url, name, attributes);
 } else {
	detail_window.open(url, name, attributes);
 }
   detail_window.focus();
}


function showDetails(sku) {
		if(sku == "" || sku == "undefined") {
			alert("Invalid SKU number!");
		} else {
			showPop("item_details.asp?sku=" + sku, "_details", "width=810,height=490");
		}	
	}

function openWindow(page, width, height) {
    if (!window.window2) {
        // has not yet been defined
        window2 = window.open(page,'windowRef','width='+ width + ', height=' + height);
    }
    else {
        // has been defined
        if (!window2.closed) {
            // still open
            window2.focus();
        }
        else {
            window2 = window.open(page,'windowRef','width=' + width + ', height=' + height);
        }
    }
}


function FrontPage_Form1_Validator(theForm)
{

  if (theForm.ccItem.value == "")
  {
    alert("Please enter a value for the \"ccItem\" field.");
    theForm.ccItem.focus();
    return (false);
  }

  if (theForm.ccItem.value.length < 2)
  {
    alert("Please enter at least 2 characters in the \"ccItem\" field.");
    theForm.ccItem.focus();
    return (false);
  }

  if (theForm.Quantity.value == "")
  {
    alert("Please enter a value for the \"Quantity\" field.");
    theForm.Quantity.focus();
    return (false);
  }

  if (theForm.Quantity.value.length < 1)
  {
    alert("Please enter at least 1 characters in the \"Quantity\" field.");
    theForm.Quantity.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Quantity.value;
  var allValid = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.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 += ".";
      decPoints++;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Quantity\" field.");
    theForm.Quantity.focus();
    return (false);
  }

  if (decPoints > 1)
  {
    alert("Please enter a valid number in the \"Quantity\" field.");
    theForm.Quantity.focus();
    return (false);
  }

  if (theForm.zip.value == "")
  {
    alert("Please enter a value for the \"zip\" field.");
    theForm.zip.focus();
    return (false);
  }

  if (theForm.zip.value.length < 5)
  {
    alert("Please enter at least 5 characters in the \"zip\" field.");
    theForm.zip.focus();
    return (false);
  }
  return (true);
}