//whitespace characters
var whitespace = " \t\n\r";

// open a window
function MM_openBrWindow(theURL,winName,features) { //v2.0
 var thewin = window.open(theURL,winName,features);
 	 thewin.focus;
}


// close current window
function closewindow() {
	window.close();
}

// add to favourites
function addtofavs() {
	if (document.all) {
		window.external.AddFavorite('http://www.psychiatrymatters.md','PsychiatryMatters.md');
	} else {
		strAlert = 'Your browser doesn\'t support this method\n\n If you are using Netscape you can add this';
		strAlert = strAlert + ' to your favourites by pressing "Ctrl + D", on a Mac press "Command + D"';
		alert(strAlert);
	}
}

// print the page out
function OpenPrintPage(SectionName,id) {
	// check the variables
	if ((SectionName == "") || (id == "")) { 
		alert('Sorry, there is a problem - we cannot print this page');
		return false;
 	}
	
  var appstr = "?type="+SectionName+"&id="+id
	  //alert("Value" + appstr);
      var PrintPage;
	  PrintPage = MM_openBrWindow("/asp/print/printpage.asp"+appstr, "PrintPage", "width=540,height=500,scrollbars=yes");
	  //PrintPage = MM_openBrWindow("/asp/print/printpage.html", "PrintPage", "width=540,height=500,scrollbars=yes");    
	  
	  
}

function printpage() {

 	if (window.print) {
	    window.print();
    } else {
        alert('Your browser doesn\'t support this print method')
    }
		
}
/*function printpage(SectionName,id) {
 var appstr = "?type="+SectionName+"&id="+id
      var PrintPage1;
	  PrintPage1 = window.open("/asp/print/printpage1.asp"+appstr, "PrintPage1", "width=540,height=500,scrollbars=yes");  
	  //PrintPage.document.open();
	  PrintPage1.print();
 	//if (window.print) {
	    
   //} else {
     //   alert('Your browser doesn\'t support this print method')
    //}           
}*/

// My Library
function MyLibrary(SectionName,Articleid,fullurl){

	var IE = (navigator.appName.indexOf("Microsoft") >= 0) 

	if (SectionName == "") { var sec = "undefined"; } else { var sec = SectionName; }
	if (Articleid == "") { var artid = "undefined"; } else { var artid = Articleid; }
	if (fullurl == "") { var furl = "undefined"; } else { var furl = fullurl; }

 	if (IE) {
		 var appstr = "?area="+sec+"&article="+artid+"&url="+escape(furl);
	} else {
		var appstr = "?area="+sec+"&article="+artid+"&url="+furl;
	}

  self.location = "/includes/asp/mylibrary/mylibrary_display.asp"+appstr
}

function MyLibrary_ConfirmDelAll() {
	if (confirm("Are you sure you want to clear your library?")) {
		return true
	}
	else {
		return false
	}
}


function MyLibrary_CreateDelList() {
	var strlist, count
	howmany = document.mylib_listing.elements.length;
	strlist = "";
	count = 0;

	for (i=0;i<howmany;i++) {
		what = document.mylib_listing.elements[i].type;
		if (what == "checkbox") {
			if (document.mylib_listing.elements[i].checked) {
				count++;
				if (strlist == "") {
					strlist = document.mylib_listing.elements[i].value;
				} else {
					strlist = strlist + "," + document.mylib_listing.elements[i].value;
				}
			}
		}
	}
	/* change the value of the hidden variable */
	document.mylib_dellist.del_list.value = strlist;
	if (count > 0) {
		strQ = "Are you sure you want to delete"
			if (count == 1) {
				strQ += " this item?"
			} else {
				strQ += " these " + count + " items?"
			}
		if (confirm(strQ)) {
			return true
		} else {
			return false
		}
	} else {
		alert("You haven't selected anything to clear")
		return false
	}
}	


// Send to a friend...
function EmailColleague(SectionName,Title,Url){

	if (SectionName == "") { var mSec = "undefined"; } else { var mSec = SectionName; }
	if (Title == "") { var mTitle = "undefined"; } else { var mTitle = Title; }
	if (Url == "") { var mUrl = "undefined"; } else { var mUrl = Url; }
 
  var appstr = "?area="+mSec+"&title="+mTitle+"&url="+mUrl;
  var EmailColleague;
	  EmailColleague = MM_openBrWindow("/asp/emailcolleague.asp"+appstr, "EmailColleague", "width=400,height=400,scrollbars=no");
}

//**************START :  Functions Added for DOB validation**************************/

// isYear (s [,eok])                   True if string s is a valid Year number.
// isIntegerInRange (s, a, b [,eok])   True if string s is an integer between a and b, inclusive.
// isMonth (s [,eok])                  True if string s is a valid month between 1 and 12.
// isDay (s [,eok])                    True if string s is a valid day between 1 and 31.
// daysInFebruary (year)               Returns number of days in February of that year.
// isDate (year, month, day)           True if string arguments form a valid date.
// Attempting to make this library run on Navigator 2.0,
// so I'm supplying this array creation routine as per
// JavaScript 1.0 documentation.  If you're using 
// Navigator 3.0 or later, you don't need to do this;
// you can use the Array constructor instead.

var strEmptyDOB = "Please enter the valid Consultant's DOB"
var strFutureDate = "DOB should be a past date"
var strDiffDOBDate = "You must be greater than or equal to 18 years of age"

function makeArray(n) {
//*** BUG: If I put this line in, I get two error messages:
//(1) Window.length can't be set by assignment
//(2) daysInMonth has no property indexed by 4
//If I leave it out, the code works fine.
//   this.length = n;
   for (var i = 1; i <= n; i++) {
      this[i] = 0
   } 
   return this
}



var daysInMonth = makeArray(12);
daysInMonth[1] = 31;
daysInMonth[2] = 29;   // must programmatically check this
daysInMonth[3] = 31;
daysInMonth[4] = 30;
daysInMonth[5] = 31;
daysInMonth[6] = 30;
daysInMonth[7] = 31;
daysInMonth[8] = 31;
daysInMonth[9] = 30;
daysInMonth[10] = 31;
daysInMonth[11] = 30;
daysInMonth[12] = 31;

// Get todays date and split it in Day, Month and Year
var strDate  = new Date()
var intTodDay = strDate.getDate()
var intTodMonth = strDate.getMonth() + 1
var intTodYear = strDate.getFullYear()



