
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Menu Pages Status    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var manu1, manu2, manu3, manu4, manu5, sLoc
	
function SearchMenu(url,page)
{
   return url.indexOf("/"+page+".".toLowerCase())==-1?"":1;
}
	sLoc=(document.URL).toLowerCase();
	
	manu1 = SearchMenu(sLoc,"management")?1:0;
	manu2 = SearchMenu(sLoc,"services")?1:0;
	manu3 = SearchMenu(sLoc,"contact")?1:0;
	manu4 = SearchMenu(sLoc,"information")?1:0;
	manu5 = SearchMenu(sLoc,"privacy")?1:0;
	
function SetMenu()
{
   if(manu1) MM_swapImage('menu1','','images/menu1_over.gif');
   if(manu2) MM_swapImage('menu2','','images/menu2_over.gif');
   if(manu3) MM_swapImage('menu3','','images/menu3_over.gif');
   if(manu4) MM_swapImage('menu4','','images/menu4_over.gif');
   if(manu5) MM_swapImage('menu5','','images/menu5_over.gif');
}	
	
	
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      Swap Image Functions    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
 sWin = window.open(theURL,winName,features);
 sWin.focus();
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~      getRefToDiv    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function getRefToDiv(divID,oDoc) {
    if( !oDoc ) { oDoc = document; }
    if( document.layers ) {
        if( oDoc.layers[divID] ) { return oDoc.layers[divID]; } else {
            //repeatedly run through all child layers
            for( var x = 0, y; !y && x < oDoc.layers.length; x++ ) {
                //on success, return that layer, else return nothing
                y = getRefToDiv(divID,oDoc.layers[x].document); }
            return y; } }
    if( document.getElementById ) {
        return document.getElementById(divID); }
    if( document.all ) {
        return document.all[divID]; }
    return false;
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~      Show Menu    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

var oID= new Array(3);

for(i=0; i<3; i++)
{
   oID[i] = "";
}
var ActiveBio, nc=0;
if(document.layers&&!document.getElementById) nc=1;

function showDiv(divID) {
	
	var myReference = getRefToDiv(divID), wch=divID.slice(3)
	ActiveBio = wch;	
	if(myReference.style) {myReference=myReference.style;}
	for(i=1;i<=oID.length;i++)
	{
		if(i==ActiveBio)
		{
			eval("MM_swapImage('bio_" + i + "','','images/bio_on.gif','biot_" + i + "','','images/biotext_on_" + i + ".gif')");
		}
		else
		{
			eval("MM_swapImage('bio_" + i + "','','images/bio_off.gif','biot_" + i + "','','images/biotext_off_" + i + ".gif')");
		}
	}
		
	oID[wch]=myReference;
		if (nc==1) myReference.visibility = "visible";
		else myReference.display = "block";
		
		for(i=0; i<oID.length; i++){
			if(i!=wch)
			{
				if (nc==1) oID[i].visibility = "hidden";
				else oID[i].display = "none";
			}
		}
}


function showComp(divID) {
	
	var myReference = getRefToDiv(divID)
	if(myReference.style) {myReference=myReference.style;}
			
		if (nc==1) myReference.visibility = "visible";
		else myReference.display = "block";
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~      Reset Form    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

function ResetForm()
{
	var oObj;
	
	if(document.layers&&!document.getElementByID)
		oObj = eval("document.layers['calculator'].document.forms")
	else
		oObj = eval("document.forms")
		
	oObj.compute.premium.value="";
	oObj.compute.survey.value="";
	oObj.compute.total.value="";
	return true;
}



//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~     Format Curency    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function FormatCurency(oVal)
{
	var oInt='', oDec='', oStr='', oInd;
	oVal = oVal.toString();
	
	//	Set Integer & Decimal part
	
	oInd = oVal.indexOf('.')
	
	if(oInd>-1) 
	{
		oDec = oVal.substring(oInd);
			if(oDec.length==2)
				oDec = oDec + '0';
			else if(oDec.length>3)
			{
				oDec = oDec.substring(1);
				oDec = '.' + Math.round(parseFloat(oDec.slice(0,2) + '.' + oDec.slice(2))).toString();
			}
		oInt = oVal.substr(0, oInd);
	}
	else
	{
		oDec = '.00';
		oInt = oVal;
	}
	
	//	Set	coma between figures
	while(oInt.length>3)
	{
	oStr = ',' + oInt.slice(oInt.length-3,oInt.length) + oStr;
	oInt = oInt.slice(0,oInt.length-3);
	}
	
	return '$' + oInt + oStr + oDec;
}


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~      Calculator    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


function Calculate()
{
	var oObj, oVal, ooVal;
	
	if(document.layers&&!document.getElementByID)
		oObj = eval("document.layers['calculator'].document.forms")
	else
		oObj = eval("document.forms")
		
	oVal = oObj.compute.amount.value;
	
	//	Check number format
	if(parseFloat(oVal)==oVal.toString())
	{
		oVal = parseFloat(oObj.compute.amount.value);
		
			if(oVal>100001 && oVal<1000001)
			{
				oVal = (oVal-100000)*0.00534+843;
				oVal = Math.round(oVal);
				oObj.compute.premium.value = FormatCurency(oVal);
				ooVal = oVal*0.15;
				oObj.compute.survey.value = FormatCurency(ooVal);
				oVal = oVal + ooVal; 
				oObj.compute.total.value= FormatCurency(oVal);
			}
			else if(oVal>1000000 && oVal<5000001)
			{
				oVal = (oVal-1000000)*0.00439+5649;
				oVal = Math.round(oVal);
				oObj.compute.premium.value = FormatCurency(oVal);
				ooVal = oVal*0.15;
				oObj.compute.survey.value = FormatCurency(ooVal);
				oVal = oVal + ooVal; 
				oObj.compute.total.value= FormatCurency(oVal);
			}
			else if(oVal>5000000 && oVal<15000001)
			{
				oVal = (oVal-5000000)*0.00362+23209;
				oVal = Math.round(oVal);
				oObj.compute.premium.value = FormatCurency(oVal);
				ooVal = oVal*0.15;
				oObj.compute.survey.value = FormatCurency(ooVal);
				oVal = oVal + ooVal; 
				oObj.compute.total.value= FormatCurency(oVal);
			}
			else if(oVal>15000000 && oVal<25000001)
			{
				oVal = (oVal-15000000)*0.00257+59409;
				oVal = Math.round(oVal);
				oObj.compute.premium.value = FormatCurency(oVal);
				ooVal = oVal*0.15;
				oObj.compute.survey.value = FormatCurency(ooVal);
				oVal = oVal + ooVal; 
				oObj.compute.total.value= FormatCurency(oVal);
			}
			else if(oVal>25000000 && oVal<10000000000)
			{
				oVal = (oVal-25000000)*0.00154+85109;
				oVal = Math.round(oVal);
				oObj.compute.premium.value = FormatCurency(oVal);
				ooVal = oVal*0.15;
				oObj.compute.survey.value = FormatCurency(ooVal);
				oVal = oVal + ooVal; 
				oObj.compute.total.value= FormatCurency(oVal);
			}
			else
			{
				alert("You entered a value below $100,000.00 or above $10,000,000,000.00 .");
				ResetForm();
				oObj.compute.amount.value = "";
				oObj.compute.amount.focus();
			}
	}
	else
	{
		alert("Please enter a valid amount!");
		oObj.compute.amount.value = "";
		oObj.compute.amount.focus();
	}
	
	return false;
}


