// constants
var initX       = 145; // x-coordinate of top left corner of dropdown menu 
var initY       = 290; // y-coordinate of top left corner of dropdown menu 
var backColor   = 'white'; // the background color of dropdown menu, set empty '' for transparent
var borderColor = 'black'; // the color of dropdown menu border
var borderSize  = '1'; // the width of dropdown menu border
var itemHeight  = 15;
var xOverlap    = 5;
var yOverlap    = 10;
//


menuContent     = new Array ();

menuContent [0] = new Array ( 
-1, // the id of parent menu, -1 if this is a first level menu
-1, // the number of line in parent menu, -1 if this is a first level menu
70, // the width of current menu list 
-1, // x coordinate (absolute) of left corner of this menu list, -1 if the coordinate is defined from parent x-coordinate
-1, // y coordinate (absolute) of left corner of this menu list, -1 if the coordinate is defined from parent y-coordinate
new Array (
'England', './why.php',
'Scotland', './scotwhy.php'
));

// Don't change these parameters
var delay        = 500; /////
var menuElement  = new Array ();
var usedWidth    = 0;
var numOfMenus   = 0;
/// ----------------------------

// check browser version
isNC    = (document.layers) ? 1 : 0;
isOPERA = (navigator.userAgent.indexOf('Opera') >= 0)? true : false;
isIE    = (document.all && !isOPERA)? true : false;
isDOM   = (document.getElementById && !isIE && !isOPERA)? true : false;

var topID  = -1;

