/////////////////////////////////////////////////////////////////////////////
//     JavaScript functions in order of appearance:
/////////////////////////////////////////////////////////////////////////////
//
//     load style sheet based on user's browser
//     DisplayTopNav(SubNav)            - load top nav and specified sub nav
//     HighLightNavButton()             - navigation links
//     NavMouseOver(Id)                 - navigation links
//     NavMouseOut (Id)                 - navigation links
//     DrawDots(NumberOfDots)           - vertical row used in the top navigation
//     DrawDotsHorizontal(NumberOfDots) - used on callouts
//     DrawHeaderDots(NumberOfDots)     - used to wrap sub header images
//     ToggleDivDisplay(event, ID)      - used for gloassary items and claim calculator
//     DisplayFlash()                   - loads a new flash movie after so many seconds
//     ChangeFlashMovie()               - plays a new movie every 30 seconds
//     SetDivHeight(DivId, DivHeight)   - sets DIV height specific to browser 
//     CalculateClaim()                 - Claim Calculator 
//     AddComma()                       - adds commas to large numbers
//
/////////////////////////////////////////////////////////////////////////////

// === START Load Style Sheet ===========================================



// common styles for all browsers and platforms
var CssStyles = '<link rel="stylesheet" type="text/css" href="/CSS/Styles.css" />';

// get user's browser 
var UserAgent = navigator.userAgent.toLowerCase(); 

//alert("UserAgent = " + UserAgent); // test ***

if(CheckFor('msie')){ // Microsoft Internet Explorer
	
	var UserBrowser = "IE";	
	
}else if(CheckFor('safari')){ // Safari
	
	var UserBrowser = "Safari"
	
	// load Safari CSS style sheet
	CssStyles = CssStyles + '<link rel="stylesheet" type="text/css" href="/CSS/Safari.css">';	
	
}else{ // use FireFox for all other browsers
	
	var UserBrowser = "FireFox";
	
	// load FireFox CSS style sheet
	CssStyles = CssStyles + '<link rel="stylesheet" type="text/css" href="/CSS/FireFox.css">';	
	
}

// get user's platform 
if(CheckFor('mac')){ // Mac 
	
    UserPlatform = "Mac";
	
	// load Macintosh CSS style sheet
    CssStyles = CssStyles + '<link rel="stylesheet" type="text/css" href="/CSS/Mac.css">';
   
}else{ // use Windows platfrom for all others
	
    UserPlatform = "Win32";
	
}

document.write(CssStyles);

function CheckFor(string){ // returns the starting character position or -1 if not found
	
	position = UserAgent.indexOf(string) + 1;
	
	return position;
}

// === END Load Style Sheet ==============================================

// tried to consolidate TopNavTop with SubNav and TopNavBottom but the subnav jerked around in IE

