
function checkformwithfavourites(theform) {
        if (!theform.securitycode.value) {
              alert("Error: 'Security Code' is blank. Please amend before proceeding");
              return false;
        }
        if (!theform.personname.value) {
                alert("Error: 'Person Name' is blank. Please amend before proceeding");
                return false;
        }
        var contact = '';
        for (i = 0; i < theform.contact.length; i++){
                // alert(i+' : '+theform.contact[i].checked + ' == '+theform.contact[i].value);
          if (theform.contact[i].checked == true){   contact = theform.contact[i].value };
        }
        if ( ! contact ) {
                alert("Error: 'Prefered method of contact' is blank. Please amend before proceeding");
                return false;
        }
        if (contact == 'telephone' && ! theform.telephone.value ) {
                alert("Error: You have chosen for us to reply back via the "+contact+". Please enter your "+contact+" number");
               return false;
        } else if (contact == 'email' && ! theform.email.value ) {
                alert("Error: You have chosen for us to reply back via the "+contact+". Please enter your "+contact+" address");
                return false;
        } else if (contact == 'post' && ( ! theform.address.value || ! theform.postcode.value )  ) {
                alert("Error: You have chosen for us to reply back via the "+contact+". Please enter your address and postcode");
                return false;
        }

        var re=/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i;
        if ((theform.email.value && !re.test(theform.email.value))) {
           alert("Error: Your email address is invalid. Please amend before proceeding.");
           return false;
        }
         //  alert('testing in progress - Thank you for your patience'); return false;
        return true;
}


function favouritelistmanagement(thisaction,thisid) {
	if ( ! thisaction || !thisid || isNaN(thisid)) {
		alert('Oops - No id passed - Please contact Administrator');
		return false;
	} else {
		if (opener && opener.open && !opener.closed) {
			opener.focus();
		}
		var w = 400;
		var h = 220;
		var left = (screen.width/2)-(w/2);
		var top = (screen.height/2)-(h/2);
		var url = '/cgi-bin/favouritelist1management.cgi?form_action='+thisaction+'&passid='+thisid;
		var myregf = window.open(url,'opener','location=0,toolbar=0,menubar=0,status=0,left='+left+',top='+top+',width='+w+',height='+h+',resizable=0');
		opener = myregf;
	}
}

