  function checkInitialEmpty(field){
	if (field.value == ""){
		field.value = "1000";
	}
  }
  
  function checkMonthlyEmpty(field){
	if (field.value == ""){
		field.value = "50";
	}
  }	
	
	function checkName(theEl){
		if (theEl.value.indexOf("&") != -1){
			alert('Please do not include the "&" symbol in this field.');
			theEl.focus();}
			else if (theEl.value.indexOf("(") != -1 || theEl.value.indexOf(")") != -1){
				alert('Please do not use parentheses in this field.');
				theEl.focus();
				}
				else if (theEl.value.length > 52){
					alert('You can only enter up to 52 characters in this field. Please modify.');
					theEl.focus();
					}
	}

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;
  				}
  			}
  		}
    	}
    }
  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 £1000');
			document.getElementById(sender.controltovalidate).value = 1000;
			return;
		}
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			args.IsValid = (args.Value <= 7200);
			if(!args.IsValid){
				alert('Investments of greater than £7200 are only permissible as transfer ISAs. Please select the ISA Transfer option');
				document.getElementById(sender.controltovalidate).value = 7200;
			}
		}
	}
	if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'withdrawal'){
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			 args.IsValid = (args.Value >= 1000 && args.Value <= 7200);
			if(!args.IsValid) {
				alert('Initial investment must be between £1000 and £7200');
				document.getElementById(sender.controltovalidate).value = 1000;
				return;
			}
		}else{
			 args.IsValid = (args.Value >= 1000);
			if(!args.IsValid) {
				alert('Initial investment must be greater than £1000 ');
				document.getElementById(sender.controltovalidate).value = 1000;
				return;
			}
		}
	}
  }

  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 £1000');
			document.getElementById(sender.controltovalidate).value = 1000;
			return;
		}
	    if(Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltProduct.value == 'ISA'){
			args.IsValid = (args.Value <= 7200);
			if(!args.IsValid){
				alert('Investments of greater than £7200 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 <= 600);
			if(!args.IsValid){
				alert('Investments of greater than £7200 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 £50');
			document.getElementById(sender.controltovalidate).value = 50;
			return;
	    }
	}
	if (Form1.IllustrationFormOnePage1_IllustrationBasicDetails1_sltType.value == 'withdrawal'){
		var min = 10;
		if (document.getElementsByName("illRow").item(0).childNodes(2).innerText == "Skandia American"){
			min = 50;
		}
		args.IsValid = (args.Value / Form1.IllustrationFormOnePage1_IllustrationWithdrawalDetails1_sltWithdrawalFrequency.value >= min);
		if(!args.IsValid) {
			alert('Individual withdrawal amounts must be greater than £' + min);
			document.getElementById(sender.controltovalidate).value = Form1.IllustrationFormOnePage1_IllustrationWithdrawalDetails1_sltWithdrawalFrequency.value * min;
			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.parentNode.parentNode.childNodes.length;i++){
			if (control.parentNode.parentNode.childNodes(i).className == 'toShow'){
				control.parentNode.parentNode.childNodes(i).style.display = ((control.checked)?'':'none');
			}
		}
	}