function checkform() {
	var reason = "";
	var option = document.form1.option.value;
	
	return true;
	
	//alert (option);
	if ((option == 'add') || (option == 'change')){
		reason = validateText(document.form1.hdr_description);
  		if (reason != "") {
    		alert("Description field needs correction:\n" + reason);
    		document.form1.hdr_description.focus();
			return false;
  		}
		reason = validateURL(document.form1.furl);
  		if (reason != "") {
    		alert("URL field needs correction:\n" + reason);
    		document.form1.furl.focus();
			return false;
  		}		
	}

	if ((option == 'adddtl') || (option == 'chgdtl')) {
		reason = validateText(document.form1.dtl_description);
  		if (reason != "") {
    		alert("Description field needs correction:\n" + reason);
    		document.form1.dtl_description.focus();
			return false;
  		}
		reason = validateURL(document.form1.furl);
  		if (reason != "") {
    		alert("URL field needs correction:\n" + reason);
    		document.form1.furl.focus();
			return false;
  		}		
		
	}
	
	if ((option == 'addGen') || (option == 'changeGen')){
		reason = validateText(document.form1.gen_description);
  		if (reason != "") {
    		alert("Description field needs correction:\n" + reason);
    		document.form1.gen_description.focus();
			return false;
  		}
		reason = validateURL(document.form1.furl);
  		if (reason != "") {
    		alert("URL field needs correction:\n" + reason);
    		document.form1.furl.focus();
			return false;
  		}		
	}
	if ((option == 'addSub') || (option == 'chgsub')){
		reason = validateText(document.form1.sub_description);
  		if (reason != "") {
    		alert("Description field needs correction:\n" + reason);
    		document.form1.sub_description.focus();
			return false;
  		}
		reason = validateURL(document.form1.furl);
  		if (reason != "") {
    		alert("URL field needs correction:\n" + reason);
    		document.form1.furl.focus();
			return false;
  		}		
	}
	
	if ((option == 'delete') || (option == 'dltdtl') || (option == 'deleteGen') || (option == 'dltsub')) {			
		var field =document.form1.del;
		if (!field.checked){
			alert ('please check box to proceed');
			return false; 
		}
	}
	
	return true;
}

function trim(s) {
  	return s.replace(/^\s+|\s+$/, '');
}

function isUrl(s) {
	var regexp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i ;
	return regexp.test(s);
}

function validateText(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]\`\~\^]/ ;
   
    if (tfld == "") {
        error = "You didn't enter any text.\n";
    } else if (tfld.match(illegalChars)) {
        error = "Text entered contains illegal characters.\n";
    } 
    return error;
}
function validateURL(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var illegalChars= /[\(\)\<\>\,\;\\\"\[\]\`\~\^]/ ;
	var linkexternal = tfld.match(/http/i);

    if (tfld == "") {
        error = "You didn't enter any text.\n";
    } else if (tfld.match(illegalChars)) {
        error = "Text entered contains illegal characters.\n";
    } else if (linkexternal) {
		if (!isUrl(tfld)) {
	    	error = "Text entered is not a valid URL.\n";
		}
	}
    return error;
}