
var male_age = 18;
var male_smoker = false;
var female_age = 18;
var female_smoker = false;
var numChildren = 0;
var county;
var chosenplan;
var pageloaded = false;

var plan1, plan2, plan3, plan4, plan5, plan6, plan7, plan8;

// arrays of combo values
var cnames = ['Select WA County','Adams County', 'Asotin County', 'Benton County', 'Chelan County', 'Clallam County', 'Clark County', 'Columbia County', 'Cowlitz County', 'Douglas County', 'Ferry County', 'Franklin County', 'Garfield County', 'Grant County', 'Grays Harbor County', 'Island County', 'Jefferson County', 'King County', 'Kitsap County', 'Kittitas County', 'Klickitat County', 'Lewis County', 'Lincoln County', 'Mason County', 'Okanogan County', 'Pacific County', 'Pend Oreille County', 'Pierce County', 'San Juan County', 'Skagit County', 'Skamania County', 'Snohomish County', 'Spokane County', 'Stevens County', 'Thurston County', 'Wahkiakum County', 'Walla Walla County', 'Whatcom County', 'Whitman County', 'Yakima County'];

var ages = ['none','under 18','18-24','25-29','30-34','35-39','40-44','45-49','50-54','55-59','60-64','65+'];
var agevalues = [0,17,18,25,30,35,40,45,50,55,60,65];

// 	1 - Asuris		2 - Regence		3 - Group Health 		4 - Likewise

