function formCheck(formobj){
	// Enter name of mandatory fields
	var fieldRequired = Array("quote_email","quote_life1_gender","quote_life1_smoker","quote_life1_birthday","quote_life1_birthmonth","quote_life1_birthyear","quote_covertype","quote_term","quote_indexation","quote_life1_lifecoveramount");
	// Enter field description to appear in the dialog box
	var fieldDescription = Array("Your Email Address","Your Gender","Smoker or Not","Life One Birth Day","Life One Birth Month","Life One Birth Year","Single, Joint or Dual","Length of term","Include indexation","Cover insured");
	// dialog message
	var lifeTwoFieldRequired = Array("quote_life2_gender","quote_life2_smoker","quote_life2_birthday","quote_life2_birthmonth","quote_life2_birthyear");
	var lifeTwoFieldDescription = Array("Life Two Gender","Life Two Smoker or Not","Life Two Birth Day","Life Two Birth Month","Life Two Birth Year");
	
	var alertMsg = "Please complete the following fields:\n";
	var coverTypeObj = formobj.elements["quote_covertype"];
	if (coverTypeObj.options[coverTypeObj.selectedIndex].value!="1"){
		var fieldRequired=fieldRequired.concat(lifeTwoFieldRequired);
		var fieldDescription=fieldDescription.concat(lifeTwoFieldDescription);
	}
	var l_Msg = alertMsg.length;
	
	for (var i = 0; i < fieldRequired.length; i++){
		var obj = formobj.elements[fieldRequired[i]];
		if (obj){
			switch(obj.type){
			case "select-one":
				if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].value == ""){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "select-multiple":
				if (obj.selectedIndex == -1){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			case "text":
			case "textarea":
				if (obj.value == "" || obj.value == null){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
				break;
			default:
			}
			if (obj.type == undefined){
				var blnchecked = false;
				for (var j = 0; j < obj.length; j++){
					if (obj[j].checked){
						blnchecked = true;
					}
				}
				if (!blnchecked){
					alertMsg += " - " + fieldDescription[i] + "\n";
				}
			}
		}
	}
	if (document.quote.termsandconditions.checked!=true){
		alertMsg +=" - Terms and Conditions";
	}
	if (alertMsg.length == l_Msg){
		return true;
	}else{
                hidediv('pleasewait');
		alert(alertMsg);
		return false;
	}
}





function coverTypeChange(inputData){
	var selected = $("#quote_covertype option:selected");
	if (selected.val()!="1"){
		$('#secondpersonadvert').hide();
		$('#secondperson').slideDown();
	}else{
		$('#secondperson').hide();		
		$('#secondpersonadvert').show();
	}
	
}




function CheckSingleJoint( inputData )
{
  var whichLayer='lifetwosection';
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  if (inputData.options[inputData.selectedIndex].value==1){
      vis.display='none';
      var whichLayer='life2banner';
      var elem, vis;
      if( document.getElementById ) // this is the way the standards work
        elem = document.getElementById( whichLayer );
      else if( document.all ) // this is the way old msie versions work
          elem = document.all[whichLayer];
      else if( document.layers ) // this is the way nn4 works
        elem = document.layers[whichLayer];
      vis = elem.style;
      vis.display='block';
  }else {
    vis.display='block';
    var whichLayer='life2banner';
    var elem, vis;
    if( document.getElementById ) // this is the way the standards work
      elem = document.getElementById( whichLayer );
    else if( document.all ) // this is the way old msie versions work
        elem = document.all[whichLayer];
    else if( document.layers ) // this is the way nn4 works
      elem = document.layers[whichLayer];
    vis = elem.style;
    vis.display='none';
  // if the style.display value is blank we try to figure it out here
  //if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
  //  vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  //vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  }
}
function showhide( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;

  //if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
  
}
function hidediv( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = "none";
}
function showdiv( whichLayer )
{
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  vis.display = "block";
}
function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
  return newnumber;
}
function displayQuotingCompany(monthQuoteCompany,annualQuoteCompany){
  //document.quote.quote_company_monthly.value=document.quote.mort_monthly_company.value;
  //document.quote.quote_company_annual.value=document.quote.mort_annually_company.value;
  document.quote.quote_company_monthly.value=monthQuoteCompany;
  document.quote.quote_company_annual.value=annualQuoteCompany;
  var rad_val="annually";
  for (var i=0; i < document.quote.payment_option.length; i++)
  {
      if (document.quote.payment_option[i].checked)
      {
          var rad_val = document.quote.payment_option[i].value;
      }
  }
  var whichLayer="quotecompanyname";
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  if (rad_val=="monthly"){
    elem.innerHTML=monthQuoteCompany;    
  }else{
    elem.innerHTML=annualQuoteCompany;
  }

  var whichLayer="insurance_document";
  var pdfelem, pdfvis;
  if( document.getElementById ) // this is the way the standards work
    pdfelem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      pdfelem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    pdfelem = document.layers[whichLayer];

  var pdfdocument="";
  if (elem.innerHTML=="Caledonian Life"){
    pdfdocument="caledonianlife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Aviva"){    
    pdfdocument="hibernian.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Canada Life"){
    pdfdocument="canadalife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Zurich Life"){
    pdfdocument="javascript: submitEagleStarForm()";
    pdfelem.innerHTML='<img src="images/apply_now.jpg"  alt="" />';
  }else if (elem.innerHTML=="Friends First"){
    pdfdocument="friendsfirst.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Hibernian"){
    pdfdocument="hibernian.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Irish Life"){
    pdfdocument="irishlife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="New Ireland"){
    pdfdocument="newireland.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else{
    pdfdocument="unknowninsurer.pdf";
    pdfelem.innerHTML='<img src="images/apply_now.jpg" alt="" />';
  }
  pdfelem.href=pdfdocument;
}

function loadQuotePage(insuranceType){
	$('input[name=payment_option]')[0].checked = true;
	var paymentOption = $('input[name=payment_option]:checked').val();
	var quotingCompany = $('#quotecompanyname').html();
	var pdfdocument="";
	if (quotingCompany=="Caledonian Life"){
	  pdfdocument="caledonianlife.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="Canada Life"){
	  pdfdocument="canadalife.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="Zurich Life"){
	  pdfdocument="javascript: submitEagleStarForm()";
	  $('#insurance_document').val('<img src="images/apply_now.jpg" alt="" />');
	}else if (quotingCompany=="Friends First"){
	  pdfdocument="friendsfirst.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="Hibernian"){
	  pdfdocument="hibernian.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="Aviva"){
	  pdfdocument="hibernian.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="Irish Life"){
	  pdfdocument="irishlife.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg" alt="" />');
	}else if (quotingCompany=="New Ireland"){
	  pdfdocument="newireland.pdf";
	  $('#insurance_document').val('<img src="images/buttons/download.jpg"  alt="" />');
	}else{
	  pdfdocument="unknowninsurer.pdf";
	  $('#insurance_document').val('<img src="images/apply_now.jpg" alt="" />');
	}
	$('#insurance_document').attr("href",pdfdocument);
	$('quote_company_monthly').val();
	$('quote_company_annual').val();
	//document.quote.quote_company_monthly.value=quotingCompany;
	//document.quote.quote_company_annual.value=quotingCompany;

}

function initQuotingCompany(){
  //document.quote.quote_company_monthly.value=document.quote.mort_monthly_company.value;
  //document.quote.quote_company_annual.value=document.quote.mort_annually_company.value;
  var rad_val="annually";
  for (var i=0; i < document.quote.payment_option.length; i++)
  {
      if (document.quote.payment_option[i].checked)
      {
          var rad_val = document.quote.payment_option[i].value;
      }
  }  var whichLayer="quotecompanyname";
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];

  var whichLayer="insurance_document";
  var pdfelem, pdfvis;
  if( document.getElementById ) // this is the way the standards work
    pdfelem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      pdfelem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    pdfelem = document.layers[whichLayer];

  var pdfdocument="";
  if (elem.innerHTML=="Caledonian Life"){
    pdfdocument="caledonianlife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Canada Life"){
    pdfdocument="canadalife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Zurich Life"){
    pdfdocument="javascript: submitEagleStarForm()";
    pdfelem.innerHTML='<img src="images/apply_now.jpg" alt="" />';
  }else if (elem.innerHTML=="Friends First"){
    pdfdocument="friendsfirst.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Hibernian"){
    pdfdocument="hibernian.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Aviva"){
    pdfdocument="hibernian.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="Irish Life"){
    pdfdocument="irishlife.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg" alt="" />';
  }else if (elem.innerHTML=="New Ireland"){
    pdfdocument="newireland.pdf";
    pdfelem.innerHTML='<img src="images/buttons/download.jpg"  alt="" />';
  }else{
    pdfdocument="unknowninsurer.pdf";
    pdfelem.innerHTML='<img src="images/apply_now.jpg" alt="" />';
  }
  pdfelem.href=pdfdocument;
  //document.quote.quote_company_monthly.value=elem.innerHTML;
  //document.quote.quote_company_annual.value=elem.innerHTML;
}

