/**
 * site_quote_life_mortgage.js - JavaScript Functions.
 * @package site_quote_life_mortgage.js
*/
<!--
function CheckSingleJoint() { 
	if(document.form.SingleJoint.options[1].selected) { 
        document.getElementById("life2show").style.display="block";
	}else { 
		document.getElementById("life2show").style.display="none";
	}
}

function showLoader() { 
    document.getElementById("loading").style.display="block";    
    setTimeout('document.images["loading_img"].src = "/images/loading.gif"', 200); 
}

//make first letter uppercase
function Capsize(sStr) { 
	 var bCapsit = false;
	 var iLength = sStr.length;
	 var sString = sStr.substring(0,1).toUpperCase() + sStr.substring(1,sStr.length);
	 var sResult = '';
	 var i;
	
	 for (i = 1; i < iLength; i++) { 
		 var sChar = sString.charAt(i);
		 //sResult += ((bCapsit == true) ? sChar.toUpperCase() : sChar);
		 //bCapsit = false;
		 if (bCapsit == true)  sResult += sChar.toUpperCase();
		 if (bCapsit == false) sResult += sChar.toLowerCase();
		 bCapsit = false;

		 if ((sChar == ' ') || (sChar == '\'') || (sChar == '"') || (sChar == '.')) bCapsit = true;
	 }

	 return(sStr.substring(0,1).toUpperCase() + sResult);
}

// Used in second page of Life / Mortgage
function checkQuotes() { 
    var tempmonthly;

    var product = document.form.product.value;
    if (document.form.product[2].checked) { 
	    document.form.convertable.disabled=false;
	    document.form.accelerated.disabled=true;
	    tempmonthly = monthly_serious;

	    if(document.form.convertable.checked) { 
		    tempmonthly = conv_serious;
	    }
    }

    if (document.form.product[1].checked) { 
	    tempmonthly = monthly;
	    document.form.convertable.disabled=false;
	    document.form.accelerated.disabled=false;

	    if(document.form.convertable.checked) { 
		    tempmonthly = conv;
		    if(document.form.accelerated.checked) { 
			    tempmonthly = conv_accel;
		    }
	    }else if(document.form.accelerated.checked) { 
		    tempmonthly = monthly_accel;
			
	    }
    }
    if (document.form.product[0].checked) { 
	    tempmonthly=mort;
	    document.form.convertable.disabled=true;
	    document.form.accelerated.disabled=false;

	    if(document.form.accelerated.checked) { 
		    tempmonthly = mort_accel;
	    }
    }

    var tempannualy = (tempmonthly * 12);
    var tempspecial = (tempannualy / 2);

    document.form.monthprice.value = tempmonthly.toFixed(2);
    document.form.yearprice.value= tempannualy.toFixed(2);
    document.form.specialprice.value = tempspecial.toFixed(2);
}


// Used in first page of Life / Mortgage
function CheckLMForm() { 
	var inputEmail = document.form.email.value;
	var pass = true;
	var details = 'Invalid information entered.\n\n';

    // Handles date of birth info for person 1
    if(document.form.app1BirthDay.options[document.form.app1BirthDay.selectedIndex].value=="") { 
		details+= '- Please select which Day Life 1 was born.\n\n';
    	if (pass) document.form.app1BirthDay.focus();
		pass = false;
	}
    if(document.form.app1BirthMonth.options[document.form.app1BirthMonth.selectedIndex].value=="") { 
		details+= '- Please select which Month Life 1 was born.\n\n';
    	if (pass) document.form.app1BirthMonth.focus();
		pass = false;
	}
    if(document.form.app1BirthYear.options[document.form.app1BirthYear.selectedIndex].value=="") { 
		details+= '- Please select which Year Life 1 was born.\n\n';
    	if (pass) document.form.app1BirthYear.focus();
		pass = false;
	}

    var indexation = document.form.amount.value -0;
    // Check the sum entered, is it within the range of values
    if (document.form.amount.value== "") { 
		details+= '- Please enter Sum Insured Amount.\n\n';
    	if (pass) document.form.amount.focus();
		pass = false;
    }
    else if (isNaN(document.form.amount.value)) { 
		details+= '- Please enter a number for the Sum Insured Amount.\n\n';
    	if (pass) document.form.amount.focus();
		pass = false;
	}
	else if (indexation < 25000) { 
		details+= '- Please enter a Sum Insured Amount of 25000 or more.\n\n';
    	if (pass) document.form.amount.focus();
		pass = false;
	}
	else if (indexation > 1000000) { 
		details+= '- Please enter a Sum Insured Amount between 25000 - 1000000.\n\n';
    	if (pass) document.form.amount.focus();
		pass = false;
	}

	// Check email entered
	if (inputEmail == '') {
		details+= '- Please enter an Email Address.\n\n';
    	if (pass) document.form.email.focus();
		pass = false;
	}
	else if ((inputEmail.indexOf("@") == -1) || (inputEmail.indexOf(".") == -1)) {
		details+= '- Please enter a properly formatted Email Address.\n\n';
    	if (pass) document.form.email.focus();
		pass = false;
	}

	// Hanldes life2 birthday details
    if((document.form.SingleJoint.options[1].selected)&&
      (document.form.app2BirthDay.options[document.form.app2BirthDay.selectedIndex].value=="")) { 
		details+= '- Please select which Day Life 2 was born.\n\n';
    	if (pass) document.form.app2BirthDay.focus();
		pass = false;
	}
    if((document.form.SingleJoint.options[1].selected)&&
      (document.form.app2BirthMonth.options[document.form.app2BirthMonth.selectedIndex].value=="")) { 
		details+= '- Please select which Month Life 2 was born.\n\n';
    	if (pass) document.form.app2BirthMonth.focus();
		pass = false;
	}
    if((document.form.SingleJoint.options[1].selected)&&
      (document.form.app2BirthYear.options[document.form.app2BirthYear.selectedIndex].value=="")) { 
		details+= '- Please select which Year Life 2 was born.\n\n';
    	if (pass) document.form.app2BirthYear.focus();
		pass = false;
	}
	if (pass) { 
	    showLoader();
		//return true;
		//return false;
	}
	else { 
		details+= 'Please correct the above errors before proceeding.    \n\n';
		alert(details);
		return false;
	}
}