var c = [];
c['Select WA County1'] = false;
c['Select WA County2'] = true; 
c['Select WA County3'] = true; // Group Health 
c['Select WA County4'] = true; // Lifewise
c['Adams County1'] = true;
c['Adams County2'] = false;
c['Adams County3'] = false;
c['Adams County4'] = true;
c['Asotin County1'] = true;
c['Asotin County2'] = false;
c['Asotin County3'] = false;
c['Asotin County4'] = true;
c['Benton County1'] = true;
c['Benton County2'] = false;
c['Benton County3'] = true;
c['Benton County4'] = true;
c['Chelan County1'] = true;
c['Chelan County2'] = false;
c['Chelan County3'] = false;
c['Chelan County4'] = true;
c['Clallam County1'] = false;
c['Clallam County2'] = true;
c['Clallam County3'] = false;
c['Clallam County4'] = true;
c['Clark County1'] = false;
c['Clark County2'] = false;
c['Clark County3'] = false;
c['Clark County4'] = true;
c['Columbia County1'] = false;
c['Columbia County2'] = true;
c['Columbia County3'] = true;
c['Columbia County4'] = true;
c['Cowlitz County1'] = false;
c['Cowlitz County2'] = true;
c['Cowlitz County3'] = false;
c['Cowlitz County4'] = true;
c['Douglas County1'] = true;
c['Douglas County2'] = false;
c['Douglas County3'] = false;
c['Douglas County4'] = true;
c['Ferry County1'] = true;
c['Ferry County2'] = false;
c['Ferry County3'] = false;
c['Ferry County4'] = true;
c['Franklin County1'] = true;
c['Franklin County2'] = false;
c['Franklin County3'] = true;
c['Franklin County4'] = true;
c['Garfield County1'] = true;
c['Garfield County2'] = false;
c['Garfield County3'] = false;
c['Garfield County4'] = true;
c['Grant County1'] = true;
c['Grant County2'] = false;
c['Grant County3'] = false;
c['Grant County4'] = true;
c['Grays Harbor County1'] = false;
c['Grays Harbor County2'] = true;
c['Grays Harbor County3'] = true;
c['Grays Harbor County4'] = true;
c['Island County1'] = false;
c['Island County2'] = true;
c['Island County3'] = true;
c['Island County4'] = true;
c['Jefferson County1'] = false;
c['Jefferson County2'] = true;
c['Jefferson County3'] = false;
c['Jefferson County4'] = true;
c['King County1'] = false;
c['King County2'] = true;
c['King County3'] = true;
c['King County4'] = true;
c['Kitsap County1'] = false;
c['Kitsap County2'] = true;
c['Kitsap County3'] = true;
c['Kitsap County4'] = true;
c['Kittitas County1'] = true;
c['Kittitas County2'] = false;
c['Kittitas County3'] = true;
c['Kittitas County4'] = true;
c['Klickitat County1'] = false;
c['Klickitat County2'] = true;
c['Klickitat County3'] = false;
c['Klickitat County4'] = true;
c['Lewis County1'] = false;
c['Lewis County2'] = true;
c['Lewis County3'] = true;
c['Lewis County4'] = true;
c['Lincoln County1'] = true;
c['Lincoln County2'] = false;
c['Lincoln County3'] = false;
c['Lincoln County4'] = true;
c['Mason County1'] = false;
c['Mason County2'] = true;
c['Mason County3'] = true;
c['Mason County4'] = true;
c['Okanogan County1'] = true;
c['Okanogan County2'] = false;
c['Okanogan County3'] = false;
c['Okanogan County4'] = true;
c['Pacific County1'] = false;
c['Pacific County2'] = true;
c['Pacific County3'] = false;
c['Pacific County4'] = true;
c['Pend Oreille County1'] = true;
c['Pend Oreille County2'] = false;
c['Pend Oreille County3'] = false;
c['Pend Oreille County4'] = true;
c['Pierce County1'] = false;
c['Pierce County2'] = true;
c['Pierce County3'] = true;
c['Pierce County4'] = true;
c['San Juan County1'] = false;
c['San Juan County2'] = true;
c['San Juan County3'] = true;
c['San Juan County4'] = true;
c['Skagit County1'] = false;
c['Skagit County2'] = true;
c['Skagit County3'] = true;
c['Skagit County4'] = true;
c['Skamania County1'] = true;
c['Skamania County2'] = false;
c['Skamania County3'] = false;
c['Skamania County4'] = true;
c['Snohomish County1'] = false;
c['Snohomish County2'] = true;
c['Snohomish County3'] = true;
c['Snohomish County4'] = true;
c['Spokane County1'] = true;
c['Spokane County2'] = false;
c['Spokane County3'] = true;
c['Spokane County4'] = true;
c['Stevens County1'] = true;
c['Stevens County2'] = false;
c['Stevens County3'] = false;
c['Stevens County4'] = true;
c['Thurston County1'] = false;
c['Thurston County2'] = true;
c['Thurston County3'] = true;
c['Thurston County4'] = true;
c['Wahkiakum County1'] = false;
c['Wahkiakum County2'] = true;
c['Wahkiakum County3'] = false;
c['Wahkiakum County4'] = true;
c['Walla Walla County1'] = false;
c['Walla Walla County2'] = true;
c['Walla Walla County3'] = true;
c['Walla Walla County4'] = true;
c['Whatcom County1'] = false;
c['Whatcom County2'] = true;
c['Whatcom County3'] = true;
c['Whatcom County4'] = true;
c['Whitman County1'] = true;
c['Whitman County2'] = false;
c['Whitman County3'] = true;
c['Whitman County4'] = true;
c['Yakima County1'] = false;
c['Yakima County2'] = true;
c['Yakima County3'] = true;
c['Yakima County4'] = true;

