
<!-- hide

myInitialise = 0

function initialise(){

		try{
        // this fails if the cells arnt on the page
        objSetParent('parent',ArrParent);//set the puldown called parent with the values of the array

        //defaultName = eval(ArrParent[0]) ;//cant get this to work
        defaultName = "Adaptor"//adjust this if the first one



        objSetChild('criteria','','')
        }
        catch (z){
        //do nothing
        }
}

function objSetTB(lastObj, textBox){
	//this sets the Text box to a select pulldown value
    //created for packing form 050504

     myObj = eval("document.orderForm." + textBox)
     myChoice = eval("orderForm."+ lastObj +".selectedIndex")
     temp =  eval("orderForm."+ lastObj +".options[myChoice].value")
     myObj.value = temp

     //now I write the text from the select into a hidden field so I can pass this to the db
     //or I find I end up with the amount (from the select value) in the DB which is bad
     myObj = eval("document.orderForm." + textBox +"Txt")
     temp =  eval("orderForm."+ lastObj +".options[myChoice].text")
     myObj.value = temp
}

function calcDeliveryCost(){
	//this calculates the delivery costs
    //created for packing form 050504
    //updated 260105 for Mozilla (needed document.orderForm - not just orderForm!)

     myObj = document.orderForm.deliveryCostTxt
     strDest =""
     strServ =""
     strType =""

     document.orderForm.service.disabled=false
	 document.orderForm.mytype.disabled=false


     myChoice = eval("document.orderForm.destination.selectedIndex")
     strDest =  eval("document.orderForm.destination.options[myChoice].text")

     //do a test for Ex-works or own carrier as the other pulldowns arnt required
     if((strDest =="Ex-works") ||(strDest =="Own carrier")){
      strServ = "n-a"
      strType = "n-a";
      //now turn off the othr two pulldowns
      document.orderForm.service.disabled=true
//document.orderForm.mytype.disabled=true
     }
     else{
     	myChoice = eval("document.orderForm.service.selectedIndex")
	     //temp = temp + " | " +  eval("document.orderForm.service.options[myChoice].text")
	     strServ =  eval("document.orderForm.service.options[myChoice].text")

	     myChoice = eval("document.orderForm.mytype.selectedIndex")
	     //temp = temp + " | " + eval("document.orderForm.mytype.options[myChoice].text")
	     strType = eval("document.orderForm.mytype.options[myChoice].text")
     }
     //I do this char mapping to ensure that only valid chars are used to ref array names
	 //of course the array names have to be in this format as well. ie illegal chars replaced with underscore

     myObj.value = "Destination: " +strDest +".\n Service: "+ strServ +".\n Product:  "+ strType

     temp = strDest + strServ + strType

	 temp = temp.replace(/\/|-/,"_")
     temp = temp.replace(/\/|-|&|\s/g,"_");//replace slash or - or & or one space with underscore. g makes it happen globaly accross the string
	 //temp = temp.replace(/\s/,"_")
     //temp = temp.replace(/\s/,"_");//replaces one space with underscore
     temp = temp.replace(/>/,"GT");
     temp = temp.replace(/</,"LT");
     temp = temp.replace(/:/,"_");

     //myObj.value = temp

     //now I need to set the delivery cost box to the price stored in the deliveryArry
     //newObj = eval("document.orderForm.deliveryCost")


     result = arrDelivery[temp]
     //if(result == undefined)result = "POA";//that was a nice supprise for undefined!
     if(typeof arrDelivery[temp] == "undefined")result = "POA"


     document.orderForm.deliveryCost.value = result
     document.orderForm.deliveryCostList.value = result; //this is a hidden filed for comparing with the editable box

     //now quickly update the packing cost
     calcPackingCost()
}

function calcPackingCost(){
	//this calculates the packing cost
    //created for packing form 050504

     //myObj = eval("document.orderForm." + textBox)
     myObj = document.orderForm.packingCostTxt
     strPack =""
     strType = ""

     myChoice = eval("document.orderForm.packing.selectedIndex")
     strPack =  eval("document.orderForm.packing.options[myChoice].text")

     myChoice = eval("document.orderForm.mytype.selectedIndex")
     strType = eval("document.orderForm.mytype.options[myChoice].text")

     //myObj.value = strPack +" "+ strType
     myObj.value = strPack

     temp =  strPack + strType

     //I do this char mapping to ensure that only valid chars are used to ref array names
	   //of course the array names have to be in this format as well. ie illegal chars replaced with underscore

	 temp = temp.replace(/\/|-/,"_")
     temp = temp.replace(/\/|-|&|\s/g,"_");//replace slash or - or & or one space with underscore. g makes it happen globaly accross the string
	 //temp = temp.replace(/\s/,"_")
     //temp = temp.replace(/\s/,"_");//replaces one space with underscore
     temp = temp.replace(/>/,"GT");
     temp = temp.replace(/</,"LT");
     temp = temp.replace(/:/,"_");


     //myObj.value = temp

     //now I need to set the packing cost box to the price stored in the packingArry
     newObj = eval("document.orderForm.packingCost")

     result = arrPacking[temp]
     //if(result == undefined)result = "POA";//that was a nice supprise for undefined! NO It doesnt work in ie5!
     if(typeof arrPacking[temp] == "undefined")result = "POA"
     document.orderForm.packingCost.value = result
     document.orderForm.packingCostList.value = result;//This is a hidden filed for comparing with actual
     //newObj.value = arrPacking[temp]
}


