function check_form(formname,ids) {
        var alert_str='';
        var idarray = ids.split("|");
        for(var i=0;i<idarray.length;i++){
            if(document.getElementById(idarray[i]).type == 'checkbox'){
               if(document.getElementById(idarray[i]).checked == false) {
                 alert_str += "Ticking the box "+document.getElementById(idarray[i]).name + " is required\n";
document.getElementById(idarray[i]).parentNode.style.backgroundColor = "#FFEBEB";

               } else {
                 document.getElementById(idarray[i]).parentNode.style.backgroundColor = "#FFFFFF";
               }
            } else {
               var fieldvalue = document.getElementById(idarray[i]).value;
	       if(fieldvalue ==''){
	         alert_str += document.getElementById(idarray[i]).name + " is required\n";
	         document.getElementById(idarray[i]).style.backgroundColor = "#FFEBEB";
	       } else {
                 valid_email ='';
		 if(idarray[i] == 'email'){
		    valid_email = check_email(fieldvalue);
		 }
                 if(valid_email !=''){
                    alert_str+=valid_email;
		    document.getElementById(idarray[i]).style.backgroundColor = "#FFEBEB";
		 } else {
		    document.getElementById(idarray[i]).style.backgroundColor = "#FFFFFF";
                 }
	       }
            }
        }
        if(alert_str ==''){
            eval("document."+formname+".submit()");
        } else {
            alert(alert_str);
	    return false;
        }
}

function check_email(email){
 //check if email is entered and valid syntax
  var str = email // email string
  var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid email
  var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/; // valid email
  if (!reg1.test(str) && reg2.test(str)) { // if syntax is valid
        return '';
  } else {
	if(!str=='') {
	    return "\"" + str + "\" is an invalid e-mail\n";
	} else {
	    return "You need to add your email address\n";
	}
  }        
}