function showinstructions(agent) {

    closeagents();
    // open instructions window
    document.getElementById('instructions').style.display = 'block';
    // hide all instruction pdf's
    for (x = 1; x < 10; x++) {
        document.getElementById('i-plan-' + x).style.display = 'none';
    }
    //show instruction pdfs for current plan
    if (chosenplan == 3 || chosenplan == 6) {
        
        if (chosenplan == 3) {
            if (c[county + '1'] == false && c[county + '2'] == true) {
                // Regence
                document.getElementById('i-plan-' + chosenplan).style.display = 'block';
            } else if (c[county + '1'] == true && c[county + '2'] == false) {
                // asuris
                // 2 - Asuris HSA 4 - Core 6 - Clarity
                document.getElementById('i-plan-8').style.display = 'block';
            }
        }
        if (chosenplan == 6) {
            if (c[county + '1'] == false && c[county + '2'] == true) {
                // Regence
                document.getElementById('i-plan-' + chosenplan).style.display = 'block';
            } else if (c[county + '1'] == true && c[county + '2'] == false) {
                // asuris
                // 2 - Asuris HSA 4 - Core 6 - Clarity
                document.getElementById('i-plan-9').style.display = 'block';
            }
        }
    } else {
        document.getElementById('i-plan-' + chosenplan).style.display = 'block';
    }

    //	document.getElementById('i-plan-' + chosenplan).style.display = 'block';

    document.cookie = "agent=" + escape(agent) + ";";
    
	// change links 
	switch (chosenplan) {
		case 1: 
			// Group Health
			switch (agent) {
    			 case 'RyanHart':
		    	    document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117319';
		    	    return;
	    		 case 'BeckyHart':
    			    document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117296';
    			    return;
			     case 'KyleHart':
			        document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117266';
			        return;
				 case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=149688';
					 return;
			}
			
	 	case 2: 
			// Lifewise
			switch (agent) {
    			 case 'RyanHart':
    			    document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101314';
    			    return;
    			 case 'BeckyHart':
        			document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101299';
        			return;
        		 case 'KyleHart':
	        		document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101318';
	        	       return;
				 case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=149726';
					 return;
	        	}
    	case 3: 
			//Regence and Asuris
			if(c[county + '1'] == false && c[county + '2'] == true) { 
				switch (agent) {
    			 case 'RyanHart':
    			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
    			    return;
	    		 case 'BeckyHart':
    				//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-06&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
        			return;
	    		 case 'KyleHart':	
	    			//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-03&dispatch=medical';
					document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
	    		    return;
 				case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
					 return;
				}
			} else if (c[county + '1'] == true && c[county + '2'] == false) { 
				switch (agent) {    
				    case 'RyanHart':
    			        //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
    			        return;
    			    case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
        				return;
                    case 'KyleHart':
       				    //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
       				    return;
					case 'PeterLaney':
						 document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
						 return;
       				}
			}		
		case 4: 
			// Lifewise
			switch (agent) {
    			 case 'RyanHart':
    			    document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101314';
    			    return;
    			 case 'BeckyHart':
        			document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101299';
        			return;
        		 case 'KyleHart':
	        		document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=101318';
	        	       return;
     		   case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://lwwa.inshealth.com/ehi/Alliance?allid=Lif25311&agentid=149726';
					 return;
	        	}
			
		case 5: 
			// Group Health
			switch (agent) {
    			    case 'RyanHart':
    			        document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117319';
    			        return;
    			    case 'BeckyHart':    
            			document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117296';
            			return;
            		case 'KyleHart':
            			document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=117266';
            			return;
						case 'PeterLaney':
					 document.getElementById("planlink").href = 'https://ghc.inshealth.com/ehi/Alliance?allid=Gro21010&agentid=149688';
					 return;
            		}
			
		case 6: 
			//Regence and Asuris
			if(c[county + '1'] == false && c[county + '2'] == true) { 
				switch (agent) {
    			    case 'RyanHart':
        			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0003';
        			    return;
        			case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-06&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0001';
        				return;
        			case 'KyleHart':
        			    //document.getElementById("planlink").href = 'https://www.shop.wa.regence.com/action/new-from-broker?agentNumber=H00531-03&dispatch=medical';
						document.getElementById("planlink").href ='http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0004';
        			    return;
						case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://www.regence.com/individual/medical/index.jsp?agentid=0100234-0005';
					 return;
        		    }
			} else if (c[county + '1'] == true && c[county + '2'] == false) { 
				switch (agent) {
    			    case 'RyanHart':
    			        //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
    			        return;
    			    case 'BeckyHart':
        				//document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
        				document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
						return;
                    case 'KyleHart':
       				    //document.getElementById("planlink").href = 'https://www.shop.asurisnorthwesthealth.com/action/new-from-broker?agentNumber=H00531-02&dispatch=medical';
						document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
       				    return;
					case 'PeterLaney':
					 document.getElementById("planlink").href = 'http://web.asuris.com/individual/medical/AS/index.jsp?agentid=0100234-0001';
					 return;
       				}
			}
        }
}

