  function checkInitialEmpty(field){
	if (field.value == ""){
		alert('If you are not doing a lump investment please ensure that the lump sum investment amount is zero'); 
		field.value = "1000";
	}
  }
  
  function checkMonthlyEmpty(field){
	if (field.value == ""){
		field.value = "50";
	}
  }	
	

function hideInstitutional(){
	var theApp = (String(document.location.href).split("="))[1];
     	if (theApp != 12592){
  		for(var i=0;i<document.getElementsByName("illRow").length;i++){
			if(document.getElementsByName("illRow").item(i).childNodes(0).childNodes(0).innerText=="60089144"){
				document.getElementsByName("illRow").item(i).style.display="none";
			}
  		}
  	}
}

hideInstitutional();
  // Skandia-specific feature - disables Monthly Investment fields for ISA & PEP transfers
function disableMonthly(){
	if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value != 'withdrawal' && Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value != 'target'){
		if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISATransfer' || Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'PEP'){
  			for (i=1 ; Form1[i] ; i++){
  				if (Form1[i].name.indexOf("txtMonthlyInvestment") != -1){
  					Form1[i].disabled = true;
  				}
  			}
		}
	}
	
	var d = document.getElementById('IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct');
	var f = document.getElementById('IllustrationFormOnePage1_fndClassHidden');
	var c = 0;
	
	if (f!=undefined){ c = f.value; }
	if (c!=0) {
		if (c=="SICAV"||c=="Heart of Africa Fund"){
			for (var i = 0; i < d.options.length; i++) {
				if (d.options[i].value == 'ISA'||d.options[i].value == 'ISATransfer') { d.remove(i); i--; }
			}		
  			for (i=1 ; Form1[i] ; i++){
  				if (Form1[i].name.indexOf("txtMonthlyInvestment") != -1){
  					Form1[i].value = 0;
  					Form1[i].disabled = true;
  				}
  			}
		}
	}
}
disableMonthly();

  // Skandia-specific feature - sets three decimal places for Annual Commission - 12593 Distributor only
  function setAnnualCommission(){
  	theApp = (String(document.location.href).split("="))[1];
  	if (theApp == 12593){
  		for (i=1 ; Form1[i] ; i++){
  			if (Form1[i].name.indexOf("sltAnnualCommission") != -1){
  				Form1[i][Form1[i].selectedIndex].text = "0.625";
  			}
  		}
  	} 
    }
  setAnnualCommission();

	
  
  function validateInitial(sender, args){
	
	if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'standard' || Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'contribution'){
		 args.IsValid = (args.Value >= 1000 || args.Value == 0);
		if(!args.IsValid) {
			alert('If an initial contribution is selected it must be more than \2431000');
			document.getElementById(sender.controltovalidate).value = 1000;
			return;
		}
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			args.IsValid = (args.Value <= 10200);
			if(!args.IsValid){
				alert('Investments of greater than \24310,200 are only permissible as transfer ISAs. Please select the ISA Transfer option');
				document.getElementById(sender.controltovalidate).value = 7200;
			}
		}
	}
	
	if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'target'){
		args.IsValid = (args.Value >0);
		if (!args.IsValid){
			alert('Initial investment must be more than \2430');
			document.getElementById(sender.controltovalidate).value = 1000;
		}
	}
	
  }

  function validateMonthly(sender, args){
   
  
    if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'target'){
		 args.IsValid = (args.Value >= 1000 || args.Value == 0);
		if(!args.IsValid) {
			alert('If an initial investment is selected it must be more than \2431000');
			document.getElementById(sender.controltovalidate).value = 1000;
			return;
		}
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			args.IsValid = (args.Value <= 10200);
			if(!args.IsValid){
				alert('Investments of greater than \24310,200 are only permissible as transfer ISAs. Please select the ISA Transfer option');
				document.getElementById(sender.controltovalidate).value = 7200;
			}
		}

    }
    if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'standard' || Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'contribution'){
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			args.IsValid = (args.Value <= 850);
			if(!args.IsValid){
				alert('Investments of greater than \24310,200 are only permissible as transfer ISAs. Please select the ISA Transfer option');
				document.getElementById(sender.controltovalidate).value = 50;
				return;
			}
	    }
	    args.isValid = (args.Value >= 50 || args.Value == 0);
	    if(!args.isValid){
			alert('If a monthly contribution is selected it must be more than \24350');
			document.getElementById(sender.controltovalidate).value = 50;
			return;
	    }
	}
	// Finally check if it is empty
	args.IsValid = (args.Value != "");;
	if(!args.IsValid){
		document.getElementById(sender.controltovalidate).value = 0;
	}
  }
	
	function toggleRow(){
		var control = window.event.srcElement;
		for (var i=0;i<control.parentElement.parentElement.childNodes.length;i++){
			if (control.parentElement.parentElement.childNodes(i).className == 'toShow'){
				control.parentElement.parentElement.childNodes(i).style.display = ((control.checked)?'':'none');
			}
		}
	}
