

function getSelectedOptionId(){
   if(document.images) {
      var which = document.productForm;

      for(i=0;i<which.length;i++) {
         var tempobj=which.elements[i];
         if(tempobj.name.substring(0,7)=='options' || tempobj.name.substring(0,16)=='checkbox_options') {
            var fieldType = tempobj.type;
            if(fieldType=='select-one'){
               if(tempobj.selectedIndex > -1){
                  //var myval = tempobj[tempobj.selectedIndex].value;
                  var myval = tempobj.selectedIndex;
               	  return myval;
               }

            } else {
				//ignore
            }
         }
      }
   }
}


function getChildOptionElement(){
   if(document.images) {
      var which = document.productForm;

      for(i=0;i<which.length;i++) {
         var tempobj=which.elements[i];
         if(tempobj.name.substring(0,10)=='options[2]') {
            return tempobj;           
         }
      }
   }
}

function updatePrice(){
   var which = document.productForm;
   var myoptions = getSelectedOptions();
   var productId = which.productID.value;
   var extraField = '';
   
   if(which.extraField){
       var extraField = which.extraField.value;
   }

   x_getLiveProductTotal(myoptions, productId, extraField, '1', totalHandler);
}

function totalHandler(response){
   if(response){
   		document.getElementById('price').innerHTML = response;
   }
}

function getSelectedOptions(){
   var myoptions = '';

   if(document.images) {
      var which = document.productForm;

      for(i=0;i<which.length;i++) {
         var tempobj=which.elements[i];
         if(tempobj.name.substring(0,7)=='options' || tempobj.name.substring(0,16)=='checkbox_options') {
            var fieldType = tempobj.type;
            if(fieldType=='select-one'){
               if(tempobj.selectedIndex > -1){
                  var myval = tempobj[tempobj.selectedIndex].value;
               	  myoptions += ',' + myval;
               }

            } else if(fieldType=='radio' || fieldType=='checkbox'){
               if(tempobj.checked){
                  var myval = tempobj.value;
                  myoptions += ',' + myval;
               }

            } else {
		//ignore 
            }
         }
      }
   }

   return myoptions;
}