// isYear (STRING s [, BOOLEAN emptyOK])
// 
// isYear returns true if string s is a valid 
// Year number.  Must be 2 or 4 digits only.
// 
// For Year 2000 compliance, you are advised
// to use 4-digit year numbers everywhere.
//
// And yes, this function is not Year 10000 compliant, but 
// because I am giving you 8003 years of advance notice,
// I don't feel very guilty about this ...
//
// For B.C. compliance, write your own function. ;->
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isYear (s)
{   if (isEmpty(s)) 
       if (isYear.arguments.length == 1) return defaultEmptyOK;
       else return (isYear.arguments[1] == true);
    if (!isNonnegativeInteger(s)) return false;
    return ((s.length == 2) || (s.length == 4));
}



// isIntegerInRange (STRING s, INTEGER a, INTEGER b [, BOOLEAN emptyOK])
// 
// isIntegerInRange returns true if string s is an integer 
// within the range of integer arguments a and b, inclusive.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.


function isIntegerInRange (s, a, b)
{   if (isEmpty(s)) 
       if (isIntegerInRange.arguments.length == 1) return defaultEmptyOK;
       else return (isIntegerInRange.arguments[1] == true);

    // Catch non-integer strings to avoid creating a NaN below,
    // which isn't available on JavaScript 1.0 for Windows.
    if (!isInteger(s, false)) return false;

    // Now, explicitly change the type to integer via parseInt
    // so that the comparison code below will work both on 
    // JavaScript 1.2 (which typechecks in equality comparisons)
    // and JavaScript 1.1 and before (which doesn't).
    var num = parseInt (s);
    return ((num >= a) && (num <= b));
}



// isMonth (STRING s [, BOOLEAN emptyOK])
// 
// isMonth returns true if string s is a valid 
// month number between 1 and 12.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isMonth (s)
{   if (isEmpty(s)) 
       if (isMonth.arguments.length == 1) return defaultEmptyOK;
       else return (isMonth.arguments[1] == true);
    return isIntegerInRange (s, 1, 12);
}



// isDay (STRING s [, BOOLEAN emptyOK])
// 
// isDay returns true if string s is a valid 
// day number between 1 and 31.
// 
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isDay (s)
{   if (isEmpty(s)) 
       if (isDay.arguments.length == 1) return defaultEmptyOK;
       else return (isDay.arguments[1] == true);   
    return isIntegerInRange (s, 1, 31);
}



// daysInFebruary (INTEGER year)
// 
// Given integer argument year,
// returns number of days in February of that year.

function daysInFebruary (year)
{   // February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (  ((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0) ) ) ? 29 : 28 );
}



// isDate (STRING year, STRING month, STRING day)
//
// isDate returns true if string arguments year, month, and day 
// form a valid date.
// 

function isDate (year, month, day)
{   // catch invalid years (not 2- or 4-digit) and invalid months and days.
    if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;

    // Explicitly change type to integer to make code work in both
    // JavaScript 1.1 and JavaScript 1.2.
    var intYear = parseInt(year);
    var intMonth = parseInt(month);
    var intDay = parseInt(day);

    // catch invalid days, except for February
    if (intDay > daysInMonth[intMonth]) return false; 

    if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;

    return true;
}

function checkDOB(day,month,year)
{	
		if (gfn_validate_date(day,month,year)==-1){
			return false;			
			}
	return true;
}

function checkDiffLessThan_N_Yrs(month1,day1,year1,month2,day2,year2,PERMIITED_DIFF)
 {
  month1 = parseInt(month1,10)
  day1 =  parseInt(day1,10)
  year1 = parseInt(year1,10)
 
  month2 = parseInt(month2,10)
  day2 =  parseInt(day2,10)
  year2 = parseInt(year2,10)
 
 if ( year1 - year2 < PERMIITED_DIFF )
     return true

 if ( year1 - year2 > PERMIITED_DIFF )
   return false
 
 if ((year1 - year2) == PERMIITED_DIFF  && month1 > month2)
   return false
   
 if (((year1 - year2) ==  PERMIITED_DIFF) && (month1 == month2) && (day1 >= day2) )
   return false
return true
}

	
function gfn_validate_date ( pdt_day, pdt_month, pdt_year)
{	
/*
	*****************************************************************
	Name of the function	: gfn_validate_date
	Description		: Validates the day, month, & year passed
	Parameters Passed	: Object Reference of Day, Month, Year
	Parameter Returned	: "0" for Valid date and "-1" for Invalid 
							  input				
	*****************************************************************
	Amendment History
	*****************************************************************
	Date Amended			Amendment				Author	 
	
	*****************************************************************

*/
	
	if ( gfn_nbr_option (pdt_day,'W') == -1 )  return  -1 ;
	if ( gfn_nbr_option (pdt_month,'W') == -1 )  return  -1 ;
	if ( gfn_nbr_option (pdt_year,'W') == -1 )  return  -1 ;
	
	pdt_day = Number (pdt_day);
	pdt_month = Number (pdt_month);
	pdt_year = Number (pdt_year);
	
	if (pdt_day < 1)						return -1;
	if (pdt_month < 1 || pdt_month > 12) 	return -1;
	if (pdt_year < 1900 || pdt_year > 9999) return -1;
	
	if (isNaN (pdt_day) || isNaN (pdt_month) || isNaN (pdt_year)) return -1;
	switch (pdt_month) {
	
		case 1	:
		case 3	: 
		case 5	:
		case 7	:
		case 8	:
		case 10	:
		case 12	:
			if  (pdt_day > 31) return -1;
			break; 
	    case 4	:
	    case 6	:
	    case 9	:
	    case 11	:
			if  (pdt_day > 30) return -1;
			break; 
		case 2	:
	
			if ((pdt_year % 100) == 0) {
				if ((pdt_year % 400) == 0) {
					if (pdt_day >29) {
						return -1;
					}
					else {
						return 0;
					}
				}	
				else {
					if (pdt_day >28) {
						return -1;
					}
					else {
						return 0;
					}
				}
			}
			else {
				if ((pdt_year % 4) == 0) {
					if (pdt_day >29) {
						return -1;
					}
					else {
						return 0;
					}
				}
				else {
					if (pdt_day >28) {
						return -1;
					}
					else {
						return 0;
					}
				}	

			}

			break;
				
		default		:
		
			if (pdt_day > 30) 
					return -1;
			break;
			
	}	
	return 0;	
}
function gfn_nbr_option (p_data, p_flag)
{

/*
	*****************************************************************
	Name of the function	: gfn_nbr_option
	Description		: Depending on the flag passed it will
				: Check for valid whole nos. or valid float 
				: number.
	Parameters Passed	: The data to be validated, the flag to 
					: decide the mode.
	Parameter Returned	: "0" for valid data
							: "-1" for invalid data
	*****************************************************************
	Amendment History
	*****************************************************************
	Date Amended			Amendment				Author	 
	
	*****************************************************************
*/
	var regexp;
	switch (p_flag)
	{
		case "w" :
		case "W" :
			p_data = String (p_data);
			regexp = /[\+,\-,.]{1,}/g;
			if (p_data.search(regexp) >= 0)
			{
				return -1;
			}
			if (isNaN (p_data))
			{
				return -1;
			}
			break;
		case "f" :
		case "F" :
			if (isNaN(Number(p_data)))
			{
				return -1;
			}
			break;
		case "fs" :
		case "FS" :
			p_data = String (p_data);
			regexp = /[\+,\-,.,\s]{1,}/g;
			if (p_data.search(regexp) >= 0)
			{
				return -1;
			}
			if (isNaN (p_data))
			{
				return -1;
			}
			break;
	}
	return 0;
}


