<!--- hide script from old browsers

function validate(field,theValue) {
  var ok = "yes";
  var temp;
  for (var i=0; i<field.value.length; i++) {
    temp = "" + field.value.substring(i, i+1);
    if (theValue.indexOf(temp) == "-1") ok = "no";
  }
  if (ok == "no") {
    msg = "Invalid entry!  Only ";
	msg += theValue;
	msg += " characters are accepted!";
    alert(msg);
    field.focus();
  }
}


<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Original:  Roman Feldblum (web.developer@programmer.net) -->

<!-- Begin
var n;
var p;
var p1;
function ValidatePhone(){
p=p1.value
if(p.length==3){
	//d10=p.indexOf('(')
	pp=p;
	d4=p.indexOf('(')
	d5=p.indexOf(')')
	if(d4==-1){
		pp="("+pp;
	}
	if(d5==-1){
		pp=pp+")";
	}
	//pp="("+pp+")";
	document.frmPhone.txtphone.value="";
	document.frmPhone.txtphone.value=pp;
}
if(p.length>3){
	d1=p.indexOf('(')
	d2=p.indexOf(')')
	if (d2==-1){
		l30=p.length;
		p30=p.substring(0,4);
		//alert(p30);
		p30=p30+")"
		p31=p.substring(4,l30);
		pp=p30+p31;
		//alert(p31);
		document.frmPhone.txtphone.value="";
		document.frmPhone.txtphone.value=pp;
	}
	}
if(p.length>5){
	p11=p.substring(d1+1,d2);
	if(p11.length>3){
	p12=p11;
	l12=p12.length;
	l15=p.length
	//l12=l12-3
	p13=p11.substring(0,3);
	p14=p11.substring(3,l12);
	p15=p.substring(d2+1,l15);
	document.frmPhone.txtphone.value="";
	pp="("+p13+")"+p14+p15;
	document.frmPhone.txtphone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
	l16=p.length;
	p16=p.substring(d2+1,l16);
	l17=p16.length;
	if(l17>3&&p16.indexOf('-')==-1){
		p17=p.substring(d2+1,d2+4);
		p18=p.substring(d2+4,l16);
		p19=p.substring(0,d2+1);
		//alert(p19);
	pp=p19+p17+"-"+p18;
	document.frmPhone.txtphone.value="";
	document.frmPhone.txtphone.value=pp;
	//obj1.value="";
	//obj1.value=pp;
	}
}
//}
setTimeout(ValidatePhone,100)
}
function getIt(m){
	n=m.name;
	//p1=document.forms[0].elements[n]
	p1=m
	ValidatePhone()
}

function testphone(obj1){
	p=obj1.value
	//alert(p)
	p=p.replace("(","")
	p=p.replace(")","")
	p=p.replace("-","")
	p=p.replace("-","")
	//alert(isNaN(p))
	if (isNaN(p)==true){
		alert("Check phone");
		return false;
	}
}


function isblank(s)
{
    for(var i = 0; i < s.length; i++) {
        var c = s.charAt(i);
        if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
    }
    return true;
}

// This is the function that performs form verification. It will be invoked
// from the onSubmit() event handler. The handler should return whatever
// value this function returns.
function verify(f)
{
    var msg;
    var empty_fields = "";
    var errors = "";

    // Loop through the elements of the form, looking for all 
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(var i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea") || (e.type == "password") || (e.type == "radio") || (e.type == "file") || (e.type == "checkbox")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || e.value=="undefined" (e.value == "") || isblank(e.value)) {
                empty_fields += "\n          " + e.name;
                continue;
            }

            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) { 
                var v = parseFloat(e.value);
                if (isNaN(v) || 
                    ((e.min != null) && (v < e.min)) || 
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null) 
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null) 
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted. 
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "______________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "Please correct these error(s) and re-submit.\n";
    msg += "______________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:" 
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

var newWin = null;
function newWindow(hiddenWindow, WindowName) {
	if (!newWin || newWin.closed){
		if (WindowName == "login"){
			newWin = window.open(hiddenWindow, WindowName, "width=550,height=500,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes");
		}else{
			newWin = window.open(hiddenWindow, WindowName, "width=550,height=500,toolbar=no,menubar=no,status=no,scrollbars=yes,resizable=yes");
		}
	}else{
		newWin.location.href = hiddenWindow;
		newWin.focus();
	}
}

function openWindow(hiddenWindow, WindowName,theWidth,theHeight) {
	if (!newWin || newWin.closed){
		if (WindowName == "login"){
			newWin = window.open(hiddenWindow, WindowName, "width=650,height=500,toolbars=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
		}else{
			newWin = window.open(hiddenWindow, WindowName, "width=650,height=500,toolbars=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
		}
	}else{
		newWin.location.href = hiddenWindow;
		newWin.focus();
	}
}

function linkSelect(form) {
  window.parent.location = form.link.options[form.link.selectedIndex].value
}

function PrintPage() {
if (navigator.appName.indexOf("Microsoft")>=0 && navigator.appVersion.substring(22,23) == 4 || navigator.platform.substring(0,3) == "Mac") {
		alert("Your current browser does not support this button.  Please choose File/Print from your browser's menu.");
	} else {
		window.print();
	}
}

function RandomImageLong(images,iparams) {
 si = 0; 
 ci=0;
 cc=0;
 imageSet = new Array();
 ei = images.length;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() *cc);
  document.writeln("<img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\">");
}

function RandomImage(images)
{
  RandomImageLong(images," ");
}

function RandomImageLinkLongTarget(images,urls,iparams,hparams)
{
 imageSet = new Array();
 urlSet = new Array();
 si = 0; 
 ci=0;
 cc=0;
 ei = images.length;
 il=ei;
  for (i=1;i<ei;i++) {
    if (images.charAt(i) == ' ' || images.charAt(i) == ',') {
      imageSet[cc] = images.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  ind = Math.floor(Math.random() *cc);
 si = 0; 
 ci=0;
 cc=0;
 ei = urls.length;
 ul=ei;
  for (i=1;i<ei && cc <=ind ;i++) {
    if (urls.charAt(i) == ' ' || urls.charAt(i) == ',') {
      urlSet[cc] = urls.substring(si,i);
      cc++;
      si=i+1;
      }
    }
  	document.writeln("<a "+hparams+" href=\""+urlSet[ind]+"\"><img "+iparams+" src="+imageSet[ind]+" alt=\""+imageSet[ind]+"\"></a>");
}

function RandomImageLinkLong(images,urls,iparams) {
  RandomImageLinkLongTarget(images,urls,iparams,"");
}

function RandomImageLink(images,urls) {
  RandomImageLinkLongTarget(images,urls,"border=0","");
}
//--> Stop hiding


