/* Special Validation */
if (top != self) top.location.replace(location);

// JScript source code
/**
 * SWFObject v1.4.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){
if(!document.createElement||!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7);
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;
},getSWFHTML:function(){
var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}
_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){
var _25=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
for(var i=3;axo!=null;i++){axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i);_25=new deconcept.PlayerVersion([i,0,0]);}}
catch(e){}
if(_23&&_25.major>_23.major){return _25;}
if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){
try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}
catch(e){}}}return _25;};
deconcept.PlayerVersion=function(_29){
this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0;
this.minor=parseInt(_29[1])||0;
this.rev=parseInt(_29[2])||0;};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){return false;}return true;};
deconcept.util={getRequestParameter:function(_2b){
var q=document.location.search||document.location.hash;
if(q){var _2d=q.indexOf(_2b+"=");
var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length;
if(q.length>1&&_2d>-1){return q.substring(q.indexOf("=",_2d)+1,_2e);}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){
var _2f=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2f.length;i++){
for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=null;}}}};
if(typeof window.onunload=="function"){
var oldunload=window.onunload;
window.onunload=function(){deconcept.SWFObjectUtil.cleanupSWFs();oldunload();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}
if(Array.prototype.push==null){
Array.prototype.push=function(_32){
this[this.length]=_32;
return this.length;};}

var getQueryParamValue = deconcept.util.getRequestParameter;
var FlashObject = deconcept.SWFObject; // for backwards compatibility
var SWFObject = deconcept.SWFObject;

function addLoadEvent(func) {	
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;		
	} 
	else {
		window.onload = function() {
		oldonload();
		func();
		}
	}
}

// Date Validation
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

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++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

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 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		//alert("The date format should be : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		//alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		//alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		//alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){		
		return false;
	}
	else{
		return true;
	}
}

// Navation Dropdown
addLoadEvent(function() {
    if (document.all && document.getElementById) {
        navRoot = document.getElementById("navlist");

        if (navRoot) {
            for (i = 0; i < navRoot.childNodes.length; i++) {
                node = navRoot.childNodes[i];
                if (node.nodeName == "LI") {
                    node.onmouseover = function() {
                        this.className += " over";
                    }
                    node.onmouseout = function() {
                        this.className = this.className.replace(" over", "");
                    }
                }
            }
        }
    }
})

// JScript source code
function isValidEmail(str) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
		return true;
	}
	else {
		return false;
	}
}

function checkenquiryform(){
	var ftxt = '';

	if (document.enquiryform.Name.value==''){
		ftxt += '\n- Please enter your Name.';
	}
	
	if (document.enquiryform.PhoneNumber.value==''){
		ftxt += '\n- Please enter your Telephone Number.';
	}
	
	if (isValidEmail(document.enquiryform.email.value)==false){
		ftxt += '\n- Please enter your Email Address.';
	}
	
	if (document.enquiryform.Enquiry.value==''){
		ftxt += '\n- Please enter your Enquiry.';
	}
	
	if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

/* Mailing List Signup */
function checkmailingform(){
    var ftxt = '';
    
    if (document.mailinglist.Name.value==''){
        ftxt += '\n- Please enter your Name.';
    }
    
    if (isValidEmail(document.mailinglist.EmailAddress.value)==false){
        ftxt += '\n- Please enter an Email Address.';
    }
    
    var typecount = document.mailinglist.TypeCount.value;
    if (typecount==1){
        if (document.mailinglist.TypeID.checked==false){
            ftxt += '\n- Please select a Mailing List.';
        }
    }
    else {
        var bmailing = false;
        for (var i=0;i<typecount;i++){
            if (document.mailinglist.TypeID[i].checked==true){
                bmailing = true;
            }
        }
        if (bmailing==false){
            ftxt += '\n- Please select at least one Mailing List.';
        }
    }  
    
    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}  
}

/* Login Pages etc */
function checkloginform(){
    var ftxt = '';
    
    if (isValidEmail(document.loginform.EmailAddress.value)==false){
        ftxt += '\n- Please enter your Email Address.';
    }
    
    if (document.loginform.Password.value==''){
        ftxt += '\n- Please enter your Password.';
    }
    
    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	} 
}

function confirmLogout(){
    if (confirm('Are you sure you want to logout?')){
        location.href='risk_rated_funds_reports.asp?Logout=True';
    }
}

function checkcustomiseform(){
    var ftxt = '';
    
    if (document.customiseform.ReportName.value==''){
        ftxt += '\n- Please enter a Client Name.';
    }    
    
    if (document.customiseform.ReportAdvisor.value==''){
        ftxt += '\n- Please enter an Advisor Name.';
    }  
    
    if (document.customiseform.ReportCompany.value==''){
        ftxt += '\n- Please enter an Advisor Company.';
    }     
    
    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	} 
}

