 var percent = .3;
 var isCompatibleWithFlash = false; 
 var activeTab = 1;
 var cookieSaveArray = {'age':'a','IncomeReplacement':'b','MortgageProtection':'c','DebtProtection':'d','CollegeFunding':'e','SupplementSavings':'f','SupplementToRetirement':'g','EstatePlanning':'h','yearsCoverage':'i','futureincome':'j','prefertopay':'k','premiumguarantees':'l','goals':'m','investments':'n','inflation':'o','risk':'p','cashvalue':'q'};
 var cookieLoadArray = {'a':'age','b':'IncomeReplacement','c':'MortgageProtection','d':'DebtProtection','e':'CollegeFunding','f':'SupplementSavings','g':'SupplementToRetirement','h':'EstatePlanning','i':'yearsCoverage','j':'futureincome','k':'prefertopay','l':'premiumguarantees','m':'goals','n':'investments','o':'inflation','p':'risk','q':'cashvalue'};

 var scoreArray = new Array();
 
var ART = 0;
var TERM10_20 = 0;
var UL = 0;
var UL_LPR = 0;
var VARIABLE = 0; 
 
function getCookie(NameOfCookie)
{
  if (document.cookie.length > 0) 
  {
    begin = document.cookie.indexOf(NameOfCookie+"="); 
    if (begin != -1) 
    { 
     begin += NameOfCookie.length+1; 
     end = document.cookie.indexOf(";", begin);
     if (end == -1) end = document.cookie.length;
     return unescape(document.cookie.substring(begin, end)); 
    } 
  }
  return ""; 
}



