function $(id){return document.getElementById(id);}

function onRootConvChanged(root,sub)
{
    var subsel=$(sub);
    if(subsel.selectedIndex > -1) 
    {
        //删除原有的
        for(var i=1;i<subsel.options.length;i++)
        {
            subsel.remove(i);
            i = i - 1;//索引减1
        }
        
        var subid=GetUrlParam('subid1');
        
        //添加
        if(root.selectedIndex>0)
        { 
            var subcategories=eval('cate_'+root.value);
            if(subcategories!=null && subcategories!='')
            {
                for(var j=0;j<subcategories.length;j++)
                {
                    var oOption = document.createElement("option");
                    oOption.appendChild(document.createTextNode(subcategories[j][1]));
                    oOption.setAttribute("value", subcategories[j][0]);
                    if(subcategories[j][0]==subid)
                    {
                        oOption.setAttribute("selected", true);
                    }
                    subsel.appendChild(oOption);
                }
            }
        }
    }
}
function GetUrlParam(paramName)
{
    var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
    var oMatch = oRegex.exec( window.location.search ) ;
    if ( oMatch && oMatch.length > 1 )
        return oMatch[1] ;
    else
        return '' ;
}


