//function to open new window
function open_window(url_i, width_i, height_i)
{
    window.open(url_i,'new_win', 'width=' + width_i + ',height=' + height_i + ',resizable=no,status=no,titlebar=no,scrollbars=yes');
}

/*****
 * The calculateTotal() method calculates the total amount of an annual or semi-annual pledge and sets
 * the value of either the semiAnnualTotal or annualTotal field.  The installmentType argument is a string
 * that should be either "semiAnnual" or "annual", which specifies which installment type is to be calculated.
 *****/
function calculateTotal(installmentType)
{
	var amount = document.getElementById(installmentType + "Amt").value;
	var numInstallments = document.getElementById(installmentType + "Num").value;
	var total = amount * numInstallments;
	document.getElementById(installmentType + "Total").value = total.toFixed(2);
}

// /////////////////////////////////////////////////////////////////////
// This function limits the input to numbers
// Input: the field, an event, a decimal
// Output: restricts the field to numbers
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function numbersonly(myfield, e, dec)
{
	var key;
	var keychar;
	
	// Grab the key events
	if (window.event)
	{
		key = window.event.keyCode;
	}
	else if (e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	// Convert the character code to string
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
	{
		return true;
	}
	// numbers
	else if ( ( ("0123456789.-").indexOf(keychar) > -1) )
	{
		return true;
	}
	// decimal point jump
	else if ( dec && (keychar == ".") )
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
	{
		return false;
	}
}

// /////////////////////////////////////////////////////////////////////
// This function limits the field to only alphanumeric values
// Input: the field, an event, decimal(optional)
// Output: restricts to alpha numeric
// Created by: Feryl A. Dec. 20, 2004
// /////////////////////////////////////////////////////////////////////
function alphanum(myfield, e, dec)
{
	var key;
	var keychar;
	
	// Grab the key events
	if (window.event)
	{
		key = window.event.keyCode;
	}
	else if (e)
	{
		key = e.which;
	}
	else
	{
		return true;
	}
	
	// Convert from character code to string
	keychar = String.fromCharCode(key);
	
	// control keys
	if ((key == null) || (key == 0) || (key == 8) || (key == 9) || (key == 13) || (key == 27))
	{
		return true;
	}
	// Number and letters(to lower case)
	// *NOTE* ADD to this if some characters are needed *NOTE*
	else if ( ( ("0123456789abcdefghijklmnopqrstuvwxyz-.&',/* ").indexOf(keychar.toLowerCase()) > -1) )
	{
		return true;
	}
	// decimal point jump
	else if ( dec && (keychar == ".") )
	{
		myfield.form.elements[dec].focus();
		return false;
	}
	else
	{
		return false;
	}
}

//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.forms[0].email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
      //alert('A valid e-mail address is required.\nPlease amend and retry');
      return false;
    } 
    return true; 
}

<!--
/**
 * DHTML phone number validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 9;

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag)
{   var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function checkPhone(strPhone)
{
	s=stripCharsInBag(strPhone,validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidatePhone(){
	var Phone=document.regForm.homePhone
	
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Primary Phone Number")
		Phone.focus()
		return false
	}
	if (checkPhone(Phone.value)==false){
		alert("Please Enter a Valid Primary Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}
	return true
 }
 
