/* 
Function created by Anis Ahmad from

http://www.ajaxray.com/blog/2007/11/08/jquery-controlled-dependent-or-cascading-select-list-2/

Adapted by Mark Steer of igeek 17/04/2009
*/
function makeSublist(parent,child,isSubselectOptional,childVal) {
    $("body").append("<select style='display:none' id='"+parent+child+"'></select>");
    $('#'+parent+child).html($("#"+child+" option"));
    
    var parentValue = $('#'+parent).attr('value');
    $('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
    
    childVal = (typeof childVal == "undefined")? "" : childVal ;
    $("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');
    
    $('#'+parent).change( 
        function() {
            var parentValue = $('#'+parent).attr('value');
            $('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
            if(isSubselectOptional) 
            $('#'+child).prepend("<option value=''> Please Choose </option>");
            $('#'+child).trigger("change"); 
            $('#'+child).focus();
        }
    );
}
/*
    $(document).ready(function()
    {
        makeSublist('model','body', false, '1');
    });
*/