function apply(plannumber){

    if (pageloaded) {
        chosenplan = plannumber;

        //showinstructions(plannumber);

        if (get_cookie("agent")) {
            //window.alert(get_cookie("agent"))
            showinstructions(get_cookie("agent"));
        } else {
            if(newcookie == null) {
	            document.getElementById('agentselection').style.display = 'block';
			} else {
				showinstructions(newcookie);	
			}
        }
    }	
}

function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}

function closesearch() {
    document.getElementById('search-pop').style.display = 'none';
}
function closeinstructions() {
	document.getElementById('instructions').style.display='none';	
}
function closeagents() {
	document.getElementById('agentselection').style.display='none';	
}

function pageload(opensearch){
	// link to output elements for readability.
	plan1 = document.getElementById('plan1-rate');
	plan2 = document.getElementById('plan2-rate');
	plan3 = document.getElementById('plan3-rate');
	plan4 = document.getElementById('plan4-rate');			
	plan5 = document.getElementById('plan5-rate');
	plan6 = document.getElementById('plan6-rate');
	plan7 = document.getElementById('plan7-rate');
	plan8 = document.getElementById('plan8-rate');
	plan9 = document.getElementById('plan9-rate');
	plan10 = document.getElementById('plan10-rate');
	plan11 = document.getElementById('plan11-rate');
	plan12 = document.getElementById('plan12-rate');
	var select1 = document.getElementById('select1');
	var select2 = document.getElementById('select2');
	var p_male_age = document.getElementById('p_male_age');
	var r_male_age = document.getElementById('r_male_age');
	var p_female_age = document.getElementById('p_female_age');
	var r_female_age = document.getElementById('r_female_age');
	var p_numChildren = document.getElementById('p_numChildren');
	var r_numChildren = document.getElementById('r_numChildren');
	
	// Populate Combo Boxes
	for(i=0; i<cnames.length; i++) {
		select1.options[i] = new Option(cnames[i], cnames[i]);
		select2.options[i] = new Option(cnames[i], cnames[i]);
	}	
	for(i=0; i<=ages.length - 1; i++) {
		r_male_age.options[i] = new Option(ages[i], agevalues[i]);
		p_male_age.options[i] = new Option(ages[i], agevalues[i]);
		r_female_age.options[i] = new Option(ages[i], agevalues[i]);
		p_female_age.options[i] = new Option(ages[i], agevalues[i]);
	}
	for(i=0; i<= 10; i++) {
		r_numChildren.options[i] = new Option(i, i);
		p_numChildren.options[i] = new Option(i, i);
	}	
	if(opensearch) 
	    {
	        document.getElementById('search-pop').style.display = 'block';
	    } else {
			 popchange();
		}
	    pageloaded = true;
}

function popchange()	{
	male_age = document.getElementById('p_male_age').value;
	if(document.getElementById('p_s_male').checked) {male_smoker = true; }else{ male_smoker = false;}
	female_age = document.getElementById('p_female_age').value;
	if(document.getElementById('p_s_female').checked) { female_smoker = true; } else { female_smoker = false; } 
	numChildren = document.getElementById('p_numChildren').value;
	county = document.getElementById('select1').value;
	
	document.getElementById('r_male_age').value = document.getElementById('p_male_age').value;
	document.getElementById('r_s_male').checked = document.getElementById('p_s_male').checked;
	document.getElementById('r_female_age').value = document.getElementById('p_female_age').value;
	document.getElementById('r_s_female').checked = document.getElementById('p_s_female').checked;
	document.getElementById('r_numChildren').value = document.getElementById('p_numChildren').value;
	document.getElementById('select2').value = document.getElementById('select1').value

	changestyles();
	
	calculate();
}
function recalculate()	{
	male_age = document.getElementById('r_male_age').value;
	if(document.getElementById('r_s_male').checked) {male_smoker = true; }else{ male_smoker = false;}
	female_age = document.getElementById('r_female_age').value;
	if(document.getElementById('r_s_female').checked) { female_smoker = true; } else { female_smoker = false; } 
	numChildren = document.getElementById('r_numChildren').value;
	county = document.getElementById('select2').value;
	
	document.getElementById('p_male_age').value = document.getElementById('r_male_age').value;
	document.getElementById('p_s_male').checked = document.getElementById('r_s_male').checked;
	document.getElementById('p_female_age').value = document.getElementById('r_female_age').value;
	document.getElementById('p_s_female').checked = document.getElementById('r_s_female').checked;
	document.getElementById('p_numChildren').value = document.getElementById('r_numChildren').value;
	document.getElementById('select1').value = document.getElementById('select2').value
	
	changestyles();
	
	calculate();
}