// constructor of menu elements
function menuConstructor (id, content)
{
	this.ID            = id;
	this.parentID      = content [0]*1;
	this.parentItemID  = content [1]*1;
	this.width         = content [2]*1;
	this.timerID       = -1;
	this.isOn          = false;
	this.item          = new Array ();
	this.currItemID    = -1;
	
	this.x = content [3]*1;
	
	if (this.x < 0 && this.parentID == -1)
	{
		this.x = initX + usedWidth;
		usedWidth = usedWidth + this.width;
	}
	else if (this.x < 0 && this.parentID > -1)
	{
		this.x =  menuElement [this.parentID].x
			      + menuElement [this.parentID].width
			      - xOverlap;
	}
	
	this.y = content [4]*1;
	if (this.y < 0 && this.parentID == -1)
		this.y = initY;
	else if (this.y < 0 && this.parentID > -1)
		this.y =  menuElement [this.parentID].y
	 		      + itemHeight*this.parentItemID
			      + yOverlap;
	
	items = content [5];

	layerBody = '<table width=' + this.width + ' cellpadding=3 cellspacing='  + borderSize + ' border=0>';
	
	for (j = 0; j <= items.length - 2; j = j + 2)
	{
		controlBlock = ' onMouseOver = "enterItem (' + this.ID + ', ' + ((j + 2)/2 - 1) + ');" onMouseOut = "exitItem (' + this.ID + ', ' + ((j + 2)/2 - 1) + ');" ';
		layerBody += '<td height=' + itemHeight + ' width=' + this.width + ' bgcolor=' + backColor + '><a class=subMenu href='+ items [j + 1] +' ' + controlBlock + '>' + items [j] + '</a></td>';
		if (j < items.length - 2)
			layerBody = layerBody +  '<tr>\n';
		else
			layerBody = layerBody + '\n';
	}

	if (!isNC)
		layerHeader = '<div id=Menu' + this.ID +
				   	   ' onMouseOver="enterMenu (' + this.ID + ');" onMouseOut = "exitMenu (' + this.ID + ');"' +
		    	       ' style="background: ; width: ' + this.width + '; visibility: hidden; position: absolute; left: ' + this.x +
		        	   '; top: ' + this.y + ';">';
	else
		layerHeader = '<layer id=Menu' + this.ID +
					   ' onMouseOver="enterMenu (' + this.ID + ');" onMouseOut = "exitMenu (' + this.ID + ');"' +
					   ' visibility=hide left=' + this.x +
					   ' top =' + this.y + '>';

	layerHeader += '<table width=' + this.width + ' cellpadding=0 cellspacing=0 border=0>' +
				    '<td bgcolor=' + borderColor + '>';

	layerFooter = '</table></td></table>';

	if (!isNC)
		layerFooter = layerFooter + '</div>';
	else
		layerFooter = layerFooter + '</layer>';

	document.writeln (layerHeader + layerBody + layerFooter);

	return this;
}
function enterTopItem (ID)
{
	if (topID != ID && topID != -1)
		hideTree (topID);
	releaseTree (ID);
	topID = ID;
	show (ID);
}
function exitTopItem (ID)
{
	menuElement [ID].timerID = setTimeout ('hide (' + ID + ')', delay);
}
function enterItem (menuID, itemID)
{
	var currItemID = menuElement [menuID].currItemID;

	if (currItemID != i & currItemID > -1)	
		hide (currItemID);
	

	for (var i = 0; i < numOfMenus; i++)
	{
		if (menuElement [i].parentID == menuID &&
		    menuElement [i].parentItemID == itemID)
		{
			clearTimeout (menuElement [i].timerID);
			menuElement [i].timerID = -1;
			show (i);
			return 0;
		}
	}

	return -1;
}
function exitItem (menuID, itemID)
{
	for (var i = 0; i < numOfMenus; i++)
	{
		if (menuElement [i].parentID == menuID &&
		    menuElement [i].parentItemID == itemID)
		{
			menuElement [i].timerID = setTimeout ('hide (' + i + ')', delay);
			return 0;
		}
	}
}
function enterMenu (ID)
{
	var parentID = menuElement [ID].parentID;
	if (parentID == -1)
	{
		clearTimeout (menuElement [ID].timerID);
		menuElement [ID].timerID = -1;
	}
	else
		releaseTree (ID);
}
function exitMenu (ID)
{
	timeoutTree (ID);
}
function hideTree (ID)
{
	hide (ID);
	for (var j = 0; j < numOfMenus; j++)
	{
		if (menuElement [j].parentID == ID &&
			menuElement [j].isOn)
		{
			hideTree (j);
			return 0;
		}
	}
}
function releaseTree (ID)
{
	clearTimeout (menuElement [ID].timerID);
	menuElement [ID].timerID = -1;

	var parentID = menuElement [ID].parentID;
	if (parentID > -1)
		releaseTree (parentID);
}
function timeoutTree (ID)
{
	menuElement [ID].timerID = setTimeout ('hide (' + ID + ')', delay);
	var parentID = menuElement [ID].parentID;
	if (parentID > -1)
		timeoutTree (parentID);
}

function show (ID)
{
	if (isDOM) 
		document.getElementById('Menu' + ID).style.visibility = "visible";
    	else if (isIE) {
		document.all['Menu' + ID].style.visibility = "visible";
		document.all['Menu' + ID].style.zindex = "10";
        }
      	else if (isNC) 
		document.layers[ID].visibility = "show";		

	menuElement [ID].isOn = true;

	if (menuElement [ID].parentID > -1)
		menuElement [menuElement [ID].parentID].currItemID = ID;
}

function hide (ID)
{
	if (isDOM) 
		document.getElementById('Menu' + ID).style.visibility = "hidden";
    	else if (isIE) 
		document.all['Menu' + ID].style.visibility = "hidden";
      	else if (isNC) 
		document.layers[ID].visibility = "hide";

	menuElement [ID].isOn = false;

	if (menuElement [ID].parentID > -1)
		menuElement [menuElement [ID].parentID].currItemID = -1;
}

function createMenuTree ()
{
	for (var i = 0; i < menuContent.length; i++)
	{
		menuElement [i] = new menuConstructor (i, menuContent [i]);
		numOfMenus++;
	}
}

createMenuTree ();


// Function used by Executor and Guardian screens
function initWind2() {
   getBrowserType();
   document.forms[0].reset();
   if (ie) namesRow = document.all.namesArea.innerHTML;
   if (netscape) namesRow = document.namesArea.innerHTML;
   loadNames();
}
// End of JS function initWind2()

