/**************************************************************************************************                                                                                                           *
* Purpose: This will validate the format of an email address                                                 *
***************************************************************************************************/

function checkEmail(strng) {
var error="";
if (strng == "") {
   return true;
}

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

/**************************************************************************************************                                                                                                            *
* Purpose: This will validate the format of a phone number                                                   *
***************************************************************************************************/

function checkPhone (strng) {

var error = "";
if (strng == "") {
   return true;
}

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters

    if (isNaN(parseInt(stripped))) {
       alert("The phone number contains illegal characters.");
       document.forms[0].phone.focus();
  
    }
    if (!(stripped.length == 10)) {
		 alert("The phone number is the wrong length. Make sure you included an area code.\n");
		 document.forms[0].phone.focus();
    } 
	var t = stripped.substring(0, 3) + "-" + stripped.substring(3, 6) + "-" + stripped.substring(6, 10);
	return t;
//return error;
}
function getImageName() {
	var f = document.forms[0];
	 path = f.file1.value.replace(/\\/g, '\\').split('\\');
    i = path.length-1;
	f.Image.value = "../images/classified/" + path[i];
	
}