//************** END : DOB validation**************************/


//checking for empty fields
function isEmpty(s) { // Check whether string s is empty.
    return ((s == null) || (s.length == 0))
}
// Returns true if string s is empty or whitespace characters only.
function isWhitespace(s) {
    var whitespace = " \t\n\r";
    var i;

    if (isEmpty(s)) return true; // s is empty
    
    // Search through string's characters one by one until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.
    for (i=0; i<s.length; i++) {   
        if (whitespace.indexOf(s.charAt(i)) == -1) return false;
    }
    return true;     // All characters are whitespace.
}
 
// Return true if str is not blank and is a valid name

function isValidName(s) {
    var i
    if (isWhitespace(s)) 
        if (isValidName.arguments.length == 1) return false;
        else return (isValidName.arguments[1] == true);

    for(i=0; i<s.length; i++) {
        if (!((s.charCodeAt(i)>=65 && s.charCodeAt(i)<=90) || 
              (s.charCodeAt(i)>=97 && s.charCodeAt(i)<=122) || 
              s.charCodeAt(i)==45 || 
              s.charCodeAt(i)==46 || 
              s.charCodeAt(i)==39 || 
              s.charCodeAt(i)==32)) return false;
    }
    return true;
}
 


// Feedback and/or Comments
function Feedback_validate() {
	var strRecip = document.feedback.frmEmail.value;
	var strName=document.feedback.frmName.value;
	var strComments=document.feedback.frmComments.value;
	var strRet;
	
	//check for valid name 
	if(!isValidName(strName))
	{
	  alert("Please enter valid name");
	  document.feedback.frmName.value="";
	  document.feedback.frmName.focus();
	  return false;
	}
	
	
	// check the recipient
	strRet = check_emailaddr(strRecip);

	if (strRet != null) {  
		alert(strRet);
		return false;
	}
	
	//check for comments field
	if(isWhitespace(strComments)==true)
	{
	  alert("Please enter your comments");
	  document.feedback.frmComments.value="";
	  document.feedback.frmComments.focus();
	  return false;
	}		
}

function Feedback(FBType,SectionName,Title,Url){
	var ty = FBType
	if (SectionName == "") { var mSec = "undefined"; } else { var mSec = SectionName; }
	if (Title == "") { var mTitle = "undefined"; } else { var mTitle = Title; }
	if (Url == "") { var mUrl = "undefined"; } else { var mUrl = Url; }

  var appstr = "?type="+ty+"&area="+mSec+"&title="+mTitle+"&url="+mUrl
  var FeedbackWindow;
	  FeedbackWindow = MM_openBrWindow("/asp/feedback.asp"+appstr, "FeedbackWindow", "width=400,height=500,scrollbars=no");
}

// EMAIL COLLEAGUE
function EmailColleague_validate() {
	var strEmailList = document.colleague.frmRecipients.value;
	var strSender = document.colleague.frmSender.value;	
	var strRet;

	// check the recipients
	strRet = check_emailaddr(strEmailList);

	if (strRet != null) {  
		alert("Email recipients: \n" + strRet);
		return false;
	}
	
	// check the senders address
	strRet = check_emailaddr(strSender);
	if (strRet != null) {
		alert("Senders email address: \n" + strRet);
		return false;
	}
}

function QuestSubmit_validate(){
	var strEmail = document.QuestionSubmit.txtEmail.value;
	var strQuestion = document.QuestionSubmit.txtQuestion.value;
	var strRet;
			
	strRet = check_emailaddr(strEmail);
	
	if (strRet != null) {  
		alert(strRet);
		return false;
	}
	
	if (strQuestion == ''){
		alert("You must enter a question \n");
		return false;
	}
	
}

// validate email addresses
function check_emailaddr(emaillist) {
	// we should receive a comma delimited list of email addresses
	// we will loop through these and validate each one
	var pos = 0;  // first position where to check for the comma
	var comma_count = 0;
	var err_msg = ""
	var badcount = 0;
	var err_count = 0; // will be changed to 1 if there is an error
	
	// first check to make sure something has been entered
	if (emaillist.length == "0") {
		err_msg += "Email address is invalid\n\n- You must enter an email address\n";
		err_count = 1;
	} else {
		// start the loop and see how many we can find
		for (i=0; i < emaillist.length; i++) {
			com = emaillist.charAt(i);
			if (com == ",") {
				comma_count++;
			}
		}
		// if the comma count is greater than 0 then we should have at least 2 email addresses.. validate them
		if (comma_count > 0) {
			emailarray = emaillist.split(",");  // returns an array of email addresses ;)
			//alert(emailarray.length + " email address to be validated");
			for (i in emailarray) {
				// loop through the array and validate each email address
				if (!isValidEmail(emailarray[i])) {
					// this is invalid
					err_msg += "- \'"+emailarray[i]+"\' is invalid! \n"
					err_count = 1;
					badcount++;							
				}
			}
			
			if (err_count == 1) { err_msg = "Email address is invalid\n\n" + badcount + " of the " + emailarray.length + " addresses has errors.\n\n" + err_msg; }
			
		} else {
			// validate what has been put in...
			if (!isValidEmail(emaillist)) {
				// this is invalid
				err_msg += "- \'"+emaillist+"\' is invalid! please re-enter\n"
				err_count = 1;
			}
			
			if (err_count == 1) { err_msg = "Email address is invalid\n\n" + err_msg; }			
		}
	}

	if (err_count == 0) {
		return (null);  // returning blank is good
	}

	return(err_msg); // throw back the error message
}