function checkCoverType(){
  try {
    if (document.quote.quote_covertype.options[0].selected) {
      hidediv('lifetwosection');
      showdiv('life2banner');
    }else{
      showdiv('lifetwosection');
      hidediv('life2banner');
    }
  }catch( ex ) {
    
  }
}

function submitEagleStarForm(){
  document.quote.action = 'applyonline.php';
  document.quote.submit();
}
function checkAllOptions(producttype){
  
  if (producttype=="lifeonly"){
    if (document.quote.seriousacc_life_monthly.value==""){
      document.quote.apply_seriousilness.disabled=true;
      document.quote.apply_seriousilness.enabled=false;
    }else{
      document.quote.apply_seriousilness.disabled=false;
      document.quote.apply_seriousilness.enabled=true;
    }
    if (document.quote.convert_life_monthly.value==""){
      document.quote.apply_convertible.disabled=true;
      document.quote.apply_convertible.enabled=false;
    }else{
      document.quote.apply_convertible.disabled=false;
      document.quote.apply_convertible.enabled=true;
    }
    
  }else if (producttype=="mortgage"){
    if (document.quote.seriousacc_mort_monthly.value==""){
      document.quote.apply_seriousilness.disabled=true;
      document.quote.apply_seriousilness.enabled=false;
    }
    if (document.quote.convert_mort_monthly.value==""){
      document.quote.apply_convertible.disabled=true;
      document.quote.apply_convertible.enabled=false;
    }
  } else if (producttype=="illness"){
    if (document.quote.serious_monthly.value==""){
      document.quote.apply_seriousilness.disabled=true;
      document.quote.apply_seriousilness.enabled=false;
      document.quote.apply_prodchosen[1].disabled=true;
    }
    if (document.quote.convert_serious_monthly.value==""){
      document.quote.apply_convertible.disabled=true;
      document.quote.apply_convertible.enabled=false;
    }
  }
}