/* IFA Subscription */
function checkifasubscriptionform(){
    var ftxt = '';
    
    if (document.ifasubscription.Title.value==''){
        ftxt += '\n- Please enter your Title;';
    }
    
    if (document.ifasubscription.FirstName.value==''){
        ftxt += '\n- Please enter your First Name.';
    }
    
    if (document.ifasubscription.LastName.value==''){
        ftxt += '\n- Please enter your Last Name.';
    }
    
    if (document.ifasubscription.Company.value==''){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.ifasubscription.Telephone.value==''){
        ftxt += '\n- Please enter your Telephone Number.';
    }
    
    if (isValidEmail(document.ifasubscription.EmailAddress.value)==false){
        ftxt += '\n- Please enter your Email Address.';
    }
    
    if (document.ifasubscription.Address1.value==''){
        ftxt += '\n- Please enter your Address 1.';
    }
    
    if (document.ifasubscription.City.value==''){
        ftxt += '\n- Please enter your City.';
    }
    
    if (document.ifasubscription.County.value==''){
        ftxt += '\n- Please enter your County.';
    }
    
    if (document.ifasubscription.Postcode.value==''){
        ftxt += '\n- Please enter your Postcode.';
    }
    
    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
	    if (document.ifasubscription.RegulatedIndividual.checked==true){
		    return true;
		}
		else {
		    alert('You must select that you are a Regulated Individual to be able to register online.');
		    return false;
		}
	} 
}

/* Wizard */
function controlQuestion2(theval){
    var Question2Title = document.getElementById("Question2Title");
    var Question2_1 = document.getElementById("Question2_1");    
    var Question2_2 = document.getElementById("Question2_2");
    var Question2_3 = document.getElementById("Question2_3");
    var Question2_4 = document.getElementById("Question2_4");
    var Question2_5 = document.getElementById("Question2_5");
    
    if (theval=='1'){
        Question2Title.innerHTML = "2) How would you classify your stage of life?"
        Question2_1.innerHTML = "Retired - I no longer work and I now live off my assets";
        Question2_2.innerHTML = "Nearing retirement - I am within a few years of retirement when I will have to depend on my assets";
        Question2_3.innerHTML = "Established career - I am enjoying my peak earning potential and need to start considering my retirement";
        Question2_4.innerHTML = "Mid career - I have gained several years experience and roughly half way between starting to work and my retirement (typically 35 - 45 years of age)";
        Question2_5.innerHTML = "Early career - I am at the start of my career and many years from being dependent on my assets";
    }
    else if (theval=='2'){       
        Question2Title.innerHTML = "2) How many years do you reasonably expect to hold your portfolio of investments?"
        Question2_1.innerHTML = "1 - 3 Years";
        Question2_2.innerHTML = "4 - 7 Years";
        Question2_3.innerHTML = "8 - 12 Years";
        Question2_4.innerHTML = "13 - 19 Years";
        Question2_5.innerHTML = "20 Years or longer";
    }
}