function changestyles () {
	
	var hidecolor = "#eeeeee";
	var hideindent = "-9999px"
    var normalindent = "0px"
	// Asuris
	if(c[county + '1'] == false && c[county + '2'] == true) { 
		// set to Regence
		document.getElementById('img3').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/plans_2.jpg";
		document.getElementById('pn3').innerHTML = "Evolve Core";
		//document.getElementById('pdf3').href = "http://www.healthinsuranceconnection.com/docs/HSA/HSA_DetailedInfo.pdf";

		document.getElementById('img6').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/plans_2.jpg";
		document.getElementById('pn6').innerHTML = "Evolve Plus";
		//document.getElementById('pdf6').href = "http://www.healthinsuranceconnection.com/2010/Evolve%20Plus/DetailedInfo.pdf";
		
		document.getElementById('plan3-overlay').style.display = 'none';
		document.getElementById('plan6-overlay').style.display = 'none';
		document.getElementById('plan3').style.color='black'; 
		document.getElementById('plan6').style.color='black';  
		
		} 
	else if (c[county + '1'] == true && c[county + '2'] == false) { 
		// set to Asuris
		document.getElementById('img3').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/asuris-logo.jpg";
		document.getElementById('pn3').innerHTML = "Asuris Core";
		//document.getElementById('pdf3').href = "http://www.healthinsuranceconnection.com/docs/HSA/HSA_DetailedInfo.pdf";
		
		document.getElementById('img6').src="http://www.healthinsuranceconnection.com.asp1-2.dfw1-1.websitetestlink.com/images/asuris-logo.jpg";
		document.getElementById('pn6').innerHTML = "Asuris Plus";
		//document.getElementById('pdf2').href = "docs/HSA/HSA_DetailedInfo.pdf";
		
		document.getElementById('plan3-overlay').style.display = 'none';
		document.getElementById('plan6-overlay').style.display = 'none';
		document.getElementById('plan3').style.color='black';  
		document.getElementById('plan6').style.color='black';  
		
	} else {
		document.getElementById('plan3').style.color= hidecolor;  
		document.getElementById('plan3-overlay').style.display = 'block';
		document.getElementById('plan6').style.color= hidecolor;   
		document.getElementById('plan6-overlay').style.display = 'block';
	}
	
	
	if(c[county + '3'] == false) { // Group Health
		document.getElementById('plan1').style.color= hidecolor;    
		document.getElementById('plan1-overlay').style.display = 'block';
		document.getElementById('plan5').style.color= hidecolor;    
		document.getElementById('plan5-overlay').style.display = 'block';
		} 
	else { 
		document.getElementById('plan1').style.color='black';   
		document.getElementById('plan1-overlay').style.display = 'none';
		document.getElementById('plan5').style.color='black';  
		document.getElementById('plan5-overlay').style.display = 'none';
		// Hide plan 1 and plan 5
		}
		
	if(c[county + '4'] == false) { // Lifewise
		document.getElementById('plan2').style.color= hidecolor;   
		document.getElementById('plan2-overlay').style.display = 'block';
		document.getElementById('plan4').style.color= hidecolor;   
		document.getElementById('plan4-overlay').style.display = 'block';
		}
	else { 
		document.getElementById('plan2').style.color='black';  
		document.getElementById('plan2-overlay').style.display = 'none';
 		document.getElementById('plan4').style.color='black';  
		document.getElementById('plan4-overlay').style.display = 'none';
	}
	
}

function closepop() {
	document.getElementById('search-pop').style.display = 'none';	
}