// Second form page of Life / Mortgage
function CheckLMForm2(single) { 
	var pass = true;
	var details = 'Invalid information entered.\n\n';
    //var single = "<?php echo $single; ?>";

	if(document.form.L1Title.options[document.form.L1Title.selectedIndex].value=="") { 
		details+= '- Please select a Title for Life 1.\n\n';
    	if (pass) document.form.L1Title.focus();
		pass = false;
	}
	//checks firstname
	if (document.form.L1Firstname.value == "") { 
		details+= '- Please enter a First Name for Life 1.\n\n';
    	if (pass) document.form.L1Firstname.focus();
		pass = false;
	}
	//checks firstname
	if (document.form.L1Surname.value == "") { 
		details+= '- Please enter a First Surname for Life 1.\n\n';
    	if (pass) document.form.L1Surname.focus();
		pass = false;
	}
	if (document.form.L1Address1.value == "") { 
		details+= '- Please enter an Address for Life 1.\n\n';
    	if (pass) document.form.L1Address1.focus();
		pass = false;
	}
	//Phone Number
	if (document.form.L1Phone.value =="") { 
		details+= '- Please enter a Phone Number for Life 1.\n\n';
    	if (pass) document.form.L1Phone.focus();
		pass = false;
	}
	else if (isNaN(document.form.L1Phone.value)) { 
		details+= '- Please enter a Phone Number for Life 1.\n\n';
    	if (pass) document.form.L1Phone.focus();
		pass = false;
	}
	if (document.form.L1occupation.value == "") { 
		details+= '- Please enter an Occupation for Life 1.\n\n';
    	if (pass) document.form.L1occupation.focus();
		pass = false;
	}
	if (document.form.L1Marital.options[document.form.L1Marital.selectedIndex].value == "") { 
		details+= '- Please select Marital Status for Life 1.\n\n';
    	if (pass) document.form.L1Marital.focus();
		pass = false;
	}

	if(single!="single") { 
		//Person 2 
		//Handles the title of person 2
		if(document.form.L2Title.options[document.form.L2Title.selectedIndex].value=="") { 
            details+= '- Please select a Title for Life 2.\n\n';
            if (pass) document.form.L2Title.focus();
    		pass = false;
		}
		//checks firstname
		if (document.form.L2Firstname.value== "") { 
            details+= '- Please enter a First Name for Life 2.\n\n';
        	if (pass) document.form.L2Firstname.focus();
    		pass = false;
		}
		//checks firstname
		if (document.form.L2Surname.value== "") { 
    		details+= '- Please enter a First Surname for Life 2.\n\n';
        	if (pass) document.form.L2Surname.focus();
    		pass = false;
		}
		if(document.form.L2Address1.value== "") { 
    		details+= '- Please enter an Address for Life 2.\n\n';
        	if (pass) document.form.L2Address1.focus();
    		pass = false;
		}
		//Phone Number
		if (document.form.L2Phone.value=="") { 
    		details+= '- Please enter a Phone Number for Life 2.\n\n';
        	if (pass) document.form.L2Phone.focus();
    		pass = false;
		}
		else if (isNaN(document.form.L2Phone.value)) { 
    		details+= '- Please enter a Phone Number for Life 2.\n\n';
        	if (pass) document.form.L2Phone.focus();
    		pass = false;
		}
		if (document.form.L2occupation.value== "") { 
    		details+= '- Please enter an Occupation for Life 2.\n\n';
        	if (pass) document.form.L2occupation.focus();
    		pass = false;
		}
		if (document.form.L2Marital.options[document.form.L2Marital.selectedIndex].value=="") { 
    		details+= '- Please select Marital Status for Life2.\n\n';
        	if (pass) document.form.L2Marital.focus();
    		pass = false;
		}
	}

	//Check the tick box value
	if (!document.form.Compliance.checked) { 
    	details+= '- You must agree to our Terms of Business to continue.\n\n';
        if (pass) document.form.Compliance.focus();
    	pass = false;
	}

	if (pass) { 
		return true;
	}
	else { 
		details+= 'Please correct the above errors before proceeding.    \n\n';
		alert(details);
		return false;
	}
}

// Third form page of Life / Mortgage
function CheckLMForm3() { 
	var pass = true;
	var details = 'Invalid information entered.\n\n';

	//check the sum entered, is it within the range of values
	if (document.form.MortAmount.value == "") { 
		details+= '- Please the Mortgage Amount.\n\n';
    	if (pass) document.form.MortAmount.focus();
		pass = false;
	}
    else if (isNaN(document.form.MortAmount.value)) { 
		details+= '- Please enter a number for the Mortgage Amount.\n\n';
    	if (pass) document.form.MortAmount.focus();
		pass = false;
	}

	if (document.form.MortTerm.options[document.form.MortTerm.selectedIndex].value == "") { 
		details+= '- Please select the Mortgage Term.\n\n';
    	if (pass) document.form.MortTerm.focus();
		pass = false;
	}

	if (pass) { 
		return true;
	}
	else { 
		details+= 'Please correct the above errors before proceeding.    \n\n';
		alert(details);
		return false;
	}
}
-->
