function get_subcategory() {
    /*$('#other').html(''); 
    if ($('#category option:selected').text() == 'other') {
        $('#subcategory').html('Suggest A Category: <br /><input type="text" name="other" maxlength="20"  size="29" />');     
    }

    else {
    var loadUrl = "/ilist/getsubcategories/";
    $.ajaxSetup ({
        cache: false
    });
    
        var ajax_load = "<img src='/assets/images/loading2.gif' alt='loading...' />";
         $('#subcategory')
                            .html(ajax_load).load(loadUrl)
                            .load(loadUrl, { catID: $('#category').val()});
    } */
            
    if ($('#category option:selected').text() == 'other') {            
        $('#subcategory').html('Suggest A Category: <br /><input type="text" name="other" maxlength="20"  size="29" />');     
    } else {
            $('#subcategory').html("<img src='/assets/images/loading2.gif' alt='loading...' />");
            $.ajax({ 
                url: '/ilist/getsubcategories/', 
                cache: false,
                type: "POST", 
                data:  "catID="+$('#category').val(),
                success: function(msg){
                    $('#subcategory').html(msg);
                } 
            });    
    }
    
   
}

function get_other() {
    
    /*
    if ($('#subCategory option:selected').text() == 'other') {
        $('#other').html('Suggest A SubCategory: <br /><input type="text" name="other"  maxlength="20" size="29" />');     
    }
    else if ($('#subCategoryStatic option:selected').text() == 'other') {
        $('#other').html('Suggest A SubCategory: <br /><input type="text" name="other"  maxlength="20" size="29" />');     
    }
    else {
       $('#other').html(''); 
    } 
    */
}

$(document).ready(function(){
    $("#geteBay").click(function() {
        geteBayItem();
    });
});
function geteBayItem() {
    //$("#geteBay").click(function() {
        //alert('sadfasdf');
            $.ajax({ 
                url: '/transport/ebay/', 
                cache: false,
                type: "POST", 
                data:  "id="+$('#ebayitemno').val()+"&user="+$('#ebayusername').val()+"&i="+$("#countid"),
                success: function(msg){
                    //alert(msg);
                    if (msg == 'wrongnull') {
                        alert('Invalid eBay Username or Item number!');
                    } else {
                            obj = jQuery.parseJSON(msg);
                           if ( (obj === null) ) {
                               alert('Invalid eBay Username or Item number!');                       
                           } else {
                               //alert(obj);
                               //if (obj.status == 'Active') {
                                   $("#shipmentName").val(obj.ebayName);
                                   $("#itemDescription1").val(obj.ebayName);
                                   $("#pickupAddressPostCode").val(obj.postcode);
                                   $("#isEbay").val('Y');
                                   $("#ebayId").val(obj.ebayId);
                                   $("#ebayUser").val(obj.ebayUser);
                                   //$("#ebayType").val(obj.seller);
                                   $("#ebaySeller").val(obj.seller);
                                   
                                   if ($("#category").val() == '') { $("#category").css('background-color','#FBE6F2'); }
                                   $("#deliveryAddressPostCode").css('background-color','#FBE6F2');
                                   $(".listingDatesLabelText").css('background-color','#FBE6F2');
                                   $("#security_code").css('background-color','#FBE6F2');
                                   if (obj.postcode == '') {
                                       $("#pickupAddressPostCode").css('background-color','#FBE6F2');
                                   } 
                                      /*
                                   if ( (obj.endtime != '') && (obj.starttime != '') ) {
                                       $("#deliveryTimeChoice").attr('checked','checked');
                                       $("#noDeliveryTimeChoice").removeAttr('checked');
                                       $("#deliveryTimeChoices").css('display','block');
                                       $("#deliveryT1").val(obj.starttime);
                                       $("#deliveryT2").val(obj.endtime);
                                       
                                   }    */

                                   if (obj.image != '') {
                                        $.ajax({ 
                                            url: '/transport/ebayimage/', 
                                            cache: false,
                                            type: "POST", 
                                            data:  "img="+$.toJSON(obj.image),
                                            success: function(msg){
                                                //alert(msg);
                                                imgObj = jQuery.parseJSON(msg);
                                                
                                                //alert(obj.image);
                                                
                                                jQuery.each(imgObj,function (id,name) {
                                                    img = '<li id="listImage' + id + '" style="float:left;margin-right:10px;text-align:center;"><div style="height:150px;"><img src="/assets/images/uploads/temp/150x150_' + name +'" /></div><br /><a href="javascript:removeImage('+ id +')"  ><img alt="Remove item" src="/assets/images/delete-icon.png" style="vertical-align:middle;"/> Remove</a></li>';
                                                    $("#imageListUL").append(img);
                                                    i++;
                                                })
                                                
                                                $("#nr").val(i+1);
                                            } 
                                        }); 
                                   }
                               /*} else {
                                   alert('eBay listing status is no longer active!');
                               } */
                           }               
                        
                        } 
                }
            });         


            


        return false;
//    });
//});
}
