$(document).ready(function() {
initCluetip();
});

function initCluetip() {
    $('img.link').cluetip({
        arrows: false,
        dropShadow: false,
        cluetipClass: 'jtipnew',
        showTitle: false
    });
    $('span.assetlink').cluetip({
        arrows: false,
        dropShadow: false,
        cluetipClass: 'jtipnew',
        showTitle: false
    });
}

window.afterInitTable = function () {
    InitResizableGrid('table.resizable-grid', getHeightTableHolder(95));
    
    var readonly = $('#assetread').val();
    if (readonly == 'True') {
        //$('th.cb').remove();
        //$('td.cb').remove();
        $('td a.openlink').each(function() {
        var link = $(this);
            var span = link.find('span');
            link.parent().append(span);
            link.remove();
            $('td span').removeClass('normal');
        });
    }
    initCluetip();
};

function assetDetails(e, id) {
    if (!e)
        e = window.event;

    if (e.cancelBubble)
        e.cancelBubble = true;
    else if (e.stopPropagation)
        e.stopPropagation();

    openDialog('assettable.ivp/view/' + id + '?popup=true&read=true', '', { width: 980, height: 650 });
    return false;
}

function userDetails(e, id) {
    if (!e)
        e = window.event;

    if (e.cancelBubble)
        e.cancelBubble = true;
    else if (e.stopPropagation)
        e.stopPropagation();

    openDialog('user.ivp/viewhash/' + id + '?popup=true', '', { width: 980, height: 650 });
    return false;
}

function userDetails(hashid) {
    openDialog('user.ivp/viewhash/' + hashid + '?popup=true', 'viewhash');
    return false;
}

function companyDetailsHash(hashid) {
    window.open(base + 'company.ivp/viewhash/' + hashid);
    //openDialog('company.ivp/viewhash/' + hashid + '?popup=true');
    return false;
}

function assetSelected(aids) {
    var ms = jQuery.multipleSelects[filterName];
    $(aids.split(',')).each(function(i, id) {
    var an = dlg.AssetName['an' + id.toString()];
        if ($('option[value="' + id + '"]', ms.select).length > 0) return;
        ms.select.append('<option selected value="' + id + '">' + an + '</option>');
        ms.addOption(id, an, true);
        ms.optionsToString();
        ms.select.trigger('change');
    });
}