//<!--

function str_replace (c1, c2, s)

{   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 (c == c1) { 
         	returnString += c2;
        } else {
        	returnString += c;
        }
    }

    return returnString;
}

function isEmpty(s) {
	return ((s == null) || (s.length == 0))
}

// Returns true if string s is empty or 
// whitespace characters only.

function isWhitespace (s) {   

	var whitespace = " \t\n\r";
	var i;
	// Is s empty?
	if (isEmpty(s)) return true;

	// Search through string's characters one by one
	// until we find a non-whitespace character.
	// When we do, return false; if we don't, return true.

	for (i = 0; i < s.length; i++) {   
		 var c = s.charAt(i);
		if (whitespace.indexOf(c) == -1) return false;
	}

	// All characters are whitespace.
	return true;
}


function check_required(thisform) {

	form1 = document.forms[thisform];
	required_string = form1.required.value;

	myalert = '';
	for (i=0;i<form1.elements.length;++i) {
		thisfield = form1.elements[i];
		if (thisfield.name != '') {
			if (required_string.indexOf(thisfield.name) != -1) {
				if ((isWhitespace(thisfield.value) && ((thisfield.type=="text"||thisfield.type=="textarea"))) || ((thisfield.type.toString().charAt(0)=="s") && (thisfield.selectedIndex==0))) {
					myname = str_replace("_"," ",thisfield.name);
					myalert += myname+"\n";
				}
			}
		}
	}
	
	if (myalert != '') {
		mymessage = 'Please enter the following required fields:\n';
		mymessage += myalert;
		alert (mymessage);
		return false;
	} else {
		return true;
	}
	
}

//-->