HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ns3133907 6.8.0-84-generic #84-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 5 22:36:38 UTC 2025 x86_64
User: cssnetorguk (1024)
PHP: 8.2.28
Disabled: NONE
Upload Files
File: //old_home_backup/2010healthandwellbeing.org.uk/public_html/menu_pmi.js
function popup(mylink, windowname)
{
if (! window.focus)return true;
var agent = navigator.userAgent.toLowerCase();
if (agent.indexOf("msie") != -1) {
		// check for platform
		if (agent.indexOf("mac") != -1) {
			var features = "menubar=1,height=500,width=500,scrollbars=yes";
		} else {
			var features = "menubar=1,height=500,width=500";
		}
	} else {
		var features = "menubar=1,innerHeight=300,innerWidth=500,scrollbars=yes";
	}
	window.open(mylink, windowname, features);
return false;
}


function addOptions(_obj) 
{
	if (_obj.value == "Married" || _obj.value == "Co-habiting") {
										document.getElementById("partner_info").style.display = "block";
									}
									else {
										document.getElementById("partner_info").style.display = "none";
									}
}


function checkFieldBack(fieldObj) {
	if (fieldObj.value!=0) {
		fieldObj.style.backgroundColor='#FFFFFF';
	}
}

function changedResidentPermit(secVal){
	if(secVal=='yes'){
	alert('yes');
	}
	else if(secVal=='no'){
	alert('no')
	}
	else{
	alert('Please specify resident details' );
	}
}

/*==============================================================================

This routine checks the value of the string variable specified by the parameter
for a valid UK telphone number. It returns false for an invalid number and the
reformatted telephone number false a valid number.

If false is returned, the global variable telNumberError contains an error
number, which may be used to index into the array of error descriptions 
contained in the global array telNumberErrors.

The definition of a valid telephone number has been taken from:

http://www.ofcom.org.uk/telecoms/ioi/numbers/numplan310507.pdf
  and
http://www.ofcom.org.uk/telecoms/ioi/numbers/num_drama

All inappropriate telephone numbers are disallowed (e.g. premium lines, sex 
lines, radio-paging services etc.)

Author:    John Gardner
Date:      16th November 2003

Version:   V1.1  4th August 2006       
					 Updated to include 03 numbers being added by Ofcom in early 2007.

Version:   V1.2  9th January 2007
           Isle of Man mobile numbers catered for 

Version:   V1.3  6th November 2007
           Support for mobile numbers improved - thanks to Natham Lisgo

Version:   V1.4  14th April 2008
           Numbers allocated for drama excluded - thanks to David Legg
			
Example calling sequnce:

  if (!checkUKTelephone (myTelNo)) {
     alert (telNumberErrors[telNumberErrorNo]);
  }

------------------------------------------------------------------------------*/

function checkUKTelephone (telephoneNumber) {

  // Convert into a string and check that we were provided with something
  var telnum = telephoneNumber + " ";
  if (telnum.length == 1)  {
     telNumberErrorNo = 1;
     return false
  }
  telnum.length = telnum.length - 1;
  
  // Don't allow country codes to be included (assumes a leading "+")
  var exp = /^(\+)[\s]*(.*)$/;
  if (exp.test(telnum) == true) {
     telNumberErrorNo = 2;
     return false;
  }
  
  // Remove spaces from the telephone number to help validation
  while (telnum.indexOf(" ")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf(" ")) + telnum.slice (telnum.indexOf(" ")+1)
  }
  
  // Remove hyphens from the telephone number to help validation
  while (telnum.indexOf("-")!= -1)  {
    telnum = telnum.slice (0,telnum.indexOf("-")) + telnum.slice (telnum.indexOf("-")+1)
  }  
  
  // Now check that all the characters are digits
  exp = /^[0-9]{10,11}$/;
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 3;
     return false;
  }
  
  // Now check that the first digit is 0
  exp = /^0[0-9]{9,10}$/;
  if (exp.test(telnum) != true) {
     telNumberErrorNo = 4;
     return false;
  }
	
	// Disallow numbers allocated for dramas.
	 
  // Array holds the regular expressions for the drama telephone numbers
  var tnexp = new Array ();
	tnexp.push (/^(0113|0114|0115|0116|0117|0118|0121|0131|0141|0151|0161)(4960)[0-9]{3}$/);
	tnexp.push (/^02079460[0-9]{3}$/);
	tnexp.push (/^01914980[0-9]{3}$/);
	tnexp.push (/^02890180[0-9]{3}$/);
	tnexp.push (/^02920180[0-9]{3}$/);
	tnexp.push (/^01632960[0-9]{3}$/);
	tnexp.push (/^07700900[0-9]{3}$/);
	tnexp.push (/^08081570[0-9]{3}$/);
	tnexp.push (/^09098790[0-9]{3}$/);
	tnexp.push (/^03069990[0-9]{3}$/);
	
	for (var i=0; i<tnexp.length; i++) {
    if ( tnexp[i].test(telnum) ) {
      telNumberErrorNo = 5;
      return false;
    }
	}
  
  // Finally check that the telephone number is appropriate.
  exp = (/^(01|02|03|05|070|071|072|073|074|075|07624|077|078|079)[0-9]+$/);
	if (exp.test(telnum) != true) {
     telNumberErrorNo = 5;
     return false;
  }
  
  // Telephone number seems to be valid - return the stripped telehone number  
  return telnum;
}
var telNumberErrorNo = 0;
var telNumberErrors = new Array ();
telNumberErrors[0] = "";
telNumberErrors[1] = "Telephone number not provided";
telNumberErrors[2] = "UK telephone number without the country code, please";
telNumberErrors[3] = "UK telephone numbers should contain 10 or 11 digits";
telNumberErrors[4] = "The telephone number should start with a 0";
telNumberErrors[5] = "The telephone number is either invalid or inappropriate";