function calculate(){

	closepop();

	male = male_age;
	female = female_age;
	children = numChildren;

	if (!male_smoker && !female_smoker){
		plan1.innerHTML = "$" + eval(calc_p1(male)+calc_p1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_p2(male)+calc_p2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_p3(male)+calc_p3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_p4(male)+calc_p4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_p5(male)+calc_p5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_p6(male)+calc_p6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_p7(male)+calc_p7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_p8(male)+calc_p8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_p9(male)+calc_p9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_p10(male)+calc_p10(female)+calc_pc10(children));
	} else  if (!male_smoker && female_smoker){
		plan1.innerHTML = "$" + eval(calc_p1(male)+calc_ps1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_p2(male)+calc_ps2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_p3(male)+calc_ps3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_p4(male)+calc_ps4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_p5(male)+calc_ps5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_p6(male)+calc_ps6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_p7(male)+calc_ps7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_p8(male)+calc_ps8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_p9(male)+calc_ps9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_p10(male)+calc_ps10(female)+calc_pc10(children));
	} else  if (male_smoker && !female_smoker){
		plan1.innerHTML = "$" + eval(calc_ps1(male)+calc_p1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_ps2(male)+calc_p2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_ps3(male)+calc_p3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_ps4(male)+calc_p4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_ps5(male)+calc_p5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_ps6(male)+calc_p6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_ps7(male)+calc_p7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_ps8(male)+calc_p8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_ps9(male)+calc_p9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_ps10(male)+calc_p10(female)+calc_pc10(children));
		plan.innerHTML = "$" + eval(calc_ps(male)+calc_p(female)+calc_pc(children));
		plan.innerHTML = "$" + eval(calc_ps(male)+calc_p(female)+calc_pc(children));
	} else  if (male_smoker && female_smoker){
		plan1.innerHTML = "$" + eval(calc_ps1(male)+calc_ps1(female)+calc_pc1(children));
		plan3.innerHTML = "$" + eval(calc_ps2(male)+calc_ps2(female)+calc_pc2(children));
		plan4.innerHTML = "$" + eval(calc_ps3(male)+calc_ps3(female)+calc_pc3(children));
		plan5.innerHTML = "$" + eval(calc_ps4(male)+calc_ps4(female)+calc_pc4(children));
		plan7.innerHTML = "$" + eval(calc_ps5(male)+calc_ps5(female)+calc_pc5(children));
		//plan8.innerHTML = "$" + eval(calc_ps6(male)+calc_ps6(female)+calc_pc6(children));
		plan9.innerHTML = "$" + eval(calc_ps7(male)+calc_ps7(female)+calc_pc7(children));
		plan10.innerHTML = "$" + eval(calc_ps8(male)+calc_ps8(female)+calc_pc8(children));
		plan11.innerHTML = "$" + eval(calc_ps9(male)+calc_ps9(female)+calc_pc9(children));
		plan12.innerHTML = "$" + eval(calc_ps10(male)+calc_ps10(female)+calc_pc10(children));
	}
}

//code column - cut and paste to file
// Group Health HSA Healthpays
function calc_p1(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 79; }
if (age < 30) { return 86; }
if (age < 35) { return 95; }
if (age < 40) { return 105; }
if (age < 45) { return 128; }
if (age < 50) { return 152; }
if (age < 55) { return 182; }
if (age < 60) { return 225; }
if (age < 100) { return 285; }
return 0; 
}

// Smoker
function calc_ps1(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 95; }
if (age < 30) { return 104; }
if (age < 35) { return 114; }
if (age < 40) { return 126; }
if (age < 45) { return 154; }
if (age < 50) { return 182; }
if (age < 55) { return 219; }
if (age < 60) { return 269; }
if (age < 100) { return 341; }
return 0; 
}

// Children
function calc_pc1(num) {
if (num < 1) { return 0; }
if (num < 2) { return 68; }
if (num < 100) { return 136; }
return 0; 
}

// Group Health HSA Healthpays
function calc_p2(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 126; }
if (age < 30) { return 144; }
if (age < 35) { return 165; }
if (age < 40) { return 197; }
if (age < 45) { return 231; }
if (age < 50) { return 291; }
if (age < 55) { return 356; }
if (age < 60) { return 414; }
if (age < 100) { return 472; }
return 0; 
}

