// check the whole form

function checkWholeForm(theForm) {
	var content = "";
    var why = "";
	content = isEmpty(theForm.evt_name.value);
	if(content == ""){
		content = isEmpty(theForm.evt_date.value);
		if(content == ""){
			content = isEmpty(theForm.org_name.value);
			if(content == ""){
				content = isEmpty(theForm.arena_loc.value);
			}
		}	
	}
	why += content;
	why += checkPhone(theForm.org_number.value);
    why += checkEmail(theForm.org_email.value);
    if (why != "") {
       alert(why);
       return false;
    }
	return true;
}

function checkEmail (strng) {
var error="";
if (strng == "") {
   error = "You didn't enter an email address.\n";
}

    var emailFilter=/^.+@.+\..{2,3}$/;
    if (!(emailFilter.test(strng))) { 
       error = "Please enter a valid email address.\n";
    }
    else {
//test email for illegal characters
       var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
         if (strng.match(illegalChars)) {
          error = "The email address contains illegal characters.\n";
       }
    }
return error;    
}


// phone number - strip out delimiters and check for 11 digits

function checkPhone (strng) {
var error = "";
if (strng == "") {
   error = "You didn't enter a phone number.\n";
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
    if (isNaN(parseInt(stripped))) {
       error = "The phone number contains illegal characters.";
  
    }
    if (!(stripped.length == 11)) {
        error = "The phone number is the wrong length (make sure you included an area code).\n";
    } 
return error;
}   


// non-empty textbox

function isEmpty(strng) {
var error = "";
  if (strng.length == 0) {
     error = "All fields on the form must be filled in.\n"
  }
return error;     
}

// date functions

function GetDay(nDay)
{
        var Days = new Array('Sun','Mon','Tue','Wed',
                             'Thu','Fri','Sat');
        return Days[nDay]
}

function GetMonth(nMonth)
{
        var Months = new Array('Jan','Feb','Mar','Apr','May','Jun',
                               'Jul','Aug','Sep','Oct','Nov','Dec');
        return Months[nMonth]            
}

function DateString()
{
        var Today = new Date();
        var strDate = GetDay(Today.getDay()) + ' ' + Today.getDate() + ' ';
        strDate += GetMonth(Today.getMonth()) + ' ' + Today.getFullYear();
        return strDate
}

function PrintDate()
{
	document.write("<p>" + DateString() + "</p>");
}

function PrintYear()
{
	var Today = new Date();
	document.write(Today.getFullYear())
}

// popup function for gallery
function popUp(URL)
{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=700,height=550,left = 290,top = 262');");
}
// end javascript code -->