// Function to open a new window for links to other sites
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// Function used by executor and guardian screens
// Checks to see if a person has already been included
function chkPersonId(personId) {
var i;
var fldName;
var prefix;
var suffix;
var suffixLoc;
var statName;

   for (i = 0; i < document.forms[0].elements.length; i++)
   {
     fldName = document.forms[0].elements[i].name;
     if(fldName.match(/^[PS]persid/)
        && document.forms[0].elements[i].value == personId)
     {
       prefix=fldName.charAt(0);
       suffixLoc=fldName.indexOf('d')+1;
       suffix=fldName.substr(suffixLoc,fldName.length);
       statName=prefix+'dbStat'+suffix;
       if(document.forms[0].elements[statName].value != 'D')
         return true;
     }
   }
   return false;
}
// End of JS function chkPersonId()


//------------------------------------------------------------------------
// Formats an address so that empty fields don't result in surplus commas
//------------------------------------------------------------------------
function formatted_address(line1,line2,town,county,postcode)
{
  var address = line1;
  if(address && line2)    address += ', '+line2;
  else                    address += line2;
  if(address && town)     address += ', '+town;
  else                    address += town;
  if(address && county)   address += ', '+county;
  else                    address += county;
  if(address && postcode) address += ', '+postcode;
  else                    address += postcode;

  return address;
}
// End of JS function formatted_address()



//--------------------------------------------------------------------
// Formats a name so that empty fields don't result in surplus spaces
//--------------------------------------------------------------------
function formatted_name(firstname,initials,surname)
{
  var name = firstname;
  if(name && initials) name += ' '+initials;
  else                 name += initials;
  if(name && surname)  name += ' '+surname;
  else                 name += surname;

  return name;
}
// End of JS function formatted_name()



//-------------------------------------------------------
// Checks if relationship should be used instead of name
//-------------------------------------------------------
function use_rel(rel)
{
  if(rel=='Children' || rel=='Grandchildren' || rel=='Parents')
    return true;
  else
    return false;
}


// Function used by executor and guardian screens
// Creates a new empty HTML member or substitute member record
// and give all elements a prefix 'p' and a suffix 's'
function newMemberRow(p,s)
{
  var emptyRow =
  '<TABLE ID="'+p+s+'" width="450" bgcolor="#CC9966" align="center" cellspacing="0" cellpadding="0">' +
  '<TR><TD width="20" height="10"></TD><TD width="350"></TD><TD width="10"></TD><TD width="70"></TD></TR>' +
  '<TR>' +
    '<TD>' +
      '<INPUT type="hidden" name="'+p+'dbStat'+s+'">' +
      '<INPUT type="hidden" name="'+p+'persid'+s+'">' +
      '<INPUT type="hidden" name="'+p+'memberType'+s+'">' +
      '<INPUT type="hidden" name="'+p+'chgNum'+s+'" value="'+s+'">' +
    '</TD>' +
    '<TD ID="'+p+'Person' +s+ '" style="font-size:11; font-weight:bold" valign="top"></TD>' +
    '<TD><br></TD><TD>' +
    '<img name="'+p+'delete'+s+'" src="../images/uremove.gif" width="45" height="13" ' +
         'onMouseDown="document.all[\''+p+'delete'+s+'\'].src=\'../images/dremove.gif\';" ' +
         'onMouseUp="document.all[\''+p+'delete'+s+'\'].src=\'../images/uremove.gif\';" ' +
         'onMouseOut="document.all[\''+p+'delete'+s+'\'].src=\'../images/uremove.gif\';" ' +
         'onClick="removeRow(\''+p+'\',\''+s+'\')">' +
    '</TD>' +
  '</TR>' +
  '<TR>' +
    '<TD><br></TD>' +
    '<TD ID="'+p+'Address' +s+ '" style="font-size:11; font-weight:bold" valign="top"></TD>' +
  '<TD colspan="2"><br></TD></TR>' +
  '</TABLE>' +
  '<DIV ID="'+p+'addMemberHere"></DIV>';

  return emptyRow;
}
// End of JS function newMemberRow()



