    $(function(){
	    $("a[rel^='box']").each(function(){$rel=$(this).attr("rel");$width=$rel.substring($rel.indexOf('(')+1,$rel.indexOf(','));var $offset=$rel.indexOf(',')+1;$height=$rel.substring($rel.indexOf(',')+1,$rel.indexOf(',',$offset));$iframe=$rel.substring($rel.indexOf(',',$offset)+1,$rel.indexOf(')'));$(this).colorbox({width:$width,height:$height,iframe:false,overlayClose:false})});
	    $("#submitLifeCal").click(function(){
	       var valid = ValidateForm();
		   if(valid){
			   calIncomeResult();
		   }
		})
	})

    function isNumeric(val){return(parseFloat(val,10)==(val*1));}

    function nFCheck(){
		var field = document.getElementById("grossSalaryField");
		var field2 = document.getElementById("grossSalaryField2");
		var error = document.getElementById("grossSalaryInputError");
		var grossSalary =document.getElementById("grossIncome").value;
		var validd = true;
        if(!isNumeric(grossSalary)){
			field.style.background = "#F1D2B6";
			field.style.borderColor = "";
			field.style.borderStyle = "";
			field.style.BorderStyleRight = "hidden";

			field2.style.background = "#F1D2B6";
			field2.style.borderColor = "";
			field2.style.borderStyle = "";
			field2.style.BorderStyleRight = "hidden";

            error.innerHTML =  "<br>Required Field";
            validd = false;
        }
        else{
			field.style.background = "#FFFFFF";
			field.style.borderColor = "#ffffff";
			field.style.borderStyle = "none solid solid none";
			field.style.borderWidth = "medium 0px 2px medium";
			field2.style.background = "#FFFFFF";
			field2.style.borderColor = "#ffffff";
			field2.style.borderStyle = "none solid solid none";
			field2.style.borderWidth = "medium 0px 2px medium";
			error.innerHTML = "";
       }
	   return validd;
 }
	 function calIncomeResult(){
		 	var hostUrl="";
			if(window.location.host == "www.testiselect.com.au"){
				hostUrl="http://life.iselect.com.au";
			}

			$.post(""+hostUrl+"/life-insurance-australia/IncomeProtectionCalc.action","grossIncome=" + $("#grossIncome").val(), function(msg){
							var value = '<div id="expandingContent"> <p><strong>We estimate you may require: <span id="calValue"></span>cover.</strong></p></div><a href="lifeInsuranceCalculator.jsp"><img src="/images/_life/b-life-insurance-calculator.gif" alt="Life Insurance Calculator" border="0" /></a><a href="'+hostUrl+'/life-insurance-australia/home.action"><img src="/images/_life/b-get-quote.gif" alt="Income Protection Calculator" border="0" /></a>';$("#incomeCalForm").html(value);$("#calValue").html(msg);$("#main-content").css("min-height", "150px");
			});
	 }

	 function ValidateForm(){
		var valid = true;
	        if(nFCheck()==false){
	          valid = false;
	        }
		return valid;
	 }

 	function submitForm(){
	   document.incomeProtectionCalculator.submit();
	}
