

function isEmpty(strfield1, strfield2, strfield3) {


//change "field1, field2 and field3" to your field names
strfield1 = document.send2friend.id_message.value 


  //name field
    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
	document.getElementById("mess_mess").innerHTML = 'Please include a message for the recipient.'; 	
	document.getElementById("rec_mess").innerHTML = ""; 
    //alert("Please include a message for the recipient")
    return;
    }

    return true;
}


//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.send2friend.id_sender.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
	  document.getElementById("sender_mess").innerHTML = 'Please enter your valid email address.'; 
      //alert('Please enter your valid email address.');
      return;
    } 
    return true; 
}

//function to check valid email address
function isValidEmail2(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.send2friend.id_recipient.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
       document.getElementById("rec_mess").innerHTML = "Please enter a valid email address."; 
	   document.getElementById("sender_mess").innerHTML = '';
	  //alert('Please enter a valid email address in the recipients field');
      return;
    } 
    return true; 
}



//function that performs all functions, defined in the onsubmit event handler

function checkSend(docForm,form){
if (isValidEmail2(form.id_recipient)){
  if (isValidEmail(form.id_sender)){
    if (isEmpty(form.id_message)){
		  completeSend(docForm);
	  }
  }
}
return false;
}




function completeSend (docForm) {
	document.getElementById("btnSubmit").value="Wait ...";
	document.getElementById("btnSubmit").disabled=true;				
	DWREngine._execute(_ajaxConfig.send2friendAjaxCFC,null,'send2friend',DWRUtil.serializeForm(docForm),resultSentEmail);
}


function resultSentEmail (r){
	if (r.blninvalid == "true")	{
		document.getElementById("btnSubmit").value="Submit";
		document.getElementById("btnSubmit").disabled=false;
		alert("An error occured while saving your feedback.  If the problem persists, please contact DE support at 800-323-9084.");
	}
	else {
		document.getElementById("feedWrap").innerHTML = "<br><div align='center'><h3>Your message and link have been sent!<h3></div><br><div align='center'>- <a href='javascript:closeFloatingDiv(\"windowcontent\")'>close</a> -</div>";
	}
}	
	