//----------------------------------------------------
// Function used by testator screen to remove partner
//----------------------------------------------------
function removePartner()
{
  document.all.Person.innerHTML='';
}
// End of JS function removeRow()



//------------------------------------------------
// Function used by executor and guardian screens
// Deletes a row
//------------------------------------------------
function removeRow(prefx,suffx)
{
  RowName = prefx + suffx;
  dbStat = prefx + 'dbStat' + suffx;
  Pcount--;

  // If this is a database record then logically delete else physically delete
  if(document.all[dbStat].value == 'Y'){
    document.all[dbStat].value = 'D'
    document.all[RowName].className = "collapsed";
  }
  else
    document.all[RowName].outerHTML = "";
}
// End of JS function removeRow()



//---------------------------------------------------
// Function used by testator screen. Copies a person
// from the names panel to the partner block
//---------------------------------------------------
function addMirror(fromFormField,prefix) {
 var mesg;

  elementNo = fromFormField.name.slice(11);

  nameElm = 'nameName' + elementNo;
  fullnameElm = 'nameVal' + elementNo;
  idElm = 'nameId' + elementNo;
  addr1Elm = 'nameAddr1' + elementNo;
  addr2Elm = 'nameAddr2' + elementNo;
  townElm = 'nameTown' + elementNo;
  countyElm = 'nameCounty' + elementNo;
  postcodeElm = 'namePostCode' + elementNo;
  relElm = 'nameRel' + elementNo;


  PersonIdVal=document.forms[0].elements[idElm].value;

  // The following checks and warns for certain GROUP relationships
  relationship = document.forms[0].elements[relElm].value;
  if(use_rel(relationship))
  {
    mesg = 'Only a named person can be selected as your partner.';
    alert(mesg);
    return false;
  }
  else
    FullName='&nbsp;&nbsp;' + document.forms[0].elements[fullnameElm].value;

  AddressStr='&nbsp;&nbsp;' +
          formatted_address(document.forms[0].elements[addr1Elm].value,
                            document.forms[0].elements[addr2Elm].value,
                            document.forms[0].elements[townElm].value,
                            document.forms[0].elements[countyElm].value,
                            document.forms[0].elements[postcodeElm].value);

  // Copy data into partner block
  document.all.Person.innerHTML=FullName;
  document.all.Address.innerHTML=AddressStr;
  document.all.chgsper1.value=1;
  document.all.idsper1.value=PersonIdVal;
  document.all.remove.style.display='block';
}
// End of JS function addMirror()