function DisplayTopNav(SubNav){	

	if(SubNav){ // sub nav
		
		var ClassExtension = 'WithSubNav';  
		var NumberOfDots = 9;	
		
	}else{ // no sub nav
					
		var ClassExtension = '';  
		var NumberOfDots = 6;					
	}
	
	document.write('<div id="TopNav" class="TopNav' + ClassExtension + '">');
			
	document.write('	<div class="ShadowRight' + ClassExtension + '">');	
	document.write('		<div class="ShadowRight15"></div>');
	document.write('		<div class="ShadowRight10"></div>');
	document.write('		<div class="ShadowRight05"></div>');	
	document.write('	</div>'); // Shadow Right
	
	document.write('	<div id="TopNavContent" class="TopNavContent' + ClassExtension + '">');
					
	document.write('		<a href="/"><img id="PetPlanLogo" class="PetPlanLogo" src="http://www.gopetplan.com/Images/pet_plan_logo.jpg" alt="Petplan Pet Insurance" /></a>');
				
	document.write('		<script language="javascript" type="text/javascript"> DrawDots(' + NumberOfDots + '); </script>');
				
	document.write('		<div id="MainNav" class="MainNav">'); // main navigation buttons
	
	document.write('    	    <a href="/Why-Pet-Plan.html" class="NavButton" OnMouseOver="NavMouseOver(\'WhyPetPlan\');" OnMouseOut ="NavMouseOut (\'WhyPetPlan\');"><img id="WhyPetPlan" src="http://www.gopetplan.com/Images/Button/WhyPetPlan.gif" width="112" height="18" alt="Why Petplan" style="float: none;" /><img id="WhyPetPlan_On" src="http://www.gopetplan.com/Images/Button/WhyPetPlan_On.gif" width="112" height="18" alt="Why Petplan" style="visibility: hidden; float: none; margin-left: -112px;" /></a>');
	
	document.write('	   		<a href="http://www.gopetplan.com/Dog-Insurance-Policies.html" class="NavButton" OnMouseOver="NavMouseOver(\'DogPlans\');" OnMouseOut ="NavMouseOut (\'DogPlans\');"><img id="DogPlans" src="http://www.gopetplan.com/Images/Button/dogplans.gif" width="108" height="18" alt="Dog Plans" style="float: none;" /><img id="DogPlans_On" src="http://www.gopetplan.com/Images/Button/dogplans_on.gif" width="108" height="18" alt="Dog Plans" style="visibility: hidden; float: none; margin-left: -108px;" /></a>');
	
	document.write('    		<a href="http://www.gopetplan.com/Cat-Insurance-Policies.html" class="NavButton" OnMouseOver="NavMouseOver(\'CatPlans\');" OnMouseOut ="NavMouseOut (\'CatPlans\');"><img id="CatPlans" src="http://www.gopetplan.com/Images/Button/catplans.gif" width="98" height="18" alt="Cat Plans" style="float: none;" /><img id="CatPlans_On" src="http://www.gopetplan.com/Images/Button/catplans_on.gif"  width="98" height="18" alt="Cat Plans" style="visibility: hidden; float: none; margin-left: -98px;"/></a>');
	
	document.write('    		<a href="https://secure.gopetplan.com/index.aspx?op=getaquote" target="_self" class="NavButton" OnMouseOver="NavMouseOver(\'Quote\');" OnMouseOut ="NavMouseOut (\'Quote\');"><img id="Quote" src="http://www.gopetplan.com/Images/Button/Quote.gif" width="78" height="18" alt="Quote" style="float: none;" /><img id="Quote_On" src="http://www.gopetplan.com/Images/Button/Quote_On.gif" width="78" height="18" alt="Quote" style="visibility: hidden; float: none; margin-left: -78px;"/></a>');
	
	//document.write('    		<a href="#" onclick=window.open("https://secure.gopetplan.com/index.aspx?op=login",null,"width=1000,height=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes");  class="NavButton" OnMouseOver="NavMouseOver(\'Enroll\');" OnMouseOut ="NavMouseOut (\'Enroll\');"><img id="Enroll" src="http://www.gopetplan.com/Images/Button/Enroll.gif" width="88" height="18" alt="Enroll" style="float: none;"/><img id="Enroll_On" src="http://www.gopetplan.com/Images/Button/Enroll_On.gif" width="88" height="18" alt="Enroll" style="visibility: hidden; float: none; margin-left: -88px;" /></a>');
	document.write('    		<a href="https://secure.gopetplan.com/index.aspx?op=getaquote" target="_self" class="NavButton" OnMouseOver="NavMouseOver(\'Enroll\');" OnMouseOut ="NavMouseOut (\'Enroll\');"><img id="Enroll" src="http://www.gopetplan.com/Images/Button/Enroll.gif" width="88" height="18" alt="Enroll" style="float: none;"/><img id="Enroll_On" src="http://www.gopetplan.com/Images/Button/Enroll_On.gif" width="88" height="18" alt="Enroll" style="visibility: hidden; float: none; margin-left: -88px;" /></a>');
	
	document.write('    		<script language="javascript" type="text/javascript" src="/Nav/SubNav/' + SubNav + '.js"></script>');		
	
	document.write('		</div>'); // MainNav
	
	document.write('    	<script language="javascript" type="text/javascript"> DrawDots(' + NumberOfDots + '); </script>');
	
	document.write('    	<div id="BreadCrumbs" class="BreadCrumbs">');	
	document.write('        	<a href="http://www.gopetplan.com/Contact-Petplan.html" class="BreadCrumb" style="float: left;"><img src="http://www.gopetplan.com/Images/arrow.gif" width="4" height="5" alt="" style="padding-top: 3px; padding-right: 3px;" />Contact Us</a><br /><img src="http://www.gopetplan.com/Images/arrow.gif" width="4" height="5" alt="" style="padding-top: 3px; padding-right: 3px;" /><a href="http://www.gopetplan.com/Support-For-Vets.html" class="BreadCrumb" style="float: left;">For&nbsp;Vets</a><br /><img src="http://www.gopetplan.com/Images/arrow.gif" width="4" height="5" alt="" style="padding-top: 3px; padding-right: 3px;" /><a  href="#" onclick=window.open("https://secure.gopetplan.com/index.aspx?op=login",null,"width=1000,height=800,status=yes,toolbar=no,menubar=no,location=no,scrollbars=yes"); class="BreadCrumb" style="float: left;">Log In</a>');
	//document.write('        	<a href="http://www.gopetplan.com/Contact-Petplan.html" class="BreadCrumb" style="float: left;"><img src="http://www.gopetplan.com/Images/arrow.gif" width="4" height="5" alt="" style="padding-top: 3px; padding-right: 3px;" />Contact Us</a><br /><img src="http://www.gopetplan.com/Images/arrow.gif" width="4" height="5" alt="" style="padding-top: 3px; padding-right: 3px;" /><a href="http://www.gopetplan.com/Support-For-Vets.html" class="BreadCrumb" style="float: left;">For&nbsp;Vets</a>');	
	document.write('    	</div>'); // BreadCrumbs
	
	document.write('	</div>'); // TopNavContent
	
	document.write('	<div class="ShadowTopNavBottom">');	
	document.write('    	<div class="ShadowBottom15"></div>');
	document.write('    	<div class="ShadowBottom10"></div>');
	document.write('    	<div class="ShadowBottom05"></div>');	
	document.write('	</div>'); // ShadowTopNavBottom
	
	document.write('</div>'); // TopNav
	 
} // function DisplayTopNav(SubNav)


