﻿/*
    File: Expandble DDL
        
    Author: Gareth Clare (gareth@dataphiles.co.uk); Dataphiles (http://www.dataphiles.co.uk)
    Date: 16/10/2008
    
    Details:  Allows you to expand a single dropdownlist when viewing items

*/
/*
    File: Expandble DDL
        
    Author: Gareth Clare (gareth@dataphiles.co.uk); Dataphiles (http://www.dataphiles.co.uk)
    Date: 16/10/2008
    
    Details:  Allows you to expand a single dropdownlist when viewing items

*/
    function maxWidth(elementname)
        {
        isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
        if (isIE6 == false)
            {
            var maxlength = 0;
            var mySelect = document.getElementById(elementname);
            for (var i=0; i<mySelect.options.length;i++)
            {
                if (mySelect[i].text.length > maxlength)
                {
                    maxlength = mySelect[i].text.length;
                }
            }
            mySelect.style.width = maxlength * 7;
            }
        }
        
    function restoreWidth(elementname, width, focusid)
        {
        var mySelect = document.getElementById(elementname);
        mySelect.style.width=width;
        
        setfocus(focusid)
        }
        
    function setfocus(a_field_id) 
        {
            var mySelect = document.getElementById(a_field_id);
            mySelect.focus()
        }


//    function maxWidth(elementname)
//        {
//        if (isIE6() == false)
//            {
//            var maxlength = 0;
//            var mySelect = document.getElementById(elementname);
//            for (var i=0; i<mySelect.options.length;i++)
//            {
//                if (mySelect[i].text.length > maxlength)
//                {
//                    maxlength = mySelect[i].text.length;
//                }
//            }
//            mySelect.style.width = maxlength * 7;
//            }
//        }
        
    function isIE6()
      {
        isIE6 = /msie|MSIE 6/.test(navigator.userAgent);
        return isIE6;
      }