//------------------------------------------------
// Function used by executor and guardian screens
// Adds a member or substitute member
//------------------------------------------------
function addMember(fromFormField,prefix,memberType) {
 var mesg;

  elementNo = fromFormField.name.slice(11);

  nameElm = 'nameName' + elementNo;
  fullnameElm = 'nameVal' + elementNo;
  idElm = 'nameId' + elementNo;
  addr1Elm = 'nameAddr1' + elementNo;
  addr2Elm = 'nameAddr2' + elementNo;
  townElm = 'nameTown' + elementNo;
  countyElm = 'nameCounty' + elementNo;
  postcodeElm = 'namePostCode' + elementNo;
  relElm = 'nameRel' + elementNo;


  PersonIdVal=document.forms[0].elements[idElm].value;
  if(chkPersonId(PersonIdVal))
  {
    mesg="This person already exists as "+memberType+" or substitute "+memberType;
    alert(mesg);
    return false;
  }

  if(chkMemberCount(prefix)==false) return false;

  // The following checks and warns for certain GROUP relationships
  relationship = document.forms[0].elements[relElm].value;
  if(use_rel(relationship))
  {
    mesg = 'You must give the full name and address of each person to be named here.\n'
          +'I.e. If you wish to name your parents then you must create each by name in '
          +'the \'NAMES PANEL\' first.';
    alert(mesg);
    return false;
  }
  else
    FullName='&nbsp;&nbsp;' + document.forms[0].elements[fullnameElm].value;

  Address='&nbsp;&nbsp;' +
          formatted_address(document.forms[0].elements[addr1Elm].value,
                            document.forms[0].elements[addr2Elm].value,
                            document.forms[0].elements[townElm].value,
                            document.forms[0].elements[countyElm].value,
                            document.forms[0].elements[postcodeElm].value);

  // Generate DIV tag name
  DivName=prefix+'addMemberHere';

  // Create new empty html table
  suffix=parseInt(document.all["chgCounter"].value) + 1;
  document.all["chgCounter"].value=suffix;
  document.all[DivName].outerHTML=newMemberRow(prefix,suffix);

  // Determine object names
  PersonObj=prefix+'Person'+suffix;
  AddressObj=prefix+'Address'+suffix;
  DBStatObj=prefix+'dbStat'+suffix;
  MemberTypeObj=prefix+'memberType'+suffix;
  PersIdObj=prefix+'persid'+suffix;

  // Insert data into empty table
  document.all[PersonObj].innerHTML=FullName;
  document.all[AddressObj].innerHTML=Address;
  document.forms[0].elements[DBStatObj].value='N';
  document.forms[0].elements[MemberTypeObj].value=prefix;
  document.forms[0].elements[PersIdObj].value=PersonIdVal;
}
// End of JS function addMember()


// Debugging function lists all elements of a form together with values
function getElements() {
var i;
var list;
   
   for (i = 0; i < document.forms[0].elements.length; i++) {
     list=list + document.forms[0].elements[i].name + '(' + i + '): ' +
         document.forms[0].elements[i].value + '<br>';
   }
   return list;
}


function getBrowserType() {
   netscape = false;
   ie = false;
   
   if (parseInt(navigator.appVersion) >= 4) {
      if (navigator.appName == "Microsoft Internet Explorer")
         ie = true;
      if (navigator.appName == "Netscape")
         netscape = true;
   }
}


function getElementNo(fldName, startPoint) {
var i;
   
   for (i = startPoint; i < document.forms[0].elements.length; i++) {
      if (document.forms[0].elements[i].name == fldName) {
         return i;
      }
   }
}


//var navClicked;
function get_next(fromscreen,toscreen){
//  if(navClicked == 'Y')
//    return (false);
//  navClicked = 'Y';
  var prog = fromscreen + "_upd.php";
  document.all.to.value=toscreen;
  document.all.will.action=prog;
  document.all.will.submit();
}


// validates whether an age value is numeric and at least 18
function checkAge(f) {

   if (f.value == "") return;

   if (isNaN(f.value) == true) {

      alert("Age must be numeric");
      f.focus();
      return false;
   }

   if (f.value < 18) {

      alert("A beneficiary must be at least 18 to inherit a bequest.");
      f.focus();
      return false;
   }
}

function glossary(termName)
{
var posName = "../glossary.html#" + termName
var helpWin = window.open(posName, 'glossary',"menubar=no,scrollbars=yes,status=no,toolbar=no,directories=no,width=350,height=100,resizable=yes");
helpWin.focus();
}

function glossary1(termName)
{
var posName = "./glossary.html#" + termName
var helpWin = window.open(posName, 'glossary',"menubar=no,scrollbars=yes,status=no,toolbar=no,directories=no,width=350,height=100,resizable=yes");
helpWin.focus();
}

function info(subject)
{
var posName = "../info.php?location=" + subject
var helpWin = window.open(posName, 'information',"menubar=no,scrollbars=yes,status=no,toolbar=no,directories=no,width=540,height=400,resizable=yes");
helpWin.focus();
}

function info1(subject)
{
var posName = "./info.php?location=" + subject
var helpWin = window.open(posName, 'information',"menubar=no,scrollbars=yes,status=no,toolbar=no,directories=no,width=540,height=400,resizable=yes");
helpWin.focus();
}

