// JavaScript Document
//options array:
var arrYrs = new Array();
arrYrs[1] = new Array("type1","please choose", "option1", "option2");
arrYrs[2] = new Array("type2","please choose");
arrYrs[3] = new Array("type3","please choose");

function initYrs() {
  //alert(document.orderform.HFwdTar.value);
  // Inititalise the new 'Years' selection
    document.orderform.ddlYrs.length = arrYrs.length;
  // Now select all years amd populate the years drop down
    var strOut = "No Years : " + arrYrs.length + "\n";
    for (var i=1; i < arrYrs.length; i++){
      document.orderform.ddlYrs.options[i].text = arrYrs[i][0];
      document.orderform.ddlYrs.options[i].value = arrYrs[i][0];

    }
    document.orderform.ddlYrs.options[0].text = "";
    document.orderform.ddlYrs.options[0].value = "";
    document.orderform.ddlYrs.options[0].selected = true;
  }
function selectMdls(){

// Obtain the first dimension position of the currently selected year

  var i = window.document.forms[0].ddlYrs.selectedIndex;

  if (i > 0){
  // Inititalise the new 'models' selection
    document.orderform.ddlMdls.options.length = arrYrs[i].length - 1;
  // Now select the models associated with the selected year
    for (var j=1; j < arrYrs[i].length; j++){
      document.orderform.ddlMdls.options[j-1].text = arrYrs[i][j];
      document.orderform.ddlMdls.options[j-1].value = arrYrs[i][j];

    }
  }
  else{
  // User has reselected the blank 'years' option
    document.orderform.ddlMdls.options.length = 1;
    document.orderform.ddlMdls.options[0].text = "<< Select a Year";
    document.orderform.ddlMdls.options[0].value = "";
  }
  document.orderform.ddlMdls.options[0].selected = true;
}

//format the currency field
function FormatCurrency(nVarIn){

	var TempNum1
	var TempStr1

	TempNum1=(Number(nVarIn) * Number(document.orderform.pounds[document.orderform.pounds.selectedIndex].value))
	TempStr1=(String(TempNum1))
	TempNum1=(TempNum1/100)
	TempStr2=(String(TempNum1))

	//--- Pad a zero or 2 on the end of the string?
	//
	if (TempStr1.length == TempStr2.length)
		{
		TempStr2=TempStr2 + "0"
		}

	else if (TempStr1.length == (TempStr2.length + 2))
		{
		TempStr2=TempStr2 + ".00"
		}

	//TempStr2=(TempStr2 * document.orderform.pounds[document.orderform.pounds.selectedIndex].value)

	//---- stringvar.length
	//     stringvar.substr(start, length)
	//
	TempStr2=TempStr2.substr((TempStr2.length-20),20)

	//--- For easy view during debugging
	TempNum1=TempStr2.length

	return TempStr2
}