
function populateProductSizes(oDDL,aSizeInfo){ 

    var newOption;
    var aCuffType; 
    var iSelectedIndex = 0; 

	
    if (document.forms['ProductDetails'].productSizesDDL.length > 1){       
        for (i = document.forms['ProductDetails'].productSizesDDL.length - 1; i>0;i--){
            document.forms['ProductDetails'].productSizesDDL.options[i] = null;         
        }   
    }


    for (j=0;j <= aSizeInfo.length-1;j++){ 
        aCuffType = aSizeInfo[j];   
        if (aCuffType[0]== oDDL.options[oDDL.selectedIndex].value){
            break
        }   
    }

    var aIDs =  aCuffType[1];
    var aSizeStrings= aCuffType[2];

    for (i = 0; i <= aIDs.length-1; i++){ 
    
        newOption = new Option(aSizeStrings[i],aIDs[i],false,false);          
        document.forms['ProductDetails'].productSizesDDL.options[document.forms['ProductDetails'].productSizesDDL.length] = newOption;          

        //if (document.forms['ProductDetails'].ctrlPreviousSize.value==aSizeStrings[i]){
        //    iSelectedIndex = i + 1;             
        //}        
    }  

    //document.forms['ProductDetails'].productSizesDDL.selectedIndex=iSelectedIndex;

}



function getSleeveLength(l_sizedescription){ 
    var l_unitmeasure = '"'; 
    var l_separatorposition = l_sizedescription.indexOf("/"); 
    var l_unitmeasureposition = l_sizedescription.lastIndexOf(l_unitmeasure); 
    var l_dblSleeveLength = l_sizedescription.substring(l_separatorposition+1,l_unitmeasureposition); 
    return l_dblSleeveLength;
}



function populateSleeveAdjustmentDDL(){ 
	var shortenDDL = document.getElementById('addShortenDDL');
	var l_dblSelectedItem = shortenDDL.options[shortenDDL.selectedIndex].text;
    var l_dblSleeveLength = getSleeveLength(document.forms['ProductDetails'].productSizesDDL.options[document.forms['ProductDetails'].productSizesDDL.selectedIndex].text);
    var b_valueSet = false;
    
    if (isNaN(l_dblSleeveLength)){
        l_dblSleeveLength=0;
    } 

    if (l_dblSleeveLength!=getSleeveLength(document.forms['ProductDetails'].ctrlPreviousSize.value)){ 
        var l_dblShorteningUnit=0.5; 
        var l_dblShorteningLength; 
        var l_dblLength; 
        var newOption; 
        l_dblSleeveLength = parseFloat(l_dblSleeveLength); 

        if (document.forms['ProductDetails'].addShortenDDL.length > 1){

            for (i = document.forms['ProductDetails'].addShortenDDL.length - 1; i>0;i--){       
                document.forms['ProductDetails'].addShortenDDL.options[i] = null; 
            }   
        }


        for (i = 1; i <= 8; i++){
            l_dblShorteningLength = i * l_dblShorteningUnit;          
            l_dblLength = l_dblSleeveLength - l_dblShorteningLength;          
            newOption = new Option(l_dblLength + '"',i,false,false);  
            
            if(newOption.text == l_dblSelectedItem) {
				b_valueSet = true;
				newOption.selected = true;
            }        
            document.forms['ProductDetails'].addShortenDDL.options[document.forms['ProductDetails'].addShortenDDL.length] = newOption;       
        }  

		if(!b_valueSet) {
			document.forms['ProductDetails'].addShortenDDL.selectedIndex = 0;
		}

        
    }  

    document.forms['ProductDetails'].ctrlPreviousSize.value=document.forms['ProductDetails'].productSizesDDL.options[document.forms['ProductDetails'].productSizesDDL.selectedIndex].text;

}