function controlQ2(theval){
    var Q2Red = document.getElementById("Q2Red");
    if (document.wizardform.Q1[1].checked&&theval=='1'){
        Q2Red.style.display='block';
        Q2Red.innerHTML = "Please note that all of the Margetts funds carry financial risk.  The funds should be considered as long term investments with a minimum timescale of three years in our lowest risk fund.<br /><br />This does not provide any guarantee that the funds will provide a positive return over their minimum timescale and you may not get back the full amount invested.<br /><br />Past Performance is no guarantee of future performance. Investment values can go down and well as up.";
    }
    else {
        Q2Red.style.display='none';
    }
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

var WizardQ7 = "";
var WizardQ7 = "";
var WizardQ8 = "";
var WizardQ9 = "";
var WizardQ10 = "";
var WizardQ11 = "";
var WizardQ12 = "";
var WizardQ13 = "";


addLoadEvent(function(){
    var formexists = typeof document.forms['wizardform'] != 'undefined';
    //alert('exists: ' + foo);

    if (formexists) {
        WizardQ6 = getCheckedValue(document.forms['wizardform'].elements['Q6']);
        WizardQ7 = getCheckedValue(document.forms['wizardform'].elements['Q7']);
        WizardQ8 = getCheckedValue(document.forms['wizardform'].elements['Q8']);
        WizardQ9 = getCheckedValue(document.forms['wizardform'].elements['Q9']);
        WizardQ10 = getCheckedValue(document.forms['wizardform'].elements['Q10']);
        WizardQ11 = getCheckedValue(document.forms['wizardform'].elements['Q11']);
        WizardQ12 = getCheckedValue(document.forms['wizardform'].elements['Q12']);
        WizardQ13 = getCheckedValue(document.forms['wizardform'].elements['Q13']);
    }
})

function controlQ7(theval) {
    var Q7Red = document.getElementById("Q7Red");
    var Q7Text = "";

    if (theval == '2') {
        if (Q7Text !== '') {
            Q7Text += '<br /><br />';
        }
        Q7Text += "You have stated that you are not willing to accept any fluctuations in the value of your portfolio.  It is unlikely that any strategy other than holding cash will meet your objectives.";
    }

    if (Q7Text !== '') {
        Q7Red.style.display = 'block';
        Q7Red.innerHTML = Q7Text;
    }
    else {
        Q7Red.style.display = 'none';
    }
}

function controlQ8(theval){
    var Q8Red = document.getElementById("Q8Red");
    var Q8Text = "";

    WizardQ8 = theval;

    if (theval == '6') {
        if (Q8Text !== '') {
            Q8Text += '<br /><br />';
        }
        Q8Text += "You have stated that you do not understand or that you do not know the answer to this question.  It is important that you understand whether your portfolio will fluctuate in value and to be comfortable with the size of any fluctuations if you will be taking financial risk.  We would recommend that you speak to your financial adviser before continuing with the questionnaire.  If you choose to continue without selecting another option then your answer will not be taken into account and the result may be less accurate.";
    }

    if (Q8Text !== '') {
        Q8Red.style.display = 'block';
        Q8Red.innerHTML = Q8Text;
    }
    else {
        Q8Red.style.display = 'none';
    }
}

function controlQ9(theval){
    var Q9Red = document.getElementById("Q9Red");
    var Q9Text = "";

    //=IF(AND(NOT(Ref!B8=0),ABS(Ref!B8-Ref!B7)>2),Ref!G67,"")
    //=IF(AND(NOT(Ref!B9=0),ABS(Ref!B9-Ref!B8)>=2),Ref!G68,"")

    if (WizardQ8 == 6) {
        WizardQ8 = 0;
    }
    
    WizardQ9 = theval;
    var Q9ABS = Math.abs(WizardQ9-WizardQ8);

    //alert(WizardQ9);

    //alert(WizardQ8 + '/' + WizardQ9 + '/' + Q9ABS);
    
    if (Q9ABS>=2){
        Q9Text = "Your response to this question is unexpected based on answers to previous questions. Please check that your answer most appropriately reflects your views, before continuing with the next question.";
    }
    
    //=IF(Ref!B8=1,Ref!B110,"")
    if (WizardQ9=='1'){
        if (Q9Text!==''){
            Q9Text += '<br /><br />';
        }
        Q9Text += "Your answer to this question indicates that holding cash only may be the most suitable strategy to meet your expectations for this question. Please consider the question carefully before continuing with the next question.";
    }
    
    if (Q9Text!==''){
        Q9Red.style.display='block';
        Q9Red.innerHTML = Q9Text;
    }
    else {
        Q9Red.style.display='none';
    }
}

function controlQ10(theval){
    var Q10Red = document.getElementById("Q10Red");
    var Q10Text = "";
    
    //=IF(AND(NOT(Ref!B9=0),ABS(Ref!B9-AVERAGE(Ref!B7,Ref!B8))>2),Ref!G67,"")
    WizardQ10 = theval;

    if (theval !== 0) {
        var WizardAvg = (parseFloat(WizardQ8) + parseFloat(WizardQ9)) / 2;
        var Q10ABS = Math.abs(WizardQ10 - WizardAvg);

        //alert(WizardQ10 + '/' + WizardAvg);

        if (Q10ABS >= 2) {
            Q10Text = "Your response to this question is unexpected based on answers to previous questions. Please check that your answer most appropriately reflects your views, before continuing with the next question.";
        }
    }
    
    if (Q10Text!==''){
        Q10Red.style.display='block';
        Q10Red.innerHTML = Q10Text;
    }
    else {
        Q10Red.style.display='none';
    }
}

function controlQ11(theval){
    var Q11Red = document.getElementById("Q11Red");
    var Q11Text = "";

    //=IF(AND(NOT(Ref!B10=0),ABS(Ref!B10-AVERAGE(Ref!B7:Ref!B9))>2),Ref!G67,"")
    //=IF(AND(NOT(Ref!B11=0),ABS(Ref!B11-AVERAGE(Ref!B8:Ref!B10))>2),Ref!G68,"")
    //=IF(AND(NOT(Ref!B11=0),ABS(Ref!B11-AVERAGE(Ref!B8:Ref!B10))>2),Ref!G68,"")
    WizardQ11 = theval;

    if (theval !== 0) {
        var WizardAvg = (parseFloat(WizardQ8) + parseFloat(WizardQ9) + parseFloat(WizardQ10)) / 3;
        var Q11ABS = Math.abs(WizardQ11 - WizardAvg);

        //alert(WizardQ8 + '/' + WizardQ9 + '/' + WizardQ10 + '/' + WizardQ11);
        //alert(WizardQ11 + '/' + WizardAvg);
        //alert(Q11ABS);

        if (Q11ABS >= 2) {
            Q11Text = "Your response to this question is unexpected based on answers to previous questions. Please check that your answer most appropriately reflects your views, before continuing with the next question.";
        }

        if (Q11Text !== '') {
            Q11Red.style.display = 'block';
            Q11Red.innerHTML = Q11Text;
        }
        else {
            Q11Red.style.display = 'none';
        }
    }
}

function controlQ12(theval){
    var Q12Red = document.getElementById("Q12Red");
    var Q12Text = "";

    //=IF(AND(NOT(Ref!B11=0),ABS(Ref!B11-AVERAGE(Ref!B7:Ref!B10))>2),Ref!G67,"")
    //=IF(AND(NOT(Ref!B12=0),ABS(Ref!B12-AVERAGE(Ref!B8:Ref!B11))>=2),Ref!G68,"")
    WizardQ12 = theval;

    if (theval !== 0) {
        var WizardAvg = (parseFloat(WizardQ8) + parseFloat(WizardQ9) + parseFloat(WizardQ10) + parseFloat(WizardQ11)) / 4;
        var Q12ABS = Math.abs(WizardQ12 - WizardAvg);

        //alert(theval + '/' + WizardAvg + '/' + Q12ABS);

        if (Q12ABS >= 2) {
            Q12Text = "Your response to this question is unexpected based on answers to previous questions. Please check that your answer most appropriately reflects your views, before continuing with the next question.";
        }
    }
    
    //=IF(Ref!B11=1,Ref!B110,"")
    if (WizardQ12=='1'){
        if (Q12Text!==''){
            Q12Text += '<br /><br />';
        }
        Q12Text += "Your answer to this question indicates that holding cash only may be the most suitable strategy to meet your expectations for this question. Please consider the question carefully before continuing with the next question.";
    }
    
    
    if (Q12Text!==''){
        Q12Red.style.display='block';
        Q12Red.innerHTML = Q12Text;
    }
    else {
        Q12Red.style.display='none';
    }
}

function controlQ13(theval){
    var Q13Red = document.getElementById("Q13Red");
    var Q13Text = "";

    //=IF(AND(NOT(Ref!B12=0),ABS(Ref!B12-AVERAGE(Ref!B7:Ref!B11))>2),Ref!G67,"")
    //=IF(AND(NOT(Ref!B13=0),ABS(Ref!B13-AVERAGE(Ref!B8:Ref!B12))>2),Ref!G68,"")
    WizardQ13 = theval;
    
    var WizardAvg = (parseFloat(WizardQ8)+parseFloat(WizardQ9)+parseFloat(WizardQ10)+parseFloat(WizardQ11)+parseFloat(WizardQ12))/5;  
    var Q13ABS = Math.abs(WizardQ13-WizardAvg);
       
    if (Q13ABS>=2){
        Q13Text = "Your response to this question is unexpected based on answers to previous questions. Please check that your answer most appropriately reflects your views, before continuing with the next question.";    
    }
    
    if (Q13Text!==''){
        Q13Red.style.display='block';
        Q13Red.innerHTML = Q13Text;
    }
    else {
        Q13Red.style.display='none';
    }
}

function checkwizardform(theval){
    var ftxt = '';
    if (theval == 1) {
        if (document.wizardform.FirstDisabled.value !== 'True') {
            var q1 = false;
            for (var i = 0; i < 2; i++) {
                if (document.wizardform.Q1[i].checked == true) {
                    q1 = true;
                }
            }
            if (q1 == false) {
                ftxt = 'Please select an Answer.';
            }
        }
    }
    else if (theval == 2) {
        var q2 = false;
        for (var i = 0; i < 5; i++) {
            if (document.wizardform.Q2[i].checked == true) {
                q2 = true;
            }
        }
        if (q2 == false) {
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==3){
        var q3 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q3[i].checked==true){
                q3 = true;
            }
        }
        if (q3==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==4){
        var q4 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q4[i].checked==true){
                q4 = true;
            }
        }
        if (q4==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==5){
        var q5 = false;
        for (var i=0;i<4;i++){
            if (document.wizardform.Q5[i].checked==true){
                q5 = true;
            }
        }
        if (q5==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==6){
        var q6 = false;
        for (var i=0;i<3;i++){
            if (document.wizardform.Q6[i].checked==true){
                q6 = true;
            }
        }
        if (q6==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==7){
        var q7 = false;
        for (var i=0;i<2;i++){
            if (document.wizardform.Q7[i].checked==true){
                q7 = true;
            }
        }
        if (q7==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==8){
        var q8 = false;
        for (var i=0;i<6;i++){
            if (document.wizardform.Q8[i].checked==true){
                q8 = true;
            }
        }
        if (q8==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==9){
        var q9 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q9[i].checked==true){
                q9 = true;
            }
        }
        if (q9==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==10){
        var q10 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q10[i].checked==true){
                q10 = true;
            }
        }
        if (q10==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==11){
        var q11 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q11[i].checked==true){
                q11 = true;
            }
        }
        if (q11==false){
            ftxt = 'Please select an Answer.';
        }
    }
    else if (theval==12){
        var q12 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q12[i].checked==true){
                q12 = true;
            }
        }
        if (q12==false){
            ftxt = 'Please select an Answer.';
        }
    } 
    else if (theval==13){
        var q13 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q13[i].checked==true){
                q13 = true;
            }
        }
        if (q13==false){
            ftxt = 'Please select an Answer.';
        }
    } 
    else if (theval==14){
        var q14 = false;
        for (var i=0;i<5;i++){
            if (document.wizardform.Q14[i].checked==true){
                q14 = true;
            }
        }
        if (q14==false){
            ftxt = 'Please select an Answer.';
        }
    } 
    
    return ftxt;
}