function copyResAddr()
{
    document.will.chgsaddr1.value = 1;
    document.will.sResl1.value = document.will.tResl1.value;
    document.will.sResl2.value = document.will.tResl2.value;
    document.will.sRestwn.value = document.will.tRestwn.value;
    document.will.sRescnty.value = document.will.tRescnty.value;
    document.will.sRespc.value = document.will.tRespc.value;
}

function copyCorAddr()
{
    document.will.chgsaddr2.value = 1;
    document.will.sCorl1.value = document.will.tCorl1.value;
    document.will.sCorl2.value = document.will.tCorl2.value;
    document.will.sCortwn.value = document.will.tCortwn.value;
    document.will.sCorcnty.value = document.will.tCorcnty.value;
    document.will.sCorpc.value = document.will.tCorpc.value;
}

function do_tSex()
{
  document.all.chgtper1.value=1;

  // If mirror is a spouse
  if(document.will.tmpRelation && document.will.tmpRelation.selectedIndex==0){
    if(document.will.tSex[0].checked==true && document.will.sSex.value=='M'){
      document.will.sSex.value='F';
      document.will.sRelation.value='Wife';
      document.all.chgsper1.value=1;
    }
    else{
      if(document.will.tSex[1].checked==true && document.will.sSex.value=='F'){
        document.will.sSex.value='M';
        document.will.sRelation.value='Husband';
        document.all.chgsper1.value=1;
      }
    }
  }
}

function do_sSex()
{
  document.all.chgsper1.value=1;
  if(document.will.tmpSex[0].checked==true)
    document.will.sSex.value='M';
  else
    document.will.sSex.value='F';
  document.will.sRelation.value='Partner';
}

function do_sRelation()
{
  var isMale = '';
  var isFemale = '';
  // If changed to spouse
  if(document.will.tmpRelation.selectedIndex==0)
  {
    document.all.chgsper1.value=1;
    document.all.sex.innerHTML='<br>';
    document.all.male.innerHTML='<br>';
    document.all.female.innerHTML='<br>';
    if(document.will.tSex[1].checked==true){
      document.will.sRelation.value='Husband';
      document.will.sSex.value='M';
    }
    else{
      document.will.sRelation.value='Wife';
      document.will.sSex.value='F';
    }
  }
  else
  {
    if(document.will.sSex.value=='M') isMale='CHECKED';
    else isFemale='CHECKED';
    document.all.chgsper1.value=1;
    document.will.sRelation.value='Partner';
    document.all.sex.innerHTML='&nbsp;&nbsp;Sex:';
    maleStr='Male<sub><INPUT type="radio" name="tmpSex" value="M" ' + isMale
             + ' onClick="document.all.chgsper1.value=1; document.will.sSex.value=\'M\'"></sub>';
    document.all.male.innerHTML=maleStr;
    femaleStr='Female<sub><INPUT type="radio" name="tmpSex" value="F" ' + isFemale
              + ' onChange="document.all.chgsper1.value=1; document.will.sSex.value=\'F\'"></sub>';
    document.all.female.innerHTML=femaleStr;
  }
}


// Function to check and if necessary call the add or remove partner block functions
function doPartnerBlockChecks()
{
  if(document.all.mirror.checked==true || document.all.out2bmarried.checked==true)
    document.all.partnersection.style.display='block';
  else
    document.all.partnersection.style.display='none';

  if(document.all.mirror.checked==true)
    document.all.mirrortext.style.display='block';
  else
    document.all.mirrortext.style.display='none';
}


// FOLLOWING FUNCTION NOW REDUNDENT
/*
function doPartnerBlockChecks()
{
  if(document.all.PartnerBlockVisible.value=='Y')
  {
    if(document.all.mirror.checked==false)
    {
      offMirrorText();
      if(document.all.out2bmarried.checked==false)
        removePartnerBlock();
    }
    else
      onMirrorText();
  }
  else
  {
    if(document.all.mirror.checked==true || document.all.out2bmarried.checked==true)
      addPartnerBlock();
    if(document.all.mirror.checked==true)
      onMirrorText();
  }
}
*/