// Smoker
function calc_ps2(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 148; }
if (age < 30) { return 166; }
if (age < 35) { return 191; }
if (age < 40) { return 230; }
if (age < 45) { return 271; }
if (age < 50) { return 336; }
if (age < 55) { return 414; }
if (age < 60) { return 480; }
if (age < 100) { return 552; }
return 0; 
}

// Children
function calc_pc2(num) {
if (num < 1) { return 0; }
if (num < 2) { return 107; }
if (num < 3) { return 214; }
if (num < 4) { return 321; }
if (num < 5) { return 428; }
if (num < 6) { return 535; }
if (num < 7) { return 642; }
if (num < 8) { return 749; }
if (num < 9) { return 856; }
if (num < 10) { return 963; }
return 0; 
}

// Lifewise HSA 
function calc_p3(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 108; }
if (age < 30) { return 122; }
if (age < 35) { return 140; }
if (age < 40) { return 168; }
if (age < 45) { return 197; }
if (age < 50) { return 248; }
if (age < 55) { return 304; }
if (age < 60) { return 354; }
if (age < 100) { return 403; }
return 0; 
}

// Smoker
function calc_ps3(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 126; }
if (age < 30) { return 142; }
if (age < 35) { return 162; }
if (age < 40) { return 196; }
if (age < 45) { return 231; }
if (age < 50) { return 287; }
if (age < 55) { return 354; }
if (age < 60) { return 410; }
if (age < 100) { return 470; }
return 0; 
}

// Children
function calc_pc3(num) {
if (num < 1) { return 0; }
if (num < 2) { return 90; }
if (num < 3) { return 180; }
if (num < 4) { return 270; }
if (num < 5) { return 360; }
if (num < 6) { return 450; }
if (num < 7) { return 540; }
if (num < 8) { return 630; }
if (num < 9) { return 720; }
if (num < 10) { return 810; }
return 0; 
}

// Lifewise HSA 
function calc_p4(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 97; }
if (age < 30) { return 112; }
if (age < 35) { return 130; }
if (age < 40) { return 153; }
if (age < 45) { return 180; }
if (age < 50) { return 218; }
if (age < 55) { return 260; }
if (age < 60) { return 305; }
if (age < 100) { return 357; }
return 0; 
}

// Smoker
function calc_ps4(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 112; }
if (age < 30) { return 129; }
if (age < 35) { return 149; }
if (age < 40) { return 176; }
if (age < 45) { return 207; }
if (age < 50) { return 251; }
if (age < 55) { return 298; }
if (age < 60) { return 350; }
if (age < 100) { return 410; }
return 0; 
}

// Children
function calc_pc4(num) {
if (num < 1) { return 0; }
if (num < 2) { return 97; }
if (num < 3) { return 194; }
if (num < 4) { return 291; }
if (num < 5) { return 388; }
if (num < 6) { return 485; }
if (num < 7) { return 582; }
if (num < 8) { return 679; }
if (num < 9) { return 776; }
if (num < 10) { return 873; }
return 0; 
}

// RBS Evolve Core
function calc_p5(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 203; }
if (age < 30) { return 231; }
if (age < 35) { return 265; }
if (age < 40) { return 318; }
if (age < 45) { return 372; }
if (age < 50) { return 468; }
if (age < 55) { return 573; }
if (age < 60) { return 667; }
if (age < 100) { return 759; }
return 0; 
}

// Smoker
function calc_ps5(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 238; }
if (age < 30) { return 267; }
if (age < 35) { return 308; }
if (age < 40) { return 370; }
if (age < 45) { return 436; }
if (age < 50) { return 541; }
if (age < 55) { return 667; }
if (age < 60) { return 774; }
if (age < 100) { return 888; }
return 0; 
}

// Children
function calc_pc5(num) {
if (num < 1) { return 0; }
if (num < 2) { return 171; }
if (num < 3) { return 342; }
if (num < 4) { return 513; }
if (num < 5) { return 684; }
if (num < 6) { return 855; }
if (num < 7) { return 1026; }
if (num < 8) { return 1197; }
if (num < 9) { return 1368; }
if (num < 10) { return 1539; }
return 0; 
}

