<!-- Hide script from older browsers
function validEmail(email) {
invalidChars = " /:,;";
if (email == "") {
return false;
}
for (i=0;i<invalidChars.length;i++) {
badChar = invalidChars.charAt(i);
if (email.indexOf(badChar,0) > -1) {
return false;
}
}
atPos = email.indexOf("@",1);
if (atPos == -1) {
return false;
}
if (email.indexOf("@",atPos+1) > -1) {
return false;
}
periodPos = email.indexOf(".",atPos);
if (periodPos == -1) {
return false;
}
if (periodPos+3 > email.length)	{
return false;
}
return true;
}
function isPrice(moneyVal) { // check if the string is ddd,ddd.dd
if (moneyVal == "") {
return false;
}
for (i=0; i<moneyVal.length; i++) {
if ((moneyVal.charAt(i) < "0") || (moneyVal.charAt(i) > "9")) {
if ((moneyVal.charAt(i) != ",") && (moneyVal.charAt(i) != ".")) {
return false;
}
}
}
return true;
}
function isInt(passedVal) { // check if the string is integer
if (passedVal == "") {
return false;
}
for (i=0; i<passedVal.length; i++) {
if (passedVal.charAt(i) < "0") {
return false;
}
if (passedVal.charAt(i) > "9") {
return false;
}
}
return true;
}
function isPhn(phoneNum) { // check if the string is a phone number
var phoneRegExp = /^\s*1?\s*[\-\(\.]?\d\d\d[\)\-\.]?\s*\d\d\d[\-\.]?\d\d\d\d\s*(ext|x)?[\.]?(\d)*/i;
// it is to match (916)933-1234 ext.456  or 916.933.1234x5 or 1-8009331234
var result = phoneNum.match(phoneRegExp);
if (result == null) {
//alert("bad result='"+result+"'");
return false;
} else {
//alert("good result='"+result[0]+"'");
}
return true;
}
function isNum(passedVal) { // check if the string is numbers. used in validZip
if (passedVal == "") {
return false;
}
for (i=0; i<passedVal.length; i++) {
if (passedVal.charAt(i) != "-") { // allow the dash (e.g. 95762-8122);
if (passedVal.charAt(i) < "0") {
return false;
}
if (passedVal.charAt(i) > "9") {
return false;
}
}
}
return true;
}
function validZip(inZip) { // validate the zipcode
if (inZip == "") {
return false;
}
if (inZip.length < 5) {
return false;
}
if (isNum(inZip)) {
return true;
}
return false;
}
// Due to special characters, do not cut-paste this section of codes !!!
// If browser reports error, check the brwoser and make sure the setting
//        view -> encoding -> Western European
function fixQuote(inStr) { // fix the quote marks
// ----------------------------------------------------
// --   See note below before touch the code!      ----
// ----------------------------------------------------
// Step 1. Use the MS Word to generate the sample of curly quote
// Step 2. Open this file use MS Notepad  (don't use WordPad !!!)
// Step 3. Copy the characters from Word to this file in Notepad
// Step 4. Save.
// -----------------------------------------------------
// If you use Word, the curly quote will be converted as straight quote
// -----------------------------------------------------
var newString= inStr.replace(/\'/g, "&#39;");  // single quote
newString= newString.replace(/\‘/g, "&#145;"); // curly single quote, left
newString= newString.replace(/\’/g, "&#146;"); // curly single quote, right
newString= newString.replace(/\"/g, "&#34;");  // Double quote
newString= newString.replace(/\“/g, "&#147;"); // curly Double quote, left
newString= newString.replace(/\”/g, "&#148;"); // curly Double quote, right
return newString;
}
function showQuote(inStr) { // show the quote marks for <textarea>
var newString= inStr.replace(/\&\#39;/g, "'"); // single quote
newString= newString.replace(/\&\#145;/g, "'"); // single quote
newString= newString.replace(/\&\#146;/g, "'"); // single quote
newString= newString.replace(/\&\#34;/g, "\""); // double quote
newString= newString.replace(/\&\#147;/g, "\""); // double quote
newString= newString.replace(/\&\#148;/g, "\""); // double quote
return newString;
}
function rmDoubleQuote(inStr) { // remove the double quote
var newString= inStr.replace(/\"/g, ""); // Double quote
newString= newString.replace(/\“/g, ""); // curly Double quote, left
newString= newString.replace(/\”/g, ""); // curly Double quote, right
return newString;
}
// End hiding script from older browsers -->
