//Standard Dreamweaver Code
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_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=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}    
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
	selObj.form.action = selObj.form.action + selObj.options[selObj.selectedIndex].value;
	selObj.form.submit();
  //eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function hideDropDowns() {
  for (i = 0; i < document.forms.length; i++) {
	for (j = 0; j < document.forms[i].elements.length; j++) {
	  if (document.forms[i].elements[j].type == "select-one" || document.forms[i].elements[j].type =="select-multiple") {
		document.forms[i].elements[j].style.visibility = "hidden";
	  }
	}
  }
  if (document.getElementById("contentframe")) {
	top.contentframe.HideDropDowns();
  }
}

function showDropDowns() {
  for (i = 0; i < document.forms.length; i++) {
	for (j = 0; j < document.forms[i].elements.length; j++) {
	  if (document.forms[i].elements[j].type == "select-one" || document.forms[i].elements[j].type =="select-multiple") {
		document.forms[i].elements[j].style.visibility = "";
	  }
	}
  }
  if (document.getElementById("contentframe")) {
	top.contentframe.ShowDropDowns();
  }
}


// validateform(form) function
// validates all forms on the page, displays error message and highlights problem inputs
// fields should have an id attribute formatted id="FriendlyName,Required,DataType"
// for example <input type="text" name="txtBlahBlah" id="Text Box,1,txt">
// data types can be {txt,num,num+,int,int+,eml,dte,phone,tme}
// field names starting with 'num' will be checked that they're numeric