var NavID = new Array(); // define page names for function HighLightNavButton()

// Main nav
NavID[0] = "WhyPetPlan";
NavID[1] = "DogPlans";
NavID[2] = "CatPlans";
NavID[3] = "Quote";
NavID[4] = "Enroll";

// Sub Nav - WhyPetPlan
NavID[5] = "Petplan_Advantage";
NavID[6] = "What_Petplan_Covers";
NavID[7] = "How_Petplan_Works";
NavID[8] = "Covered_For_Life_Pet_Policies";
NavID[9] = "Choosing_The_Right_Pet_Insurance";
NavID[10] = "Praise";

// Sub Nav - Dog/Cat Plans
NavID[11] = "Compare_Pet_Policies";
NavID[12] = "Veterinary_Treatment_Costs";
NavID[13] = "pet_insurance_discounts";
NavID[14] = "ClaimCalculator";
NavID[15] = "ClaimCalculator";

// Sub Nav - For Vets
NavID[16] = "Increasing_Your_Clinics_Revenue";
NavID[17] = "UltimateSupport";

// Sub Nav - About Petplan
NavID[18] = "AllAbout_Petplan_Pet_Insurance";
NavID[19] = "Petplan_Press";
NavID[20] = "Petplan_Partners";
NavID[21] = "Petplan_Charitable_Fund";
NavID[22] = "Veterinary_Advisory_Board";
	
function HighLightNavButton(){
	
	var ThisPageName = window.location.toString().toLowerCase();
	ThisPageName = ThisPageName.toLowerCase();
	//alert("ThisPageName="+ThisPageName);
	
	for (i = 0; i < NavID.length; i++){
		//alert("nav="+NavID[i].toLowerCase());		
		
		var Match = ThisPageName.indexOf(NavID[i].toLowerCase());	
		//alert("Match="+Match);		

		/* test ***
		alert("ThisPageName = " + ThisPageName);
		alert("NavID["+ i + "] = " + NavID[i]);
		alert("Match = " + Match);
		*/
		
		if(Match > 0){
			
			document.getElementById(NavID[i]).src="http://www.gopetplan.com/Images/Button/"+ NavID[i] + "_On.gif";
		}
	}
}

function NavMouseOver(Id){
	
    //alert(window.location.toString().indexOf(Id.toLowerCase()));  // test ***
	
	// skip mouse over function if user is on this page
	if(window.location.toString().toLowerCase().indexOf(Id.toLowerCase()) < 0){ 
	  
	    document.getElementById(Id + "_On").style.visibility = "visible";
		document.getElementById(Id        ).style.visibility = "hidden" ;	  
	}
}
  
function NavMouseOut(Id){
	
	 document.getElementById(Id        ).style.visibility = "visible";
	 document.getElementById(Id + "_On").style.visibility = "hidden" ;	 
}
  