function openWizardSummary(){
    window.open('risk_review_print.asp','WizardSummary','width=740,height=580,scrollbars=yes,resizable=no');
}

/* Report Public */
function getReport(theval){
    location.href='Scripts/GetTemplateReport.asp?ReportID=' + theval;
}

/* IFA Password Reset */
function checkifapasswordreset(){
    if (isValidEmail(document.ifapasswordreset.EmailAddress.value)==false){
        alert('Please enter your Email Address.');
        return false;
    }
    else {
        return true;
    }
}

/* IFA Edit */
function checkifaedit(){
    var ftxt = '';
    
    if (document.ifaedit.Title.value==''){
        ftxt += '\n- Please enter your Title.';
    }
    
    if (document.ifaedit.FirstName.value==''){
        ftxt += '\n- Please enter your First Name.';
    }
    
    if (document.ifaedit.LastName.value==''){
        ftxt += '\n- Please enter your Last Name.';
    }
    
    if (document.ifaedit.Company.value==''){
        ftxt += '\n- Please enter your Company Name.';
    }
    
    if (document.ifaedit.Telephone.value==''){
        ftxt += '\n- Please enter your Telephone Number.';
    }
    
    if (isValidEmail(document.ifaedit.EmailAddress.value)==false){
        ftxt += '\n- Please enter your Email Address.';
    }
    
    if (document.ifaedit.Address1.value==''){
        ftxt += '\n- Please enter your Address 1.';
    }
    
    if (document.ifaedit.City.value==''){
        ftxt += '\n- Please enter a City.';
    }
    
    if (document.ifaedit.County.value==''){
        ftxt += '\n- Please enter a County.';
    }
    
    if (document.ifaedit.Postcode.value==''){
        ftxt += '\n- Please enter a Postcode.';
    }
    
    if (document.ifaedit.NewPassword.value!==''){
        if (document.ifaedit.NewPassword.value!==document.ifaedit.RptNewPassword.value){
            ftxt += '\n- Please ensure both New Passwords Match.';
        }
        else {
            if (document.ifaedit.NewPasswordOK.value=='False'){
                ftxt += '\n- Please ensure your Password shows as Strong.';
            }
        }
    }

    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function confirmLogoDelete(submitstring){
    if (confirm('Are you sure ou want to delete this logo?')){
        location.href=submitstring;
    }
}

/* Wizard Extra */
function checkwizardintro(){
    var ftxt = '';
    
    if (document.introform.ClientName.value==''){
        ftxt += '\n- Please enter a Client Name.';
    }
    
    if (document.introform.AdviserName.value==''){
        ftxt += '\n- Please enter an Adviser Name.';
    }
    
    if (document.introform.SelfAssessedRiskProfile.value==''){
        ftxt += '\n- Please select a Self Assessed Risk Profile.';
    }
    
    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

/* Client Search */
function checkclientsearch() {
    if (document.clientsearch.Name.value == '' && document.clientsearch.Postcode.value == '') {
        alert('Please enter your Search Criteria.');
        return false;
    }
    else {
        return true;
    }
}

/* Investment Flow Manager */
function checkmanageclient() {
    var ftxt = '';

    if (document.stepform.Name.value == '') {
        ftxt += '\n- Please enter a Name.';
    }

    if (isValidEmail(document.stepform.EmailAddress.value) == false) {
        ftxt += '\n- Please enter an Email Address.';
    }

    if (document.stepform.Address.value == '') {
        ftxt += '\n- Please enter an Address.';
    }

    if (document.stepform.Postcode.value == '') {
        ftxt += '\n- Please enter a Postcode.';
    }

    if (isDate(document.stepform.DOB.value) == false) {
        ftxt += '\n- Please enter a Date of Birth.';
    }

    if (document.stepform.ReviewFrequency.value == '') {
        ftxt += '\n- Please select a Review Frequency.';
    }
    
    // Accounts
    /*
    var accountrawarray = document.stepform.AccountArray.value;    
    var accountsarray = accountrawarray.split(",");
    
    var baccounts = false;
    for (var i = 0; i < document.stepform.AccountCount.value; i++) {
        if (document.stepform.Account[i].checked){
            baccounts = true;

            // find out the checked ID value!
            var theval = document.stepform.Account[i].value;

            if (eval('document.stepform.InvestmentID' + theval + '.value') == '') {
                ftxt += '\n- Please enter all information for the account: ' + accountsarray[i];
            }
        }
    }
    if (baccounts==false){
        ftxt += '\n- Please select at least one Account.';
    }
    */
    

    if (ftxt!==''){
		alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
		return false;
	}
	else {
		return true;
	}
}

function controlclientaccount(accountPos) {
    var rawfield = eval('document.stepform.AccountID' + accountPos + '.value');
    var theArray = rawfield.split("|");

    if (theArray.length == 3) {
        var AccountNumber = document.getElementById("AccountNumber" + theArray[2]);
        var Designation = document.getElementById("Designation" + theArray[2]);
        var RegisteredName = document.getElementById("RegisteredName" + theArray[2]);

        if (theArray[0] == '0') {
            AccountNumber.disabled = true;
            Designation.disabled = true;
            RegisteredName.style.backgroundColor = '#CCCCCC';
        }
        else if (theArray[0] == '2') {
            AccountNumber.disabled = false;            
        }        
        else {        
            if (theArray[1] == 'True') {
                AccountNumber.disabled = false;
                Designation.disabled = false;
                RegisteredName.style.backgroundColor = '#FFFFFF';
            }
            else {                
                AccountNumber.disabled = true;
                Designation.disabled = true;
                RegisteredName.style.backgroundColor = '#CCCCCC';
            }
        }
    }
}

function showRegisteredName(theVal,accountPos) {
    var theArray = theVal.split("|");
    eval('document.stepform.RegisteredName' + accountPos).value = theArray[1];
}

function populateClientAccountRow(theid, valone, valtwo, valthree) {
    var AccountNumber = document.getElementById("AccountNumber" + theid);
    var RegisteredName = document.getElementById("RegisteredName" + theid);
    var Designation = document.getElementById("Designation" + theid);

    var thefield = document.getElementById("Account" + theid);

    thefield.checked = true;
    AccountNumber.value = valone;
    RegisteredName.value = valtwo;
    Designation.value = valthree;
}

function changePageToThis(reviewid, filename) {
    if (reviewid == '') {
        location.href = 'investment_flow_manager_overview.asp?NewReview=True';
    }
    else {
        location.href = filename + '?ReviewID=' + reviewid;
    }
}

function controlApplicableStep(theval) {
    var ApplicableStep = document.getElementById("ApplicableStepBlock");

    if (document.stepform.ApplicableStep.value == 'True') {
        ApplicableStep.style.display = 'block';
    }
    else {
        ApplicableStep.style.display = 'none';
    }
}

function controlEachAccountScoring() {
    var SingleScore = document.getElementById("SingleScore");
    var MultiScore = document.getElementById("MultiScore");

    if (document.stepform.IsEachAccountScoring.value == 'True') {
        SingleScore.style.display = 'none';
        MultiScore.style.display = 'block';
    }
    else {
        SingleScore.style.display = 'block';
        MultiScore.style.display = 'none';
    }
}

// Step 1
function checkstepone() {
}

// Step 2
function checksteptwo() {
}

function controlClientScoreTwo() {
    var ManualScore = document.getElementById("ManualScore");
    var ClientRaw = document.stepform.ClientScore.value;
    var ClientScore = ClientRaw.split("|");

    if (ClientScore[1] == 'True') {
        ManualScore.style.display = 'block';
    }
    else {
        ManualScore.style.display = 'none';
    }
}

// Step 3
function controlStepThreeIllustration(theVal) {
    var NewIllustration = document.getElementById("NewIllustrationBlock");

    if (theVal == 'True') {
        NewIllustration.style.display = 'block';
    }
    else {
        NewIllustration.style.display = 'none';
    }
}

var brequirelumpsum = false;
var brequireregularsaver = false;
var brequireamount = true;

function enableAmountFields() {
    var LumpSumVal = document.getElementById("LumpSumVal");
    var RegularSaverVal = document.getElementById("RegularSaverVal");

    var LumpSumInput = document.getElementById("LumpSumInput");
    var RegularSaverInput = document.getElementById("RegularSaverInput");

    var RiskProfileInput = document.getElementById("RiskProfileInput");

    
    if (document.stepform.LumpSum.checked) {
        //LumpSumVal.style.display = 'none';
        LumpSumInput.style.display = 'block';
        //brequirelumpsum = true;
    }
    else {
        //LumpSumVal.style.display = 'block';
        LumpSumInput.style.display = 'none';
        //brequirelumpsum = false;
    }
    
    /*
    if (document.stepform.RegularSaver.checked) {
        RegularSaverVal.style.display = 'none';
        RegularSaverInput.style.display = 'block';
        brequireregularsaver = true;
    }
    else {
        RegularSaverVal.style.display = 'block';
        RegularSaverInput.style.display = 'none';
        brequireregularsaver = false;
    }    

    if (document.stepform.LumpSum.checked && document.stepform.RegularSaver.checked) {
        brequireamount = false;
        //RiskProfileInput.style.display = 'none';
    }
    else {
        brequireamount = true;
        //RiskProfileInput.style.display = 'block';
    }
    */
}

function controlRiskProfile() {
    //var RiskProfileInput = document.getElementById("RiskProfileInput");
    //var FurtherInfo = document.getElementById("FurtherInfo");

    var RiskProfileType = document.getElementById("RiskProfileType");
    var AccountSelection = document.getElementById("AccountSelection");
    var RiskProfileInput = document.getElementById("RiskProfileInput");
    //var AccountSelection = document.getElementById("AccountSelection");

    controlIllustrationScoring();

    if (document.stepform.LumpSum.checked) {
        // Hide
        RiskProfileType.style.display = 'none';
        AccountSelection.style.display = 'none';
        RiskProfileInput.style.display = 'none';        
    }
    else {
        // Show
        RiskProfileType.style.display = 'block';
        AccountSelection.style.display = 'block';
        RiskProfileInput.style.display = 'block';

        controlIllustrationScoring();
    }
}

function validateillustration(){
    var ftxt = '';
    
    if (document.stepform.Years.value == '') {
        ftxt += '\n- Please select the Number of Years.';
    }

    /*
    if (document.stepform.EnhancedDiscount.value == '') {
        ftxt += '\n- Please enter an Ehhanced Discount. Enter 0% if not applicable.';
    }
    */

    if (document.stepform.TrailCommission.value == '') {
        ftxt += '\n- Please enter a Trail Commission. Enter 0% if not applicable.'
    }

    if (brequirelumpsum) {
        if (document.stepform.LumpSum_Providence.value == '') {
            ftxt += '\n- Please enter a Lump Sum Value for Providence.';
        }

        if (document.stepform.LumpSum_Select.value == '') {
            ftxt += '\n- Please enter a Lump Sum Value for Select.';
        }

        if (document.stepform.LumpSum_International.value == '') {
            ftxt += '\n- Please enter a Lump Sum Value for International.';
        }

        if (document.stepform.LumpSum_Venture.value == '') {
            ftxt += '\n- Please enter a Lump Sum Value for Venture.';
        }
    }        
    else {
        if (document.stepform.RegularSaverValue.value == '') {
            ftxt += '\n- Please enter a Regular Saver Amount. Enter £0.00 if not applicable.';
        }
    }

    if (brequireregularsaver) {
        if (document.stepform.RegularSaver_Providence.value == '') {
            ftxt += '\n- Please enter a Regular Saver Value for Providence.';
        }

        if (document.stepform.RegularSaver_Select.value == '') {
            ftxt += '\n- Please enter a Regular Saver Value for Select.';
        }

        if (document.stepform.RegularSaver_International.value == '') {
            ftxt += '\n- Please enter a Regular Saver Value for International.';
        }

        if (document.stepform.RegularSaver_Venture.value == '') {
            ftxt += '\n- Please enter a Regular Saver Value for Venture.';
        }
    }
    else {
        if (document.stepform.LumpSumpValue.value == '') {
            ftxt += '\n- Please enter a Lump Sum Amount. Enter £0.00 if not applicable.';
        }
    }
    
    return ftxt;
}

function checkstepthree() {
    var ftxt = '';

    if (document.stepform.NewIllustration.value == 'True') {
        ftxt = validateillustration();
    }

    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }  
}

// Step 4
function controlStep4Details(theVal) {
    var ExistingDetails = document.getElementById("ExistingDetails");

    if (theVal == 'True') {
        ExistingDetails.style.display = 'block';
    }
    else {
        ExistingDetails.style.display = 'none';
    }
}

function controlStep4Illustration(theVal) {    
    var NewIllustration = document.getElementById("NewIllustration");
    
    if (theVal == 'True') {
        NewIllustration.style.display = 'block';
    }
    else {
        NewIllustration.style.display = 'none';
    }
}

function controlInvestmentType(theVal) {
    //Secondary Fields
    var SecondaryControl = document.getElementById("SecondaryControl");
    var SecondaryContainer = document.getElementById("SecondaryContainer");

    var TheTypePos = document.stepform.Type.selectedIndex;

    //alert(TheTypePos);

    if (TheTypePos==1) {
        SecondaryControl.style.display = 'none';
        SecondaryContainer.style.display = 'none';
    }
    else {
        SecondaryControl.style.display = 'block';
        //SecondaryContainer.style.display = 'block';
    }

    //Control DetailControl Field
    if (TheTypePos == 2) {
        document.stepform.DetailControl.selectedIndex = 1;
        controlStep4Details('True');

        var fieldarr = new Array("Primary_Surname", "Primary_Forename", "Primary_Address1", "Primary_Address2", "Primary_Address3", "Primary_Postcode", "Primary_Telephone", "Primary_DOB");

        for (var i = 0; i < fieldarr.length; i++) {
            eval('document.stepform.' + fieldarr[i]).value = '';
        }
    }
}

var requiresecondary = false;
function controlSecondaryContainer() {
    var SecondaryControl = document.getElementById("SecondaryControl");
    var SecondaryContainer = document.getElementById("SecondaryContainer");
    var SecondaryButton = document.getElementById("SecondaryButton");

    if (SecondaryContainer.style.display == 'none') {
        SecondaryContainer.style.display = 'block';
        requiresecondary = true;
        SecondaryButton.innerHTML = 'Remove Secondary Account Holder';
        document.stepform.SecondaryAccountHolder.value = 'True';
    }
    else {
        SecondaryContainer.style.display = 'none';
        requiresecondary = false;
        SecondaryButton.innerHTML = 'Add Secondary Account Holder';
        document.stepform.SecondaryAccountHolder.value = 'False';
    }
}

function checkstepfour() {
    var ftxt = '';

    if (document.stepform.DetailControl.value == 'True') {
        var atxt = '';
        
        if (document.stepform.Primary_Surname.value == '') {
            atxt += '\n- Please enter a Surname.';
        }

        if (document.stepform.Primary_Forename.value == '') {
            atxt += '\n- Please enter the Forenames.';
        }

        if (document.stepform.Primary_Address1.value == '') {
            atxt += '\n- Please enter an Address 1.';
        }

        if (document.stepform.Primary_Postcode.value == '') {
            atxt += '\n- Please enter a Postcode.';
        }

        if (document.stepform.Primary_Telephone.value == '') {
            atxt += '\n- Please enter a Telephone Number.';
        }

        if (isDate(document.stepform.Primary_DOB.value) == false) {
            atxt += '\n- Please enter a Date of Birth.';
        }

        if (document.stepform.Primary_NINumber.value == '') {
            atxt += '\n- Please enter a National Insurance Number.';
        }

        if (atxt !== '') {
            ftxt += '\n** Primary Account Holder **\n' + atxt;
        }

        if (requiresecondary) {
            var btxt = '';

            if (document.stepform.Secondary_Surname.value == '') {
                btxt += '\n- Please enter a Surname.';
            }

            if (document.stepform.Secondary_Forename.value == '') {
                btxt += '\n- Please enter the Forenames.';
            }

            if (document.stepform.Secondary_Address1.value == '') {
                btxt += '\n- Please enter an Address 1.';
            }

            if (document.stepform.Secondary_Postcode.value == '') {
                btxt += '\n- Please enter a Postcode.';
            }

            if (document.stepform.Secondary_Telephone.value == '') {
                btxt += '\n- Please enter a Telephone Number.';
            }

            if (isDate(document.stepform.Secondary_DOB.value) == false) {
                btxt += '\n- Please enter a Date of Birth.';
            }

            if (document.stepform.Secondary_NINumber.value == '') {
                btxt += '\n- Please enter a National Insurance Number.';
            }

            if (btxt !== '') {
                if (ftxt !== '') {
                    ftxt += '\n';
                }
                ftxt += '\n** Secondary Account Holder **\n' + btxt;
            }
        }
    }

    if (document.stepform.ControlIllustration.value == 'True') {
        var itxt = '';        
        itxt = validateillustration();
        if (itxt !== '') {
            if (ftxt !== '') {
                ftxt += '\n';
            }
            ftxt += '\n** Investment Details **\n' + itxt;
        }
    }
    
    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }
}