// FOLLOWING FUNCTION NOW REDUNDENT
// Removes the mirror text by replacing it with an empty table
function offMirrorText()
{
var offMT;
offMT='<TABLE ID="mirrortext" width="420" align="center" cellspacing="0" cellpadding="0">\
     <TR><TD></TD></TR></TABLE>';
document.all.mirrortext.outerHTML=offMT;
}


// FOLLOWING FUNCTION NOW REDUNDENT
// Adds the mirror text by replacing the empty table
function onMirrorText()
{
var onMT;
onMT='<table ID="mirrortext" width="420" align="center" cellspacing="0" cellpadding="0">\
      <tr><td style="font-size:12"><br>\
        A mirror Will is identical to your own Will except that all instances\
          of your name are interchanged with the person named below.<br>\
          If you are going to leave everything to each other then you must name your\
          partner as a beneficiary in the \'Residue\' screen.\
        </td></tr></table>';
document.all.mirrortext.outerHTML=onMT;
}


// FOLLOWING FUNCTION NOW REDUNDENT
// Function to remove the partner block from the testator screen
function removePartnerBlock()
{
  document.all.partnersection.outerHTML='\
       <TABLE ID="partnersection" width="710" align="center" cellspacing="0" \
       cellpadding="0"><TR><TD><br></TD></TR></TABLE>';
  document.all.PartnerBlockVisible.value='N';
}

// FOLLOWING FUNCTION NOW REDUNDENT
/*
function removePartnerBlock()
{
  document.all.partnerblock.outerHTML='\
       <TABLE ID="partnerblock" width="696" align="center" cellspacing="0" \
       cellpadding="0"><TR><TD><br></TD></TR></TABLE>';
  document.all.PartnerBlockVisible.value='N';
}
*/