// validate the format of an email address
function validate_emailaddr(emailaddr) {
   if (emailaddr.indexOf("@") < 1)  {
		return false; // checking its @ symbol is not the first character...
   } else {
		if (emailaddr.indexOf(".",emailaddr.indexOf("@")) < emailaddr.indexOf("@")) {
			return false;  // checking that there is a . after the @ symbol
		}
	}		
return true; // if everything is ok then return true
}


// EMAIL COLLEAGUE
function EAlerts_validate() {
	var strEmailAddr = document.ealerts.frmEalertsEmail.value;
	var strRet, cont, intErr
	
	// check the recipients

	
	
	if (strEmailAddr.length == 0) {
		strRet = "Sorry, we don\'t have an email address for you. \n\n You haven\'t given us one in your profile. \n";
		strRet = strRet + "Would you like to enter one now?";
		intErr = 1
	};

	if (intErr < 1)	{ // we need to check its a vaid email
		strRet2 = check_emailaddr(strEmailAddr);	
		if (strRet2 != null) {  
			strRet = "Sorry, the email address is invalid, would you like to modify it in your profile now?";
		};
	};

	if (strRet != null) {
		if (confirm(strRet)) {
			self.location = "/asp/edit_profile/edit_profile_1_fulldisplay.asp";
			return false;
		} else {
			return false;
		};	
	};
	
	// check they have selected something from the list of checkboxes, if not then
	// there is no point checking anything else
	
	amount = document.ealerts.list_name_amount.value;
		cont = 0; //continue
		for (i=0;i<amount;i++) {
		//	alert(i);
			what = document.ealerts.elements[i].type;
			if (what == "checkbox") {
				if (document.ealerts.elements[i].checked) {
					cont = 1;
				}
			}
		}

	//check that cont is 1, if not then they haven't selected anything
	if (cont == "0") {
		alert("Select the tick box to subscribe to UK Medical News.");
		return false;
	} 		
}


// PROFILE CHECKS
function Profile_ValidUNPW(strString) {
		var pattern = /[a-zA-Z0-9_-]/;
		return strString.search(pattern);	
}

function ProviderID_Validate() {

	var missinginfo = '';
	var err_count = 0;
	// check the specialist username/password
		var frm_Forename = document.usercheck.frmForename.value;
		var frm_Surname = document.usercheck.frmSurname.value;
		var frm_Providerid = document.usercheck.frmProviderid.value;
		//var frm_email = document.usercheck.frmemail.value;
	
		if (frm_Forename.length == 0) {
				missinginfo += "\n     -  Forename";
				err_count = 1;
		}

		//Valid Forename
		if(frm_Forename != '')
		{
			if(!isValidName(frm_Forename))
			{
			  missinginfo += "\n     -  Enter a Valid Forename";
			  err_count = 1;         
			}
		
		}
	
		if (frm_Surname.length == 0) {
				missinginfo += "\n     -  Surname";
				err_count = 1;
		}

		//Valid Surname
		if(frm_Surname != '')
		{
			if(!isValidName(frm_Surname))
			{
			  missinginfo += "\n     -  Enter a Valid Surname";
			  err_count = 1;         
			}
		
		}
	
		if (frm_Providerid.length == 0) {
				missinginfo += "\n     -  Provider ID";
				err_count = 1;
		} else {

			var pattern = /[^0-9]/;			
				intFound = frm_Providerid.search(pattern);
			if (intFound != -1) {
				missinginfo += "\n     -  Provider ID - invalid number";		
				err_count = 1;
			}
		}
		
		//if (frm_email == 0) {
		//		missinginfo += "\n     -  E-mail";
	//			err_count = 1;
		//}

		//if (frm_email != 0) {
		//	if (!validate_emailaddr(frm_email)) {
		//			if(err_count == 1)
		//			{
		//				// this is invalid
		//				missinginfo += "\n     -  E-mail";
		//				err_count = 1;					
		//			}
		//			else
		//			{
		//				// this is invalid
		//				missinginfo += "\n"
		//				err_count = 2;
		//			}
		//			
		//		}
		//}
		
	if (err_count == 1) {
		missinginfo = "______________________________________\n" +
		"An error has been found with the form.\n You must enter valid information in the following fields:\n" +
		missinginfo + "\n____________________________________"
		alert(missinginfo);
		return false;
	}	
	if (err_count == 2) {
		missinginfo = "_________________________________________\n" +
		"An error has been found with the form.\n You must enter a valid E-mail address:" +
		missinginfo + "_________________________________________"
		alert(missinginfo);
		return false;
	}		
			
}