/* Valuation Form */
function checkvaluationform() {
    alert('Test');
    return false;
}

/* Go Back - New Function */
function checkgoback() {
    if (confirm('Are you sure you want to go-back? This will NOT save any changes you have made.\n\nAre you sure you want to continue?')) {
        history.go(-1);
    }
}

/* Control Entire Review */
function controlEntireReview(theVal) {
    if (confirm('Are you sure you want to change the status of this review?')) {
        document.reviewrequired.submit();
    }
}

/* Submit Value */
function savesubmitvalue(theval) {
    document.stepform.submit.value = theval;
}

/* New Left Login */
function checkleftloginform() {
    var ftxt = '';

    if (isValidEmail(document.leftloginform.EmailAddress.value) == false) {
        ftxt += '\n- Please enter your Email Address.';
    }

    if (document.leftloginform.Password.value == '') {
        ftxt += '\n- Please enter your Password.';
    }

    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }
}

/* Client Scoring - Control */
function controlClientScoring() {   
    var IsEachAccountScoring = false;
    if (document.stepform.IsEachAccountScoring.value == 'True') {
        IsEachAccountScoring = true;
    }

    var IsClientScoring = false;
    if (document.stepform.IsClientScoring.value == 'True') {
        IsClientScoring = true;
    }


    if (IsEachAccountScoring) {
        for (var i = 0; i < document.stepform.MultiScoreCount.value; i++) {
            if (IsClientScoring) {
                document.getElementById("ScoreCounter" + (i + 1)).style.display = 'block';
                //alert('going in');
            }
            else {
                document.getElementById("ScoreCounter" + (i + 1)).style.display = 'none';
                //alert('not going in');
            }
        }
    }
    else {
        if (IsClientScoring) {
            document.getElementById("ScoreCounter0").style.display = 'block';
        }
        else {
            document.getElementById("ScoreCounter0").style.display = 'none';
        }
    }
    
    //ScoreCounter
}