// Lifewise Wisechoices Prime
function calc_p7(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 238; }
if (age < 30) { return 289; }
if (age < 35) { return 302; }
if (age < 40) { return 279; }
if (age < 45) { return 292; }
if (age < 50) { return 333; }
if (age < 55) { return 411; }
if (age < 60) { return 491; }
if (age < 100) { return 634; }
return 0; 
}

// Smoker
function calc_ps7(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 285; }
if (age < 30) { return 346; }
if (age < 35) { return 361; }
if (age < 40) { return 335; }
if (age < 45) { return 349; }
if (age < 50) { return 399; }
if (age < 55) { return 496; }
if (age < 60) { return 589; }
if (age < 100) { return 761; }
return 0; 
}

// Children
function calc_pc7(num) {
if (num < 1) { return 0; }
if (num < 2) { return 151; }
if (num < 100) { return 302; }
return 0; 
}

// Lifewise Wisechoices Prime
function calc_p8(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 202; }
if (age < 30) { return 245; }
if (age < 35) { return 256; }
if (age < 40) { return 236; }
if (age < 45) { return 248; }
if (age < 50) { return 283; }
if (age < 55) { return 349; }
if (age < 60) { return 416; }
if (age < 100) { return 537; }
return 0; 
}

// Smoker
function calc_ps8(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 242; }
if (age < 30) { return 294; }
if (age < 35) { return 305; }
if (age < 40) { return 284; }
if (age < 45) { return 296; }
if (age < 50) { return 338; }
if (age < 55) { return 418; }
if (age < 60) { return 500; }
if (age < 100) { return 645; }
return ; 
}

// Children
function calc_pc8(num) {
if (num < 1) { return 0; }
if (num < 2) { return 126; }
if (num < 100) { return 252; }
return 0; 
}

// Group Health Balance
function calc_p9(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 215; }
if (age < 30) { return 247; }
if (age < 35) { return 287; }
if (age < 40) { return 339; }
if (age < 45) { return 399; }
if (age < 50) { return 482; }
if (age < 55) { return 574; }
if (age < 60) { return 673; }
if (age < 100) { return 789; }
return 0; 
}

// Smoker
function calc_ps9(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 247; }
if (age < 30) { return 284; }
if (age < 35) { return 330; }
if (age < 40) { return 390; }
if (age < 45) { return 458; }
if (age < 50) { return 555; }
if (age < 55) { return 660; }
if (age < 60) { return 775; }
if (age < 100) { return 907; }
return 0; 
}

// Children
function calc_pc9(num) {
if (num < 1) { return 0; }
if (num < 2) { return 247; }
if (num < 3) { return 494; }
if (num < 4) { return 741; }
if (num < 5) { return 988; }
if (num < 6) { return 1235; }
if (num < 7) { return 1482; }
if (num < 8) { return 1729; }
if (num < 9) { return 1976; }
if (num < 10) { return 2223; }
return 0; 
}

// Group Health Balance
function calc_p10(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 163; }
if (age < 30) { return 187; }
if (age < 35) { return 217; }
if (age < 40) { return 256; }
if (age < 45) { return 301; }
if (age < 50) { return 365; }
if (age < 55) { return 434; }
if (age < 60) { return 509; }
if (age < 100) { return 597; }
return 0; 
}

// Smoker
function calc_ps10(age) {
if (age < 0.1) { return 0; }
if (age < 25) { return 187; }
if (age < 30) { return 215; }
if (age < 35) { return 249; }
if (age < 40) { return 295; }
if (age < 45) { return 347; }
if (age < 50) { return 419; }
if (age < 55) { return 499; }
if (age < 60) { return 586; }
if (age < 100) { return 686; }
return 0; 
}

// Children
function calc_pc10(num) {
if (num < 1) { return 0; }
if (num < 2) { return 187; }
if (num < 3) { return 374; }
if (num < 4) { return 561; }
if (num < 5) { return 748; }
if (num < 6) { return 935; }
if (num < 7) { return 1122; }
if (num < 8) { return 1309; }
if (num < 9) { return 1496; }
if (num < 10) { return 1683; }
return 0; 
}





 
