function changeCase(frmObj) {
var index;
var tmpStr;
var tmpChar;
var preString;
var postString;
var strlen;
tmpStr = frmObj.value.toLowerCase();
strLen = tmpStr.length;
if (strLen > 0)  {
for (index = 0; index < strLen; index++)  {
if (index == 0)  {
tmpChar = tmpStr.substring(0,1).toUpperCase();
postString = tmpStr.substring(1,strLen);
tmpStr = tmpChar + postString;
}
else {
tmpChar = tmpStr.substring(index, index+1);
if (tmpChar == " " && index < (strLen-1))  {
tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
preString = tmpStr.substring(0, index+1);
postString = tmpStr.substring(index+2,strLen);
tmpStr = preString + tmpChar + postString;
         }
      }
   }
}
frmObj.value = tmpStr;
}


	function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Please Enter a Valid Email Address. Your Information will be sent to this address.")
		    return false
		 }

 		 return true					
	}

function check_required(){
	var emailID=document.theForm.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter a Valid Email Address. Your Information will be sent to this address.");
		emailID.focus();
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value="";
		emailID.focus();
		return false;
	}
	
	
if ( document.theForm.fname.value == "" ) {
alert('You did not enter an answer for the required field \'First Name\'! \n\nYou must do this before your information can be sent.');
document.theForm.fname.focus();
return false;
}

if ( document.theForm.lname.value == "" ) {
alert('You did not enter an answer for the required field \'Last Name\'! \n\nYou must do this before your information can be sent.');
document.theForm.lname.focus();
return false;
}

if ( document.theForm.street1.value == "" ) {
alert('You did not enter an answer for the required field \'Street Address\'! \n\nYou must do this before your information can be sent.');
document.theForm.street1.focus();
return false;
}

if ( document.theForm.user2.value == "" ) {
alert('You did not enter an answer for the required field \'City\'! \n\nYou must do this before your information can be sent.');
document.theForm.user2.focus();
return false;
}

if (( document.theForm.province_state1.value == "-- Please select --" ) && ( document.theForm.province_state2.value == "" )){
alert('You did not enter an answer for the required field \'Province / State\'! \n\nYou must do this before your information can be sent.');
document.theForm.province_state1.focus();
return false;
}

if ( document.theForm.user4.value == "" ) {
alert('You did not enter an answer for the required field \'Country\'! \n\nYou must do this before your information can be sent.');
document.theForm.user4.focus();
return false;
}

if ( document.theForm.user5.value == "" ) {
alert('You did not enter an answer for the required field \'Postal / Zip Code\'! \n\nYou must do this before your information can be sent.');
document.theForm.user5.focus();
return false;
}

document.theForm.user1.value = document.theForm.street1.value + ", " + document.theForm.street2.value;

if (document.theForm.province_state1.value == "-- Please select --")
{
document.theForm.user3.value = document.theForm.province_state2.value;
}
else
{
document.theForm.user3.value = document.theForm.province_state1.value;
}

if (document.theForm.province_state2.value != "")
{
document.theForm.user3.value = document.theForm.province_state2.value;
}

if (document.theForm.telephone_time[0].checked == true)
{
document.theForm.user6.value = "Mornings: " + document.theForm.telephone1.value + "-" + document.theForm.telephone2.value + "\n";
}
else
{
document.theForm.user6.value = "Afternoons: " + document.theForm.telephone1.value + " " + document.theForm.telephone2.value + "\n";
}

changeCase(document.theForm.fname);
changeCase(document.theForm.lname);
changeCase(document.theForm.user1);
changeCase(document.theForm.user2);
changeCase(document.theForm.user3);
changeCase(document.theForm.user4);
document.theForm.user7.value = document.theForm.user7.value + "\n";
document.theForm.user9.value = document.theForm.user9.value + "\n";
document.theForm.submitButton.value = "Processing. Please Wait ...";
document.theForm.submitButton.disabled = true;
return true;
}