function DrawDots(NumberOfDots){
		  
	document.write('<div id="TopNavDots" class="TopNavDots">');
	
    for(x = 0; x < NumberOfDots; x++){ // create horizontal dots line
		  
        document.write('<img src="http://www.gopetplan.com/Images/Dot.gif" class="DotVertical" alt=""  />');		  
    }
	
	document.write('</div>');	
}
  
function DrawDotsHorizontal(NumberOfDots){
		
    for(x = 0; x < NumberOfDots; x++){ // create horizontal dots line
		  
        document.write('<img src="http://www.gopetplan.com/Images/DotBig.gif" width="4" height="4" alt="" class="CallOutDots" />');		  
    }
		 
}

function DrawHeaderDots(NumberOfDots){
	
	document.write('<div style="clear: both;">');
	 
    for(x = 0; x < NumberOfDots; x++){ // create horizontal dots line
		  
        document.write('<img src="http://www.gopetplan.com/Images/DotBig.gif" width="4" height="4" alt="" class="HeaderDots" />');		  
    }
			
	document.write('</div>');
	 
}

var Drag = false;  // used to drag and drop calculator

function MouseMove(event){  //  lets user drag calculator in IE only
		
	//alert("MouseDown = " + 1);
	if(Drag){ // check if user has mouse button pressed down (drag)
						
		if(UserBrowser != "IE"){ 
			//alert("event.pageX = " + event.pageX) // test
			
			if(UserBrowser == "Safari"){ // Safari
				document.getElementById("Claim Calculator").style.top  = event.pageY -  40 + 'px'; 
				document.getElementById("Claim Calculator").style.left = event.pageX - 360 + 'px'; 
				
			}else{ // Fire Fox
				document.getElementById("Claim Calculator").style.top  = event.pageY -  40 + 'px'; 
				document.getElementById("Claim Calculator").style.left = event.pageX - 300 + 'px'; 	
			}
			
		}else{ // IE 
			
			//alert("IE: x = " + window.event.x + " y = " + window.event.y); // test ***
			//alert("IE: document.documentElement.scrollTop = " + document.documentElement.scrollTop); // test ***
			
			if(document.documentElement && document.documentElement.scrollTop){ // IE 6+
				
				theScrollTop  = document.documentElement.scrollTop;
				theScrollLeft = document.documentElement.scrollLeft;				
				
		    }else{ // IE 5-
			
			    theScrollTop  = document.body.scrollTop;
			    theScrollLeft = document.body.scrollLeft;				
			}
		
		// relocate glossary div to mouse click coordinates
		//document.getElementById(ID).style.top  = window.event.y + theScrollTop  + 'px';
		//document.getElementById(ID).style.left = window.event.x + theScrollLeft + 'px';
				
		document.getElementById("Claim Calculator").style.top  = window.event.y -  theScrollTop -  40 + 'px';
		document.getElementById("Claim Calculator").style.left = window.event.x - theScrollLeft - 220 + 'px';
				
		} // if(UserBrowser!="IE")
		
	} // if(Drag)
	
} // function MouseMove(event)

function MouseDown(event){  // drag

	Drag = true;	
	
	//if(UserBrowser == "IE"){ // throw this intentional error to take select off of page while dragging Claim Calculator
	
		//window.status = IntentionalError; 
					
	//} // if(UserBrowser=="IE")
	
} // function MouseDown(event)

function MouseUp(event){  // drop
	
	Drag = false;	
}

var DivId = new Array(); // load all glossary ids into an array for function ToggleDivDisplay(event, ID)

DivId [0] = "Acupuncture";
DivId [1] = "Advertising and Reward";
DivId [2] = "Alternative Therapies";
DivId [3] = "Alternative Therapies2";
DivId [4] = "AM Best";
DivId [5] = "AM Best2";
DivId [6] = "AM Best3";
DivId [7] = "ANPAC";
DivId [8] = "ANPAC2";
DivId [9] = "ANPAC3";
DivId[10] = "Boarding Kennel Fees";
DivId[11] = "Chiropractic Treatment";
DivId[12] = "Coinsurance";
DivId[13] = "Death from Illness or Injury";
DivId[14] = "Deductible";
DivId[15] = "Exclusion";
DivId[16] = "Exclusion2";
DivId[17] = "Exclusion3";	
DivId[18] = "Hereditary Conditions";
DivId[19] = "Hip Dysplasia";
DivId[20] = "Loss due to Theft or Straying";
DivId[21] = "maximum benefit policy";
DivId[22] = "Maximum Benefit Policy2";
DivId[23] = "Vacation Cancellation";
DivId[24] = "Veterinary Fees";	
DivId[25] = "12 Month Policy";	
DivId[26] = "12 Month Policy2";	