function objSetParent(currObject, currArray){
	//this sets the category pulldown in parts chooser
   myObj = eval("document.myForm." + currObject)
   for (i=0; i<currArray.length; i++){
        myObj.options[i] = new Option(currArray[i], currArray[i]);
        myObj.options[i].id = currArray[i]
        // myObj.options[i].text = currArray[i]
        //myObj.options[i].value = currArray[i]
   }
}

function objSetChild(currObject, currArray, lastObj){
   //this sets the sub category pulldown in parts chooser
   if(myInitialise ==0){

        currArrayName = eval(defaultName)
   		currArrayMnem = eval(defaultName+"Mnem")

   		myInitialise =1
   }
   else{
   		//I do this char mapping to ensure that only valid chars are used to ref array names
	   //of course the array names have to be in this format as well. ie illegal chars replaced with underscore
	   temp =  lastObj.options[lastObj.selectedIndex].id
	   temp = temp.replace(/\/|-/,"_")
       temp = temp.replace(/\/|-|&|\s/g,"_");//replace slash or - or & or one space with underscore. g makes it happen globaly accross the string
	   //temp = temp.replace(/\s/,"_")
       //temp = temp.replace(/\s/,"_");//replaces one space with underscore
	   currArrayName = eval(temp)
	   currArrayMnem = eval(temp + "Mnem")
   }
   myObj = eval("document.myForm." + currObject)
   myObj.options.length = 0;//reset the mumber of options

   //now stick each array object into an option line in the select object
   for (i=0; i<currArrayName.length; i++){
       myObj.options[i] = new Option(currArrayName[i], currArrayMnem[i]);
       // myObj.options[i].text = currArrayName[i]
       //myObj.options[i].value = currArrayPrice[i]
   }
}


function objSetQual(currObject, currArray, row, lastObj){

   currArrayName =eval(lastObj.options[lastObj.selectedIndex].id)
   currArrayName = eval(currArray)[currArrayName]

   //(document.form.elements['mySelect[]'].selectedIndex > 0)


   myObj = eval("document.partsForm.elements[currObject]")
   //myObj = eval("document.partsForm.elements['qual[]']")
   // myObj = eval("document.partsForm.qual[]")
   //myObj = eval("document.partsForm." + currObject)
   //alert(myObj)

   //there might be a better trap but this identifies if its and array or not
   try{
       myObj[row].options.length = 0;
   }
   catch (z){myObj.options.length = 0;
   }

   for (i=0; i<currArrayName.length; i++){
          lookup = eval(currArrayName[i])
          //myObj[row].options[i] = new Option(lookup, currArrayName[i]);
          try{
          myObj[row].options[i] = new Option(lookup, currArrayName[i]);
          }
          catch (z) {myObj.options[i] = new Option(lookup, currArrayName[i]);
          }
   }
}

function objSetAddress(currArray,prefix){

  	//this sets the text of the following text fields to the array

   	   myObj = eval("document.orderForm")
	   myAddressID = eval("document.orderForm." + prefix + "AddressId");
	   myAddressRID = eval("document.orderForm." + prefix + "RemoteAddressId");

       //try this to start with

       myAddressID.value = currArray[0]
       myAddressRID.value = currArray[1]

       //wrap all the address into one string with new lines but ignor blanks

       var myText = ""

       for (i=2; i<currArray.length; i++){
       		//if(currArray[i]!="")myText = myText + currArray[i] + "\r"
            if(currArray[i]!="")myText = myText + currArray[i] + " <BR>";//added explicit BR tag as \n not work with mozilla
       }

       //old way for ie
       //my_span = eval(prefix + "_address_text");
       //my_span.innerText = myText


       //new stuff for mozilla ADDED 260105 bug 166
       mySpan = prefix + "_address_text";
       var span_el = document.getElementById(mySpan);
       span_el.innerHTML = myText

}


-->