// FOLLOWING FUNCTION NOW REDUNDENT
function addPartnerBlock()
{
var mS;
if(document.will.tSex[0].checked==true) {relation='Wife'; sex='F';}
else {relation='Husband'; sex='M'};
document.will.sRelation.value=relation;
document.will.sSex.value=sex;
mS='<table ID="partnerblock" align="center" cellspacing="0" cellpadding="0">\
    <tr><td height="10"><br></td></tr>\
    <tr><td style="font-size:12">Enter the details of your spouse/partner in the boxes below.</td></tr>\
    <tr><td>\
    <TABLE class="testatorpanel" align="center" cellspacing="0" cellpadding="0">\
    <TR><TD colspan="12" align="center" style="font-size:12"><b><u>SPOUSE/PARTNER</u></b></TD></TR>\
    <TR><TD width="10"><br></TD>\
    <TD class="td2" width="120" colspan="2">&nbsp;&nbsp;&nbsp;First name</TD>\
    <TD class="td2" width="110" style="font-size:11">Surname</TD>\
    <TD class="td2" width="40" style="line-height:12px">Other<br>initials</TD>\
    <TD class="td2" width="77" align="center">Relationship</TD>\
    <TD width=20><br></TD>\
    <TD class="td2" width="110" align="right" style="line-height:12px">\
    Residential&nbsp;&nbsp;&nbsp;&nbsp;<br>Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</TD>\
    <TD width="40" align="right">\
    <img src="../images/uasabove.gif" width="40" height="30"\
                alt="Copies the residential address from above"\
                onMouseDown="this.src=\'../images/dasabove.gif\';"\
                onMouseUp="this.src=\'../images/uasabove.gif\';"\
                onMouseOut="this.src=\'../images/uasabove.gif\';"\
                onClick="copyResAddr()"></TD>\
    <TD class="td2" width="113" align="center" style="line-height:12px">\
    Correspondence<br>Address <span style="font-size:10">(if different)</span></TD>\
    <TD width="47" align="left">\
    <img src="../images/uasabove.gif" width="40" height="30"\
                alt="Copies the correspondence address from above"\
                onMouseDown="this.src=\'../images/dasabove.gif\';"\
                onMouseUp="this.src=\'../images/uasabove.gif\';"\
                onMouseOut="this.src=\'../images/uasabove.gif\';"\
                onClick="copyCorAddr()">\
    </TD><TD width="10"><br></TD></TR>\
    <TR><TD><br></TD><TD align="left" valign="top" colspan="2">&nbsp;\
    <INPUT type="text" name="sFirst" size="14" maxlength="30" tabindex="14"\
    onChange="document.all.chgsper1.value=1"></TD><TD align="left" valign=top">\
    <INPUT type="text" name="sSurname" size="14" maxlength="30" tabindex="15"\
    onChange="document.all.chgsper1.value=1"></TD><TD valign=top>\
    <INPUT type="text" name="sInitials" size="4" maxlength="4" tabindex="16"\
    onChange="document.all.chgsper1.value=1"></TD>\
    <TD valign="top" align="center">\
    <select name="tmpRelation" tabindex="17" onChange="do_sRelation()">\
    <option value="Spouse" SELECTED>Spouse</option>\
    <option value="Partner" >Partner</option>\
    </select></TD><TD><br></TD><TD valign="top" align="right" colspan="2">\
    <INPUT type="text" name="sResl1" tabindex="18"\
    onChange="document.all.chgsaddr1.value=1"></TD>\
    <TD valign=top align="center" colspan="2">\
    <INPUT type="text" name="sCorl1" tabindex="23"\
    onChange="document.all.chgsaddr2.value=1"></TD><TD><br></TD>\
    </TR><TR><TD colspan="7"><br></TD>\
    <TD valign=top align="right" colspan="2">\
    <INPUT type="text" name="sResl2" tabindex="19"\
    onChange="document.all.chgsaddr1.value=1"></TD>\
    <TD valign=top align="center" colspan="2">\
    <INPUT type="text" name="sCorl2" tabindex="24"\
    onChange="document.all.chgsaddr2.value=1"></TD><TD><br></TD></TR>\
    <TR height="20px"><TD><br></TD><TD ID="sex"></TD>\
    <TD class="td2" ID="male" width="70" align="right"></TD>\
    <TD colspan="2"><br></TD><TD class="td2" colspan="2" align="right">Town</TD>\
    <TD valign=top align="right" colspan="2">\
    <INPUT type="text" name="sRestwn" tabindex="20"\
    onChange="document.all.chgsaddr1.value=1"></TD>\
    <TD valign=top align="center" colspan="2">\
    <INPUT type="text" name="sCortwn" tabindex="25"\
    onChange="document.all.chgsaddr2.value=1"></TD><TD><br></TD></TR>\
    <TR height="20px"><TD colspan="2"><br></TD>\
    <TD class="td2" ID="female" width="70" align="right"></TD>\
    <TD colspan="2"><br></TD><TD class="td2" colspan="2" align="right">County</TD>\
    <TD valign="top" align="right" colspan="2">\
    <INPUT type="text" name="sRescnty" tabindex="21"\
    onChange="document.all.chgsaddr1.value=1"></TD>\
    <TD valign="top" align="center" colspan="2">\
    <INPUT type="text" name="sCorcnty" tabindex="26"\
    onChange="document.all.chgsaddr2.value=1"></TD><TD><br></TD></TR>\
    <TR><TD colspan="5"></TD><TD class="td2" colspan="2" align="right">Postcode</TD>\
    <TD valign="top" align="right" colspan="2">\
    <INPUT type="text" name="sRespc" tabindex="22"\
    onChange="document.all.chgsaddr1.value=1"></TD>\
    <TD valign="top" align="center" colspan="2">\
    <INPUT type="text" name="sCorpc" tabindex="27"\
    onChange="document.all.chgsaddr2.value=1"></TD><TD><br></TD></TR>\
    <TR><TD colspan="8"><br></TD><TD colspan="3" align="right">\
    <br></TD><TD><br></TD></TR></TABLE> </td></tr></table>';
    document.all.partnerblock.outerHTML=mS;
    document.all.PartnerBlockVisible.value='Y';
}