function ToggleDivDisplay(event, ID){ // used with gloassary items and claim calculator

    //alert("document.getElementById(ID).style.display.value = " + document.getElementById("Claim Calculator").style.display.value); // test ***			
	
	for(i = 0; i < DivId.length; i++){ // hide any open divs(user can only have one div item open)
			
		//alert("DivId[i] = " + DivId[i]); // test ***
		
		if(DivId[i] != ID){ // skip current div id
			
			try{ // if div id does not exist on page ignore
				
				eval("document.getElementById('" + DivId[i] + "').style.display='none'"); // hide 
			
			}catch(err){ // an error has occured
				
				//alert("Error Description: " + err.description + "\n\n"); // test ***

			} // try			
			
		} // if(DivId[i] != ID)
		
	} // for(i = 0; i < DivId.length; i++)
	
	if(document.getElementById(ID).style.display!='block'){ 
		
		document.getElementById(ID).style.display='block';  // display
		
	}else{
		
		document.getElementById(ID).style.display='none';  // hide
	}	
	
} // function ToggleDivDisplay

function DisplayFlash(){
	
	var FlashName = new Array(); // create array of flash names

	FlashName[0] = "Dog1";
	FlashName[1] = "Cat1";
	FlashName[2] = "Dog2";
	
	var RandomNumber = Math.floor(Math.random() * 3); // generates a number from 0 to 2
	
	document.write('<object id="FlashIE" style="margin-top: 0px;" ');
	document.write('     width="770"          ');
	document.write('    height="453"          ');		     
	document.write('	 align="middle"       ');
	document.write('   classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" ');
	document.write('  codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,24,0"> ');
	document.write('  <param name="movie"   value="/Flash/' + FlashName[RandomNumber] + '.swf" /> ');
	document.write('  <param name="quality" value="high" />        ');
	document.write('  <param name="wmode"   value="transparent" /> ');
	document.write('  <param name="bgcolor" value="#fbe9c1" />     ');
	document.write('  <embed  id="FlashNotIE" ');
	document.write('     quality="high"       ');
	document.write('     wmode="transparent"  ');
	document.write('     bgcolor="#fbe9c1"    ');
	document.write('       width="772"        ');
	document.write('      height="453"        ');
	document.write('       align="middle"     ');  
	document.write('         src="/Flash/' + FlashName[RandomNumber] + '.swf"        ');
	document.write('        type="application/x-shockwave-flash"                     ');
	document.write('    pluginspage="http://www.macromedia.com/go/getflashplayer" /> ');
	document.write('</object>');
	
	// change flash movie in 30 seconds
	//alex z
	//setTimeout("ChangeFlashMovie()", 30000);	// in milliseconds	
}

function ChangeFlashMovie(){
		
	var FlashPath = "";
	
	//alert("UserBrowser = " + UserBrowser); // test ***
	
	if(UserBrowser == "IE"){ // reference <object> flash
	    		
		FlashPath = document.getElementById("FlashIE").movie;		
		
		//alert("FlashPath = " + FlashPath); // test ***
			
		if(FlashPath == "Flash/Dog1.swf"){  // change flash movie
			
			FlashPath = "Flash/Cat1.swf"
			
		}else if(FlashPath == "Flash/Cat1.swf"){ 
		
			FlashPath = "Flash/Dog2.swf"		
			
		}else if(FlashPath == "Flash/Dog2.swf"){
			
			FlashPath = "Flash/Dog1.swf"		
		}
		
		document.getElementById("FlashIE").movie = FlashPath;
		
	}else{ // reference <embed> flash
		
		window.location.href = window.location.href; // reload page to change flash movie
		
/*	can't get FireFox to change the flash movie	

		//alert("document.getElementById(FlashNotIE).src = " + document.getElementById("FlashNotIE").src); // test ***
		
		FlashPath = document.getElementById("FlashNotIE").src;	
		
		if(FlashPath == "/Flash/Dog1.swf"){  // change flash movie
			
			FlashPath = "/Flash/Cat1.swf"
			
		}else if(FlashPath == "/Flash/Cat1.swf"){ 
		
			FlashPath = "/Flash/Dog2.swf"		
			
		}else if(FlashPath == "/Flash/Dog2.swf"){
			
			FlashPath = "/Flash/Dog1.swf"		
		}
		
		//alert("FlashPath = " + FlashPath); // test ***				
		document.getElementById("FlashNotIE").src = FlashPath;  // 	just won't work!
*/
	}
		
	// do it all over again in 30 seconds
	//alex z
	//setTimeout("ChangeFlashMovie()", 30000);	// in milliseconds
}