/* Illustration Scoring */
function controlIllustrationScoring() {
    var RiskProfileInput = document.getElementById("RiskProfileInput");
    var AccountSelection = document.getElementById("AccountSelection");

    if (document.stepform.ScoringType.value == 'False') {
        RiskProfileInput.style.display = 'block';
        AccountSelection.style.display = 'none';
    }
    else {
        RiskProfileInput.style.display = 'none';
        AccountSelection.style.display = 'block';
        //document.stepform.amount.value = document.stepform.CustomerRetrievedScore.value;
        
    }
}

/* Manage Client Auto Fill */
function displayClientAccountInformation(accountLoopPos, accountPos, investorPos, designationPos) {
    //alert(accountLoopPos);
    if (accountPos !== '') {
        // Account
        eval('document.stepform.AccountID' + accountLoopPos).selectedIndex = accountPos;
        controlclientaccount(accountLoopPos);

        if (investorPos !== 0) {            
            // Account Number
            eval('document.stepform.AccountNumber' + accountLoopPos).selectedIndex = investorPos;
            getNames(_names[investorPos], accountLoopPos);
        }

        //alert(designationPos);

        if (designationPos !== 0) {            
            // Designation (last one!)
            eval('document.stepform.Designation' + accountLoopPos).selectedIndex = designationPos;
            if (designationPos !== 9999) {
                alert('going in');
                showRegisteredName(eval('document.stepform.Designation' + accountLoopPos + '.value'), accountLoopPos);
            }
        }
    }
}

/* Quick Valuation Form */
function checkquickvaluationform() {
    var ftxt = '';

    if (document.valuationsform.AccountNumber.value == '' && document.valuationsform.RegisteredName.value == '') {
        ftxt += '\n- Please select an Account Number OR Registered Name.';
    }

    /* 
    Disabled 290611
    if (document.valuationsform.Designation.value == '') {
        ftxt += '\n- Please select a Designation.';
    }
    */

    if (ftxt !== '') {
        alert('One or more errors were found while submitting this form. The errors found are displayed below.\n' + ftxt + '\n\nPlease correct the above errors and try again.');
        return false;
    }
    else {
        return true;
    }
}

/* Overview Submit Value */
function saveoverviewsubmitvalue(theval) {
    document.overviewform.submit.value = theval;
}

/* New Review */
function checknewreview(submitstring) {
    if (confirm('** WARNING **\n\nBy confirming this popup you will be creating a new Review for this client. This will make any previous reviews archived.\n\nAre you sure you want to continue?')) {
        location.href = submitstring;
    }
}

function setRiskProfileScoringManual() {
    document.stepform.IsClientScoring.selectedIndex = 1;
}