/*==============================================================================

Application:   Utiity Function
Author:        John Gardner

Version:       V1.0
Date:          18th November 2003
Description:   Used to check the validity of a UK postcode

Version:       V2.0
Date:          8th March 2005
Description:   BFPO postcodes implemented.
               The rules concerning which alphabetic characters are alllowed in 
               which part of the postcode were more stringently implementd.
  
Parameters:    toCheck - postcodeto be checked. 

This function checks the value of the parameter for a valid postcode format. The 
space between the inward part and the outward part is optional, although is 
inserted if not there as it is part of the official postcode.

If the postcode is found to be in a valid format, the function returns the 
postcode properly formatted (in capitals with the outward code and the inward
code separated by a space. If the postcode is deemed to be incorrect a value of 
false is returned.
  
Example call:
  
  if (checkPostCode (myPostCode)) {
    alert ("Postcode has a valid format")
  } 
  else {alert ("Postcode has invalid format")};
                    
------------------------------------------------------------------------------*/

function checkPostCode (toCheck) {
 // Permitted letters depend upon their position in the postcode.
  var alpha1 = "[abcdefghijklmnoprstuwyz]";                       // Character 1
  var alpha2 = "[abcdefghklmnopqrstuvwxy]";                       // Character 2
  var alpha3 = "[abcdefghjkstuw]";                                // Character 3
  var alpha4 = "[abehmnprvwxy]";                                  // Character 4
  var alpha5 = "[abdefghjlnpqrstuwxyz]";                          // Character 5
  

  // Array holds the regular expressions for the valid postcodes
  var pcexp = new Array ();

  // Expression for postcodes: AN NAA, ANN NAA, AAN NAA, and AANN NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1,2})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
  
  // Expression for postcodes: ANA NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}[0-9]{1}" + alpha3 + "{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));

  // Expression for postcodes: AANA  NAA
  pcexp.push (new RegExp ("^(" + alpha1 + "{1}" + alpha2 + "?[0-9]{1}" + alpha4 +"{1})(\\s*)([0-9]{1}" + alpha5 + "{2})$","i"));
  
  // Exception for the special postcode GIR 0AA
  pcexp.push (/^(GIR)(\s*)(0AA)$/i);
  
  // Standard BFPO numbers
  pcexp.push (/^(bfpo)(\s*)([0-9]{1,4})$/i);
  
  // c/o BFPO numbers
  pcexp.push (/^(bfpo)(\s*)(c\/o\s*[0-9]{1,3})$/i);

  // Load up the string to check
  var postCode = toCheck;

  // Assume we're not going to find a valid postcode
  var valid = false;
  
  // Check the string against the types of post codes
  for ( var i=0; i<pcexp.length; i++) {
    if (pcexp[i].test(postCode)) {
    
      // The post code is valid - split the post code into component parts
      pcexp[i].exec(postCode);
      
      // Copy it back into the original string, converting it to uppercase and
      // inserting a space between the inward and outward codes
      postCode = RegExp.$1.toUpperCase() + " " + RegExp.$3.toUpperCase();
      
      // If it is a BFPO c/o type postcode, tidy up the "c/o" part
      postCode = postCode.replace (/C\/O\s*/,"c/o ");
      
      // Load new postcode back into the form element
      valid = true;
      
      // Remember that we have found that the code is valid and break from loop
      break;
    }
  }
  
  // Return with either the reformatted valid postcode or the original invalid 
  // postcode
  if (valid) {return postCode;} else return false;
}
function testPostCode(val)
         {
             
			 var post=val;
			 var myPostCode = document.getElementById(post).value;                 
             if(myPostCode !="")
			 {
			 if (checkPostCode(myPostCode))
              {
                document.getElementById(post).value = checkPostCode(myPostCode);
                //alert ("Postcode has a valid format");
				return true;
              } 
            else 
            {
             alert ("Postcode has invalid format");
			 document.getElementById(post).style.backgroundColor='#ffa5a5';
			 document.getElementById(post).focus();
			 return false;
            }  
			 }
          } 