function setCookie(NameOfCookie, value ) 
{ 
  var expiredays = 365;
  var ExpireDate = new Date ();
  ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
  document.cookie = NameOfCookie + "=" + escape(value) + 
  ((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}



function delCookie (NameOfCookie) 
{ 
  if (getCookie(NameOfCookie)) 
  {
   document.cookie = NameOfCookie + "=" +
   "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
 
 
function LoadCookies()
{
  //alert( document.cookie );
  var cookieStr = getCookie( 'PrincipalLifeInsTypeCalculator' ) ;
  var elementsValuePair = cookieStr.substring(cookieStr.indexOf("?")+1,cookieStr.length).split("&");
  var eleLength = elementsValuePair.length;
 
  
  for( i = 0; i<eleLength; i++ )
  {
        elementVP = elementsValuePair[i].split("=");
        elementObj = document.frmInput.elements[cookieLoadArray[elementVP[0]]];
        
        if( elementObj != undefined )
        {
          setCheckedValue( elementObj, elementVP[1] );
        }
        
        if( elementVP[0] == "r" )
         document.frmInput.elements["lifeinsurance"].value = elementVP[1];
        
        
  }
 
 
}
  

function SaveCookies()
{
  var eleLength = document.frmInput.elements.length;
   var radioSelectedArray = new Array();
  var nameValue = "";
  var cookieStr = "";
  
  for( i = 0; i< eleLength; i++ )
  {
    elementObj = document.frmInput.elements[i];
    
    if( cookieSaveArray[elementObj.name] != undefined )
    {
     	if( radioSelectedArray[elementObj.name] != 1 )
     	{
     	  fldValue = getCheckedValue(elementObj);
     	  if( fldValue !=0 )
     	  {
		  radioSelectedArray[elementObj.name] = 1;
		  cookieStr = cookieStr + cookieSaveArray[elementObj.name] + "=" +  fldValue + "&";
		  nameValue = nameValue + elementObj.name + " " + elementObj.type + " " + fldValue + "   ---   ";
	  }
	}
     }
  }
  
  
  cookieStr = cookieStr + "r=" + document.frmInput.elements["lifeinsurance"].value + "&";
  
  //alert( nameValue );
  //alert( cookieStr );
  
  setCookie( 'PrincipalLifeInsTypeCalculator', cookieStr );
  
  //alert( document.cookie );

  
}


 
 
 
  function activateTab( tabcontentid, listId )
  { 
    
    
    var imgObject = document.getElementById("stepImage" );
    var contentTabs = document.getElementById("contentTabs");
    var tabList = contentTabs.getElementsByTagName("div");
    
    var ulobj=document.getElementById("maintab");
    var ulist=ulobj.getElementsByTagName("li");
    
    if( listId < 1 )
    	window.location.href="/insurance/ind/fromheretosecurity/lifecalc/lifecalc.htm?load=1";
    
    if( listId < 1 )
     listId = 1;
     
    if( listId > 4 )
     listId = 4;
    
    
    if( ValidatePage( activeTab, listId ) )
    {
    
           if( activeTab == 1 || activeTab == 4 )
           {
            	if( getCheckedValue( document.frmInput["yearsCoverage"] ) < 3 )
            	{
            	  if( activeTab == 1 && listId == 2 )
            	   listId = 4;
            	  
            	  if( activeTab == 4 && listId == 3 )
            	   listId = 1;
            	  
            	}
           }
    
     
	    for (var x=0; x<ulist.length; x++)
	    {
	      tabList[x].style.display = "none";
	      if( x == ( listId - 1 ) )
	      {
		ulist[x].className="selected";
		imgObject.src = "images/step" + listId + ".gif";
		tabList[x].style.display = "inline";
		activeTab = listId;
	      }
	      else
		ulist[x].className="";
	    }
    
    }
    else
      alert( 'Each choice must have a selection.\nPlease enter a choice for each question.');
    
    
    DisplayResults();
    
   
	javascript:scroll(0,0);
  }
  
  
  function appendValue(strValue, aValue)
  {
    var re = /\$|,|%/gi;  
    strValue = strValue.replace(re,""); 
    return   strValue + aValue;
  }
  
  function prefixValue(strValue, pValue)
  {
    var re = /\$|,|%/gi;
    strValue = strValue.replace(re,""); 
    return   pValue + strValue ;    
  }

 

function ConvertToInteger(strValue)
{
  // replace $ and ,
  var re = /\$|,|%/gi;
  strValue = strValue.replace(re,"");
  var temp = parseInt(strValue, 10);
  if(isNaN(temp)) temp = 0;
  if(temp < 0)
    temp = -temp;
  return temp;
}

function FormatAsDollars(num) 
{
  num = num.toString().replace(/\$|\,/g,'');
  if(isNaN(num))
    return "$0";
  sign = (num == (num = Math.abs(num)));
  num = Math.floor(num*100+0.50000000001);
  cents = num%100;
  num = Math.floor(num/100).toString();
  if(cents<10)
  cents = "0" + cents;
  for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
  num = num.substring(0,num.length-(4*i+3))+','+
  num.substring(num.length-(4*i+3));
  return (((sign)?'':'-') + '$' + num);
}

function tabOnEnterSum (field, evt) 
{
      var keyCode = document.layers ? evt.which : evt.keyCode;
      if (keyCode != 13)
        return true;
      else 
    {
          getNextElement(field).focus();
          return false;
      }
}
function tabOnEnter (field ) 
{
  if (event.keyCode == 13) 
  {
    event.keyCode=9;
    return true;
  }
}


function ValidateRadioButtons( fldArray )
{
 var checkResult = 1;
 for( keyVar in fldArray )
 {
  if( getCheckedValue( document.frmInput[fldArray[keyVar]] ) ==0 )
   checkResult = 0;
 } 
 
 return ( ( checkResult == 0 )?false:true );
 
}

function ValidatePage( currPage, nextPage )
{
 if( nextPage > currPage )
 {
   
  if( currPage == 1 )
  {
    var fldArray= new Array("IncomeReplacement","MortgageProtection", "DebtProtection", "CollegeFunding", "SupplementSavings", "SupplementToRetirement", "EstatePlanning");
    if( getCheckedValue( document.frmInput["age"] ) != 0 && getCheckedValue( document.frmInput["yearsCoverage"] ) != 0 )
    {
      
      for( keyVar in fldArray )
      {
        if( getCheckedValue( document.frmInput[fldArray[keyVar]] ) !=0 )
          checkResult = getCheckedValue( document.frmInput[fldArray[keyVar]] );
      }
      
      if( checkResult == 0 )
        return false;
      
    }
    else
     return false;
  }
   
  if( currPage == 2 )
  {
   var fldArray= new Array("futureincome", "prefertopay", "premiumguarantees", "goals");
   return ValidateRadioButtons( fldArray );
  }
  
  if( currPage == 3 )
  {
   var fldArray= new Array("investments", "inflation", "risk", "cashvalue");
   return ValidateRadioButtons( fldArray );
  }
   
 }

 return true;
}

function setCheckedValue(radioObj, value)
{
	if(!radioObj)  return 0;

	var radioLength = radioObj.length;

	if(radioLength == undefined)
	{
		if( value == 1 )
		radioObj.checked = true;
	}

	for(var i = 0; i < radioLength; i++) 
	{
		if( value == radioObj[i].value )
		radioObj[i].checked = true;
		
	}
}

function getCheckedValue(radioObj)
{
	if(!radioObj)  return 0;

	var radioLength = radioObj.length;

	if(radioLength == undefined)
	{
		if(radioObj.checked)
			return ConvertToInteger( radioObj.value );
		else
			return 0;
	}

	for(var i = 0; i < radioLength; i++) 
	{
		if(radioObj[i].checked) 
		{
			return ConvertToInteger( radioObj[i].value );
		}
	}
	return 0;
}



function CalculateTotal(bMonthlyToAnnual)
{


var ART_CHECK = 0;
var TERM10_20_CHECK = 0;
var UL_CHECK = 0;
var UL_LPR_CHECK = 0;
var VARIABLE_CHECK = 0;

initScoreArray();
var fldArray = new Array("age","IncomeReplacement","MortgageProtection", "DebtProtection", "CollegeFunding", "SupplementSavings", "SupplementToRetirement", "EstatePlanning", "yearsCoverage",
 			  "futureincome", "prefertopay", "premiumguarantees", "goals",
 			  "investments", "inflation", "risk", "cashvalue");	
 			  
 			  
 var resultArray = new Array();
 var str = "";

ART = 0;
TERM10_20 = 0;
UL = 0;
UL_LPR = 0;
VARIABLE = 0; 

 
 for( keyVar in fldArray )
 {
 
   resultArray[fldArray[keyVar]] = getCheckedValue( document.frmInput[fldArray[keyVar]] );
 }
 
 
 
  /*for( keyVar in fldArray )
  {
    str = str + fldArray[keyVar] + " = " + resultArray[fldArray[keyVar]] + " ;; ";
  }
  alert( str );*/
  
  
  
  var divFactor = 0;  
  for( keyVar in fldArray )
  {
    
    if( resultArray[fldArray[keyVar]] != "0" )
    {
	    if( keyVar > 0 && keyVar < 8 )
	    {
		var weights = scoreArray[fldArray[keyVar]];
		divFactor++;
		ART_CHECK = ART_CHECK + weights[0];
		TERM10_20_CHECK = TERM10_20_CHECK + weights[1];
		UL_CHECK = UL_CHECK + weights[2];
		UL_LPR_CHECK = UL_LPR_CHECK + weights[3];
		VARIABLE_CHECK = VARIABLE_CHECK + weights[4];		
		
	    }
	    else
	    {
		var weights = scoreArray[fldArray[keyVar]][ resultArray[fldArray[keyVar]] - 1 ];
		ART = ART + weights[0];
		TERM10_20 = TERM10_20 + weights[1];
		UL = UL + weights[2];
		UL_LPR = UL_LPR + weights[3];
		VARIABLE = VARIABLE + weights[4];
	    }
    
    }
  }
  
  if( divFactor > 0 )
  {
  
	ART 	  = ART + ConvertToInteger( ( ART_CHECK/divFactor ) + "" );
	TERM10_20 = TERM10_20 + ConvertToInteger( ( TERM10_20_CHECK/divFactor ) + "" );
	UL 	  = UL + ConvertToInteger( ( UL_CHECK/divFactor ) + "" );
	UL_LPR 	  = UL_LPR + ConvertToInteger( ( UL_LPR_CHECK/divFactor ) + "" );
	VARIABLE  = VARIABLE + ConvertToInteger( ( VARIABLE_CHECK/divFactor ) + "" );
  }
  
  //alert( ART + " " + TERM10_20 + " " + UL + " " + UL_LPR + " " + VARIABLE );
  
  
}


function DisplayResults()
{
 
 if( activeTab == 4 )
 {
 	var yearCoverageVal = getCheckedValue( document.frmInput["yearsCoverage"] );
 	
 	var ARTContent = "<hr size=\"1\"/><p><a name=\"annual\" id=\"annual\"></a><strong>Annual Renewable Term:</strong> A term policy with low initial cost.  Premiums increase, usually on each policy anniversary.  May be the ideal solution for short-term needs, such as a three-year debt obligation.</p>"; 
 	var TERM10_20Content = "<hr size=\"1\"/><p><a name=\"ten\" id=\"ten\"></a><strong>Ten or Thirty  Year Term:</strong> With these term policies, premiums are guaranteed to remain level for all or part of the life of the policy. They generally renew at rates that increase annually after the initial term of the policy expires. They are ideal for needs of four to 10 years in duration. Longer needs may be more cost-effectively addressed with cash value insurance, though the size of the premiums may ultimately affect your decision.</p>"; 
 	var ULContent = "<hr size=\"1\"/><p><a name=\"ul\" id=\"ul\"></a><strong>Universal Life:</strong> (without secondary guarantees)  With universal life, you get low cost death benefit protection and affordable death benefit guarantees.  Universal life insurance is a cash value policy which offers flexible premiums, within minimum and maximum guidelines.  The death benefit can also be adjusted, within limits.  The portion of the premium in excess of that required to pay the policy costs, is accumulated tax-deferred at interest rates which are reset regularly.  A minimum interest-crediting rate is guaranteed in the policy.  The cash value then pays the mortality and rider costs (if any) and may be accessed through partial surrenders, and/or loans, to use for emergencies, college funding, opportunities, or to supplement retirement income.  Universal life insurance allows you to address retirement income preservation and family protection.</p>";
 	var UL_LPRContent = "<hr size=\"1\"/><p><a name=\"uls\" id=\"uls\"></a><strong>Universal Life:</strong> (with secondary guarantees) With universal life, you get low cost death benefit protection and affordable death benefit guarantees.  Universal life insurance is a cash value policy, which offers flexible premiums, within minimum and maximum guidelines.  The death benefit can also be adjusted, within limits.  The portion of the premium in excess of that required to pay the policy costs, is accumulated tax-deferred at interest rates which are reset regularly.  A minimum interest-crediting rate is guaranteed in the policy.  The cash value then pays the mortality and rider costs (if any) and may be accessed through partial surrenders, and/or loans, to use for emergencies, college funding, opportunities, or to supplement retirement income.  Secondary guarantees offer the insured the ability to guarantee the death benefit, up to lifetime, by paying a premium that matches the Lapse Protection Rider requirement for that age.  It should be noted that varying the premium or the death benefit, or surrendering or borrowing from a policy with a secondary guarantee, might void the guarantee.  Universal life insurance allows you to address retirement income preservation and family protection.</p>";
 	var VARIABLEContent = "<hr size=\"1\"/><p><a name=\"vul\" id=\"vul\"></a><strong>Variable Universal Life:</strong> First and foremost, when purchasing a variable universal life policy, not only do you receive death benefit protection, you also put your premiums to work for you.  Variable Universal life insurance is a cash value policy which offers flexible premiums, within minimum and maximum guidelines.  The death benefit can also be adjusted, within limits.  The portion of the premium in excess of that required to pay the policy costs, is allocated to separate accounts, which are much like mutual funds.  The mortality and rider costs (if any) are deducted from the separate accounts monthly.  Money can be accessed from the separate accounts through partial surrenders, and/or loans, to use for emergencies, college funding, opportunities, or to supplement retirement income.  Secondary guarantees may be available for a minimum premium, which offers the insured a guarantee the death benefit will not expire even if the separate accounts run out of money.  These guarantees may be for a number of years, or to a certain age, generally not beyond age 85.</p>";
 	
 	
 	var sideContent1  = "<p class=\"textsmall\">If you expect your income to outpace inflation, you should consider a policy where the death benefit and cash value grow to match your changing needs. You could also purchase relatively inexpensive term insurance to supplement your permanent policies, which could then be converted to permanent insurance as your needs increase - without evidence of insurability.</p>";
 	var sideContent2  = "<p class=\"textsmall\">While universal life or variable universal life may be appropriate solutions for you, affordability may be a factor in your ultimate decision. Cash value policies generally have higher initial premiums than term, which may tempt you to rule them out. Instead, consider buying as much cash value insurance as you can comfortably afford, then covering the balance of your need with term. Using this strategy will enable you to begin building cash value.</p>";
 	var sideContent3  = "<p class=\"textsmall\">As a general rule, it&rsquo;s better to use cash value life insurance to cover long-term needs such as final expenses, survivor income and estate liquidity. Term insurance works well for covering short-term needs such as debt and education expenses. A Principal Life financial representative is trained to help you examine these issues as a part of the comprehensive planning process.</p>";
 	
 	
 	var anchorContent = "";
 	var mainContent = "";
 	var sideContent = "";

	var title1Atag = "";
	var title2Atag = "";
	var title3Atag = "";
	
	var title1 = "";
	var title2 = "";
	var title3 = "";
	
	var blnDisplayThirdPrd = false;


 	if( yearCoverageVal < 3 )
 	{
	   anchorContent="<p><strong><a href=\"#annual\">1st: Annual Renewable Term</a></strong></p>";
	   mainContent  = ARTContent;
	   sideContent  = sideContent1;
	   
	   if( yearCoverageVal == "2" )
	   {
	    anchorContent = anchorContent + "<p><strong><a href=\"#ten\">2nd: Ten or Thirty Year Term</a></strong></p>";
	    mainContent = mainContent + TERM10_20Content;
	   }
 	
 	}
 	else
 	{
 		var Products = new Array();
 		
 		
		Products[0]=ART;
		Products[1]=TERM10_20;
		Products[2]=UL;
		Products[3]=UL_LPR;
		Products[4]=VARIABLE;
		Quicksort(Products,0,4); 
		//alert( Products[4]  + " " +  Products[3] );
		
		switch ( Products[4])
		{
			case ART: 
			   title1 = "Annual Renewable Term"; title1Atag = "annual"; mainContent = ARTContent; break;

			case TERM10_20:
			   title1 = "2nd: Ten or Thirty Year Term"; title1Atag = "ten"; mainContent = TERM10_20Content; break;

			case UL:
			   title1 = "Universal Life  (without secondary guarantees)"; title1Atag = "ul"; mainContent = ULContent; break;

			case UL_LPR:
			   title1 = "Universal Life"; title1Atag = "uls"; mainContent = UL_LPRContent; break;					

			case VARIABLE:
			   title1 = "Variable Universal Life"; title1Atag = "vul"; mainContent = VARIABLEContent; break;				
		}		
			
			
		switch ( Products[3])
		{
			case ART: 
			   title2 = "Annual Renewable Term"; title2Atag = "annual"; mainContent = mainContent + ARTContent; break;

			case TERM10_20:
			   title2 = "2nd: Ten or Thirty Year Term"; title2Atag = "ten"; mainContent = mainContent + TERM10_20Content; break;

			case UL:
			   title2 = "Universal Life  (without secondary guarantees)"; title2Atag = "ul"; mainContent = mainContent + ULContent; break;

			case UL_LPR:
			   title2 = "Universal Life"; title2Atag = "uls"; mainContent = mainContent + UL_LPRContent; break;					

			case VARIABLE:
			   title2 = "Variable Universal Life"; title2Atag = "vul"; mainContent = mainContent + VARIABLEContent; break;				
		}	
		
		
		/* Never Display a Third Product*/
		/*if( Products[2] == UL ) 
		{
			if( !( Products[4] == UL || Products[3] == UL ) )
			{
			  blnDisplayThirdPrd=true; title3  = "Universal Life (without secondary guarantees)"; title3Atag = "ul"; mainContent = mainContent + ULContent; 
			 }
		}
		else 		
		{
			if( Products[3] == Products[2] )
			{
			 switch ( Products[2])
			 { 		
				case ART: 
				   if( !( Products[4] == ART || Products[3] == ART ) ) { blnDisplayThirdPrd=true; title3 = "Annual Renewable Term"; title3Atag = "annual"; mainContent = mainContent + ARTContent; } break;

				case TERM10_20:
				   if( !( Products[4] == TERM10_20 || Products[3] == TERM10_20 ) ) { blnDisplayThirdPrd=true; title3  = "2nd: Ten or Thirty Year Term"; title3Atag = "ten"; mainContent = mainContent + TERM10_20Content; } break;

				case UL:
				   if( !( Products[4] == UL || Products[3] == UL ) ) { blnDisplayThirdPrd=true; title3  = "Universal Life"; title3Atag = "ul"; mainContent = mainContent + ULContent; } break;

				case UL_LPR:
				   if( !( Products[4] == UL_LPR || Products[3] == UL_LPR ) ) { blnDisplayThirdPrd=true; title3  = "Universal Life (without secondary guarantees)"; title3Atag = "uls"; mainContent = mainContent + UL_LPRContent; } break;					

				case VARIABLE:
				   if( !( Products[4] == VARIABLE || Products[3] == VARIABLE ) ) { blnDisplayThirdPrd=true; title3  = "Variable Universal Life"; title3Atag = "vul"; mainContent = mainContent + VARIABLEContent; } break;				
			  }
			}
		}*/
		
		
		
		
		if( Products[4] == UL || Products[4] == UL_LPR || Products[4] == VARIABLE || 
		    Products[3] == UL || Products[3] == UL_LPR || Products[3] == VARIABLE || 
		    ( blnDisplayThirdPrd && ( Products[2] == UL || Products[2] == UL_LPR || Products[2] == VARIABLE ) )   )
		 {
		   sideContent = sideContent1 + sideContent2 + sideContent3;
		 }
		
 	 	anchorContent= "<p><strong><a href=\"#" + title1Atag + "\">1st: " + title1 + "</a></strong></p>";
 	 	anchorContent= anchorContent + "<p><strong><a href=\"#" + title2Atag + "\">2nd: " + title2 + "</a></strong></p>";
 	 	
 	 	if( blnDisplayThirdPrd )
 	 		anchorContent= anchorContent + "<p><strong><a href=\"#" + title3Atag + "\">3rd: " + title3 + "</a></strong></p>";
 	}
 	
 	
 	
 	document.getElementById("anchorLinksDiv").innerHTML = anchorContent;
 	
 	document.getElementById("mainContentDiv").innerHTML = mainContent;
 	
 	document.getElementById("sideNoteDiv").innerHTML = sideContent;
 }
  
  
}
 
 
 function initScoreArray()
 {
  scoreArray["IncomeReplacement"] = [10,10,8,8,6];
  scoreArray["MortgageProtection"] = [9,10,8,10,6];
  scoreArray["DebtProtection"] = [10,10,6,6,4];
  scoreArray["CollegeFunding"] = [10,10,6,8,6];
  scoreArray["SupplementSavings"] = [0,0,7,2,10];
  scoreArray["SupplementToRetirement"] = [0,0,7,4,10];
  scoreArray["EstatePlanning"] = [0,0,8,10,6];
 
  scoreArray["age"] = [[5,10,7,5,10],[10,10,10,10,10],[7,7,8,10,7],[4,3,7,10,6]];
  scoreArray["yearsCoverage"] = [[10,5,0,0,0],[7,10,0,0,0],[4,7,10,10,8],[0,3,9,9,10]];
 
 
  scoreArray["futureincome"] = [[0,0,0,0,0],[0,0,0,0,0],[0,0,0,0,0]];
  scoreArray["prefertopay"] = [[0,2,8,8,8],[0,4,8,10,7],[10,9,3,2,1]]; //scoreArray["prefertopay"] = [[0,2,8,6,10],[0,4,8,10,7],[10,9,3,2,1]];
  scoreArray["premiumguarantees"] = [[6,6,5,10,6],[8,7,10,6,7]];
  scoreArray["goals"] = [[10,10,7,10,6],[0,0,8,6,10]];
 
 
  scoreArray["investments"] = [[0,0,7,10,2 ],[0,0,7,5,10],[ 0,0,5,10,0],[0,0,10,5,7]]; //scoreArray["investments"] = [[0,0,7,10,2 ],[0,0,7,5,10],[ 0,0,5,10,0],[0,0,10,3,7]];
  scoreArray["inflation"] = [[0,0,7,10,5],[0,0,10,5,9 ],[0,0,7,3,10 ]];
  scoreArray["risk"] = [[0,0,5,3,10],[0,0,8,5,9],[0,0,7,10,3]]; //scoreArray["risk"] = [[0,0,6,1,10],[0,0,9,5,9],[0,0,7,10,1]];
  scoreArray["cashvalue"] = [[0,0,0,0,7],[ 0,0,7,7,0],[ 0,0,3,3,0]]; //scoreArray["cashvalue"] = [[0,0,0,0,10],[ 0,0,10,10,2],[ 0,0,0,0,0]];
  
 }
 
 
 function Quicksort(vec, loBound, hiBound) 
 { 
 	var pivot, loSwap, hiSwap, temp; 
 	// Two items to sort 
 	if (hiBound - loBound == 1) 
 	{ 
 		if (vec[loBound] > vec[hiBound]) 
 		{ 
 			temp = vec[loBound]; 
 			vec[loBound] = vec[hiBound]; 
 			vec[hiBound] = temp; 
 		} 
 		return; 
 	} 
 
 	// Three or more items to sort 
 	pivot = vec[parseInt((loBound + hiBound) / 2)]; 
 	vec[parseInt((loBound + hiBound) / 2)] = vec[loBound]; 
 	vec[loBound] = pivot; 
 	loSwap = loBound + 1; 
 	hiSwap = hiBound; 
 	do 
 	{ 
 		// Find the right loSwap 
 		while (loSwap <= hiSwap && vec[loSwap] <= pivot) 
 		loSwap++; 
 		// Find the right hiSwap 
 		while (vec[hiSwap] > pivot) 
 		hiSwap--; 
 		// Swap values if loSwap is less than hiSwap 
 		if (loSwap < hiSwap) 
 		{ 
 			temp = vec[loSwap]; 
 			vec[loSwap] = vec[hiSwap]; 
 			vec[hiSwap] = temp; 
 		} 
 	} 
 	while (loSwap < hiSwap); 
 		vec[loBound] = vec[hiSwap]; 
 		vec[hiSwap] = pivot; 
 		// Recursively call function... the beauty of quicksort 
 		// 2 or more items in first section 
 		if (loBound < hiSwap - 1) 
 			Quicksort(vec, loBound, hiSwap - 1); 
 		// 2 or more items in second section 
 		if (hiSwap + 1 < hiBound) 
 			Quicksort(vec, hiSwap + 1, hiBound); 
}
 
