﻿<!--
var whitespace = " \t\n\r";
var digits = "0123456789";

function removeSpaces(string) {
	var tstring = "";
	string = '' + string;
	splitstring = string.split(" ");
	for(i = 0; i < splitstring.length; i++)
	tstring += splitstring[i];
	return tstring;
}

function isValidCreditCard(type, ccnum) {
   if (type == "VISA") {
      // Visa: length 16, prefix 4, dashes optional.
      var re = /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "MasterCard") {
      // Mastercard: length 16, prefix 51-55, dashes optional.
      var re = /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "Disc") {
      // Discover: length 16, prefix 6011, dashes optional.
      var re = /^6011-?\d{4}-?\d{4}-?\d{4}$/;
   } else if (type == "American Express") {
      // American Express: length 15, prefix 34 or 37.
      var re = /^3[4,7]\d{13}$/;
   } else if (type == "Diners") {
      // Diners: length 14, prefix 30, 36, or 38.
      var re = /^3[0,6,8]\d{12}$/;
   }
   if (!re.test(ccnum)) return false;
   // Remove all dashes for the checksum checks to eliminate negative numbers
   ccnum = ccnum.split("-").join("");
   // Checksum ("Mod 10")
   // Add even digits in even length strings or odd digits in odd length strings.
   var checksum = 0;
   for (var i=(2-(ccnum.length % 2)); i<=ccnum.length; i+=2) {
      checksum += parseInt(ccnum.charAt(i-1));
   }
   // Analyze odd digits in even length strings or even digits in odd length strings.
   for (var i=(ccnum.length % 2) + 1; i<ccnum.length; i+=2) {
      var digit = parseInt(ccnum.charAt(i-1)) * 2;
      if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
   }
   if ((checksum % 10) == 0) return true; else return false;
}

function isValidCreditCardDate (dMonth, dYear) {
    var today = new Date();
    arryEndDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
    d = new Date(dYear,dMonth-1,arryEndDays[dMonth-1]+1);
    if (d > today) return true; else return false;
}

function isEmpty(s) {   
	return ((s == null) || (s.length == 0))
}

function isEmptyOrWhitespace (s) {   
	var i;
    if (isEmpty(s)) return true;
    for (i = 0; i < s.length; i++) {   
        var c = s.charAt(i);
        if (whitespace.indexOf(c) == -1) return false;
    }
    return true;
}

function isRadioSelected(radiofield) {   
	for (var i = 0; i < radiofield.length; i++) {   
		if (radiofield[i].checked) return true
    }
    return false
}

function isValidPhoneNumber(s) {
	var temp = s.replace(/\D/g, "")
	return temp.length > 9 && temp.length < 26
}

function isNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
 }

function getElementRef(id){
	if (dom1) return document.getElementById(id);
	else if (ie4plus) return document.all[id];
	else if (ns4) return document.layers[id];
	else return null;
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

function isRadioSelected(radiofield) {   
	for (var i = 0; i < radiofield.length; i++) {   
		if (radiofield[i].checked) return true
    }
    return false
}

function formStyle(formField, formLabel, status) {
    	
	if (status == "invalid") {
	    alert('Please enter a value for: ' + formLabel);
		formField.style.background = "#f6ef7a";
		formField.style.border = "1px solid #000000";
		formField.style.color = "#666666";
		formField.focus();
	} else {
		formField.style.border = "1px solid #999999";
		formField.style.background = "#ffffff";
		formField.style.color = "#666666";
	}
}

///////////////////////////////
var popupWin;
// wit & hite will determine where the window opens on the screen
function openWin(windowURL,windowName,wit,hite,scroll) { 
	var winH = (screen.height - hite) / 2;
	var winW = (screen.width - wit) / 2;
	popupWin = window.open( windowURL, windowName, "menubar=no,status=no,toolbar=no,location=no,scrollbars="+scroll+",screenx=1,screeny=1,width=" + wit + ",height=" + hite + ",top="+winH+",left="+winW);
	popupWin.focus();
} 