function SetDivHeight(DivId, DivHeight){
	
	if(UserBrowser != "IE"){
		
		DivHeight = DivHeight + 10  // increase height for Netscape		
	}
	
	document.getElementById(DivId).style.height = DivHeight + 'px';	
}


// add commas to a large number

String.prototype.reverse = function(){
	
	return this.split('').reverse().join('');	
	} 

Number.prototype.withCommas = function(){ 

	if (isNaN (this)){
		
		return NaN.toString(); 		
	}
	
	var n = Math.abs(this).toFixed(2).split('.');
	
	return [(this < 0 ? '-' : ''), (n[0].length > 3 ? n[0].reverse().match(/\d{1,3}/g).join(',').reverse() : n[0]), n[1] > 0 ? '.' + n[1] : 		undefined].join(''); 
} 
//alert(Number(1234567890).withCommas()) // test ***

function  CalculateClaim(){ // Claim Calculator

	var CostDollars = document.getElementById("CostDollars").value;
	
	// remove commas for computation
	CostDollars = CostDollars.replace(/\,/g, ""); 

	// append cent to dollar value 
    var Cost = parseFloat(CostDollars + "." + document.getElementById("CostCents").value);
	//alert("Cost = " + Cost); // test ***
	
	// add commas for display
	document.getElementById("CostDollars").value = parseFloat(CostDollars).withCommas();
		
	var Plan = parseFloat(document.getElementById("Plan").value); 
		
	var CoInsurance = parseFloat(Plan * document.getElementById("CoInsuranceValue").value); 
	
	// round number to two decimal places
	
	CoInsurance = Math.round(CoInsurance * 100) / 100;
		
	//alert("CoInsurance = " + CoInsurance); // test ***
	
	var Deductible = parseFloat(document.getElementById("DeductibleValue").value);
	
		// Gold   $20,000
		// Silver $12,000
		// Bronze  $8,000
		
	//if (Cost > Plan){ // reimbursement is capped by plan limit
		
	//	var Reimbursement = Plan - CoInsurance - Deductible;
	
	//}else{
		
	//	var Reimbursement = Cost - CoInsurance - Deductible;		
	//}
	
	if ((Cost-Plan)>0)
	{
		var AmountOverIns =  Cost-Plan;
	}
	else
	{
		var AmountOverIns =  0;
		var CoInsurance = parseFloat(Cost * document.getElementById("CoInsuranceValue").value);

	}
	//alert("Cost="+Cost);
	//alert("Plan="+Plan);
	//alert("CoInsurance="+CoInsurance);
	//alert("CoInsurance selected="+document.getElementById("CoInsuranceValue").value);
			
	
	//Reimbursement = Math.round(Reimbursement * 100) / 100;
	
	//var YourCost = Cost - Reimbursement+AmountOverIns;

	var YourCost = CoInsurance + Deductible + AmountOverIns;
	
	//alert("YourCost="+YourCost);

	if ((Plan-Cost)>0)
	{
		var Reimbursement = Cost - CoInsurance - Deductible;
	}
	else
	{
		var Reimbursement = Plan - CoInsurance - Deductible;
	}

	if (Reimbursement<0)
	{
		Reimbursement=0;
	}

	YourCost = Math.round(YourCost * 100) / 100;
		
	// display Your Share of Costs
	document.getElementById("YourCost").innerHTML = "$" + YourCost.withCommas();
	
	// display Reimbursement
	document.getElementById("Reimbursement").innerHTML = "$" + Reimbursement.withCommas();

	
	if ((Plan-Cost)>0)
	{
		var ReaminaingCoverage = parseFloat(Plan - Reimbursement);
		//was cost
	}
	else
	{
		var ReaminaingCoverage =  0;
	}
	
	//if (ReaminaingCoverage<AmountOverIns)
	//{
	//	ReaminaingCoverage=0;
	//}
	//else
	//{
	//	ReaminaingCoverage=ReaminaingCoverage-AmountOverIns;
	
	//}
	
	// display Reaminaing Coverage
	document.getElementById("RemainingCoverage").innerHTML = "$" + ReaminaingCoverage.withCommas();
	
}