function ProductChange(prodcuttype){
	document.quote.apply_seriousilness.checked=false;
	document.quote.apply_convertible.checked=false;

	if (prodcuttype=="MP"){
		document.quote.apply_convertible.disabled=true;
		document.quote.apply_convertible.enabled=true;
		document.quote.apply_seriousilness.disabled=false;
		document.quote.apply_seriousilness.enabled=true;
		document.quote.apply_monthquote.value=document.quote.mort_monthly.value;
                document.quote.quote_company_monthly.value=document.quote.mort_monthly_company.value;
                document.quote.apply_annualquote.value=document.quote.mort_annually.value;
                document.quote.quote_company_annual.value=document.quote.mort_annually_company.value;
                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                var refundMonthlyAmount=roundNumber((document.quote.mort_monthly.value*0.70)*12,2);
		if (document.quote.mort_monthly.value<=30.00){
			refundMonthlyAmount=0.00;
		}
                var refundAnnuallyAmount=roundNumber(document.quote.mort_annually.value*0.30,2);
                if (document.quote.mort_annually.value<=299.00){
			refundAnnuallyAmount=parseFloat(document.quote.mort_annually.value);
		}
		//document.quote.apply_monthquoterefund.value=refundMonthlyAmount.toFixed(2);
		//document.quote.apply_annualquoterefund.value=refundAnnuallyAmount.toFixed(2);
                checkAllOptions('mortgage');

	}else if (prodcuttype=="TL"){
		document.quote.apply_convertible.enabled=true;
		document.quote.apply_convertible.disabled=false;
		document.quote.apply_seriousilness.enabled=true;
		document.quote.apply_seriousilness.disabled=false;
		document.quote.apply_monthquote.value=document.quote.life_monthly.value;
                document.quote.quote_company_monthly.value=document.quote.life_monthly_company.value;
                document.quote.apply_annualquote.value=document.quote.life_annually.value;
                document.quote.quote_company_annual.value=document.quote.life_annually_company.value;
                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                var refundMonthlyAmount=roundNumber((document.quote.life_monthly.value*0.70)*12,2);
		if (document.quote.life_monthly.value<=30.00){
			refundMonthlyAmount=0.00;
		}
                var refundAnnuallyAmount=roundNumber(document.quote.life_annually.value*0.30,2);
		if (document.quote.life_annually.value<=299.00){
			refundAnnuallyAmount=parseFloat(document.quote.life_annually.value);
		}		
                //document.quote.apply_monthquoterefund.value=refundMonthlyAmount.toFixed(2);
                //document.quote.apply_annualquoterefund.value=refundAnnuallyAmount.toFixed(2);
                checkAllOptions('lifeonly');
	}else if (prodcuttype=="SI"){
		document.quote.apply_convertible.enabled=true;
		document.quote.apply_convertible.disabled=false;
		document.quote.apply_seriousilness.disabled=true;
		document.quote.apply_seriousilness.enabled=false;
		
		document.quote.apply_monthquote.value=document.quote.serious_monthly.value;
                document.quote.quote_company_monthly.value=document.quote.serious_monthly_company.value;
		document.quote.apply_annualquote.value=document.quote.serious_annually.value;
                document.quote.quote_company_annual.value=document.quote.serious_annually_company.value;
                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                var refundMonthlyAmount=roundNumber((document.quote.serious_monthly.value*0.70)*12,2);
		if (document.quote.serious_monthly.value<=30.00){
			refundMonthlyAmount=0.00;
		}	
                var refundAnnuallyAmount=roundNumber(document.quote.serious_annually.value*0.30,2);
		if (document.quote.serious_annually.value<=299.00){
			refundAnnuallyAmount=parseFloat(document.quote.serious_annually.value);
		}
                //document.quote.apply_monthquoterefund.value=refundMonthlyAmount.toFixed(2);
                //document.quote.apply_annualquoterefund.value=refundAnnuallyAmount.toFixed(2);
                checkAllOptions('illness');
	}
}
function ProductOptions(applyoption){
        if (applyoption=="opt_ilness_mort"){
          var rad_val="MP";
          var applyoption="opt_ilness";
        }else{
	for (var i=0; i < document.quote.apply_prodchosen.length; i++)
	   {
	   if (document.quote.apply_prodchosen[i].checked)
	      {
	      var rad_val = document.quote.apply_prodchosen[i].value;
	      }
	   }
        }
	if(applyoption=="opt_ilness"){
		if (rad_val=="MP"){
			var currentmonthquote=eval(document.quote.mort_monthly.value);
			var currentannualquote=eval(document.quote.mort_annually.value);
			if (document.quote.apply_seriousilness.checked==true){
				monthlySum=eval(document.quote.seriousacc_mort_monthly.value);
                                //document.quote.quote_company_monthly.value=document.quote.seriousacc_mort_monthly_company.value;
				annuallySum=eval(document.quote.seriousacc_mort_annually.value);
                                //document.quote.quote_company_annual.value=document.quote.seriousacc_mort_annually_company.value;
				displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			} else {
				monthlySum=currentmonthquote;
                                annuallySum=currentannualquote;
                                //document.quote.quote_company_monthly.value=document.quote.mort_monthly_company.value;
                                //document.quote.quote_company_annual.value=document.quote.mort_annually_company.value;
                                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			}
			document.quote.apply_monthquote.value=roundNumber(monthlySum,2).toFixed(2);
			document.quote.apply_annualquote.value=roundNumber(annuallySum,2).toFixed(2);

                        var refundmonthlyamount=roundNumber((monthlySum*0.70)*12,2);
			if (document.quote.apply_monthquote.value<=30.00){
				refundmonthlyamount=0.00;
			}
                        //document.quote.apply_monthquoterefund.value=refundmonthlyamount.toFixed(2);
                        var refundannuallyamount=roundNumber(annuallySum*0.30,2);
			if (document.quote.apply_annualquote.value<=299.00){
				refundannuallyamount=parseFloat(document.quote.apply_annualquote.value);
			}
                        //document.quote.apply_annualquoterefund.value=refundannuallyamount.toFixed(2);
                        checkAllOptions('mortgage');
		}else if (rad_val=="TL"){
			var currentmonthquote=eval(document.quote.apply_monthquote.value);
			var currentannualquote=eval(document.quote.apply_annualquote.value);
			if (document.quote.apply_seriousilness.checked==true){
				if (document.quote.apply_convertible.checked==true){
                                  monthlySum=eval(document.quote.seriousacc_life_convert_monthly.value);
                                  //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_convert_monthly_company.value;
                                  annuallySum=eval(document.quote.seriousacc_life_convert_annually.value);
                                  //document.quote.quote_company_annual.value=document.quote.seriousacc_life_convert_annually_company.value;
                                  displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                                }else{
                                  monthlySum=eval(document.quote.seriousacc_life_monthly.value);
                                  annuallySum=eval(document.quote.seriousacc_life_annually.value);
                                  //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_monthly_company.value;
                                  //document.quote.quote_company_annual.value=document.quote.seriousacc_life_annually_company.value;
                                  displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                                }
			}else if (document.quote.apply_convertible.checked==true){
                                if (document.quote.apply_seriousilness.checked==true){
                                  monthlySum=eval(document.quote.seriousacc_life_convert_monthly.value);
                                  annuallySum=eval(document.quote.seriousacc_life_convert_annually.value);
                                  //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_convert_monthly_company.value;
                                  //document.quote.quote_company_annual.value=document.quote.seriousacc_life_convert_annually_company.value;
                                  displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                                }else{
                                  monthlySum=eval(document.quote.convert_life_monthly.value);
                                  annuallySum=eval(document.quote.convert_life_annually.value);
                                  //document.quote.quote_company_monthly.value=document.quote.convert_life_monthly_company.value;
                                  //document.quote.quote_company_annual.value=document.quote.convert_life_annually_company.value;
                                  displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                                }
                        }else{
				monthlySum=currentmonthquote;
				annuallySum=currentannualquote;
                                //document.quote.quote_company_monthly.value=document.quote.life_monthly_company.value;
                                //document.quote.quote_company_annual.value=document.quote.life_annually_company.value;
                                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			}
			document.quote.apply_monthquote.value=roundNumber(monthlySum,2).toFixed(2);
			document.quote.apply_annualquote.value=roundNumber(annuallySum,2).toFixed(2);

                        var refundmonthlyamount=roundNumber((monthlySum*0.70)*12,2);
			if (document.quote.apply_monthquote.value<=30.00){
				refundmonthlyamount=0.00;
			}			
                        //document.quote.apply_monthquoterefund.value=refundmonthlyamount.toFixed(2);
                        var refundannuallyamount=roundNumber(annuallySum*0.30,2);
			if (document.quote.apply_annualquote.value<=299.00){
				refundannuallyamount=parseFloat(document.quote.apply_annualquote.value);
			}
                        //document.quote.apply_annualquoterefund.value=refundannuallyamount.toFixed(2);
                        checkAllOptions('lifeonly');
		}else{
			displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
		}
	}else if(applyoption=="opt_convert"){
		if (rad_val=="TL"){
			var currentmonthquote=parseFloat(document.quote.life_monthly.value);
			var currentannualquote=parseFloat(document.quote.life_annually.value);
			if (document.quote.apply_convertible.checked==true){
                          if (document.quote.apply_seriousilness.checked==true){
				monthlySum=parseFloat(document.quote.seriousacc_life_convert_monthly.value);
				annuallySum=parseFloat(document.quote.seriousacc_life_convert_annually.value);
                                //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_convert_monthly_company.value;
                                //document.quote.quote_company_annual.value=document.quote.seriousacc_life_convert_annually_company.value;
                                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                          } else {
				monthlySum=parseFloat(document.quote.convert_life_monthly.value);
				annuallySum=parseFloat(document.quote.convert_life_annually.value);
                                //document.quote.quote_company_monthly.value=document.quote.convert_life_monthly_company.value;
                                //document.quote.quote_company_annual.value=document.quote.convert_life_annually_company.value;
                                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                          }
                        }else if (document.quote.apply_seriousilness.checked==true){
                          if (document.quote.apply_convertible.checked==true){
				monthlySum=parseFloat(document.quote.seriousacc_life_convert_monthly.value);
				annuallySum=parseFloat(document.quote.seriousacc_life_convert_annually.value);
                                //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_convert_monthly_company.value;
                                //document.quote.quote_company_annual.value=document.quote.seriousacc_life_convert_annually_company.value;
                                displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                          }else {
                              monthlySum=parseFloat(document.quote.seriousacc_life_monthly.value);
                              annuallySum=parseFloat(document.quote.seriousacc_life_annually.value);
                              //document.quote.quote_company_monthly.value=document.quote.seriousacc_life_monthly_company.value;
                              //document.quote.quote_company_annual.value=document.quote.seriousacc_life_annually_company.value;
                              displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
                          }
                        }else{
			      monthlySum=currentmonthquote;
			      annuallySum=currentannualquote;
                              //document.quote.quote_company_monthly.value=document.quote.life_monthly_company.value;
                              //document.quote.quote_company_annual.value=document.quote.life_annually_company.value;
                              displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			}
			document.quote.apply_monthquote.value=roundNumber(monthlySum,2).toFixed(2);
			document.quote.apply_annualquote.value=roundNumber(annuallySum,2).toFixed(2);

                        var refundmonthlyamount=roundNumber((monthlySum*0.70)*12,2);
			if (document.quote.apply_monthquote.value<=30.00){
				refundmonthlyamount=0.00;
			}			
                        //document.quote.apply_monthquoterefund.value=refundmonthlyamount.toFixed(2);
                        var refundannuallyamount=roundNumber(annuallySum*0.30,2);
			if (document.quote.apply_annualquote.value<=299.00){
				refundannuallyamount=parseFloat(document.quote.apply_annualquote.value);
			}
                        //document.quote.apply_annualquoterefund.value=refundannuallyamount.toFixed(2);
                        checkAllOptions('lifeonly');
		}else if (rad_val=="SI"){
			var currentmonthquote=parseFloat(document.quote.serious_monthly.value);
			var currentannualquote=parseFloat(document.quote.serious_annually.value);
			if (document.quote.apply_convertible.checked==true){
			      monthlySum=parseFloat(document.quote.convert_serious_monthly.value);
                              annuallySum=parseFloat(document.quote.convert_serious_annually.value);
                              //document.quote.quote_company_monthly.value=document.quote.convert_serious_monthly_company.value;
                              //document.quote.quote_company_annual.value=document.quote.convert_serious_annually_company.value;
                              displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			}else{
			      monthlySum=currentmonthquote;
			      annuallySum=currentannualquote;
                              document.quote.quote_company_monthly.value=document.quote.serious_monthly_company.value;
                              document.quote.quote_company_annual.value=document.quote.serious_annually_company.value;
                              displayQuotingCompany(document.quote.quote_company_monthly.value,document.quote.quote_company_annual.value);
			}
			document.quote.apply_monthquote.value=roundNumber(monthlySum,2).toFixed(2);
			document.quote.apply_annualquote.value=roundNumber(annuallySum,2).toFixed(2);

                        var refundmonthlyamount=roundNumber((monthlySum*0.70)*12,2);
			if (document.quote.apply_monthquote.value<=30.00){
				refundmonthlyamount=0.00;
			}
                        //document.quote.apply_monthquoterefund.value=refundmonthlyamount.toFixed(2);
                        var refundannuallyamount=roundNumber(annuallySum*0.30,2);
			if (document.quote.apply_annualquote.value<=299.00){
				refundannuallyamount=parseFloat(document.quote.apply_annualquote.value);
			}
                        //document.quote.apply_annualquoterefund.value=refundannuallyamount.toFixed(2);
                        checkAllOptions('illness');
		}
	}
	//document.quote.apply_lifeproduct.checked=true;
}




//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblClick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