function validatePMIForm(theForm) {
var reason = "";

  reason += validateName(theForm.forename);
  reason += validateName(theForm.surname);
  reason += validateEmpty(theForm.street);
  reason += validateEmail(theForm.email);
  reason += validatePhone(theForm.home_phone);
  reason += validatePhone(theForm.mobile_phone);
  reason += validatePostcode(theForm.postcode);
  reason += validateEmpty(theForm.dob_day);
  reason += validateEmpty(theForm.dob_month);
  reason += validateEmpty(theForm.dob_year);
  reason += validateEmpty(theForm.smoker);
  reason += validateEmpty(theForm.cover);
  reason += validateEmpty(theForm.people);
  reason += validateEmpty(theForm.cancer_cover);
  reason += validateEmpty(theForm.insured);

     
  if (reason != "") {
    alert("Please correct the highlighted fields:\n" + reason);
    return false;
  }

  return true;
}

function validateEmpty(fld) {
    var error = "";
 
    if (fld.value.length == 0 || fld.value == -1) {
        fld.style.background = 'Yellow'; 
        error = fld.name + " has not been filled in.\n"
    } else {
        fld.style.background = 'White';
    }
    return error;  
}


function validatePostcode(fld) {
    var error = "";

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "Please enter your postcode.\n";
    } else if (checkPostCode (fld.value)) {
        fld.style.background = 'White';
  } 
  else {
         fld.style.background = 'Yellow'; 
         error = "Postcode has invalid format.\n"
    }
    return error;  
}


function trim(s)
{
  return s.replace(/^\s+|\s+$/, '');
}

function validateEmail(fld) {
    var error="";
    var tfld = trim(fld.value);                        // value of field with whitespace trimmed off
    var emailFilter = /^[^@]+@[^@.]+\.[^@]*\w\w$/ ;
    var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/ ;
   
    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "You didn't enter an email address.\n";
    } else if (!emailFilter.test(tfld)) {              //test email for illegal characters
        fld.style.background = 'Yellow';
        error = "Please enter a valid email address.\n";
    } else if (fld.value.match(illegalChars)) {
        fld.style.background = 'Yellow';
        error = "The email address contains illegal characters.\n";
    } else {
        fld.style.background = 'White';
    }
    return error;
}

function validateName(fld) {
    var error = "";
     var illegalChars = /[^a-zA-Z ]/; // allow only letters

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "Please enter your " + fld.name + ".\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 30)) {
        error = "Your " + fld.name + " must be min 2 and max 30 characters. \n";
        fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "Your " + fld.name +" contains illegal characters or Numbers.\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}  

function validateCity(fld) {
    var error = "";
     var illegalChars = /[^a-zA-Z ]/; // allow only letters

    if (fld.value == "") {
        fld.style.background = 'Yellow';
        error = "Please enter your " + fld.name + ".\n";
    } else if ((fld.value.length < 2) || (fld.value.length > 50)) {
        error = "Your " + fld.name + " must be min 2 and max 50 characters. \n";
        fld.style.background = 'Yellow';
    } else if (illegalChars.test(fld.value)) {
        error = "Your " + fld.name +" contains illegal characters or Numbers.\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }
   return error;
}  


function validatePhone(fld) {
    var error = "";
    var stripped = fld.value.replace(/[\(\)\.\-\ ]/g, '');    

   if (fld.value == "") {
        error = "You didn't enter your " + fld.name + " number.\n";
        fld.style.background = 'Yellow';
    } else if (isNaN(parseInt(stripped))) {
        error = "The " + fld.name + " number contains illegal characters.\n";
        fld.style.background = 'Yellow';
    } else if (!(stripped.length == 10 || stripped.length == 11)) {
        error = "The " + fld.name + " number must be 10 or 11 characters.\n";
        fld.style.background = 'Yellow';
    } else if (!checkUKTelephone (fld.value)) {
        error = telNumberErrors[telNumberErrorNo] + ".\n";
        fld.style.background = 'Yellow';
    } else {
        fld.style.background = 'White';
    }

    return error;
}