function validateform(myform) {

	var elementname;						// name attribute
	var elementvalue;						// value attribute
	var valid = true;						// becomes false when any error is encountered
	var errData = "";						// names of bad Data fields
	var errReq = "";						// names of missing required fields
	var id, arrid;							// array with contents of form element's id attribute
	var req;								// temp variable for required field check
	var friendly;							// friendly field name string
	var datatype;							// data type, string, eg txt, num, eml, dte
	var strError = "";
	var iTmp1;
	var iTmp2;
	var sTmp1;
	var sTmp2;
	var sTmp3;
	var arremail;
	var EACTotal = 0;
	var FutTotal = 0;
	var percentvalue = 0;
	var chkPerc = 0;
	var chkInt = 0;
	var chkFloat = 0;
	var selixd = 0;
	var selixm = 0;
	var selixy = 0;
	var dtEffIC = new Date();
	var dtEffEnt = new Date();
	var month=new Array(12);
	month[0]="Jan";
	month[1]="Feb";
	month[2]="Mar";
	month[3]="Apr";
	month[4]="May";
	month[5]="Jun";
	month[6]="Jul";
	month[7]="Aug";
	month[8]="Sep";
	month[9]="Oct";
	month[10]="Nov";
	month[11]="Dec";
	var bgColor="#D6E4EF";

	
	for (j = 0; j < myform.elements.length; j++) {
		
		elementname = myform.elements[j].name;
		elementvalue = myform.elements[j].value;
		
            // If [frmChangeInvestment] save the percentage value for use further down
		if ((myform.name == "frmChangeInvestment") || (myform.name == "frmChangeInvestmentP")) {		
			percentvalue = parseInt(elementvalue,10);			
		}
		
		req = false;
		friendly = "";
		datatype = "";
		
		// check for an id attribute, and draw out friendly name, etc.
		if (myform.elements[j].id != "") {
			id = myform.elements[j].id;
			arrid = id.split(",");
			friendly = arrid[0];
			if (parseInt(arrid[1])) req = true;
			datatype = arrid[2];
		}



		// reset borders in case they were already highlighted
		//myform.elements[j].style.borderWidth = "";
		//myform.elements[j].style.borderStyle = "";
		//myform.elements[j].style.borderColor = "";
		myform.elements[j].style.backgroundColor = "";

		// check for invalid data type if type was specified and field is not blank
		// as this will be handled later.
		if ((datatype != "") && !(elementvalue == "")) { 
			if (datatype == "num") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + friendly + " must be numeric.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "num+") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + friendly + " must be numeric.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "int") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue) || (parseInt(elementvalue) != parseFloat(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "int+") {
				elementvalue = elementvalue.replace("$", "");
				elementvalue = elementvalue.replace(",", "");
				if (isNaN(elementvalue) || (parseInt(elementvalue) != parseFloat(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a positive whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive whole number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "dte") {
				if (isNaN(Date.parse(elementvalue))) {
					valid = false;
					errData += " -  " + friendly + " must be a valid date.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "eml") {
				// put into an array to enable test for multiple email addresses
				arremail = elementvalue.split(",")
				for (var loop=0; loop < arremail.length; loop++) { 
					// new and improved RegExp
					myRegExp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
					if (arremail[loop].search(myRegExp) == -1  && arremail[loop] !='') {
						valid = false;
						errData += " -  " + friendly + " has an invalid e-mail address:'" + arremail[loop] + "'\n";
						if (loop > 0) {
							errData += "    (separate multiple addresses with ',')\n";
						}
						// highlight this problem field
						myform.elements[j].style.backgroundColor = bgColor; 
					}
				} 
			}
			if (datatype == "phone") {
				elementvalue = elementvalue.replace("(", "");
				elementvalue = elementvalue.replace(")", "");
				elementvalue = elementvalue.replace(/[\s]+/g, "");
				if (isNaN(elementvalue)) {
					valid = false;
					errData += " -  " + elementvalue + " has an invalid format.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
				else if (parseFloat(elementvalue) <= 0) {
					valid = false;
					errData += " -  " + friendly + " must be a positive number.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
			}
			if (datatype == "tme") {
  				iTmp1 = elementvalue.indexOf(":") 
  				if (iTmp1 == -1) { 
					valid = false;
					errData += " -  " + friendly + " must be a valid time.\n";
					// highlight this problem field
					myform.elements[j].style.backgroundColor = bgColor; 
				}
  				else { 
					sTmp1 = elementvalue.substr(0 , iTmp1);
					sTmp2 = elementvalue.substr(iTmp1 + 1, 2) ;
					sTmp3 = elementvalue.substr(iTmp1 + 4, 2);
					sTmp4 = elementvalue.substr(iTmp1 + 7);
  				  	if (!((!isNaN(sTmp1)) && (!isNaN(sTmp2)) && (!isNaN(sTmp3)) && (sTmp1>=0) && (sTmp1<24) && (sTmp2>=0) && (sTmp2<60) && (sTmp3>=0) && (sTmp3<60))) {
						valid = false;
						errData += " -  " + friendly + " must be a valid time.\n";
						// highlight this problem field
						myform.elements[j].style.backgroundColor = bgColor; 
					}
				} 
			}
		}
		
		// check for required field being blank
		if (req && (elementvalue == "")) {
			valid = false;
			errReq += " -  " + friendly + " is required.\n";
			// highlight this problem field
			myform.elements[j].style.backgroundColor = bgColor; 
		}

		
		// Add up the percentages in form [frmChangeInvestment()]
		if ((valid) && (myform.name == "frmChangeInvestment")) {
			iTmp1 = elementname.indexOf("EAC");
			iTmp2 = elementname.indexOf("Fut");
  			if ((iTmp1 != -1) || (iTmp2 != -1)) { 
				chkPerc = percentvalue / 5;
				chkInt = parseInt(chkPerc,10);
				chkFloat = parseFloat(chkPerc);
				if ((chkInt) != (chkFloat)) {
					valid = false;
					myform.elements[j].style.backgroundColor = bgColor; 
					if (elementname == "EACGro") {
						errData += " - " + "Current Account Growth percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACBal") {
						errData += " - " + "Current Account Balanced percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACCon") {
						errData += " - " + "Current Account Conservative percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACCas") {
						errData += " - " + "Current Account Cash percentage is not a multiple of 5.\n";
					}
					if (elementname == "FutGro") {
						errData += " - " + "Future Cash Flow Growth percentage is not a multiple of 5.\n";
					}
					if (elementname == "FutBal") {
						errData += " - " + "Future Cash Flow Balanced percentage is not a multiple of 5.\n";
					}
					if (elementname == "FutCon") {
						errData += " - " + "Future Cash Flow Conservative percentage is not a multiple of 5.\n";
					}
					if (elementname == "FutCas") {
						errData += " - " + "Future Cash Flow Cash percentage is not a multiple of 5.\n";
					}
				}
  				if (iTmp1 != -1) { 
					EACTotal += percentvalue;
				}
  				if (iTmp2 != -1) { 
					FutTotal += percentvalue;
				}
			}
		}

		
		// Add up the percentages in form [frmChangeInvestmentP()]
		if ((valid) && (myform.name == "frmChangeInvestmentP")) {
			iTmp1 = elementname.indexOf("EAC");
  			if (iTmp1 != -1) { 
				chkPerc = percentvalue / 5;
				chkInt = parseInt(chkPerc,10);
				chkFloat = parseFloat(chkPerc);
				if ((chkInt) != (chkFloat)) {
					valid = false;
					myform.elements[j].style.backgroundColor = bgColor; 
					if (elementname == "EACGro") {
						errData += " - " + "Current Account Growth percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACBal") {
						errData += " - " + "Current Account Balanced percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACCon") {
						errData += " - " + "Current Account Conservative percentage is not a multiple of 5.\n";
					}
					if (elementname == "EACCas") {
						errData += " - " + "Current Account Cash percentage is not a multiple of 5.\n";
					}
				}
  				if (iTmp1 != -1) { 
					EACTotal += percentvalue;
				}
			}
		}
		
	
		// Retrieve the Inv.Choice Date-Effective
		if (elementname == "_dtEffICDay") {
			dtEffIC.setDate(elementvalue);
		}
		if (elementname == "_dtEffICMonth") {
			dtEffIC.setMonth(elementvalue - 1);
		}
		if (elementname == "_dtEffICYear") {
			dtEffIC.setFullYear(elementvalue);
		}
		
	}

		
	// Set the Future percentages for form [frmChangeInvestmentP()]
	if (myform.name == "frmChangeInvestmentP") {
		// Check if Future Strategy radio buttons have been checked
		if (myform.futPC(0).checked) {
			FutGro = 100;
			FutTotal = 100;
		}
		if (myform.futPC(1).checked) {
			FutBal = 100;
			FutTotal = 100;
		}
		if (myform.futPC(2).checked) {
			FutCon = 100;
			FutTotal = 100;
		}
		if (myform.futPC(3).checked) {
			FutCas = 100;
			FutTotal = 100;
		}
		// Member chose allocate Future Cash by Ratio
		if (myform.Choice(1).checked) {
			FutGro = 0;
			FutBal = 0;
			FutCon = 0;
			FutCas = 0;
			FutTotal = 0;
		}
	}

	
	// Check the radio buttons on form [frmChangeInvestment()]
	if (myform.name == "frmChangeInvestment") {
		// Check if radio buttons for type of switch have been checked
		if ((!myform.chkIC(0).checked) && (!myform.chkIC(1).checked) && (!myform.chkIC(2).checked)) {
			valid = false;
			errData += " - " + "Please tick which type of switch you are doing.\n";
			myform.chkIC(0).style.backgroundColor = bgColor;
			myform.chkIC(1).style.backgroundColor = bgColor;
			myform.chkIC(2).style.backgroundColor = bgColor;
		}	

	
// ---------------------------------------------------------------------------------------------------------------		
		// Check if radio buttons for type of account have been checked
//		if ((!myform.chkBen(0).checked) && (!myform.chkBen(1).checked)) {
//			valid = false;
//			errData += " - " + "Please tick which type of account you are changing.\n";
//			myform.chkBen(0).style.backgroundColor = bgColor;
//			myform.chkBen(1).style.backgroundColor = bgColor;
//		}	
// ---------------------------------------------------------------------------------------------------------------		


	}


	// for Investment Choice change form [frmChangeInvestment()]
	// check that entered percentages match the selected switch
	// eg EAC ticked, EAC %'ages should be entered, but not Future %'ages
	// first check that percentages have been entered
	if (myform.name == "frmChangeInvestment") {
		iTmp = 0;
		if ((EACTotal == 0) && (FutTotal == 0)) {
			valid = false;
			errData += " - " + "You haven't entered any percentages.\n";
			myform.EACGro.style.backgroundColor = bgColor;
			myform.EACBal.style.backgroundColor = bgColor;
			myform.EACCon.style.backgroundColor = bgColor;
			myform.EACCas.style.backgroundColor = bgColor;
			myform.FutGro.style.backgroundColor = bgColor;
			myform.FutBal.style.backgroundColor = bgColor;
			myform.FutCon.style.backgroundColor = bgColor;
			myform.FutCas.style.backgroundColor = bgColor;
		}
		else {
			if ((myform.chkIC(0).checked) && (EACTotal == 0)) {
				valid = false;
				errData += " - " + "You selected Existing Balance switch but haven't entered your percentages.\n";
				myform.EACGro.style.backgroundColor = bgColor;
				myform.EACBal.style.backgroundColor = bgColor;
				myform.EACCon.style.backgroundColor = bgColor;
				myform.EACCas.style.backgroundColor = bgColor;
			}
			if ((myform.chkIC(0).checked) && (FutTotal != 0)) {
				valid = false;
				errData += " - " + "You selected Existing Balance switch but entered Future percentages.\n";
				myform.FutGro.style.backgroundColor = bgColor;
				myform.FutBal.style.backgroundColor = bgColor;
				myform.FutCon.style.backgroundColor = bgColor;
				myform.FutCas.style.backgroundColor = bgColor;
			}
			if ((myform.chkIC(1).checked) && (EACTotal != 0)) {
				valid = false;
				errData += " - " + "You selected Future switch but entered Existing percentages.\n";
				myform.EACGro.style.backgroundColor = bgColor;
				myform.EACBal.style.backgroundColor = bgColor;
				myform.EACCon.style.backgroundColor = bgColor;
				myform.EACCas.style.backgroundColor = bgColor;
			}
			if ((myform.chkIC(2).checked) && (EACTotal == 0)) {
				valid = false;
				errData += " - " + "You selected Existing and Future switch but haven't entered Existing percentages.\n";
				myform.EACGro.style.backgroundColor = bgColor;
				myform.EACBal.style.backgroundColor = bgColor;
				myform.EACCon.style.backgroundColor = bgColor;
				myform.EACCas.style.backgroundColor = bgColor;
			}
			if ((myform.chkIC(2).checked) && (FutTotal == 0)) {
				valid = false;
				errData += " - " + "You selected Existing and Future switch but haven't entered Future percentages.\n";
				myform.FutGro.style.backgroundColor = bgColor;
				myform.FutBal.style.backgroundColor = bgColor;
				myform.FutCon.style.backgroundColor = bgColor;
				myform.FutCas.style.backgroundColor = bgColor;
			}
		}
	}

	// Do this after the percentages have been validated	
	// for Investment Choice changes form [frmChangeInvestment()]
	// now check the entered percentages add to 100
	if ((valid) && (myform.name == "frmChangeInvestment")) {
		if ((EACTotal != 0) && (EACTotal != 100)) {
			valid = false;
			errData += " - " + "Current Account percentage must total 0 or 100.\n";
			myform.EACGro.style.backgroundColor = bgColor;
			myform.EACBal.style.backgroundColor = bgColor;
			myform.EACCon.style.backgroundColor = bgColor;
			myform.EACCas.style.backgroundColor = bgColor;
		}
		if ((FutTotal != 0) && (FutTotal != 100)) {
			valid = false;
			errData += " - " + "Future Cash Flow percentage must total 0 or 100.\n";
			myform.FutGro.style.backgroundColor = bgColor;
			myform.FutBal.style.backgroundColor = bgColor;
			myform.FutCon.style.backgroundColor = bgColor;
			myform.FutCas.style.backgroundColor = bgColor;
		}
	}
	
	
	// Do this after the percentages have been validated	
	// for Investment Choice changes form [frmChangeInvestment()]
	// now check the entered percentages add to 100
	if ((valid) && (myform.name == "frmChangeInvestmentP")) {
		if ((EACTotal != 0) && (EACTotal != 100)) {
			valid = false;
			errData += " - " + "Current Account percentage must total 0 or 100.\n";
			myform.EACGro.style.backgroundColor = bgColor;
			myform.EACBal.style.backgroundColor = bgColor;
			myform.EACCon.style.backgroundColor = bgColor;
			myform.EACCas.style.backgroundColor = bgColor;
		}
		if ((FutTotal != 0) && (FutTotal != 100)) {
			valid = false;
			errData += " - " + "Future Cash Flow percentage must total 0 or 100.\n";
			myform.FutPC.style.backgroundColor = bgColor;
		}
	}
	
	
	if ((myform.name == "frmChangeInvestment") || (myform.name == "frmChangeInvestmentP")) {
		selixd = myform.ICDay.selectedIndex;
		selixm = myform.ICMonth.selectedIndex;
		selixy = myform.ICYear.selectedIndex;
		dtEffEnt.setDate(myform.ICDay.options(selixd).value);
		dtEffEnt.setMonth(myform.ICMonth.options(selixm).value - 1);
		dtEffEnt.setFullYear(myform.ICYear.options(selixy).value);
		if (dtEffEnt < dtEffIC) {
			valid = false;
			errData += " - " + "Date Effective cannot be earlier than " + dtEffIC.getDate() + " " + month[dtEffIC.getMonth()]  + " " + dtEffIC.getFullYear() + "\n";
			myform.ICDay.style.backgroundColor = bgColor;
			myform.ICMonth.style.backgroundColor = bgColor;
			myform.ICYear.style.backgroundColor = bgColor;
		}
	}
	
	


	if (!valid) {	// if an error occurred, generate the error report display
		strError = "The data in these fields are invalid:\n\n";
		if (errReq != "") strError += errReq;
		if (errData != "") strError += errData;
		strError += "\nThe fields requiring attention have been highlighted.\n";
		alert(strError);
	}
	else {
		// disable submit button after clicking to prevent repeat submission
		myform.submit.disabled = true;
		myform.submit.value="Please wait..."
	}

	return valid;
}

	

// selectdate takes a reference to the form in which an element sits, and the name of the target field
// NB: this function always returns false, so for image inputs, you can put onclick="return selectdate(...);"
function selectdate(form, fieldname) {
	querystring = "?field=document." + form.name + "." + fieldname;
	myfield = eval(form.name + "." + fieldname);
	// sometimes we have two fields with the same name to separately edit the date and time
	// in this case we select the first one to work with
	if (myfield.length) myfield = myfield[0]
	if (myfield.value != "") {
		var myDate = new Date(myfield.value)
		querystring += "&d=" + myDate.getDate() + "&m=" + (myDate.getMonth() + 1) + "&y=" + myDate.getFullYear()
	}
	window_popup = window.open('includes/calendar.asp' + querystring, 'selectdate', 'width=210,height=203');
	window_popup.focus();
	return false;
}


//-->