function Profile_Validate() {

	var missinginfo = '';
	
	// if secretary is logged in then this will not be done

	if (document.reg.frmSpecUsername != null)
	{
	// check the specialist username/password
		var frm_SpecUN = document.reg.frmSpecUsername.value;
		var frm_SpecUN_valid = Profile_ValidUNPW(frm_SpecUN);
		
			if (frm_SpecUN_valid > 0) { 	//Error - invalid chars found
				missinginfo += "\n     -  Consultant Username -- Invalid character entry*";
			}
			if ((frm_SpecUN.length < 8) || (frm_SpecUN.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Consultant Username -- Your username must be between 8 and 20 charcters long.";
			}

		var frm_SpecPW = document.reg.frmSpecPassword.value;
		var frm_SpecPW_valid = Profile_ValidUNPW(frm_SpecPW)		
			if (frm_SpecPW_valid > 0) {
				//Error - invalid chars found
				missinginfo += "\n     -  Consultant Password -- Invalid character entry*.";
			}
			if ((frm_SpecPW.length < 8) || (frm_SpecPW.length > 20)) {  // wrong lengths
				missinginfo += "\n     -  Consultant Password -- Your password is not valid, it must be between 8 and 20 characters long*.";
			}

		var frm_SpecPWTwo = document.reg.frmSpecPasswordCheck.value;
		var frm_SpecPWTwo_valid = Profile_ValidUNPW(frm_SpecPWTwo)		
			if (frm_SpecPWTwo != frm_SpecPW) {
				missinginfo += "\n     -  Consultant Password Confirmation -- Your password confirmation MUST match your original password";
			}
	}	
			

	// check the secretaries username/password - not required but must be valid if entered
	var frm_SecrUN = document.reg.frmSecrUsername.value;
	if (frm_SecrUN.length > 0) {  // we must check the details entered
		var frm_SecrUN_valid = Profile_ValidUNPW(frm_SecrUN);		
			if (frm_SecrUN_valid > 0) { 	//Error - invalid chars found
				missinginfo += "\n     -  Secretary Username -- Invalid character entry*";
			}
			if ((frm_SecrUN.length < 8) || (frm_SecrUN.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Secretary Username -- Your username must be between 8 and 20 charcters long.";
			}   
		
		var frm_SecrPW = document.reg.frmSecrPassword.value;
		var frm_SecrPW_valid = Profile_ValidUNPW(frm_SecrPW)
			if (frm_SecrPW_valid > 0) {
				//Error - invalid chars found
				missinginfo += "\n     -  Secretary Password -- Invalid character entry*.";
			}
			if ((frm_SecrPW.length < 8) || (frm_SecrPW.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Secretary Password -- Your password is not valid, it must be between 8 and 20 characters long*.";
				}

		var frm_SecrPWTwo = document.reg.frmSecrPasswordCheck.value;
			 if (frm_SecrPWTwo != frm_SecrPW) {
				missinginfo += "\n     -  Secretary Password Confirmation -- Your password confirmation MUST match your original password";
			}
			
		if (frm_SecrUN == frm_SpecUN) {
				missinginfo += "\n     -  Consultant and Secretary Usernames must be different";
		}
	}
	// check the email address has been entered
	var frm_Email = document.reg.frmEmail.value;
	strRet = check_emailaddr(frm_Email);
	if (strRet != null) {  
		//missinginfo += "\n     -  Email Address -- Please enter valid Email Address";
		alert(strRet);
		return false;
	}
												      
	if (missinginfo != "") {
		missinginfo = "______________________________________________________________________________\n" +
		"An error has been found with the form:\n" +
		missinginfo + "\n____________________________________________________________________________" +
		"\nPlease re-enter and submit again!\n" +
		"\n*Entries must be alphanumeric and MAY include hyphens." +
		"\nDo not use any punctuation or non-alphanumeric character."
		alert(missinginfo);
		return false;
	}

}


function Profile_Validate_Edit() {

//**********************************************************************************
// Name : Qamar Ali		Date : 05/10/05
// Description : validate the Profile edit form.
//**********************************************************************************
if (document.profile.frmTitle.value == 'Other')
 {
   if (isWhitespace(document.profile.frmTitleOther.value))
	{
	   alert("Please enter Title");
	   document.profile.frmTitleOther.focus();
	   return false;	
	}

  }
if (!isValidName(document.profile.frmForename.value))
	{
	   alert("Please enter your Forename");
	   document.profile.frmForename.focus();
	   return false;	
	}

  if (!isValidName(document.profile.frmSurname.value))
	{
	   alert("Please enter your Surname");
	   document.profile.frmSurname.focus();
	   return false;	
	}
  if (document.profile.frmSpecOther.value != '')
  {
   if (isWhitespace(document.profile.frmSpecOther.value))
	{
	   alert("Please enter valid Specialty Other");
	   document.profile.frmSpecOther.focus();
	   return false;	
	}
  }

if (document.profile.frmAddress1.value != '')
 {
  if (isWhitespace(document.profile.frmAddress1.value))
	{
	   alert("Please enter valid Address");
	   document.profile.frmAddress1.focus();
	   return false;	
	}
 }
	var missinginfo = '';
	
	// if secretary is logged in then this will not be done

	if (document.profile.frmSpecUsername != null)
	{
	// check the specialist username/password
		var frm_SpecUN = document.profile.frmSpecUsername.value;
		var frm_SpecUN_valid = Profile_ValidUNPW(frm_SpecUN);
		
			if (frm_SpecUN_valid > 0) { 	//Error - invalid chars found
				missinginfo += "\n     -  Consultant Username -- Invalid character entry*";
			}
			if ((frm_SpecUN.length < 8) || (frm_SpecUN.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Consultant Username -- Your username must be between 8 and 20 charcters long.";
			}

		var frm_SpecPW = document.profile.frmSpecPassword.value;
		var frm_SpecPW_valid = Profile_ValidUNPW(frm_SpecPW)		
			if (frm_SpecPW_valid > 0) {				//Error - invalid chars found
				missinginfo += "\n     -  Consultant Password -- Invalid character entry*.";
			}
			if ((frm_SpecPW.length < 8) || (frm_SpecPW.length > 20)) {  // wrong lengths
				missinginfo += "\n     -  Consultant Password -- Your password is not valid, it must be between 8 and 20 characters long*.";
			}

		var frm_SpecPWTwo = document.profile.frmSpecPasswordCheck.value;
		var frm_SpecPWTwo_valid = Profile_ValidUNPW(frm_SpecPWTwo)		
			if (frm_SpecPWTwo != frm_SpecPW) {
				missinginfo += "\n     -  Consultant Password Confirmation -- Your password confirmation MUST match your original password";
			}
	}	
	
	/* Start, Modified by swati on 04/03/2010 for HPOV 495057 - Problem updating profile on Consultants online
	var frmTel = document.profile.frmTel.value;
	
	if(!isInteger(document.profile.frmTel.value)){
		missinginfo += "\n     -  Telephone number -- Invalid character entry";
	}
	
	var frmFax = document.profile.frmFax.value;
	
	if(!isInteger(frmFax)){
		missinginfo += "\n     -  Fax number -- Invalid character entry";
	}
	End, Modified by swati on 04/03/2010 for HPOV 495057 - Problem updating profile on Consultants online */

  //checking for valid email address  
     var strEmailList=document.profile.frmEmail.value;
    var strRet 
    strRet = check_emailaddr(strEmailList);
	/*if (strRet != null) {  
		alert(strRet);
		//missinginfo += "\n - Email address -- Enter valid email address" ;
		return false;
	}*/

	// check the secretaries username/password - not required but must be valid if entered
	var frm_SecrUN = document.profile.frmSecrUsername.value;
	if (frm_SecrUN.length > 0) {  // we must check the details entered
		var frm_SecrUN_valid = Profile_ValidUNPW(frm_SecrUN);		
			if (frm_SecrUN_valid < 0) { 	//Error - invalid chars found
				missinginfo += "\n     -  Secretary Username -- Invalid character entry*";
			}
			if ((frm_SecrUN.length < 8) || (frm_SecrUN.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Secretary Username -- Your username must be between 8 and 20 charcters long.";
			}   
		
		var frm_SecrPW = document.profile.frmSecrPassword.value;
		var frm_SecrPW_valid = Profile_ValidUNPW(frm_SecrPW)
			if (frm_SecrPW_valid < 0) {
				//Error - invalid chars found
				missinginfo += "\n     -  Secretary Password -- Invalid character entry*.";
			}
			if ((frm_SecrPW.length < 8) || (frm_SecrPW.length > 20)) {  // wrong lengths
					missinginfo += "\n     -  Secretary Password -- Your password is not valid, it must be between 8 and 20 characters long*.";
				}

		var frm_SecrPWTwo = document.profile.frmSecrPasswordCheck.value;
			 if (frm_SecrPWTwo != frm_SecrPW) {
				missinginfo += "\n     -  Secretary Password Confirmation -- Your password confirmation MUST match your original password";
			}
			
		if (frm_SecrUN == frm_SpecUN) {
				missinginfo += "\n     -  Consultant and Secretary Usernames must be different";
		}
	}
	
											      
	if (missinginfo != "") {
		missinginfo = "______________________________________________________________________________\n" +
		"An error has been found with the form:\n" +
		missinginfo + "\n____________________________________________________________________________" +
		"\nPlease re-enter and submit again!\n" +
		"\n*Entries must be alphanumeric and MAY include hyphens." +
		"\nDo not use any punctuation or non-alphanumeric character."
		alert(missinginfo);
		return false;
	}


if(document.profile.frmPostcode.value != '') 
 {
if (isWhitespace(document.profile.frmPostcode.value))
	{
	   alert("Please enter valid Postcode");
	   document.profile.frmPostcode.focus();
	   return false;	
	}
}

 if 	(!isValidEmail(document.profile.frmEmail.value,false))
	{
	   alert("Please enter email");
	   document.profile.frmEmail.focus();	 
	   return false;	
	}

}


function isNull(sVal) {
	if (sVal == undef || sVal.length == 0) {
		return true;
	} else {
		return false;
	}
}

function ExpressionChecker(sString, sExpression) {
	// takes in a string, and a regular expression - tests the two and returns boolean

	Reg = new RegExp(sExpression,"i") 
	return (Reg.test(sString)) // pretty simple really
}

function isDigit (c)
{   return ((c >= "0") && (c <= "9"))
}

function isInteger (s)
{   
  var i;

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!isDigit(c)) return false;
    }

    return true;
}
// Removes initial (leading) whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripInitialWhitespace (s)

{   var i = 0;

    while ((i < s.length) && charInString (s.charAt(i), whitespace))
       i++;
    
    return s.substring (i, s.length);
}


function stripTrailingWhitespace (s)
{
 var  length = s.length
 var i = 0
  
  while (s.charAt(length-1)==' ')
   {
    length = s.length - i
    i++
   }  
    return s.substring(0, length)
}    


// Removes all whitespace characters from s.
// Global variable whitespace (see above)
// defines which characters are considered whitespace.

function stripWhitespace (s)

{   return stripCharsInBag (s, whitespace)
}

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

//this function checks for valid email address
function isValidEmail(s)
{
    if (isWhitespace(s))     
        if (isValidEmail.arguments.length == 1) return false;
        else return (isValidEmail.arguments[1] == true);   
 
    // a@b.c where a b and c are any number of any characters     
    var validFormat = /^[a-zA-Z0-9\._-]+@[a-zA-Z0-9\._-]+\.[a-zA-Z]+$/i;
    return validFormat.test(s);
}





function KeyPress() 
{
//alert(window.event.keyCode)
if (window.event.keyCode == 13)
	return ValidateForm();
} 

function Con_Partner_Validate() {

	var missinginfo = '';

	if(document.form1.txtForenames.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's forename";
	}
	
	if(document.form1.txtSurname.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's surname";
	}	
	
	if(document.form1.txtAddress1.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's address line 1 for the mailing address";
	}		
	
	if(document.form1.txtTown.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's town for the mailing address";
	}	
	
	if (stripWhitespace(document.form1.txtTelephone.value) == "")  {
		missinginfo += "\n     -  Please enter the Consultant's contact telephone number";
	}
	if (!isInteger(stripWhitespace(document.form1.txtTelephone.value)))
	{
		missinginfo += "\n     -  Please enter the numeric values for telephone number";
	}
	
	if(stripWhitespace(document.form1.txtFax.value) == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's fax number";
	}
	
	if (!isInteger(stripWhitespace(document.form1.txtFax.value)))
	{
		missinginfo += "\n     -  Please enter the numeric values for fax number";
	}
	
	if (!isValidEmail(stripWhitespace(document.form1.txtEmail.value)))
	{
		missinginfo += "\n     -  Please enter the valid Consultant's email addres";
	}

	// added by ANkur on 22 nd MArch, 2006 for Ebs_Support_Req : 205
	// Medical secretary First Name
	if(stripWhitespace(document.form1.txtMedsecfirstname.value) == "" )
	{
		missinginfo += "\n     -  Please enter Medical Secretary First Name";
	}
	// Medical Secretary surname
	if(stripWhitespace(document.form1.txtMedsecsurname.value) == "" )
	{
		missinginfo += "\n     -  Please enter Medical Secretary SurName";
	}
	// Hospital Name 1
	if(stripWhitespace(document.form1.txtName_of_hospital1.value) == "" )
	{
		missinginfo += "\n     -  Please enter Hospital Name 1";
	}
	
	//*****************************
	
	if(document.form1.cboDayDOB.value == 0 || document.form1.cboMonthDOB.value == 0 || document.form1.cboYearDOB.value == 0){
		missinginfo += "\n     -  Please enter the Consultant's DOB ";
	}		
	
	var strDay = document.form1.cboDayDOB.value;
	var strMonth = document.form1.cboMonthDOB.value;
	var strYear = document.form1.cboYearDOB.value;

	if (checkDOB(strDay,strMonth,strYear)==false)
	 {
	       missinginfo += "\n     -  " + strEmptyDOB;
	       
 	 }

	if(checkDiffLessThan_N_Yrs(intTodMonth,intTodDay,intTodYear,strMonth,strDay,strYear,18))
	{
	       missinginfo += "\n     -  " + strDiffDOBDate;
	}	

	var rad_Hospital_type1;
	var rad_Hospital_type2;
	var rad_Hospital_type3;
	var rad_Hospital_type4;
	var rad_Hospital_type5;
	
	rad_Hospital_type1 = '';
	rad_Hospital_type2 = '';
	rad_Hospital_type3 = '';
	rad_Hospital_type4 = '';
	rad_Hospital_type5 = '';
	
	for (var i=0; i < document.form1.radHospital_type1.length; i++)
	{
	if (document.form1.radHospital_type1[i].checked)
      {
		rad_Hospital_type1 = document.form1.radHospital_type1[i].value;
      }   
	}
	
	for (var i=0; i < document.form1.radHospital_type2.length; i++)
	{
	if (document.form1.radHospital_type2[i].checked)
      {
		rad_Hospital_type2 = document.form1.radHospital_type2[i].value;
      }   
	}
	
	for (var i=0; i < document.form1.radHospital_type3.length; i++)
	{
	if (document.form1.radHospital_type3[i].checked)
      {
		rad_Hospital_type3 = document.form1.radHospital_type3[i].value;
      }   
	}
	
	for (var i=0; i < document.form1.radHospital_type4.length; i++)
	{
	if (document.form1.radHospital_type4[i].checked)
      {
		rad_Hospital_type4 = document.form1.radHospital_type4[i].value;
      }   
	}
	
	for (var i=0; i < document.form1.radHospital_type5.length; i++)
	{
	if (document.form1.radHospital_type5[i].checked)
      {
		rad_Hospital_type5 = document.form1.radHospital_type5[i].value;
      }   
	}			
	 
	if(document.form1.txtName_of_hospital1.value != "" && rad_Hospital_type1 == ""){
		missinginfo += "\n     -  Please select the type for hospital 1 ";
	}
	// By ankur for reverse validation on 22 nd March, 2006 for Ebs_Support_Req : 205
		if(document.form1.txtName_of_hospital1.value == "" && rad_Hospital_type1 != ""){
		missinginfo += "\n     -  Please enter hospital 1 name ";
	}
	
	if(document.form1.txtName_of_hospital2.value != "" && rad_Hospital_type2 == ""){
		missinginfo += "\n     -  Please select the type for hospital 2 ";
	}
	
	if(document.form1.txtName_of_hospital2.value == "" && rad_Hospital_type2 != ""){
		missinginfo += "\n     -  Please enter hospital 2 name ";
	}
	
	if(document.form1.txtName_of_hospital3.value != "" && rad_Hospital_type3 == ""){
		missinginfo += "\n     -  Please select the type for hospital 3 ";
	}
	
	if(document.form1.txtName_of_hospital3.value == "" && rad_Hospital_type3 != ""){
		missinginfo += "\n     -  Please enter hospital 3 name";
	}
	
	if(document.form1.txtName_of_hospital4.value != "" && rad_Hospital_type4 == ""){
		missinginfo += "\n     -  Please select the type for hospital 4 ";
	}
	
	if(document.form1.txtName_of_hospital4.value == "" && rad_Hospital_type4 != ""){
		missinginfo += "\n     -  Please enter hospital 4 name";
	}
	
	if(document.form1.txtName_of_hospital5.value != "" && rad_Hospital_type5 == ""){
		missinginfo += "\n     -  Please select the type for hospital 5 ";
	}				
	
	if(document.form1.txtName_of_hospital5.value == "" && rad_Hospital_type5 != ""){
		missinginfo += "\n     -  Please enter hospital 5 name";
	}	
	
	// added by ANkur on 22 nd MArch, 2006 for Ebs_Support_Req : 205
	if(stripWhitespace(document.form1.txtBillingGroup.value) == "" )
	{
		missinginfo += "\n     -  Please enter Billing Group Member Name";
	}
											      
	if (missinginfo != "") {
		missinginfo = "______________________________________________________________________________\n" +
		"An error has been found with the form:\n" +
		missinginfo + "\n____________________________________________________________________________" +
		"\nPlease re-enter and submit again!\n" +
		"\n*Entries must be alphanumeric and MAY include hyphens." +
		"\nDo not use any punctuation or non-alphanumeric character."
		alert(missinginfo);
		return false;
	}else{
		return true;
	}
}

function NewsEvents_Validate_Roadshow() {

	var missinginfo = '';

	if(document.roadshowsForm.txtFirstname.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's forename";
	}
	
	if(document.roadshowsForm.txtSurname.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's surname";
	}	
	
	if(document.roadshowsForm.txtEmail.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's Email address";
	}		
	
	if(document.roadshowsForm.txtTelephone.value == "" ) {
		missinginfo += "\n     -  Please enter the Consultant's contact telephone number";
	}
	
	if(document.roadshowsForm.txtComments.value == "" ) {
		missinginfo += "\n     -  Please enter some details in the comments field";
	}
		
											      
	if (missinginfo != "") {
		missinginfo = "______________________________________________________________________________\n" +
		"An error has been found with the form:\n" +
		missinginfo + "\n____________________________________________________________________________" +
		"\nPlease re-enter and submit again!\n" +
		"\n*Entries must be alphanumeric and MAY include hyphens." +
		"\nDo not use any punctuation or non-alphanumeric character."
		alert(missinginfo);
		return false;
	}
}

function findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function showHideProfile() { //v6.0
  var i,p,v,obj,args=showHideProfile.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'block':(v=='hide')?'none':v; }
    obj.display=v; }
}


function hideAllProfile(){
	showHideProfile('details','','hide');
	showHideProfile('logindetails','','hide');
	showHideProfile('seclogin','','hide');
}

function isValidName(s) {
    var i
    if (isWhitespace(s)) 
        if (isValidName.arguments.length == 1) return false;
        else return (isValidName.arguments[1] == true);

    for(i=0; i<s.length; i++) {
        if (!((s.charCodeAt(i)>=65 && s.charCodeAt(i)<=90) || 
              (s.charCodeAt(i)>=97 && s.charCodeAt(i)<=122) || 
              s.charCodeAt(i)==45 || 
              s.charCodeAt(i)==46 || 
              s.charCodeAt(i)==39 || 
              s.charCodeAt(i)==32)) return false;
    }
    return true;
}


function EditUNPW_Validate() {

	var missinginfo = '';
	var invalidinfo = '';
	var err_count = 0;
	var err_passwordMatch = 0;
	var err_UNPWLength = 0;
	

	// check the specialist username/password
		var frm_Username = document.profile.frmSpecUsername.value;
		var frm_Password = document.profile.frmSpecPassword.value;
		var frm_ConfirmPassword = document.profile.frmSpecPasswordCheck.value;
		
	
		if (frm_Username.length == 0) {
				missinginfo += "\n     -  Username";
				err_count = 1;
		}
		
			
		if (frm_Password.length == 0) {
				missinginfo += "\n     -  Password";
				err_count = 1;
		}
			
		if (frm_ConfirmPassword.length == 0) {
				missinginfo += "\n     -  Confirm password";
				err_count = 1;
		}
		
		
		if (frm_Username.length < 8  && err_count != 1) {
				missinginfo += "\n     -  Username";
				err_UNPWLength = 2;
		}
		
		if (frm_Password.length < 8  && err_count != 1) {
				missinginfo += "\n     -  Password";
				err_UNPWLength = 2;
		}
		
		if (frm_ConfirmPassword.length < 8 && err_count != 1) {
				missinginfo += "\n     -  Confirm Password";
				err_UNPWLength = 2;
		}
		
		if (frm_Password != frm_ConfirmPassword  && err_UNPWLength != 2 && err_count != 1 ) {
				missinginfo += "\n      Please enter matching passwords";
				err_passwordMatch = 3;
		}	
			
		
	if (err_count == 1) {
		missinginfo = "______________________________________\n" +
		"An error has been found with the form.\n You must enter valid information in the following fields:\n" +
		missinginfo + "\n____________________________________"
		alert(missinginfo);
		return false;
	}	
	
	if (err_UNPWLength == 2) {
		missinginfo = "______________________________________\n" +
		"The following information must be greater than or equal to 8 characters:\n" +
		missinginfo + "\n____________________________________"
		alert(missinginfo);
		return false;
	}	
	
	if (err_passwordMatch == 3) {
		missinginfo = "______________________________________\n" +
		missinginfo + "\n____________________________________"
		alert(missinginfo);
		return false;
	}			
}			

var strBankNameCP
var strAddress1CP
var strAddress2CP
var strAddress3CP
var strAddress4CP
var strPostcodeCP
var strSortCode1CP
var strSortCode2CP
var strSortCode3CP
var strAccountNumberCP
var strAccountNameCP

function CopyInvoiceDetails() {
	with(document.all){
		if(chkSameDetails.checked == true){
			strBankNameCP = txtBankNameCP.value;
			strAddress1CP = txtAddress1CP.value;       
			strAddress2CP = txtAddress2CP.value;  
			strAddress3CP = txtAddress3CP.value;  
			strAddress4CP = txtAddress4CP.value;  
			strPostcodeCP = txtPostcodeCP.value;
			strSortCode1CP = txtSortCode1CP.value;
			strSortCode2CP = txtSortCode2CP.value;
			strSortCode3CP = txtSortCode3CP.value;
			strAccountNumberCP = txtAccountNumberCP.value;
			strAccountNameCP = txtAccountNameCP.value;
		
			txtBankNameCP.value = txtBankName.value;
			txtAddress1CP.value = txtAddress1.value;       
			txtAddress2CP.value = txtAddress2.value;  
			txtAddress3CP.value = txtAddress3.value;  
			txtAddress4CP.value = txtAddress4.value;  
			txtPostcodeCP.value = txtPostcode.value;
			txtSortCode1CP.value = txtSortCode1.value;
			txtSortCode2CP.value = txtSortCode2.value;
			txtSortCode3CP.value = txtSortCode3.value;
			txtAccountNumberCP.value = txtAccountNumber.value;
			txtAccountNameCP.value = txtAccountName.value;
			
			txtBankNameCP.readOnly = true;
			txtAddress1CP.readOnly = true;       
			txtAddress2CP.readOnly = true;  
			txtAddress3CP.readOnly = true;  
			txtAddress4CP.readOnly = true;  
			txtPostcodeCP.readOnly = true;
			txtSortCode1CP.readOnly = true;
			txtSortCode2CP.readOnly = true;
			txtSortCode3CP.readOnly = true;
			txtAccountNumberCP.readOnly = true;
			txtAccountNameCP.readOnly = true;
		}
		else
		{
			txtBankNameCP.readOnly = false;
			txtAddress1CP.readOnly = false;       
			txtAddress2CP.readOnly = false;  
			txtAddress3CP.readOnly = false;  
			txtAddress4CP.readOnly = false;  
			txtPostcodeCP.readOnly = false;
			txtSortCode1CP.readOnly = false;
			txtSortCode2CP.readOnly = false;
			txtSortCode3CP.readOnly = false;
			txtAccountNumberCP.readOnly = false;
			txtAccountNameCP.readOnly = false;
		
			txtBankNameCP.value = strBankNameCP;
			txtAddress1CP.value = strAddress1CP;       
			txtAddress2CP.value = strAddress2CP;  
			txtAddress3CP.value = strAddress3CP;  
			txtAddress4CP.value = strAddress4CP;  
			txtPostcodeCP.value = strPostcodeCP;
			txtSortCode1CP.value = strSortCode1CP;
			txtSortCode2CP.value = strSortCode2CP;
			txtSortCode3CP.value = strSortCode3CP;
			txtAccountNumberCP.value = strAccountNumberCP;
			txtAccountNameCP.value = strAccountNameCP;	
		}
	}
}



